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