Root/drivers/usb/gadget/jz4740_udc.h

Source at commit eb7e867e25b365fc7e5214607b58c3c800bc93f7 created 10 years 3 months ago.
By Lars-Peter Clausen, Add jz4740 udc driver
1/*
2 * linux/drivers/usb/gadget/jz4740_udc.h
3 *
4 * Ingenic JZ4740 on-chip high speed USB device controller
5 *
6 * Copyright (C) 2006 Ingenic Semiconductor Inc.
7 * Author: <jlwei@ingenic.cn>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#ifndef __USB_GADGET_JZ4740_H__
16#define __USB_GADGET_JZ4740_H__
17
18/*-------------------------------------------------------------------------*/
19
20// Max packet size
21#define EP0_MAXPACKETSIZE 64
22#define EPBULK_MAXPACKETSIZE 512
23#define EPINTR_MAXPACKETSIZE 64
24
25#define UDC_MAX_ENDPOINTS 4
26
27/*-------------------------------------------------------------------------*/
28
29enum ep_type {
30    ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
31};
32
33struct jz4740_ep {
34    struct usb_ep ep;
35    struct jz4740_udc *dev;
36
37    const struct usb_endpoint_descriptor *desc;
38
39    uint8_t stopped;
40    uint8_t bEndpointAddress;
41    uint8_t bmAttributes;
42
43    enum ep_type type;
44    size_t fifo;
45    uint32_t csr;
46
47    uint32_t reg_addr;
48    struct list_head queue;
49};
50
51struct jz4740_request {
52    struct usb_request req;
53    struct list_head queue;
54};
55
56enum ep0state {
57    WAIT_FOR_SETUP, /* between STATUS ack and SETUP report */
58    DATA_STATE_XMIT, /* data tx stage */
59    DATA_STATE_NEED_ZLP, /* data tx zlp stage */
60    WAIT_FOR_OUT_STATUS, /* status stages */
61    DATA_STATE_RECV, /* data rx stage */
62};
63
64/* For function binding with UDC Disable - Added by River */
65typedef enum {
66    UDC_STATE_ENABLE = 0,
67    UDC_STATE_DISABLE,
68}udc_state_t;
69
70struct jz4740_udc {
71    struct usb_gadget gadget;
72    struct usb_gadget_driver *driver;
73    struct device *dev;
74    spinlock_t lock;
75    unsigned long lock_flags;
76
77    enum ep0state ep0state;
78    struct jz4740_ep ep[UDC_MAX_ENDPOINTS];
79
80    udc_state_t state;
81
82    struct resource *mem;
83    void __iomem *base;
84    int irq;
85
86    struct clk *clk;
87};
88
89#define ep_maxpacket(EP) ((EP)->ep.maxpacket)
90
91static inline bool ep_is_in(const struct jz4740_ep *ep)
92{
93    return (ep->bEndpointAddress & USB_DIR_IN) == USB_DIR_IN;
94}
95
96static inline uint8_t ep_index(const struct jz4740_ep *ep)
97{
98    return ep->bEndpointAddress & 0xf;
99}
100
101#endif /* __USB_GADGET_JZ4740_H__ */
102

Archive Download this file



interactive