1bdefa3baSNishad Kamdar /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 2197ba5f4SPaul Zimmerman /* 3197ba5f4SPaul Zimmerman * core.h - DesignWare HS OTG Controller common declarations 4197ba5f4SPaul Zimmerman * 5197ba5f4SPaul Zimmerman * Copyright (C) 2004-2013 Synopsys, Inc. 6197ba5f4SPaul Zimmerman * 7197ba5f4SPaul Zimmerman * Redistribution and use in source and binary forms, with or without 8197ba5f4SPaul Zimmerman * modification, are permitted provided that the following conditions 9197ba5f4SPaul Zimmerman * are met: 10197ba5f4SPaul Zimmerman * 1. Redistributions of source code must retain the above copyright 11197ba5f4SPaul Zimmerman * notice, this list of conditions, and the following disclaimer, 12197ba5f4SPaul Zimmerman * without modification. 13197ba5f4SPaul Zimmerman * 2. Redistributions in binary form must reproduce the above copyright 14197ba5f4SPaul Zimmerman * notice, this list of conditions and the following disclaimer in the 15197ba5f4SPaul Zimmerman * documentation and/or other materials provided with the distribution. 16197ba5f4SPaul Zimmerman * 3. The names of the above-listed copyright holders may not be used 17197ba5f4SPaul Zimmerman * to endorse or promote products derived from this software without 18197ba5f4SPaul Zimmerman * specific prior written permission. 19197ba5f4SPaul Zimmerman * 20197ba5f4SPaul Zimmerman * ALTERNATIVELY, this software may be distributed under the terms of the 21197ba5f4SPaul Zimmerman * GNU General Public License ("GPL") as published by the Free Software 22197ba5f4SPaul Zimmerman * Foundation; either version 2 of the License, or (at your option) any 23197ba5f4SPaul Zimmerman * later version. 24197ba5f4SPaul Zimmerman * 25197ba5f4SPaul Zimmerman * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 26197ba5f4SPaul Zimmerman * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 27197ba5f4SPaul Zimmerman * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28197ba5f4SPaul Zimmerman * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 29197ba5f4SPaul Zimmerman * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30197ba5f4SPaul Zimmerman * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 31197ba5f4SPaul Zimmerman * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32197ba5f4SPaul Zimmerman * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33197ba5f4SPaul Zimmerman * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34197ba5f4SPaul Zimmerman * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35197ba5f4SPaul Zimmerman * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36197ba5f4SPaul Zimmerman */ 37197ba5f4SPaul Zimmerman 38197ba5f4SPaul Zimmerman #ifndef __DWC2_CORE_H__ 39197ba5f4SPaul Zimmerman #define __DWC2_CORE_H__ 40197ba5f4SPaul Zimmerman 41f7c0b143SDinh Nguyen #include <linux/phy/phy.h> 42f7c0b143SDinh Nguyen #include <linux/regulator/consumer.h> 43f7c0b143SDinh Nguyen #include <linux/usb/gadget.h> 44f7c0b143SDinh Nguyen #include <linux/usb/otg.h> 45197ba5f4SPaul Zimmerman #include <linux/usb/phy.h> 46197ba5f4SPaul Zimmerman #include "hw.h" 47197ba5f4SPaul Zimmerman 4874fc4a75SDouglas Anderson /* 4974fc4a75SDouglas Anderson * Suggested defines for tracers: 5074fc4a75SDouglas Anderson * - no_printk: Disable tracing 5174fc4a75SDouglas Anderson * - pr_info: Print this info to the console 5274fc4a75SDouglas Anderson * - trace_printk: Print this info to trace buffer (good for verbose logging) 5374fc4a75SDouglas Anderson */ 5474fc4a75SDouglas Anderson 5574fc4a75SDouglas Anderson #define DWC2_TRACE_SCHEDULER no_printk 5674fc4a75SDouglas Anderson #define DWC2_TRACE_SCHEDULER_VB no_printk 5774fc4a75SDouglas Anderson 5874fc4a75SDouglas Anderson /* Detailed scheduler tracing, but won't overwhelm console */ 5974fc4a75SDouglas Anderson #define dwc2_sch_dbg(hsotg, fmt, ...) \ 6074fc4a75SDouglas Anderson DWC2_TRACE_SCHEDULER(pr_fmt("%s: SCH: " fmt), \ 6174fc4a75SDouglas Anderson dev_name(hsotg->dev), ##__VA_ARGS__) 6274fc4a75SDouglas Anderson 6374fc4a75SDouglas Anderson /* Verbose scheduler tracing */ 6474fc4a75SDouglas Anderson #define dwc2_sch_vdbg(hsotg, fmt, ...) \ 6574fc4a75SDouglas Anderson DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \ 6674fc4a75SDouglas Anderson dev_name(hsotg->dev), ##__VA_ARGS__) 6774fc4a75SDouglas Anderson 68197ba5f4SPaul Zimmerman /* Maximum number of Endpoints/HostChannels */ 69197ba5f4SPaul Zimmerman #define MAX_EPS_CHANNELS 16 70197ba5f4SPaul Zimmerman 711f91b4ccSFelipe Balbi /* dwc2-hsotg declarations */ 721f91b4ccSFelipe Balbi static const char * const dwc2_hsotg_supply_names[] = { 73f7c0b143SDinh Nguyen "vusb_d", /* digital USB supply, 1.2V */ 74f7c0b143SDinh Nguyen "vusb_a", /* analog USB supply, 1.1V */ 75f7c0b143SDinh Nguyen }; 76f7c0b143SDinh Nguyen 77b98866c2SJohn Youn #define DWC2_NUM_SUPPLIES ARRAY_SIZE(dwc2_hsotg_supply_names) 78b98866c2SJohn Youn 79f7c0b143SDinh Nguyen /* 80f7c0b143SDinh Nguyen * EP0_MPS_LIMIT 81f7c0b143SDinh Nguyen * 82f7c0b143SDinh Nguyen * Unfortunately there seems to be a limit of the amount of data that can 83f7c0b143SDinh Nguyen * be transferred by IN transactions on EP0. This is either 127 bytes or 3 84f7c0b143SDinh Nguyen * packets (which practically means 1 packet and 63 bytes of data) when the 85f7c0b143SDinh Nguyen * MPS is set to 64. 86f7c0b143SDinh Nguyen * 87f7c0b143SDinh Nguyen * This means if we are wanting to move >127 bytes of data, we need to 88f7c0b143SDinh Nguyen * split the transactions up, but just doing one packet at a time does 89f7c0b143SDinh Nguyen * not work (this may be an implicit DATA0 PID on first packet of the 90f7c0b143SDinh Nguyen * transaction) and doing 2 packets is outside the controller's limits. 91f7c0b143SDinh Nguyen * 92f7c0b143SDinh Nguyen * If we try to lower the MPS size for EP0, then no transfers work properly 93f7c0b143SDinh Nguyen * for EP0, and the system will fail basic enumeration. As no cause for this 94f7c0b143SDinh Nguyen * has currently been found, we cannot support any large IN transfers for 95f7c0b143SDinh Nguyen * EP0. 96f7c0b143SDinh Nguyen */ 97f7c0b143SDinh Nguyen #define EP0_MPS_LIMIT 64 98f7c0b143SDinh Nguyen 99941fcce4SDinh Nguyen struct dwc2_hsotg; 1001f91b4ccSFelipe Balbi struct dwc2_hsotg_req; 101f7c0b143SDinh Nguyen 102f7c0b143SDinh Nguyen /** 1031f91b4ccSFelipe Balbi * struct dwc2_hsotg_ep - driver endpoint definition. 104f7c0b143SDinh Nguyen * @ep: The gadget layer representation of the endpoint. 105f7c0b143SDinh Nguyen * @name: The driver generated name for the endpoint. 106f7c0b143SDinh Nguyen * @queue: Queue of requests for this endpoint. 107f7c0b143SDinh Nguyen * @parent: Reference back to the parent device structure. 108f7c0b143SDinh Nguyen * @req: The current request that the endpoint is processing. This is 109f7c0b143SDinh Nguyen * used to indicate an request has been loaded onto the endpoint 110f7c0b143SDinh Nguyen * and has yet to be completed (maybe due to data move, or simply 111f7c0b143SDinh Nguyen * awaiting an ack from the core all the data has been completed). 112f7c0b143SDinh Nguyen * @debugfs: File entry for debugfs file for this endpoint. 113f7c0b143SDinh Nguyen * @dir_in: Set to true if this endpoint is of the IN direction, which 114f7c0b143SDinh Nguyen * means that it is sending data to the Host. 115f7c0b143SDinh Nguyen * @index: The index for the endpoint registers. 116f7c0b143SDinh Nguyen * @mc: Multi Count - number of transactions per microframe 1176fb914d7SGrigor Tovmasyan * @interval: Interval for periodic endpoints, in frames or microframes. 118f7c0b143SDinh Nguyen * @name: The name array passed to the USB core. 119f7c0b143SDinh Nguyen * @halted: Set if the endpoint has been halted. 120f7c0b143SDinh Nguyen * @periodic: Set if this is a periodic ep, such as Interrupt 121f7c0b143SDinh Nguyen * @isochronous: Set if this is a isochronous ep 1228a20fa45SMian Yousaf Kaukab * @send_zlp: Set if we need to send a zero-length packet. 1235f54c54bSVahram Aharonyan * @desc_list_dma: The DMA address of descriptor chain currently in use. 1245f54c54bSVahram Aharonyan * @desc_list: Pointer to descriptor DMA chain head currently in use. 1255f54c54bSVahram Aharonyan * @desc_count: Count of entries within the DMA descriptor chain of EP. 126ab7d2192SVahram Aharonyan * @next_desc: index of next free descriptor in the ISOC chain under SW control. 127729cac69SMinas Harutyunyan * @compl_desc: index of next descriptor to be completed by xFerComplete 128f7c0b143SDinh Nguyen * @total_data: The total number of data bytes done. 129f7c0b143SDinh Nguyen * @fifo_size: The size of the FIFO (for periodic IN endpoints) 1306fb914d7SGrigor Tovmasyan * @fifo_index: For Dedicated FIFO operation, only FIFO0 can be used for EP0. 131f7c0b143SDinh Nguyen * @fifo_load: The amount of data loaded into the FIFO (periodic IN) 132f7c0b143SDinh Nguyen * @last_load: The offset of data for the last start of request. 133f7c0b143SDinh Nguyen * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN 13492d1635dSVardan Mikayelyan * @target_frame: Targeted frame num to setup next ISOC transfer 13592d1635dSVardan Mikayelyan * @frame_overrun: Indicates SOF number overrun in DSTS 136f7c0b143SDinh Nguyen * 137c1aa81daSGeert Uytterhoeven * This is the driver's state for each registered endpoint, allowing it 138f7c0b143SDinh Nguyen * to keep track of transactions that need doing. Each endpoint has a 139f7c0b143SDinh Nguyen * lock to protect the state, to try and avoid using an overall lock 140f7c0b143SDinh Nguyen * for the host controller as much as possible. 141f7c0b143SDinh Nguyen * 142f7c0b143SDinh Nguyen * For periodic IN endpoints, we have fifo_size and fifo_load to try 143f7c0b143SDinh Nguyen * and keep track of the amount of data in the periodic FIFO for each 144f7c0b143SDinh Nguyen * of these as we don't have a status register that tells us how much 145f7c0b143SDinh Nguyen * is in each of them. (note, this may actually be useless information 146f7c0b143SDinh Nguyen * as in shared-fifo mode periodic in acts like a single-frame packet 147f7c0b143SDinh Nguyen * buffer than a fifo) 148f7c0b143SDinh Nguyen */ 1491f91b4ccSFelipe Balbi struct dwc2_hsotg_ep { 150f7c0b143SDinh Nguyen struct usb_ep ep; 151f7c0b143SDinh Nguyen struct list_head queue; 152941fcce4SDinh Nguyen struct dwc2_hsotg *parent; 1531f91b4ccSFelipe Balbi struct dwc2_hsotg_req *req; 154f7c0b143SDinh Nguyen struct dentry *debugfs; 155f7c0b143SDinh Nguyen 156f7c0b143SDinh Nguyen unsigned long total_data; 157f7c0b143SDinh Nguyen unsigned int size_loaded; 158f7c0b143SDinh Nguyen unsigned int last_load; 159f7c0b143SDinh Nguyen unsigned int fifo_load; 160f7c0b143SDinh Nguyen unsigned short fifo_size; 161b203d0a2SRobert Baldyga unsigned short fifo_index; 162f7c0b143SDinh Nguyen 163f7c0b143SDinh Nguyen unsigned char dir_in; 164f7c0b143SDinh Nguyen unsigned char index; 165f7c0b143SDinh Nguyen unsigned char mc; 16612814a3fSGrigor Tovmasyan u16 interval; 167f7c0b143SDinh Nguyen 168f7c0b143SDinh Nguyen unsigned int halted:1; 169f7c0b143SDinh Nguyen unsigned int periodic:1; 170f7c0b143SDinh Nguyen unsigned int isochronous:1; 1718a20fa45SMian Yousaf Kaukab unsigned int send_zlp:1; 17292d1635dSVardan Mikayelyan unsigned int target_frame; 17392d1635dSVardan Mikayelyan #define TARGET_FRAME_INITIAL 0xFFFFFFFF 17492d1635dSVardan Mikayelyan bool frame_overrun; 175f7c0b143SDinh Nguyen 1765f54c54bSVahram Aharonyan dma_addr_t desc_list_dma; 1775f54c54bSVahram Aharonyan struct dwc2_dma_desc *desc_list; 1785f54c54bSVahram Aharonyan u8 desc_count; 1795f54c54bSVahram Aharonyan 180ab7d2192SVahram Aharonyan unsigned int next_desc; 181729cac69SMinas Harutyunyan unsigned int compl_desc; 182ab7d2192SVahram Aharonyan 183f7c0b143SDinh Nguyen char name[10]; 184f7c0b143SDinh Nguyen }; 185f7c0b143SDinh Nguyen 186f7c0b143SDinh Nguyen /** 1871f91b4ccSFelipe Balbi * struct dwc2_hsotg_req - data transfer request 188f7c0b143SDinh Nguyen * @req: The USB gadget request 189f7c0b143SDinh Nguyen * @queue: The list of requests for the endpoint this is queued for. 1907d24c1b5SMian Yousaf Kaukab * @saved_req_buf: variable to save req.buf when bounce buffers are used. 191f7c0b143SDinh Nguyen */ 1921f91b4ccSFelipe Balbi struct dwc2_hsotg_req { 193f7c0b143SDinh Nguyen struct usb_request req; 194f7c0b143SDinh Nguyen struct list_head queue; 1957d24c1b5SMian Yousaf Kaukab void *saved_req_buf; 196f7c0b143SDinh Nguyen }; 197f7c0b143SDinh Nguyen 198b98866c2SJohn Youn #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 199b98866c2SJohn Youn IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 200f7c0b143SDinh Nguyen #define call_gadget(_hs, _entry) \ 201f7c0b143SDinh Nguyen do { \ 202f7c0b143SDinh Nguyen if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \ 203f7c0b143SDinh Nguyen (_hs)->driver && (_hs)->driver->_entry) { \ 204f7c0b143SDinh Nguyen spin_unlock(&_hs->lock); \ 205f7c0b143SDinh Nguyen (_hs)->driver->_entry(&(_hs)->gadget); \ 206f7c0b143SDinh Nguyen spin_lock(&_hs->lock); \ 207f7c0b143SDinh Nguyen } \ 208f7c0b143SDinh Nguyen } while (0) 209941fcce4SDinh Nguyen #else 210941fcce4SDinh Nguyen #define call_gadget(_hs, _entry) do {} while (0) 211941fcce4SDinh Nguyen #endif 212f7c0b143SDinh Nguyen 213197ba5f4SPaul Zimmerman struct dwc2_hsotg; 214197ba5f4SPaul Zimmerman struct dwc2_host_chan; 215197ba5f4SPaul Zimmerman 216197ba5f4SPaul Zimmerman /* Device States */ 217197ba5f4SPaul Zimmerman enum dwc2_lx_state { 218197ba5f4SPaul Zimmerman DWC2_L0, /* On state */ 219197ba5f4SPaul Zimmerman DWC2_L1, /* LPM sleep state */ 220197ba5f4SPaul Zimmerman DWC2_L2, /* USB suspend state */ 221197ba5f4SPaul Zimmerman DWC2_L3, /* Off state */ 222197ba5f4SPaul Zimmerman }; 223197ba5f4SPaul Zimmerman 224fe0b94abSMian Yousaf Kaukab /* Gadget ep0 states */ 225fe0b94abSMian Yousaf Kaukab enum dwc2_ep0_state { 226fe0b94abSMian Yousaf Kaukab DWC2_EP0_SETUP, 227fe0b94abSMian Yousaf Kaukab DWC2_EP0_DATA_IN, 228fe0b94abSMian Yousaf Kaukab DWC2_EP0_DATA_OUT, 229fe0b94abSMian Yousaf Kaukab DWC2_EP0_STATUS_IN, 230fe0b94abSMian Yousaf Kaukab DWC2_EP0_STATUS_OUT, 231fe0b94abSMian Yousaf Kaukab }; 232fe0b94abSMian Yousaf Kaukab 233197ba5f4SPaul Zimmerman /** 234197ba5f4SPaul Zimmerman * struct dwc2_core_params - Parameters for configuring the core 235197ba5f4SPaul Zimmerman * 236197ba5f4SPaul Zimmerman * @otg_cap: Specifies the OTG capabilities. 237197ba5f4SPaul Zimmerman * 0 - HNP and SRP capable 238197ba5f4SPaul Zimmerman * 1 - SRP Only capable 239197ba5f4SPaul Zimmerman * 2 - No HNP/SRP capable (always available) 240197ba5f4SPaul Zimmerman * Defaults to best available option (0, 1, then 2) 241e7839f99SJohn Youn * @host_dma: Specifies whether to use slave or DMA mode for accessing 242197ba5f4SPaul Zimmerman * the data FIFOs. The driver will automatically detect the 243197ba5f4SPaul Zimmerman * value for this parameter if none is specified. 244197ba5f4SPaul Zimmerman * 0 - Slave (always available) 245197ba5f4SPaul Zimmerman * 1 - DMA (default, if available) 246197ba5f4SPaul Zimmerman * @dma_desc_enable: When DMA mode is enabled, specifies whether to use 247197ba5f4SPaul Zimmerman * address DMA mode or descriptor DMA mode for accessing 248197ba5f4SPaul Zimmerman * the data FIFOs. The driver will automatically detect the 249197ba5f4SPaul Zimmerman * value for this if none is specified. 250197ba5f4SPaul Zimmerman * 0 - Address DMA 251197ba5f4SPaul Zimmerman * 1 - Descriptor DMA (default, if available) 252fbb9e22bSMian Yousaf Kaukab * @dma_desc_fs_enable: When DMA mode is enabled, specifies whether to use 253fbb9e22bSMian Yousaf Kaukab * address DMA mode or descriptor DMA mode for accessing 254fbb9e22bSMian Yousaf Kaukab * the data FIFOs in Full Speed mode only. The driver 255fbb9e22bSMian Yousaf Kaukab * will automatically detect the value for this if none is 256fbb9e22bSMian Yousaf Kaukab * specified. 257fbb9e22bSMian Yousaf Kaukab * 0 - Address DMA 258fbb9e22bSMian Yousaf Kaukab * 1 - Descriptor DMA in FS (default, if available) 259197ba5f4SPaul Zimmerman * @speed: Specifies the maximum speed of operation in host and 260197ba5f4SPaul Zimmerman * device mode. The actual speed depends on the speed of 261197ba5f4SPaul Zimmerman * the attached device and the value of phy_type. 262197ba5f4SPaul Zimmerman * 0 - High Speed 263197ba5f4SPaul Zimmerman * (default when phy_type is UTMI+ or ULPI) 264197ba5f4SPaul Zimmerman * 1 - Full Speed 265197ba5f4SPaul Zimmerman * (default when phy_type is Full Speed) 266197ba5f4SPaul Zimmerman * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters 267197ba5f4SPaul Zimmerman * 1 - Allow dynamic FIFO sizing (default, if available) 268197ba5f4SPaul Zimmerman * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs 269c1d286cfSJohn Youn * are enabled for non-periodic IN endpoints in device 270c1d286cfSJohn Youn * mode. 271197ba5f4SPaul Zimmerman * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when 272197ba5f4SPaul Zimmerman * dynamic FIFO sizing is enabled 273197ba5f4SPaul Zimmerman * 16 to 32768 274197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 275197ba5f4SPaul Zimmerman * the default. 276197ba5f4SPaul Zimmerman * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 277197ba5f4SPaul Zimmerman * in host mode when dynamic FIFO sizing is enabled 278197ba5f4SPaul Zimmerman * 16 to 32768 279197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 280197ba5f4SPaul Zimmerman * the default. 281197ba5f4SPaul Zimmerman * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in 282197ba5f4SPaul Zimmerman * host mode when dynamic FIFO sizing is enabled 283197ba5f4SPaul Zimmerman * 16 to 32768 284197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 285197ba5f4SPaul Zimmerman * the default. 286197ba5f4SPaul Zimmerman * @max_transfer_size: The maximum transfer size supported, in bytes 287197ba5f4SPaul Zimmerman * 2047 to 65,535 288197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 289197ba5f4SPaul Zimmerman * the default. 290197ba5f4SPaul Zimmerman * @max_packet_count: The maximum number of packets in a transfer 291197ba5f4SPaul Zimmerman * 15 to 511 292197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 293197ba5f4SPaul Zimmerman * the default. 294197ba5f4SPaul Zimmerman * @host_channels: The number of host channel registers to use 295197ba5f4SPaul Zimmerman * 1 to 16 296197ba5f4SPaul Zimmerman * Actual maximum value is autodetected and also 297197ba5f4SPaul Zimmerman * the default. 298197ba5f4SPaul Zimmerman * @phy_type: Specifies the type of PHY interface to use. By default, 299197ba5f4SPaul Zimmerman * the driver will automatically detect the phy_type. 300197ba5f4SPaul Zimmerman * 0 - Full Speed Phy 301197ba5f4SPaul Zimmerman * 1 - UTMI+ Phy 302197ba5f4SPaul Zimmerman * 2 - ULPI Phy 303197ba5f4SPaul Zimmerman * Defaults to best available option (2, 1, then 0) 304197ba5f4SPaul Zimmerman * @phy_utmi_width: Specifies the UTMI+ Data Width (in bits). This parameter 305197ba5f4SPaul Zimmerman * is applicable for a phy_type of UTMI+ or ULPI. (For a 306197ba5f4SPaul Zimmerman * ULPI phy_type, this parameter indicates the data width 307197ba5f4SPaul Zimmerman * between the MAC and the ULPI Wrapper.) Also, this 308197ba5f4SPaul Zimmerman * parameter is applicable only if the OTG_HSPHY_WIDTH cC 309197ba5f4SPaul Zimmerman * parameter was set to "8 and 16 bits", meaning that the 310197ba5f4SPaul Zimmerman * core has been configured to work at either data path 311197ba5f4SPaul Zimmerman * width. 312197ba5f4SPaul Zimmerman * 8 or 16 (default 16 if available) 313197ba5f4SPaul Zimmerman * @phy_ulpi_ddr: Specifies whether the ULPI operates at double or single 314197ba5f4SPaul Zimmerman * data rate. This parameter is only applicable if phy_type 315197ba5f4SPaul Zimmerman * is ULPI. 316197ba5f4SPaul Zimmerman * 0 - single data rate ULPI interface with 8 bit wide 317197ba5f4SPaul Zimmerman * data bus (default) 318197ba5f4SPaul Zimmerman * 1 - double data rate ULPI interface with 4 bit wide 319197ba5f4SPaul Zimmerman * data bus 320197ba5f4SPaul Zimmerman * @phy_ulpi_ext_vbus: For a ULPI phy, specifies whether to use the internal or 321197ba5f4SPaul Zimmerman * external supply to drive the VBus 322197ba5f4SPaul Zimmerman * 0 - Internal supply (default) 323197ba5f4SPaul Zimmerman * 1 - External supply 324197ba5f4SPaul Zimmerman * @i2c_enable: Specifies whether to use the I2Cinterface for a full 325197ba5f4SPaul Zimmerman * speed PHY. This parameter is only applicable if phy_type 326197ba5f4SPaul Zimmerman * is FS. 327197ba5f4SPaul Zimmerman * 0 - No (default) 328197ba5f4SPaul Zimmerman * 1 - Yes 3296fb914d7SGrigor Tovmasyan * @ipg_isoc_en: Indicates the IPG supports is enabled or disabled. 330b43ebc96SGrigor Tovmasyan * 0 - Disable (default) 331b43ebc96SGrigor Tovmasyan * 1 - Enable 3326fb914d7SGrigor Tovmasyan * @acg_enable: For enabling Active Clock Gating in the controller 3336fb914d7SGrigor Tovmasyan * 0 - No 3346fb914d7SGrigor Tovmasyan * 1 - Yes 335197ba5f4SPaul Zimmerman * @ulpi_fs_ls: Make ULPI phy operate in FS/LS mode only 336197ba5f4SPaul Zimmerman * 0 - No (default) 337197ba5f4SPaul Zimmerman * 1 - Yes 338197ba5f4SPaul Zimmerman * @host_support_fs_ls_low_power: Specifies whether low power mode is supported 339197ba5f4SPaul Zimmerman * when attached to a Full Speed or Low Speed device in 340197ba5f4SPaul Zimmerman * host mode. 341197ba5f4SPaul Zimmerman * 0 - Don't support low power mode (default) 342197ba5f4SPaul Zimmerman * 1 - Support low power mode 343197ba5f4SPaul Zimmerman * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode 344197ba5f4SPaul Zimmerman * when connected to a Low Speed device in host 345197ba5f4SPaul Zimmerman * mode. This parameter is applicable only if 346197ba5f4SPaul Zimmerman * host_support_fs_ls_low_power is enabled. 347197ba5f4SPaul Zimmerman * 0 - 48 MHz 348197ba5f4SPaul Zimmerman * (default when phy_type is UTMI+ or ULPI) 349197ba5f4SPaul Zimmerman * 1 - 6 MHz 350197ba5f4SPaul Zimmerman * (default when phy_type is Full Speed) 351b11633c4SDinh Nguyen * @oc_disable: Flag to disable overcurrent condition. 352b11633c4SDinh Nguyen * 0 - Allow overcurrent condition to get detected 353b11633c4SDinh Nguyen * 1 - Disable overcurrent condtion to get detected 354197ba5f4SPaul Zimmerman * @ts_dline: Enable Term Select Dline pulsing 355197ba5f4SPaul Zimmerman * 0 - No (default) 356197ba5f4SPaul Zimmerman * 1 - Yes 357197ba5f4SPaul Zimmerman * @reload_ctl: Allow dynamic reloading of HFIR register during runtime 358197ba5f4SPaul Zimmerman * 0 - No (default for core < 2.92a) 359197ba5f4SPaul Zimmerman * 1 - Yes (default for core >= 2.92a) 360197ba5f4SPaul Zimmerman * @ahbcfg: This field allows the default value of the GAHBCFG 361197ba5f4SPaul Zimmerman * register to be overridden 362197ba5f4SPaul Zimmerman * -1 - GAHBCFG value will be set to 0x06 3631b52d2faSRazmik Karapetyan * (INCR, default) 364197ba5f4SPaul Zimmerman * all others - GAHBCFG value will be overridden with 365197ba5f4SPaul Zimmerman * this value 366197ba5f4SPaul Zimmerman * Not all bits can be controlled like this, the 367197ba5f4SPaul Zimmerman * bits defined by GAHBCFG_CTRL_MASK are controlled 368197ba5f4SPaul Zimmerman * by the driver and are ignored in this 369197ba5f4SPaul Zimmerman * configuration value. 370197ba5f4SPaul Zimmerman * @uframe_sched: True to enable the microframe scheduler 371a6d249d8SGregory Herrero * @external_id_pin_ctl: Specifies whether ID pin is handled externally. 372a6d249d8SGregory Herrero * Disable CONIDSTSCHNG controller interrupt in such 373a6d249d8SGregory Herrero * case. 374a6d249d8SGregory Herrero * 0 - No (default) 375a6d249d8SGregory Herrero * 1 - Yes 37641ba9b9bSVardan Mikayelyan * @power_down: Specifies whether the controller support power_down. 37741ba9b9bSVardan Mikayelyan * If power_down is enabled, the controller will enter 37841ba9b9bSVardan Mikayelyan * power_down in both peripheral and host mode when 379285046aaSGregory Herrero * needed. 380285046aaSGregory Herrero * 0 - No (default) 381631a2310SVardan Mikayelyan * 1 - Partial power down 382631a2310SVardan Mikayelyan * 2 - Hibernation 3836f80b6deSSevak Arakelyan * @lpm: Enable LPM support. 3846f80b6deSSevak Arakelyan * 0 - No 3856f80b6deSSevak Arakelyan * 1 - Yes 3866f80b6deSSevak Arakelyan * @lpm_clock_gating: Enable core PHY clock gating. 3876f80b6deSSevak Arakelyan * 0 - No 3886f80b6deSSevak Arakelyan * 1 - Yes 3896f80b6deSSevak Arakelyan * @besl: Enable LPM Errata support. 3906f80b6deSSevak Arakelyan * 0 - No 3916f80b6deSSevak Arakelyan * 1 - Yes 3926f80b6deSSevak Arakelyan * @hird_threshold_en: HIRD or HIRD Threshold enable. 3936f80b6deSSevak Arakelyan * 0 - No 3946f80b6deSSevak Arakelyan * 1 - Yes 3956f80b6deSSevak Arakelyan * @hird_threshold: Value of BESL or HIRD Threshold. 396f3a61e4eSGrigor Tovmasyan * @ref_clk_per: Indicates in terms of pico seconds the period 397f3a61e4eSGrigor Tovmasyan * of ref_clk. 398f3a61e4eSGrigor Tovmasyan * 62500 - 16MHz 399f3a61e4eSGrigor Tovmasyan * 58823 - 17MHz 400f3a61e4eSGrigor Tovmasyan * 52083 - 19.2MHz 401f3a61e4eSGrigor Tovmasyan * 50000 - 20MHz 402f3a61e4eSGrigor Tovmasyan * 41666 - 24MHz 403f3a61e4eSGrigor Tovmasyan * 33333 - 30MHz (default) 404f3a61e4eSGrigor Tovmasyan * 25000 - 40MHz 405f3a61e4eSGrigor Tovmasyan * @sof_cnt_wkup_alert: Indicates in term of number of SOF's after which 406f3a61e4eSGrigor Tovmasyan * the controller should generate an interrupt if the 407f3a61e4eSGrigor Tovmasyan * device had been in L1 state until that period. 408f3a61e4eSGrigor Tovmasyan * This is used by SW to initiate Remote WakeUp in the 409f3a61e4eSGrigor Tovmasyan * controller so as to sync to the uF number from the host. 410e35b1350SBruno Herrera * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO 411e35b1350SBruno Herrera * register. 412e35b1350SBruno Herrera * 0 - Deactivate the transceiver (default) 413e35b1350SBruno Herrera * 1 - Activate the transceiver 414a415083aSAmelie Delaunay * @activate_stm_id_vb_detection: Activate external ID pin and Vbus level 415a415083aSAmelie Delaunay * detection using GGPIO register. 416a415083aSAmelie Delaunay * 0 - Deactivate the external level detection (default) 417a415083aSAmelie Delaunay * 1 - Activate the external level detection 4189962b62fSJohn Youn * @g_dma: Enables gadget dma usage (default: autodetect). 419dec4b556SVahram Aharonyan * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect). 42005ee799fSJohn Youn * @g_rx_fifo_size: The periodic rx fifo size for the device, in 42105ee799fSJohn Youn * DWORDS from 16-32768 (default: 2048 if 42205ee799fSJohn Youn * possible, otherwise autodetect). 42305ee799fSJohn Youn * @g_np_tx_fifo_size: The non-periodic tx fifo size for the device in 42405ee799fSJohn Youn * DWORDS from 16-32768 (default: 1024 if 42505ee799fSJohn Youn * possible, otherwise autodetect). 42605ee799fSJohn Youn * @g_tx_fifo_size: An array of TX fifo sizes in dedicated fifo 42705ee799fSJohn Youn * mode. Each value corresponds to one EP 42805ee799fSJohn Youn * starting from EP1 (max 15 values). Sizes are 429*f8590006STian Tao * in DWORDS with possible values from 43005ee799fSJohn Youn * 16-32768 (default: 256, 256, 256, 256, 768, 43105ee799fSJohn Youn * 768, 768, 768, 0, 0, 0, 0, 0, 0, 0). 432ca8b0332SChen Yu * @change_speed_quirk: Change speed configuration to DWC2_SPEED_PARAM_FULL 433ca8b0332SChen Yu * while full&low speed device connect. And change speed 434ca8b0332SChen Yu * back to DWC2_SPEED_PARAM_HIGH while device is gone. 435ca8b0332SChen Yu * 0 - No (default) 436ca8b0332SChen Yu * 1 - Yes 437ca531bc2SGrigor Tovmasyan * @service_interval: Enable service interval based scheduling. 438ca531bc2SGrigor Tovmasyan * 0 - No 439ca531bc2SGrigor Tovmasyan * 1 - Yes 440197ba5f4SPaul Zimmerman * 441197ba5f4SPaul Zimmerman * The following parameters may be specified when starting the module. These 442197ba5f4SPaul Zimmerman * parameters define how the DWC_otg controller should be configured. A 443197ba5f4SPaul Zimmerman * value of -1 (or any other out of range value) for any parameter means 444197ba5f4SPaul Zimmerman * to read the value from hardware (if possible) or use the builtin 445197ba5f4SPaul Zimmerman * default described above. 446197ba5f4SPaul Zimmerman */ 447197ba5f4SPaul Zimmerman struct dwc2_core_params { 448d21bcc3fSJohn Youn u8 otg_cap; 449c1d286cfSJohn Youn #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 450c1d286cfSJohn Youn #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE 1 451c1d286cfSJohn Youn #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 452c1d286cfSJohn Youn 453d21bcc3fSJohn Youn u8 phy_type; 454c1d286cfSJohn Youn #define DWC2_PHY_TYPE_PARAM_FS 0 455c1d286cfSJohn Youn #define DWC2_PHY_TYPE_PARAM_UTMI 1 456c1d286cfSJohn Youn #define DWC2_PHY_TYPE_PARAM_ULPI 2 457c1d286cfSJohn Youn 45857b8e235SJohn Youn u8 speed; 45957b8e235SJohn Youn #define DWC2_SPEED_PARAM_HIGH 0 46057b8e235SJohn Youn #define DWC2_SPEED_PARAM_FULL 1 46157b8e235SJohn Youn #define DWC2_SPEED_PARAM_LOW 2 46257b8e235SJohn Youn 463d21bcc3fSJohn Youn u8 phy_utmi_width; 464d21bcc3fSJohn Youn bool phy_ulpi_ddr; 465d21bcc3fSJohn Youn bool phy_ulpi_ext_vbus; 46657b8e235SJohn Youn bool enable_dynamic_fifo; 46757b8e235SJohn Youn bool en_multiple_tx_fifo; 468d21bcc3fSJohn Youn bool i2c_enable; 46966e77a24SRazmik Karapetyan bool acg_enable; 470d21bcc3fSJohn Youn bool ulpi_fs_ls; 47157b8e235SJohn Youn bool ts_dline; 47257b8e235SJohn Youn bool reload_ctl; 47357b8e235SJohn Youn bool uframe_sched; 47457b8e235SJohn Youn bool external_id_pin_ctl; 475631a2310SVardan Mikayelyan 476631a2310SVardan Mikayelyan int power_down; 477631a2310SVardan Mikayelyan #define DWC2_POWER_DOWN_PARAM_NONE 0 478631a2310SVardan Mikayelyan #define DWC2_POWER_DOWN_PARAM_PARTIAL 1 479631a2310SVardan Mikayelyan #define DWC2_POWER_DOWN_PARAM_HIBERNATION 2 480631a2310SVardan Mikayelyan 4816f80b6deSSevak Arakelyan bool lpm; 4826f80b6deSSevak Arakelyan bool lpm_clock_gating; 4836f80b6deSSevak Arakelyan bool besl; 4846f80b6deSSevak Arakelyan bool hird_threshold_en; 485ca531bc2SGrigor Tovmasyan bool service_interval; 4866f80b6deSSevak Arakelyan u8 hird_threshold; 487e35b1350SBruno Herrera bool activate_stm_fs_transceiver; 488a415083aSAmelie Delaunay bool activate_stm_id_vb_detection; 489b43ebc96SGrigor Tovmasyan bool ipg_isoc_en; 49057b8e235SJohn Youn u16 max_packet_count; 49157b8e235SJohn Youn u32 max_transfer_size; 49257b8e235SJohn Youn u32 ahbcfg; 49357b8e235SJohn Youn 494f3a61e4eSGrigor Tovmasyan /* GREFCLK parameters */ 495f3a61e4eSGrigor Tovmasyan u32 ref_clk_per; 496f3a61e4eSGrigor Tovmasyan u16 sof_cnt_wkup_alert; 497f3a61e4eSGrigor Tovmasyan 49857b8e235SJohn Youn /* Host parameters */ 49957b8e235SJohn Youn bool host_dma; 50057b8e235SJohn Youn bool dma_desc_enable; 50157b8e235SJohn Youn bool dma_desc_fs_enable; 502d21bcc3fSJohn Youn bool host_support_fs_ls_low_power; 503d21bcc3fSJohn Youn bool host_ls_low_power_phy_clk; 504b11633c4SDinh Nguyen bool oc_disable; 505c1d286cfSJohn Youn 50657b8e235SJohn Youn u8 host_channels; 50757b8e235SJohn Youn u16 host_rx_fifo_size; 50857b8e235SJohn Youn u16 host_nperio_tx_fifo_size; 50957b8e235SJohn Youn u16 host_perio_tx_fifo_size; 5106b66ce51SJohn Youn 5116b66ce51SJohn Youn /* Gadget parameters */ 51205ee799fSJohn Youn bool g_dma; 513dec4b556SVahram Aharonyan bool g_dma_desc; 51400c704ccSLeo Yan u32 g_rx_fifo_size; 51500c704ccSLeo Yan u32 g_np_tx_fifo_size; 51605ee799fSJohn Youn u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; 517ca8b0332SChen Yu 518ca8b0332SChen Yu bool change_speed_quirk; 519197ba5f4SPaul Zimmerman }; 520197ba5f4SPaul Zimmerman 521197ba5f4SPaul Zimmerman /** 522197ba5f4SPaul Zimmerman * struct dwc2_hw_params - Autodetected parameters. 523197ba5f4SPaul Zimmerman * 524197ba5f4SPaul Zimmerman * These parameters are the various parameters read from hardware 525197ba5f4SPaul Zimmerman * registers during initialization. They typically contain the best 526197ba5f4SPaul Zimmerman * supported or maximum value that can be configured in the 527197ba5f4SPaul Zimmerman * corresponding dwc2_core_params value. 528197ba5f4SPaul Zimmerman * 529197ba5f4SPaul Zimmerman * The values that are not in dwc2_core_params are documented below. 530197ba5f4SPaul Zimmerman * 5316fb914d7SGrigor Tovmasyan * @op_mode: Mode of Operation 532197ba5f4SPaul Zimmerman * 0 - HNP- and SRP-Capable OTG (Host & Device) 533197ba5f4SPaul Zimmerman * 1 - SRP-Capable OTG (Host & Device) 534197ba5f4SPaul Zimmerman * 2 - Non-HNP and Non-SRP Capable OTG (Host & Device) 535197ba5f4SPaul Zimmerman * 3 - SRP-Capable Device 536197ba5f4SPaul Zimmerman * 4 - Non-OTG Device 537197ba5f4SPaul Zimmerman * 5 - SRP-Capable Host 538197ba5f4SPaul Zimmerman * 6 - Non-OTG Host 5396fb914d7SGrigor Tovmasyan * @arch: Architecture 540197ba5f4SPaul Zimmerman * 0 - Slave only 541197ba5f4SPaul Zimmerman * 1 - External DMA 542197ba5f4SPaul Zimmerman * 2 - Internal DMA 5436fb914d7SGrigor Tovmasyan * @ipg_isoc_en: This feature indicates that the controller supports 544b43ebc96SGrigor Tovmasyan * the worst-case scenario of Rx followed by Rx 545b43ebc96SGrigor Tovmasyan * Interpacket Gap (IPG) (32 bitTimes) as per the utmi 546b43ebc96SGrigor Tovmasyan * specification for any token following ISOC OUT token. 547b43ebc96SGrigor Tovmasyan * 0 - Don't support 548b43ebc96SGrigor Tovmasyan * 1 - Support 5496fb914d7SGrigor Tovmasyan * @power_optimized: Are power optimizations enabled? 5506fb914d7SGrigor Tovmasyan * @num_dev_ep: Number of device endpoints available 5516fb914d7SGrigor Tovmasyan * @num_dev_in_eps: Number of device IN endpoints available 5526fb914d7SGrigor Tovmasyan * @num_dev_perio_in_ep: Number of device periodic IN endpoints 553997f4f81SMickael Maison * available 5546fb914d7SGrigor Tovmasyan * @dev_token_q_depth: Device Mode IN Token Sequence Learning Queue 555197ba5f4SPaul Zimmerman * Depth 556197ba5f4SPaul Zimmerman * 0 to 30 5576fb914d7SGrigor Tovmasyan * @host_perio_tx_q_depth: 558197ba5f4SPaul Zimmerman * Host Mode Periodic Request Queue Depth 559197ba5f4SPaul Zimmerman * 2, 4 or 8 5606fb914d7SGrigor Tovmasyan * @nperio_tx_q_depth: 561197ba5f4SPaul Zimmerman * Non-Periodic Request Queue Depth 562197ba5f4SPaul Zimmerman * 2, 4 or 8 5636fb914d7SGrigor Tovmasyan * @hs_phy_type: High-speed PHY interface type 564197ba5f4SPaul Zimmerman * 0 - High-speed interface not supported 565197ba5f4SPaul Zimmerman * 1 - UTMI+ 566197ba5f4SPaul Zimmerman * 2 - ULPI 567197ba5f4SPaul Zimmerman * 3 - UTMI+ and ULPI 5686fb914d7SGrigor Tovmasyan * @fs_phy_type: Full-speed PHY interface type 569197ba5f4SPaul Zimmerman * 0 - Full speed interface not supported 570197ba5f4SPaul Zimmerman * 1 - Dedicated full speed interface 571197ba5f4SPaul Zimmerman * 2 - FS pins shared with UTMI+ pins 572197ba5f4SPaul Zimmerman * 3 - FS pins shared with ULPI pins 573197ba5f4SPaul Zimmerman * @total_fifo_size: Total internal RAM for FIFOs (bytes) 5746fb914d7SGrigor Tovmasyan * @hibernation: Is hibernation enabled? 5756fb914d7SGrigor Tovmasyan * @utmi_phy_data_width: UTMI+ PHY data width 576197ba5f4SPaul Zimmerman * 0 - 8 bits 577197ba5f4SPaul Zimmerman * 1 - 16 bits 578197ba5f4SPaul Zimmerman * 2 - 8 or 16 bits 579197ba5f4SPaul Zimmerman * @snpsid: Value from SNPSID register 58055e1040eSJohn Youn * @dev_ep_dirs: Direction of device endpoints (GHWCFG1) 5816fb914d7SGrigor Tovmasyan * @g_tx_fifo_size: Power-on values of TxFIFO sizes 5826fb914d7SGrigor Tovmasyan * @dma_desc_enable: When DMA mode is enabled, specifies whether to use 5836fb914d7SGrigor Tovmasyan * address DMA mode or descriptor DMA mode for accessing 5846fb914d7SGrigor Tovmasyan * the data FIFOs. The driver will automatically detect the 5856fb914d7SGrigor Tovmasyan * value for this if none is specified. 5866fb914d7SGrigor Tovmasyan * 0 - Address DMA 5876fb914d7SGrigor Tovmasyan * 1 - Descriptor DMA (default, if available) 5886fb914d7SGrigor Tovmasyan * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters 5896fb914d7SGrigor Tovmasyan * 1 - Allow dynamic FIFO sizing (default, if available) 5906fb914d7SGrigor Tovmasyan * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs 5916fb914d7SGrigor Tovmasyan * are enabled for non-periodic IN endpoints in device 5926fb914d7SGrigor Tovmasyan * mode. 5936fb914d7SGrigor Tovmasyan * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 5946fb914d7SGrigor Tovmasyan * in host mode when dynamic FIFO sizing is enabled 5956fb914d7SGrigor Tovmasyan * 16 to 32768 5966fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 5976fb914d7SGrigor Tovmasyan * the default. 5986fb914d7SGrigor Tovmasyan * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in 5996fb914d7SGrigor Tovmasyan * host mode when dynamic FIFO sizing is enabled 6006fb914d7SGrigor Tovmasyan * 16 to 32768 6016fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6026fb914d7SGrigor Tovmasyan * the default. 6036fb914d7SGrigor Tovmasyan * @max_transfer_size: The maximum transfer size supported, in bytes 6046fb914d7SGrigor Tovmasyan * 2047 to 65,535 6056fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6066fb914d7SGrigor Tovmasyan * the default. 6076fb914d7SGrigor Tovmasyan * @max_packet_count: The maximum number of packets in a transfer 6086fb914d7SGrigor Tovmasyan * 15 to 511 6096fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6106fb914d7SGrigor Tovmasyan * the default. 6116fb914d7SGrigor Tovmasyan * @host_channels: The number of host channel registers to use 6126fb914d7SGrigor Tovmasyan * 1 to 16 6136fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6146fb914d7SGrigor Tovmasyan * the default. 6156fb914d7SGrigor Tovmasyan * @dev_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 6166fb914d7SGrigor Tovmasyan * in device mode when dynamic FIFO sizing is enabled 6176fb914d7SGrigor Tovmasyan * 16 to 32768 6186fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6196fb914d7SGrigor Tovmasyan * the default. 6206fb914d7SGrigor Tovmasyan * @i2c_enable: Specifies whether to use the I2Cinterface for a full 6216fb914d7SGrigor Tovmasyan * speed PHY. This parameter is only applicable if phy_type 6226fb914d7SGrigor Tovmasyan * is FS. 6236fb914d7SGrigor Tovmasyan * 0 - No (default) 6246fb914d7SGrigor Tovmasyan * 1 - Yes 6256fb914d7SGrigor Tovmasyan * @acg_enable: For enabling Active Clock Gating in the controller 6266fb914d7SGrigor Tovmasyan * 0 - Disable 6276fb914d7SGrigor Tovmasyan * 1 - Enable 6286fb914d7SGrigor Tovmasyan * @lpm_mode: For enabling Link Power Management in the controller 6296fb914d7SGrigor Tovmasyan * 0 - Disable 6306fb914d7SGrigor Tovmasyan * 1 - Enable 6316fb914d7SGrigor Tovmasyan * @rx_fifo_size: Number of 4-byte words in the Rx FIFO when dynamic 6326fb914d7SGrigor Tovmasyan * FIFO sizing is enabled 16 to 32768 6336fb914d7SGrigor Tovmasyan * Actual maximum value is autodetected and also 6346fb914d7SGrigor Tovmasyan * the default. 635ca531bc2SGrigor Tovmasyan * @service_interval_mode: For enabling service interval based scheduling in the 636ca531bc2SGrigor Tovmasyan * controller. 637ca531bc2SGrigor Tovmasyan * 0 - Disable 638ca531bc2SGrigor Tovmasyan * 1 - Enable 639197ba5f4SPaul Zimmerman */ 640197ba5f4SPaul Zimmerman struct dwc2_hw_params { 641197ba5f4SPaul Zimmerman unsigned op_mode:3; 642197ba5f4SPaul Zimmerman unsigned arch:2; 643197ba5f4SPaul Zimmerman unsigned dma_desc_enable:1; 644197ba5f4SPaul Zimmerman unsigned enable_dynamic_fifo:1; 645197ba5f4SPaul Zimmerman unsigned en_multiple_tx_fifo:1; 646d1531319SJohn Youn unsigned rx_fifo_size:16; 647197ba5f4SPaul Zimmerman unsigned host_nperio_tx_fifo_size:16; 64855e1040eSJohn Youn unsigned dev_nperio_tx_fifo_size:16; 649197ba5f4SPaul Zimmerman unsigned host_perio_tx_fifo_size:16; 650197ba5f4SPaul Zimmerman unsigned nperio_tx_q_depth:3; 651197ba5f4SPaul Zimmerman unsigned host_perio_tx_q_depth:3; 652197ba5f4SPaul Zimmerman unsigned dev_token_q_depth:5; 653197ba5f4SPaul Zimmerman unsigned max_transfer_size:26; 654197ba5f4SPaul Zimmerman unsigned max_packet_count:11; 655197ba5f4SPaul Zimmerman unsigned host_channels:5; 656197ba5f4SPaul Zimmerman unsigned hs_phy_type:2; 657197ba5f4SPaul Zimmerman unsigned fs_phy_type:2; 658197ba5f4SPaul Zimmerman unsigned i2c_enable:1; 65966e77a24SRazmik Karapetyan unsigned acg_enable:1; 660197ba5f4SPaul Zimmerman unsigned num_dev_ep:4; 6619273083aSMinas Harutyunyan unsigned num_dev_in_eps : 4; 662197ba5f4SPaul Zimmerman unsigned num_dev_perio_in_ep:4; 663197ba5f4SPaul Zimmerman unsigned total_fifo_size:16; 664197ba5f4SPaul Zimmerman unsigned power_optimized:1; 665631a2310SVardan Mikayelyan unsigned hibernation:1; 666197ba5f4SPaul Zimmerman unsigned utmi_phy_data_width:2; 6676f80b6deSSevak Arakelyan unsigned lpm_mode:1; 668b43ebc96SGrigor Tovmasyan unsigned ipg_isoc_en:1; 669ca531bc2SGrigor Tovmasyan unsigned service_interval_mode:1; 670197ba5f4SPaul Zimmerman u32 snpsid; 67155e1040eSJohn Youn u32 dev_ep_dirs; 6729273083aSMinas Harutyunyan u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; 673197ba5f4SPaul Zimmerman }; 674197ba5f4SPaul Zimmerman 6753f95001dSMian Yousaf Kaukab /* Size of control and EP0 buffers */ 6763f95001dSMian Yousaf Kaukab #define DWC2_CTRL_BUFF_SIZE 8 6773f95001dSMian Yousaf Kaukab 678197ba5f4SPaul Zimmerman /** 67938beaec6SJohn Youn * struct dwc2_gregs_backup - Holds global registers state before 68038beaec6SJohn Youn * entering partial power down 681d17ee77bSGregory Herrero * @gotgctl: Backup of GOTGCTL register 682d17ee77bSGregory Herrero * @gintmsk: Backup of GINTMSK register 683d17ee77bSGregory Herrero * @gahbcfg: Backup of GAHBCFG register 684d17ee77bSGregory Herrero * @gusbcfg: Backup of GUSBCFG register 685d17ee77bSGregory Herrero * @grxfsiz: Backup of GRXFSIZ register 686d17ee77bSGregory Herrero * @gnptxfsiz: Backup of GNPTXFSIZ register 687d17ee77bSGregory Herrero * @gi2cctl: Backup of GI2CCTL register 68866a36096SVardan Mikayelyan * @glpmcfg: Backup of GLPMCFG register 689d17ee77bSGregory Herrero * @gdfifocfg: Backup of GDFIFOCFG register 6906fb914d7SGrigor Tovmasyan * @pcgcctl: Backup of PCGCCTL register 6916fb914d7SGrigor Tovmasyan * @pcgcctl1: Backup of PCGCCTL1 register 6926fb914d7SGrigor Tovmasyan * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint 693d17ee77bSGregory Herrero * @gpwrdn: Backup of GPWRDN register 6946fb914d7SGrigor Tovmasyan * @valid: True if registers values backuped. 695d17ee77bSGregory Herrero */ 696d17ee77bSGregory Herrero struct dwc2_gregs_backup { 697d17ee77bSGregory Herrero u32 gotgctl; 698d17ee77bSGregory Herrero u32 gintmsk; 699d17ee77bSGregory Herrero u32 gahbcfg; 700d17ee77bSGregory Herrero u32 gusbcfg; 701d17ee77bSGregory Herrero u32 grxfsiz; 702d17ee77bSGregory Herrero u32 gnptxfsiz; 703d17ee77bSGregory Herrero u32 gi2cctl; 70466a36096SVardan Mikayelyan u32 glpmcfg; 705d17ee77bSGregory Herrero u32 pcgcctl; 706600a490eSRazmik Karapetyan u32 pcgcctl1; 707d17ee77bSGregory Herrero u32 gdfifocfg; 708d17ee77bSGregory Herrero u32 gpwrdn; 709cc1e204cSMian Yousaf Kaukab bool valid; 710d17ee77bSGregory Herrero }; 711d17ee77bSGregory Herrero 712d17ee77bSGregory Herrero /** 71338beaec6SJohn Youn * struct dwc2_dregs_backup - Holds device registers state before 71438beaec6SJohn Youn * entering partial power down 715d17ee77bSGregory Herrero * @dcfg: Backup of DCFG register 716d17ee77bSGregory Herrero * @dctl: Backup of DCTL register 717d17ee77bSGregory Herrero * @daintmsk: Backup of DAINTMSK register 718d17ee77bSGregory Herrero * @diepmsk: Backup of DIEPMSK register 719d17ee77bSGregory Herrero * @doepmsk: Backup of DOEPMSK register 720d17ee77bSGregory Herrero * @diepctl: Backup of DIEPCTL register 721d17ee77bSGregory Herrero * @dieptsiz: Backup of DIEPTSIZ register 722d17ee77bSGregory Herrero * @diepdma: Backup of DIEPDMA register 723d17ee77bSGregory Herrero * @doepctl: Backup of DOEPCTL register 724d17ee77bSGregory Herrero * @doeptsiz: Backup of DOEPTSIZ register 725d17ee77bSGregory Herrero * @doepdma: Backup of DOEPDMA register 726af7c2bd3SVardan Mikayelyan * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint 7276fb914d7SGrigor Tovmasyan * @valid: True if registers values backuped. 728d17ee77bSGregory Herrero */ 729d17ee77bSGregory Herrero struct dwc2_dregs_backup { 730d17ee77bSGregory Herrero u32 dcfg; 731d17ee77bSGregory Herrero u32 dctl; 732d17ee77bSGregory Herrero u32 daintmsk; 733d17ee77bSGregory Herrero u32 diepmsk; 734d17ee77bSGregory Herrero u32 doepmsk; 735d17ee77bSGregory Herrero u32 diepctl[MAX_EPS_CHANNELS]; 736d17ee77bSGregory Herrero u32 dieptsiz[MAX_EPS_CHANNELS]; 737d17ee77bSGregory Herrero u32 diepdma[MAX_EPS_CHANNELS]; 738d17ee77bSGregory Herrero u32 doepctl[MAX_EPS_CHANNELS]; 739d17ee77bSGregory Herrero u32 doeptsiz[MAX_EPS_CHANNELS]; 740d17ee77bSGregory Herrero u32 doepdma[MAX_EPS_CHANNELS]; 741af7c2bd3SVardan Mikayelyan u32 dtxfsiz[MAX_EPS_CHANNELS]; 742cc1e204cSMian Yousaf Kaukab bool valid; 743d17ee77bSGregory Herrero }; 744d17ee77bSGregory Herrero 745d17ee77bSGregory Herrero /** 74638beaec6SJohn Youn * struct dwc2_hregs_backup - Holds host registers state before 74738beaec6SJohn Youn * entering partial power down 748d17ee77bSGregory Herrero * @hcfg: Backup of HCFG register 749d17ee77bSGregory Herrero * @haintmsk: Backup of HAINTMSK register 750d17ee77bSGregory Herrero * @hcintmsk: Backup of HCINTMSK register 7516fb914d7SGrigor Tovmasyan * @hprt0: Backup of HPTR0 register 752d17ee77bSGregory Herrero * @hfir: Backup of HFIR register 75366a36096SVardan Mikayelyan * @hptxfsiz: Backup of HPTXFSIZ register 7546fb914d7SGrigor Tovmasyan * @valid: True if registers values backuped. 755d17ee77bSGregory Herrero */ 756d17ee77bSGregory Herrero struct dwc2_hregs_backup { 757d17ee77bSGregory Herrero u32 hcfg; 758d17ee77bSGregory Herrero u32 haintmsk; 759d17ee77bSGregory Herrero u32 hcintmsk[MAX_EPS_CHANNELS]; 760d17ee77bSGregory Herrero u32 hprt0; 761d17ee77bSGregory Herrero u32 hfir; 76266a36096SVardan Mikayelyan u32 hptxfsiz; 763cc1e204cSMian Yousaf Kaukab bool valid; 764d17ee77bSGregory Herrero }; 765d17ee77bSGregory Herrero 7669f9f09b0SDouglas Anderson /* 7679f9f09b0SDouglas Anderson * Constants related to high speed periodic scheduling 7689f9f09b0SDouglas Anderson * 7699f9f09b0SDouglas Anderson * We have a periodic schedule that is DWC2_HS_SCHEDULE_UFRAMES long. From a 7709f9f09b0SDouglas Anderson * reservation point of view it's assumed that the schedule goes right back to 7719f9f09b0SDouglas Anderson * the beginning after the end of the schedule. 7729f9f09b0SDouglas Anderson * 7739f9f09b0SDouglas Anderson * What does that mean for scheduling things with a long interval? It means 7749f9f09b0SDouglas Anderson * we'll reserve time for them in every possible microframe that they could 7759f9f09b0SDouglas Anderson * ever be scheduled in. ...but we'll still only actually schedule them as 7769f9f09b0SDouglas Anderson * often as they were requested. 7779f9f09b0SDouglas Anderson * 7789f9f09b0SDouglas Anderson * We keep our schedule in a "bitmap" structure. This simplifies having 7799f9f09b0SDouglas Anderson * to keep track of and merge intervals: we just let the bitmap code do most 7809f9f09b0SDouglas Anderson * of the heavy lifting. In a way scheduling is much like memory allocation. 7819f9f09b0SDouglas Anderson * 7829f9f09b0SDouglas Anderson * We schedule 100us per uframe or 80% of 125us (the maximum amount you're 7839f9f09b0SDouglas Anderson * supposed to schedule for periodic transfers). That's according to spec. 7849f9f09b0SDouglas Anderson * 7859f9f09b0SDouglas Anderson * Note that though we only schedule 80% of each microframe, the bitmap that we 7869f9f09b0SDouglas Anderson * keep the schedule in is tightly packed (AKA it doesn't have 100us worth of 7879f9f09b0SDouglas Anderson * space for each uFrame). 7889f9f09b0SDouglas Anderson * 7899f9f09b0SDouglas Anderson * Requirements: 7909f9f09b0SDouglas Anderson * - DWC2_HS_SCHEDULE_UFRAMES must even divide 0x4000 (HFNUM_MAX_FRNUM + 1) 7919f9f09b0SDouglas Anderson * - DWC2_HS_SCHEDULE_UFRAMES must be 8 times DWC2_LS_SCHEDULE_FRAMES (probably 7929f9f09b0SDouglas Anderson * could be any multiple of 8 times DWC2_LS_SCHEDULE_FRAMES, but there might 7939f9f09b0SDouglas Anderson * be bugs). The 8 comes from the USB spec: number of microframes per frame. 7949f9f09b0SDouglas Anderson */ 7959f9f09b0SDouglas Anderson #define DWC2_US_PER_UFRAME 125 7969f9f09b0SDouglas Anderson #define DWC2_HS_PERIODIC_US_PER_UFRAME 100 7979f9f09b0SDouglas Anderson 7989f9f09b0SDouglas Anderson #define DWC2_HS_SCHEDULE_UFRAMES 8 7999f9f09b0SDouglas Anderson #define DWC2_HS_SCHEDULE_US (DWC2_HS_SCHEDULE_UFRAMES * \ 8009f9f09b0SDouglas Anderson DWC2_HS_PERIODIC_US_PER_UFRAME) 8019f9f09b0SDouglas Anderson 8029f9f09b0SDouglas Anderson /* 8039f9f09b0SDouglas Anderson * Constants related to low speed scheduling 8049f9f09b0SDouglas Anderson * 8059f9f09b0SDouglas Anderson * For high speed we schedule every 1us. For low speed that's a bit overkill, 8069f9f09b0SDouglas Anderson * so we make up a unit called a "slice" that's worth 25us. There are 40 8079f9f09b0SDouglas Anderson * slices in a full frame and we can schedule 36 of those (90%) for periodic 8089f9f09b0SDouglas Anderson * transfers. 8099f9f09b0SDouglas Anderson * 8109f9f09b0SDouglas Anderson * Our low speed schedule can be as short as 1 frame or could be longer. When 8119f9f09b0SDouglas Anderson * we only schedule 1 frame it means that we'll need to reserve a time every 8129f9f09b0SDouglas Anderson * frame even for things that only transfer very rarely, so something that runs 8139f9f09b0SDouglas Anderson * every 2048 frames will get time reserved in every frame. Our low speed 8149f9f09b0SDouglas Anderson * schedule can be longer and we'll be able to handle more overlap, but that 8159f9f09b0SDouglas Anderson * will come at increased memory cost and increased time to schedule. 8169f9f09b0SDouglas Anderson * 8179f9f09b0SDouglas Anderson * Note: one other advantage of a short low speed schedule is that if we mess 8189f9f09b0SDouglas Anderson * up and miss scheduling we can jump in and use any of the slots that we 8199f9f09b0SDouglas Anderson * happened to reserve. 8209f9f09b0SDouglas Anderson * 8219f9f09b0SDouglas Anderson * With 25 us per slice and 1 frame in the schedule, we only need 4 bytes for 8229f9f09b0SDouglas Anderson * the schedule. There will be one schedule per TT. 8239f9f09b0SDouglas Anderson * 8249f9f09b0SDouglas Anderson * Requirements: 8259f9f09b0SDouglas Anderson * - DWC2_US_PER_SLICE must evenly divide DWC2_LS_PERIODIC_US_PER_FRAME. 8269f9f09b0SDouglas Anderson */ 8279f9f09b0SDouglas Anderson #define DWC2_US_PER_SLICE 25 8289f9f09b0SDouglas Anderson #define DWC2_SLICES_PER_UFRAME (DWC2_US_PER_UFRAME / DWC2_US_PER_SLICE) 8299f9f09b0SDouglas Anderson 8309f9f09b0SDouglas Anderson #define DWC2_ROUND_US_TO_SLICE(us) \ 8319f9f09b0SDouglas Anderson (DIV_ROUND_UP((us), DWC2_US_PER_SLICE) * \ 8329f9f09b0SDouglas Anderson DWC2_US_PER_SLICE) 8339f9f09b0SDouglas Anderson 8349f9f09b0SDouglas Anderson #define DWC2_LS_PERIODIC_US_PER_FRAME \ 8359f9f09b0SDouglas Anderson 900 8369f9f09b0SDouglas Anderson #define DWC2_LS_PERIODIC_SLICES_PER_FRAME \ 8379f9f09b0SDouglas Anderson (DWC2_LS_PERIODIC_US_PER_FRAME / \ 8389f9f09b0SDouglas Anderson DWC2_US_PER_SLICE) 8399f9f09b0SDouglas Anderson 8409f9f09b0SDouglas Anderson #define DWC2_LS_SCHEDULE_FRAMES 1 8419f9f09b0SDouglas Anderson #define DWC2_LS_SCHEDULE_SLICES (DWC2_LS_SCHEDULE_FRAMES * \ 8429f9f09b0SDouglas Anderson DWC2_LS_PERIODIC_SLICES_PER_FRAME) 8439f9f09b0SDouglas Anderson 844d17ee77bSGregory Herrero /** 845197ba5f4SPaul Zimmerman * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic 846197ba5f4SPaul Zimmerman * and periodic schedules 847197ba5f4SPaul Zimmerman * 848941fcce4SDinh Nguyen * These are common for both host and peripheral modes: 849941fcce4SDinh Nguyen * 850197ba5f4SPaul Zimmerman * @dev: The struct device pointer 851197ba5f4SPaul Zimmerman * @regs: Pointer to controller regs 852197ba5f4SPaul Zimmerman * @hw_params: Parameters that were autodetected from the 853197ba5f4SPaul Zimmerman * hardware registers 8546fb914d7SGrigor Tovmasyan * @params: Parameters that define how the core should be configured 855197ba5f4SPaul Zimmerman * @op_state: The operational State, during transitions (a_host=> 856197ba5f4SPaul Zimmerman * a_peripheral and b_device=>b_host) this may not match 857197ba5f4SPaul Zimmerman * the core, but allows the software to determine 858197ba5f4SPaul Zimmerman * transitions 859c0155b9dSKever Yang * @dr_mode: Requested mode of operation, one of following: 860c0155b9dSKever Yang * - USB_DR_MODE_PERIPHERAL 861c0155b9dSKever Yang * - USB_DR_MODE_HOST 862c0155b9dSKever Yang * - USB_DR_MODE_OTG 86317f93402SAmelie Delaunay * @role_sw: usb_role_switch handle 8646fb914d7SGrigor Tovmasyan * @hcd_enabled: Host mode sub-driver initialization indicator. 8656fb914d7SGrigor Tovmasyan * @gadget_enabled: Peripheral mode sub-driver initialization indicator. 8666fb914d7SGrigor Tovmasyan * @ll_hw_enabled: Status of low-level hardware resources. 86720fe4409SVardan Mikayelyan * @hibernated: True if core is hibernated 868c40cf770SDouglas Anderson * @reset_phy_on_wake: Quirk saying that we should assert PHY reset on a 869c40cf770SDouglas Anderson * remote wakeup. 870c846b03fSDouglas Anderson * @phy_off_for_suspend: Status of whether we turned the PHY off at suspend. 871c846b03fSDouglas Anderson * @need_phy_for_wake: Quirk saying that we should keep the PHY on at 872c846b03fSDouglas Anderson * suspend if we need USB to wake us up. 873c7c24e7aSArtur Petrosyan * @frame_number: Frame number read from the core. For both device 874c7c24e7aSArtur Petrosyan * and host modes. The value ranges are from 0 875c7c24e7aSArtur Petrosyan * to HFNUM_MAX_FRNUM. 87609a75e85SMarek Szyprowski * @phy: The otg phy transceiver structure for phy control. 87738beaec6SJohn Youn * @uphy: The otg phy transceiver structure for old USB phy 87838beaec6SJohn Youn * control. 87938beaec6SJohn Youn * @plat: The platform specific configuration data. This can be 88038beaec6SJohn Youn * removed once all SoCs support usb transceiver. 88109a75e85SMarek Szyprowski * @supplies: Definition of USB power supplies 882531ef5ebSAmelie Delaunay * @vbus_supply: Regulator supplying vbus. 883a415083aSAmelie Delaunay * @usb33d: Optional 3.3v regulator used on some stm32 devices to 884a415083aSAmelie Delaunay * supply ID and VBUS detection hardware. 885941fcce4SDinh Nguyen * @lock: Spinlock that protects all the driver data structures 886941fcce4SDinh Nguyen * @priv: Stores a pointer to the struct usb_hcd 887197ba5f4SPaul Zimmerman * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth 888197ba5f4SPaul Zimmerman * transfer are in process of being queued 889197ba5f4SPaul Zimmerman * @srp_success: Stores status of SRP request in the case of a FS PHY 890197ba5f4SPaul Zimmerman * with an I2C interface 891197ba5f4SPaul Zimmerman * @wq_otg: Workqueue object used for handling of some interrupts 892197ba5f4SPaul Zimmerman * @wf_otg: Work object for handling Connector ID Status Change 893197ba5f4SPaul Zimmerman * interrupt 894197ba5f4SPaul Zimmerman * @wkp_timer: Timer object for handling Wakeup Detected interrupt 895197ba5f4SPaul Zimmerman * @lx_state: Lx state of connected device 8966fb914d7SGrigor Tovmasyan * @gr_backup: Backup of global registers during suspend 8976fb914d7SGrigor Tovmasyan * @dr_backup: Backup of device registers during suspend 8986fb914d7SGrigor Tovmasyan * @hr_backup: Backup of host registers during suspend 899fe369e18SGevorg Sahakyan * @needs_byte_swap: Specifies whether the opposite endianness. 900941fcce4SDinh Nguyen * 901941fcce4SDinh Nguyen * These are for host mode: 902941fcce4SDinh Nguyen * 903197ba5f4SPaul Zimmerman * @flags: Flags for handling root port state changes 9046fb914d7SGrigor Tovmasyan * @flags.d32: Contain all root port flags 9056fb914d7SGrigor Tovmasyan * @flags.b: Separate root port flags from each other 9066fb914d7SGrigor Tovmasyan * @flags.b.port_connect_status_change: True if root port connect status 9076fb914d7SGrigor Tovmasyan * changed 9086fb914d7SGrigor Tovmasyan * @flags.b.port_connect_status: True if device connected to root port 9096fb914d7SGrigor Tovmasyan * @flags.b.port_reset_change: True if root port reset status changed 9106fb914d7SGrigor Tovmasyan * @flags.b.port_enable_change: True if root port enable status changed 9116fb914d7SGrigor Tovmasyan * @flags.b.port_suspend_change: True if root port suspend status changed 9126fb914d7SGrigor Tovmasyan * @flags.b.port_over_current_change: True if root port over current state 9136fb914d7SGrigor Tovmasyan * changed. 9146fb914d7SGrigor Tovmasyan * @flags.b.port_l1_change: True if root port l1 status changed 9156fb914d7SGrigor Tovmasyan * @flags.b.reserved: Reserved bits of root port register 916197ba5f4SPaul Zimmerman * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule. 917197ba5f4SPaul Zimmerman * Transfers associated with these QHs are not currently 918197ba5f4SPaul Zimmerman * assigned to a host channel. 919197ba5f4SPaul Zimmerman * @non_periodic_sched_active: Active QHs in the non-periodic schedule. 920197ba5f4SPaul Zimmerman * Transfers associated with these QHs are currently 921197ba5f4SPaul Zimmerman * assigned to a host channel. 922197ba5f4SPaul Zimmerman * @non_periodic_qh_ptr: Pointer to next QH to process in the active 923197ba5f4SPaul Zimmerman * non-periodic schedule 9246fb914d7SGrigor Tovmasyan * @non_periodic_sched_waiting: Waiting QHs in the non-periodic schedule. 9256fb914d7SGrigor Tovmasyan * Transfers associated with these QHs are not currently 9266fb914d7SGrigor Tovmasyan * assigned to a host channel. 927197ba5f4SPaul Zimmerman * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a 928197ba5f4SPaul Zimmerman * list of QHs for periodic transfers that are _not_ 929197ba5f4SPaul Zimmerman * scheduled for the next frame. Each QH in the list has an 930197ba5f4SPaul Zimmerman * interval counter that determines when it needs to be 931197ba5f4SPaul Zimmerman * scheduled for execution. This scheduling mechanism 932197ba5f4SPaul Zimmerman * allows only a simple calculation for periodic bandwidth 933197ba5f4SPaul Zimmerman * used (i.e. must assume that all periodic transfers may 934197ba5f4SPaul Zimmerman * need to execute in the same frame). However, it greatly 935197ba5f4SPaul Zimmerman * simplifies scheduling and should be sufficient for the 936197ba5f4SPaul Zimmerman * vast majority of OTG hosts, which need to connect to a 937197ba5f4SPaul Zimmerman * small number of peripherals at one time. Items move from 938197ba5f4SPaul Zimmerman * this list to periodic_sched_ready when the QH interval 939197ba5f4SPaul Zimmerman * counter is 0 at SOF. 940197ba5f4SPaul Zimmerman * @periodic_sched_ready: List of periodic QHs that are ready for execution in 941197ba5f4SPaul Zimmerman * the next frame, but have not yet been assigned to host 942197ba5f4SPaul Zimmerman * channels. Items move from this list to 943197ba5f4SPaul Zimmerman * periodic_sched_assigned as host channels become 944197ba5f4SPaul Zimmerman * available during the current frame. 945197ba5f4SPaul Zimmerman * @periodic_sched_assigned: List of periodic QHs to be executed in the next 946197ba5f4SPaul Zimmerman * frame that are assigned to host channels. Items move 947197ba5f4SPaul Zimmerman * from this list to periodic_sched_queued as the 948197ba5f4SPaul Zimmerman * transactions for the QH are queued to the DWC_otg 949197ba5f4SPaul Zimmerman * controller. 950197ba5f4SPaul Zimmerman * @periodic_sched_queued: List of periodic QHs that have been queued for 951197ba5f4SPaul Zimmerman * execution. Items move from this list to either 952197ba5f4SPaul Zimmerman * periodic_sched_inactive or periodic_sched_ready when the 953197ba5f4SPaul Zimmerman * channel associated with the transfer is released. If the 954197ba5f4SPaul Zimmerman * interval for the QH is 1, the item moves to 955197ba5f4SPaul Zimmerman * periodic_sched_ready because it must be rescheduled for 956197ba5f4SPaul Zimmerman * the next frame. Otherwise, the item moves to 957197ba5f4SPaul Zimmerman * periodic_sched_inactive. 958c9c8ac01SDouglas Anderson * @split_order: List keeping track of channels doing splits, in order. 959197ba5f4SPaul Zimmerman * @periodic_usecs: Total bandwidth claimed so far for periodic transfers. 960197ba5f4SPaul Zimmerman * This value is in microseconds per (micro)frame. The 961197ba5f4SPaul Zimmerman * assumption is that all periodic transfers may occur in 962197ba5f4SPaul Zimmerman * the same (micro)frame. 9639f9f09b0SDouglas Anderson * @hs_periodic_bitmap: Bitmap used by the microframe scheduler any time the 9649f9f09b0SDouglas Anderson * host is in high speed mode; low speed schedules are 9659f9f09b0SDouglas Anderson * stored elsewhere since we need one per TT. 966197ba5f4SPaul Zimmerman * @periodic_qh_count: Count of periodic QHs, if using several eps. Used for 967197ba5f4SPaul Zimmerman * SOF enable/disable. 968197ba5f4SPaul Zimmerman * @free_hc_list: Free host channels in the controller. This is a list of 969197ba5f4SPaul Zimmerman * struct dwc2_host_chan items. 970197ba5f4SPaul Zimmerman * @periodic_channels: Number of host channels assigned to periodic transfers. 971197ba5f4SPaul Zimmerman * Currently assuming that there is a dedicated host 972197ba5f4SPaul Zimmerman * channel for each periodic transaction and at least one 973197ba5f4SPaul Zimmerman * host channel is available for non-periodic transactions. 974197ba5f4SPaul Zimmerman * @non_periodic_channels: Number of host channels assigned to non-periodic 975197ba5f4SPaul Zimmerman * transfers 9766fb914d7SGrigor Tovmasyan * @available_host_channels: Number of host channels available for the 9776fb914d7SGrigor Tovmasyan * microframe scheduler to use 978197ba5f4SPaul Zimmerman * @hc_ptr_array: Array of pointers to the host channel descriptors. 979197ba5f4SPaul Zimmerman * Allows accessing a host channel descriptor given the 980197ba5f4SPaul Zimmerman * host channel number. This is useful in interrupt 981197ba5f4SPaul Zimmerman * handlers. 982197ba5f4SPaul Zimmerman * @status_buf: Buffer used for data received during the status phase of 983197ba5f4SPaul Zimmerman * a control transfer. 984197ba5f4SPaul Zimmerman * @status_buf_dma: DMA address for status_buf 985197ba5f4SPaul Zimmerman * @start_work: Delayed work for handling host A-cable connection 986197ba5f4SPaul Zimmerman * @reset_work: Delayed work for handling a port reset 987c40cf770SDouglas Anderson * @phy_reset_work: Work structure for doing a PHY reset 988197ba5f4SPaul Zimmerman * @otg_port: OTG port number 989197ba5f4SPaul Zimmerman * @frame_list: Frame list 990197ba5f4SPaul Zimmerman * @frame_list_dma: Frame list DMA address 99195105a99SGregory Herrero * @frame_list_sz: Frame list size 9923b5fcc9aSGregory Herrero * @desc_gen_cache: Kmem cache for generic descriptors 9933b5fcc9aSGregory Herrero * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors 994af424a41SWilliam Wu * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf 995941fcce4SDinh Nguyen * 996941fcce4SDinh Nguyen * These are for peripheral mode: 997941fcce4SDinh Nguyen * 998941fcce4SDinh Nguyen * @driver: USB gadget driver 999941fcce4SDinh Nguyen * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. 1000941fcce4SDinh Nguyen * @num_of_eps: Number of available EPs (excluding EP0) 1001941fcce4SDinh Nguyen * @debug_root: Root directrory for debugfs. 1002941fcce4SDinh Nguyen * @ep0_reply: Request used for ep0 reply. 1003941fcce4SDinh Nguyen * @ep0_buff: Buffer for EP0 reply data, if needed. 1004941fcce4SDinh Nguyen * @ctrl_buff: Buffer for EP0 control requests. 1005941fcce4SDinh Nguyen * @ctrl_req: Request for EP0 control packets. 1006fe0b94abSMian Yousaf Kaukab * @ep0_state: EP0 control transfers state 1007b4c53b4aSMinas Harutyunyan * @delayed_status: true when gadget driver asks for delayed status 10089e14d0a5SGregory Herrero * @test_mode: USB test mode requested by the host 1009fa389a6dSVardan Mikayelyan * @remote_wakeup_allowed: True if device is allowed to wake-up host by 1010fa389a6dSVardan Mikayelyan * remote-wakeup signalling 10110f6b80c0SVahram Aharonyan * @setup_desc_dma: EP0 setup stage desc chain DMA address 10120f6b80c0SVahram Aharonyan * @setup_desc: EP0 setup stage desc chain pointer 10130f6b80c0SVahram Aharonyan * @ctrl_in_desc_dma: EP0 IN data phase desc chain DMA address 10140f6b80c0SVahram Aharonyan * @ctrl_in_desc: EP0 IN data phase desc chain pointer 10150f6b80c0SVahram Aharonyan * @ctrl_out_desc_dma: EP0 OUT data phase desc chain DMA address 10160f6b80c0SVahram Aharonyan * @ctrl_out_desc: EP0 OUT data phase desc chain pointer 10176fb914d7SGrigor Tovmasyan * @irq: Interrupt request line number 10186fb914d7SGrigor Tovmasyan * @clk: Pointer to otg clock 10196fb914d7SGrigor Tovmasyan * @reset: Pointer to dwc2 reset controller 10206fb914d7SGrigor Tovmasyan * @reset_ecc: Pointer to dwc2 optional reset controller in Stratix10. 10216fb914d7SGrigor Tovmasyan * @regset: A pointer to a struct debugfs_regset32, which contains 10226fb914d7SGrigor Tovmasyan * a pointer to an array of register definitions, the 10236fb914d7SGrigor Tovmasyan * array size and the base address where the register bank 10246fb914d7SGrigor Tovmasyan * is to be found. 10256fb914d7SGrigor Tovmasyan * @bus_suspended: True if bus is suspended 10266fb914d7SGrigor Tovmasyan * @last_frame_num: Number of last frame. Range from 0 to 32768 10276fb914d7SGrigor Tovmasyan * @frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is 10286fb914d7SGrigor Tovmasyan * defined, for missed SOFs tracking. Array holds that 10296fb914d7SGrigor Tovmasyan * frame numbers, which not equal to last_frame_num +1 10306fb914d7SGrigor Tovmasyan * @last_frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is 10316fb914d7SGrigor Tovmasyan * defined, for missed SOFs tracking. 10326fb914d7SGrigor Tovmasyan * If current_frame_number != last_frame_num+1 10336fb914d7SGrigor Tovmasyan * then last_frame_num added to this array 10346fb914d7SGrigor Tovmasyan * @frame_num_idx: Actual size of frame_num_array and last_frame_num_array 10356fb914d7SGrigor Tovmasyan * @dumped_frame_num_array: 1 - if missed SOFs frame numbers dumbed 10366fb914d7SGrigor Tovmasyan * 0 - if missed SOFs frame numbers not dumbed 10376fb914d7SGrigor Tovmasyan * @fifo_mem: Total internal RAM for FIFOs (bytes) 10386fb914d7SGrigor Tovmasyan * @fifo_map: Each bit intend for concrete fifo. If that bit is set, 10396fb914d7SGrigor Tovmasyan * then that fifo is used 1040b9b70170SGreg Kroah-Hartman * @gadget: Represents a usb gadget device 10416fb914d7SGrigor Tovmasyan * @connected: Used in slave mode. True if device connected with host 10426fb914d7SGrigor Tovmasyan * @eps_in: The IN endpoints being supplied to the gadget framework 10436fb914d7SGrigor Tovmasyan * @eps_out: The OUT endpoints being supplied to the gadget framework 10446fb914d7SGrigor Tovmasyan * @new_connection: Used in host mode. True if there are new connected 10456fb914d7SGrigor Tovmasyan * device 10466fb914d7SGrigor Tovmasyan * @enabled: Indicates the enabling state of controller 10476fb914d7SGrigor Tovmasyan * 1048197ba5f4SPaul Zimmerman */ 1049197ba5f4SPaul Zimmerman struct dwc2_hsotg { 1050197ba5f4SPaul Zimmerman struct device *dev; 1051197ba5f4SPaul Zimmerman void __iomem *regs; 1052197ba5f4SPaul Zimmerman /** Params detected from hardware */ 1053197ba5f4SPaul Zimmerman struct dwc2_hw_params hw_params; 1054197ba5f4SPaul Zimmerman /** Params to actually use */ 1055bea8e86cSJohn Youn struct dwc2_core_params params; 1056197ba5f4SPaul Zimmerman enum usb_otg_state op_state; 1057c0155b9dSKever Yang enum usb_dr_mode dr_mode; 105817f93402SAmelie Delaunay struct usb_role_switch *role_sw; 1059e39af88fSMarek Szyprowski unsigned int hcd_enabled:1; 1060e39af88fSMarek Szyprowski unsigned int gadget_enabled:1; 106109a75e85SMarek Szyprowski unsigned int ll_hw_enabled:1; 106220fe4409SVardan Mikayelyan unsigned int hibernated:1; 1063c40cf770SDouglas Anderson unsigned int reset_phy_on_wake:1; 1064c846b03fSDouglas Anderson unsigned int need_phy_for_wake:1; 1065c846b03fSDouglas Anderson unsigned int phy_off_for_suspend:1; 1066c7c24e7aSArtur Petrosyan u16 frame_number; 1067197ba5f4SPaul Zimmerman 1068941fcce4SDinh Nguyen struct phy *phy; 1069941fcce4SDinh Nguyen struct usb_phy *uphy; 107009a75e85SMarek Szyprowski struct dwc2_hsotg_plat *plat; 1071b98866c2SJohn Youn struct regulator_bulk_data supplies[DWC2_NUM_SUPPLIES]; 1072531ef5ebSAmelie Delaunay struct regulator *vbus_supply; 1073a415083aSAmelie Delaunay struct regulator *usb33d; 1074941fcce4SDinh Nguyen 1075941fcce4SDinh Nguyen spinlock_t lock; 1076941fcce4SDinh Nguyen void *priv; 1077941fcce4SDinh Nguyen int irq; 1078941fcce4SDinh Nguyen struct clk *clk; 107983f8da56SDinh Nguyen struct reset_control *reset; 1080f2830ad4SDinh Nguyen struct reset_control *reset_ecc; 1081941fcce4SDinh Nguyen 1082197ba5f4SPaul Zimmerman unsigned int queuing_high_bandwidth:1; 1083197ba5f4SPaul Zimmerman unsigned int srp_success:1; 1084197ba5f4SPaul Zimmerman 1085197ba5f4SPaul Zimmerman struct workqueue_struct *wq_otg; 1086197ba5f4SPaul Zimmerman struct work_struct wf_otg; 1087197ba5f4SPaul Zimmerman struct timer_list wkp_timer; 1088197ba5f4SPaul Zimmerman enum dwc2_lx_state lx_state; 1089cc1e204cSMian Yousaf Kaukab struct dwc2_gregs_backup gr_backup; 1090cc1e204cSMian Yousaf Kaukab struct dwc2_dregs_backup dr_backup; 1091cc1e204cSMian Yousaf Kaukab struct dwc2_hregs_backup hr_backup; 1092197ba5f4SPaul Zimmerman 1093941fcce4SDinh Nguyen struct dentry *debug_root; 1094563cf017SMian Yousaf Kaukab struct debugfs_regset32 *regset; 1095fe369e18SGevorg Sahakyan bool needs_byte_swap; 1096941fcce4SDinh Nguyen 1097941fcce4SDinh Nguyen /* DWC OTG HW Release versions */ 1098941fcce4SDinh Nguyen #define DWC2_CORE_REV_2_71a 0x4f54271a 10995295322aSArtur Petrosyan #define DWC2_CORE_REV_2_72a 0x4f54272a 11006f80b6deSSevak Arakelyan #define DWC2_CORE_REV_2_80a 0x4f54280a 1101941fcce4SDinh Nguyen #define DWC2_CORE_REV_2_90a 0x4f54290a 1102e1f411d1SSevak Arakelyan #define DWC2_CORE_REV_2_91a 0x4f54291a 1103941fcce4SDinh Nguyen #define DWC2_CORE_REV_2_92a 0x4f54292a 1104941fcce4SDinh Nguyen #define DWC2_CORE_REV_2_94a 0x4f54294a 1105941fcce4SDinh Nguyen #define DWC2_CORE_REV_3_00a 0x4f54300a 1106fef6bc37SJohn Youn #define DWC2_CORE_REV_3_10a 0x4f54310a 11075295322aSArtur Petrosyan #define DWC2_CORE_REV_4_00a 0x4f54400a 110865dc2e72SMinas Harutyunyan #define DWC2_CORE_REV_4_20a 0x4f54420a 11091e6b98ebSVardan Mikayelyan #define DWC2_FS_IOT_REV_1_00a 0x5531100a 11101e6b98ebSVardan Mikayelyan #define DWC2_HS_IOT_REV_1_00a 0x5532100a 111165dc2e72SMinas Harutyunyan #define DWC2_CORE_REV_MASK 0x0000ffff 1112941fcce4SDinh Nguyen 1113d14ccabaSGevorg Sahakyan /* DWC OTG HW Core ID */ 1114d14ccabaSGevorg Sahakyan #define DWC2_OTG_ID 0x4f540000 1115d14ccabaSGevorg Sahakyan #define DWC2_FS_IOT_ID 0x55310000 1116d14ccabaSGevorg Sahakyan #define DWC2_HS_IOT_ID 0x55320000 1117d14ccabaSGevorg Sahakyan 1118941fcce4SDinh Nguyen #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 1119197ba5f4SPaul Zimmerman union dwc2_hcd_internal_flags { 1120197ba5f4SPaul Zimmerman u32 d32; 1121197ba5f4SPaul Zimmerman struct { 1122197ba5f4SPaul Zimmerman unsigned port_connect_status_change:1; 1123197ba5f4SPaul Zimmerman unsigned port_connect_status:1; 1124197ba5f4SPaul Zimmerman unsigned port_reset_change:1; 1125197ba5f4SPaul Zimmerman unsigned port_enable_change:1; 1126197ba5f4SPaul Zimmerman unsigned port_suspend_change:1; 1127197ba5f4SPaul Zimmerman unsigned port_over_current_change:1; 1128197ba5f4SPaul Zimmerman unsigned port_l1_change:1; 1129fd4850cfSCharles Manning unsigned reserved:25; 1130197ba5f4SPaul Zimmerman } b; 1131197ba5f4SPaul Zimmerman } flags; 1132197ba5f4SPaul Zimmerman 1133197ba5f4SPaul Zimmerman struct list_head non_periodic_sched_inactive; 113438d2b5fbSDouglas Anderson struct list_head non_periodic_sched_waiting; 1135197ba5f4SPaul Zimmerman struct list_head non_periodic_sched_active; 1136197ba5f4SPaul Zimmerman struct list_head *non_periodic_qh_ptr; 1137197ba5f4SPaul Zimmerman struct list_head periodic_sched_inactive; 1138197ba5f4SPaul Zimmerman struct list_head periodic_sched_ready; 1139197ba5f4SPaul Zimmerman struct list_head periodic_sched_assigned; 1140197ba5f4SPaul Zimmerman struct list_head periodic_sched_queued; 1141c9c8ac01SDouglas Anderson struct list_head split_order; 1142197ba5f4SPaul Zimmerman u16 periodic_usecs; 11439f9f09b0SDouglas Anderson unsigned long hs_periodic_bitmap[ 11449f9f09b0SDouglas Anderson DIV_ROUND_UP(DWC2_HS_SCHEDULE_US, BITS_PER_LONG)]; 1145197ba5f4SPaul Zimmerman u16 periodic_qh_count; 1146734643dfSGregory Herrero bool bus_suspended; 1147fbb9e22bSMian Yousaf Kaukab bool new_connection; 1148197ba5f4SPaul Zimmerman 1149483bb254SDouglas Anderson u16 last_frame_num; 1150483bb254SDouglas Anderson 1151197ba5f4SPaul Zimmerman #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS 1152197ba5f4SPaul Zimmerman #define FRAME_NUM_ARRAY_SIZE 1000 1153197ba5f4SPaul Zimmerman u16 *frame_num_array; 1154197ba5f4SPaul Zimmerman u16 *last_frame_num_array; 1155197ba5f4SPaul Zimmerman int frame_num_idx; 1156197ba5f4SPaul Zimmerman int dumped_frame_num_array; 1157197ba5f4SPaul Zimmerman #endif 1158197ba5f4SPaul Zimmerman 1159197ba5f4SPaul Zimmerman struct list_head free_hc_list; 1160197ba5f4SPaul Zimmerman int periodic_channels; 1161197ba5f4SPaul Zimmerman int non_periodic_channels; 1162197ba5f4SPaul Zimmerman int available_host_channels; 1163197ba5f4SPaul Zimmerman struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS]; 1164197ba5f4SPaul Zimmerman u8 *status_buf; 1165197ba5f4SPaul Zimmerman dma_addr_t status_buf_dma; 1166197ba5f4SPaul Zimmerman #define DWC2_HCD_STATUS_BUF_SIZE 64 1167197ba5f4SPaul Zimmerman 1168197ba5f4SPaul Zimmerman struct delayed_work start_work; 1169197ba5f4SPaul Zimmerman struct delayed_work reset_work; 1170c40cf770SDouglas Anderson struct work_struct phy_reset_work; 1171197ba5f4SPaul Zimmerman u8 otg_port; 1172197ba5f4SPaul Zimmerman u32 *frame_list; 1173197ba5f4SPaul Zimmerman dma_addr_t frame_list_dma; 117495105a99SGregory Herrero u32 frame_list_sz; 11753b5fcc9aSGregory Herrero struct kmem_cache *desc_gen_cache; 11763b5fcc9aSGregory Herrero struct kmem_cache *desc_hsisoc_cache; 1177af424a41SWilliam Wu struct kmem_cache *unaligned_cache; 1178af424a41SWilliam Wu #define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024 1179197ba5f4SPaul Zimmerman 1180941fcce4SDinh Nguyen #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */ 1181941fcce4SDinh Nguyen 1182b98866c2SJohn Youn #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 1183b98866c2SJohn Youn IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 1184941fcce4SDinh Nguyen /* Gadget structures */ 1185941fcce4SDinh Nguyen struct usb_gadget_driver *driver; 1186941fcce4SDinh Nguyen int fifo_mem; 1187941fcce4SDinh Nguyen unsigned int dedicated_fifos:1; 1188941fcce4SDinh Nguyen unsigned char num_of_eps; 1189941fcce4SDinh Nguyen u32 fifo_map; 1190941fcce4SDinh Nguyen 1191941fcce4SDinh Nguyen struct usb_request *ep0_reply; 1192941fcce4SDinh Nguyen struct usb_request *ctrl_req; 11933f95001dSMian Yousaf Kaukab void *ep0_buff; 11943f95001dSMian Yousaf Kaukab void *ctrl_buff; 1195fe0b94abSMian Yousaf Kaukab enum dwc2_ep0_state ep0_state; 1196b4c53b4aSMinas Harutyunyan unsigned delayed_status : 1; 11979e14d0a5SGregory Herrero u8 test_mode; 1198941fcce4SDinh Nguyen 11990f6b80c0SVahram Aharonyan dma_addr_t setup_desc_dma[2]; 12000f6b80c0SVahram Aharonyan struct dwc2_dma_desc *setup_desc[2]; 12010f6b80c0SVahram Aharonyan dma_addr_t ctrl_in_desc_dma; 12020f6b80c0SVahram Aharonyan struct dwc2_dma_desc *ctrl_in_desc; 12030f6b80c0SVahram Aharonyan dma_addr_t ctrl_out_desc_dma; 12040f6b80c0SVahram Aharonyan struct dwc2_dma_desc *ctrl_out_desc; 12050f6b80c0SVahram Aharonyan 1206941fcce4SDinh Nguyen struct usb_gadget gadget; 1207dc6e69e6SMarek Szyprowski unsigned int enabled:1; 12084ace06e8SMarek Szyprowski unsigned int connected:1; 1209fa389a6dSVardan Mikayelyan unsigned int remote_wakeup_allowed:1; 12101f91b4ccSFelipe Balbi struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS]; 12111f91b4ccSFelipe Balbi struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS]; 1212941fcce4SDinh Nguyen #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ 1213197ba5f4SPaul Zimmerman }; 1214197ba5f4SPaul Zimmerman 12150f548098SGevorg Sahakyan /* Normal architectures just use readl/write */ 1216f25c42b8SGevorg Sahakyan static inline u32 dwc2_readl(struct dwc2_hsotg *hsotg, u32 offset) 12170f548098SGevorg Sahakyan { 1218fe369e18SGevorg Sahakyan u32 val; 1219fe369e18SGevorg Sahakyan 1220fe369e18SGevorg Sahakyan val = readl(hsotg->regs + offset); 1221fe369e18SGevorg Sahakyan if (hsotg->needs_byte_swap) 1222fe369e18SGevorg Sahakyan return swab32(val); 1223fe369e18SGevorg Sahakyan else 1224fe369e18SGevorg Sahakyan return val; 12250f548098SGevorg Sahakyan } 12260f548098SGevorg Sahakyan 1227f25c42b8SGevorg Sahakyan static inline void dwc2_writel(struct dwc2_hsotg *hsotg, u32 value, u32 offset) 12280f548098SGevorg Sahakyan { 1229fe369e18SGevorg Sahakyan if (hsotg->needs_byte_swap) 1230fe369e18SGevorg Sahakyan writel(swab32(value), hsotg->regs + offset); 1231fe369e18SGevorg Sahakyan else 1232f25c42b8SGevorg Sahakyan writel(value, hsotg->regs + offset); 12330f548098SGevorg Sahakyan 12340f548098SGevorg Sahakyan #ifdef DWC2_LOG_WRITES 1235f25c42b8SGevorg Sahakyan pr_info("info:: wrote %08x to %p\n", value, hsotg->regs + offset); 12360f548098SGevorg Sahakyan #endif 12370f548098SGevorg Sahakyan } 1238342ccce1SGevorg Sahakyan 1239342ccce1SGevorg Sahakyan static inline void dwc2_readl_rep(struct dwc2_hsotg *hsotg, u32 offset, 1240342ccce1SGevorg Sahakyan void *buffer, unsigned int count) 1241342ccce1SGevorg Sahakyan { 1242342ccce1SGevorg Sahakyan if (count) { 1243342ccce1SGevorg Sahakyan u32 *buf = buffer; 1244342ccce1SGevorg Sahakyan 1245342ccce1SGevorg Sahakyan do { 1246342ccce1SGevorg Sahakyan u32 x = dwc2_readl(hsotg, offset); 1247342ccce1SGevorg Sahakyan *buf++ = x; 1248342ccce1SGevorg Sahakyan } while (--count); 1249342ccce1SGevorg Sahakyan } 1250342ccce1SGevorg Sahakyan } 1251342ccce1SGevorg Sahakyan 1252342ccce1SGevorg Sahakyan static inline void dwc2_writel_rep(struct dwc2_hsotg *hsotg, u32 offset, 1253342ccce1SGevorg Sahakyan const void *buffer, unsigned int count) 1254342ccce1SGevorg Sahakyan { 1255342ccce1SGevorg Sahakyan if (count) { 1256342ccce1SGevorg Sahakyan const u32 *buf = buffer; 1257342ccce1SGevorg Sahakyan 1258342ccce1SGevorg Sahakyan do { 1259342ccce1SGevorg Sahakyan dwc2_writel(hsotg, *buf++, offset); 1260342ccce1SGevorg Sahakyan } while (--count); 1261342ccce1SGevorg Sahakyan } 1262342ccce1SGevorg Sahakyan } 12630f548098SGevorg Sahakyan 1264197ba5f4SPaul Zimmerman /* Reasons for halting a host channel */ 1265197ba5f4SPaul Zimmerman enum dwc2_halt_status { 1266197ba5f4SPaul Zimmerman DWC2_HC_XFER_NO_HALT_STATUS, 1267197ba5f4SPaul Zimmerman DWC2_HC_XFER_COMPLETE, 1268197ba5f4SPaul Zimmerman DWC2_HC_XFER_URB_COMPLETE, 1269197ba5f4SPaul Zimmerman DWC2_HC_XFER_ACK, 1270197ba5f4SPaul Zimmerman DWC2_HC_XFER_NAK, 1271197ba5f4SPaul Zimmerman DWC2_HC_XFER_NYET, 1272197ba5f4SPaul Zimmerman DWC2_HC_XFER_STALL, 1273197ba5f4SPaul Zimmerman DWC2_HC_XFER_XACT_ERR, 1274197ba5f4SPaul Zimmerman DWC2_HC_XFER_FRAME_OVERRUN, 1275197ba5f4SPaul Zimmerman DWC2_HC_XFER_BABBLE_ERR, 1276197ba5f4SPaul Zimmerman DWC2_HC_XFER_DATA_TOGGLE_ERR, 1277197ba5f4SPaul Zimmerman DWC2_HC_XFER_AHB_ERR, 1278197ba5f4SPaul Zimmerman DWC2_HC_XFER_PERIODIC_INCOMPLETE, 1279197ba5f4SPaul Zimmerman DWC2_HC_XFER_URB_DEQUEUE, 1280197ba5f4SPaul Zimmerman }; 1281197ba5f4SPaul Zimmerman 12821e6b98ebSVardan Mikayelyan /* Core version information */ 12831e6b98ebSVardan Mikayelyan static inline bool dwc2_is_iot(struct dwc2_hsotg *hsotg) 12841e6b98ebSVardan Mikayelyan { 12851e6b98ebSVardan Mikayelyan return (hsotg->hw_params.snpsid & 0xfff00000) == 0x55300000; 12861e6b98ebSVardan Mikayelyan } 12871e6b98ebSVardan Mikayelyan 12881e6b98ebSVardan Mikayelyan static inline bool dwc2_is_fs_iot(struct dwc2_hsotg *hsotg) 12891e6b98ebSVardan Mikayelyan { 12901e6b98ebSVardan Mikayelyan return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55310000; 12911e6b98ebSVardan Mikayelyan } 12921e6b98ebSVardan Mikayelyan 12931e6b98ebSVardan Mikayelyan static inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg) 12941e6b98ebSVardan Mikayelyan { 12951e6b98ebSVardan Mikayelyan return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55320000; 12961e6b98ebSVardan Mikayelyan } 12971e6b98ebSVardan Mikayelyan 1298197ba5f4SPaul Zimmerman /* 1299197ba5f4SPaul Zimmerman * The following functions support initialization of the core driver component 1300197ba5f4SPaul Zimmerman * and the DWC_otg controller 1301197ba5f4SPaul Zimmerman */ 13026e6360b6SJohn Stultz int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait); 130341ba9b9bSVardan Mikayelyan int dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg); 130441ba9b9bSVardan Mikayelyan int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore); 1305624815ceSVardan Mikayelyan int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host); 1306624815ceSVardan Mikayelyan int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup, 1307624815ceSVardan Mikayelyan int reset, int is_host); 1308059d8d52SJules Maselbas void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg); 1309059d8d52SJules Maselbas int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy); 1310197ba5f4SPaul Zimmerman 131113b1f8e2SVardan Mikayelyan void dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host); 131209c96980SJohn Youn void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg); 131309c96980SJohn Youn 13149da51974SJohn Youn bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg); 1315197ba5f4SPaul Zimmerman 131665dc2e72SMinas Harutyunyan int dwc2_check_core_version(struct dwc2_hsotg *hsotg); 131765dc2e72SMinas Harutyunyan 1318197ba5f4SPaul Zimmerman /* 1319197ba5f4SPaul Zimmerman * Common core Functions. 1320197ba5f4SPaul Zimmerman * The following functions support managing the DWC_otg controller in either 1321197ba5f4SPaul Zimmerman * device or host mode. 1322197ba5f4SPaul Zimmerman */ 13239da51974SJohn Youn void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes); 13249da51974SJohn Youn void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num); 13259da51974SJohn Youn void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg); 1326197ba5f4SPaul Zimmerman 13279da51974SJohn Youn void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd); 13289da51974SJohn Youn void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd); 1329197ba5f4SPaul Zimmerman 133094d2666cSVardan Mikayelyan void dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup, 133194d2666cSVardan Mikayelyan int is_host); 1332c5c403dcSVardan Mikayelyan int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg); 1333c5c403dcSVardan Mikayelyan int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg); 133494d2666cSVardan Mikayelyan 133566e77a24SRazmik Karapetyan void dwc2_enable_acg(struct dwc2_hsotg *hsotg); 133666e77a24SRazmik Karapetyan 1337197ba5f4SPaul Zimmerman /* This function should be called on every hardware interrupt. */ 13389da51974SJohn Youn irqreturn_t dwc2_handle_common_intr(int irq, void *dev); 1339197ba5f4SPaul Zimmerman 1340323230efSJohn Youn /* The device ID match table */ 1341323230efSJohn Youn extern const struct of_device_id dwc2_of_match_table[]; 1342323230efSJohn Youn 13439da51974SJohn Youn int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg); 13449da51974SJohn Youn int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg); 1345ecb176c6SMian Yousaf Kaukab 134679d6b8c5SSevak Arakelyan /* Common polling functions */ 134779d6b8c5SSevak Arakelyan int dwc2_hsotg_wait_bit_set(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit, 134879d6b8c5SSevak Arakelyan u32 timeout); 134979d6b8c5SSevak Arakelyan int dwc2_hsotg_wait_bit_clear(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit, 135079d6b8c5SSevak Arakelyan u32 timeout); 1351334bbd4eSJohn Youn /* Parameters */ 1352c1d286cfSJohn Youn int dwc2_get_hwparams(struct dwc2_hsotg *hsotg); 1353334bbd4eSJohn Youn int dwc2_init_params(struct dwc2_hsotg *hsotg); 1354334bbd4eSJohn Youn 1355197ba5f4SPaul Zimmerman /* 13566bea9620SJohn Youn * The following functions check the controller's OTG operation mode 13576bea9620SJohn Youn * capability (GHWCFG2.OTG_MODE). 13586bea9620SJohn Youn * 13596bea9620SJohn Youn * These functions can be used before the internal hsotg->hw_params 13606bea9620SJohn Youn * are read in and cached so they always read directly from the 13616bea9620SJohn Youn * GHWCFG2 register. 13626bea9620SJohn Youn */ 13639da51974SJohn Youn unsigned int dwc2_op_mode(struct dwc2_hsotg *hsotg); 13646bea9620SJohn Youn bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg); 13656bea9620SJohn Youn bool dwc2_hw_is_host(struct dwc2_hsotg *hsotg); 13666bea9620SJohn Youn bool dwc2_hw_is_device(struct dwc2_hsotg *hsotg); 13676bea9620SJohn Youn 13686bea9620SJohn Youn /* 13691696d5abSJohn Youn * Returns the mode of operation, host or device 13701696d5abSJohn Youn */ 13711696d5abSJohn Youn static inline int dwc2_is_host_mode(struct dwc2_hsotg *hsotg) 13721696d5abSJohn Youn { 1373f25c42b8SGevorg Sahakyan return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) != 0; 13741696d5abSJohn Youn } 13759da51974SJohn Youn 13761696d5abSJohn Youn static inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg) 13771696d5abSJohn Youn { 1378f25c42b8SGevorg Sahakyan return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0; 13791696d5abSJohn Youn } 13801696d5abSJohn Youn 138117f93402SAmelie Delaunay int dwc2_drd_init(struct dwc2_hsotg *hsotg); 138217f93402SAmelie Delaunay void dwc2_drd_suspend(struct dwc2_hsotg *hsotg); 138317f93402SAmelie Delaunay void dwc2_drd_resume(struct dwc2_hsotg *hsotg); 138417f93402SAmelie Delaunay void dwc2_drd_exit(struct dwc2_hsotg *hsotg); 138517f93402SAmelie Delaunay 13861696d5abSJohn Youn /* 1387197ba5f4SPaul Zimmerman * Dump core registers and SPRAM 1388197ba5f4SPaul Zimmerman */ 13899da51974SJohn Youn void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg); 13909da51974SJohn Youn void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg); 13919da51974SJohn Youn void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); 1392197ba5f4SPaul Zimmerman 1393117777b2SDinh Nguyen /* Gadget defines */ 1394b98866c2SJohn Youn #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 1395b98866c2SJohn Youn IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 13969da51974SJohn Youn int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg); 13979da51974SJohn Youn int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2); 13989da51974SJohn Youn int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2); 1399f3768997SVardan Mikayelyan int dwc2_gadget_init(struct dwc2_hsotg *hsotg); 14009da51974SJohn Youn void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, 1401643cc4deSGregory Herrero bool reset); 140217f93402SAmelie Delaunay void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg); 14039da51974SJohn Youn void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg); 14049da51974SJohn Youn void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2); 14059da51974SJohn Youn int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode); 1406f81f46e1SGregory Herrero #define dwc2_is_device_connected(hsotg) (hsotg->connected) 140758e52ff6SJohn Youn int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg); 14089a5d2816SVardan Mikayelyan int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup); 1409c5c403dcSVardan Mikayelyan int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg); 1410c5c403dcSVardan Mikayelyan int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, 1411c5c403dcSVardan Mikayelyan int rem_wakeup, int reset); 1412c138ecfaSSevak Arakelyan int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg); 1413c138ecfaSSevak Arakelyan int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg); 1414c138ecfaSSevak Arakelyan int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg); 141521b03405SSevak Arakelyan void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg); 141615d9dbf8SGrigor Tovmasyan void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg); 1417117777b2SDinh Nguyen #else 14181f91b4ccSFelipe Balbi static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2) 1419117777b2SDinh Nguyen { return 0; } 14201f91b4ccSFelipe Balbi static inline int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2) 1421117777b2SDinh Nguyen { return 0; } 14221f91b4ccSFelipe Balbi static inline int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2) 1423117777b2SDinh Nguyen { return 0; } 1424f3768997SVardan Mikayelyan static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg) 1425117777b2SDinh Nguyen { return 0; } 14261f91b4ccSFelipe Balbi static inline void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, 1427643cc4deSGregory Herrero bool reset) {} 142817f93402SAmelie Delaunay static inline void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) {} 14291f91b4ccSFelipe Balbi static inline void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) {} 14301f91b4ccSFelipe Balbi static inline void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2) {} 14311f91b4ccSFelipe Balbi static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, 1432f91eea44SMian Yousaf Kaukab int testmode) 1433f91eea44SMian Yousaf Kaukab { return 0; } 1434f81f46e1SGregory Herrero #define dwc2_is_device_connected(hsotg) (0) 143558e52ff6SJohn Youn static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) 143658e52ff6SJohn Youn { return 0; } 14379a5d2816SVardan Mikayelyan static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, 14389a5d2816SVardan Mikayelyan int remote_wakeup) 143958e52ff6SJohn Youn { return 0; } 1440c5c403dcSVardan Mikayelyan static inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg) 1441c5c403dcSVardan Mikayelyan { return 0; } 1442c5c403dcSVardan Mikayelyan static inline int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, 1443c5c403dcSVardan Mikayelyan int rem_wakeup, int reset) 1444c5c403dcSVardan Mikayelyan { return 0; } 1445c138ecfaSSevak Arakelyan static inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) 1446c138ecfaSSevak Arakelyan { return 0; } 1447c138ecfaSSevak Arakelyan static inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) 1448c138ecfaSSevak Arakelyan { return 0; } 1449c138ecfaSSevak Arakelyan static inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) 1450c138ecfaSSevak Arakelyan { return 0; } 145121b03405SSevak Arakelyan static inline void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) {} 145215d9dbf8SGrigor Tovmasyan static inline void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) {} 1453117777b2SDinh Nguyen #endif 1454117777b2SDinh Nguyen 1455117777b2SDinh Nguyen #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 14569da51974SJohn Youn int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg); 14579da51974SJohn Youn int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, int us); 14589da51974SJohn Youn void dwc2_hcd_connect(struct dwc2_hsotg *hsotg); 14599da51974SJohn Youn void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force); 14609da51974SJohn Youn void dwc2_hcd_start(struct dwc2_hsotg *hsotg); 146165c9c4c6SVardan Mikayelyan int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup); 146258e52ff6SJohn Youn int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg); 146358e52ff6SJohn Youn int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg); 1464c5c403dcSVardan Mikayelyan int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg); 1465c5c403dcSVardan Mikayelyan int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 1466c5c403dcSVardan Mikayelyan int rem_wakeup, int reset); 1467c846b03fSDouglas Anderson bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2); 1468c40cf770SDouglas Anderson static inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) 1469c40cf770SDouglas Anderson { schedule_work(&hsotg->phy_reset_work); } 1470117777b2SDinh Nguyen #else 1471117777b2SDinh Nguyen static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) 1472117777b2SDinh Nguyen { return 0; } 1473fae4e826SDouglas Anderson static inline int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, 1474fae4e826SDouglas Anderson int us) 1475fae4e826SDouglas Anderson { return 0; } 14766a659531SDouglas Anderson static inline void dwc2_hcd_connect(struct dwc2_hsotg *hsotg) {} 14776a659531SDouglas Anderson static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {} 1478117777b2SDinh Nguyen static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} 1479117777b2SDinh Nguyen static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} 148065c9c4c6SVardan Mikayelyan static inline int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup) 148165c9c4c6SVardan Mikayelyan { return 0; } 14824fe160d5SHeiner Kallweit static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg) 1483117777b2SDinh Nguyen { return 0; } 148458e52ff6SJohn Youn static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) 148558e52ff6SJohn Youn { return 0; } 148658e52ff6SJohn Youn static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg) 148758e52ff6SJohn Youn { return 0; } 1488c5c403dcSVardan Mikayelyan static inline int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg) 1489c5c403dcSVardan Mikayelyan { return 0; } 1490c5c403dcSVardan Mikayelyan static inline int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 1491c5c403dcSVardan Mikayelyan int rem_wakeup, int reset) 1492c5c403dcSVardan Mikayelyan { return 0; } 1493c846b03fSDouglas Anderson static inline bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2) 1494c846b03fSDouglas Anderson { return false; } 1495c40cf770SDouglas Anderson static inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) {} 149658e52ff6SJohn Youn 1497117777b2SDinh Nguyen #endif 1498117777b2SDinh Nguyen 1499197ba5f4SPaul Zimmerman #endif /* __DWC2_CORE_H__ */ 1500