1 #ifndef _IEEE1394_CORE_H
2 #define _IEEE1394_CORE_H
4 #include <linux/device.h>
6 #include <linux/list.h>
7 #include <linux/types.h>
8 #include <asm/atomic.h>
11 #include "ieee1394_types.h"
14 /* This struct is basically read-only for hosts with the exception of
15 * the data buffer contents and driver_list. */
17 /* This can be used for host driver internal linking.
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;
27 /* Async and Iso types should be clear, raw means send-as-is, do not
28 * CRC! Byte swapping shall still be done in this case. */
29 enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type;
31 /* Okay, this is core internal and a no care for hosts.
32 * queued = queued for sending
33 * pending = sent, waiting for response
34 * complete = processing completed, successful or not
37 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
38 } __attribute__((packed)) state;
40 /* These are core internal. */
45 unsigned expect_response:1;
48 /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
49 unsigned speed_code:2;
51 struct hpsb_host *host;
52 unsigned int generation;
55 struct list_head queue;
57 /* Function (and possible data to pass to it) to call when this
58 * packet is completed. */
59 void (*complete_routine)(void *);
62 /* Store jiffies for implementing bus timeouts. */
63 unsigned long sendtime;
65 /* Sizes are in bytes. *data can be DMA-mapped. */
66 size_t allocated_data_size; /* as allocated */
67 size_t data_size; /* as filled in */
68 size_t header_size; /* as filled in, not counting the CRC */
71 quadlet_t embedded_data[0]; /* keep as last member */
74 void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
75 void (*routine)(void *), void *data);
76 static inline struct hpsb_packet *driver_packet(struct list_head *l)
78 return list_entry(l, struct hpsb_packet, driver_list);
80 void abort_timedouts(unsigned long __opaque);
81 struct hpsb_packet *hpsb_alloc_packet(size_t data_size);
82 void hpsb_free_packet(struct hpsb_packet *packet);
85 * get_hpsb_generation - generation counter for the complete 1394 subsystem
87 * Generation gets incremented on every change in the subsystem (notably on bus
88 * resets). Use the functions, not the variable.
90 static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
92 return atomic_read(&host->generation);
95 int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt);
96 int hpsb_send_packet(struct hpsb_packet *packet);
97 int hpsb_send_packet_and_wait(struct hpsb_packet *packet);
98 int hpsb_reset_bus(struct hpsb_host *host, int type);
99 int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
102 int hpsb_bus_reset(struct hpsb_host *host);
103 void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid);
104 void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
105 void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
107 void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
111 * CHARACTER DEVICE DISPATCHING
113 * All ieee1394 character device drivers share the same major number
114 * (major 171). The 256 minor numbers are allocated to the various
115 * task-specific interfaces (raw1394, video1394, dv1394, etc) in
118 * The core ieee1394.o module allocates the device number region
119 * 171:0-255, the various drivers must then cdev_add() their cdev
120 * objects to handle their respective sub-regions.
122 * Minor device number block allocations:
124 * Block 0 ( 0- 15) raw1394
125 * Block 1 ( 16- 31) video1394
126 * Block 2 ( 32- 47) dv1394
128 * Blocks 3-14 free for future allocation
130 * Block 15 (240-255) reserved for drivers under development, etc.
133 #define IEEE1394_MAJOR 171
135 #define IEEE1394_MINOR_BLOCK_RAW1394 0
136 #define IEEE1394_MINOR_BLOCK_VIDEO1394 1
137 #define IEEE1394_MINOR_BLOCK_DV1394 2
138 #define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
140 #define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0)
141 #define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, \
142 IEEE1394_MINOR_BLOCK_RAW1394 * 16)
143 #define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, \
144 IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
145 #define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, \
146 IEEE1394_MINOR_BLOCK_DV1394 * 16)
147 #define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \
148 IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
151 * ieee1394_file_to_instance - get the index within a minor number block
153 static inline unsigned char ieee1394_file_to_instance(struct file *file)
155 return file->f_path.dentry->d_inode->i_cindex;
158 extern int hpsb_disable_irm;
160 /* Our sysfs bus entry */
161 extern struct bus_type ieee1394_bus_type;
162 extern struct class hpsb_host_class;
163 extern struct class *hpsb_protocol_class;
165 #endif /* _IEEE1394_CORE_H */