core.h 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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. struct phy *phy;
  574. struct usb_phy *uphy;
  575. struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
  576. spinlock_t lock;
  577. struct mutex init_mutex;
  578. void *priv;
  579. int irq;
  580. struct clk *clk;
  581. unsigned int queuing_high_bandwidth:1;
  582. unsigned int srp_success:1;
  583. struct workqueue_struct *wq_otg;
  584. struct work_struct wf_otg;
  585. struct timer_list wkp_timer;
  586. enum dwc2_lx_state lx_state;
  587. struct dentry *debug_root;
  588. struct dentry *debug_file;
  589. struct dentry *debug_testmode;
  590. struct dentry *debug_fifo;
  591. /* DWC OTG HW Release versions */
  592. #define DWC2_CORE_REV_2_71a 0x4f54271a
  593. #define DWC2_CORE_REV_2_90a 0x4f54290a
  594. #define DWC2_CORE_REV_2_92a 0x4f54292a
  595. #define DWC2_CORE_REV_2_94a 0x4f54294a
  596. #define DWC2_CORE_REV_3_00a 0x4f54300a
  597. #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  598. union dwc2_hcd_internal_flags {
  599. u32 d32;
  600. struct {
  601. unsigned port_connect_status_change:1;
  602. unsigned port_connect_status:1;
  603. unsigned port_reset_change:1;
  604. unsigned port_enable_change:1;
  605. unsigned port_suspend_change:1;
  606. unsigned port_over_current_change:1;
  607. unsigned port_l1_change:1;
  608. unsigned reserved:25;
  609. } b;
  610. } flags;
  611. struct list_head non_periodic_sched_inactive;
  612. struct list_head non_periodic_sched_active;
  613. struct list_head *non_periodic_qh_ptr;
  614. struct list_head periodic_sched_inactive;
  615. struct list_head periodic_sched_ready;
  616. struct list_head periodic_sched_assigned;
  617. struct list_head periodic_sched_queued;
  618. u16 periodic_usecs;
  619. u16 frame_usecs[8];
  620. u16 frame_number;
  621. u16 periodic_qh_count;
  622. #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
  623. #define FRAME_NUM_ARRAY_SIZE 1000
  624. u16 last_frame_num;
  625. u16 *frame_num_array;
  626. u16 *last_frame_num_array;
  627. int frame_num_idx;
  628. int dumped_frame_num_array;
  629. #endif
  630. struct list_head free_hc_list;
  631. int periodic_channels;
  632. int non_periodic_channels;
  633. int available_host_channels;
  634. struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS];
  635. u8 *status_buf;
  636. dma_addr_t status_buf_dma;
  637. #define DWC2_HCD_STATUS_BUF_SIZE 64
  638. struct delayed_work start_work;
  639. struct delayed_work reset_work;
  640. u8 otg_port;
  641. u32 *frame_list;
  642. dma_addr_t frame_list_dma;
  643. #ifdef DEBUG
  644. u32 frrem_samples;
  645. u64 frrem_accum;
  646. u32 hfnum_7_samples_a;
  647. u64 hfnum_7_frrem_accum_a;
  648. u32 hfnum_0_samples_a;
  649. u64 hfnum_0_frrem_accum_a;
  650. u32 hfnum_other_samples_a;
  651. u64 hfnum_other_frrem_accum_a;
  652. u32 hfnum_7_samples_b;
  653. u64 hfnum_7_frrem_accum_b;
  654. u32 hfnum_0_samples_b;
  655. u64 hfnum_0_frrem_accum_b;
  656. u32 hfnum_other_samples_b;
  657. u64 hfnum_other_frrem_accum_b;
  658. #endif
  659. #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
  660. #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  661. /* Gadget structures */
  662. struct usb_gadget_driver *driver;
  663. struct s3c_hsotg_plat *plat;
  664. u32 phyif;
  665. int fifo_mem;
  666. unsigned int dedicated_fifos:1;
  667. unsigned char num_of_eps;
  668. u32 fifo_map;
  669. struct usb_request *ep0_reply;
  670. struct usb_request *ctrl_req;
  671. void *ep0_buff;
  672. void *ctrl_buff;
  673. enum dwc2_ep0_state ep0_state;
  674. u8 test_mode;
  675. struct usb_gadget gadget;
  676. unsigned int enabled:1;
  677. unsigned int connected:1;
  678. unsigned long last_rst;
  679. struct s3c_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
  680. struct s3c_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
  681. u32 g_using_dma;
  682. u32 g_rx_fifo_sz;
  683. u32 g_np_g_tx_fifo_sz;
  684. u32 g_tx_fifo_sz[MAX_EPS_CHANNELS];
  685. #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
  686. };
  687. /* Reasons for halting a host channel */
  688. enum dwc2_halt_status {
  689. DWC2_HC_XFER_NO_HALT_STATUS,
  690. DWC2_HC_XFER_COMPLETE,
  691. DWC2_HC_XFER_URB_COMPLETE,
  692. DWC2_HC_XFER_ACK,
  693. DWC2_HC_XFER_NAK,
  694. DWC2_HC_XFER_NYET,
  695. DWC2_HC_XFER_STALL,
  696. DWC2_HC_XFER_XACT_ERR,
  697. DWC2_HC_XFER_FRAME_OVERRUN,
  698. DWC2_HC_XFER_BABBLE_ERR,
  699. DWC2_HC_XFER_DATA_TOGGLE_ERR,
  700. DWC2_HC_XFER_AHB_ERR,
  701. DWC2_HC_XFER_PERIODIC_INCOMPLETE,
  702. DWC2_HC_XFER_URB_DEQUEUE,
  703. };
  704. /*
  705. * The following functions support initialization of the core driver component
  706. * and the DWC_otg controller
  707. */
  708. extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
  709. /*
  710. * Host core Functions.
  711. * The following functions support managing the DWC_otg controller in host
  712. * mode.
  713. */
  714. extern void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan);
  715. extern void dwc2_hc_halt(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan,
  716. enum dwc2_halt_status halt_status);
  717. extern void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg,
  718. struct dwc2_host_chan *chan);
  719. extern void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
  720. struct dwc2_host_chan *chan);
  721. extern void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg,
  722. struct dwc2_host_chan *chan);
  723. extern int dwc2_hc_continue_transfer(struct dwc2_hsotg *hsotg,
  724. struct dwc2_host_chan *chan);
  725. extern void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg,
  726. struct dwc2_host_chan *chan);
  727. extern void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg);
  728. extern void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg);
  729. extern u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg);
  730. extern bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg);
  731. /*
  732. * Common core Functions.
  733. * The following functions support managing the DWC_otg controller in either
  734. * device or host mode.
  735. */
  736. extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes);
  737. extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
  738. extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
  739. extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
  740. extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
  741. extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
  742. /* This function should be called on every hardware interrupt. */
  743. extern irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
  744. /* OTG Core Parameters */
  745. /*
  746. * Specifies the OTG capabilities. The driver will automatically
  747. * detect the value for this parameter if none is specified.
  748. * 0 - HNP and SRP capable (default)
  749. * 1 - SRP Only capable
  750. * 2 - No HNP/SRP capable
  751. */
  752. extern void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val);
  753. #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0
  754. #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE 1
  755. #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2
  756. /*
  757. * Specifies whether to use slave or DMA mode for accessing the data
  758. * FIFOs. The driver will automatically detect the value for this
  759. * parameter if none is specified.
  760. * 0 - Slave
  761. * 1 - DMA (default, if available)
  762. */
  763. extern void dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val);
  764. /*
  765. * When DMA mode is enabled specifies whether to use
  766. * address DMA or DMA Descritor mode for accessing the data
  767. * FIFOs in device mode. The driver will automatically detect
  768. * the value for this parameter if none is specified.
  769. * 0 - address DMA
  770. * 1 - DMA Descriptor(default, if available)
  771. */
  772. extern void dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val);
  773. /*
  774. * Specifies the maximum speed of operation in host and device mode.
  775. * The actual speed depends on the speed of the attached device and
  776. * the value of phy_type. The actual speed depends on the speed of the
  777. * attached device.
  778. * 0 - High Speed (default)
  779. * 1 - Full Speed
  780. */
  781. extern void dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int val);
  782. #define DWC2_SPEED_PARAM_HIGH 0
  783. #define DWC2_SPEED_PARAM_FULL 1
  784. /*
  785. * Specifies whether low power mode is supported when attached
  786. * to a Full Speed or Low Speed device in host mode.
  787. *
  788. * 0 - Don't support low power mode (default)
  789. * 1 - Support low power mode
  790. */
  791. extern void dwc2_set_param_host_support_fs_ls_low_power(
  792. struct dwc2_hsotg *hsotg, int val);
  793. /*
  794. * Specifies the PHY clock rate in low power mode when connected to a
  795. * Low Speed device in host mode. This parameter is applicable only if
  796. * HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
  797. * then defaults to 6 MHZ otherwise 48 MHZ.
  798. *
  799. * 0 - 48 MHz
  800. * 1 - 6 MHz
  801. */
  802. extern void dwc2_set_param_host_ls_low_power_phy_clk(struct dwc2_hsotg *hsotg,
  803. int val);
  804. #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0
  805. #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1
  806. /*
  807. * 0 - Use cC FIFO size parameters
  808. * 1 - Allow dynamic FIFO sizing (default)
  809. */
  810. extern void dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg,
  811. int val);
  812. /*
  813. * Number of 4-byte words in the Rx FIFO in host mode when dynamic
  814. * FIFO sizing is enabled.
  815. * 16 to 32768 (default 1024)
  816. */
  817. extern void dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val);
  818. /*
  819. * Number of 4-byte words in the non-periodic Tx FIFO in host mode
  820. * when Dynamic FIFO sizing is enabled in the core.
  821. * 16 to 32768 (default 256)
  822. */
  823. extern void dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg,
  824. int val);
  825. /*
  826. * Number of 4-byte words in the host periodic Tx FIFO when dynamic
  827. * FIFO sizing is enabled.
  828. * 16 to 32768 (default 256)
  829. */
  830. extern void dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg,
  831. int val);
  832. /*
  833. * The maximum transfer size supported in bytes.
  834. * 2047 to 65,535 (default 65,535)
  835. */
  836. extern void dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val);
  837. /*
  838. * The maximum number of packets in a transfer.
  839. * 15 to 511 (default 511)
  840. */
  841. extern void dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val);
  842. /*
  843. * The number of host channel registers to use.
  844. * 1 to 16 (default 11)
  845. * Note: The FPGA configuration supports a maximum of 11 host channels.
  846. */
  847. extern void dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val);
  848. /*
  849. * Specifies the type of PHY interface to use. By default, the driver
  850. * will automatically detect the phy_type.
  851. *
  852. * 0 - Full Speed PHY
  853. * 1 - UTMI+ (default)
  854. * 2 - ULPI
  855. */
  856. extern void dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val);
  857. #define DWC2_PHY_TYPE_PARAM_FS 0
  858. #define DWC2_PHY_TYPE_PARAM_UTMI 1
  859. #define DWC2_PHY_TYPE_PARAM_ULPI 2
  860. /*
  861. * Specifies the UTMI+ Data Width. This parameter is
  862. * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
  863. * PHY_TYPE, this parameter indicates the data width between
  864. * the MAC and the ULPI Wrapper.) Also, this parameter is
  865. * applicable only if the OTG_HSPHY_WIDTH cC parameter was set
  866. * to "8 and 16 bits", meaning that the core has been
  867. * configured to work at either data path width.
  868. *
  869. * 8 or 16 bits (default 16)
  870. */
  871. extern void dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val);
  872. /*
  873. * Specifies whether the ULPI operates at double or single
  874. * data rate. This parameter is only applicable if PHY_TYPE is
  875. * ULPI.
  876. *
  877. * 0 - single data rate ULPI interface with 8 bit wide data
  878. * bus (default)
  879. * 1 - double data rate ULPI interface with 4 bit wide data
  880. * bus
  881. */
  882. extern void dwc2_set_param_phy_ulpi_ddr(struct dwc2_hsotg *hsotg, int val);
  883. /*
  884. * Specifies whether to use the internal or external supply to
  885. * drive the vbus with a ULPI phy.
  886. */
  887. extern void dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val);
  888. #define DWC2_PHY_ULPI_INTERNAL_VBUS 0
  889. #define DWC2_PHY_ULPI_EXTERNAL_VBUS 1
  890. /*
  891. * Specifies whether to use the I2Cinterface for full speed PHY. This
  892. * parameter is only applicable if PHY_TYPE is FS.
  893. * 0 - No (default)
  894. * 1 - Yes
  895. */
  896. extern void dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val);
  897. extern void dwc2_set_param_ulpi_fs_ls(struct dwc2_hsotg *hsotg, int val);
  898. extern void dwc2_set_param_ts_dline(struct dwc2_hsotg *hsotg, int val);
  899. /*
  900. * Specifies whether dedicated transmit FIFOs are
  901. * enabled for non periodic IN endpoints in device mode
  902. * 0 - No
  903. * 1 - Yes
  904. */
  905. extern void dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg,
  906. int val);
  907. extern void dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val);
  908. extern void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val);
  909. extern void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
  910. /*
  911. * Dump core registers and SPRAM
  912. */
  913. extern void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg);
  914. extern void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg);
  915. extern void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg);
  916. /*
  917. * Return OTG version - either 1.3 or 2.0
  918. */
  919. extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
  920. /* Gadget defines */
  921. #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  922. extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
  923. extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
  924. extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
  925. extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
  926. extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
  927. bool reset);
  928. extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
  929. extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
  930. #else
  931. static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
  932. { return 0; }
  933. static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
  934. { return 0; }
  935. static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
  936. { return 0; }
  937. static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
  938. { return 0; }
  939. static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
  940. bool reset) {}
  941. static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
  942. static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
  943. #endif
  944. #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  945. extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
  946. extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
  947. extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
  948. #else
  949. static inline void dwc2_set_all_params(struct dwc2_core_params *params, int value) {}
  950. static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
  951. { return 0; }
  952. static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
  953. static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
  954. static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
  955. static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
  956. const struct dwc2_core_params *params)
  957. { return 0; }
  958. #endif
  959. #endif /* __DWC2_CORE_H__ */