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