whcd.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Wireless Host Controller (WHC) private header.
  3. *
  4. * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef __WHCD_H
  21. #define __WHCD_H
  22. #include <linux/uwb/whci.h>
  23. #include <linux/uwb/umc.h>
  24. #include <linux/workqueue.h>
  25. #include "whci-hc.h"
  26. /* Generic command timeout. */
  27. #define WHC_GENCMD_TIMEOUT_MS 100
  28. struct whc_dbg;
  29. struct whc {
  30. struct wusbhc wusbhc;
  31. struct umc_dev *umc;
  32. resource_size_t base_phys;
  33. void __iomem *base;
  34. int irq;
  35. u8 n_devices;
  36. u8 n_keys;
  37. u8 n_mmc_ies;
  38. u64 *pz_list;
  39. struct dn_buf_entry *dn_buf;
  40. struct di_buf_entry *di_buf;
  41. dma_addr_t pz_list_dma;
  42. dma_addr_t dn_buf_dma;
  43. dma_addr_t di_buf_dma;
  44. spinlock_t lock;
  45. struct mutex mutex;
  46. void * gen_cmd_buf;
  47. dma_addr_t gen_cmd_buf_dma;
  48. wait_queue_head_t cmd_wq;
  49. struct workqueue_struct *workqueue;
  50. struct work_struct dn_work;
  51. struct dma_pool *qset_pool;
  52. struct list_head async_list;
  53. struct list_head async_removed_list;
  54. wait_queue_head_t async_list_wq;
  55. struct work_struct async_work;
  56. struct list_head periodic_list[5];
  57. struct list_head periodic_removed_list;
  58. wait_queue_head_t periodic_list_wq;
  59. struct work_struct periodic_work;
  60. struct whc_dbg *dbg;
  61. };
  62. #define wusbhc_to_whc(w) (container_of((w), struct whc, wusbhc))
  63. /**
  64. * struct whc_std - a software TD.
  65. * @urb: the URB this sTD is for.
  66. * @offset: start of the URB's data for this TD.
  67. * @len: the length of data in the associated TD.
  68. * @ntds_remaining: number of TDs (starting from this one) in this transfer.
  69. *
  70. * Queued URBs may require more TDs than are available in a qset so we
  71. * use a list of these "software TDs" (sTDs) to hold per-TD data.
  72. */
  73. struct whc_std {
  74. struct urb *urb;
  75. size_t len;
  76. int ntds_remaining;
  77. struct whc_qtd *qtd;
  78. struct list_head list_node;
  79. int num_pointers;
  80. dma_addr_t dma_addr;
  81. struct whc_page_list_entry *pl_virt;
  82. };
  83. /**
  84. * struct whc_urb - per URB host controller structure.
  85. * @urb: the URB this struct is for.
  86. * @qset: the qset associated to the URB.
  87. * @dequeue_work: the work to remove the URB when dequeued.
  88. * @is_async: the URB belongs to async sheduler or not.
  89. * @status: the status to be returned when calling wusbhc_giveback_urb.
  90. */
  91. struct whc_urb {
  92. struct urb *urb;
  93. struct whc_qset *qset;
  94. struct work_struct dequeue_work;
  95. bool is_async;
  96. int status;
  97. };
  98. /**
  99. * whc_std_last - is this sTD the URB's last?
  100. * @std: the sTD to check.
  101. */
  102. static inline bool whc_std_last(struct whc_std *std)
  103. {
  104. return std->ntds_remaining <= 1;
  105. }
  106. enum whc_update {
  107. WHC_UPDATE_ADDED = 0x01,
  108. WHC_UPDATE_REMOVED = 0x02,
  109. WHC_UPDATE_UPDATED = 0x04,
  110. };
  111. /* init.c */
  112. int whc_init(struct whc *whc);
  113. void whc_clean_up(struct whc *whc);
  114. /* hw.c */
  115. void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val);
  116. int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len);
  117. void whc_hw_error(struct whc *whc, const char *reason);
  118. /* wusb.c */
  119. int whc_wusbhc_start(struct wusbhc *wusbhc);
  120. void whc_wusbhc_stop(struct wusbhc *wusbhc, int delay);
  121. int whc_mmcie_add(struct wusbhc *wusbhc, u8 interval, u8 repeat_cnt,
  122. u8 handle, struct wuie_hdr *wuie);
  123. int whc_mmcie_rm(struct wusbhc *wusbhc, u8 handle);
  124. int whc_bwa_set(struct wusbhc *wusbhc, s8 stream_index, const struct uwb_mas_bm *mas_bm);
  125. int whc_dev_info_set(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev);
  126. int whc_set_num_dnts(struct wusbhc *wusbhc, u8 interval, u8 slots);
  127. int whc_set_ptk(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
  128. const void *ptk, size_t key_size);
  129. int whc_set_gtk(struct wusbhc *wusbhc, u32 tkid,
  130. const void *gtk, size_t key_size);
  131. int whc_set_cluster_id(struct whc *whc, u8 bcid);
  132. /* int.c */
  133. irqreturn_t whc_int_handler(struct usb_hcd *hcd);
  134. void whc_dn_work(struct work_struct *work);
  135. /* asl.c */
  136. void asl_start(struct whc *whc);
  137. void asl_stop(struct whc *whc);
  138. int asl_init(struct whc *whc);
  139. void asl_clean_up(struct whc *whc);
  140. int asl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
  141. int asl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
  142. void asl_qset_delete(struct whc *whc, struct whc_qset *qset);
  143. void scan_async_work(struct work_struct *work);
  144. /* pzl.c */
  145. int pzl_init(struct whc *whc);
  146. void pzl_clean_up(struct whc *whc);
  147. void pzl_start(struct whc *whc);
  148. void pzl_stop(struct whc *whc);
  149. int pzl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
  150. int pzl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
  151. void pzl_qset_delete(struct whc *whc, struct whc_qset *qset);
  152. void scan_periodic_work(struct work_struct *work);
  153. /* qset.c */
  154. struct whc_qset *qset_alloc(struct whc *whc, gfp_t mem_flags);
  155. void qset_free(struct whc *whc, struct whc_qset *qset);
  156. struct whc_qset *get_qset(struct whc *whc, struct urb *urb, gfp_t mem_flags);
  157. void qset_delete(struct whc *whc, struct whc_qset *qset);
  158. void qset_clear(struct whc *whc, struct whc_qset *qset);
  159. void qset_reset(struct whc *whc, struct whc_qset *qset);
  160. int qset_add_urb(struct whc *whc, struct whc_qset *qset, struct urb *urb,
  161. gfp_t mem_flags);
  162. void qset_free_std(struct whc *whc, struct whc_std *std);
  163. void qset_remove_urb(struct whc *whc, struct whc_qset *qset,
  164. struct urb *urb, int status);
  165. void process_halted_qtd(struct whc *whc, struct whc_qset *qset,
  166. struct whc_qtd *qtd);
  167. void process_inactive_qtd(struct whc *whc, struct whc_qset *qset,
  168. struct whc_qtd *qtd);
  169. enum whc_update qset_add_qtds(struct whc *whc, struct whc_qset *qset);
  170. void qset_remove_complete(struct whc *whc, struct whc_qset *qset);
  171. void pzl_update(struct whc *whc, uint32_t wusbcmd);
  172. void asl_update(struct whc *whc, uint32_t wusbcmd);
  173. /* debug.c */
  174. void whc_dbg_init(struct whc *whc);
  175. void whc_dbg_clean_up(struct whc *whc);
  176. #endif /* #ifndef __WHCD_H */