Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _IEEE1394_HOSTS_H |
| 2 | #define _IEEE1394_HOSTS_H |
| 3 | |
| 4 | #include <linux/device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/list.h> |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame] | 6 | #include <linux/timer.h> |
| 7 | #include <linux/types.h> |
| 8 | #include <linux/workqueue.h> |
| 9 | #include <asm/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame] | 11 | struct pci_dev; |
| 12 | struct module; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include "ieee1394_types.h" |
| 15 | #include "csr.h" |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | struct hpsb_packet; |
| 18 | struct hpsb_iso; |
| 19 | |
| 20 | struct hpsb_host { |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 21 | struct list_head host_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 23 | void *hostdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 25 | atomic_t generation; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Stefan Richter | 7542e0e | 2007-03-25 22:22:40 +0200 | [diff] [blame] | 27 | struct list_head pending_packets; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | struct timer_list timeout; |
| 29 | unsigned long timeout_interval; |
| 30 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 31 | unsigned char iso_listen_count[64]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Ben Collins | eaf8845 | 2006-06-12 18:12:49 -0400 | [diff] [blame] | 33 | int node_count; /* number of identified nodes on this bus */ |
| 34 | int selfid_count; /* total number of SelfIDs received */ |
| 35 | int nodes_active; /* number of nodes with active link layer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Ben Collins | eaf8845 | 2006-06-12 18:12:49 -0400 | [diff] [blame] | 37 | nodeid_t node_id; /* node ID of this host */ |
| 38 | nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ |
| 39 | nodeid_t busmgr_id; /* ID of this bus' bus manager */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 41 | /* this nodes state */ |
| 42 | unsigned in_bus_reset:1; |
| 43 | unsigned is_shutdown:1; |
Stefan Richter | 14c0fa2 | 2005-12-01 18:51:52 -0500 | [diff] [blame] | 44 | unsigned resume_packet_sent:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 46 | /* this nodes' duties on the bus */ |
| 47 | unsigned is_root:1; |
| 48 | unsigned is_cycmst:1; |
| 49 | unsigned is_irm:1; |
| 50 | unsigned is_busmgr:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 52 | int reset_retries; |
| 53 | quadlet_t *topology_map; |
| 54 | u8 *speed_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | int id; |
Stefan Richter | 9951903 | 2006-07-02 14:17:00 +0200 | [diff] [blame] | 57 | struct hpsb_host_driver *driver; |
| 58 | struct pci_dev *pdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | struct device device; |
Kay Sievers | dd7f292 | 2007-05-25 11:50:53 +0200 | [diff] [blame^] | 60 | struct device host_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 62 | struct delayed_work delayed_reset; |
Stefan Richter | d06170a | 2007-01-07 21:51:48 +0100 | [diff] [blame] | 63 | unsigned config_roms:31; |
| 64 | unsigned update_config_rom:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | struct list_head addr_space; |
Ben Collins | 8aef63f | 2006-06-12 18:13:21 -0400 | [diff] [blame] | 67 | u64 low_addr_space; /* upper bound of physical DMA area */ |
| 68 | u64 middle_addr_space; /* upper bound of posted write area */ |
Stefan Richter | 9951903 | 2006-07-02 14:17:00 +0200 | [diff] [blame] | 69 | |
| 70 | u8 speed[ALL_NODES]; /* speed between each node and local node */ |
| 71 | |
| 72 | /* per node tlabel allocation */ |
| 73 | u8 next_tl[ALL_NODES]; |
| 74 | struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES]; |
| 75 | |
| 76 | struct csr_control csr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | enum devctl_cmd { |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 80 | /* Host is requested to reset its bus and cancel all outstanding async |
| 81 | * requests. If arg == 1, it shall also attempt to become root on the |
| 82 | * bus. Return void. */ |
| 83 | RESET_BUS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 85 | /* Arg is void, return value is the hardware cycle counter value. */ |
| 86 | GET_CYCLE_COUNTER, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 88 | /* Set the hardware cycle counter to the value in arg, return void. |
| 89 | * FIXME - setting is probably not required. */ |
| 90 | SET_CYCLE_COUNTER, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 92 | /* Configure hardware for new bus ID in arg, return void. */ |
| 93 | SET_BUS_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 95 | /* If arg true, start sending cycle start packets, stop if arg == 0. |
| 96 | * Return void. */ |
| 97 | ACT_CYCLE_MASTER, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 99 | /* Cancel all outstanding async requests without resetting the bus. |
| 100 | * Return void. */ |
| 101 | CANCEL_REQUESTS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 103 | /* Start or stop receiving isochronous channel in arg. Return void. |
| 104 | * This acts as an optimization hint, hosts are not required not to |
| 105 | * listen on unrequested channels. */ |
| 106 | ISO_LISTEN_CHANNEL, |
| 107 | ISO_UNLISTEN_CHANNEL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | enum isoctl_cmd { |
| 111 | /* rawiso API - see iso.h for the meanings of these commands |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 112 | * (they correspond exactly to the hpsb_iso_* API functions) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | * INIT = allocate resources |
| 114 | * START = begin transmission/reception |
| 115 | * STOP = halt transmission/reception |
| 116 | * QUEUE/RELEASE = produce/consume packets |
| 117 | * SHUTDOWN = deallocate resources |
| 118 | */ |
| 119 | |
| 120 | XMIT_INIT, |
| 121 | XMIT_START, |
| 122 | XMIT_STOP, |
| 123 | XMIT_QUEUE, |
| 124 | XMIT_SHUTDOWN, |
| 125 | |
| 126 | RECV_INIT, |
| 127 | RECV_LISTEN_CHANNEL, /* multi-channel only */ |
| 128 | RECV_UNLISTEN_CHANNEL, /* multi-channel only */ |
| 129 | RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */ |
| 130 | RECV_START, |
| 131 | RECV_STOP, |
| 132 | RECV_RELEASE, |
| 133 | RECV_SHUTDOWN, |
| 134 | RECV_FLUSH |
| 135 | }; |
| 136 | |
| 137 | enum reset_types { |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 138 | /* 166 microsecond reset -- only type of reset available on |
| 139 | non-1394a capable controllers */ |
| 140 | LONG_RESET, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 142 | /* Short (arbitrated) reset -- only available on 1394a capable |
| 143 | controllers */ |
| 144 | SHORT_RESET, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Jody McIntyre | 3256cc1 | 2005-09-30 11:59:16 -0700 | [diff] [blame] | 146 | /* Variants that set force_root before issueing the bus reset */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, |
| 148 | |
Jody McIntyre | 3256cc1 | 2005-09-30 11:59:16 -0700 | [diff] [blame] | 149 | /* Variants that clear force_root before issueing the bus reset */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT |
| 151 | }; |
| 152 | |
| 153 | struct hpsb_host_driver { |
| 154 | struct module *owner; |
| 155 | const char *name; |
| 156 | |
| 157 | /* The hardware driver may optionally support a function that is used |
| 158 | * to set the hardware ConfigROM if the hardware supports handling |
| 159 | * reads to the ConfigROM on its own. */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 160 | void (*set_hw_config_rom)(struct hpsb_host *host, |
| 161 | quadlet_t *config_rom); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 163 | /* This function shall implement packet transmission based on |
| 164 | * packet->type. It shall CRC both parts of the packet (unless |
| 165 | * packet->type == raw) and do byte-swapping as necessary or instruct |
| 166 | * the hardware to do so. It can return immediately after the packet |
| 167 | * was queued for sending. After sending, hpsb_sent_packet() has to be |
| 168 | * called. Return 0 on success, negative errno on failure. |
| 169 | * NOTE: The function must be callable in interrupt context. |
| 170 | */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 171 | int (*transmit_packet)(struct hpsb_host *host, |
| 172 | struct hpsb_packet *packet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 174 | /* This function requests miscellanous services from the driver, see |
| 175 | * above for command codes and expected actions. Return -1 for unknown |
| 176 | * command, though that should never happen. |
| 177 | */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 178 | int (*devctl)(struct hpsb_host *host, enum devctl_cmd command, int arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
| 180 | /* ISO transmission/reception functions. Return 0 on success, -1 |
| 181 | * (or -EXXX errno code) on failure. If the low-level driver does not |
| 182 | * support the new ISO API, set isoctl to NULL. |
| 183 | */ |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 184 | int (*isoctl)(struct hpsb_iso *iso, enum isoctl_cmd command, |
| 185 | unsigned long arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Stefan Richter | 741854e | 2005-12-01 18:52:03 -0500 | [diff] [blame] | 187 | /* This function is mainly to redirect local CSR reads/locks to the iso |
| 188 | * management registers (bus manager id, bandwidth available, channels |
| 189 | * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus |
| 190 | * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids |
| 191 | * as OHCI uses). data and compare are the new data and expected data |
| 192 | * respectively, return value is the old value. |
| 193 | */ |
| 194 | quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, |
| 195 | quadlet_t data, quadlet_t compare); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | }; |
| 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, |
| 199 | struct device *dev); |
| 200 | int hpsb_add_host(struct hpsb_host *host); |
Stefan Richter | 3360177 | 2007-01-07 21:49:27 +0100 | [diff] [blame] | 201 | void hpsb_resume_host(struct hpsb_host *host); |
| 202 | void hpsb_remove_host(struct hpsb_host *host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | int hpsb_update_config_rom_image(struct hpsb_host *host); |
| 204 | |
| 205 | #endif /* _IEEE1394_HOSTS_H */ |