]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/usb/host/whci/whcd.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-omap-h63xx.git] / drivers / usb / host / whci / whcd.h
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
23 #include <linux/uwb/whci.h>
24 #include <linux/workqueue.h>
25
26 #include "whci-hc.h"
27
28 /* Generic command timeout. */
29 #define WHC_GENCMD_TIMEOUT_MS 100
30
31
32 struct whc {
33         struct wusbhc wusbhc;
34         struct umc_dev *umc;
35
36         resource_size_t base_phys;
37         void __iomem *base;
38         int irq;
39
40         u8 n_devices;
41         u8 n_keys;
42         u8 n_mmc_ies;
43
44         u64 *pz_list;
45         struct dn_buf_entry *dn_buf;
46         struct di_buf_entry *di_buf;
47         dma_addr_t pz_list_dma;
48         dma_addr_t dn_buf_dma;
49         dma_addr_t di_buf_dma;
50
51         spinlock_t   lock;
52         struct mutex mutex;
53
54         void *            gen_cmd_buf;
55         dma_addr_t        gen_cmd_buf_dma;
56         wait_queue_head_t cmd_wq;
57
58         struct workqueue_struct *workqueue;
59         struct work_struct       dn_work;
60
61         struct dma_pool *qset_pool;
62
63         struct list_head async_list;
64         struct list_head async_removed_list;
65         wait_queue_head_t async_list_wq;
66         struct work_struct async_work;
67
68         struct list_head periodic_list[5];
69         struct list_head periodic_removed_list;
70         wait_queue_head_t periodic_list_wq;
71         struct work_struct periodic_work;
72 };
73
74 #define wusbhc_to_whc(w) (container_of((w), struct whc, wusbhc))
75
76 /**
77  * struct whc_std - a software TD.
78  * @urb: the URB this sTD is for.
79  * @offset: start of the URB's data for this TD.
80  * @len: the length of data in the associated TD.
81  * @ntds_remaining: number of TDs (starting from this one) in this transfer.
82  *
83  * Queued URBs may require more TDs than are available in a qset so we
84  * use a list of these "software TDs" (sTDs) to hold per-TD data.
85  */
86 struct whc_std {
87         struct urb *urb;
88         size_t len;
89         int    ntds_remaining;
90         struct whc_qtd *qtd;
91
92         struct list_head list_node;
93         int num_pointers;
94         dma_addr_t dma_addr;
95         struct whc_page_list_entry *pl_virt;
96 };
97
98 /**
99  * struct whc_urb - per URB host controller structure.
100  * @urb: the URB this struct is for.
101  * @qset: the qset associated to the URB.
102  * @dequeue_work: the work to remove the URB when dequeued.
103  * @is_async: the URB belongs to async sheduler or not.
104  * @status: the status to be returned when calling wusbhc_giveback_urb.
105  */
106 struct 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  * whc_std_last - is this sTD the URB's last?
116  * @std: the sTD to check.
117  */
118 static inline bool whc_std_last(struct whc_std *std)
119 {
120         return std->ntds_remaining <= 1;
121 }
122
123 enum whc_update {
124         WHC_UPDATE_ADDED   = 0x01,
125         WHC_UPDATE_REMOVED = 0x02,
126         WHC_UPDATE_UPDATED = 0x04,
127 };
128
129 /* init.c */
130 int whc_init(struct whc *whc);
131 void whc_clean_up(struct whc *whc);
132
133 /* hw.c */
134 void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val);
135 int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len);
136
137 /* wusb.c */
138 int whc_wusbhc_start(struct wusbhc *wusbhc);
139 void whc_wusbhc_stop(struct wusbhc *wusbhc);
140 int whc_mmcie_add(struct wusbhc *wusbhc, u8 interval, u8 repeat_cnt,
141                   u8 handle, struct wuie_hdr *wuie);
142 int whc_mmcie_rm(struct wusbhc *wusbhc, u8 handle);
143 int whc_bwa_set(struct wusbhc *wusbhc, s8 stream_index, const struct uwb_mas_bm *mas_bm);
144 int whc_dev_info_set(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev);
145 int whc_set_num_dnts(struct wusbhc *wusbhc, u8 interval, u8 slots);
146 int whc_set_ptk(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
147                 const void *ptk, size_t key_size);
148 int whc_set_gtk(struct wusbhc *wusbhc, u32 tkid,
149                 const void *gtk, size_t key_size);
150 int whc_set_cluster_id(struct whc *whc, u8 bcid);
151
152 /* int.c */
153 irqreturn_t whc_int_handler(struct usb_hcd *hcd);
154 void whc_dn_work(struct work_struct *work);
155
156 /* asl.c */
157 void asl_start(struct whc *whc);
158 void asl_stop(struct whc *whc);
159 int  asl_init(struct whc *whc);
160 void asl_clean_up(struct whc *whc);
161 int  asl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
162 int  asl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
163 void asl_qset_delete(struct whc *whc, struct whc_qset *qset);
164 void scan_async_work(struct work_struct *work);
165
166 /* pzl.c */
167 int  pzl_init(struct whc *whc);
168 void pzl_clean_up(struct whc *whc);
169 void pzl_start(struct whc *whc);
170 void pzl_stop(struct whc *whc);
171 int  pzl_urb_enqueue(struct whc *whc, struct urb *urb, gfp_t mem_flags);
172 int  pzl_urb_dequeue(struct whc *whc, struct urb *urb, int status);
173 void pzl_qset_delete(struct whc *whc, struct whc_qset *qset);
174 void scan_periodic_work(struct work_struct *work);
175
176 /* qset.c */
177 struct whc_qset *qset_alloc(struct whc *whc, gfp_t mem_flags);
178 void qset_free(struct whc *whc, struct whc_qset *qset);
179 struct whc_qset *get_qset(struct whc *whc, struct urb *urb, gfp_t mem_flags);
180 void qset_delete(struct whc *whc, struct whc_qset *qset);
181 void qset_clear(struct whc *whc, struct whc_qset *qset);
182 int qset_add_urb(struct whc *whc, struct whc_qset *qset, struct urb *urb,
183                  gfp_t mem_flags);
184 void qset_free_std(struct whc *whc, struct whc_std *std);
185 void qset_remove_urb(struct whc *whc, struct whc_qset *qset,
186                             struct urb *urb, int status);
187 void process_halted_qtd(struct whc *whc, struct whc_qset *qset,
188                                struct whc_qtd *qtd);
189 void process_inactive_qtd(struct whc *whc, struct whc_qset *qset,
190                                  struct whc_qtd *qtd);
191 enum whc_update qset_add_qtds(struct whc *whc, struct whc_qset *qset);
192 void qset_remove_complete(struct whc *whc, struct whc_qset *qset);
193 void dump_qset(struct whc_qset *qset, struct device *dev);
194 void pzl_update(struct whc *whc, uint32_t wusbcmd);
195 void asl_update(struct whc *whc, uint32_t wusbcmd);
196
197 #endif /* #ifndef __WHCD_H */