core.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  1. // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
  2. /*
  3. * core.h - DesignWare HS OTG Controller common declarations
  4. *
  5. * Copyright (C) 2004-2013 Synopsys, Inc.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions, and the following disclaimer,
  12. * without modification.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. The names of the above-listed copyright holders may not be used
  17. * to endorse or promote products derived from this software without
  18. * specific prior written permission.
  19. *
  20. * ALTERNATIVELY, this software may be distributed under the terms of the
  21. * GNU General Public License ("GPL") as published by the Free Software
  22. * Foundation; either version 2 of the License, or (at your option) any
  23. * later version.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  26. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  27. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  29. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  30. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  33. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  34. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  35. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #ifndef __DWC2_CORE_H__
  38. #define __DWC2_CORE_H__
  39. #include <linux/phy/phy.h>
  40. #include <linux/regulator/consumer.h>
  41. #include <linux/usb/gadget.h>
  42. #include <linux/usb/otg.h>
  43. #include <linux/usb/phy.h>
  44. #include "hw.h"
  45. /*
  46. * Suggested defines for tracers:
  47. * - no_printk: Disable tracing
  48. * - pr_info: Print this info to the console
  49. * - trace_printk: Print this info to trace buffer (good for verbose logging)
  50. */
  51. #define DWC2_TRACE_SCHEDULER no_printk
  52. #define DWC2_TRACE_SCHEDULER_VB no_printk
  53. /* Detailed scheduler tracing, but won't overwhelm console */
  54. #define dwc2_sch_dbg(hsotg, fmt, ...) \
  55. DWC2_TRACE_SCHEDULER(pr_fmt("%s: SCH: " fmt), \
  56. dev_name(hsotg->dev), ##__VA_ARGS__)
  57. /* Verbose scheduler tracing */
  58. #define dwc2_sch_vdbg(hsotg, fmt, ...) \
  59. DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \
  60. dev_name(hsotg->dev), ##__VA_ARGS__)
  61. /* Maximum number of Endpoints/HostChannels */
  62. #define MAX_EPS_CHANNELS 16
  63. /* dwc2-hsotg declarations */
  64. static const char * const dwc2_hsotg_supply_names[] = {
  65. "vusb_d", /* digital USB supply, 1.2V */
  66. "vusb_a", /* analog USB supply, 1.1V */
  67. };
  68. #define DWC2_NUM_SUPPLIES ARRAY_SIZE(dwc2_hsotg_supply_names)
  69. /*
  70. * EP0_MPS_LIMIT
  71. *
  72. * Unfortunately there seems to be a limit of the amount of data that can
  73. * be transferred by IN transactions on EP0. This is either 127 bytes or 3
  74. * packets (which practically means 1 packet and 63 bytes of data) when the
  75. * MPS is set to 64.
  76. *
  77. * This means if we are wanting to move >127 bytes of data, we need to
  78. * split the transactions up, but just doing one packet at a time does
  79. * not work (this may be an implicit DATA0 PID on first packet of the
  80. * transaction) and doing 2 packets is outside the controller's limits.
  81. *
  82. * If we try to lower the MPS size for EP0, then no transfers work properly
  83. * for EP0, and the system will fail basic enumeration. As no cause for this
  84. * has currently been found, we cannot support any large IN transfers for
  85. * EP0.
  86. */
  87. #define EP0_MPS_LIMIT 64
  88. struct dwc2_hsotg;
  89. struct dwc2_hsotg_req;
  90. /**
  91. * struct dwc2_hsotg_ep - driver endpoint definition.
  92. * @ep: The gadget layer representation of the endpoint.
  93. * @name: The driver generated name for the endpoint.
  94. * @queue: Queue of requests for this endpoint.
  95. * @parent: Reference back to the parent device structure.
  96. * @req: The current request that the endpoint is processing. This is
  97. * used to indicate an request has been loaded onto the endpoint
  98. * and has yet to be completed (maybe due to data move, or simply
  99. * awaiting an ack from the core all the data has been completed).
  100. * @debugfs: File entry for debugfs file for this endpoint.
  101. * @dir_in: Set to true if this endpoint is of the IN direction, which
  102. * means that it is sending data to the Host.
  103. * @index: The index for the endpoint registers.
  104. * @mc: Multi Count - number of transactions per microframe
  105. * @interval: Interval for periodic endpoints, in frames or microframes.
  106. * @name: The name array passed to the USB core.
  107. * @halted: Set if the endpoint has been halted.
  108. * @periodic: Set if this is a periodic ep, such as Interrupt
  109. * @isochronous: Set if this is a isochronous ep
  110. * @send_zlp: Set if we need to send a zero-length packet.
  111. * @desc_list_dma: The DMA address of descriptor chain currently in use.
  112. * @desc_list: Pointer to descriptor DMA chain head currently in use.
  113. * @desc_count: Count of entries within the DMA descriptor chain of EP.
  114. * @next_desc: index of next free descriptor in the ISOC chain under SW control.
  115. * @compl_desc: index of next descriptor to be completed by xFerComplete
  116. * @total_data: The total number of data bytes done.
  117. * @fifo_size: The size of the FIFO (for periodic IN endpoints)
  118. * @fifo_index: For Dedicated FIFO operation, only FIFO0 can be used for EP0.
  119. * @fifo_load: The amount of data loaded into the FIFO (periodic IN)
  120. * @last_load: The offset of data for the last start of request.
  121. * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN
  122. * @target_frame: Targeted frame num to setup next ISOC transfer
  123. * @frame_overrun: Indicates SOF number overrun in DSTS
  124. *
  125. * This is the driver's state for each registered enpoint, allowing it
  126. * to keep track of transactions that need doing. Each endpoint has a
  127. * lock to protect the state, to try and avoid using an overall lock
  128. * for the host controller as much as possible.
  129. *
  130. * For periodic IN endpoints, we have fifo_size and fifo_load to try
  131. * and keep track of the amount of data in the periodic FIFO for each
  132. * of these as we don't have a status register that tells us how much
  133. * is in each of them. (note, this may actually be useless information
  134. * as in shared-fifo mode periodic in acts like a single-frame packet
  135. * buffer than a fifo)
  136. */
  137. struct dwc2_hsotg_ep {
  138. struct usb_ep ep;
  139. struct list_head queue;
  140. struct dwc2_hsotg *parent;
  141. struct dwc2_hsotg_req *req;
  142. struct dentry *debugfs;
  143. unsigned long total_data;
  144. unsigned int size_loaded;
  145. unsigned int last_load;
  146. unsigned int fifo_load;
  147. unsigned short fifo_size;
  148. unsigned short fifo_index;
  149. unsigned char dir_in;
  150. unsigned char index;
  151. unsigned char mc;
  152. u16 interval;
  153. unsigned int halted:1;
  154. unsigned int periodic:1;
  155. unsigned int isochronous:1;
  156. unsigned int send_zlp:1;
  157. unsigned int target_frame;
  158. #define TARGET_FRAME_INITIAL 0xFFFFFFFF
  159. bool frame_overrun;
  160. dma_addr_t desc_list_dma;
  161. struct dwc2_dma_desc *desc_list;
  162. u8 desc_count;
  163. unsigned int next_desc;
  164. unsigned int compl_desc;
  165. char name[10];
  166. };
  167. /**
  168. * struct dwc2_hsotg_req - data transfer request
  169. * @req: The USB gadget request
  170. * @queue: The list of requests for the endpoint this is queued for.
  171. * @saved_req_buf: variable to save req.buf when bounce buffers are used.
  172. */
  173. struct dwc2_hsotg_req {
  174. struct usb_request req;
  175. struct list_head queue;
  176. void *saved_req_buf;
  177. };
  178. #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
  179. IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  180. #define call_gadget(_hs, _entry) \
  181. do { \
  182. if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
  183. (_hs)->driver && (_hs)->driver->_entry) { \
  184. spin_unlock(&_hs->lock); \
  185. (_hs)->driver->_entry(&(_hs)->gadget); \
  186. spin_lock(&_hs->lock); \
  187. } \
  188. } while (0)
  189. #else
  190. #define call_gadget(_hs, _entry) do {} while (0)
  191. #endif
  192. struct dwc2_hsotg;
  193. struct dwc2_host_chan;
  194. /* Device States */
  195. enum dwc2_lx_state {
  196. DWC2_L0, /* On state */
  197. DWC2_L1, /* LPM sleep state */
  198. DWC2_L2, /* USB suspend state */
  199. DWC2_L3, /* Off state */
  200. };
  201. /* Gadget ep0 states */
  202. enum dwc2_ep0_state {
  203. DWC2_EP0_SETUP,
  204. DWC2_EP0_DATA_IN,
  205. DWC2_EP0_DATA_OUT,
  206. DWC2_EP0_STATUS_IN,
  207. DWC2_EP0_STATUS_OUT,
  208. };
  209. /**
  210. * struct dwc2_core_params - Parameters for configuring the core
  211. *
  212. * @otg_cap: Specifies the OTG capabilities.
  213. * 0 - HNP and SRP capable
  214. * 1 - SRP Only capable
  215. * 2 - No HNP/SRP capable (always available)
  216. * Defaults to best available option (0, 1, then 2)
  217. * @host_dma: Specifies whether to use slave or DMA mode for accessing
  218. * the data FIFOs. The driver will automatically detect the
  219. * value for this parameter if none is specified.
  220. * 0 - Slave (always available)
  221. * 1 - DMA (default, if available)
  222. * @dma_desc_enable: When DMA mode is enabled, specifies whether to use
  223. * address DMA mode or descriptor DMA mode for accessing
  224. * the data FIFOs. The driver will automatically detect the
  225. * value for this if none is specified.
  226. * 0 - Address DMA
  227. * 1 - Descriptor DMA (default, if available)
  228. * @dma_desc_fs_enable: When DMA mode is enabled, specifies whether to use
  229. * address DMA mode or descriptor DMA mode for accessing
  230. * the data FIFOs in Full Speed mode only. The driver
  231. * will automatically detect the value for this if none is
  232. * specified.
  233. * 0 - Address DMA
  234. * 1 - Descriptor DMA in FS (default, if available)
  235. * @speed: Specifies the maximum speed of operation in host and
  236. * device mode. The actual speed depends on the speed of
  237. * the attached device and the value of phy_type.
  238. * 0 - High Speed
  239. * (default when phy_type is UTMI+ or ULPI)
  240. * 1 - Full Speed
  241. * (default when phy_type is Full Speed)
  242. * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters
  243. * 1 - Allow dynamic FIFO sizing (default, if available)
  244. * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs
  245. * are enabled for non-periodic IN endpoints in device
  246. * mode.
  247. * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when
  248. * dynamic FIFO sizing is enabled
  249. * 16 to 32768
  250. * Actual maximum value is autodetected and also
  251. * the default.
  252. * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO
  253. * in host mode when dynamic FIFO sizing is enabled
  254. * 16 to 32768
  255. * Actual maximum value is autodetected and also
  256. * the default.
  257. * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in
  258. * host mode when dynamic FIFO sizing is enabled
  259. * 16 to 32768
  260. * Actual maximum value is autodetected and also
  261. * the default.
  262. * @max_transfer_size: The maximum transfer size supported, in bytes
  263. * 2047 to 65,535
  264. * Actual maximum value is autodetected and also
  265. * the default.
  266. * @max_packet_count: The maximum number of packets in a transfer
  267. * 15 to 511
  268. * Actual maximum value is autodetected and also
  269. * the default.
  270. * @host_channels: The number of host channel registers to use
  271. * 1 to 16
  272. * Actual maximum value is autodetected and also
  273. * the default.
  274. * @phy_type: Specifies the type of PHY interface to use. By default,
  275. * the driver will automatically detect the phy_type.
  276. * 0 - Full Speed Phy
  277. * 1 - UTMI+ Phy
  278. * 2 - ULPI Phy
  279. * Defaults to best available option (2, 1, then 0)
  280. * @phy_utmi_width: Specifies the UTMI+ Data Width (in bits). This parameter
  281. * is applicable for a phy_type of UTMI+ or ULPI. (For a
  282. * ULPI phy_type, this parameter indicates the data width
  283. * between the MAC and the ULPI Wrapper.) Also, this
  284. * parameter is applicable only if the OTG_HSPHY_WIDTH cC
  285. * parameter was set to "8 and 16 bits", meaning that the
  286. * core has been configured to work at either data path
  287. * width.
  288. * 8 or 16 (default 16 if available)
  289. * @phy_ulpi_ddr: Specifies whether the ULPI operates at double or single
  290. * data rate. This parameter is only applicable if phy_type
  291. * is ULPI.
  292. * 0 - single data rate ULPI interface with 8 bit wide
  293. * data bus (default)
  294. * 1 - double data rate ULPI interface with 4 bit wide
  295. * data bus
  296. * @phy_ulpi_ext_vbus: For a ULPI phy, specifies whether to use the internal or
  297. * external supply to drive the VBus
  298. * 0 - Internal supply (default)
  299. * 1 - External supply
  300. * @i2c_enable: Specifies whether to use the I2Cinterface for a full
  301. * speed PHY. This parameter is only applicable if phy_type
  302. * is FS.
  303. * 0 - No (default)
  304. * 1 - Yes
  305. * @ipg_isoc_en: Indicates the IPG supports is enabled or disabled.
  306. * 0 - Disable (default)
  307. * 1 - Enable
  308. * @acg_enable: For enabling Active Clock Gating in the controller
  309. * 0 - No
  310. * 1 - Yes
  311. * @ulpi_fs_ls: Make ULPI phy operate in FS/LS mode only
  312. * 0 - No (default)
  313. * 1 - Yes
  314. * @host_support_fs_ls_low_power: Specifies whether low power mode is supported
  315. * when attached to a Full Speed or Low Speed device in
  316. * host mode.
  317. * 0 - Don't support low power mode (default)
  318. * 1 - Support low power mode
  319. * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode
  320. * when connected to a Low Speed device in host
  321. * mode. This parameter is applicable only if
  322. * host_support_fs_ls_low_power is enabled.
  323. * 0 - 48 MHz
  324. * (default when phy_type is UTMI+ or ULPI)
  325. * 1 - 6 MHz
  326. * (default when phy_type is Full Speed)
  327. * @oc_disable: Flag to disable overcurrent condition.
  328. * 0 - Allow overcurrent condition to get detected
  329. * 1 - Disable overcurrent condtion to get detected
  330. * @ts_dline: Enable Term Select Dline pulsing
  331. * 0 - No (default)
  332. * 1 - Yes
  333. * @reload_ctl: Allow dynamic reloading of HFIR register during runtime
  334. * 0 - No (default for core < 2.92a)
  335. * 1 - Yes (default for core >= 2.92a)
  336. * @ahbcfg: This field allows the default value of the GAHBCFG
  337. * register to be overridden
  338. * -1 - GAHBCFG value will be set to 0x06
  339. * (INCR, default)
  340. * all others - GAHBCFG value will be overridden with
  341. * this value
  342. * Not all bits can be controlled like this, the
  343. * bits defined by GAHBCFG_CTRL_MASK are controlled
  344. * by the driver and are ignored in this
  345. * configuration value.
  346. * @uframe_sched: True to enable the microframe scheduler
  347. * @external_id_pin_ctl: Specifies whether ID pin is handled externally.
  348. * Disable CONIDSTSCHNG controller interrupt in such
  349. * case.
  350. * 0 - No (default)
  351. * 1 - Yes
  352. * @power_down: Specifies whether the controller support power_down.
  353. * If power_down is enabled, the controller will enter
  354. * power_down in both peripheral and host mode when
  355. * needed.
  356. * 0 - No (default)
  357. * 1 - Partial power down
  358. * 2 - Hibernation
  359. * @lpm: Enable LPM support.
  360. * 0 - No
  361. * 1 - Yes
  362. * @lpm_clock_gating: Enable core PHY clock gating.
  363. * 0 - No
  364. * 1 - Yes
  365. * @besl: Enable LPM Errata support.
  366. * 0 - No
  367. * 1 - Yes
  368. * @hird_threshold_en: HIRD or HIRD Threshold enable.
  369. * 0 - No
  370. * 1 - Yes
  371. * @hird_threshold: Value of BESL or HIRD Threshold.
  372. * @ref_clk_per: Indicates in terms of pico seconds the period
  373. * of ref_clk.
  374. * 62500 - 16MHz
  375. * 58823 - 17MHz
  376. * 52083 - 19.2MHz
  377. * 50000 - 20MHz
  378. * 41666 - 24MHz
  379. * 33333 - 30MHz (default)
  380. * 25000 - 40MHz
  381. * @sof_cnt_wkup_alert: Indicates in term of number of SOF's after which
  382. * the controller should generate an interrupt if the
  383. * device had been in L1 state until that period.
  384. * This is used by SW to initiate Remote WakeUp in the
  385. * controller so as to sync to the uF number from the host.
  386. * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO
  387. * register.
  388. * 0 - Deactivate the transceiver (default)
  389. * 1 - Activate the transceiver
  390. * @g_dma: Enables gadget dma usage (default: autodetect).
  391. * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect).
  392. * @g_rx_fifo_size: The periodic rx fifo size for the device, in
  393. * DWORDS from 16-32768 (default: 2048 if
  394. * possible, otherwise autodetect).
  395. * @g_np_tx_fifo_size: The non-periodic tx fifo size for the device in
  396. * DWORDS from 16-32768 (default: 1024 if
  397. * possible, otherwise autodetect).
  398. * @g_tx_fifo_size: An array of TX fifo sizes in dedicated fifo
  399. * mode. Each value corresponds to one EP
  400. * starting from EP1 (max 15 values). Sizes are
  401. * in DWORDS with possible values from from
  402. * 16-32768 (default: 256, 256, 256, 256, 768,
  403. * 768, 768, 768, 0, 0, 0, 0, 0, 0, 0).
  404. * @change_speed_quirk: Change speed configuration to DWC2_SPEED_PARAM_FULL
  405. * while full&low speed device connect. And change speed
  406. * back to DWC2_SPEED_PARAM_HIGH while device is gone.
  407. * 0 - No (default)
  408. * 1 - Yes
  409. * @service_interval: Enable service interval based scheduling.
  410. * 0 - No
  411. * 1 - Yes
  412. *
  413. * The following parameters may be specified when starting the module. These
  414. * parameters define how the DWC_otg controller should be configured. A
  415. * value of -1 (or any other out of range value) for any parameter means
  416. * to read the value from hardware (if possible) or use the builtin
  417. * default described above.
  418. */
  419. struct dwc2_core_params {
  420. u8 otg_cap;
  421. #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0
  422. #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE 1
  423. #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2
  424. u8 phy_type;
  425. #define DWC2_PHY_TYPE_PARAM_FS 0
  426. #define DWC2_PHY_TYPE_PARAM_UTMI 1
  427. #define DWC2_PHY_TYPE_PARAM_ULPI 2
  428. u8 speed;
  429. #define DWC2_SPEED_PARAM_HIGH 0
  430. #define DWC2_SPEED_PARAM_FULL 1
  431. #define DWC2_SPEED_PARAM_LOW 2
  432. u8 phy_utmi_width;
  433. bool phy_ulpi_ddr;
  434. bool phy_ulpi_ext_vbus;
  435. bool enable_dynamic_fifo;
  436. bool en_multiple_tx_fifo;
  437. bool i2c_enable;
  438. bool acg_enable;
  439. bool ulpi_fs_ls;
  440. bool ts_dline;
  441. bool reload_ctl;
  442. bool uframe_sched;
  443. bool external_id_pin_ctl;
  444. int power_down;
  445. #define DWC2_POWER_DOWN_PARAM_NONE 0
  446. #define DWC2_POWER_DOWN_PARAM_PARTIAL 1
  447. #define DWC2_POWER_DOWN_PARAM_HIBERNATION 2
  448. bool lpm;
  449. bool lpm_clock_gating;
  450. bool besl;
  451. bool hird_threshold_en;
  452. bool service_interval;
  453. u8 hird_threshold;
  454. bool activate_stm_fs_transceiver;
  455. bool ipg_isoc_en;
  456. u16 max_packet_count;
  457. u32 max_transfer_size;
  458. u32 ahbcfg;
  459. /* GREFCLK parameters */
  460. u32 ref_clk_per;
  461. u16 sof_cnt_wkup_alert;
  462. /* Host parameters */
  463. bool host_dma;
  464. bool dma_desc_enable;
  465. bool dma_desc_fs_enable;
  466. bool host_support_fs_ls_low_power;
  467. bool host_ls_low_power_phy_clk;
  468. bool oc_disable;
  469. u8 host_channels;
  470. u16 host_rx_fifo_size;
  471. u16 host_nperio_tx_fifo_size;
  472. u16 host_perio_tx_fifo_size;
  473. /* Gadget parameters */
  474. bool g_dma;
  475. bool g_dma_desc;
  476. u32 g_rx_fifo_size;
  477. u32 g_np_tx_fifo_size;
  478. u32 g_tx_fifo_size[MAX_EPS_CHANNELS];
  479. bool change_speed_quirk;
  480. };
  481. /**
  482. * struct dwc2_hw_params - Autodetected parameters.
  483. *
  484. * These parameters are the various parameters read from hardware
  485. * registers during initialization. They typically contain the best
  486. * supported or maximum value that can be configured in the
  487. * corresponding dwc2_core_params value.
  488. *
  489. * The values that are not in dwc2_core_params are documented below.
  490. *
  491. * @op_mode: Mode of Operation
  492. * 0 - HNP- and SRP-Capable OTG (Host & Device)
  493. * 1 - SRP-Capable OTG (Host & Device)
  494. * 2 - Non-HNP and Non-SRP Capable OTG (Host & Device)
  495. * 3 - SRP-Capable Device
  496. * 4 - Non-OTG Device
  497. * 5 - SRP-Capable Host
  498. * 6 - Non-OTG Host
  499. * @arch: Architecture
  500. * 0 - Slave only
  501. * 1 - External DMA
  502. * 2 - Internal DMA
  503. * @ipg_isoc_en: This feature indicates that the controller supports
  504. * the worst-case scenario of Rx followed by Rx
  505. * Interpacket Gap (IPG) (32 bitTimes) as per the utmi
  506. * specification for any token following ISOC OUT token.
  507. * 0 - Don't support
  508. * 1 - Support
  509. * @power_optimized: Are power optimizations enabled?
  510. * @num_dev_ep: Number of device endpoints available
  511. * @num_dev_in_eps: Number of device IN endpoints available
  512. * @num_dev_perio_in_ep: Number of device periodic IN endpoints
  513. * available
  514. * @dev_token_q_depth: Device Mode IN Token Sequence Learning Queue
  515. * Depth
  516. * 0 to 30
  517. * @host_perio_tx_q_depth:
  518. * Host Mode Periodic Request Queue Depth
  519. * 2, 4 or 8
  520. * @nperio_tx_q_depth:
  521. * Non-Periodic Request Queue Depth
  522. * 2, 4 or 8
  523. * @hs_phy_type: High-speed PHY interface type
  524. * 0 - High-speed interface not supported
  525. * 1 - UTMI+
  526. * 2 - ULPI
  527. * 3 - UTMI+ and ULPI
  528. * @fs_phy_type: Full-speed PHY interface type
  529. * 0 - Full speed interface not supported
  530. * 1 - Dedicated full speed interface
  531. * 2 - FS pins shared with UTMI+ pins
  532. * 3 - FS pins shared with ULPI pins
  533. * @total_fifo_size: Total internal RAM for FIFOs (bytes)
  534. * @hibernation: Is hibernation enabled?
  535. * @utmi_phy_data_width: UTMI+ PHY data width
  536. * 0 - 8 bits
  537. * 1 - 16 bits
  538. * 2 - 8 or 16 bits
  539. * @snpsid: Value from SNPSID register
  540. * @dev_ep_dirs: Direction of device endpoints (GHWCFG1)
  541. * @g_tx_fifo_size: Power-on values of TxFIFO sizes
  542. * @dma_desc_enable: When DMA mode is enabled, specifies whether to use
  543. * address DMA mode or descriptor DMA mode for accessing
  544. * the data FIFOs. The driver will automatically detect the
  545. * value for this if none is specified.
  546. * 0 - Address DMA
  547. * 1 - Descriptor DMA (default, if available)
  548. * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters
  549. * 1 - Allow dynamic FIFO sizing (default, if available)
  550. * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs
  551. * are enabled for non-periodic IN endpoints in device
  552. * mode.
  553. * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO
  554. * in host mode when dynamic FIFO sizing is enabled
  555. * 16 to 32768
  556. * Actual maximum value is autodetected and also
  557. * the default.
  558. * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in
  559. * host mode when dynamic FIFO sizing is enabled
  560. * 16 to 32768
  561. * Actual maximum value is autodetected and also
  562. * the default.
  563. * @max_transfer_size: The maximum transfer size supported, in bytes
  564. * 2047 to 65,535
  565. * Actual maximum value is autodetected and also
  566. * the default.
  567. * @max_packet_count: The maximum number of packets in a transfer
  568. * 15 to 511
  569. * Actual maximum value is autodetected and also
  570. * the default.
  571. * @host_channels: The number of host channel registers to use
  572. * 1 to 16
  573. * Actual maximum value is autodetected and also
  574. * the default.
  575. * @dev_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO
  576. * in device mode when dynamic FIFO sizing is enabled
  577. * 16 to 32768
  578. * Actual maximum value is autodetected and also
  579. * the default.
  580. * @i2c_enable: Specifies whether to use the I2Cinterface for a full
  581. * speed PHY. This parameter is only applicable if phy_type
  582. * is FS.
  583. * 0 - No (default)
  584. * 1 - Yes
  585. * @acg_enable: For enabling Active Clock Gating in the controller
  586. * 0 - Disable
  587. * 1 - Enable
  588. * @lpm_mode: For enabling Link Power Management in the controller
  589. * 0 - Disable
  590. * 1 - Enable
  591. * @rx_fifo_size: Number of 4-byte words in the Rx FIFO when dynamic
  592. * FIFO sizing is enabled 16 to 32768
  593. * Actual maximum value is autodetected and also
  594. * the default.
  595. * @service_interval_mode: For enabling service interval based scheduling in the
  596. * controller.
  597. * 0 - Disable
  598. * 1 - Enable
  599. */
  600. struct dwc2_hw_params {
  601. unsigned op_mode:3;
  602. unsigned arch:2;
  603. unsigned dma_desc_enable:1;
  604. unsigned enable_dynamic_fifo:1;
  605. unsigned en_multiple_tx_fifo:1;
  606. unsigned rx_fifo_size:16;
  607. unsigned host_nperio_tx_fifo_size:16;
  608. unsigned dev_nperio_tx_fifo_size:16;
  609. unsigned host_perio_tx_fifo_size:16;
  610. unsigned nperio_tx_q_depth:3;
  611. unsigned host_perio_tx_q_depth:3;
  612. unsigned dev_token_q_depth:5;
  613. unsigned max_transfer_size:26;
  614. unsigned max_packet_count:11;
  615. unsigned host_channels:5;
  616. unsigned hs_phy_type:2;
  617. unsigned fs_phy_type:2;
  618. unsigned i2c_enable:1;
  619. unsigned acg_enable:1;
  620. unsigned num_dev_ep:4;
  621. unsigned num_dev_in_eps : 4;
  622. unsigned num_dev_perio_in_ep:4;
  623. unsigned total_fifo_size:16;
  624. unsigned power_optimized:1;
  625. unsigned hibernation:1;
  626. unsigned utmi_phy_data_width:2;
  627. unsigned lpm_mode:1;
  628. unsigned ipg_isoc_en:1;
  629. unsigned service_interval_mode:1;
  630. u32 snpsid;
  631. u32 dev_ep_dirs;
  632. u32 g_tx_fifo_size[MAX_EPS_CHANNELS];
  633. };
  634. /* Size of control and EP0 buffers */
  635. #define DWC2_CTRL_BUFF_SIZE 8
  636. /**
  637. * struct dwc2_gregs_backup - Holds global registers state before
  638. * entering partial power down
  639. * @gotgctl: Backup of GOTGCTL register
  640. * @gintmsk: Backup of GINTMSK register
  641. * @gahbcfg: Backup of GAHBCFG register
  642. * @gusbcfg: Backup of GUSBCFG register
  643. * @grxfsiz: Backup of GRXFSIZ register
  644. * @gnptxfsiz: Backup of GNPTXFSIZ register
  645. * @gi2cctl: Backup of GI2CCTL register
  646. * @glpmcfg: Backup of GLPMCFG register
  647. * @gdfifocfg: Backup of GDFIFOCFG register
  648. * @pcgcctl: Backup of PCGCCTL register
  649. * @pcgcctl1: Backup of PCGCCTL1 register
  650. * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint
  651. * @gpwrdn: Backup of GPWRDN register
  652. * @valid: True if registers values backuped.
  653. */
  654. struct dwc2_gregs_backup {
  655. u32 gotgctl;
  656. u32 gintmsk;
  657. u32 gahbcfg;
  658. u32 gusbcfg;
  659. u32 grxfsiz;
  660. u32 gnptxfsiz;
  661. u32 gi2cctl;
  662. u32 glpmcfg;
  663. u32 pcgcctl;
  664. u32 pcgcctl1;
  665. u32 gdfifocfg;
  666. u32 gpwrdn;
  667. bool valid;
  668. };
  669. /**
  670. * struct dwc2_dregs_backup - Holds device registers state before
  671. * entering partial power down
  672. * @dcfg: Backup of DCFG register
  673. * @dctl: Backup of DCTL register
  674. * @daintmsk: Backup of DAINTMSK register
  675. * @diepmsk: Backup of DIEPMSK register
  676. * @doepmsk: Backup of DOEPMSK register
  677. * @diepctl: Backup of DIEPCTL register
  678. * @dieptsiz: Backup of DIEPTSIZ register
  679. * @diepdma: Backup of DIEPDMA register
  680. * @doepctl: Backup of DOEPCTL register
  681. * @doeptsiz: Backup of DOEPTSIZ register
  682. * @doepdma: Backup of DOEPDMA register
  683. * @dtxfsiz: Backup of DTXFSIZ registers for each endpoint
  684. * @valid: True if registers values backuped.
  685. */
  686. struct dwc2_dregs_backup {
  687. u32 dcfg;
  688. u32 dctl;
  689. u32 daintmsk;
  690. u32 diepmsk;
  691. u32 doepmsk;
  692. u32 diepctl[MAX_EPS_CHANNELS];
  693. u32 dieptsiz[MAX_EPS_CHANNELS];
  694. u32 diepdma[MAX_EPS_CHANNELS];
  695. u32 doepctl[MAX_EPS_CHANNELS];
  696. u32 doeptsiz[MAX_EPS_CHANNELS];
  697. u32 doepdma[MAX_EPS_CHANNELS];
  698. u32 dtxfsiz[MAX_EPS_CHANNELS];
  699. bool valid;
  700. };
  701. /**
  702. * struct dwc2_hregs_backup - Holds host registers state before
  703. * entering partial power down
  704. * @hcfg: Backup of HCFG register
  705. * @haintmsk: Backup of HAINTMSK register
  706. * @hcintmsk: Backup of HCINTMSK register
  707. * @hprt0: Backup of HPTR0 register
  708. * @hfir: Backup of HFIR register
  709. * @hptxfsiz: Backup of HPTXFSIZ register
  710. * @valid: True if registers values backuped.
  711. */
  712. struct dwc2_hregs_backup {
  713. u32 hcfg;
  714. u32 haintmsk;
  715. u32 hcintmsk[MAX_EPS_CHANNELS];
  716. u32 hprt0;
  717. u32 hfir;
  718. u32 hptxfsiz;
  719. bool valid;
  720. };
  721. /*
  722. * Constants related to high speed periodic scheduling
  723. *
  724. * We have a periodic schedule that is DWC2_HS_SCHEDULE_UFRAMES long. From a
  725. * reservation point of view it's assumed that the schedule goes right back to
  726. * the beginning after the end of the schedule.
  727. *
  728. * What does that mean for scheduling things with a long interval? It means
  729. * we'll reserve time for them in every possible microframe that they could
  730. * ever be scheduled in. ...but we'll still only actually schedule them as
  731. * often as they were requested.
  732. *
  733. * We keep our schedule in a "bitmap" structure. This simplifies having
  734. * to keep track of and merge intervals: we just let the bitmap code do most
  735. * of the heavy lifting. In a way scheduling is much like memory allocation.
  736. *
  737. * We schedule 100us per uframe or 80% of 125us (the maximum amount you're
  738. * supposed to schedule for periodic transfers). That's according to spec.
  739. *
  740. * Note that though we only schedule 80% of each microframe, the bitmap that we
  741. * keep the schedule in is tightly packed (AKA it doesn't have 100us worth of
  742. * space for each uFrame).
  743. *
  744. * Requirements:
  745. * - DWC2_HS_SCHEDULE_UFRAMES must even divide 0x4000 (HFNUM_MAX_FRNUM + 1)
  746. * - DWC2_HS_SCHEDULE_UFRAMES must be 8 times DWC2_LS_SCHEDULE_FRAMES (probably
  747. * could be any multiple of 8 times DWC2_LS_SCHEDULE_FRAMES, but there might
  748. * be bugs). The 8 comes from the USB spec: number of microframes per frame.
  749. */
  750. #define DWC2_US_PER_UFRAME 125
  751. #define DWC2_HS_PERIODIC_US_PER_UFRAME 100
  752. #define DWC2_HS_SCHEDULE_UFRAMES 8
  753. #define DWC2_HS_SCHEDULE_US (DWC2_HS_SCHEDULE_UFRAMES * \
  754. DWC2_HS_PERIODIC_US_PER_UFRAME)
  755. /*
  756. * Constants related to low speed scheduling
  757. *
  758. * For high speed we schedule every 1us. For low speed that's a bit overkill,
  759. * so we make up a unit called a "slice" that's worth 25us. There are 40
  760. * slices in a full frame and we can schedule 36 of those (90%) for periodic
  761. * transfers.
  762. *
  763. * Our low speed schedule can be as short as 1 frame or could be longer. When
  764. * we only schedule 1 frame it means that we'll need to reserve a time every
  765. * frame even for things that only transfer very rarely, so something that runs
  766. * every 2048 frames will get time reserved in every frame. Our low speed
  767. * schedule can be longer and we'll be able to handle more overlap, but that
  768. * will come at increased memory cost and increased time to schedule.
  769. *
  770. * Note: one other advantage of a short low speed schedule is that if we mess
  771. * up and miss scheduling we can jump in and use any of the slots that we
  772. * happened to reserve.
  773. *
  774. * With 25 us per slice and 1 frame in the schedule, we only need 4 bytes for
  775. * the schedule. There will be one schedule per TT.
  776. *
  777. * Requirements:
  778. * - DWC2_US_PER_SLICE must evenly divide DWC2_LS_PERIODIC_US_PER_FRAME.
  779. */
  780. #define DWC2_US_PER_SLICE 25
  781. #define DWC2_SLICES_PER_UFRAME (DWC2_US_PER_UFRAME / DWC2_US_PER_SLICE)
  782. #define DWC2_ROUND_US_TO_SLICE(us) \
  783. (DIV_ROUND_UP((us), DWC2_US_PER_SLICE) * \
  784. DWC2_US_PER_SLICE)
  785. #define DWC2_LS_PERIODIC_US_PER_FRAME \
  786. 900
  787. #define DWC2_LS_PERIODIC_SLICES_PER_FRAME \
  788. (DWC2_LS_PERIODIC_US_PER_FRAME / \
  789. DWC2_US_PER_SLICE)
  790. #define DWC2_LS_SCHEDULE_FRAMES 1
  791. #define DWC2_LS_SCHEDULE_SLICES (DWC2_LS_SCHEDULE_FRAMES * \
  792. DWC2_LS_PERIODIC_SLICES_PER_FRAME)
  793. /**
  794. * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
  795. * and periodic schedules
  796. *
  797. * These are common for both host and peripheral modes:
  798. *
  799. * @dev: The struct device pointer
  800. * @regs: Pointer to controller regs
  801. * @hw_params: Parameters that were autodetected from the
  802. * hardware registers
  803. * @params: Parameters that define how the core should be configured
  804. * @op_state: The operational State, during transitions (a_host=>
  805. * a_peripheral and b_device=>b_host) this may not match
  806. * the core, but allows the software to determine
  807. * transitions
  808. * @dr_mode: Requested mode of operation, one of following:
  809. * - USB_DR_MODE_PERIPHERAL
  810. * - USB_DR_MODE_HOST
  811. * - USB_DR_MODE_OTG
  812. * @hcd_enabled: Host mode sub-driver initialization indicator.
  813. * @gadget_enabled: Peripheral mode sub-driver initialization indicator.
  814. * @ll_hw_enabled: Status of low-level hardware resources.
  815. * @hibernated: True if core is hibernated
  816. * @frame_number: Frame number read from the core. For both device
  817. * and host modes. The value ranges are from 0
  818. * to HFNUM_MAX_FRNUM.
  819. * @phy: The otg phy transceiver structure for phy control.
  820. * @uphy: The otg phy transceiver structure for old USB phy
  821. * control.
  822. * @plat: The platform specific configuration data. This can be
  823. * removed once all SoCs support usb transceiver.
  824. * @supplies: Definition of USB power supplies
  825. * @vbus_supply: Regulator supplying vbus.
  826. * @phyif: PHY interface width
  827. * @lock: Spinlock that protects all the driver data structures
  828. * @priv: Stores a pointer to the struct usb_hcd
  829. * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
  830. * transfer are in process of being queued
  831. * @srp_success: Stores status of SRP request in the case of a FS PHY
  832. * with an I2C interface
  833. * @wq_otg: Workqueue object used for handling of some interrupts
  834. * @wf_otg: Work object for handling Connector ID Status Change
  835. * interrupt
  836. * @wkp_timer: Timer object for handling Wakeup Detected interrupt
  837. * @lx_state: Lx state of connected device
  838. * @gr_backup: Backup of global registers during suspend
  839. * @dr_backup: Backup of device registers during suspend
  840. * @hr_backup: Backup of host registers during suspend
  841. * @needs_byte_swap: Specifies whether the opposite endianness.
  842. *
  843. * These are for host mode:
  844. *
  845. * @flags: Flags for handling root port state changes
  846. * @flags.d32: Contain all root port flags
  847. * @flags.b: Separate root port flags from each other
  848. * @flags.b.port_connect_status_change: True if root port connect status
  849. * changed
  850. * @flags.b.port_connect_status: True if device connected to root port
  851. * @flags.b.port_reset_change: True if root port reset status changed
  852. * @flags.b.port_enable_change: True if root port enable status changed
  853. * @flags.b.port_suspend_change: True if root port suspend status changed
  854. * @flags.b.port_over_current_change: True if root port over current state
  855. * changed.
  856. * @flags.b.port_l1_change: True if root port l1 status changed
  857. * @flags.b.reserved: Reserved bits of root port register
  858. * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule.
  859. * Transfers associated with these QHs are not currently
  860. * assigned to a host channel.
  861. * @non_periodic_sched_active: Active QHs in the non-periodic schedule.
  862. * Transfers associated with these QHs are currently
  863. * assigned to a host channel.
  864. * @non_periodic_qh_ptr: Pointer to next QH to process in the active
  865. * non-periodic schedule
  866. * @non_periodic_sched_waiting: Waiting QHs in the non-periodic schedule.
  867. * Transfers associated with these QHs are not currently
  868. * assigned to a host channel.
  869. * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a
  870. * list of QHs for periodic transfers that are _not_
  871. * scheduled for the next frame. Each QH in the list has an
  872. * interval counter that determines when it needs to be
  873. * scheduled for execution. This scheduling mechanism
  874. * allows only a simple calculation for periodic bandwidth
  875. * used (i.e. must assume that all periodic transfers may
  876. * need to execute in the same frame). However, it greatly
  877. * simplifies scheduling and should be sufficient for the
  878. * vast majority of OTG hosts, which need to connect to a
  879. * small number of peripherals at one time. Items move from
  880. * this list to periodic_sched_ready when the QH interval
  881. * counter is 0 at SOF.
  882. * @periodic_sched_ready: List of periodic QHs that are ready for execution in
  883. * the next frame, but have not yet been assigned to host
  884. * channels. Items move from this list to
  885. * periodic_sched_assigned as host channels become
  886. * available during the current frame.
  887. * @periodic_sched_assigned: List of periodic QHs to be executed in the next
  888. * frame that are assigned to host channels. Items move
  889. * from this list to periodic_sched_queued as the
  890. * transactions for the QH are queued to the DWC_otg
  891. * controller.
  892. * @periodic_sched_queued: List of periodic QHs that have been queued for
  893. * execution. Items move from this list to either
  894. * periodic_sched_inactive or periodic_sched_ready when the
  895. * channel associated with the transfer is released. If the
  896. * interval for the QH is 1, the item moves to
  897. * periodic_sched_ready because it must be rescheduled for
  898. * the next frame. Otherwise, the item moves to
  899. * periodic_sched_inactive.
  900. * @split_order: List keeping track of channels doing splits, in order.
  901. * @periodic_usecs: Total bandwidth claimed so far for periodic transfers.
  902. * This value is in microseconds per (micro)frame. The
  903. * assumption is that all periodic transfers may occur in
  904. * the same (micro)frame.
  905. * @hs_periodic_bitmap: Bitmap used by the microframe scheduler any time the
  906. * host is in high speed mode; low speed schedules are
  907. * stored elsewhere since we need one per TT.
  908. * @periodic_qh_count: Count of periodic QHs, if using several eps. Used for
  909. * SOF enable/disable.
  910. * @free_hc_list: Free host channels in the controller. This is a list of
  911. * struct dwc2_host_chan items.
  912. * @periodic_channels: Number of host channels assigned to periodic transfers.
  913. * Currently assuming that there is a dedicated host
  914. * channel for each periodic transaction and at least one
  915. * host channel is available for non-periodic transactions.
  916. * @non_periodic_channels: Number of host channels assigned to non-periodic
  917. * transfers
  918. * @available_host_channels: Number of host channels available for the
  919. * microframe scheduler to use
  920. * @hc_ptr_array: Array of pointers to the host channel descriptors.
  921. * Allows accessing a host channel descriptor given the
  922. * host channel number. This is useful in interrupt
  923. * handlers.
  924. * @status_buf: Buffer used for data received during the status phase of
  925. * a control transfer.
  926. * @status_buf_dma: DMA address for status_buf
  927. * @start_work: Delayed work for handling host A-cable connection
  928. * @reset_work: Delayed work for handling a port reset
  929. * @otg_port: OTG port number
  930. * @frame_list: Frame list
  931. * @frame_list_dma: Frame list DMA address
  932. * @frame_list_sz: Frame list size
  933. * @desc_gen_cache: Kmem cache for generic descriptors
  934. * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
  935. * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
  936. *
  937. * These are for peripheral mode:
  938. *
  939. * @driver: USB gadget driver
  940. * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  941. * @num_of_eps: Number of available EPs (excluding EP0)
  942. * @debug_root: Root directrory for debugfs.
  943. * @ep0_reply: Request used for ep0 reply.
  944. * @ep0_buff: Buffer for EP0 reply data, if needed.
  945. * @ctrl_buff: Buffer for EP0 control requests.
  946. * @ctrl_req: Request for EP0 control packets.
  947. * @ep0_state: EP0 control transfers state
  948. * @test_mode: USB test mode requested by the host
  949. * @remote_wakeup_allowed: True if device is allowed to wake-up host by
  950. * remote-wakeup signalling
  951. * @setup_desc_dma: EP0 setup stage desc chain DMA address
  952. * @setup_desc: EP0 setup stage desc chain pointer
  953. * @ctrl_in_desc_dma: EP0 IN data phase desc chain DMA address
  954. * @ctrl_in_desc: EP0 IN data phase desc chain pointer
  955. * @ctrl_out_desc_dma: EP0 OUT data phase desc chain DMA address
  956. * @ctrl_out_desc: EP0 OUT data phase desc chain pointer
  957. * @irq: Interrupt request line number
  958. * @clk: Pointer to otg clock
  959. * @reset: Pointer to dwc2 reset controller
  960. * @reset_ecc: Pointer to dwc2 optional reset controller in Stratix10.
  961. * @regset: A pointer to a struct debugfs_regset32, which contains
  962. * a pointer to an array of register definitions, the
  963. * array size and the base address where the register bank
  964. * is to be found.
  965. * @bus_suspended: True if bus is suspended
  966. * @last_frame_num: Number of last frame. Range from 0 to 32768
  967. * @frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is
  968. * defined, for missed SOFs tracking. Array holds that
  969. * frame numbers, which not equal to last_frame_num +1
  970. * @last_frame_num_array: Used only if CONFIG_USB_DWC2_TRACK_MISSED_SOFS is
  971. * defined, for missed SOFs tracking.
  972. * If current_frame_number != last_frame_num+1
  973. * then last_frame_num added to this array
  974. * @frame_num_idx: Actual size of frame_num_array and last_frame_num_array
  975. * @dumped_frame_num_array: 1 - if missed SOFs frame numbers dumbed
  976. * 0 - if missed SOFs frame numbers not dumbed
  977. * @fifo_mem: Total internal RAM for FIFOs (bytes)
  978. * @fifo_map: Each bit intend for concrete fifo. If that bit is set,
  979. * then that fifo is used
  980. * @gadget: Represents a usb slave device
  981. * @connected: Used in slave mode. True if device connected with host
  982. * @eps_in: The IN endpoints being supplied to the gadget framework
  983. * @eps_out: The OUT endpoints being supplied to the gadget framework
  984. * @new_connection: Used in host mode. True if there are new connected
  985. * device
  986. * @enabled: Indicates the enabling state of controller
  987. *
  988. */
  989. struct dwc2_hsotg {
  990. struct device *dev;
  991. void __iomem *regs;
  992. /** Params detected from hardware */
  993. struct dwc2_hw_params hw_params;
  994. /** Params to actually use */
  995. struct dwc2_core_params params;
  996. enum usb_otg_state op_state;
  997. enum usb_dr_mode dr_mode;
  998. unsigned int hcd_enabled:1;
  999. unsigned int gadget_enabled:1;
  1000. unsigned int ll_hw_enabled:1;
  1001. unsigned int hibernated:1;
  1002. u16 frame_number;
  1003. struct phy *phy;
  1004. struct usb_phy *uphy;
  1005. struct dwc2_hsotg_plat *plat;
  1006. struct regulator_bulk_data supplies[DWC2_NUM_SUPPLIES];
  1007. struct regulator *vbus_supply;
  1008. u32 phyif;
  1009. spinlock_t lock;
  1010. void *priv;
  1011. int irq;
  1012. struct clk *clk;
  1013. struct reset_control *reset;
  1014. struct reset_control *reset_ecc;
  1015. unsigned int queuing_high_bandwidth:1;
  1016. unsigned int srp_success:1;
  1017. struct workqueue_struct *wq_otg;
  1018. struct work_struct wf_otg;
  1019. struct timer_list wkp_timer;
  1020. enum dwc2_lx_state lx_state;
  1021. struct dwc2_gregs_backup gr_backup;
  1022. struct dwc2_dregs_backup dr_backup;
  1023. struct dwc2_hregs_backup hr_backup;
  1024. struct dentry *debug_root;
  1025. struct debugfs_regset32 *regset;
  1026. bool needs_byte_swap;
  1027. /* DWC OTG HW Release versions */
  1028. #define DWC2_CORE_REV_2_71a 0x4f54271a
  1029. #define DWC2_CORE_REV_2_72a 0x4f54272a
  1030. #define DWC2_CORE_REV_2_80a 0x4f54280a
  1031. #define DWC2_CORE_REV_2_90a 0x4f54290a
  1032. #define DWC2_CORE_REV_2_91a 0x4f54291a
  1033. #define DWC2_CORE_REV_2_92a 0x4f54292a
  1034. #define DWC2_CORE_REV_2_94a 0x4f54294a
  1035. #define DWC2_CORE_REV_3_00a 0x4f54300a
  1036. #define DWC2_CORE_REV_3_10a 0x4f54310a
  1037. #define DWC2_CORE_REV_4_00a 0x4f54400a
  1038. #define DWC2_FS_IOT_REV_1_00a 0x5531100a
  1039. #define DWC2_HS_IOT_REV_1_00a 0x5532100a
  1040. /* DWC OTG HW Core ID */
  1041. #define DWC2_OTG_ID 0x4f540000
  1042. #define DWC2_FS_IOT_ID 0x55310000
  1043. #define DWC2_HS_IOT_ID 0x55320000
  1044. #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  1045. union dwc2_hcd_internal_flags {
  1046. u32 d32;
  1047. struct {
  1048. unsigned port_connect_status_change:1;
  1049. unsigned port_connect_status:1;
  1050. unsigned port_reset_change:1;
  1051. unsigned port_enable_change:1;
  1052. unsigned port_suspend_change:1;
  1053. unsigned port_over_current_change:1;
  1054. unsigned port_l1_change:1;
  1055. unsigned reserved:25;
  1056. } b;
  1057. } flags;
  1058. struct list_head non_periodic_sched_inactive;
  1059. struct list_head non_periodic_sched_waiting;
  1060. struct list_head non_periodic_sched_active;
  1061. struct list_head *non_periodic_qh_ptr;
  1062. struct list_head periodic_sched_inactive;
  1063. struct list_head periodic_sched_ready;
  1064. struct list_head periodic_sched_assigned;
  1065. struct list_head periodic_sched_queued;
  1066. struct list_head split_order;
  1067. u16 periodic_usecs;
  1068. unsigned long hs_periodic_bitmap[
  1069. DIV_ROUND_UP(DWC2_HS_SCHEDULE_US, BITS_PER_LONG)];
  1070. u16 periodic_qh_count;
  1071. bool bus_suspended;
  1072. bool new_connection;
  1073. u16 last_frame_num;
  1074. #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
  1075. #define FRAME_NUM_ARRAY_SIZE 1000
  1076. u16 *frame_num_array;
  1077. u16 *last_frame_num_array;
  1078. int frame_num_idx;
  1079. int dumped_frame_num_array;
  1080. #endif
  1081. struct list_head free_hc_list;
  1082. int periodic_channels;
  1083. int non_periodic_channels;
  1084. int available_host_channels;
  1085. struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS];
  1086. u8 *status_buf;
  1087. dma_addr_t status_buf_dma;
  1088. #define DWC2_HCD_STATUS_BUF_SIZE 64
  1089. struct delayed_work start_work;
  1090. struct delayed_work reset_work;
  1091. u8 otg_port;
  1092. u32 *frame_list;
  1093. dma_addr_t frame_list_dma;
  1094. u32 frame_list_sz;
  1095. struct kmem_cache *desc_gen_cache;
  1096. struct kmem_cache *desc_hsisoc_cache;
  1097. struct kmem_cache *unaligned_cache;
  1098. #define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
  1099. #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
  1100. #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
  1101. IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  1102. /* Gadget structures */
  1103. struct usb_gadget_driver *driver;
  1104. int fifo_mem;
  1105. unsigned int dedicated_fifos:1;
  1106. unsigned char num_of_eps;
  1107. u32 fifo_map;
  1108. struct usb_request *ep0_reply;
  1109. struct usb_request *ctrl_req;
  1110. void *ep0_buff;
  1111. void *ctrl_buff;
  1112. enum dwc2_ep0_state ep0_state;
  1113. u8 test_mode;
  1114. dma_addr_t setup_desc_dma[2];
  1115. struct dwc2_dma_desc *setup_desc[2];
  1116. dma_addr_t ctrl_in_desc_dma;
  1117. struct dwc2_dma_desc *ctrl_in_desc;
  1118. dma_addr_t ctrl_out_desc_dma;
  1119. struct dwc2_dma_desc *ctrl_out_desc;
  1120. struct usb_gadget gadget;
  1121. unsigned int enabled:1;
  1122. unsigned int connected:1;
  1123. unsigned int remote_wakeup_allowed:1;
  1124. struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
  1125. struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
  1126. #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
  1127. };
  1128. /* Normal architectures just use readl/write */
  1129. static inline u32 dwc2_readl(struct dwc2_hsotg *hsotg, u32 offset)
  1130. {
  1131. u32 val;
  1132. val = readl(hsotg->regs + offset);
  1133. if (hsotg->needs_byte_swap)
  1134. return swab32(val);
  1135. else
  1136. return val;
  1137. }
  1138. static inline void dwc2_writel(struct dwc2_hsotg *hsotg, u32 value, u32 offset)
  1139. {
  1140. if (hsotg->needs_byte_swap)
  1141. writel(swab32(value), hsotg->regs + offset);
  1142. else
  1143. writel(value, hsotg->regs + offset);
  1144. #ifdef DWC2_LOG_WRITES
  1145. pr_info("info:: wrote %08x to %p\n", value, hsotg->regs + offset);
  1146. #endif
  1147. }
  1148. static inline void dwc2_readl_rep(struct dwc2_hsotg *hsotg, u32 offset,
  1149. void *buffer, unsigned int count)
  1150. {
  1151. if (count) {
  1152. u32 *buf = buffer;
  1153. do {
  1154. u32 x = dwc2_readl(hsotg, offset);
  1155. *buf++ = x;
  1156. } while (--count);
  1157. }
  1158. }
  1159. static inline void dwc2_writel_rep(struct dwc2_hsotg *hsotg, u32 offset,
  1160. const void *buffer, unsigned int count)
  1161. {
  1162. if (count) {
  1163. const u32 *buf = buffer;
  1164. do {
  1165. dwc2_writel(hsotg, *buf++, offset);
  1166. } while (--count);
  1167. }
  1168. }
  1169. /* Reasons for halting a host channel */
  1170. enum dwc2_halt_status {
  1171. DWC2_HC_XFER_NO_HALT_STATUS,
  1172. DWC2_HC_XFER_COMPLETE,
  1173. DWC2_HC_XFER_URB_COMPLETE,
  1174. DWC2_HC_XFER_ACK,
  1175. DWC2_HC_XFER_NAK,
  1176. DWC2_HC_XFER_NYET,
  1177. DWC2_HC_XFER_STALL,
  1178. DWC2_HC_XFER_XACT_ERR,
  1179. DWC2_HC_XFER_FRAME_OVERRUN,
  1180. DWC2_HC_XFER_BABBLE_ERR,
  1181. DWC2_HC_XFER_DATA_TOGGLE_ERR,
  1182. DWC2_HC_XFER_AHB_ERR,
  1183. DWC2_HC_XFER_PERIODIC_INCOMPLETE,
  1184. DWC2_HC_XFER_URB_DEQUEUE,
  1185. };
  1186. /* Core version information */
  1187. static inline bool dwc2_is_iot(struct dwc2_hsotg *hsotg)
  1188. {
  1189. return (hsotg->hw_params.snpsid & 0xfff00000) == 0x55300000;
  1190. }
  1191. static inline bool dwc2_is_fs_iot(struct dwc2_hsotg *hsotg)
  1192. {
  1193. return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55310000;
  1194. }
  1195. static inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg)
  1196. {
  1197. return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55320000;
  1198. }
  1199. /*
  1200. * The following functions support initialization of the core driver component
  1201. * and the DWC_otg controller
  1202. */
  1203. int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait);
  1204. int dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg);
  1205. int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore);
  1206. int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host);
  1207. int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
  1208. int reset, int is_host);
  1209. void dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host);
  1210. void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg);
  1211. bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg);
  1212. /*
  1213. * Common core Functions.
  1214. * The following functions support managing the DWC_otg controller in either
  1215. * device or host mode.
  1216. */
  1217. void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes);
  1218. void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
  1219. void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
  1220. void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
  1221. void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
  1222. void dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup,
  1223. int is_host);
  1224. int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg);
  1225. int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg);
  1226. void dwc2_enable_acg(struct dwc2_hsotg *hsotg);
  1227. /* This function should be called on every hardware interrupt. */
  1228. irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
  1229. /* The device ID match table */
  1230. extern const struct of_device_id dwc2_of_match_table[];
  1231. int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg);
  1232. int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg);
  1233. /* Common polling functions */
  1234. int dwc2_hsotg_wait_bit_set(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit,
  1235. u32 timeout);
  1236. int dwc2_hsotg_wait_bit_clear(struct dwc2_hsotg *hs_otg, u32 reg, u32 bit,
  1237. u32 timeout);
  1238. /* Parameters */
  1239. int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
  1240. int dwc2_init_params(struct dwc2_hsotg *hsotg);
  1241. /*
  1242. * The following functions check the controller's OTG operation mode
  1243. * capability (GHWCFG2.OTG_MODE).
  1244. *
  1245. * These functions can be used before the internal hsotg->hw_params
  1246. * are read in and cached so they always read directly from the
  1247. * GHWCFG2 register.
  1248. */
  1249. unsigned int dwc2_op_mode(struct dwc2_hsotg *hsotg);
  1250. bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg);
  1251. bool dwc2_hw_is_host(struct dwc2_hsotg *hsotg);
  1252. bool dwc2_hw_is_device(struct dwc2_hsotg *hsotg);
  1253. /*
  1254. * Returns the mode of operation, host or device
  1255. */
  1256. static inline int dwc2_is_host_mode(struct dwc2_hsotg *hsotg)
  1257. {
  1258. return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) != 0;
  1259. }
  1260. static inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg)
  1261. {
  1262. return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0;
  1263. }
  1264. /*
  1265. * Dump core registers and SPRAM
  1266. */
  1267. void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg);
  1268. void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg);
  1269. void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg);
  1270. /* Gadget defines */
  1271. #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
  1272. IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  1273. int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg);
  1274. int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2);
  1275. int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2);
  1276. int dwc2_gadget_init(struct dwc2_hsotg *hsotg);
  1277. void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
  1278. bool reset);
  1279. void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg);
  1280. void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2);
  1281. int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
  1282. #define dwc2_is_device_connected(hsotg) (hsotg->connected)
  1283. int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg);
  1284. int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup);
  1285. int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg);
  1286. int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
  1287. int rem_wakeup, int reset);
  1288. int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg);
  1289. int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg);
  1290. int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg);
  1291. void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg);
  1292. void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg);
  1293. #else
  1294. static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2)
  1295. { return 0; }
  1296. static inline int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2)
  1297. { return 0; }
  1298. static inline int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2)
  1299. { return 0; }
  1300. static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
  1301. { return 0; }
  1302. static inline void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
  1303. bool reset) {}
  1304. static inline void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
  1305. static inline void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
  1306. static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
  1307. int testmode)
  1308. { return 0; }
  1309. #define dwc2_is_device_connected(hsotg) (0)
  1310. static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
  1311. { return 0; }
  1312. static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg,
  1313. int remote_wakeup)
  1314. { return 0; }
  1315. static inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
  1316. { return 0; }
  1317. static inline int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
  1318. int rem_wakeup, int reset)
  1319. { return 0; }
  1320. static inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg)
  1321. { return 0; }
  1322. static inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg)
  1323. { return 0; }
  1324. static inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg)
  1325. { return 0; }
  1326. static inline void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) {}
  1327. static inline void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) {}
  1328. #endif
  1329. #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
  1330. int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
  1331. int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, int us);
  1332. void dwc2_hcd_connect(struct dwc2_hsotg *hsotg);
  1333. void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force);
  1334. void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
  1335. int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup);
  1336. int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg);
  1337. int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg);
  1338. int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg);
  1339. int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg,
  1340. int rem_wakeup, int reset);
  1341. #else
  1342. static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
  1343. { return 0; }
  1344. static inline int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg,
  1345. int us)
  1346. { return 0; }
  1347. static inline void dwc2_hcd_connect(struct dwc2_hsotg *hsotg) {}
  1348. static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {}
  1349. static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
  1350. static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
  1351. static inline int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup)
  1352. { return 0; }
  1353. static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
  1354. { return 0; }
  1355. static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
  1356. { return 0; }
  1357. static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
  1358. { return 0; }
  1359. static inline int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
  1360. { return 0; }
  1361. static inline int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg,
  1362. int rem_wakeup, int reset)
  1363. { return 0; }
  1364. #endif
  1365. #endif /* __DWC2_CORE_H__ */