1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __WHCD_H
21#define __WHCD_H
22
23#include <linux/uwb/whci.h>
24#include <linux/uwb/umc.h>
25#include <linux/workqueue.h>
26
27#include "whci-hc.h"
28
29
30#define WHC_GENCMD_TIMEOUT_MS 100
31
32struct whc_dbg;
33
34struct whc {
35 struct wusbhc wusbhc;
36 struct umc_dev *umc;
37
38 resource_size_t base_phys;
39 void __iomem *base;
40 int irq;
41
42 u8 n_devices;
43 u8 n_keys;
44 u8 n_mmc_ies;
45
46 u64 *pz_list;
47 struct dn_buf_entry *dn_buf;
48 struct di_buf_entry *di_buf;
49 dma_addr_t pz_list_dma;
50 dma_addr_t dn_buf_dma;
51 dma_addr_t di_buf_dma;
52
53 spinlock_t lock;
54 struct mutex mutex;
55
56 void * gen_cmd_buf;
57 dma_addr_t gen_cmd_buf_dma;
58 wait_queue_head_t cmd_wq;
59
60 struct workqueue_struct *workqueue;
61 struct work_struct dn_work;
62
63 struct dma_pool *qset_pool;
64
65 struct list_head async_list;
66 struct list_head async_removed_list;
67 wait_queue_head_t async_list_wq;
68 struct work_struct async_work;
69
70 struct list_head periodic_list[5];
71 struct list_head periodic_removed_list;
72 wait_queue_head_t periodic_list_wq;
73 struct work_struct periodic_work;
74
75 struct whc_dbg *dbg;
76};
77
78#define wusbhc_to_whc(w) (container_of((w), struct whc, wusbhc))
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95struct whc_std {
96 struct urb *urb;
97 size_t len;
98 int ntds_remaining;
99 struct whc_qtd *qtd;
100
101 struct list_head list_node;
102 int num_pointers;
103 dma_addr_t dma_addr;
104 struct whc_page_list_entry *pl_virt;
105
106 void *bounce_buf;
107 struct scatterlist *bounce_sg;
108 unsigned bounce_offset;
109};
110
111
112
113
114
115
116
117
118
119struct whc_urb {
120 struct urb *urb;
121 struct whc_qset *qset;
122 struct work_struct dequeue_work;
123 bool is_async;
124 int status;
125};
126
127
128
129
130
131static inline bool whc_std_last(struct whc_std *std)
132{
133 return std->ntds_remaining <= 1;
134}
135
136enum whc_update {
137 WHC_UPDATE_ADDED = 0x01,
138 WHC_UPDATE_REMOVED = 0x02,
139 WHC_UPDATE_UPDATED = 0x04,
140};
141
142
143int whc_init(struct whc *whc);
144void whc_clean_up(struct whc *whc);
145
146
147void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val);
148int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len);
149void whc_hw_error(struct whc *whc, const char *reason);
150
151
152int whc_wusbhc_start(struct wusbhc *wusbhc);
153void whc_wusbhc_stop(struct wusbhc *wusbhc, int delay);
154int whc_mmcie_add(struct wusbhc *wusbhc, u8 interval, u8 repeat_cnt,
155 u8 handle, struct wuie_hdr *wuie);
156int whc_mmcie_rm(struct wusbhc *wusbhc, u8 handle);
157int whc_bwa_set(struct wusbhc *wusbhc, s8 stream_index, const struct uwb_mas_bm *mas_bm);
158int whc_dev_info_set(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev);
159int whc_set_num_dnts(struct wusbhc *wusbhc, u8 interval, u8 slots);
160int whc_set_ptk(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
161 const void *ptk, size_t key_size);
162int whc_set_gtk(struct wusbhc *wusbhc, u32 tkid,
163 const void *gtk, size_t key_size);
164int whc_set_cluster_id(struct whc *whc, u8 bcid);
165
166
167irqreturn_t whc_int_handler(struct usb_hcd *hcd);
168void whc_dn_work(struct work_struct *work);
169
170
171void asl_start(struct whc *whc);
172void asl_stop(struct whc *whc);
173int asl_init(struct whc *whc);
174void asl_clean_up(struct whc *whc);
175int asl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
176int asl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
177void asl_qset_delete(struct whc *whc, struct whc_qset *qset);
178void scan_async_work(struct work_struct *work);
179
180
181int pzl_init(struct whc *whc);
182void pzl_clean_up(struct whc *whc);
183void pzl_start(struct whc *whc);
184void pzl_stop(struct whc *whc);
185int pzl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
186int pzl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
187void pzl_qset_delete(struct whc *whc, struct whc_qset *qset);
188void scan_periodic_work(struct work_struct *work);
189
190
191struct whc_qset *qset_alloc(struct whc *whc, gfp_t mem_flags);
192void qset_free(struct whc *whc, struct whc_qset *qset);
193struct whc_qset *get_qset(struct whc *whc, struct urb *urb, gfp_t mem_flags);
194void qset_delete(struct whc *whc, struct whc_qset *qset);
195void qset_clear(struct whc *whc, struct whc_qset *qset);
196void qset_reset(struct whc *whc, struct whc_qset *qset);
197int qset_add_urb(struct whc *whc, struct whc_qset *qset, struct urb *urb,
198 gfp_t mem_flags);
199void qset_free_std(struct whc *whc, struct whc_std *std);
200void qset_remove_urb(struct whc *whc, struct whc_qset *qset,
201 struct urb *urb, int status);
202void process_halted_qtd(struct whc *whc, struct whc_qset *qset,
203 struct whc_qtd *qtd);
204void process_inactive_qtd(struct whc *whc, struct whc_qset *qset,
205 struct whc_qtd *qtd);
206enum whc_update qset_add_qtds(struct whc *whc, struct whc_qset *qset);
207void qset_remove_complete(struct whc *whc, struct whc_qset *qset);
208void pzl_update(struct whc *whc, uint32_t wusbcmd);
209void asl_update(struct whc *whc, uint32_t wusbcmd);
210
211
212void whc_dbg_init(struct whc *whc);
213void whc_dbg_clean_up(struct whc *whc);
214
215#endif
216