hosts.h 6.0 KB

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