Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef IEEE1394_HIGHLEVEL_H |
| 2 | #define IEEE1394_HIGHLEVEL_H |
| 3 | |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame] | 4 | #include <linux/list.h> |
| 5 | #include <linux/spinlock_types.h> |
| 6 | #include <linux/types.h> |
| 7 | |
| 8 | struct module; |
| 9 | |
| 10 | #include "ieee1394_types.h" |
| 11 | |
| 12 | struct hpsb_host; |
| 13 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 14 | /* internal to ieee1394 core */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | struct hpsb_address_serve { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 16 | struct list_head host_list; /* per host list */ |
| 17 | struct list_head hl_list; /* hpsb_highlevel list */ |
| 18 | struct hpsb_address_ops *op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | struct hpsb_host *host; |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 20 | u64 start; /* first address handled, quadlet aligned */ |
| 21 | u64 end; /* first address behind, quadlet aligned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | }; |
| 23 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 24 | /* Only the following structures are of interest to actual highlevel drivers. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | struct hpsb_highlevel { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | const char *name; |
| 28 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 29 | /* Any of the following pointers can legally be NULL, except for |
| 30 | * iso_receive which can only be NULL when you don't request |
| 31 | * channels. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 33 | /* New host initialized. Will also be called during |
| 34 | * hpsb_register_highlevel for all hosts already installed. */ |
| 35 | void (*add_host)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 37 | /* Host about to be removed. Will also be called during |
| 38 | * hpsb_unregister_highlevel once for each host. */ |
| 39 | void (*remove_host)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 41 | /* Host experienced bus reset with possible configuration changes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | * Note that this one may occur during interrupt/bottom half handling. |
| 43 | * You can not expect to be able to do stock hpsb_reads. */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 44 | void (*host_reset)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 46 | /* An isochronous packet was received. Channel contains the channel |
| 47 | * number for your convenience, it is also contained in the included |
| 48 | * packet header (first quadlet, CRCs are missing). You may get called |
| 49 | * for channel/host combinations you did not request. */ |
| 50 | void (*iso_receive)(struct hpsb_host *host, int channel, |
| 51 | quadlet_t *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 53 | /* A write request was received on either the FCP_COMMAND (direction = |
| 54 | * 0) or the FCP_RESPONSE (direction = 1) register. The cts arg |
| 55 | * contains the cts field (first byte of data). */ |
| 56 | void (*fcp_request)(struct hpsb_host *host, int nodeid, int direction, |
| 57 | int cts, u8 *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* These are initialized by the subsystem when the |
| 60 | * hpsb_higlevel is registered. */ |
| 61 | struct list_head hl_list; |
| 62 | struct list_head irq_list; |
| 63 | struct list_head addr_list; |
| 64 | |
| 65 | struct list_head host_info_list; |
| 66 | rwlock_t host_info_lock; |
| 67 | }; |
| 68 | |
| 69 | struct hpsb_address_ops { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 70 | /* |
| 71 | * Null function pointers will make the respective operation complete |
| 72 | * with RCODE_TYPE_ERROR. Makes for easy to implement read-only |
| 73 | * registers (just leave everything but read NULL). |
| 74 | * |
| 75 | * All functions shall return appropriate IEEE 1394 rcodes. |
| 76 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 78 | /* These functions have to implement block reads for themselves. |
| 79 | * |
| 80 | * These functions either return a response code or a negative number. |
| 81 | * In the first case a response will be generated. In the latter case, |
| 82 | * no response will be sent and the driver which handled the request |
| 83 | * will send the response itself. */ |
| 84 | int (*read)(struct hpsb_host *host, int nodeid, quadlet_t *buffer, |
| 85 | u64 addr, size_t length, u16 flags); |
| 86 | int (*write)(struct hpsb_host *host, int nodeid, int destid, |
| 87 | quadlet_t *data, u64 addr, size_t length, u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 89 | /* Lock transactions: write results of ext_tcode operation into |
| 90 | * *store. */ |
| 91 | int (*lock)(struct hpsb_host *host, int nodeid, quadlet_t *store, |
| 92 | u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, |
| 93 | u16 flags); |
| 94 | int (*lock64)(struct hpsb_host *host, int nodeid, octlet_t *store, |
| 95 | u64 addr, octlet_t data, octlet_t arg, int ext_tcode, |
| 96 | u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | void highlevel_add_host(struct hpsb_host *host); |
| 100 | void highlevel_remove_host(struct hpsb_host *host); |
| 101 | void highlevel_host_reset(struct hpsb_host *host); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 102 | int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr, |
| 103 | unsigned int length, u16 flags); |
| 104 | int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data, |
| 105 | u64 addr, unsigned int length, u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 107 | u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, |
| 108 | u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 110 | u64 addr, octlet_t data, octlet_t arg, int ext_tcode, |
| 111 | u16 flags); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 112 | void highlevel_iso_receive(struct hpsb_host *host, void *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 114 | void *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | void hpsb_register_highlevel(struct hpsb_highlevel *hl); |
| 117 | void hpsb_unregister_highlevel(struct hpsb_highlevel *hl); |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, |
| 120 | struct hpsb_host *host, |
| 121 | struct hpsb_address_ops *ops, |
| 122 | u64 size, u64 alignment, |
| 123 | u64 start, u64 end); |
| 124 | int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 125 | struct hpsb_address_ops *ops, u64 start, u64 end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 127 | u64 start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | int hpsb_listen_channel(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | afd6546 | 2007-03-05 03:06:23 +0100 | [diff] [blame] | 129 | unsigned int channel); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | void hpsb_unlisten_channel(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 131 | unsigned int channel); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 135 | size_t data_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 137 | void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 138 | unsigned long key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 140 | int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 141 | void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #endif /* IEEE1394_HIGHLEVEL_H */ |