core.h 40 KB

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