dm thin metadata: fix __udivdi3 undefined on 32-bit
[linux/fpc-iii.git] / drivers / usb / dwc2 / core.h
bloba899d47c2a7cb6723c3e72c4d2bbb1800a301cf3
1 /*
2 * core.h - DesignWare HS OTG Controller common declarations
4 * Copyright (C) 2004-2013 Synopsys, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The names of the above-listed copyright holders may not be used
16 * to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * ALTERNATIVELY, this software may be distributed under the terms of the
20 * GNU General Public License ("GPL") as published by the Free Software
21 * Foundation; either version 2 of the License, or (at your option) any
22 * later version.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #ifndef __DWC2_CORE_H__
38 #define __DWC2_CORE_H__
40 #include <linux/phy/phy.h>
41 #include <linux/regulator/consumer.h>
42 #include <linux/usb/gadget.h>
43 #include <linux/usb/otg.h>
44 #include <linux/usb/phy.h>
45 #include "hw.h"
47 #ifdef CONFIG_MIPS
49 * There are some MIPS machines that can run in either big-endian
50 * or little-endian mode and that use the dwc2 register without
51 * a byteswap in both ways.
52 * Unlike other architectures, MIPS apparently does not require a
53 * barrier before the __raw_writel() to synchronize with DMA but does
54 * require the barrier after the __raw_writel() to serialize a set of
55 * writes. This set of operations was added specifically for MIPS and
56 * should only be used there.
58 static inline u32 dwc2_readl(const void __iomem *addr)
60 u32 value = __raw_readl(addr);
62 /* In order to preserve endianness __raw_* operation is used. Therefore
63 * a barrier is needed to ensure IO access is not re-ordered across
64 * reads or writes
66 mb();
67 return value;
70 static inline void dwc2_writel(u32 value, void __iomem *addr)
72 __raw_writel(value, addr);
75 * In order to preserve endianness __raw_* operation is used. Therefore
76 * a barrier is needed to ensure IO access is not re-ordered across
77 * reads or writes
79 mb();
80 #ifdef DWC2_LOG_WRITES
81 pr_info("INFO:: wrote %08x to %p\n", value, addr);
82 #endif
84 #else
85 /* Normal architectures just use readl/write */
86 static inline u32 dwc2_readl(const void __iomem *addr)
88 return readl(addr);
91 static inline void dwc2_writel(u32 value, void __iomem *addr)
93 writel(value, addr);
95 #ifdef DWC2_LOG_WRITES
96 pr_info("info:: wrote %08x to %p\n", value, addr);
97 #endif
99 #endif
101 /* Maximum number of Endpoints/HostChannels */
102 #define MAX_EPS_CHANNELS 16
104 /* dwc2-hsotg declarations */
105 static const char * const dwc2_hsotg_supply_names[] = {
106 "vusb_d", /* digital USB supply, 1.2V */
107 "vusb_a", /* analog USB supply, 1.1V */
111 * EP0_MPS_LIMIT
113 * Unfortunately there seems to be a limit of the amount of data that can
114 * be transferred by IN transactions on EP0. This is either 127 bytes or 3
115 * packets (which practically means 1 packet and 63 bytes of data) when the
116 * MPS is set to 64.
118 * This means if we are wanting to move >127 bytes of data, we need to
119 * split the transactions up, but just doing one packet at a time does
120 * not work (this may be an implicit DATA0 PID on first packet of the
121 * transaction) and doing 2 packets is outside the controller's limits.
123 * If we try to lower the MPS size for EP0, then no transfers work properly
124 * for EP0, and the system will fail basic enumeration. As no cause for this
125 * has currently been found, we cannot support any large IN transfers for
126 * EP0.
128 #define EP0_MPS_LIMIT 64
130 struct dwc2_hsotg;
131 struct dwc2_hsotg_req;
134 * struct dwc2_hsotg_ep - driver endpoint definition.
135 * @ep: The gadget layer representation of the endpoint.
136 * @name: The driver generated name for the endpoint.
137 * @queue: Queue of requests for this endpoint.
138 * @parent: Reference back to the parent device structure.
139 * @req: The current request that the endpoint is processing. This is
140 * used to indicate an request has been loaded onto the endpoint
141 * and has yet to be completed (maybe due to data move, or simply
142 * awaiting an ack from the core all the data has been completed).
143 * @debugfs: File entry for debugfs file for this endpoint.
144 * @lock: State lock to protect contents of endpoint.
145 * @dir_in: Set to true if this endpoint is of the IN direction, which
146 * means that it is sending data to the Host.
147 * @index: The index for the endpoint registers.
148 * @mc: Multi Count - number of transactions per microframe
149 * @interval - Interval for periodic endpoints
150 * @name: The name array passed to the USB core.
151 * @halted: Set if the endpoint has been halted.
152 * @periodic: Set if this is a periodic ep, such as Interrupt
153 * @isochronous: Set if this is a isochronous ep
154 * @send_zlp: Set if we need to send a zero-length packet.
155 * @total_data: The total number of data bytes done.
156 * @fifo_size: The size of the FIFO (for periodic IN endpoints)
157 * @fifo_load: The amount of data loaded into the FIFO (periodic IN)
158 * @last_load: The offset of data for the last start of request.
159 * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN
161 * This is the driver's state for each registered enpoint, allowing it
162 * to keep track of transactions that need doing. Each endpoint has a
163 * lock to protect the state, to try and avoid using an overall lock
164 * for the host controller as much as possible.
166 * For periodic IN endpoints, we have fifo_size and fifo_load to try
167 * and keep track of the amount of data in the periodic FIFO for each
168 * of these as we don't have a status register that tells us how much
169 * is in each of them. (note, this may actually be useless information
170 * as in shared-fifo mode periodic in acts like a single-frame packet
171 * buffer than a fifo)
173 struct dwc2_hsotg_ep {
174 struct usb_ep ep;
175 struct list_head queue;
176 struct dwc2_hsotg *parent;
177 struct dwc2_hsotg_req *req;
178 struct dentry *debugfs;
180 unsigned long total_data;
181 unsigned int size_loaded;
182 unsigned int last_load;
183 unsigned int fifo_load;
184 unsigned short fifo_size;
185 unsigned short fifo_index;
187 unsigned char dir_in;
188 unsigned char index;
189 unsigned char mc;
190 u16 interval;
192 unsigned int halted:1;
193 unsigned int periodic:1;
194 unsigned int isochronous:1;
195 unsigned int send_zlp:1;
196 unsigned int has_correct_parity:1;
198 char name[10];
202 * struct dwc2_hsotg_req - data transfer request
203 * @req: The USB gadget request
204 * @queue: The list of requests for the endpoint this is queued for.
205 * @saved_req_buf: variable to save req.buf when bounce buffers are used.
207 struct dwc2_hsotg_req {
208 struct usb_request req;
209 struct list_head queue;
210 void *saved_req_buf;
213 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
214 #define call_gadget(_hs, _entry) \
215 do { \
216 if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
217 (_hs)->driver && (_hs)->driver->_entry) { \
218 spin_unlock(&_hs->lock); \
219 (_hs)->driver->_entry(&(_hs)->gadget); \
220 spin_lock(&_hs->lock); \
222 } while (0)
223 #else
224 #define call_gadget(_hs, _entry) do {} while (0)
225 #endif
227 struct dwc2_hsotg;
228 struct dwc2_host_chan;
230 /* Device States */
231 enum dwc2_lx_state {
232 DWC2_L0, /* On state */
233 DWC2_L1, /* LPM sleep state */
234 DWC2_L2, /* USB suspend state */
235 DWC2_L3, /* Off state */
239 * Gadget periodic tx fifo sizes as used by legacy driver
240 * EP0 is not included
242 #define DWC2_G_P_LEGACY_TX_FIFO_SIZE {256, 256, 256, 256, 768, 768, 768, \
243 768, 0, 0, 0, 0, 0, 0, 0}
245 /* Gadget ep0 states */
246 enum dwc2_ep0_state {
247 DWC2_EP0_SETUP,
248 DWC2_EP0_DATA_IN,
249 DWC2_EP0_DATA_OUT,
250 DWC2_EP0_STATUS_IN,
251 DWC2_EP0_STATUS_OUT,
255 * struct dwc2_core_params - Parameters for configuring the core
257 * @otg_cap: Specifies the OTG capabilities.
258 * 0 - HNP and SRP capable
259 * 1 - SRP Only capable
260 * 2 - No HNP/SRP capable (always available)
261 * Defaults to best available option (0, 1, then 2)
262 * @otg_ver: OTG version supported
263 * 0 - 1.3 (default)
264 * 1 - 2.0
265 * @dma_enable: Specifies whether to use slave or DMA mode for accessing
266 * the data FIFOs. The driver will automatically detect the
267 * value for this parameter if none is specified.
268 * 0 - Slave (always available)
269 * 1 - DMA (default, if available)
270 * @dma_desc_enable: When DMA mode is enabled, specifies whether to use
271 * address DMA mode or descriptor DMA mode for accessing
272 * the data FIFOs. The driver will automatically detect the
273 * value for this if none is specified.
274 * 0 - Address DMA
275 * 1 - Descriptor DMA (default, if available)
276 * @speed: Specifies the maximum speed of operation in host and
277 * device mode. The actual speed depends on the speed of
278 * the attached device and the value of phy_type.
279 * 0 - High Speed
280 * (default when phy_type is UTMI+ or ULPI)
281 * 1 - Full Speed
282 * (default when phy_type is Full Speed)
283 * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters
284 * 1 - Allow dynamic FIFO sizing (default, if available)
285 * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs
286 * are enabled
287 * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when
288 * dynamic FIFO sizing is enabled
289 * 16 to 32768
290 * Actual maximum value is autodetected and also
291 * the default.
292 * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO
293 * in host mode when dynamic FIFO sizing is enabled
294 * 16 to 32768
295 * Actual maximum value is autodetected and also
296 * the default.
297 * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in
298 * host mode when dynamic FIFO sizing is enabled
299 * 16 to 32768
300 * Actual maximum value is autodetected and also
301 * the default.
302 * @max_transfer_size: The maximum transfer size supported, in bytes
303 * 2047 to 65,535
304 * Actual maximum value is autodetected and also
305 * the default.
306 * @max_packet_count: The maximum number of packets in a transfer
307 * 15 to 511
308 * Actual maximum value is autodetected and also
309 * the default.
310 * @host_channels: The number of host channel registers to use
311 * 1 to 16
312 * Actual maximum value is autodetected and also
313 * the default.
314 * @phy_type: Specifies the type of PHY interface to use. By default,
315 * the driver will automatically detect the phy_type.
316 * 0 - Full Speed Phy
317 * 1 - UTMI+ Phy
318 * 2 - ULPI Phy
319 * Defaults to best available option (2, 1, then 0)
320 * @phy_utmi_width: Specifies the UTMI+ Data Width (in bits). This parameter
321 * is applicable for a phy_type of UTMI+ or ULPI. (For a
322 * ULPI phy_type, this parameter indicates the data width
323 * between the MAC and the ULPI Wrapper.) Also, this
324 * parameter is applicable only if the OTG_HSPHY_WIDTH cC
325 * parameter was set to "8 and 16 bits", meaning that the
326 * core has been configured to work at either data path
327 * width.
328 * 8 or 16 (default 16 if available)
329 * @phy_ulpi_ddr: Specifies whether the ULPI operates at double or single
330 * data rate. This parameter is only applicable if phy_type
331 * is ULPI.
332 * 0 - single data rate ULPI interface with 8 bit wide
333 * data bus (default)
334 * 1 - double data rate ULPI interface with 4 bit wide
335 * data bus
336 * @phy_ulpi_ext_vbus: For a ULPI phy, specifies whether to use the internal or
337 * external supply to drive the VBus
338 * 0 - Internal supply (default)
339 * 1 - External supply
340 * @i2c_enable: Specifies whether to use the I2Cinterface for a full
341 * speed PHY. This parameter is only applicable if phy_type
342 * is FS.
343 * 0 - No (default)
344 * 1 - Yes
345 * @ulpi_fs_ls: Make ULPI phy operate in FS/LS mode only
346 * 0 - No (default)
347 * 1 - Yes
348 * @host_support_fs_ls_low_power: Specifies whether low power mode is supported
349 * when attached to a Full Speed or Low Speed device in
350 * host mode.
351 * 0 - Don't support low power mode (default)
352 * 1 - Support low power mode
353 * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode
354 * when connected to a Low Speed device in host
355 * mode. This parameter is applicable only if
356 * host_support_fs_ls_low_power is enabled.
357 * 0 - 48 MHz
358 * (default when phy_type is UTMI+ or ULPI)
359 * 1 - 6 MHz
360 * (default when phy_type is Full Speed)
361 * @ts_dline: Enable Term Select Dline pulsing
362 * 0 - No (default)
363 * 1 - Yes
364 * @reload_ctl: Allow dynamic reloading of HFIR register during runtime
365 * 0 - No (default for core < 2.92a)
366 * 1 - Yes (default for core >= 2.92a)
367 * @ahbcfg: This field allows the default value of the GAHBCFG
368 * register to be overridden
369 * -1 - GAHBCFG value will be set to 0x06
370 * (INCR4, default)
371 * all others - GAHBCFG value will be overridden with
372 * this value
373 * Not all bits can be controlled like this, the
374 * bits defined by GAHBCFG_CTRL_MASK are controlled
375 * by the driver and are ignored in this
376 * configuration value.
377 * @uframe_sched: True to enable the microframe scheduler
378 * @external_id_pin_ctl: Specifies whether ID pin is handled externally.
379 * Disable CONIDSTSCHNG controller interrupt in such
380 * case.
381 * 0 - No (default)
382 * 1 - Yes
383 * @hibernation: Specifies whether the controller support hibernation.
384 * If hibernation is enabled, the controller will enter
385 * hibernation in both peripheral and host mode when
386 * needed.
387 * 0 - No (default)
388 * 1 - Yes
390 * The following parameters may be specified when starting the module. These
391 * parameters define how the DWC_otg controller should be configured. A
392 * value of -1 (or any other out of range value) for any parameter means
393 * to read the value from hardware (if possible) or use the builtin
394 * default described above.
396 struct dwc2_core_params {
398 * Don't add any non-int members here, this will break
399 * dwc2_set_all_params!
401 int otg_cap;
402 int otg_ver;
403 int dma_enable;
404 int dma_desc_enable;
405 int speed;
406 int enable_dynamic_fifo;
407 int en_multiple_tx_fifo;
408 int host_rx_fifo_size;
409 int host_nperio_tx_fifo_size;
410 int host_perio_tx_fifo_size;
411 int max_transfer_size;
412 int max_packet_count;
413 int host_channels;
414 int phy_type;
415 int phy_utmi_width;
416 int phy_ulpi_ddr;
417 int phy_ulpi_ext_vbus;
418 int i2c_enable;
419 int ulpi_fs_ls;
420 int host_support_fs_ls_low_power;
421 int host_ls_low_power_phy_clk;
422 int ts_dline;
423 int reload_ctl;
424 int ahbcfg;
425 int uframe_sched;
426 int external_id_pin_ctl;
427 int hibernation;
431 * struct dwc2_hw_params - Autodetected parameters.
433 * These parameters are the various parameters read from hardware
434 * registers during initialization. They typically contain the best
435 * supported or maximum value that can be configured in the
436 * corresponding dwc2_core_params value.
438 * The values that are not in dwc2_core_params are documented below.
440 * @op_mode Mode of Operation
441 * 0 - HNP- and SRP-Capable OTG (Host & Device)
442 * 1 - SRP-Capable OTG (Host & Device)
443 * 2 - Non-HNP and Non-SRP Capable OTG (Host & Device)
444 * 3 - SRP-Capable Device
445 * 4 - Non-OTG Device
446 * 5 - SRP-Capable Host
447 * 6 - Non-OTG Host
448 * @arch Architecture
449 * 0 - Slave only
450 * 1 - External DMA
451 * 2 - Internal DMA
452 * @power_optimized Are power optimizations enabled?
453 * @num_dev_ep Number of device endpoints available
454 * @num_dev_perio_in_ep Number of device periodic IN endpoints
455 * available
456 * @dev_token_q_depth Device Mode IN Token Sequence Learning Queue
457 * Depth
458 * 0 to 30
459 * @host_perio_tx_q_depth
460 * Host Mode Periodic Request Queue Depth
461 * 2, 4 or 8
462 * @nperio_tx_q_depth
463 * Non-Periodic Request Queue Depth
464 * 2, 4 or 8
465 * @hs_phy_type High-speed PHY interface type
466 * 0 - High-speed interface not supported
467 * 1 - UTMI+
468 * 2 - ULPI
469 * 3 - UTMI+ and ULPI
470 * @fs_phy_type Full-speed PHY interface type
471 * 0 - Full speed interface not supported
472 * 1 - Dedicated full speed interface
473 * 2 - FS pins shared with UTMI+ pins
474 * 3 - FS pins shared with ULPI pins
475 * @total_fifo_size: Total internal RAM for FIFOs (bytes)
476 * @utmi_phy_data_width UTMI+ PHY data width
477 * 0 - 8 bits
478 * 1 - 16 bits
479 * 2 - 8 or 16 bits
480 * @snpsid: Value from SNPSID register
482 struct dwc2_hw_params {
483 unsigned op_mode:3;
484 unsigned arch:2;
485 unsigned dma_desc_enable:1;
486 unsigned enable_dynamic_fifo:1;
487 unsigned en_multiple_tx_fifo:1;
488 unsigned host_rx_fifo_size:16;
489 unsigned host_nperio_tx_fifo_size:16;
490 unsigned host_perio_tx_fifo_size:16;
491 unsigned nperio_tx_q_depth:3;
492 unsigned host_perio_tx_q_depth:3;
493 unsigned dev_token_q_depth:5;
494 unsigned max_transfer_size:26;
495 unsigned max_packet_count:11;
496 unsigned host_channels:5;
497 unsigned hs_phy_type:2;
498 unsigned fs_phy_type:2;
499 unsigned i2c_enable:1;
500 unsigned num_dev_ep:4;
501 unsigned num_dev_perio_in_ep:4;
502 unsigned total_fifo_size:16;
503 unsigned power_optimized:1;
504 unsigned utmi_phy_data_width:2;
505 u32 snpsid;
508 /* Size of control and EP0 buffers */
509 #define DWC2_CTRL_BUFF_SIZE 8
512 * struct dwc2_gregs_backup - Holds global registers state before entering partial
513 * power down
514 * @gotgctl: Backup of GOTGCTL register
515 * @gintmsk: Backup of GINTMSK register
516 * @gahbcfg: Backup of GAHBCFG register
517 * @gusbcfg: Backup of GUSBCFG register
518 * @grxfsiz: Backup of GRXFSIZ register
519 * @gnptxfsiz: Backup of GNPTXFSIZ register
520 * @gi2cctl: Backup of GI2CCTL register
521 * @hptxfsiz: Backup of HPTXFSIZ register
522 * @gdfifocfg: Backup of GDFIFOCFG register
523 * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint
524 * @gpwrdn: Backup of GPWRDN register
526 struct dwc2_gregs_backup {
527 u32 gotgctl;
528 u32 gintmsk;
529 u32 gahbcfg;
530 u32 gusbcfg;
531 u32 grxfsiz;
532 u32 gnptxfsiz;
533 u32 gi2cctl;
534 u32 hptxfsiz;
535 u32 pcgcctl;
536 u32 gdfifocfg;
537 u32 dtxfsiz[MAX_EPS_CHANNELS];
538 u32 gpwrdn;
539 bool valid;
543 * struct dwc2_dregs_backup - Holds device registers state before entering partial
544 * power down
545 * @dcfg: Backup of DCFG register
546 * @dctl: Backup of DCTL register
547 * @daintmsk: Backup of DAINTMSK register
548 * @diepmsk: Backup of DIEPMSK register
549 * @doepmsk: Backup of DOEPMSK register
550 * @diepctl: Backup of DIEPCTL register
551 * @dieptsiz: Backup of DIEPTSIZ register
552 * @diepdma: Backup of DIEPDMA register
553 * @doepctl: Backup of DOEPCTL register
554 * @doeptsiz: Backup of DOEPTSIZ register
555 * @doepdma: Backup of DOEPDMA register
557 struct dwc2_dregs_backup {
558 u32 dcfg;
559 u32 dctl;
560 u32 daintmsk;
561 u32 diepmsk;
562 u32 doepmsk;
563 u32 diepctl[MAX_EPS_CHANNELS];
564 u32 dieptsiz[MAX_EPS_CHANNELS];
565 u32 diepdma[MAX_EPS_CHANNELS];
566 u32 doepctl[MAX_EPS_CHANNELS];
567 u32 doeptsiz[MAX_EPS_CHANNELS];
568 u32 doepdma[MAX_EPS_CHANNELS];
569 bool valid;
573 * struct dwc2_hregs_backup - Holds host registers state before entering partial
574 * power down
575 * @hcfg: Backup of HCFG register
576 * @haintmsk: Backup of HAINTMSK register
577 * @hcintmsk: Backup of HCINTMSK register
578 * @hptr0: Backup of HPTR0 register
579 * @hfir: Backup of HFIR register
581 struct dwc2_hregs_backup {
582 u32 hcfg;
583 u32 haintmsk;
584 u32 hcintmsk[MAX_EPS_CHANNELS];
585 u32 hprt0;
586 u32 hfir;
587 bool valid;
591 * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
592 * and periodic schedules
594 * These are common for both host and peripheral modes:
596 * @dev: The struct device pointer
597 * @regs: Pointer to controller regs
598 * @hw_params: Parameters that were autodetected from the
599 * hardware registers
600 * @core_params: Parameters that define how the core should be configured
601 * @op_state: The operational State, during transitions (a_host=>
602 * a_peripheral and b_device=>b_host) this may not match
603 * the core, but allows the software to determine
604 * transitions
605 * @dr_mode: Requested mode of operation, one of following:
606 * - USB_DR_MODE_PERIPHERAL
607 * - USB_DR_MODE_HOST
608 * - USB_DR_MODE_OTG
609 * @hcd_enabled Host mode sub-driver initialization indicator.
610 * @gadget_enabled Peripheral mode sub-driver initialization indicator.
611 * @ll_hw_enabled Status of low-level hardware resources.
612 * @phy: The otg phy transceiver structure for phy control.
613 * @uphy: The otg phy transceiver structure for old USB phy control.
614 * @plat: The platform specific configuration data. This can be removed once
615 * all SoCs support usb transceiver.
616 * @supplies: Definition of USB power supplies
617 * @phyif: PHY interface width
618 * @lock: Spinlock that protects all the driver data structures
619 * @priv: Stores a pointer to the struct usb_hcd
620 * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
621 * transfer are in process of being queued
622 * @srp_success: Stores status of SRP request in the case of a FS PHY
623 * with an I2C interface
624 * @wq_otg: Workqueue object used for handling of some interrupts
625 * @wf_otg: Work object for handling Connector ID Status Change
626 * interrupt
627 * @wkp_timer: Timer object for handling Wakeup Detected interrupt
628 * @lx_state: Lx state of connected device
629 * @gregs_backup: Backup of global registers during suspend
630 * @dregs_backup: Backup of device registers during suspend
631 * @hregs_backup: Backup of host registers during suspend
633 * These are for host mode:
635 * @flags: Flags for handling root port state changes
636 * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule.
637 * Transfers associated with these QHs are not currently
638 * assigned to a host channel.
639 * @non_periodic_sched_active: Active QHs in the non-periodic schedule.
640 * Transfers associated with these QHs are currently
641 * assigned to a host channel.
642 * @non_periodic_qh_ptr: Pointer to next QH to process in the active
643 * non-periodic schedule
644 * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a
645 * list of QHs for periodic transfers that are _not_
646 * scheduled for the next frame. Each QH in the list has an
647 * interval counter that determines when it needs to be
648 * scheduled for execution. This scheduling mechanism
649 * allows only a simple calculation for periodic bandwidth
650 * used (i.e. must assume that all periodic transfers may
651 * need to execute in the same frame). However, it greatly
652 * simplifies scheduling and should be sufficient for the
653 * vast majority of OTG hosts, which need to connect to a
654 * small number of peripherals at one time. Items move from
655 * this list to periodic_sched_ready when the QH interval
656 * counter is 0 at SOF.
657 * @periodic_sched_ready: List of periodic QHs that are ready for execution in
658 * the next frame, but have not yet been assigned to host
659 * channels. Items move from this list to
660 * periodic_sched_assigned as host channels become
661 * available during the current frame.
662 * @periodic_sched_assigned: List of periodic QHs to be executed in the next
663 * frame that are assigned to host channels. Items move
664 * from this list to periodic_sched_queued as the
665 * transactions for the QH are queued to the DWC_otg
666 * controller.
667 * @periodic_sched_queued: List of periodic QHs that have been queued for
668 * execution. Items move from this list to either
669 * periodic_sched_inactive or periodic_sched_ready when the
670 * channel associated with the transfer is released. If the
671 * interval for the QH is 1, the item moves to
672 * periodic_sched_ready because it must be rescheduled for
673 * the next frame. Otherwise, the item moves to
674 * periodic_sched_inactive.
675 * @periodic_usecs: Total bandwidth claimed so far for periodic transfers.
676 * This value is in microseconds per (micro)frame. The
677 * assumption is that all periodic transfers may occur in
678 * the same (micro)frame.
679 * @frame_usecs: Internal variable used by the microframe scheduler
680 * @frame_number: Frame number read from the core at SOF. The value ranges
681 * from 0 to HFNUM_MAX_FRNUM.
682 * @periodic_qh_count: Count of periodic QHs, if using several eps. Used for
683 * SOF enable/disable.
684 * @free_hc_list: Free host channels in the controller. This is a list of
685 * struct dwc2_host_chan items.
686 * @periodic_channels: Number of host channels assigned to periodic transfers.
687 * Currently assuming that there is a dedicated host
688 * channel for each periodic transaction and at least one
689 * host channel is available for non-periodic transactions.
690 * @non_periodic_channels: Number of host channels assigned to non-periodic
691 * transfers
692 * @available_host_channels Number of host channels available for the microframe
693 * scheduler to use
694 * @hc_ptr_array: Array of pointers to the host channel descriptors.
695 * Allows accessing a host channel descriptor given the
696 * host channel number. This is useful in interrupt
697 * handlers.
698 * @status_buf: Buffer used for data received during the status phase of
699 * a control transfer.
700 * @status_buf_dma: DMA address for status_buf
701 * @start_work: Delayed work for handling host A-cable connection
702 * @reset_work: Delayed work for handling a port reset
703 * @otg_port: OTG port number
704 * @frame_list: Frame list
705 * @frame_list_dma: Frame list DMA address
707 * These are for peripheral mode:
709 * @driver: USB gadget driver
710 * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
711 * @num_of_eps: Number of available EPs (excluding EP0)
712 * @debug_root: Root directrory for debugfs.
713 * @debug_file: Main status file for debugfs.
714 * @debug_testmode: Testmode status file for debugfs.
715 * @debug_fifo: FIFO status file for debugfs.
716 * @ep0_reply: Request used for ep0 reply.
717 * @ep0_buff: Buffer for EP0 reply data, if needed.
718 * @ctrl_buff: Buffer for EP0 control requests.
719 * @ctrl_req: Request for EP0 control packets.
720 * @ep0_state: EP0 control transfers state
721 * @test_mode: USB test mode requested by the host
722 * @eps: The endpoints being supplied to the gadget framework
723 * @g_using_dma: Indicate if dma usage is enabled
724 * @g_rx_fifo_sz: Contains rx fifo size value
725 * @g_np_g_tx_fifo_sz: Contains Non-Periodic tx fifo size value
726 * @g_tx_fifo_sz: Contains tx fifo size value per endpoints
728 struct dwc2_hsotg {
729 struct device *dev;
730 void __iomem *regs;
731 /** Params detected from hardware */
732 struct dwc2_hw_params hw_params;
733 /** Params to actually use */
734 struct dwc2_core_params *core_params;
735 enum usb_otg_state op_state;
736 enum usb_dr_mode dr_mode;
737 unsigned int hcd_enabled:1;
738 unsigned int gadget_enabled:1;
739 unsigned int ll_hw_enabled:1;
741 struct phy *phy;
742 struct usb_phy *uphy;
743 struct dwc2_hsotg_plat *plat;
744 struct regulator_bulk_data supplies[ARRAY_SIZE(dwc2_hsotg_supply_names)];
745 u32 phyif;
747 spinlock_t lock;
748 void *priv;
749 int irq;
750 struct clk *clk;
752 unsigned int queuing_high_bandwidth:1;
753 unsigned int srp_success:1;
755 struct workqueue_struct *wq_otg;
756 struct work_struct wf_otg;
757 struct timer_list wkp_timer;
758 enum dwc2_lx_state lx_state;
759 struct dwc2_gregs_backup gr_backup;
760 struct dwc2_dregs_backup dr_backup;
761 struct dwc2_hregs_backup hr_backup;
763 struct dentry *debug_root;
764 struct debugfs_regset32 *regset;
766 /* DWC OTG HW Release versions */
767 #define DWC2_CORE_REV_2_71a 0x4f54271a
768 #define DWC2_CORE_REV_2_90a 0x4f54290a
769 #define DWC2_CORE_REV_2_92a 0x4f54292a
770 #define DWC2_CORE_REV_2_94a 0x4f54294a
771 #define DWC2_CORE_REV_3_00a 0x4f54300a
773 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
774 union dwc2_hcd_internal_flags {
775 u32 d32;
776 struct {
777 unsigned port_connect_status_change:1;
778 unsigned port_connect_status:1;
779 unsigned port_reset_change:1;
780 unsigned port_enable_change:1;
781 unsigned port_suspend_change:1;
782 unsigned port_over_current_change:1;
783 unsigned port_l1_change:1;
784 unsigned reserved:25;
785 } b;
786 } flags;
788 struct list_head non_periodic_sched_inactive;
789 struct list_head non_periodic_sched_active;
790 struct list_head *non_periodic_qh_ptr;
791 struct list_head periodic_sched_inactive;
792 struct list_head periodic_sched_ready;
793 struct list_head periodic_sched_assigned;
794 struct list_head periodic_sched_queued;
795 u16 periodic_usecs;
796 u16 frame_usecs[8];
797 u16 frame_number;
798 u16 periodic_qh_count;
799 bool bus_suspended;
801 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
802 #define FRAME_NUM_ARRAY_SIZE 1000
803 u16 last_frame_num;
804 u16 *frame_num_array;
805 u16 *last_frame_num_array;
806 int frame_num_idx;
807 int dumped_frame_num_array;
808 #endif
810 struct list_head free_hc_list;
811 int periodic_channels;
812 int non_periodic_channels;
813 int available_host_channels;
814 struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS];
815 u8 *status_buf;
816 dma_addr_t status_buf_dma;
817 #define DWC2_HCD_STATUS_BUF_SIZE 64
819 struct delayed_work start_work;
820 struct delayed_work reset_work;
821 u8 otg_port;
822 u32 *frame_list;
823 dma_addr_t frame_list_dma;
825 #ifdef DEBUG
826 u32 frrem_samples;
827 u64 frrem_accum;
829 u32 hfnum_7_samples_a;
830 u64 hfnum_7_frrem_accum_a;
831 u32 hfnum_0_samples_a;
832 u64 hfnum_0_frrem_accum_a;
833 u32 hfnum_other_samples_a;
834 u64 hfnum_other_frrem_accum_a;
836 u32 hfnum_7_samples_b;
837 u64 hfnum_7_frrem_accum_b;
838 u32 hfnum_0_samples_b;
839 u64 hfnum_0_frrem_accum_b;
840 u32 hfnum_other_samples_b;
841 u64 hfnum_other_frrem_accum_b;
842 #endif
843 #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
845 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
846 /* Gadget structures */
847 struct usb_gadget_driver *driver;
848 int fifo_mem;
849 unsigned int dedicated_fifos:1;
850 unsigned char num_of_eps;
851 u32 fifo_map;
853 struct usb_request *ep0_reply;
854 struct usb_request *ctrl_req;
855 void *ep0_buff;
856 void *ctrl_buff;
857 enum dwc2_ep0_state ep0_state;
858 u8 test_mode;
860 struct usb_gadget gadget;
861 unsigned int enabled:1;
862 unsigned int connected:1;
863 struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
864 struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
865 u32 g_using_dma;
866 u32 g_rx_fifo_sz;
867 u32 g_np_g_tx_fifo_sz;
868 u32 g_tx_fifo_sz[MAX_EPS_CHANNELS];
869 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
872 /* Reasons for halting a host channel */
873 enum dwc2_halt_status {
874 DWC2_HC_XFER_NO_HALT_STATUS,
875 DWC2_HC_XFER_COMPLETE,
876 DWC2_HC_XFER_URB_COMPLETE,
877 DWC2_HC_XFER_ACK,
878 DWC2_HC_XFER_NAK,
879 DWC2_HC_XFER_NYET,
880 DWC2_HC_XFER_STALL,
881 DWC2_HC_XFER_XACT_ERR,
882 DWC2_HC_XFER_FRAME_OVERRUN,
883 DWC2_HC_XFER_BABBLE_ERR,
884 DWC2_HC_XFER_DATA_TOGGLE_ERR,
885 DWC2_HC_XFER_AHB_ERR,
886 DWC2_HC_XFER_PERIODIC_INCOMPLETE,
887 DWC2_HC_XFER_URB_DEQUEUE,
891 * The following functions support initialization of the core driver component
892 * and the DWC_otg controller
894 extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
895 extern int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg);
896 extern int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore);
899 * Host core Functions.
900 * The following functions support managing the DWC_otg controller in host
901 * mode.
903 extern void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan);
904 extern void dwc2_hc_halt(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan,
905 enum dwc2_halt_status halt_status);
906 extern void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg,
907 struct dwc2_host_chan *chan);
908 extern void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
909 struct dwc2_host_chan *chan);
910 extern void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg,
911 struct dwc2_host_chan *chan);
912 extern int dwc2_hc_continue_transfer(struct dwc2_hsotg *hsotg,
913 struct dwc2_host_chan *chan);
914 extern void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg,
915 struct dwc2_host_chan *chan);
916 extern void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg);
917 extern void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg);
919 extern u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg);
920 extern bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg);
923 * Common core Functions.
924 * The following functions support managing the DWC_otg controller in either
925 * device or host mode.
927 extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes);
928 extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
929 extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
931 extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
932 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
933 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
935 /* This function should be called on every hardware interrupt. */
936 extern irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
938 /* OTG Core Parameters */
941 * Specifies the OTG capabilities. The driver will automatically
942 * detect the value for this parameter if none is specified.
943 * 0 - HNP and SRP capable (default)
944 * 1 - SRP Only capable
945 * 2 - No HNP/SRP capable
947 extern void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val);
948 #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0
949 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE 1
950 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2
953 * Specifies whether to use slave or DMA mode for accessing the data
954 * FIFOs. The driver will automatically detect the value for this
955 * parameter if none is specified.
956 * 0 - Slave
957 * 1 - DMA (default, if available)
959 extern void dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val);
962 * When DMA mode is enabled specifies whether to use
963 * address DMA or DMA Descritor mode for accessing the data
964 * FIFOs in device mode. The driver will automatically detect
965 * the value for this parameter if none is specified.
966 * 0 - address DMA
967 * 1 - DMA Descriptor(default, if available)
969 extern void dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val);
972 * Specifies the maximum speed of operation in host and device mode.
973 * The actual speed depends on the speed of the attached device and
974 * the value of phy_type. The actual speed depends on the speed of the
975 * attached device.
976 * 0 - High Speed (default)
977 * 1 - Full Speed
979 extern void dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int val);
980 #define DWC2_SPEED_PARAM_HIGH 0
981 #define DWC2_SPEED_PARAM_FULL 1
984 * Specifies whether low power mode is supported when attached
985 * to a Full Speed or Low Speed device in host mode.
987 * 0 - Don't support low power mode (default)
988 * 1 - Support low power mode
990 extern void dwc2_set_param_host_support_fs_ls_low_power(
991 struct dwc2_hsotg *hsotg, int val);
994 * Specifies the PHY clock rate in low power mode when connected to a
995 * Low Speed device in host mode. This parameter is applicable only if
996 * HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
997 * then defaults to 6 MHZ otherwise 48 MHZ.
999 * 0 - 48 MHz
1000 * 1 - 6 MHz
1002 extern void dwc2_set_param_host_ls_low_power_phy_clk(struct dwc2_hsotg *hsotg,
1003 int val);
1004 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0
1005 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1
1008 * 0 - Use cC FIFO size parameters
1009 * 1 - Allow dynamic FIFO sizing (default)
1011 extern void dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg,
1012 int val);
1015 * Number of 4-byte words in the Rx FIFO in host mode when dynamic
1016 * FIFO sizing is enabled.
1017 * 16 to 32768 (default 1024)
1019 extern void dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val);
1022 * Number of 4-byte words in the non-periodic Tx FIFO in host mode
1023 * when Dynamic FIFO sizing is enabled in the core.
1024 * 16 to 32768 (default 256)
1026 extern void dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg,
1027 int val);
1030 * Number of 4-byte words in the host periodic Tx FIFO when dynamic
1031 * FIFO sizing is enabled.
1032 * 16 to 32768 (default 256)
1034 extern void dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg,
1035 int val);
1038 * The maximum transfer size supported in bytes.
1039 * 2047 to 65,535 (default 65,535)
1041 extern void dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val);
1044 * The maximum number of packets in a transfer.
1045 * 15 to 511 (default 511)
1047 extern void dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val);
1050 * The number of host channel registers to use.
1051 * 1 to 16 (default 11)
1052 * Note: The FPGA configuration supports a maximum of 11 host channels.
1054 extern void dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val);
1057 * Specifies the type of PHY interface to use. By default, the driver
1058 * will automatically detect the phy_type.
1060 * 0 - Full Speed PHY
1061 * 1 - UTMI+ (default)
1062 * 2 - ULPI
1064 extern void dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val);
1065 #define DWC2_PHY_TYPE_PARAM_FS 0
1066 #define DWC2_PHY_TYPE_PARAM_UTMI 1
1067 #define DWC2_PHY_TYPE_PARAM_ULPI 2
1070 * Specifies the UTMI+ Data Width. This parameter is
1071 * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
1072 * PHY_TYPE, this parameter indicates the data width between
1073 * the MAC and the ULPI Wrapper.) Also, this parameter is
1074 * applicable only if the OTG_HSPHY_WIDTH cC parameter was set
1075 * to "8 and 16 bits", meaning that the core has been
1076 * configured to work at either data path width.
1078 * 8 or 16 bits (default 16)
1080 extern void dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val);
1083 * Specifies whether the ULPI operates at double or single
1084 * data rate. This parameter is only applicable if PHY_TYPE is
1085 * ULPI.
1087 * 0 - single data rate ULPI interface with 8 bit wide data
1088 * bus (default)
1089 * 1 - double data rate ULPI interface with 4 bit wide data
1090 * bus
1092 extern void dwc2_set_param_phy_ulpi_ddr(struct dwc2_hsotg *hsotg, int val);
1095 * Specifies whether to use the internal or external supply to
1096 * drive the vbus with a ULPI phy.
1098 extern void dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val);
1099 #define DWC2_PHY_ULPI_INTERNAL_VBUS 0
1100 #define DWC2_PHY_ULPI_EXTERNAL_VBUS 1
1103 * Specifies whether to use the I2Cinterface for full speed PHY. This
1104 * parameter is only applicable if PHY_TYPE is FS.
1105 * 0 - No (default)
1106 * 1 - Yes
1108 extern void dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val);
1110 extern void dwc2_set_param_ulpi_fs_ls(struct dwc2_hsotg *hsotg, int val);
1112 extern void dwc2_set_param_ts_dline(struct dwc2_hsotg *hsotg, int val);
1115 * Specifies whether dedicated transmit FIFOs are
1116 * enabled for non periodic IN endpoints in device mode
1117 * 0 - No
1118 * 1 - Yes
1120 extern void dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg,
1121 int val);
1123 extern void dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val);
1125 extern void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val);
1127 extern void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
1129 extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
1130 const struct dwc2_core_params *params);
1132 extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
1134 extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
1136 extern int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg);
1137 extern int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg);
1140 * Dump core registers and SPRAM
1142 extern void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg);
1143 extern void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg);
1144 extern void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg);
1147 * Return OTG version - either 1.3 or 2.0
1149 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
1151 /* Gadget defines */
1152 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
1153 extern int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg);
1154 extern int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2);
1155 extern int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2);
1156 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
1157 extern void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
1158 bool reset);
1159 extern void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg);
1160 extern void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2);
1161 extern int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
1162 #define dwc2_is_device_connected(hsotg) (hsotg->connected)
1163 #else
1164 static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2)
1165 { return 0; }
1166 static inline int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2)
1167 { return 0; }
1168 static inline int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2)
1169 { return 0; }
1170 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
1171 { return 0; }
1172 static inline void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
1173 bool reset) {}
1174 static inline void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
1175 static inline void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
1176 static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
1177 int testmode)
1178 { return 0; }
1179 #define dwc2_is_device_connected(hsotg) (0)
1180 #endif
1182 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
1183 extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
1184 extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
1185 extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
1186 #else
1187 static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
1188 { return 0; }
1189 static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
1190 static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
1191 static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
1192 static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
1193 { return 0; }
1194 #endif
1196 #endif /* __DWC2_CORE_H__ */