mtu3.h (df2069acb00569a6299d6e11aa1865eeba463848) mtu3.h (a29de31b9ed37ebc905fe8580506b93f28701e67)
1/*
2 * mtu3.h - MediaTek USB3 DRD header
3 *
4 * Copyright (C) 2016 MediaTek Inc.
5 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public

--- 39 unchanged lines hidden (view full) ---

48#define USB_QMU_RQCSR(epnum) (U3D_RXQCSR1 + (((epnum) - 1) * 0x10))
49#define USB_QMU_RQSAR(epnum) (U3D_RXQSAR1 + (((epnum) - 1) * 0x10))
50#define USB_QMU_RQCPR(epnum) (U3D_RXQCPR1 + (((epnum) - 1) * 0x10))
51
52#define USB_QMU_TQCSR(epnum) (U3D_TXQCSR1 + (((epnum) - 1) * 0x10))
53#define USB_QMU_TQSAR(epnum) (U3D_TXQSAR1 + (((epnum) - 1) * 0x10))
54#define USB_QMU_TQCPR(epnum) (U3D_TXQCPR1 + (((epnum) - 1) * 0x10))
55
1/*
2 * mtu3.h - MediaTek USB3 DRD header
3 *
4 * Copyright (C) 2016 MediaTek Inc.
5 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public

--- 39 unchanged lines hidden (view full) ---

48#define USB_QMU_RQCSR(epnum) (U3D_RXQCSR1 + (((epnum) - 1) * 0x10))
49#define USB_QMU_RQSAR(epnum) (U3D_RXQSAR1 + (((epnum) - 1) * 0x10))
50#define USB_QMU_RQCPR(epnum) (U3D_RXQCPR1 + (((epnum) - 1) * 0x10))
51
52#define USB_QMU_TQCSR(epnum) (U3D_TXQCSR1 + (((epnum) - 1) * 0x10))
53#define USB_QMU_TQSAR(epnum) (U3D_TXQSAR1 + (((epnum) - 1) * 0x10))
54#define USB_QMU_TQCPR(epnum) (U3D_TXQCPR1 + (((epnum) - 1) * 0x10))
55
56#define SSUSB_U3_CTRL(p) (U3D_SSUSB_U3_CTRL_0P + ((p) * 0x08))
56#define SSUSB_U2_CTRL(p) (U3D_SSUSB_U2_CTRL_0P + ((p) * 0x08))
57
58#define MTU3_DRIVER_NAME "mtu3"
59#define DMA_ADDR_INVALID (~(dma_addr_t)0)
60
61#define MTU3_EP_ENABLED BIT(0)
62#define MTU3_EP_STALL BIT(1)
63#define MTU3_EP_WEDGE BIT(2)
64#define MTU3_EP_BUSY BIT(3)
65
57#define SSUSB_U2_CTRL(p) (U3D_SSUSB_U2_CTRL_0P + ((p) * 0x08))
58
59#define MTU3_DRIVER_NAME "mtu3"
60#define DMA_ADDR_INVALID (~(dma_addr_t)0)
61
62#define MTU3_EP_ENABLED BIT(0)
63#define MTU3_EP_STALL BIT(1)
64#define MTU3_EP_WEDGE BIT(2)
65#define MTU3_EP_BUSY BIT(3)
66
67#define MTU3_U3_IP_SLOT_DEFAULT 2
66#define MTU3_U2_IP_SLOT_DEFAULT 1
67
68/**
69 * Normally the device works on HS or SS, to simplify fifo management,
70 * devide fifo into some 512B parts, use bitmap to manage it; And
71 * 128 bits size of bitmap is large enough, that means it can manage
72 * up to 64KB fifo size.
73 * NOTE: MTU3_EP_FIFO_UNIT should be power of two

--- 8 unchanged lines hidden (view full) ---

82 */
83#define EP0_RESPONSE_BUF 6
84
85/* device operated link and speed got from DEVICE_CONF register */
86enum mtu3_speed {
87 MTU3_SPEED_INACTIVE = 0,
88 MTU3_SPEED_FULL = 1,
89 MTU3_SPEED_HIGH = 3,
68#define MTU3_U2_IP_SLOT_DEFAULT 1
69
70/**
71 * Normally the device works on HS or SS, to simplify fifo management,
72 * devide fifo into some 512B parts, use bitmap to manage it; And
73 * 128 bits size of bitmap is large enough, that means it can manage
74 * up to 64KB fifo size.
75 * NOTE: MTU3_EP_FIFO_UNIT should be power of two

--- 8 unchanged lines hidden (view full) ---

84 */
85#define EP0_RESPONSE_BUF 6
86
87/* device operated link and speed got from DEVICE_CONF register */
88enum mtu3_speed {
89 MTU3_SPEED_INACTIVE = 0,
90 MTU3_SPEED_FULL = 1,
91 MTU3_SPEED_HIGH = 3,
92 MTU3_SPEED_SUPER = 4,
90};
91
92/**
93 * @MU3D_EP0_STATE_SETUP: waits for SETUP or received a SETUP
94 * without data stage.
95 * @MU3D_EP0_STATE_TX: IN data stage
96 * @MU3D_EP0_STATE_RX: OUT data stage
97 * @MU3D_EP0_STATE_TX_END: the last IN data is transferred, and

--- 87 unchanged lines hidden (view full) ---

185 int slot;
186 u32 fifo_size;
187 u32 fifo_addr;
188 u32 fifo_seg_size;
189 struct mtu3_fifo_info *fifo;
190
191 struct list_head req_list;
192 struct mtu3_gpd_ring gpd_ring;
93};
94
95/**
96 * @MU3D_EP0_STATE_SETUP: waits for SETUP or received a SETUP
97 * without data stage.
98 * @MU3D_EP0_STATE_TX: IN data stage
99 * @MU3D_EP0_STATE_RX: OUT data stage
100 * @MU3D_EP0_STATE_TX_END: the last IN data is transferred, and

--- 87 unchanged lines hidden (view full) ---

188 int slot;
189 u32 fifo_size;
190 u32 fifo_addr;
191 u32 fifo_seg_size;
192 struct mtu3_fifo_info *fifo;
193
194 struct list_head req_list;
195 struct mtu3_gpd_ring gpd_ring;
196 const struct usb_ss_ep_comp_descriptor *comp_desc;
193 const struct usb_endpoint_descriptor *desc;
194
195 int flags;
196 u8 wedged;
197 u8 busy;
198};
199
200struct mtu3_request {
201 struct usb_request request;
202 struct list_head list;
203 struct mtu3_ep *mep;
204 struct mtu3 *mtu;
205 struct qmu_gpd *gpd;
206 int epnum;
207};
208
209/**
210 * struct mtu3 - device driver instance data.
197 const struct usb_endpoint_descriptor *desc;
198
199 int flags;
200 u8 wedged;
201 u8 busy;
202};
203
204struct mtu3_request {
205 struct usb_request request;
206 struct list_head list;
207 struct mtu3_ep *mep;
208 struct mtu3 *mtu;
209 struct qmu_gpd *gpd;
210 int epnum;
211};
212
213/**
214 * struct mtu3 - device driver instance data.
211 * @slot: MTU3_U2_IP_SLOT_DEFAULT for U2 IP
215 * @slot: MTU3_U2_IP_SLOT_DEFAULT for U2 IP only,
216 * MTU3_U3_IP_SLOT_DEFAULT for U3 IP
212 * @may_wakeup: means device's remote wakeup is enabled
213 * @is_self_powered: is reported in device status and the config descriptor
214 * @ep0_req: dummy request used while handling standard USB requests
215 * for GET_STATUS and SET_SEL
216 * @setup_buf: ep0 response buffer for GET_STATUS and SET_SEL requests
217 */
218struct mtu3 {
219 spinlock_t lock;

--- 17 unchanged lines hidden (view full) ---

237 int active_ep;
238
239 struct dma_pool *qmu_gpd_pool;
240 enum mtu3_g_ep0_state ep0_state;
241 struct usb_gadget g; /* the gadget */
242 struct usb_gadget_driver *gadget_driver;
243 struct mtu3_request ep0_req;
244 u8 setup_buf[EP0_RESPONSE_BUF];
217 * @may_wakeup: means device's remote wakeup is enabled
218 * @is_self_powered: is reported in device status and the config descriptor
219 * @ep0_req: dummy request used while handling standard USB requests
220 * for GET_STATUS and SET_SEL
221 * @setup_buf: ep0 response buffer for GET_STATUS and SET_SEL requests
222 */
223struct mtu3 {
224 spinlock_t lock;

--- 17 unchanged lines hidden (view full) ---

242 int active_ep;
243
244 struct dma_pool *qmu_gpd_pool;
245 enum mtu3_g_ep0_state ep0_state;
246 struct usb_gadget g; /* the gadget */
247 struct usb_gadget_driver *gadget_driver;
248 struct mtu3_request ep0_req;
249 u8 setup_buf[EP0_RESPONSE_BUF];
250 u32 max_speed;
245
246 unsigned is_active:1;
247 unsigned may_wakeup:1;
248 unsigned is_self_powered:1;
249 unsigned test_mode:1;
250 unsigned softconnect:1;
251
252 unsigned is_active:1;
253 unsigned may_wakeup:1;
254 unsigned is_self_powered:1;
255 unsigned test_mode:1;
256 unsigned softconnect:1;
257 unsigned u1_enable:1;
258 unsigned u2_enable:1;
259 unsigned is_u3_ip:1;
251
252 u8 address;
253 u8 test_mode_nr;
254 u32 hw_version;
255};
256
257static inline struct mtu3 *gadget_to_mtu3(struct usb_gadget *g)
258{

--- 60 unchanged lines hidden (view full) ---

319
320int mtu3_config_ep(struct mtu3 *mtu, struct mtu3_ep *mep,
321 int interval, int burst, int mult);
322void mtu3_deconfig_ep(struct mtu3 *mtu, struct mtu3_ep *mep);
323void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set);
324void mtu3_ep0_setup(struct mtu3 *mtu);
325void mtu3_start(struct mtu3 *mtu);
326void mtu3_stop(struct mtu3 *mtu);
260
261 u8 address;
262 u8 test_mode_nr;
263 u32 hw_version;
264};
265
266static inline struct mtu3 *gadget_to_mtu3(struct usb_gadget *g)
267{

--- 60 unchanged lines hidden (view full) ---

328
329int mtu3_config_ep(struct mtu3 *mtu, struct mtu3_ep *mep,
330 int interval, int burst, int mult);
331void mtu3_deconfig_ep(struct mtu3 *mtu, struct mtu3_ep *mep);
332void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set);
333void mtu3_ep0_setup(struct mtu3 *mtu);
334void mtu3_start(struct mtu3 *mtu);
335void mtu3_stop(struct mtu3 *mtu);
327void mtu3_hs_softconn_set(struct mtu3 *mtu, bool enable);
336void mtu3_dev_on_off(struct mtu3 *mtu, int is_on);
328
329int mtu3_gadget_setup(struct mtu3 *mtu);
330void mtu3_gadget_cleanup(struct mtu3 *mtu);
331void mtu3_gadget_reset(struct mtu3 *mtu);
332void mtu3_gadget_suspend(struct mtu3 *mtu);
333void mtu3_gadget_resume(struct mtu3 *mtu);
334void mtu3_gadget_disconnect(struct mtu3 *mtu);
335int ssusb_gadget_init(struct mtu3 *mtu);
336void ssusb_gadget_exit(struct mtu3 *mtu);
337
338irqreturn_t mtu3_ep0_isr(struct mtu3 *mtu);
339extern const struct usb_ep_ops mtu3_ep0_ops;
340
341#endif
337
338int mtu3_gadget_setup(struct mtu3 *mtu);
339void mtu3_gadget_cleanup(struct mtu3 *mtu);
340void mtu3_gadget_reset(struct mtu3 *mtu);
341void mtu3_gadget_suspend(struct mtu3 *mtu);
342void mtu3_gadget_resume(struct mtu3 *mtu);
343void mtu3_gadget_disconnect(struct mtu3 *mtu);
344int ssusb_gadget_init(struct mtu3 *mtu);
345void ssusb_gadget_exit(struct mtu3 *mtu);
346
347irqreturn_t mtu3_ep0_isr(struct mtu3 *mtu);
348extern const struct usb_ep_ops mtu3_ep0_ops;
349
350#endif