Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _IEEE1394_CORE_H |
2 | #define _IEEE1394_CORE_H | |
3 | ||
de4394f1 SR |
4 | #include <linux/device.h> |
5 | #include <linux/fs.h> | |
6 | #include <linux/list.h> | |
de4394f1 | 7 | #include <linux/types.h> |
1da177e4 | 8 | #include <asm/atomic.h> |
1da177e4 | 9 | |
de4394f1 SR |
10 | #include "hosts.h" |
11 | #include "ieee1394_types.h" | |
1da177e4 LT |
12 | |
13 | struct hpsb_packet { | |
741854e4 | 14 | /* This struct is basically read-only for hosts with the exception of |
7542e0e6 | 15 | * the data buffer contents and driver_list. */ |
1da177e4 LT |
16 | |
17 | /* This can be used for host driver internal linking. | |
18 | * | |
19 | * NOTE: This must be left in init state when the driver is done | |
20 | * with it (e.g. by using list_del_init()), since the core does | |
21 | * some sanity checks to make sure the packet is not on a | |
22 | * driver_list when free'ing it. */ | |
23 | struct list_head driver_list; | |
24 | ||
741854e4 | 25 | nodeid_t node_id; |
1da177e4 | 26 | |
53c96b41 SR |
27 | /* hpsb_raw = send as-is, do not CRC (but still byte-swap it) */ |
28 | enum { hpsb_async, hpsb_raw } __attribute__((packed)) type; | |
1da177e4 | 29 | |
741854e4 SR |
30 | /* Okay, this is core internal and a no care for hosts. |
31 | * queued = queued for sending | |
32 | * pending = sent, waiting for response | |
33 | * complete = processing completed, successful or not | |
34 | */ | |
35 | enum { | |
36 | hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete | |
37 | } __attribute__((packed)) state; | |
1da177e4 | 38 | |
6552731a | 39 | /* These are core-internal. */ |
741854e4 | 40 | signed char tlabel; |
07bbeaf1 LT |
41 | signed char ack_code; |
42 | unsigned char tcode; | |
1da177e4 | 43 | |
741854e4 SR |
44 | unsigned expect_response:1; |
45 | unsigned no_waiter:1; | |
1da177e4 | 46 | |
741854e4 SR |
47 | /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */ |
48 | unsigned speed_code:2; | |
1da177e4 | 49 | |
741854e4 SR |
50 | struct hpsb_host *host; |
51 | unsigned int generation; | |
1da177e4 LT |
52 | |
53 | atomic_t refcnt; | |
7542e0e6 | 54 | struct list_head queue; |
1da177e4 LT |
55 | |
56 | /* Function (and possible data to pass to it) to call when this | |
57 | * packet is completed. */ | |
58 | void (*complete_routine)(void *); | |
59 | void *complete_data; | |
60 | ||
741854e4 SR |
61 | /* Store jiffies for implementing bus timeouts. */ |
62 | unsigned long sendtime; | |
1da177e4 | 63 | |
6552731a | 64 | /* Core-internal. */ |
7542e0e6 | 65 | size_t allocated_data_size; /* as allocated */ |
6552731a SR |
66 | |
67 | /* Sizes are in bytes. To be set by caller of hpsb_alloc_packet. */ | |
7542e0e6 SR |
68 | size_t data_size; /* as filled in */ |
69 | size_t header_size; /* as filled in, not counting the CRC */ | |
6552731a SR |
70 | |
71 | /* Buffers */ | |
72 | quadlet_t *data; /* can be DMA-mapped */ | |
7542e0e6 SR |
73 | quadlet_t header[5]; |
74 | quadlet_t embedded_data[0]; /* keep as last member */ | |
1da177e4 LT |
75 | }; |
76 | ||
1da177e4 | 77 | void hpsb_set_packet_complete_task(struct hpsb_packet *packet, |
e1d118f1 | 78 | void (*routine)(void *), void *data); |
1da177e4 LT |
79 | static inline struct hpsb_packet *driver_packet(struct list_head *l) |
80 | { | |
81 | return list_entry(l, struct hpsb_packet, driver_list); | |
82 | } | |
1da177e4 | 83 | void abort_timedouts(unsigned long __opaque); |
1da177e4 LT |
84 | struct hpsb_packet *hpsb_alloc_packet(size_t data_size); |
85 | void hpsb_free_packet(struct hpsb_packet *packet); | |
86 | ||
afd6546d SR |
87 | /** |
88 | * get_hpsb_generation - generation counter for the complete 1394 subsystem | |
1da177e4 | 89 | * |
afd6546d SR |
90 | * Generation gets incremented on every change in the subsystem (notably on bus |
91 | * resets). Use the functions, not the variable. | |
1da177e4 LT |
92 | */ |
93 | static inline unsigned int get_hpsb_generation(struct hpsb_host *host) | |
94 | { | |
741854e4 | 95 | return atomic_read(&host->generation); |
1da177e4 LT |
96 | } |
97 | ||
1da177e4 | 98 | int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt); |
1da177e4 | 99 | int hpsb_send_packet(struct hpsb_packet *packet); |
1da177e4 | 100 | int hpsb_send_packet_and_wait(struct hpsb_packet *packet); |
1da177e4 | 101 | int hpsb_reset_bus(struct hpsb_host *host, int type); |
3dc5ea9b PP |
102 | int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer, |
103 | u64 *local_time); | |
104 | ||
1da177e4 | 105 | int hpsb_bus_reset(struct hpsb_host *host); |
1da177e4 | 106 | void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid); |
1da177e4 | 107 | void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot); |
1da177e4 | 108 | void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, |
741854e4 | 109 | int ackcode); |
1da177e4 | 110 | void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, |
741854e4 | 111 | int write_acked); |
1da177e4 | 112 | |
1da177e4 LT |
113 | /* |
114 | * CHARACTER DEVICE DISPATCHING | |
115 | * | |
116 | * All ieee1394 character device drivers share the same major number | |
117 | * (major 171). The 256 minor numbers are allocated to the various | |
118 | * task-specific interfaces (raw1394, video1394, dv1394, etc) in | |
119 | * blocks of 16. | |
120 | * | |
121 | * The core ieee1394.o module allocates the device number region | |
122 | * 171:0-255, the various drivers must then cdev_add() their cdev | |
123 | * objects to handle their respective sub-regions. | |
124 | * | |
125 | * Minor device number block allocations: | |
126 | * | |
127 | * Block 0 ( 0- 15) raw1394 | |
128 | * Block 1 ( 16- 31) video1394 | |
129 | * Block 2 ( 32- 47) dv1394 | |
130 | * | |
131 | * Blocks 3-14 free for future allocation | |
132 | * | |
133 | * Block 15 (240-255) reserved for drivers under development, etc. | |
134 | */ | |
135 | ||
741854e4 | 136 | #define IEEE1394_MAJOR 171 |
1da177e4 | 137 | |
741854e4 SR |
138 | #define IEEE1394_MINOR_BLOCK_RAW1394 0 |
139 | #define IEEE1394_MINOR_BLOCK_VIDEO1394 1 | |
140 | #define IEEE1394_MINOR_BLOCK_DV1394 2 | |
1da177e4 LT |
141 | #define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15 |
142 | ||
741854e4 | 143 | #define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) |
e1d118f1 SR |
144 | #define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, \ |
145 | IEEE1394_MINOR_BLOCK_RAW1394 * 16) | |
146 | #define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, \ | |
147 | IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) | |
148 | #define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, \ | |
149 | IEEE1394_MINOR_BLOCK_DV1394 * 16) | |
150 | #define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \ | |
151 | IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) | |
1da177e4 | 152 | |
afd6546d SR |
153 | /** |
154 | * ieee1394_file_to_instance - get the index within a minor number block | |
155 | */ | |
1da177e4 LT |
156 | static inline unsigned char ieee1394_file_to_instance(struct file *file) |
157 | { | |
4db61081 | 158 | return file->f_path.dentry->d_inode->i_cindex; |
1da177e4 LT |
159 | } |
160 | ||
161 | extern int hpsb_disable_irm; | |
162 | ||
163 | /* Our sysfs bus entry */ | |
164 | extern struct bus_type ieee1394_bus_type; | |
165 | extern struct class hpsb_host_class; | |
7e25ab91 | 166 | extern struct class *hpsb_protocol_class; |
1da177e4 LT |
167 | |
168 | #endif /* _IEEE1394_CORE_H */ |