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> |
Stefan Richter | 055a7da | 2008-05-19 22:07:28 +0200 | [diff] [blame] | 5 | #include <linux/spinlock.h> |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame] | 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 */ |
Stefan Richter | b17a550 | 2008-11-26 01:35:21 +0100 | [diff] [blame] | 18 | const 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 | 53c96b4 | 2007-06-24 15:31:54 +0200 | [diff] [blame] | 29 | /* Any of the following pointers can legally be NULL. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 31 | /* New host initialized. Will also be called during |
| 32 | * hpsb_register_highlevel for all hosts already installed. */ |
| 33 | void (*add_host)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 35 | /* Host about to be removed. Will also be called during |
| 36 | * hpsb_unregister_highlevel once for each host. */ |
| 37 | void (*remove_host)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 39 | /* Host experienced bus reset with possible configuration changes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | * Note that this one may occur during interrupt/bottom half handling. |
| 41 | * You can not expect to be able to do stock hpsb_reads. */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 42 | void (*host_reset)(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 44 | /* A write request was received on either the FCP_COMMAND (direction = |
| 45 | * 0) or the FCP_RESPONSE (direction = 1) register. The cts arg |
| 46 | * contains the cts field (first byte of data). */ |
| 47 | void (*fcp_request)(struct hpsb_host *host, int nodeid, int direction, |
| 48 | int cts, u8 *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /* These are initialized by the subsystem when the |
| 51 | * hpsb_higlevel is registered. */ |
| 52 | struct list_head hl_list; |
| 53 | struct list_head irq_list; |
| 54 | struct list_head addr_list; |
| 55 | |
| 56 | struct list_head host_info_list; |
| 57 | rwlock_t host_info_lock; |
| 58 | }; |
| 59 | |
| 60 | struct hpsb_address_ops { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 61 | /* |
| 62 | * Null function pointers will make the respective operation complete |
| 63 | * with RCODE_TYPE_ERROR. Makes for easy to implement read-only |
| 64 | * registers (just leave everything but read NULL). |
| 65 | * |
| 66 | * All functions shall return appropriate IEEE 1394 rcodes. |
| 67 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 69 | /* These functions have to implement block reads for themselves. |
| 70 | * |
| 71 | * These functions either return a response code or a negative number. |
| 72 | * In the first case a response will be generated. In the latter case, |
| 73 | * no response will be sent and the driver which handled the request |
| 74 | * will send the response itself. */ |
| 75 | int (*read)(struct hpsb_host *host, int nodeid, quadlet_t *buffer, |
| 76 | u64 addr, size_t length, u16 flags); |
| 77 | int (*write)(struct hpsb_host *host, int nodeid, int destid, |
| 78 | quadlet_t *data, u64 addr, size_t length, u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 80 | /* Lock transactions: write results of ext_tcode operation into |
| 81 | * *store. */ |
| 82 | int (*lock)(struct hpsb_host *host, int nodeid, quadlet_t *store, |
| 83 | u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, |
| 84 | u16 flags); |
| 85 | int (*lock64)(struct hpsb_host *host, int nodeid, octlet_t *store, |
| 86 | u64 addr, octlet_t data, octlet_t arg, int ext_tcode, |
| 87 | u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | void highlevel_add_host(struct hpsb_host *host); |
| 91 | void highlevel_remove_host(struct hpsb_host *host); |
| 92 | void highlevel_host_reset(struct hpsb_host *host); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 93 | int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr, |
| 94 | unsigned int length, u16 flags); |
| 95 | int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data, |
| 96 | u64 addr, unsigned int length, u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 98 | u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, |
| 99 | u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 101 | u64 addr, octlet_t data, octlet_t arg, int ext_tcode, |
| 102 | u16 flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 104 | void *data, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Stefan Richter | 055a7da | 2008-05-19 22:07:28 +0200 | [diff] [blame] | 106 | /** |
| 107 | * hpsb_init_highlevel - initialize a struct hpsb_highlevel |
| 108 | * |
| 109 | * This is only necessary if hpsb_get_hostinfo_bykey can be called |
| 110 | * before hpsb_register_highlevel. |
| 111 | */ |
| 112 | static inline void hpsb_init_highlevel(struct hpsb_highlevel *hl) |
| 113 | { |
| 114 | rwlock_init(&hl->host_info_lock); |
| 115 | INIT_LIST_HEAD(&hl->host_info_list); |
| 116 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | void hpsb_register_highlevel(struct hpsb_highlevel *hl); |
| 118 | void hpsb_unregister_highlevel(struct hpsb_highlevel *hl); |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, |
| 121 | struct hpsb_host *host, |
Stefan Richter | b17a550 | 2008-11-26 01:35:21 +0100 | [diff] [blame] | 122 | const struct hpsb_address_ops *ops, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | u64 size, u64 alignment, |
| 124 | u64 start, u64 end); |
| 125 | int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | b17a550 | 2008-11-26 01:35:21 +0100 | [diff] [blame] | 126 | const struct hpsb_address_ops *ops, |
| 127 | u64 start, u64 end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 129 | u64 start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 133 | size_t data_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 135 | void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 136 | unsigned long key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key); |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 138 | int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, |
| 139 | void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | #endif /* IEEE1394_HIGHLEVEL_H */ |