18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * core.h - DesignWare HS OTG Controller common declarations 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2004-2013 Synopsys, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 88c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 98c2ecf20Sopenharmony_ci * are met: 108c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 118c2ecf20Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 128c2ecf20Sopenharmony_ci * without modification. 138c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 148c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 158c2ecf20Sopenharmony_ci * documentation and/or other materials provided with the distribution. 168c2ecf20Sopenharmony_ci * 3. The names of the above-listed copyright holders may not be used 178c2ecf20Sopenharmony_ci * to endorse or promote products derived from this software without 188c2ecf20Sopenharmony_ci * specific prior written permission. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * ALTERNATIVELY, this software may be distributed under the terms of the 218c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") as published by the Free Software 228c2ecf20Sopenharmony_ci * Foundation; either version 2 of the License, or (at your option) any 238c2ecf20Sopenharmony_ci * later version. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 268c2ecf20Sopenharmony_ci * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 278c2ecf20Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 288c2ecf20Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 298c2ecf20Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 308c2ecf20Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 318c2ecf20Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 328c2ecf20Sopenharmony_ci * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 338c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 348c2ecf20Sopenharmony_ci * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 358c2ecf20Sopenharmony_ci * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#ifndef __DWC2_CORE_H__ 398c2ecf20Sopenharmony_ci#define __DWC2_CORE_H__ 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#include <linux/phy/phy.h> 428c2ecf20Sopenharmony_ci#include <linux/regulator/consumer.h> 438c2ecf20Sopenharmony_ci#include <linux/usb/gadget.h> 448c2ecf20Sopenharmony_ci#include <linux/usb/otg.h> 458c2ecf20Sopenharmony_ci#include <linux/usb/phy.h> 468c2ecf20Sopenharmony_ci#include "hw.h" 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* 498c2ecf20Sopenharmony_ci * Suggested defines for tracers: 508c2ecf20Sopenharmony_ci * - no_printk: Disable tracing 518c2ecf20Sopenharmony_ci * - pr_info: Print this info to the console 528c2ecf20Sopenharmony_ci * - trace_printk: Print this info to trace buffer (good for verbose logging) 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define DWC2_TRACE_SCHEDULER no_printk 568c2ecf20Sopenharmony_ci#define DWC2_TRACE_SCHEDULER_VB no_printk 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* Detailed scheduler tracing, but won't overwhelm console */ 598c2ecf20Sopenharmony_ci#define dwc2_sch_dbg(hsotg, fmt, ...) \ 608c2ecf20Sopenharmony_ci DWC2_TRACE_SCHEDULER(pr_fmt("%s: SCH: " fmt), \ 618c2ecf20Sopenharmony_ci dev_name(hsotg->dev), ##__VA_ARGS__) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* Verbose scheduler tracing */ 648c2ecf20Sopenharmony_ci#define dwc2_sch_vdbg(hsotg, fmt, ...) \ 658c2ecf20Sopenharmony_ci DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \ 668c2ecf20Sopenharmony_ci dev_name(hsotg->dev), ##__VA_ARGS__) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* Maximum number of Endpoints/HostChannels */ 698c2ecf20Sopenharmony_ci#define MAX_EPS_CHANNELS 16 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* dwc2-hsotg declarations */ 728c2ecf20Sopenharmony_cistatic const char * const dwc2_hsotg_supply_names[] = { 738c2ecf20Sopenharmony_ci "vusb_d", /* digital USB supply, 1.2V */ 748c2ecf20Sopenharmony_ci "vusb_a", /* analog USB supply, 1.1V */ 758c2ecf20Sopenharmony_ci}; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define DWC2_NUM_SUPPLIES ARRAY_SIZE(dwc2_hsotg_supply_names) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * EP0_MPS_LIMIT 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci * Unfortunately there seems to be a limit of the amount of data that can 838c2ecf20Sopenharmony_ci * be transferred by IN transactions on EP0. This is either 127 bytes or 3 848c2ecf20Sopenharmony_ci * packets (which practically means 1 packet and 63 bytes of data) when the 858c2ecf20Sopenharmony_ci * MPS is set to 64. 868c2ecf20Sopenharmony_ci * 878c2ecf20Sopenharmony_ci * This means if we are wanting to move >127 bytes of data, we need to 888c2ecf20Sopenharmony_ci * split the transactions up, but just doing one packet at a time does 898c2ecf20Sopenharmony_ci * not work (this may be an implicit DATA0 PID on first packet of the 908c2ecf20Sopenharmony_ci * transaction) and doing 2 packets is outside the controller's limits. 918c2ecf20Sopenharmony_ci * 928c2ecf20Sopenharmony_ci * If we try to lower the MPS size for EP0, then no transfers work properly 938c2ecf20Sopenharmony_ci * for EP0, and the system will fail basic enumeration. As no cause for this 948c2ecf20Sopenharmony_ci * has currently been found, we cannot support any large IN transfers for 958c2ecf20Sopenharmony_ci * EP0. 968c2ecf20Sopenharmony_ci */ 978c2ecf20Sopenharmony_ci#define EP0_MPS_LIMIT 64 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct dwc2_hsotg; 1008c2ecf20Sopenharmony_cistruct dwc2_hsotg_req; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/** 1038c2ecf20Sopenharmony_ci * struct dwc2_hsotg_ep - driver endpoint definition. 1048c2ecf20Sopenharmony_ci * @ep: The gadget layer representation of the endpoint. 1058c2ecf20Sopenharmony_ci * @name: The driver generated name for the endpoint. 1068c2ecf20Sopenharmony_ci * @queue: Queue of requests for this endpoint. 1078c2ecf20Sopenharmony_ci * @parent: Reference back to the parent device structure. 1088c2ecf20Sopenharmony_ci * @req: The current request that the endpoint is processing. This is 1098c2ecf20Sopenharmony_ci * used to indicate an request has been loaded onto the endpoint 1108c2ecf20Sopenharmony_ci * and has yet to be completed (maybe due to data move, or simply 1118c2ecf20Sopenharmony_ci * awaiting an ack from the core all the data has been completed). 1128c2ecf20Sopenharmony_ci * @debugfs: File entry for debugfs file for this endpoint. 1138c2ecf20Sopenharmony_ci * @dir_in: Set to true if this endpoint is of the IN direction, which 1148c2ecf20Sopenharmony_ci * means that it is sending data to the Host. 1158c2ecf20Sopenharmony_ci * @map_dir: Set to the value of dir_in when the DMA buffer is mapped. 1168c2ecf20Sopenharmony_ci * @index: The index for the endpoint registers. 1178c2ecf20Sopenharmony_ci * @mc: Multi Count - number of transactions per microframe 1188c2ecf20Sopenharmony_ci * @interval: Interval for periodic endpoints, in frames or microframes. 1198c2ecf20Sopenharmony_ci * @name: The name array passed to the USB core. 1208c2ecf20Sopenharmony_ci * @halted: Set if the endpoint has been halted. 1218c2ecf20Sopenharmony_ci * @periodic: Set if this is a periodic ep, such as Interrupt 1228c2ecf20Sopenharmony_ci * @isochronous: Set if this is a isochronous ep 1238c2ecf20Sopenharmony_ci * @send_zlp: Set if we need to send a zero-length packet. 1248c2ecf20Sopenharmony_ci * @desc_list_dma: The DMA address of descriptor chain currently in use. 1258c2ecf20Sopenharmony_ci * @desc_list: Pointer to descriptor DMA chain head currently in use. 1268c2ecf20Sopenharmony_ci * @desc_count: Count of entries within the DMA descriptor chain of EP. 1278c2ecf20Sopenharmony_ci * @next_desc: index of next free descriptor in the ISOC chain under SW control. 1288c2ecf20Sopenharmony_ci * @compl_desc: index of next descriptor to be completed by xFerComplete 1298c2ecf20Sopenharmony_ci * @total_data: The total number of data bytes done. 1308c2ecf20Sopenharmony_ci * @fifo_size: The size of the FIFO (for periodic IN endpoints) 1318c2ecf20Sopenharmony_ci * @fifo_index: For Dedicated FIFO operation, only FIFO0 can be used for EP0. 1328c2ecf20Sopenharmony_ci * @fifo_load: The amount of data loaded into the FIFO (periodic IN) 1338c2ecf20Sopenharmony_ci * @last_load: The offset of data for the last start of request. 1348c2ecf20Sopenharmony_ci * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN 1358c2ecf20Sopenharmony_ci * @target_frame: Targeted frame num to setup next ISOC transfer 1368c2ecf20Sopenharmony_ci * @frame_overrun: Indicates SOF number overrun in DSTS 1378c2ecf20Sopenharmony_ci * 1388c2ecf20Sopenharmony_ci * This is the driver's state for each registered endpoint, allowing it 1398c2ecf20Sopenharmony_ci * to keep track of transactions that need doing. Each endpoint has a 1408c2ecf20Sopenharmony_ci * lock to protect the state, to try and avoid using an overall lock 1418c2ecf20Sopenharmony_ci * for the host controller as much as possible. 1428c2ecf20Sopenharmony_ci * 1438c2ecf20Sopenharmony_ci * For periodic IN endpoints, we have fifo_size and fifo_load to try 1448c2ecf20Sopenharmony_ci * and keep track of the amount of data in the periodic FIFO for each 1458c2ecf20Sopenharmony_ci * of these as we don't have a status register that tells us how much 1468c2ecf20Sopenharmony_ci * is in each of them. (note, this may actually be useless information 1478c2ecf20Sopenharmony_ci * as in shared-fifo mode periodic in acts like a single-frame packet 1488c2ecf20Sopenharmony_ci * buffer than a fifo) 1498c2ecf20Sopenharmony_ci */ 1508c2ecf20Sopenharmony_cistruct dwc2_hsotg_ep { 1518c2ecf20Sopenharmony_ci struct usb_ep ep; 1528c2ecf20Sopenharmony_ci struct list_head queue; 1538c2ecf20Sopenharmony_ci struct dwc2_hsotg *parent; 1548c2ecf20Sopenharmony_ci struct dwc2_hsotg_req *req; 1558c2ecf20Sopenharmony_ci struct dentry *debugfs; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci unsigned long total_data; 1588c2ecf20Sopenharmony_ci unsigned int size_loaded; 1598c2ecf20Sopenharmony_ci unsigned int last_load; 1608c2ecf20Sopenharmony_ci unsigned int fifo_load; 1618c2ecf20Sopenharmony_ci unsigned short fifo_size; 1628c2ecf20Sopenharmony_ci unsigned short fifo_index; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci unsigned char dir_in; 1658c2ecf20Sopenharmony_ci unsigned char map_dir; 1668c2ecf20Sopenharmony_ci unsigned char index; 1678c2ecf20Sopenharmony_ci unsigned char mc; 1688c2ecf20Sopenharmony_ci u16 interval; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci unsigned int halted:1; 1718c2ecf20Sopenharmony_ci unsigned int periodic:1; 1728c2ecf20Sopenharmony_ci unsigned int isochronous:1; 1738c2ecf20Sopenharmony_ci unsigned int send_zlp:1; 1748c2ecf20Sopenharmony_ci unsigned int target_frame; 1758c2ecf20Sopenharmony_ci#define TARGET_FRAME_INITIAL 0xFFFFFFFF 1768c2ecf20Sopenharmony_ci bool frame_overrun; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci dma_addr_t desc_list_dma; 1798c2ecf20Sopenharmony_ci struct dwc2_dma_desc *desc_list; 1808c2ecf20Sopenharmony_ci u8 desc_count; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci unsigned int next_desc; 1838c2ecf20Sopenharmony_ci unsigned int compl_desc; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci char name[10]; 1868c2ecf20Sopenharmony_ci}; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci/** 1898c2ecf20Sopenharmony_ci * struct dwc2_hsotg_req - data transfer request 1908c2ecf20Sopenharmony_ci * @req: The USB gadget request 1918c2ecf20Sopenharmony_ci * @queue: The list of requests for the endpoint this is queued for. 1928c2ecf20Sopenharmony_ci * @saved_req_buf: variable to save req.buf when bounce buffers are used. 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_cistruct dwc2_hsotg_req { 1958c2ecf20Sopenharmony_ci struct usb_request req; 1968c2ecf20Sopenharmony_ci struct list_head queue; 1978c2ecf20Sopenharmony_ci void *saved_req_buf; 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 2018c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 2028c2ecf20Sopenharmony_ci#define call_gadget(_hs, _entry) \ 2038c2ecf20Sopenharmony_cido { \ 2048c2ecf20Sopenharmony_ci if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \ 2058c2ecf20Sopenharmony_ci (_hs)->driver && (_hs)->driver->_entry) { \ 2068c2ecf20Sopenharmony_ci spin_unlock(&_hs->lock); \ 2078c2ecf20Sopenharmony_ci (_hs)->driver->_entry(&(_hs)->gadget); \ 2088c2ecf20Sopenharmony_ci spin_lock(&_hs->lock); \ 2098c2ecf20Sopenharmony_ci } \ 2108c2ecf20Sopenharmony_ci} while (0) 2118c2ecf20Sopenharmony_ci#else 2128c2ecf20Sopenharmony_ci#define call_gadget(_hs, _entry) do {} while (0) 2138c2ecf20Sopenharmony_ci#endif 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_cistruct dwc2_hsotg; 2168c2ecf20Sopenharmony_cistruct dwc2_host_chan; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci/* Device States */ 2198c2ecf20Sopenharmony_cienum dwc2_lx_state { 2208c2ecf20Sopenharmony_ci DWC2_L0, /* On state */ 2218c2ecf20Sopenharmony_ci DWC2_L1, /* LPM sleep state */ 2228c2ecf20Sopenharmony_ci DWC2_L2, /* USB suspend state */ 2238c2ecf20Sopenharmony_ci DWC2_L3, /* Off state */ 2248c2ecf20Sopenharmony_ci}; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* Gadget ep0 states */ 2278c2ecf20Sopenharmony_cienum dwc2_ep0_state { 2288c2ecf20Sopenharmony_ci DWC2_EP0_SETUP, 2298c2ecf20Sopenharmony_ci DWC2_EP0_DATA_IN, 2308c2ecf20Sopenharmony_ci DWC2_EP0_DATA_OUT, 2318c2ecf20Sopenharmony_ci DWC2_EP0_STATUS_IN, 2328c2ecf20Sopenharmony_ci DWC2_EP0_STATUS_OUT, 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci/** 2368c2ecf20Sopenharmony_ci * struct dwc2_core_params - Parameters for configuring the core 2378c2ecf20Sopenharmony_ci * 2388c2ecf20Sopenharmony_ci * @otg_cap: Specifies the OTG capabilities. 2398c2ecf20Sopenharmony_ci * 0 - HNP and SRP capable 2408c2ecf20Sopenharmony_ci * 1 - SRP Only capable 2418c2ecf20Sopenharmony_ci * 2 - No HNP/SRP capable (always available) 2428c2ecf20Sopenharmony_ci * Defaults to best available option (0, 1, then 2) 2438c2ecf20Sopenharmony_ci * @host_dma: Specifies whether to use slave or DMA mode for accessing 2448c2ecf20Sopenharmony_ci * the data FIFOs. The driver will automatically detect the 2458c2ecf20Sopenharmony_ci * value for this parameter if none is specified. 2468c2ecf20Sopenharmony_ci * 0 - Slave (always available) 2478c2ecf20Sopenharmony_ci * 1 - DMA (default, if available) 2488c2ecf20Sopenharmony_ci * @dma_desc_enable: When DMA mode is enabled, specifies whether to use 2498c2ecf20Sopenharmony_ci * address DMA mode or descriptor DMA mode for accessing 2508c2ecf20Sopenharmony_ci * the data FIFOs. The driver will automatically detect the 2518c2ecf20Sopenharmony_ci * value for this if none is specified. 2528c2ecf20Sopenharmony_ci * 0 - Address DMA 2538c2ecf20Sopenharmony_ci * 1 - Descriptor DMA (default, if available) 2548c2ecf20Sopenharmony_ci * @dma_desc_fs_enable: When DMA mode is enabled, specifies whether to use 2558c2ecf20Sopenharmony_ci * address DMA mode or descriptor DMA mode for accessing 2568c2ecf20Sopenharmony_ci * the data FIFOs in Full Speed mode only. The driver 2578c2ecf20Sopenharmony_ci * will automatically detect the value for this if none is 2588c2ecf20Sopenharmony_ci * specified. 2598c2ecf20Sopenharmony_ci * 0 - Address DMA 2608c2ecf20Sopenharmony_ci * 1 - Descriptor DMA in FS (default, if available) 2618c2ecf20Sopenharmony_ci * @speed: Specifies the maximum speed of operation in host and 2628c2ecf20Sopenharmony_ci * device mode. The actual speed depends on the speed of 2638c2ecf20Sopenharmony_ci * the attached device and the value of phy_type. 2648c2ecf20Sopenharmony_ci * 0 - High Speed 2658c2ecf20Sopenharmony_ci * (default when phy_type is UTMI+ or ULPI) 2668c2ecf20Sopenharmony_ci * 1 - Full Speed 2678c2ecf20Sopenharmony_ci * (default when phy_type is Full Speed) 2688c2ecf20Sopenharmony_ci * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters 2698c2ecf20Sopenharmony_ci * 1 - Allow dynamic FIFO sizing (default, if available) 2708c2ecf20Sopenharmony_ci * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs 2718c2ecf20Sopenharmony_ci * are enabled for non-periodic IN endpoints in device 2728c2ecf20Sopenharmony_ci * mode. 2738c2ecf20Sopenharmony_ci * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when 2748c2ecf20Sopenharmony_ci * dynamic FIFO sizing is enabled 2758c2ecf20Sopenharmony_ci * 16 to 32768 2768c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2778c2ecf20Sopenharmony_ci * the default. 2788c2ecf20Sopenharmony_ci * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 2798c2ecf20Sopenharmony_ci * in host mode when dynamic FIFO sizing is enabled 2808c2ecf20Sopenharmony_ci * 16 to 32768 2818c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2828c2ecf20Sopenharmony_ci * the default. 2838c2ecf20Sopenharmony_ci * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in 2848c2ecf20Sopenharmony_ci * host mode when dynamic FIFO sizing is enabled 2858c2ecf20Sopenharmony_ci * 16 to 32768 2868c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2878c2ecf20Sopenharmony_ci * the default. 2888c2ecf20Sopenharmony_ci * @max_transfer_size: The maximum transfer size supported, in bytes 2898c2ecf20Sopenharmony_ci * 2047 to 65,535 2908c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2918c2ecf20Sopenharmony_ci * the default. 2928c2ecf20Sopenharmony_ci * @max_packet_count: The maximum number of packets in a transfer 2938c2ecf20Sopenharmony_ci * 15 to 511 2948c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2958c2ecf20Sopenharmony_ci * the default. 2968c2ecf20Sopenharmony_ci * @host_channels: The number of host channel registers to use 2978c2ecf20Sopenharmony_ci * 1 to 16 2988c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 2998c2ecf20Sopenharmony_ci * the default. 3008c2ecf20Sopenharmony_ci * @phy_type: Specifies the type of PHY interface to use. By default, 3018c2ecf20Sopenharmony_ci * the driver will automatically detect the phy_type. 3028c2ecf20Sopenharmony_ci * 0 - Full Speed Phy 3038c2ecf20Sopenharmony_ci * 1 - UTMI+ Phy 3048c2ecf20Sopenharmony_ci * 2 - ULPI Phy 3058c2ecf20Sopenharmony_ci * Defaults to best available option (2, 1, then 0) 3068c2ecf20Sopenharmony_ci * @phy_utmi_width: Specifies the UTMI+ Data Width (in bits). This parameter 3078c2ecf20Sopenharmony_ci * is applicable for a phy_type of UTMI+ or ULPI. (For a 3088c2ecf20Sopenharmony_ci * ULPI phy_type, this parameter indicates the data width 3098c2ecf20Sopenharmony_ci * between the MAC and the ULPI Wrapper.) Also, this 3108c2ecf20Sopenharmony_ci * parameter is applicable only if the OTG_HSPHY_WIDTH cC 3118c2ecf20Sopenharmony_ci * parameter was set to "8 and 16 bits", meaning that the 3128c2ecf20Sopenharmony_ci * core has been configured to work at either data path 3138c2ecf20Sopenharmony_ci * width. 3148c2ecf20Sopenharmony_ci * 8 or 16 (default 16 if available) 3158c2ecf20Sopenharmony_ci * @phy_ulpi_ddr: Specifies whether the ULPI operates at double or single 3168c2ecf20Sopenharmony_ci * data rate. This parameter is only applicable if phy_type 3178c2ecf20Sopenharmony_ci * is ULPI. 3188c2ecf20Sopenharmony_ci * 0 - single data rate ULPI interface with 8 bit wide 3198c2ecf20Sopenharmony_ci * data bus (default) 3208c2ecf20Sopenharmony_ci * 1 - double data rate ULPI interface with 4 bit wide 3218c2ecf20Sopenharmony_ci * data bus 3228c2ecf20Sopenharmony_ci * @phy_ulpi_ext_vbus: For a ULPI phy, specifies whether to use the internal or 3238c2ecf20Sopenharmony_ci * external supply to drive the VBus 3248c2ecf20Sopenharmony_ci * 0 - Internal supply (default) 3258c2ecf20Sopenharmony_ci * 1 - External supply 3268c2ecf20Sopenharmony_ci * @i2c_enable: Specifies whether to use the I2Cinterface for a full 3278c2ecf20Sopenharmony_ci * speed PHY. This parameter is only applicable if phy_type 3288c2ecf20Sopenharmony_ci * is FS. 3298c2ecf20Sopenharmony_ci * 0 - No (default) 3308c2ecf20Sopenharmony_ci * 1 - Yes 3318c2ecf20Sopenharmony_ci * @ipg_isoc_en: Indicates the IPG supports is enabled or disabled. 3328c2ecf20Sopenharmony_ci * 0 - Disable (default) 3338c2ecf20Sopenharmony_ci * 1 - Enable 3348c2ecf20Sopenharmony_ci * @acg_enable: For enabling Active Clock Gating in the controller 3358c2ecf20Sopenharmony_ci * 0 - No 3368c2ecf20Sopenharmony_ci * 1 - Yes 3378c2ecf20Sopenharmony_ci * @ulpi_fs_ls: Make ULPI phy operate in FS/LS mode only 3388c2ecf20Sopenharmony_ci * 0 - No (default) 3398c2ecf20Sopenharmony_ci * 1 - Yes 3408c2ecf20Sopenharmony_ci * @host_support_fs_ls_low_power: Specifies whether low power mode is supported 3418c2ecf20Sopenharmony_ci * when attached to a Full Speed or Low Speed device in 3428c2ecf20Sopenharmony_ci * host mode. 3438c2ecf20Sopenharmony_ci * 0 - Don't support low power mode (default) 3448c2ecf20Sopenharmony_ci * 1 - Support low power mode 3458c2ecf20Sopenharmony_ci * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode 3468c2ecf20Sopenharmony_ci * when connected to a Low Speed device in host 3478c2ecf20Sopenharmony_ci * mode. This parameter is applicable only if 3488c2ecf20Sopenharmony_ci * host_support_fs_ls_low_power is enabled. 3498c2ecf20Sopenharmony_ci * 0 - 48 MHz 3508c2ecf20Sopenharmony_ci * (default when phy_type is UTMI+ or ULPI) 3518c2ecf20Sopenharmony_ci * 1 - 6 MHz 3528c2ecf20Sopenharmony_ci * (default when phy_type is Full Speed) 3538c2ecf20Sopenharmony_ci * @oc_disable: Flag to disable overcurrent condition. 3548c2ecf20Sopenharmony_ci * 0 - Allow overcurrent condition to get detected 3558c2ecf20Sopenharmony_ci * 1 - Disable overcurrent condtion to get detected 3568c2ecf20Sopenharmony_ci * @ts_dline: Enable Term Select Dline pulsing 3578c2ecf20Sopenharmony_ci * 0 - No (default) 3588c2ecf20Sopenharmony_ci * 1 - Yes 3598c2ecf20Sopenharmony_ci * @reload_ctl: Allow dynamic reloading of HFIR register during runtime 3608c2ecf20Sopenharmony_ci * 0 - No (default for core < 2.92a) 3618c2ecf20Sopenharmony_ci * 1 - Yes (default for core >= 2.92a) 3628c2ecf20Sopenharmony_ci * @ahbcfg: This field allows the default value of the GAHBCFG 3638c2ecf20Sopenharmony_ci * register to be overridden 3648c2ecf20Sopenharmony_ci * -1 - GAHBCFG value will be set to 0x06 3658c2ecf20Sopenharmony_ci * (INCR, default) 3668c2ecf20Sopenharmony_ci * all others - GAHBCFG value will be overridden with 3678c2ecf20Sopenharmony_ci * this value 3688c2ecf20Sopenharmony_ci * Not all bits can be controlled like this, the 3698c2ecf20Sopenharmony_ci * bits defined by GAHBCFG_CTRL_MASK are controlled 3708c2ecf20Sopenharmony_ci * by the driver and are ignored in this 3718c2ecf20Sopenharmony_ci * configuration value. 3728c2ecf20Sopenharmony_ci * @uframe_sched: True to enable the microframe scheduler 3738c2ecf20Sopenharmony_ci * @external_id_pin_ctl: Specifies whether ID pin is handled externally. 3748c2ecf20Sopenharmony_ci * Disable CONIDSTSCHNG controller interrupt in such 3758c2ecf20Sopenharmony_ci * case. 3768c2ecf20Sopenharmony_ci * 0 - No (default) 3778c2ecf20Sopenharmony_ci * 1 - Yes 3788c2ecf20Sopenharmony_ci * @power_down: Specifies whether the controller support power_down. 3798c2ecf20Sopenharmony_ci * If power_down is enabled, the controller will enter 3808c2ecf20Sopenharmony_ci * power_down in both peripheral and host mode when 3818c2ecf20Sopenharmony_ci * needed. 3828c2ecf20Sopenharmony_ci * 0 - No (default) 3838c2ecf20Sopenharmony_ci * 1 - Partial power down 3848c2ecf20Sopenharmony_ci * 2 - Hibernation 3858c2ecf20Sopenharmony_ci * @lpm: Enable LPM support. 3868c2ecf20Sopenharmony_ci * 0 - No 3878c2ecf20Sopenharmony_ci * 1 - Yes 3888c2ecf20Sopenharmony_ci * @lpm_clock_gating: Enable core PHY clock gating. 3898c2ecf20Sopenharmony_ci * 0 - No 3908c2ecf20Sopenharmony_ci * 1 - Yes 3918c2ecf20Sopenharmony_ci * @besl: Enable LPM Errata support. 3928c2ecf20Sopenharmony_ci * 0 - No 3938c2ecf20Sopenharmony_ci * 1 - Yes 3948c2ecf20Sopenharmony_ci * @hird_threshold_en: HIRD or HIRD Threshold enable. 3958c2ecf20Sopenharmony_ci * 0 - No 3968c2ecf20Sopenharmony_ci * 1 - Yes 3978c2ecf20Sopenharmony_ci * @hird_threshold: Value of BESL or HIRD Threshold. 3988c2ecf20Sopenharmony_ci * @ref_clk_per: Indicates in terms of pico seconds the period 3998c2ecf20Sopenharmony_ci * of ref_clk. 4008c2ecf20Sopenharmony_ci * 62500 - 16MHz 4018c2ecf20Sopenharmony_ci * 58823 - 17MHz 4028c2ecf20Sopenharmony_ci * 52083 - 19.2MHz 4038c2ecf20Sopenharmony_ci * 50000 - 20MHz 4048c2ecf20Sopenharmony_ci * 41666 - 24MHz 4058c2ecf20Sopenharmony_ci * 33333 - 30MHz (default) 4068c2ecf20Sopenharmony_ci * 25000 - 40MHz 4078c2ecf20Sopenharmony_ci * @sof_cnt_wkup_alert: Indicates in term of number of SOF's after which 4088c2ecf20Sopenharmony_ci * the controller should generate an interrupt if the 4098c2ecf20Sopenharmony_ci * device had been in L1 state until that period. 4108c2ecf20Sopenharmony_ci * This is used by SW to initiate Remote WakeUp in the 4118c2ecf20Sopenharmony_ci * controller so as to sync to the uF number from the host. 4128c2ecf20Sopenharmony_ci * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO 4138c2ecf20Sopenharmony_ci * register. 4148c2ecf20Sopenharmony_ci * 0 - Deactivate the transceiver (default) 4158c2ecf20Sopenharmony_ci * 1 - Activate the transceiver 4168c2ecf20Sopenharmony_ci * @activate_stm_id_vb_detection: Activate external ID pin and Vbus level 4178c2ecf20Sopenharmony_ci * detection using GGPIO register. 4188c2ecf20Sopenharmony_ci * 0 - Deactivate the external level detection (default) 4198c2ecf20Sopenharmony_ci * 1 - Activate the external level detection 4208c2ecf20Sopenharmony_ci * @g_dma: Enables gadget dma usage (default: autodetect). 4218c2ecf20Sopenharmony_ci * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect). 4228c2ecf20Sopenharmony_ci * @g_rx_fifo_size: The periodic rx fifo size for the device, in 4238c2ecf20Sopenharmony_ci * DWORDS from 16-32768 (default: 2048 if 4248c2ecf20Sopenharmony_ci * possible, otherwise autodetect). 4258c2ecf20Sopenharmony_ci * @g_np_tx_fifo_size: The non-periodic tx fifo size for the device in 4268c2ecf20Sopenharmony_ci * DWORDS from 16-32768 (default: 1024 if 4278c2ecf20Sopenharmony_ci * possible, otherwise autodetect). 4288c2ecf20Sopenharmony_ci * @g_tx_fifo_size: An array of TX fifo sizes in dedicated fifo 4298c2ecf20Sopenharmony_ci * mode. Each value corresponds to one EP 4308c2ecf20Sopenharmony_ci * starting from EP1 (max 15 values). Sizes are 4318c2ecf20Sopenharmony_ci * in DWORDS with possible values from from 4328c2ecf20Sopenharmony_ci * 16-32768 (default: 256, 256, 256, 256, 768, 4338c2ecf20Sopenharmony_ci * 768, 768, 768, 0, 0, 0, 0, 0, 0, 0). 4348c2ecf20Sopenharmony_ci * @change_speed_quirk: Change speed configuration to DWC2_SPEED_PARAM_FULL 4358c2ecf20Sopenharmony_ci * while full&low speed device connect. And change speed 4368c2ecf20Sopenharmony_ci * back to DWC2_SPEED_PARAM_HIGH while device is gone. 4378c2ecf20Sopenharmony_ci * 0 - No (default) 4388c2ecf20Sopenharmony_ci * 1 - Yes 4398c2ecf20Sopenharmony_ci * @service_interval: Enable service interval based scheduling. 4408c2ecf20Sopenharmony_ci * 0 - No 4418c2ecf20Sopenharmony_ci * 1 - Yes 4428c2ecf20Sopenharmony_ci * 4438c2ecf20Sopenharmony_ci * The following parameters may be specified when starting the module. These 4448c2ecf20Sopenharmony_ci * parameters define how the DWC_otg controller should be configured. A 4458c2ecf20Sopenharmony_ci * value of -1 (or any other out of range value) for any parameter means 4468c2ecf20Sopenharmony_ci * to read the value from hardware (if possible) or use the builtin 4478c2ecf20Sopenharmony_ci * default described above. 4488c2ecf20Sopenharmony_ci */ 4498c2ecf20Sopenharmony_cistruct dwc2_core_params { 4508c2ecf20Sopenharmony_ci u8 otg_cap; 4518c2ecf20Sopenharmony_ci#define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 4528c2ecf20Sopenharmony_ci#define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE 1 4538c2ecf20Sopenharmony_ci#define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci u8 phy_type; 4568c2ecf20Sopenharmony_ci#define DWC2_PHY_TYPE_PARAM_FS 0 4578c2ecf20Sopenharmony_ci#define DWC2_PHY_TYPE_PARAM_UTMI 1 4588c2ecf20Sopenharmony_ci#define DWC2_PHY_TYPE_PARAM_ULPI 2 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci u8 speed; 4618c2ecf20Sopenharmony_ci#define DWC2_SPEED_PARAM_HIGH 0 4628c2ecf20Sopenharmony_ci#define DWC2_SPEED_PARAM_FULL 1 4638c2ecf20Sopenharmony_ci#define DWC2_SPEED_PARAM_LOW 2 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci u8 phy_utmi_width; 4668c2ecf20Sopenharmony_ci bool phy_ulpi_ddr; 4678c2ecf20Sopenharmony_ci bool phy_ulpi_ext_vbus; 4688c2ecf20Sopenharmony_ci bool enable_dynamic_fifo; 4698c2ecf20Sopenharmony_ci bool en_multiple_tx_fifo; 4708c2ecf20Sopenharmony_ci bool i2c_enable; 4718c2ecf20Sopenharmony_ci bool acg_enable; 4728c2ecf20Sopenharmony_ci bool ulpi_fs_ls; 4738c2ecf20Sopenharmony_ci bool ts_dline; 4748c2ecf20Sopenharmony_ci bool reload_ctl; 4758c2ecf20Sopenharmony_ci bool uframe_sched; 4768c2ecf20Sopenharmony_ci bool external_id_pin_ctl; 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci int power_down; 4798c2ecf20Sopenharmony_ci#define DWC2_POWER_DOWN_PARAM_NONE 0 4808c2ecf20Sopenharmony_ci#define DWC2_POWER_DOWN_PARAM_PARTIAL 1 4818c2ecf20Sopenharmony_ci#define DWC2_POWER_DOWN_PARAM_HIBERNATION 2 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci bool lpm; 4848c2ecf20Sopenharmony_ci bool lpm_clock_gating; 4858c2ecf20Sopenharmony_ci bool besl; 4868c2ecf20Sopenharmony_ci bool hird_threshold_en; 4878c2ecf20Sopenharmony_ci bool service_interval; 4888c2ecf20Sopenharmony_ci u8 hird_threshold; 4898c2ecf20Sopenharmony_ci bool activate_stm_fs_transceiver; 4908c2ecf20Sopenharmony_ci bool activate_stm_id_vb_detection; 4918c2ecf20Sopenharmony_ci bool ipg_isoc_en; 4928c2ecf20Sopenharmony_ci u16 max_packet_count; 4938c2ecf20Sopenharmony_ci u32 max_transfer_size; 4948c2ecf20Sopenharmony_ci u32 ahbcfg; 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci /* GREFCLK parameters */ 4978c2ecf20Sopenharmony_ci u32 ref_clk_per; 4988c2ecf20Sopenharmony_ci u16 sof_cnt_wkup_alert; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci /* Host parameters */ 5018c2ecf20Sopenharmony_ci bool host_dma; 5028c2ecf20Sopenharmony_ci bool dma_desc_enable; 5038c2ecf20Sopenharmony_ci bool dma_desc_fs_enable; 5048c2ecf20Sopenharmony_ci bool host_support_fs_ls_low_power; 5058c2ecf20Sopenharmony_ci bool host_ls_low_power_phy_clk; 5068c2ecf20Sopenharmony_ci bool oc_disable; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci u8 host_channels; 5098c2ecf20Sopenharmony_ci u16 host_rx_fifo_size; 5108c2ecf20Sopenharmony_ci u16 host_nperio_tx_fifo_size; 5118c2ecf20Sopenharmony_ci u16 host_perio_tx_fifo_size; 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci /* Gadget parameters */ 5148c2ecf20Sopenharmony_ci bool g_dma; 5158c2ecf20Sopenharmony_ci bool g_dma_desc; 5168c2ecf20Sopenharmony_ci u32 g_rx_fifo_size; 5178c2ecf20Sopenharmony_ci u32 g_np_tx_fifo_size; 5188c2ecf20Sopenharmony_ci u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci bool change_speed_quirk; 5218c2ecf20Sopenharmony_ci}; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci/** 5248c2ecf20Sopenharmony_ci * struct dwc2_hw_params - Autodetected parameters. 5258c2ecf20Sopenharmony_ci * 5268c2ecf20Sopenharmony_ci * These parameters are the various parameters read from hardware 5278c2ecf20Sopenharmony_ci * registers during initialization. They typically contain the best 5288c2ecf20Sopenharmony_ci * supported or maximum value that can be configured in the 5298c2ecf20Sopenharmony_ci * corresponding dwc2_core_params value. 5308c2ecf20Sopenharmony_ci * 5318c2ecf20Sopenharmony_ci * The values that are not in dwc2_core_params are documented below. 5328c2ecf20Sopenharmony_ci * 5338c2ecf20Sopenharmony_ci * @op_mode: Mode of Operation 5348c2ecf20Sopenharmony_ci * 0 - HNP- and SRP-Capable OTG (Host & Device) 5358c2ecf20Sopenharmony_ci * 1 - SRP-Capable OTG (Host & Device) 5368c2ecf20Sopenharmony_ci * 2 - Non-HNP and Non-SRP Capable OTG (Host & Device) 5378c2ecf20Sopenharmony_ci * 3 - SRP-Capable Device 5388c2ecf20Sopenharmony_ci * 4 - Non-OTG Device 5398c2ecf20Sopenharmony_ci * 5 - SRP-Capable Host 5408c2ecf20Sopenharmony_ci * 6 - Non-OTG Host 5418c2ecf20Sopenharmony_ci * @arch: Architecture 5428c2ecf20Sopenharmony_ci * 0 - Slave only 5438c2ecf20Sopenharmony_ci * 1 - External DMA 5448c2ecf20Sopenharmony_ci * 2 - Internal DMA 5458c2ecf20Sopenharmony_ci * @ipg_isoc_en: This feature indicates that the controller supports 5468c2ecf20Sopenharmony_ci * the worst-case scenario of Rx followed by Rx 5478c2ecf20Sopenharmony_ci * Interpacket Gap (IPG) (32 bitTimes) as per the utmi 5488c2ecf20Sopenharmony_ci * specification for any token following ISOC OUT token. 5498c2ecf20Sopenharmony_ci * 0 - Don't support 5508c2ecf20Sopenharmony_ci * 1 - Support 5518c2ecf20Sopenharmony_ci * @power_optimized: Are power optimizations enabled? 5528c2ecf20Sopenharmony_ci * @num_dev_ep: Number of device endpoints available 5538c2ecf20Sopenharmony_ci * @num_dev_in_eps: Number of device IN endpoints available 5548c2ecf20Sopenharmony_ci * @num_dev_perio_in_ep: Number of device periodic IN endpoints 5558c2ecf20Sopenharmony_ci * available 5568c2ecf20Sopenharmony_ci * @dev_token_q_depth: Device Mode IN Token Sequence Learning Queue 5578c2ecf20Sopenharmony_ci * Depth 5588c2ecf20Sopenharmony_ci * 0 to 30 5598c2ecf20Sopenharmony_ci * @host_perio_tx_q_depth: 5608c2ecf20Sopenharmony_ci * Host Mode Periodic Request Queue Depth 5618c2ecf20Sopenharmony_ci * 2, 4 or 8 5628c2ecf20Sopenharmony_ci * @nperio_tx_q_depth: 5638c2ecf20Sopenharmony_ci * Non-Periodic Request Queue Depth 5648c2ecf20Sopenharmony_ci * 2, 4 or 8 5658c2ecf20Sopenharmony_ci * @hs_phy_type: High-speed PHY interface type 5668c2ecf20Sopenharmony_ci * 0 - High-speed interface not supported 5678c2ecf20Sopenharmony_ci * 1 - UTMI+ 5688c2ecf20Sopenharmony_ci * 2 - ULPI 5698c2ecf20Sopenharmony_ci * 3 - UTMI+ and ULPI 5708c2ecf20Sopenharmony_ci * @fs_phy_type: Full-speed PHY interface type 5718c2ecf20Sopenharmony_ci * 0 - Full speed interface not supported 5728c2ecf20Sopenharmony_ci * 1 - Dedicated full speed interface 5738c2ecf20Sopenharmony_ci * 2 - FS pins shared with UTMI+ pins 5748c2ecf20Sopenharmony_ci * 3 - FS pins shared with ULPI pins 5758c2ecf20Sopenharmony_ci * @total_fifo_size: Total internal RAM for FIFOs (bytes) 5768c2ecf20Sopenharmony_ci * @hibernation: Is hibernation enabled? 5778c2ecf20Sopenharmony_ci * @utmi_phy_data_width: UTMI+ PHY data width 5788c2ecf20Sopenharmony_ci * 0 - 8 bits 5798c2ecf20Sopenharmony_ci * 1 - 16 bits 5808c2ecf20Sopenharmony_ci * 2 - 8 or 16 bits 5818c2ecf20Sopenharmony_ci * @snpsid: Value from SNPSID register 5828c2ecf20Sopenharmony_ci * @dev_ep_dirs: Direction of device endpoints (GHWCFG1) 5838c2ecf20Sopenharmony_ci * @g_tx_fifo_size: Power-on values of TxFIFO sizes 5848c2ecf20Sopenharmony_ci * @dma_desc_enable: When DMA mode is enabled, specifies whether to use 5858c2ecf20Sopenharmony_ci * address DMA mode or descriptor DMA mode for accessing 5868c2ecf20Sopenharmony_ci * the data FIFOs. The driver will automatically detect the 5878c2ecf20Sopenharmony_ci * value for this if none is specified. 5888c2ecf20Sopenharmony_ci * 0 - Address DMA 5898c2ecf20Sopenharmony_ci * 1 - Descriptor DMA (default, if available) 5908c2ecf20Sopenharmony_ci * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters 5918c2ecf20Sopenharmony_ci * 1 - Allow dynamic FIFO sizing (default, if available) 5928c2ecf20Sopenharmony_ci * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs 5938c2ecf20Sopenharmony_ci * are enabled for non-periodic IN endpoints in device 5948c2ecf20Sopenharmony_ci * mode. 5958c2ecf20Sopenharmony_ci * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 5968c2ecf20Sopenharmony_ci * in host mode when dynamic FIFO sizing is enabled 5978c2ecf20Sopenharmony_ci * 16 to 32768 5988c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 5998c2ecf20Sopenharmony_ci * the default. 6008c2ecf20Sopenharmony_ci * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in 6018c2ecf20Sopenharmony_ci * host mode when dynamic FIFO sizing is enabled 6028c2ecf20Sopenharmony_ci * 16 to 32768 6038c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6048c2ecf20Sopenharmony_ci * the default. 6058c2ecf20Sopenharmony_ci * @max_transfer_size: The maximum transfer size supported, in bytes 6068c2ecf20Sopenharmony_ci * 2047 to 65,535 6078c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6088c2ecf20Sopenharmony_ci * the default. 6098c2ecf20Sopenharmony_ci * @max_packet_count: The maximum number of packets in a transfer 6108c2ecf20Sopenharmony_ci * 15 to 511 6118c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6128c2ecf20Sopenharmony_ci * the default. 6138c2ecf20Sopenharmony_ci * @host_channels: The number of host channel registers to use 6148c2ecf20Sopenharmony_ci * 1 to 16 6158c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6168c2ecf20Sopenharmony_ci * the default. 6178c2ecf20Sopenharmony_ci * @dev_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO 6188c2ecf20Sopenharmony_ci * in device mode when dynamic FIFO sizing is enabled 6198c2ecf20Sopenharmony_ci * 16 to 32768 6208c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6218c2ecf20Sopenharmony_ci * the default. 6228c2ecf20Sopenharmony_ci * @i2c_enable: Specifies whether to use the I2Cinterface for a full 6238c2ecf20Sopenharmony_ci * speed PHY. This parameter is only applicable if phy_type 6248c2ecf20Sopenharmony_ci * is FS. 6258c2ecf20Sopenharmony_ci * 0 - No (default) 6268c2ecf20Sopenharmony_ci * 1 - Yes 6278c2ecf20Sopenharmony_ci * @acg_enable: For enabling Active Clock Gating in the controller 6288c2ecf20Sopenharmony_ci * 0 - Disable 6298c2ecf20Sopenharmony_ci * 1 - Enable 6308c2ecf20Sopenharmony_ci * @lpm_mode: For enabling Link Power Management in the controller 6318c2ecf20Sopenharmony_ci * 0 - Disable 6328c2ecf20Sopenharmony_ci * 1 - Enable 6338c2ecf20Sopenharmony_ci * @rx_fifo_size: Number of 4-byte words in the Rx FIFO when dynamic 6348c2ecf20Sopenharmony_ci * FIFO sizing is enabled 16 to 32768 6358c2ecf20Sopenharmony_ci * Actual maximum value is autodetected and also 6368c2ecf20Sopenharmony_ci * the default. 6378c2ecf20Sopenharmony_ci * @service_interval_mode: For enabling service interval based scheduling in the 6388c2ecf20Sopenharmony_ci * controller. 6398c2ecf20Sopenharmony_ci * 0 - Disable 6408c2ecf20Sopenharmony_ci * 1 - Enable 6418c2ecf20Sopenharmony_ci */ 6428c2ecf20Sopenharmony_cistruct dwc2_hw_params { 6438c2ecf20Sopenharmony_ci unsigned op_mode:3; 6448c2ecf20Sopenharmony_ci unsigned arch:2; 6458c2ecf20Sopenharmony_ci unsigned dma_desc_enable:1; 6468c2ecf20Sopenharmony_ci unsigned enable_dynamic_fifo:1; 6478c2ecf20Sopenharmony_ci unsigned en_multiple_tx_fifo:1; 6488c2ecf20Sopenharmony_ci unsigned rx_fifo_size:16; 6498c2ecf20Sopenharmony_ci unsigned host_nperio_tx_fifo_size:16; 6508c2ecf20Sopenharmony_ci unsigned dev_nperio_tx_fifo_size:16; 6518c2ecf20Sopenharmony_ci unsigned host_perio_tx_fifo_size:16; 6528c2ecf20Sopenharmony_ci unsigned nperio_tx_q_depth:3; 6538c2ecf20Sopenharmony_ci unsigned host_perio_tx_q_depth:3; 6548c2ecf20Sopenharmony_ci unsigned dev_token_q_depth:5; 6558c2ecf20Sopenharmony_ci unsigned max_transfer_size:26; 6568c2ecf20Sopenharmony_ci unsigned max_packet_count:11; 6578c2ecf20Sopenharmony_ci unsigned host_channels:5; 6588c2ecf20Sopenharmony_ci unsigned hs_phy_type:2; 6598c2ecf20Sopenharmony_ci unsigned fs_phy_type:2; 6608c2ecf20Sopenharmony_ci unsigned i2c_enable:1; 6618c2ecf20Sopenharmony_ci unsigned acg_enable:1; 6628c2ecf20Sopenharmony_ci unsigned num_dev_ep:4; 6638c2ecf20Sopenharmony_ci unsigned num_dev_in_eps : 4; 6648c2ecf20Sopenharmony_ci unsigned num_dev_perio_in_ep:4; 6658c2ecf20Sopenharmony_ci unsigned total_fifo_size:16; 6668c2ecf20Sopenharmony_ci unsigned power_optimized:1; 6678c2ecf20Sopenharmony_ci unsigned hibernation:1; 6688c2ecf20Sopenharmony_ci unsigned utmi_phy_data_width:2; 6698c2ecf20Sopenharmony_ci unsigned lpm_mode:1; 6708c2ecf20Sopenharmony_ci unsigned ipg_isoc_en:1; 6718c2ecf20Sopenharmony_ci unsigned service_interval_mode:1; 6728c2ecf20Sopenharmony_ci u32 snpsid; 6738c2ecf20Sopenharmony_ci u32 dev_ep_dirs; 6748c2ecf20Sopenharmony_ci u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; 6758c2ecf20Sopenharmony_ci}; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci/* Size of control and EP0 buffers */ 6788c2ecf20Sopenharmony_ci#define DWC2_CTRL_BUFF_SIZE 8 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci/** 6818c2ecf20Sopenharmony_ci * struct dwc2_gregs_backup - Holds global registers state before 6828c2ecf20Sopenharmony_ci * entering partial power down 6838c2ecf20Sopenharmony_ci * @gotgctl: Backup of GOTGCTL register 6848c2ecf20Sopenharmony_ci * @gintmsk: Backup of GINTMSK register 6858c2ecf20Sopenharmony_ci * @gahbcfg: Backup of GAHBCFG register 6868c2ecf20Sopenharmony_ci * @gusbcfg: Backup of GUSBCFG register 6878c2ecf20Sopenharmony_ci * @grxfsiz: Backup of GRXFSIZ register 6888c2ecf20Sopenharmony_ci * @gnptxfsiz: Backup of GNPTXFSIZ register 6898c2ecf20Sopenharmony_ci * @gi2cctl: Backup of GI2CCTL register 6908c2ecf20Sopenharmony_ci * @glpmcfg: Backup of GLPMCFG register 6918c2ecf20Sopenharmony_ci * @gdfifocfg: Backup of GDFIFOCFG register 6928c2ecf20Sopenharmony_ci * @pcgcctl: Backup of PCGCCTL register 6938c2ecf20Sopenharmony_ci * @pcgcctl1: Backup of PCGCCTL1 register 6948c2ecf20Sopenharmony_ci * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint 6958c2ecf20Sopenharmony_ci * @gpwrdn: Backup of GPWRDN register 6968c2ecf20Sopenharmony_ci * @valid: True if registers values backuped. 6978c2ecf20Sopenharmony_ci */ 6988c2ecf20Sopenharmony_cistruct dwc2_gregs_backup { 6998c2ecf20Sopenharmony_ci u32 gotgctl; 7008c2ecf20Sopenharmony_ci u32 gintmsk; 7018c2ecf20Sopenharmony_ci u32 gahbcfg; 7028c2ecf20Sopenharmony_ci u32 gusbcfg; 7038c2ecf20Sopenharmony_ci u32 grxfsiz; 7048c2ecf20Sopenharmony_ci u32 gnptxfsiz; 7058c2ecf20Sopenharmony_ci u32 gi2cctl; 7068c2ecf20Sopenharmony_ci u32 glpmcfg; 7078c2ecf20Sopenharmony_ci u32 pcgcctl; 7088c2ecf20Sopenharmony_ci u32 pcgcctl1; 7098c2ecf20Sopenharmony_ci u32 gdfifocfg; 7108c2ecf20Sopenharmony_ci u32 gpwrdn; 7118c2ecf20Sopenharmony_ci bool valid; 7128c2ecf20Sopenharmony_ci}; 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci/** 7158c2ecf20Sopenharmony_ci * struct dwc2_dregs_backup - Holds device registers state before 7168c2ecf20Sopenharmony_ci * entering partial power down 7178c2ecf20Sopenharmony_ci * @dcfg: Backup of DCFG register 7188c2ecf20Sopenharmony_ci * @dctl: Backup of DCTL register 7198c2ecf20Sopenharmony_ci * @daintmsk: Backup of DAINTMSK register 7208c2ecf20Sopenharmony_ci * @diepmsk: Backup of DIEPMSK register 7218c2ecf20Sopenharmony_ci * @doepmsk: Backup of DOEPMSK register 7228c2ecf20Sopenharmony_ci * @diepctl: Backup of DIEPCTL register 7238c2ecf20Sopenharmony_ci * @dieptsiz: Backup of DIEPTSIZ register 7248c2ecf20Sopenharmony_ci * @diepdma: Backup of DIEPDMA register 7258c2ecf20Sopenharmony_ci * @doepctl: Backup of DOEPCTL register 7268c2ecf20Sopenharmony_ci * @doeptsiz: Backup of DOEPTSIZ register 7278c2ecf20Sopenharmony_ci * @doepdma: Backup of DOEPDMA register 7288c2ecf20Sopenharmony_ci * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint 7298c2ecf20Sopenharmony_ci * @valid: True if registers values backuped. 7308c2ecf20Sopenharmony_ci */ 7318c2ecf20Sopenharmony_cistruct dwc2_dregs_backup { 7328c2ecf20Sopenharmony_ci u32 dcfg; 7338c2ecf20Sopenharmony_ci u32 dctl; 7348c2ecf20Sopenharmony_ci u32 daintmsk; 7358c2ecf20Sopenharmony_ci u32 diepmsk; 7368c2ecf20Sopenharmony_ci u32 doepmsk; 7378c2ecf20Sopenharmony_ci u32 diepctl[MAX_EPS_CHANNELS]; 7388c2ecf20Sopenharmony_ci u32 dieptsiz[MAX_EPS_CHANNELS]; 7398c2ecf20Sopenharmony_ci u32 diepdma[MAX_EPS_CHANNELS]; 7408c2ecf20Sopenharmony_ci u32 doepctl[MAX_EPS_CHANNELS]; 7418c2ecf20Sopenharmony_ci u32 doeptsiz[MAX_EPS_CHANNELS]; 7428c2ecf20Sopenharmony_ci u32 doepdma[MAX_EPS_CHANNELS]; 7438c2ecf20Sopenharmony_ci u32 dtxfsiz[MAX_EPS_CHANNELS]; 7448c2ecf20Sopenharmony_ci bool valid; 7458c2ecf20Sopenharmony_ci}; 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci/** 7488c2ecf20Sopenharmony_ci * struct dwc2_hregs_backup - Holds host registers state before 7498c2ecf20Sopenharmony_ci * entering partial power down 7508c2ecf20Sopenharmony_ci * @hcfg: Backup of HCFG register 7518c2ecf20Sopenharmony_ci * @haintmsk: Backup of HAINTMSK register 7528c2ecf20Sopenharmony_ci * @hcintmsk: Backup of HCINTMSK register 7538c2ecf20Sopenharmony_ci * @hprt0: Backup of HPTR0 register 7548c2ecf20Sopenharmony_ci * @hfir: Backup of HFIR register 7558c2ecf20Sopenharmony_ci * @hptxfsiz: Backup of HPTXFSIZ register 7568c2ecf20Sopenharmony_ci * @valid: True if registers values backuped. 7578c2ecf20Sopenharmony_ci */ 7588c2ecf20Sopenharmony_cistruct dwc2_hregs_backup { 7598c2ecf20Sopenharmony_ci u32 hcfg; 7608c2ecf20Sopenharmony_ci u32 haintmsk; 7618c2ecf20Sopenharmony_ci u32 hcintmsk[MAX_EPS_CHANNELS]; 7628c2ecf20Sopenharmony_ci u32 hprt0; 7638c2ecf20Sopenharmony_ci u32 hfir; 7648c2ecf20Sopenharmony_ci u32 hptxfsiz; 7658c2ecf20Sopenharmony_ci bool valid; 7668c2ecf20Sopenharmony_ci}; 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci/* 7698c2ecf20Sopenharmony_ci * Constants related to high speed periodic scheduling 7708c2ecf20Sopenharmony_ci * 7718c2ecf20Sopenharmony_ci * We have a periodic schedule that is DWC2_HS_SCHEDULE_UFRAMES long. From a 7728c2ecf20Sopenharmony_ci * reservation point of view it's assumed that the schedule goes right back to 7738c2ecf20Sopenharmony_ci * the beginning after the end of the schedule. 7748c2ecf20Sopenharmony_ci * 7758c2ecf20Sopenharmony_ci * What does that mean for scheduling things with a long interval? It means 7768c2ecf20Sopenharmony_ci * we'll reserve time for them in every possible microframe that they could 7778c2ecf20Sopenharmony_ci * ever be scheduled in. ...but we'll still only actually schedule them as 7788c2ecf20Sopenharmony_ci * often as they were requested. 7798c2ecf20Sopenharmony_ci * 7808c2ecf20Sopenharmony_ci * We keep our schedule in a "bitmap" structure. This simplifies having 7818c2ecf20Sopenharmony_ci * to keep track of and merge intervals: we just let the bitmap code do most 7828c2ecf20Sopenharmony_ci * of the heavy lifting. In a way scheduling is much like memory allocation. 7838c2ecf20Sopenharmony_ci * 7848c2ecf20Sopenharmony_ci * We schedule 100us per uframe or 80% of 125us (the maximum amount you're 7858c2ecf20Sopenharmony_ci * supposed to schedule for periodic transfers). That's according to spec. 7868c2ecf20Sopenharmony_ci * 7878c2ecf20Sopenharmony_ci * Note that though we only schedule 80% of each microframe, the bitmap that we 7888c2ecf20Sopenharmony_ci * keep the schedule in is tightly packed (AKA it doesn't have 100us worth of 7898c2ecf20Sopenharmony_ci * space for each uFrame). 7908c2ecf20Sopenharmony_ci * 7918c2ecf20Sopenharmony_ci * Requirements: 7928c2ecf20Sopenharmony_ci * - DWC2_HS_SCHEDULE_UFRAMES must even divide 0x4000 (HFNUM_MAX_FRNUM + 1) 7938c2ecf20Sopenharmony_ci * - DWC2_HS_SCHEDULE_UFRAMES must be 8 times DWC2_LS_SCHEDULE_FRAMES (probably 7948c2ecf20Sopenharmony_ci * could be any multiple of 8 times DWC2_LS_SCHEDULE_FRAMES, but there might 7958c2ecf20Sopenharmony_ci * be bugs). The 8 comes from the USB spec: number of microframes per frame. 7968c2ecf20Sopenharmony_ci */ 7978c2ecf20Sopenharmony_ci#define DWC2_US_PER_UFRAME 125 7988c2ecf20Sopenharmony_ci#define DWC2_HS_PERIODIC_US_PER_UFRAME 100 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci#define DWC2_HS_SCHEDULE_UFRAMES 8 8018c2ecf20Sopenharmony_ci#define DWC2_HS_SCHEDULE_US (DWC2_HS_SCHEDULE_UFRAMES * \ 8028c2ecf20Sopenharmony_ci DWC2_HS_PERIODIC_US_PER_UFRAME) 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci/* 8058c2ecf20Sopenharmony_ci * Constants related to low speed scheduling 8068c2ecf20Sopenharmony_ci * 8078c2ecf20Sopenharmony_ci * For high speed we schedule every 1us. For low speed that's a bit overkill, 8088c2ecf20Sopenharmony_ci * so we make up a unit called a "slice" that's worth 25us. There are 40 8098c2ecf20Sopenharmony_ci * slices in a full frame and we can schedule 36 of those (90%) for periodic 8108c2ecf20Sopenharmony_ci * transfers. 8118c2ecf20Sopenharmony_ci * 8128c2ecf20Sopenharmony_ci * Our low speed schedule can be as short as 1 frame or could be longer. When 8138c2ecf20Sopenharmony_ci * we only schedule 1 frame it means that we'll need to reserve a time every 8148c2ecf20Sopenharmony_ci * frame even for things that only transfer very rarely, so something that runs 8158c2ecf20Sopenharmony_ci * every 2048 frames will get time reserved in every frame. Our low speed 8168c2ecf20Sopenharmony_ci * schedule can be longer and we'll be able to handle more overlap, but that 8178c2ecf20Sopenharmony_ci * will come at increased memory cost and increased time to schedule. 8188c2ecf20Sopenharmony_ci * 8198c2ecf20Sopenharmony_ci * Note: one other advantage of a short low speed schedule is that if we mess 8208c2ecf20Sopenharmony_ci * up and miss scheduling we can jump in and use any of the slots that we 8218c2ecf20Sopenharmony_ci * happened to reserve. 8228c2ecf20Sopenharmony_ci * 8238c2ecf20Sopenharmony_ci * With 25 us per slice and 1 frame in the schedule, we only need 4 bytes for 8248c2ecf20Sopenharmony_ci * the schedule. There will be one schedule per TT. 8258c2ecf20Sopenharmony_ci * 8268c2ecf20Sopenharmony_ci * Requirements: 8278c2ecf20Sopenharmony_ci * - DWC2_US_PER_SLICE must evenly divide DWC2_LS_PERIODIC_US_PER_FRAME. 8288c2ecf20Sopenharmony_ci */ 8298c2ecf20Sopenharmony_ci#define DWC2_US_PER_SLICE 25 8308c2ecf20Sopenharmony_ci#define DWC2_SLICES_PER_UFRAME (DWC2_US_PER_UFRAME / DWC2_US_PER_SLICE) 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci#define DWC2_ROUND_US_TO_SLICE(us) \ 8338c2ecf20Sopenharmony_ci (DIV_ROUND_UP((us), DWC2_US_PER_SLICE) * \ 8348c2ecf20Sopenharmony_ci DWC2_US_PER_SLICE) 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci#define DWC2_LS_PERIODIC_US_PER_FRAME \ 8378c2ecf20Sopenharmony_ci 900 8388c2ecf20Sopenharmony_ci#define DWC2_LS_PERIODIC_SLICES_PER_FRAME \ 8398c2ecf20Sopenharmony_ci (DWC2_LS_PERIODIC_US_PER_FRAME / \ 8408c2ecf20Sopenharmony_ci DWC2_US_PER_SLICE) 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci#define DWC2_LS_SCHEDULE_FRAMES 1 8438c2ecf20Sopenharmony_ci#define DWC2_LS_SCHEDULE_SLICES (DWC2_LS_SCHEDULE_FRAMES * \ 8448c2ecf20Sopenharmony_ci DWC2_LS_PERIODIC_SLICES_PER_FRAME) 8458c2ecf20Sopenharmony_ci 8468c2ecf20Sopenharmony_ci/** 8478c2ecf20Sopenharmony_ci * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic 8488c2ecf20Sopenharmony_ci * and periodic schedules 8498c2ecf20Sopenharmony_ci * 8508c2ecf20Sopenharmony_ci * These are common for both host and peripheral modes: 8518c2ecf20Sopenharmony_ci * 8528c2ecf20Sopenharmony_ci * @dev: The struct device pointer 8538c2ecf20Sopenharmony_ci * @regs: Pointer to controller regs 8548c2ecf20Sopenharmony_ci * @hw_params: Parameters that were autodetected from the 8558c2ecf20Sopenharmony_ci * hardware registers 8568c2ecf20Sopenharmony_ci * @params: Parameters that define how the core should be configured 8578c2ecf20Sopenharmony_ci * @op_state: The operational State, during transitions (a_host=> 8588c2ecf20Sopenharmony_ci * a_peripheral and b_device=>b_host) this may not match 8598c2ecf20Sopenharmony_ci * the core, but allows the software to determine 8608c2ecf20Sopenharmony_ci * transitions 8618c2ecf20Sopenharmony_ci * @dr_mode: Requested mode of operation, one of following: 8628c2ecf20Sopenharmony_ci * - USB_DR_MODE_PERIPHERAL 8638c2ecf20Sopenharmony_ci * - USB_DR_MODE_HOST 8648c2ecf20Sopenharmony_ci * - USB_DR_MODE_OTG 8658c2ecf20Sopenharmony_ci * @role_sw: usb_role_switch handle 8668c2ecf20Sopenharmony_ci * @hcd_enabled: Host mode sub-driver initialization indicator. 8678c2ecf20Sopenharmony_ci * @gadget_enabled: Peripheral mode sub-driver initialization indicator. 8688c2ecf20Sopenharmony_ci * @ll_hw_enabled: Status of low-level hardware resources. 8698c2ecf20Sopenharmony_ci * @hibernated: True if core is hibernated 8708c2ecf20Sopenharmony_ci * @reset_phy_on_wake: Quirk saying that we should assert PHY reset on a 8718c2ecf20Sopenharmony_ci * remote wakeup. 8728c2ecf20Sopenharmony_ci * @phy_off_for_suspend: Status of whether we turned the PHY off at suspend. 8738c2ecf20Sopenharmony_ci * @need_phy_for_wake: Quirk saying that we should keep the PHY on at 8748c2ecf20Sopenharmony_ci * suspend if we need USB to wake us up. 8758c2ecf20Sopenharmony_ci * @frame_number: Frame number read from the core. For both device 8768c2ecf20Sopenharmony_ci * and host modes. The value ranges are from 0 8778c2ecf20Sopenharmony_ci * to HFNUM_MAX_FRNUM. 8788c2ecf20Sopenharmony_ci * @phy: The otg phy transceiver structure for phy control. 8798c2ecf20Sopenharmony_ci * @uphy: The otg phy transceiver structure for old USB phy 8808c2ecf20Sopenharmony_ci * control. 8818c2ecf20Sopenharmony_ci * @plat: The platform specific configuration data. This can be 8828c2ecf20Sopenharmony_ci * removed once all SoCs support usb transceiver. 8838c2ecf20Sopenharmony_ci * @supplies: Definition of USB power supplies 8848c2ecf20Sopenharmony_ci * @vbus_supply: Regulator supplying vbus. 8858c2ecf20Sopenharmony_ci * @usb33d: Optional 3.3v regulator used on some stm32 devices to 8868c2ecf20Sopenharmony_ci * supply ID and VBUS detection hardware. 8878c2ecf20Sopenharmony_ci * @lock: Spinlock that protects all the driver data structures 8888c2ecf20Sopenharmony_ci * @priv: Stores a pointer to the struct usb_hcd 8898c2ecf20Sopenharmony_ci * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth 8908c2ecf20Sopenharmony_ci * transfer are in process of being queued 8918c2ecf20Sopenharmony_ci * @srp_success: Stores status of SRP request in the case of a FS PHY 8928c2ecf20Sopenharmony_ci * with an I2C interface 8938c2ecf20Sopenharmony_ci * @wq_otg: Workqueue object used for handling of some interrupts 8948c2ecf20Sopenharmony_ci * @wf_otg: Work object for handling Connector ID Status Change 8958c2ecf20Sopenharmony_ci * interrupt 8968c2ecf20Sopenharmony_ci * @wkp_timer: Timer object for handling Wakeup Detected interrupt 8978c2ecf20Sopenharmony_ci * @lx_state: Lx state of connected device 8988c2ecf20Sopenharmony_ci * @gr_backup: Backup of global registers during suspend 8998c2ecf20Sopenharmony_ci * @dr_backup: Backup of device registers during suspend 9008c2ecf20Sopenharmony_ci * @hr_backup: Backup of host registers during suspend 9018c2ecf20Sopenharmony_ci * @needs_byte_swap: Specifies whether the opposite endianness. 9028c2ecf20Sopenharmony_ci * 9038c2ecf20Sopenharmony_ci * These are for host mode: 9048c2ecf20Sopenharmony_ci * 9058c2ecf20Sopenharmony_ci * @flags: Flags for handling root port state changes 9068c2ecf20Sopenharmony_ci * @flags.d32: Contain all root port flags 9078c2ecf20Sopenharmony_ci * @flags.b: Separate root port flags from each other 9088c2ecf20Sopenharmony_ci * @flags.b.port_connect_status_change: True if root port connect status 9098c2ecf20Sopenharmony_ci * changed 9108c2ecf20Sopenharmony_ci * @flags.b.port_connect_status: True if device connected to root port 9118c2ecf20Sopenharmony_ci * @flags.b.port_reset_change: True if root port reset status changed 9128c2ecf20Sopenharmony_ci * @flags.b.port_enable_change: True if root port enable status changed 9138c2ecf20Sopenharmony_ci * @flags.b.port_suspend_change: True if root port suspend status changed 9148c2ecf20Sopenharmony_ci * @flags.b.port_over_current_change: True if root port over current state 9158c2ecf20Sopenharmony_ci * changed. 9168c2ecf20Sopenharmony_ci * @flags.b.port_l1_change: True if root port l1 status changed 9178c2ecf20Sopenharmony_ci * @flags.b.reserved: Reserved bits of root port register 9188c2ecf20Sopenharmony_ci * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule. 9198c2ecf20Sopenharmony_ci * Transfers associated with these QHs are not currently 9208c2ecf20Sopenharmony_ci * assigned to a host channel. 9218c2ecf20Sopenharmony_ci * @non_periodic_sched_active: Active QHs in the non-periodic schedule. 9228c2ecf20Sopenharmony_ci * Transfers associated with these QHs are currently 9238c2ecf20Sopenharmony_ci * assigned to a host channel. 9248c2ecf20Sopenharmony_ci * @non_periodic_qh_ptr: Pointer to next QH to process in the active 9258c2ecf20Sopenharmony_ci * non-periodic schedule 9268c2ecf20Sopenharmony_ci * @non_periodic_sched_waiting: Waiting QHs in the non-periodic schedule. 9278c2ecf20Sopenharmony_ci * Transfers associated with these QHs are not currently 9288c2ecf20Sopenharmony_ci * assigned to a host channel. 9298c2ecf20Sopenharmony_ci * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a 9308c2ecf20Sopenharmony_ci * list of QHs for periodic transfers that are _not_ 9318c2ecf20Sopenharmony_ci * scheduled for the next frame. Each QH in the list has an 9328c2ecf20Sopenharmony_ci * interval counter that determines when it needs to be 9338c2ecf20Sopenharmony_ci * scheduled for execution. This scheduling mechanism 9348c2ecf20Sopenharmony_ci * allows only a simple calculation for periodic bandwidth 9358c2ecf20Sopenharmony_ci * used (i.e. must assume that all periodic transfers may 9368c2ecf20Sopenharmony_ci * need to execute in the same frame). However, it greatly 9378c2ecf20Sopenharmony_ci * simplifies scheduling and should be sufficient for the 9388c2ecf20Sopenharmony_ci * vast majority of OTG hosts, which need to connect to a 9398c2ecf20Sopenharmony_ci * small number of peripherals at one time. Items move from 9408c2ecf20Sopenharmony_ci * this list to periodic_sched_ready when the QH interval 9418c2ecf20Sopenharmony_ci * counter is 0 at SOF. 9428c2ecf20Sopenharmony_ci * @periodic_sched_ready: List of periodic QHs that are ready for execution in 9438c2ecf20Sopenharmony_ci * the next frame, but have not yet been assigned to host 9448c2ecf20Sopenharmony_ci * channels. Items move from this list to 9458c2ecf20Sopenharmony_ci * periodic_sched_assigned as host channels become 9468c2ecf20Sopenharmony_ci * available during the current frame. 9478c2ecf20Sopenharmony_ci * @periodic_sched_assigned: List of periodic QHs to be executed in the next 9488c2ecf20Sopenharmony_ci * frame that are assigned to host channels. Items move 9498c2ecf20Sopenharmony_ci * from this list to periodic_sched_queued as the 9508c2ecf20Sopenharmony_ci * transactions for the QH are queued to the DWC_otg 9518c2ecf20Sopenharmony_ci * controller. 9528c2ecf20Sopenharmony_ci * @periodic_sched_queued: List of periodic QHs that have been queued for 9538c2ecf20Sopenharmony_ci * execution. Items move from this list to either 9548c2ecf20Sopenharmony_ci * periodic_sched_inactive or periodic_sched_ready when the 9558c2ecf20Sopenharmony_ci * channel associated with the transfer is released. If the 9568c2ecf20Sopenharmony_ci * interval for the QH is 1, the item moves to 9578c2ecf20Sopenharmony_ci * periodic_sched_ready because it must be rescheduled for 9588c2ecf20Sopenharmony_ci * the next frame. Otherwise, the item moves to 9598c2ecf20Sopenharmony_ci * periodic_sched_inactive. 9608c2ecf20Sopenharmony_ci * @split_order: List keeping track of channels doing splits, in order. 9618c2ecf20Sopenharmony_ci * @periodic_usecs: Total bandwidth claimed so far for periodic transfers. 9628c2ecf20Sopenharmony_ci * This value is in microseconds per (micro)frame. The 9638c2ecf20Sopenharmony_ci * assumption is that all periodic transfers may occur in 9648c2ecf20Sopenharmony_ci * the same (micro)frame. 9658c2ecf20Sopenharmony_ci * @hs_periodic_bitmap: Bitmap used by the microframe scheduler any time the 9668c2ecf20Sopenharmony_ci * host is in high speed mode; low speed schedules are 9678c2ecf20Sopenharmony_ci * stored elsewhere since we need one per TT. 9688c2ecf20Sopenharmony_ci * @periodic_qh_count: Count of periodic QHs, if using several eps. Used for 9698c2ecf20Sopenharmony_ci * SOF enable/disable. 9708c2ecf20Sopenharmony_ci * @free_hc_list: Free host channels in the controller. This is a list of 9718c2ecf20Sopenharmony_ci * struct dwc2_host_chan items. 9728c2ecf20Sopenharmony_ci * @periodic_channels: Number of host channels assigned to periodic transfers. 9738c2ecf20Sopenharmony_ci * Currently assuming that there is a dedicated host 9748c2ecf20Sopenharmony_ci * channel for each periodic transaction and at least one 9758c2ecf20Sopenharmony_ci * host channel is available for non-periodic transactions. 9768c2ecf20Sopenharmony_ci * @non_periodic_channels: Number of host channels assigned to non-periodic 9778c2ecf20Sopenharmony_ci * transfers 9788c2ecf20Sopenharmony_ci * @available_host_channels: Number of host channels available for the 9798c2ecf20Sopenharmony_ci * microframe scheduler to use 9808c2ecf20Sopenharmony_ci * @hc_ptr_array: Array of pointers to the host channel descriptors. 9818c2ecf20Sopenharmony_ci * Allows accessing a host channel descriptor given the 9828c2ecf20Sopenharmony_ci * host channel number. This is useful in interrupt 9838c2ecf20Sopenharmony_ci * handlers. 9848c2ecf20Sopenharmony_ci * @status_buf: Buffer used for data received during the status phase of 9858c2ecf20Sopenharmony_ci * a control transfer. 9868c2ecf20Sopenharmony_ci * @status_buf_dma: DMA address for status_buf 9878c2ecf20Sopenharmony_ci * @start_work: Delayed work for handling host A-cable connection 9888c2ecf20Sopenharmony_ci * @reset_work: Delayed work for handling a port reset 9898c2ecf20Sopenharmony_ci * @phy_reset_work: Work structure for doing a PHY reset 9908c2ecf20Sopenharmony_ci * @otg_port: OTG port number 9918c2ecf20Sopenharmony_ci * @frame_list: Frame list 9928c2ecf20Sopenharmony_ci * @frame_list_dma: Frame list DMA address 9938c2ecf20Sopenharmony_ci * @frame_list_sz: Frame list size 9948c2ecf20Sopenharmony_ci * @desc_gen_cache: Kmem cache for generic descriptors 9958c2ecf20Sopenharmony_ci * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors 9968c2ecf20Sopenharmony_ci * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf 9978c2ecf20Sopenharmony_ci * 9988c2ecf20Sopenharmony_ci * These are for peripheral mode: 9998c2ecf20Sopenharmony_ci * 10008c2ecf20Sopenharmony_ci * @driver: USB gadget driver 10018c2ecf20Sopenharmony_ci * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. 10028c2ecf20Sopenharmony_ci * @num_of_eps: Number of available EPs (excluding EP0) 10038c2ecf20Sopenharmony_ci * @debug_root: Root directrory for debugfs. 10048c2ecf20Sopenharmony_ci * @ep0_reply: Request used for ep0 reply. 10058c2ecf20Sopenharmony_ci * @ep0_buff: Buffer for EP0 reply data, if needed. 10068c2ecf20Sopenharmony_ci * @ctrl_buff: Buffer for EP0 control requests. 10078c2ecf20Sopenharmony_ci * @ctrl_req: Request for EP0 control packets. 10088c2ecf20Sopenharmony_ci * @ep0_state: EP0 control transfers state 10098c2ecf20Sopenharmony_ci * @delayed_status: true when gadget driver asks for delayed status 10108c2ecf20Sopenharmony_ci * @test_mode: USB test mode requested by the host 10118c2ecf20Sopenharmony_ci * @remote_wakeup_allowed: True if device is allowed to wake-up host by 10128c2ecf20Sopenharmony_ci * remote-wakeup signalling 10138c2ecf20Sopenharmony_ci * @setup_desc_dma: EP0 setup stage desc chain DMA address 10148c2ecf20Sopenharmony_ci * @setup_desc: EP0 setup stage desc chain pointer 10158c2ecf20Sopenharmony_ci * @ctrl_in_desc_dma: EP0 IN data phase desc chain DMA address 10168c2ecf20Sopenharmony_ci * @ctrl_in_desc: EP0 IN data phase desc chain pointer 10178c2ecf20Sopenharmony_ci * @ctrl_out_desc_dma: EP0 OUT data phase desc chain DMA address 10188c2ecf20Sopenharmony_ci * @ctrl_out_desc: EP0 OUT data phase desc chain pointer 10198c2ecf20Sopenharmony_ci * @irq: Interrupt request line number 10208c2ecf20Sopenharmony_ci * @clk: Pointer to otg clock 10218c2ecf20Sopenharmony_ci * @reset: Pointer to dwc2 reset controller 10228c2ecf20Sopenharmony_ci * @reset_ecc: Pointer to dwc2 optional reset controller in Stratix10. 10238c2ecf20Sopenharmony_ci * @regset: A pointer to a struct debugfs_regset32, which contains 10248c2ecf20Sopenharmony_ci * a pointer to an array of register definitions, the 10258c2ecf20Sopenharmony_ci * array size and the base address where the register bank 10268c2ecf20Sopenharmony_ci * is to be found. 10278c2ecf20Sopenharmony_ci * @bus_suspended: True if bus is suspended 10288c2ecf20Sopenharmony_ci * @last_frame_num: Number of last frame. Range from 0 to 32768 10298c2ecf20Sopenharmony_ci * @frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is 10308c2ecf20Sopenharmony_ci * defined, for missed SOFs tracking. Array holds that 10318c2ecf20Sopenharmony_ci * frame numbers, which not equal to last_frame_num +1 10328c2ecf20Sopenharmony_ci * @last_frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is 10338c2ecf20Sopenharmony_ci * defined, for missed SOFs tracking. 10348c2ecf20Sopenharmony_ci * If current_frame_number != last_frame_num+1 10358c2ecf20Sopenharmony_ci * then last_frame_num added to this array 10368c2ecf20Sopenharmony_ci * @frame_num_idx: Actual size of frame_num_array and last_frame_num_array 10378c2ecf20Sopenharmony_ci * @dumped_frame_num_array: 1 - if missed SOFs frame numbers dumbed 10388c2ecf20Sopenharmony_ci * 0 - if missed SOFs frame numbers not dumbed 10398c2ecf20Sopenharmony_ci * @fifo_mem: Total internal RAM for FIFOs (bytes) 10408c2ecf20Sopenharmony_ci * @fifo_map: Each bit intend for concrete fifo. If that bit is set, 10418c2ecf20Sopenharmony_ci * then that fifo is used 10428c2ecf20Sopenharmony_ci * @gadget: Represents a usb gadget device 10438c2ecf20Sopenharmony_ci * @connected: Used in slave mode. True if device connected with host 10448c2ecf20Sopenharmony_ci * @eps_in: The IN endpoints being supplied to the gadget framework 10458c2ecf20Sopenharmony_ci * @eps_out: The OUT endpoints being supplied to the gadget framework 10468c2ecf20Sopenharmony_ci * @new_connection: Used in host mode. True if there are new connected 10478c2ecf20Sopenharmony_ci * device 10488c2ecf20Sopenharmony_ci * @enabled: Indicates the enabling state of controller 10498c2ecf20Sopenharmony_ci * 10508c2ecf20Sopenharmony_ci */ 10518c2ecf20Sopenharmony_cistruct dwc2_hsotg { 10528c2ecf20Sopenharmony_ci struct device *dev; 10538c2ecf20Sopenharmony_ci void __iomem *regs; 10548c2ecf20Sopenharmony_ci /** Params detected from hardware */ 10558c2ecf20Sopenharmony_ci struct dwc2_hw_params hw_params; 10568c2ecf20Sopenharmony_ci /** Params to actually use */ 10578c2ecf20Sopenharmony_ci struct dwc2_core_params params; 10588c2ecf20Sopenharmony_ci enum usb_otg_state op_state; 10598c2ecf20Sopenharmony_ci enum usb_dr_mode dr_mode; 10608c2ecf20Sopenharmony_ci struct usb_role_switch *role_sw; 10618c2ecf20Sopenharmony_ci unsigned int hcd_enabled:1; 10628c2ecf20Sopenharmony_ci unsigned int gadget_enabled:1; 10638c2ecf20Sopenharmony_ci unsigned int ll_hw_enabled:1; 10648c2ecf20Sopenharmony_ci unsigned int hibernated:1; 10658c2ecf20Sopenharmony_ci unsigned int reset_phy_on_wake:1; 10668c2ecf20Sopenharmony_ci unsigned int need_phy_for_wake:1; 10678c2ecf20Sopenharmony_ci unsigned int phy_off_for_suspend:1; 10688c2ecf20Sopenharmony_ci u16 frame_number; 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_ci struct phy *phy; 10718c2ecf20Sopenharmony_ci struct usb_phy *uphy; 10728c2ecf20Sopenharmony_ci struct dwc2_hsotg_plat *plat; 10738c2ecf20Sopenharmony_ci struct regulator_bulk_data supplies[DWC2_NUM_SUPPLIES]; 10748c2ecf20Sopenharmony_ci struct regulator *vbus_supply; 10758c2ecf20Sopenharmony_ci struct regulator *usb33d; 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_ci spinlock_t lock; 10788c2ecf20Sopenharmony_ci void *priv; 10798c2ecf20Sopenharmony_ci int irq; 10808c2ecf20Sopenharmony_ci struct clk *clk; 10818c2ecf20Sopenharmony_ci struct reset_control *reset; 10828c2ecf20Sopenharmony_ci struct reset_control *reset_ecc; 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci unsigned int queuing_high_bandwidth:1; 10858c2ecf20Sopenharmony_ci unsigned int srp_success:1; 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_ci struct workqueue_struct *wq_otg; 10888c2ecf20Sopenharmony_ci struct work_struct wf_otg; 10898c2ecf20Sopenharmony_ci struct timer_list wkp_timer; 10908c2ecf20Sopenharmony_ci enum dwc2_lx_state lx_state; 10918c2ecf20Sopenharmony_ci struct dwc2_gregs_backup gr_backup; 10928c2ecf20Sopenharmony_ci struct dwc2_dregs_backup dr_backup; 10938c2ecf20Sopenharmony_ci struct dwc2_hregs_backup hr_backup; 10948c2ecf20Sopenharmony_ci 10958c2ecf20Sopenharmony_ci struct dentry *debug_root; 10968c2ecf20Sopenharmony_ci struct debugfs_regset32 *regset; 10978c2ecf20Sopenharmony_ci bool needs_byte_swap; 10988c2ecf20Sopenharmony_ci 10998c2ecf20Sopenharmony_ci /* DWC OTG HW Release versions */ 11008c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_71a 0x4f54271a 11018c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_72a 0x4f54272a 11028c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_80a 0x4f54280a 11038c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_90a 0x4f54290a 11048c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_91a 0x4f54291a 11058c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_92a 0x4f54292a 11068c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_2_94a 0x4f54294a 11078c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_3_00a 0x4f54300a 11088c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_3_10a 0x4f54310a 11098c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_4_00a 0x4f54400a 11108c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_4_20a 0x4f54420a 11118c2ecf20Sopenharmony_ci#define DWC2_FS_IOT_REV_1_00a 0x5531100a 11128c2ecf20Sopenharmony_ci#define DWC2_HS_IOT_REV_1_00a 0x5532100a 11138c2ecf20Sopenharmony_ci#define DWC2_CORE_REV_MASK 0x0000ffff 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci /* DWC OTG HW Core ID */ 11168c2ecf20Sopenharmony_ci#define DWC2_OTG_ID 0x4f540000 11178c2ecf20Sopenharmony_ci#define DWC2_FS_IOT_ID 0x55310000 11188c2ecf20Sopenharmony_ci#define DWC2_HS_IOT_ID 0x55320000 11198c2ecf20Sopenharmony_ci 11208c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 11218c2ecf20Sopenharmony_ci union dwc2_hcd_internal_flags { 11228c2ecf20Sopenharmony_ci u32 d32; 11238c2ecf20Sopenharmony_ci struct { 11248c2ecf20Sopenharmony_ci unsigned port_connect_status_change:1; 11258c2ecf20Sopenharmony_ci unsigned port_connect_status:1; 11268c2ecf20Sopenharmony_ci unsigned port_reset_change:1; 11278c2ecf20Sopenharmony_ci unsigned port_enable_change:1; 11288c2ecf20Sopenharmony_ci unsigned port_suspend_change:1; 11298c2ecf20Sopenharmony_ci unsigned port_over_current_change:1; 11308c2ecf20Sopenharmony_ci unsigned port_l1_change:1; 11318c2ecf20Sopenharmony_ci unsigned reserved:25; 11328c2ecf20Sopenharmony_ci } b; 11338c2ecf20Sopenharmony_ci } flags; 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_ci struct list_head non_periodic_sched_inactive; 11368c2ecf20Sopenharmony_ci struct list_head non_periodic_sched_waiting; 11378c2ecf20Sopenharmony_ci struct list_head non_periodic_sched_active; 11388c2ecf20Sopenharmony_ci struct list_head *non_periodic_qh_ptr; 11398c2ecf20Sopenharmony_ci struct list_head periodic_sched_inactive; 11408c2ecf20Sopenharmony_ci struct list_head periodic_sched_ready; 11418c2ecf20Sopenharmony_ci struct list_head periodic_sched_assigned; 11428c2ecf20Sopenharmony_ci struct list_head periodic_sched_queued; 11438c2ecf20Sopenharmony_ci struct list_head split_order; 11448c2ecf20Sopenharmony_ci u16 periodic_usecs; 11458c2ecf20Sopenharmony_ci unsigned long hs_periodic_bitmap[ 11468c2ecf20Sopenharmony_ci DIV_ROUND_UP(DWC2_HS_SCHEDULE_US, BITS_PER_LONG)]; 11478c2ecf20Sopenharmony_ci u16 periodic_qh_count; 11488c2ecf20Sopenharmony_ci bool bus_suspended; 11498c2ecf20Sopenharmony_ci bool new_connection; 11508c2ecf20Sopenharmony_ci 11518c2ecf20Sopenharmony_ci u16 last_frame_num; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS 11548c2ecf20Sopenharmony_ci#define FRAME_NUM_ARRAY_SIZE 1000 11558c2ecf20Sopenharmony_ci u16 *frame_num_array; 11568c2ecf20Sopenharmony_ci u16 *last_frame_num_array; 11578c2ecf20Sopenharmony_ci int frame_num_idx; 11588c2ecf20Sopenharmony_ci int dumped_frame_num_array; 11598c2ecf20Sopenharmony_ci#endif 11608c2ecf20Sopenharmony_ci 11618c2ecf20Sopenharmony_ci struct list_head free_hc_list; 11628c2ecf20Sopenharmony_ci int periodic_channels; 11638c2ecf20Sopenharmony_ci int non_periodic_channels; 11648c2ecf20Sopenharmony_ci int available_host_channels; 11658c2ecf20Sopenharmony_ci struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS]; 11668c2ecf20Sopenharmony_ci u8 *status_buf; 11678c2ecf20Sopenharmony_ci dma_addr_t status_buf_dma; 11688c2ecf20Sopenharmony_ci#define DWC2_HCD_STATUS_BUF_SIZE 64 11698c2ecf20Sopenharmony_ci 11708c2ecf20Sopenharmony_ci struct delayed_work start_work; 11718c2ecf20Sopenharmony_ci struct delayed_work reset_work; 11728c2ecf20Sopenharmony_ci struct work_struct phy_reset_work; 11738c2ecf20Sopenharmony_ci u8 otg_port; 11748c2ecf20Sopenharmony_ci u32 *frame_list; 11758c2ecf20Sopenharmony_ci dma_addr_t frame_list_dma; 11768c2ecf20Sopenharmony_ci u32 frame_list_sz; 11778c2ecf20Sopenharmony_ci struct kmem_cache *desc_gen_cache; 11788c2ecf20Sopenharmony_ci struct kmem_cache *desc_hsisoc_cache; 11798c2ecf20Sopenharmony_ci struct kmem_cache *unaligned_cache; 11808c2ecf20Sopenharmony_ci#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */ 11838c2ecf20Sopenharmony_ci 11848c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 11858c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 11868c2ecf20Sopenharmony_ci /* Gadget structures */ 11878c2ecf20Sopenharmony_ci struct usb_gadget_driver *driver; 11888c2ecf20Sopenharmony_ci int fifo_mem; 11898c2ecf20Sopenharmony_ci unsigned int dedicated_fifos:1; 11908c2ecf20Sopenharmony_ci unsigned char num_of_eps; 11918c2ecf20Sopenharmony_ci u32 fifo_map; 11928c2ecf20Sopenharmony_ci 11938c2ecf20Sopenharmony_ci struct usb_request *ep0_reply; 11948c2ecf20Sopenharmony_ci struct usb_request *ctrl_req; 11958c2ecf20Sopenharmony_ci void *ep0_buff; 11968c2ecf20Sopenharmony_ci void *ctrl_buff; 11978c2ecf20Sopenharmony_ci enum dwc2_ep0_state ep0_state; 11988c2ecf20Sopenharmony_ci unsigned delayed_status : 1; 11998c2ecf20Sopenharmony_ci u8 test_mode; 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_ci dma_addr_t setup_desc_dma[2]; 12028c2ecf20Sopenharmony_ci struct dwc2_dma_desc *setup_desc[2]; 12038c2ecf20Sopenharmony_ci dma_addr_t ctrl_in_desc_dma; 12048c2ecf20Sopenharmony_ci struct dwc2_dma_desc *ctrl_in_desc; 12058c2ecf20Sopenharmony_ci dma_addr_t ctrl_out_desc_dma; 12068c2ecf20Sopenharmony_ci struct dwc2_dma_desc *ctrl_out_desc; 12078c2ecf20Sopenharmony_ci 12088c2ecf20Sopenharmony_ci struct usb_gadget gadget; 12098c2ecf20Sopenharmony_ci unsigned int enabled:1; 12108c2ecf20Sopenharmony_ci unsigned int connected:1; 12118c2ecf20Sopenharmony_ci unsigned int remote_wakeup_allowed:1; 12128c2ecf20Sopenharmony_ci struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS]; 12138c2ecf20Sopenharmony_ci struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS]; 12148c2ecf20Sopenharmony_ci#endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ 12158c2ecf20Sopenharmony_ci}; 12168c2ecf20Sopenharmony_ci 12178c2ecf20Sopenharmony_ci/* Normal architectures just use readl/write */ 12188c2ecf20Sopenharmony_cistatic inline u32 dwc2_readl(struct dwc2_hsotg *hsotg, u32 offset) 12198c2ecf20Sopenharmony_ci{ 12208c2ecf20Sopenharmony_ci u32 val; 12218c2ecf20Sopenharmony_ci 12228c2ecf20Sopenharmony_ci val = readl(hsotg->regs + offset); 12238c2ecf20Sopenharmony_ci if (hsotg->needs_byte_swap) 12248c2ecf20Sopenharmony_ci return swab32(val); 12258c2ecf20Sopenharmony_ci else 12268c2ecf20Sopenharmony_ci return val; 12278c2ecf20Sopenharmony_ci} 12288c2ecf20Sopenharmony_ci 12298c2ecf20Sopenharmony_cistatic inline void dwc2_writel(struct dwc2_hsotg *hsotg, u32 value, u32 offset) 12308c2ecf20Sopenharmony_ci{ 12318c2ecf20Sopenharmony_ci if (hsotg->needs_byte_swap) 12328c2ecf20Sopenharmony_ci writel(swab32(value), hsotg->regs + offset); 12338c2ecf20Sopenharmony_ci else 12348c2ecf20Sopenharmony_ci writel(value, hsotg->regs + offset); 12358c2ecf20Sopenharmony_ci 12368c2ecf20Sopenharmony_ci#ifdef DWC2_LOG_WRITES 12378c2ecf20Sopenharmony_ci pr_info("info:: wrote %08x to %p\n", value, hsotg->regs + offset); 12388c2ecf20Sopenharmony_ci#endif 12398c2ecf20Sopenharmony_ci} 12408c2ecf20Sopenharmony_ci 12418c2ecf20Sopenharmony_cistatic inline void dwc2_readl_rep(struct dwc2_hsotg *hsotg, u32 offset, 12428c2ecf20Sopenharmony_ci void *buffer, unsigned int count) 12438c2ecf20Sopenharmony_ci{ 12448c2ecf20Sopenharmony_ci if (count) { 12458c2ecf20Sopenharmony_ci u32 *buf = buffer; 12468c2ecf20Sopenharmony_ci 12478c2ecf20Sopenharmony_ci do { 12488c2ecf20Sopenharmony_ci u32 x = dwc2_readl(hsotg, offset); 12498c2ecf20Sopenharmony_ci *buf++ = x; 12508c2ecf20Sopenharmony_ci } while (--count); 12518c2ecf20Sopenharmony_ci } 12528c2ecf20Sopenharmony_ci} 12538c2ecf20Sopenharmony_ci 12548c2ecf20Sopenharmony_cistatic inline void dwc2_writel_rep(struct dwc2_hsotg *hsotg, u32 offset, 12558c2ecf20Sopenharmony_ci const void *buffer, unsigned int count) 12568c2ecf20Sopenharmony_ci{ 12578c2ecf20Sopenharmony_ci if (count) { 12588c2ecf20Sopenharmony_ci const u32 *buf = buffer; 12598c2ecf20Sopenharmony_ci 12608c2ecf20Sopenharmony_ci do { 12618c2ecf20Sopenharmony_ci dwc2_writel(hsotg, *buf++, offset); 12628c2ecf20Sopenharmony_ci } while (--count); 12638c2ecf20Sopenharmony_ci } 12648c2ecf20Sopenharmony_ci} 12658c2ecf20Sopenharmony_ci 12668c2ecf20Sopenharmony_ci/* Reasons for halting a host channel */ 12678c2ecf20Sopenharmony_cienum dwc2_halt_status { 12688c2ecf20Sopenharmony_ci DWC2_HC_XFER_NO_HALT_STATUS, 12698c2ecf20Sopenharmony_ci DWC2_HC_XFER_COMPLETE, 12708c2ecf20Sopenharmony_ci DWC2_HC_XFER_URB_COMPLETE, 12718c2ecf20Sopenharmony_ci DWC2_HC_XFER_ACK, 12728c2ecf20Sopenharmony_ci DWC2_HC_XFER_NAK, 12738c2ecf20Sopenharmony_ci DWC2_HC_XFER_NYET, 12748c2ecf20Sopenharmony_ci DWC2_HC_XFER_STALL, 12758c2ecf20Sopenharmony_ci DWC2_HC_XFER_XACT_ERR, 12768c2ecf20Sopenharmony_ci DWC2_HC_XFER_FRAME_OVERRUN, 12778c2ecf20Sopenharmony_ci DWC2_HC_XFER_BABBLE_ERR, 12788c2ecf20Sopenharmony_ci DWC2_HC_XFER_DATA_TOGGLE_ERR, 12798c2ecf20Sopenharmony_ci DWC2_HC_XFER_AHB_ERR, 12808c2ecf20Sopenharmony_ci DWC2_HC_XFER_PERIODIC_INCOMPLETE, 12818c2ecf20Sopenharmony_ci DWC2_HC_XFER_URB_DEQUEUE, 12828c2ecf20Sopenharmony_ci}; 12838c2ecf20Sopenharmony_ci 12848c2ecf20Sopenharmony_ci/* Core version information */ 12858c2ecf20Sopenharmony_cistatic inline bool dwc2_is_iot(struct dwc2_hsotg *hsotg) 12868c2ecf20Sopenharmony_ci{ 12878c2ecf20Sopenharmony_ci return (hsotg->hw_params.snpsid & 0xfff00000) == 0x55300000; 12888c2ecf20Sopenharmony_ci} 12898c2ecf20Sopenharmony_ci 12908c2ecf20Sopenharmony_cistatic inline bool dwc2_is_fs_iot(struct dwc2_hsotg *hsotg) 12918c2ecf20Sopenharmony_ci{ 12928c2ecf20Sopenharmony_ci return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55310000; 12938c2ecf20Sopenharmony_ci} 12948c2ecf20Sopenharmony_ci 12958c2ecf20Sopenharmony_cistatic inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg) 12968c2ecf20Sopenharmony_ci{ 12978c2ecf20Sopenharmony_ci return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55320000; 12988c2ecf20Sopenharmony_ci} 12998c2ecf20Sopenharmony_ci 13008c2ecf20Sopenharmony_ci/* 13018c2ecf20Sopenharmony_ci * The following functions support initialization of the core driver component 13028c2ecf20Sopenharmony_ci * and the DWC_otg controller 13038c2ecf20Sopenharmony_ci */ 13048c2ecf20Sopenharmony_ciint dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait); 13058c2ecf20Sopenharmony_ciint dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg); 13068c2ecf20Sopenharmony_ciint dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore); 13078c2ecf20Sopenharmony_ciint dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host); 13088c2ecf20Sopenharmony_ciint dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup, 13098c2ecf20Sopenharmony_ci int reset, int is_host); 13108c2ecf20Sopenharmony_civoid dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg); 13118c2ecf20Sopenharmony_ciint dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy); 13128c2ecf20Sopenharmony_ci 13138c2ecf20Sopenharmony_civoid dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host); 13148c2ecf20Sopenharmony_civoid dwc2_force_dr_mode(struct dwc2_hsotg *hsotg); 13158c2ecf20Sopenharmony_ci 13168c2ecf20Sopenharmony_cibool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg); 13178c2ecf20Sopenharmony_ci 13188c2ecf20Sopenharmony_ciint dwc2_check_core_version(struct dwc2_hsotg *hsotg); 13198c2ecf20Sopenharmony_ci 13208c2ecf20Sopenharmony_ci/* 13218c2ecf20Sopenharmony_ci * Common core Functions. 13228c2ecf20Sopenharmony_ci * The following functions support managing the DWC_otg controller in either 13238c2ecf20Sopenharmony_ci * device or host mode. 13248c2ecf20Sopenharmony_ci */ 13258c2ecf20Sopenharmony_civoid dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes); 13268c2ecf20Sopenharmony_civoid dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num); 13278c2ecf20Sopenharmony_civoid dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg); 13288c2ecf20Sopenharmony_ci 13298c2ecf20Sopenharmony_civoid dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd); 13308c2ecf20Sopenharmony_civoid dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd); 13318c2ecf20Sopenharmony_ci 13328c2ecf20Sopenharmony_civoid dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup, 13338c2ecf20Sopenharmony_ci int is_host); 13348c2ecf20Sopenharmony_ciint dwc2_backup_global_registers(struct dwc2_hsotg *hsotg); 13358c2ecf20Sopenharmony_ciint dwc2_restore_global_registers(struct dwc2_hsotg *hsotg); 13368c2ecf20Sopenharmony_ci 13378c2ecf20Sopenharmony_civoid dwc2_enable_acg(struct dwc2_hsotg *hsotg); 13388c2ecf20Sopenharmony_ci 13398c2ecf20Sopenharmony_ci/* This function should be called on every hardware interrupt. */ 13408c2ecf20Sopenharmony_ciirqreturn_t dwc2_handle_common_intr(int irq, void *dev); 13418c2ecf20Sopenharmony_ci 13428c2ecf20Sopenharmony_ci/* The device ID match table */ 13438c2ecf20Sopenharmony_ciextern const struct of_device_id dwc2_of_match_table[]; 13448c2ecf20Sopenharmony_ci 13458c2ecf20Sopenharmony_ciint dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg); 13468c2ecf20Sopenharmony_ciint dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg); 13478c2ecf20Sopenharmony_ci 13488c2ecf20Sopenharmony_ci/* Common polling functions */ 13498c2ecf20Sopenharmony_ciint dwc2_hsotg_wait_bit_set(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit, 13508c2ecf20Sopenharmony_ci u32 timeout); 13518c2ecf20Sopenharmony_ciint dwc2_hsotg_wait_bit_clear(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit, 13528c2ecf20Sopenharmony_ci u32 timeout); 13538c2ecf20Sopenharmony_ci/* Parameters */ 13548c2ecf20Sopenharmony_ciint dwc2_get_hwparams(struct dwc2_hsotg *hsotg); 13558c2ecf20Sopenharmony_ciint dwc2_init_params(struct dwc2_hsotg *hsotg); 13568c2ecf20Sopenharmony_ci 13578c2ecf20Sopenharmony_ci/* 13588c2ecf20Sopenharmony_ci * The following functions check the controller's OTG operation mode 13598c2ecf20Sopenharmony_ci * capability (GHWCFG2.OTG_MODE). 13608c2ecf20Sopenharmony_ci * 13618c2ecf20Sopenharmony_ci * These functions can be used before the internal hsotg->hw_params 13628c2ecf20Sopenharmony_ci * are read in and cached so they always read directly from the 13638c2ecf20Sopenharmony_ci * GHWCFG2 register. 13648c2ecf20Sopenharmony_ci */ 13658c2ecf20Sopenharmony_ciunsigned int dwc2_op_mode(struct dwc2_hsotg *hsotg); 13668c2ecf20Sopenharmony_cibool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg); 13678c2ecf20Sopenharmony_cibool dwc2_hw_is_host(struct dwc2_hsotg *hsotg); 13688c2ecf20Sopenharmony_cibool dwc2_hw_is_device(struct dwc2_hsotg *hsotg); 13698c2ecf20Sopenharmony_ci 13708c2ecf20Sopenharmony_ci/* 13718c2ecf20Sopenharmony_ci * Returns the mode of operation, host or device 13728c2ecf20Sopenharmony_ci */ 13738c2ecf20Sopenharmony_cistatic inline int dwc2_is_host_mode(struct dwc2_hsotg *hsotg) 13748c2ecf20Sopenharmony_ci{ 13758c2ecf20Sopenharmony_ci return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) != 0; 13768c2ecf20Sopenharmony_ci} 13778c2ecf20Sopenharmony_ci 13788c2ecf20Sopenharmony_cistatic inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg) 13798c2ecf20Sopenharmony_ci{ 13808c2ecf20Sopenharmony_ci return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0; 13818c2ecf20Sopenharmony_ci} 13828c2ecf20Sopenharmony_ci 13838c2ecf20Sopenharmony_ciint dwc2_drd_init(struct dwc2_hsotg *hsotg); 13848c2ecf20Sopenharmony_civoid dwc2_drd_suspend(struct dwc2_hsotg *hsotg); 13858c2ecf20Sopenharmony_civoid dwc2_drd_resume(struct dwc2_hsotg *hsotg); 13868c2ecf20Sopenharmony_civoid dwc2_drd_exit(struct dwc2_hsotg *hsotg); 13878c2ecf20Sopenharmony_ci 13888c2ecf20Sopenharmony_ci/* 13898c2ecf20Sopenharmony_ci * Dump core registers and SPRAM 13908c2ecf20Sopenharmony_ci */ 13918c2ecf20Sopenharmony_civoid dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg); 13928c2ecf20Sopenharmony_civoid dwc2_dump_host_registers(struct dwc2_hsotg *hsotg); 13938c2ecf20Sopenharmony_civoid dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); 13948c2ecf20Sopenharmony_ci 13958c2ecf20Sopenharmony_ci/* Gadget defines */ 13968c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 13978c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 13988c2ecf20Sopenharmony_ciint dwc2_hsotg_remove(struct dwc2_hsotg *hsotg); 13998c2ecf20Sopenharmony_ciint dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2); 14008c2ecf20Sopenharmony_ciint dwc2_hsotg_resume(struct dwc2_hsotg *dwc2); 14018c2ecf20Sopenharmony_ciint dwc2_gadget_init(struct dwc2_hsotg *hsotg); 14028c2ecf20Sopenharmony_civoid dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, 14038c2ecf20Sopenharmony_ci bool reset); 14048c2ecf20Sopenharmony_civoid dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg); 14058c2ecf20Sopenharmony_civoid dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg); 14068c2ecf20Sopenharmony_civoid dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2); 14078c2ecf20Sopenharmony_ciint dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode); 14088c2ecf20Sopenharmony_ci#define dwc2_is_device_connected(hsotg) (hsotg->connected) 14098c2ecf20Sopenharmony_ci#define dwc2_is_device_enabled(hsotg) (hsotg->enabled) 14108c2ecf20Sopenharmony_ciint dwc2_backup_device_registers(struct dwc2_hsotg *hsotg); 14118c2ecf20Sopenharmony_ciint dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup); 14128c2ecf20Sopenharmony_ciint dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg); 14138c2ecf20Sopenharmony_ciint dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, 14148c2ecf20Sopenharmony_ci int rem_wakeup, int reset); 14158c2ecf20Sopenharmony_ciint dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg); 14168c2ecf20Sopenharmony_ciint dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg); 14178c2ecf20Sopenharmony_ciint dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg); 14188c2ecf20Sopenharmony_civoid dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg); 14198c2ecf20Sopenharmony_civoid dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg); 14208c2ecf20Sopenharmony_ci#else 14218c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2) 14228c2ecf20Sopenharmony_ci{ return 0; } 14238c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2) 14248c2ecf20Sopenharmony_ci{ return 0; } 14258c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2) 14268c2ecf20Sopenharmony_ci{ return 0; } 14278c2ecf20Sopenharmony_cistatic inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg) 14288c2ecf20Sopenharmony_ci{ return 0; } 14298c2ecf20Sopenharmony_cistatic inline void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, 14308c2ecf20Sopenharmony_ci bool reset) {} 14318c2ecf20Sopenharmony_cistatic inline void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) {} 14328c2ecf20Sopenharmony_cistatic inline void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) {} 14338c2ecf20Sopenharmony_cistatic inline void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2) {} 14348c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, 14358c2ecf20Sopenharmony_ci int testmode) 14368c2ecf20Sopenharmony_ci{ return 0; } 14378c2ecf20Sopenharmony_ci#define dwc2_is_device_connected(hsotg) (0) 14388c2ecf20Sopenharmony_ci#define dwc2_is_device_enabled(hsotg) (0) 14398c2ecf20Sopenharmony_cistatic inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) 14408c2ecf20Sopenharmony_ci{ return 0; } 14418c2ecf20Sopenharmony_cistatic inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, 14428c2ecf20Sopenharmony_ci int remote_wakeup) 14438c2ecf20Sopenharmony_ci{ return 0; } 14448c2ecf20Sopenharmony_cistatic inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg) 14458c2ecf20Sopenharmony_ci{ return 0; } 14468c2ecf20Sopenharmony_cistatic inline int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, 14478c2ecf20Sopenharmony_ci int rem_wakeup, int reset) 14488c2ecf20Sopenharmony_ci{ return 0; } 14498c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) 14508c2ecf20Sopenharmony_ci{ return 0; } 14518c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) 14528c2ecf20Sopenharmony_ci{ return 0; } 14538c2ecf20Sopenharmony_cistatic inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) 14548c2ecf20Sopenharmony_ci{ return 0; } 14558c2ecf20Sopenharmony_cistatic inline void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) {} 14568c2ecf20Sopenharmony_cistatic inline void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) {} 14578c2ecf20Sopenharmony_ci#endif 14588c2ecf20Sopenharmony_ci 14598c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 14608c2ecf20Sopenharmony_ciint dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg); 14618c2ecf20Sopenharmony_ciint dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, int us); 14628c2ecf20Sopenharmony_civoid dwc2_hcd_connect(struct dwc2_hsotg *hsotg); 14638c2ecf20Sopenharmony_civoid dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force); 14648c2ecf20Sopenharmony_civoid dwc2_hcd_start(struct dwc2_hsotg *hsotg); 14658c2ecf20Sopenharmony_ciint dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup); 14668c2ecf20Sopenharmony_ciint dwc2_backup_host_registers(struct dwc2_hsotg *hsotg); 14678c2ecf20Sopenharmony_ciint dwc2_restore_host_registers(struct dwc2_hsotg *hsotg); 14688c2ecf20Sopenharmony_ciint dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg); 14698c2ecf20Sopenharmony_ciint dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 14708c2ecf20Sopenharmony_ci int rem_wakeup, int reset); 14718c2ecf20Sopenharmony_cibool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2); 14728c2ecf20Sopenharmony_cistatic inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) 14738c2ecf20Sopenharmony_ci{ schedule_work(&hsotg->phy_reset_work); } 14748c2ecf20Sopenharmony_ci#else 14758c2ecf20Sopenharmony_cistatic inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) 14768c2ecf20Sopenharmony_ci{ return 0; } 14778c2ecf20Sopenharmony_cistatic inline int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, 14788c2ecf20Sopenharmony_ci int us) 14798c2ecf20Sopenharmony_ci{ return 0; } 14808c2ecf20Sopenharmony_cistatic inline void dwc2_hcd_connect(struct dwc2_hsotg *hsotg) {} 14818c2ecf20Sopenharmony_cistatic inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {} 14828c2ecf20Sopenharmony_cistatic inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} 14838c2ecf20Sopenharmony_cistatic inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} 14848c2ecf20Sopenharmony_cistatic inline int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup) 14858c2ecf20Sopenharmony_ci{ return 0; } 14868c2ecf20Sopenharmony_cistatic inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg) 14878c2ecf20Sopenharmony_ci{ return 0; } 14888c2ecf20Sopenharmony_cistatic inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) 14898c2ecf20Sopenharmony_ci{ return 0; } 14908c2ecf20Sopenharmony_cistatic inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg) 14918c2ecf20Sopenharmony_ci{ return 0; } 14928c2ecf20Sopenharmony_cistatic inline int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg) 14938c2ecf20Sopenharmony_ci{ return 0; } 14948c2ecf20Sopenharmony_cistatic inline int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, 14958c2ecf20Sopenharmony_ci int rem_wakeup, int reset) 14968c2ecf20Sopenharmony_ci{ return 0; } 14978c2ecf20Sopenharmony_cistatic inline bool dwc2_host_can_poweroff_phy(struct dwc2_hsotg *dwc2) 14988c2ecf20Sopenharmony_ci{ return false; } 14998c2ecf20Sopenharmony_cistatic inline void dwc2_host_schedule_phy_reset(struct dwc2_hsotg *hsotg) {} 15008c2ecf20Sopenharmony_ci 15018c2ecf20Sopenharmony_ci#endif 15028c2ecf20Sopenharmony_ci 15038c2ecf20Sopenharmony_ci#endif /* __DWC2_CORE_H__ */ 1504