aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/dwc2/core.h')
-rw-r--r--drivers/usb/dwc2/core.h182
1 files changed, 182 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 648519c024b5..1efd10cc9629 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -37,6 +37,10 @@
37#ifndef __DWC2_CORE_H__ 37#ifndef __DWC2_CORE_H__
38#define __DWC2_CORE_H__ 38#define __DWC2_CORE_H__
39 39
40#include <linux/phy/phy.h>
41#include <linux/regulator/consumer.h>
42#include <linux/usb/gadget.h>
43#include <linux/usb/otg.h>
40#include <linux/usb/phy.h> 44#include <linux/usb/phy.h>
41#include "hw.h" 45#include "hw.h"
42 46
@@ -54,6 +58,184 @@ static inline void do_write(u32 value, void *addr)
54/* Maximum number of Endpoints/HostChannels */ 58/* Maximum number of Endpoints/HostChannels */
55#define MAX_EPS_CHANNELS 16 59#define MAX_EPS_CHANNELS 16
56 60
61/* s3c-hsotg declarations */
62static const char * const s3c_hsotg_supply_names[] = {
63 "vusb_d", /* digital USB supply, 1.2V */
64 "vusb_a", /* analog USB supply, 1.1V */
65};
66
67/*
68 * EP0_MPS_LIMIT
69 *
70 * Unfortunately there seems to be a limit of the amount of data that can
71 * be transferred by IN transactions on EP0. This is either 127 bytes or 3
72 * packets (which practically means 1 packet and 63 bytes of data) when the
73 * MPS is set to 64.
74 *
75 * This means if we are wanting to move >127 bytes of data, we need to
76 * split the transactions up, but just doing one packet at a time does
77 * not work (this may be an implicit DATA0 PID on first packet of the
78 * transaction) and doing 2 packets is outside the controller's limits.
79 *
80 * If we try to lower the MPS size for EP0, then no transfers work properly
81 * for EP0, and the system will fail basic enumeration. As no cause for this
82 * has currently been found, we cannot support any large IN transfers for
83 * EP0.
84 */
85#define EP0_MPS_LIMIT 64
86
87struct s3c_hsotg;
88struct s3c_hsotg_req;
89
90/**
91 * struct s3c_hsotg_ep - driver endpoint definition.
92 * @ep: The gadget layer representation of the endpoint.
93 * @name: The driver generated name for the endpoint.
94 * @queue: Queue of requests for this endpoint.
95 * @parent: Reference back to the parent device structure.
96 * @req: The current request that the endpoint is processing. This is
97 * used to indicate an request has been loaded onto the endpoint
98 * and has yet to be completed (maybe due to data move, or simply
99 * awaiting an ack from the core all the data has been completed).
100 * @debugfs: File entry for debugfs file for this endpoint.
101 * @lock: State lock to protect contents of endpoint.
102 * @dir_in: Set to true if this endpoint is of the IN direction, which
103 * means that it is sending data to the Host.
104 * @index: The index for the endpoint registers.
105 * @mc: Multi Count - number of transactions per microframe
106 * @interval - Interval for periodic endpoints
107 * @name: The name array passed to the USB core.
108 * @halted: Set if the endpoint has been halted.
109 * @periodic: Set if this is a periodic ep, such as Interrupt
110 * @isochronous: Set if this is a isochronous ep
111 * @sent_zlp: Set if we've sent a zero-length packet.
112 * @total_data: The total number of data bytes done.
113 * @fifo_size: The size of the FIFO (for periodic IN endpoints)
114 * @fifo_load: The amount of data loaded into the FIFO (periodic IN)
115 * @last_load: The offset of data for the last start of request.
116 * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN
117 *
118 * This is the driver's state for each registered enpoint, allowing it
119 * to keep track of transactions that need doing. Each endpoint has a
120 * lock to protect the state, to try and avoid using an overall lock
121 * for the host controller as much as possible.
122 *
123 * For periodic IN endpoints, we have fifo_size and fifo_load to try
124 * and keep track of the amount of data in the periodic FIFO for each
125 * of these as we don't have a status register that tells us how much
126 * is in each of them. (note, this may actually be useless information
127 * as in shared-fifo mode periodic in acts like a single-frame packet
128 * buffer than a fifo)
129 */
130struct s3c_hsotg_ep {
131 struct usb_ep ep;
132 struct list_head queue;
133 struct s3c_hsotg *parent;
134 struct s3c_hsotg_req *req;
135 struct dentry *debugfs;
136
137 unsigned long total_data;
138 unsigned int size_loaded;
139 unsigned int last_load;
140 unsigned int fifo_load;
141 unsigned short fifo_size;
142
143 unsigned char dir_in;
144 unsigned char index;
145 unsigned char mc;
146 unsigned char interval;
147
148 unsigned int halted:1;
149 unsigned int periodic:1;
150 unsigned int isochronous:1;
151 unsigned int sent_zlp:1;
152
153 char name[10];
154};
155
156/**
157 * struct s3c_hsotg - driver state.
158 * @dev: The parent device supplied to the probe function
159 * @driver: USB gadget driver
160 * @phy: The otg phy transceiver structure for phy control.
161 * @uphy: The otg phy transceiver structure for old USB phy control.
162 * @plat: The platform specific configuration data. This can be removed once
163 * all SoCs support usb transceiver.
164 * @regs: The memory area mapped for accessing registers.
165 * @irq: The IRQ number we are using
166 * @supplies: Definition of USB power supplies
167 * @phyif: PHY interface width
168 * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
169 * @num_of_eps: Number of available EPs (excluding EP0)
170 * @debug_root: root directrory for debugfs.
171 * @debug_file: main status file for debugfs.
172 * @debug_fifo: FIFO status file for debugfs.
173 * @ep0_reply: Request used for ep0 reply.
174 * @ep0_buff: Buffer for EP0 reply data, if needed.
175 * @ctrl_buff: Buffer for EP0 control requests.
176 * @ctrl_req: Request for EP0 control packets.
177 * @setup: NAK management for EP0 SETUP
178 * @last_rst: Time of last reset
179 * @eps: The endpoints being supplied to the gadget framework
180 */
181struct s3c_hsotg {
182 struct device *dev;
183 struct usb_gadget_driver *driver;
184 struct phy *phy;
185 struct usb_phy *uphy;
186 struct s3c_hsotg_plat *plat;
187
188 spinlock_t lock;
189
190 void __iomem *regs;
191 int irq;
192 struct clk *clk;
193
194 struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
195
196 u32 phyif;
197 unsigned int dedicated_fifos:1;
198 unsigned char num_of_eps;
199
200 struct dentry *debug_root;
201 struct dentry *debug_file;
202 struct dentry *debug_fifo;
203
204 struct usb_request *ep0_reply;
205 struct usb_request *ctrl_req;
206 u8 ep0_buff[8];
207 u8 ctrl_buff[8];
208
209 struct usb_gadget gadget;
210 unsigned int setup;
211 unsigned long last_rst;
212 struct s3c_hsotg_ep *eps;
213};
214
215/**
216 * struct s3c_hsotg_req - data transfer request
217 * @req: The USB gadget request
218 * @queue: The list of requests for the endpoint this is queued for.
219 * @in_progress: Has already had size/packets written to core
220 * @mapped: DMA buffer for this request has been mapped via dma_map_single().
221 */
222struct s3c_hsotg_req {
223 struct usb_request req;
224 struct list_head queue;
225 unsigned char in_progress;
226 unsigned char mapped;
227};
228
229#define call_gadget(_hs, _entry) \
230do { \
231 if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
232 (_hs)->driver && (_hs)->driver->_entry) { \
233 spin_unlock(&_hs->lock); \
234 (_hs)->driver->_entry(&(_hs)->gadget); \
235 spin_lock(&_hs->lock); \
236 } \
237} while (0)
238
57struct dwc2_hsotg; 239struct dwc2_hsotg;
58struct dwc2_host_chan; 240struct dwc2_host_chan;
59 241