dwc_otg_driver.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
  1. /* ==========================================================================
  2. * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_driver.c $
  3. * $Revision: #91 $
  4. * $Date: 2011/10/24 $
  5. * $Change: 1871159 $
  6. *
  7. * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
  8. * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
  9. * otherwise expressly agreed to in writing between Synopsys and you.
  10. *
  11. * The Software IS NOT an item of Licensed Software or Licensed Product under
  12. * any End User Software License Agreement or Agreement for Licensed Product
  13. * with Synopsys or any supplement thereto. You are permitted to use and
  14. * redistribute this Software in source and binary forms, with or without
  15. * modification, provided that redistributions of source code must retain this
  16. * notice. You may not view, use, disclose, copy or distribute this file or
  17. * any information contained herein except pursuant to this license grant from
  18. * Synopsys. If you do not agree with this notice, including the disclaimer
  19. * below, then you are not authorized to use the Software.
  20. *
  21. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
  25. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  31. * DAMAGE.
  32. * ========================================================================== */
  33. /** @file
  34. * The dwc_otg_driver module provides the initialization and cleanup entry
  35. * points for the DWC_otg driver. This module will be dynamically installed
  36. * after Linux is booted using the insmod command. When the module is
  37. * installed, the dwc_otg_driver_init function is called. When the module is
  38. * removed (using rmmod), the dwc_otg_driver_cleanup function is called.
  39. *
  40. * This module also defines a data structure for the dwc_otg_driver, which is
  41. * used in conjunction with the standard ARM lm_device structure. These
  42. * structures allow the OTG driver to comply with the standard Linux driver
  43. * model in which devices and drivers are registered with a bus driver. This
  44. * has the benefit that Linux can expose attributes of the driver and device
  45. * in its special sysfs file system. Users can then read or write files in
  46. * this file system to perform diagnostics on the driver components or the
  47. * device.
  48. */
  49. #include "dwc_otg_os_dep.h"
  50. #include "dwc_os.h"
  51. #include "dwc_otg_dbg.h"
  52. #include "dwc_otg_driver.h"
  53. #include "dwc_otg_attr.h"
  54. #include "dwc_otg_core_if.h"
  55. #include "dwc_otg_cil.h"
  56. #include "dwc_otg_pcd_if.h"
  57. #include "dwc_otg_hcd_if.h"
  58. #include <asm/io.h>
  59. #include <asm/sizes.h>
  60. #include <plat/lm.h>
  61. #include <mach/usbclock.h>
  62. #define DWC_DRIVER_VERSION "2.94a 25-JUN-2012"
  63. #define DWC_DRIVER_DESC "HS OTG USB Controller driver"
  64. static const char dwc_driver_name[] = "dwc_otg";
  65. extern int pcd_init(
  66. #ifdef LM_INTERFACE
  67. struct lm_device *_dev
  68. #elif defined(PCI_INTERFACE)
  69. struct pci_dev *_dev
  70. #endif
  71. );
  72. extern int hcd_init(
  73. #ifdef LM_INTERFACE
  74. struct lm_device *_dev
  75. #elif defined(PCI_INTERFACE)
  76. struct pci_dev *_dev
  77. #endif
  78. );
  79. extern int pcd_remove(
  80. #ifdef LM_INTERFACE
  81. struct lm_device *_dev
  82. #elif defined(PCI_INTERFACE)
  83. struct pci_dev *_dev
  84. #endif
  85. );
  86. extern void hcd_remove(
  87. #ifdef LM_INTERFACE
  88. struct lm_device *_dev
  89. #elif defined(PCI_INTERFACE)
  90. struct pci_dev *_dev
  91. #endif
  92. );
  93. extern void dwc_otg_adp_start(dwc_otg_core_if_t * core_if, uint8_t is_host);
  94. /*-------------------------------------------------------------------------*/
  95. /* Encapsulate the module parameter settings */
  96. struct dwc_otg_driver_module_params {
  97. int32_t opt;
  98. int32_t otg_cap;
  99. int32_t dma_enable;
  100. int32_t dma_desc_enable;
  101. int32_t dma_burst_size;
  102. int32_t speed;
  103. int32_t host_support_fs_ls_low_power;
  104. int32_t host_ls_low_power_phy_clk;
  105. int32_t enable_dynamic_fifo;
  106. int32_t data_fifo_size;
  107. int32_t dev_rx_fifo_size;
  108. int32_t dev_nperio_tx_fifo_size;
  109. uint32_t dev_perio_tx_fifo_size[MAX_PERIO_FIFOS];
  110. int32_t host_rx_fifo_size;
  111. int32_t host_nperio_tx_fifo_size;
  112. int32_t host_perio_tx_fifo_size;
  113. int32_t max_transfer_size;
  114. int32_t max_packet_count;
  115. int32_t host_channels;
  116. int32_t dev_endpoints;
  117. int32_t phy_type;
  118. int32_t phy_utmi_width;
  119. int32_t phy_ulpi_ddr;
  120. int32_t phy_ulpi_ext_vbus;
  121. int32_t i2c_enable;
  122. int32_t ulpi_fs_ls;
  123. int32_t ts_dline;
  124. int32_t en_multiple_tx_fifo;
  125. uint32_t dev_tx_fifo_size[MAX_TX_FIFOS];
  126. uint32_t thr_ctl;
  127. uint32_t tx_thr_length;
  128. uint32_t rx_thr_length;
  129. int32_t pti_enable;
  130. int32_t mpi_enable;
  131. int32_t lpm_enable;
  132. int32_t ic_usb_cap;
  133. int32_t ahb_thr_ratio;
  134. int32_t power_down;
  135. int32_t reload_ctl;
  136. int32_t dev_out_nak;
  137. int32_t cont_on_bna;
  138. int32_t ahb_single;
  139. int32_t otg_ver;
  140. int32_t adp_enable;
  141. };
  142. static struct dwc_otg_driver_module_params dwc_otg_module_params = {
  143. .opt = -1,
  144. .otg_cap = DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE,
  145. .dma_enable = -1,
  146. .dma_desc_enable = 0,
  147. .dma_burst_size = -1,
  148. .speed = -1,
  149. .host_support_fs_ls_low_power = -1,
  150. .host_ls_low_power_phy_clk = -1,
  151. .enable_dynamic_fifo = 1,
  152. .data_fifo_size = 1000,
  153. .dev_rx_fifo_size = 500,
  154. .dev_nperio_tx_fifo_size = 500,
  155. .dev_perio_tx_fifo_size = {
  156. /* dev_perio_tx_fifo_size_1 */
  157. -1,
  158. -1,
  159. -1,
  160. -1,
  161. -1,
  162. -1,
  163. -1,
  164. -1,
  165. -1,
  166. -1,
  167. -1,
  168. -1,
  169. -1,
  170. -1,
  171. -1
  172. /* 15 */
  173. },
  174. .host_rx_fifo_size = 512,
  175. .host_nperio_tx_fifo_size = 500,
  176. .host_perio_tx_fifo_size = -1,
  177. .max_transfer_size = -1,
  178. .max_packet_count = -1,
  179. .host_channels = -1,
  180. .dev_endpoints = -1,
  181. .phy_type = -1,
  182. .phy_utmi_width = -1,
  183. .phy_ulpi_ddr = -1,
  184. .phy_ulpi_ext_vbus = -1,
  185. .i2c_enable = -1,
  186. .ulpi_fs_ls = -1,
  187. .ts_dline = -1,
  188. .en_multiple_tx_fifo = -1,
  189. .dev_tx_fifo_size = {
  190. /* dev_tx_fifo_size */
  191. -1,
  192. -1,
  193. -1,
  194. -1,
  195. -1,
  196. -1,
  197. -1,
  198. -1,
  199. -1,
  200. -1,
  201. -1,
  202. -1,
  203. -1,
  204. -1,
  205. -1
  206. /* 15 */
  207. },
  208. .thr_ctl = -1,
  209. .tx_thr_length = -1,
  210. .rx_thr_length = -1,
  211. .pti_enable = -1,
  212. .mpi_enable = -1,
  213. .lpm_enable = -1,
  214. .ic_usb_cap = -1,
  215. .ahb_thr_ratio = -1,
  216. .power_down = -1,
  217. .reload_ctl = -1,
  218. .dev_out_nak = -1,
  219. .cont_on_bna = -1,
  220. .ahb_single = 1,
  221. .otg_ver = -1,
  222. .adp_enable = -1,
  223. };
  224. /**
  225. * Index-name refer to lm.h usb_dma_config_e
  226. */
  227. static const char *dma_config_name[] = {
  228. "BURST_DEFAULT",
  229. "BURST_SINGLE",
  230. "BURST_INCR",
  231. "BURST_INCR4",
  232. "BURST_INCR8",
  233. "BURST_INCR16"
  234. "DISABLE",
  235. };
  236. /**
  237. * This function shows the Driver Version.
  238. */
  239. static ssize_t version_show(struct device_driver *dev, char *buf)
  240. {
  241. return snprintf(buf, sizeof(DWC_DRIVER_VERSION) + 2, "%s\n",
  242. DWC_DRIVER_VERSION);
  243. }
  244. static DRIVER_ATTR(version, S_IRUGO, version_show, NULL);
  245. /**
  246. * Global Debug Level Mask.
  247. */
  248. uint32_t g_dbg_lvl = 0; /* OFF */
  249. /**
  250. * This function shows the driver Debug Level.
  251. */
  252. static ssize_t dbg_level_show(struct device_driver *drv, char *buf)
  253. {
  254. return sprintf(buf, "0x%0x\n", g_dbg_lvl);
  255. }
  256. /**
  257. * This function stores the driver Debug Level.
  258. */
  259. static ssize_t dbg_level_store(struct device_driver *drv, const char *buf,
  260. size_t count)
  261. {
  262. g_dbg_lvl = simple_strtoul(buf, NULL, 16);
  263. return count;
  264. }
  265. static DRIVER_ATTR(debuglevel, S_IRUGO | S_IWUSR, dbg_level_show,
  266. dbg_level_store);
  267. /**
  268. * This function is called during module intialization
  269. * to pass module parameters to the DWC_OTG CORE.
  270. */
  271. static int set_parameters(dwc_otg_core_if_t * core_if)
  272. {
  273. int retval = 0;
  274. int i;
  275. if (dwc_otg_module_params.otg_cap != -1) {
  276. retval +=
  277. dwc_otg_set_param_otg_cap(core_if,
  278. dwc_otg_module_params.otg_cap);
  279. }
  280. if (dwc_otg_module_params.dma_enable != -1) {
  281. retval +=
  282. dwc_otg_set_param_dma_enable(core_if,
  283. dwc_otg_module_params.
  284. dma_enable);
  285. }
  286. if (dwc_otg_module_params.dma_desc_enable != -1) {
  287. retval +=
  288. dwc_otg_set_param_dma_desc_enable(core_if,
  289. dwc_otg_module_params.
  290. dma_desc_enable);
  291. }
  292. if (dwc_otg_module_params.opt != -1) {
  293. retval +=
  294. dwc_otg_set_param_opt(core_if, dwc_otg_module_params.opt);
  295. }
  296. if (dwc_otg_module_params.dma_burst_size != -1) {
  297. retval +=
  298. dwc_otg_set_param_dma_burst_size(core_if,
  299. dwc_otg_module_params.
  300. dma_burst_size);
  301. }
  302. if (dwc_otg_module_params.host_support_fs_ls_low_power != -1) {
  303. retval +=
  304. dwc_otg_set_param_host_support_fs_ls_low_power(core_if,
  305. dwc_otg_module_params.
  306. host_support_fs_ls_low_power);
  307. }
  308. if (dwc_otg_module_params.enable_dynamic_fifo != -1) {
  309. retval +=
  310. dwc_otg_set_param_enable_dynamic_fifo(core_if,
  311. dwc_otg_module_params.
  312. enable_dynamic_fifo);
  313. }
  314. if (dwc_otg_module_params.data_fifo_size != -1) {
  315. retval +=
  316. dwc_otg_set_param_data_fifo_size(core_if,
  317. dwc_otg_module_params.
  318. data_fifo_size);
  319. }
  320. if (dwc_otg_module_params.dev_rx_fifo_size != -1) {
  321. retval +=
  322. dwc_otg_set_param_dev_rx_fifo_size(core_if,
  323. dwc_otg_module_params.
  324. dev_rx_fifo_size);
  325. }
  326. if (dwc_otg_module_params.dev_nperio_tx_fifo_size != -1) {
  327. retval +=
  328. dwc_otg_set_param_dev_nperio_tx_fifo_size(core_if,
  329. dwc_otg_module_params.
  330. dev_nperio_tx_fifo_size);
  331. }
  332. if (dwc_otg_module_params.host_rx_fifo_size != -1) {
  333. retval +=
  334. dwc_otg_set_param_host_rx_fifo_size(core_if,
  335. dwc_otg_module_params.host_rx_fifo_size);
  336. }
  337. if (dwc_otg_module_params.host_nperio_tx_fifo_size != -1) {
  338. retval +=
  339. dwc_otg_set_param_host_nperio_tx_fifo_size(core_if,
  340. dwc_otg_module_params.
  341. host_nperio_tx_fifo_size);
  342. }
  343. if (dwc_otg_module_params.host_perio_tx_fifo_size != -1) {
  344. retval +=
  345. dwc_otg_set_param_host_perio_tx_fifo_size(core_if,
  346. dwc_otg_module_params.
  347. host_perio_tx_fifo_size);
  348. }
  349. if (dwc_otg_module_params.max_transfer_size != -1) {
  350. retval +=
  351. dwc_otg_set_param_max_transfer_size(core_if,
  352. dwc_otg_module_params.
  353. max_transfer_size);
  354. }
  355. if (dwc_otg_module_params.max_packet_count != -1) {
  356. retval +=
  357. dwc_otg_set_param_max_packet_count(core_if,
  358. dwc_otg_module_params.
  359. max_packet_count);
  360. }
  361. if (dwc_otg_module_params.host_channels != -1) {
  362. retval +=
  363. dwc_otg_set_param_host_channels(core_if,
  364. dwc_otg_module_params.
  365. host_channels);
  366. }
  367. if (dwc_otg_module_params.dev_endpoints != -1) {
  368. retval +=
  369. dwc_otg_set_param_dev_endpoints(core_if,
  370. dwc_otg_module_params.
  371. dev_endpoints);
  372. }
  373. if (dwc_otg_module_params.phy_type != -1) {
  374. retval +=
  375. dwc_otg_set_param_phy_type(core_if,
  376. dwc_otg_module_params.phy_type);
  377. }
  378. if (dwc_otg_module_params.speed != -1) {
  379. retval +=
  380. dwc_otg_set_param_speed(core_if,
  381. dwc_otg_module_params.speed);
  382. }
  383. if (dwc_otg_module_params.host_ls_low_power_phy_clk != -1) {
  384. retval +=
  385. dwc_otg_set_param_host_ls_low_power_phy_clk(core_if,
  386. dwc_otg_module_params.
  387. host_ls_low_power_phy_clk);
  388. }
  389. if (dwc_otg_module_params.phy_ulpi_ddr != -1) {
  390. retval +=
  391. dwc_otg_set_param_phy_ulpi_ddr(core_if,
  392. dwc_otg_module_params.
  393. phy_ulpi_ddr);
  394. }
  395. if (dwc_otg_module_params.phy_ulpi_ext_vbus != -1) {
  396. retval +=
  397. dwc_otg_set_param_phy_ulpi_ext_vbus(core_if,
  398. dwc_otg_module_params.
  399. phy_ulpi_ext_vbus);
  400. }
  401. if (dwc_otg_module_params.phy_utmi_width != -1) {
  402. retval +=
  403. dwc_otg_set_param_phy_utmi_width(core_if,
  404. dwc_otg_module_params.
  405. phy_utmi_width);
  406. }
  407. if (dwc_otg_module_params.ulpi_fs_ls != -1) {
  408. retval +=
  409. dwc_otg_set_param_ulpi_fs_ls(core_if,
  410. dwc_otg_module_params.ulpi_fs_ls);
  411. }
  412. if (dwc_otg_module_params.ts_dline != -1) {
  413. retval +=
  414. dwc_otg_set_param_ts_dline(core_if,
  415. dwc_otg_module_params.ts_dline);
  416. }
  417. if (dwc_otg_module_params.i2c_enable != -1) {
  418. retval +=
  419. dwc_otg_set_param_i2c_enable(core_if,
  420. dwc_otg_module_params.
  421. i2c_enable);
  422. }
  423. if (dwc_otg_module_params.en_multiple_tx_fifo != -1) {
  424. retval +=
  425. dwc_otg_set_param_en_multiple_tx_fifo(core_if,
  426. dwc_otg_module_params.
  427. en_multiple_tx_fifo);
  428. }
  429. for (i = 0; i < 15; i++) {
  430. if (dwc_otg_module_params.dev_perio_tx_fifo_size[i] != -1) {
  431. retval +=
  432. dwc_otg_set_param_dev_perio_tx_fifo_size(core_if,
  433. dwc_otg_module_params.
  434. dev_perio_tx_fifo_size
  435. [i], i);
  436. }
  437. }
  438. for (i = 0; i < 15; i++) {
  439. if (dwc_otg_module_params.dev_tx_fifo_size[i] != -1) {
  440. retval += dwc_otg_set_param_dev_tx_fifo_size(core_if,
  441. dwc_otg_module_params.
  442. dev_tx_fifo_size
  443. [i], i);
  444. }
  445. }
  446. if (dwc_otg_module_params.thr_ctl != -1) {
  447. retval +=
  448. dwc_otg_set_param_thr_ctl(core_if,
  449. dwc_otg_module_params.thr_ctl);
  450. }
  451. if (dwc_otg_module_params.mpi_enable != -1) {
  452. retval +=
  453. dwc_otg_set_param_mpi_enable(core_if,
  454. dwc_otg_module_params.
  455. mpi_enable);
  456. }
  457. if (dwc_otg_module_params.pti_enable != -1) {
  458. retval +=
  459. dwc_otg_set_param_pti_enable(core_if,
  460. dwc_otg_module_params.
  461. pti_enable);
  462. }
  463. if (dwc_otg_module_params.lpm_enable != -1) {
  464. retval +=
  465. dwc_otg_set_param_lpm_enable(core_if,
  466. dwc_otg_module_params.
  467. lpm_enable);
  468. }
  469. if (dwc_otg_module_params.ic_usb_cap != -1) {
  470. retval +=
  471. dwc_otg_set_param_ic_usb_cap(core_if,
  472. dwc_otg_module_params.
  473. ic_usb_cap);
  474. }
  475. if (dwc_otg_module_params.tx_thr_length != -1) {
  476. retval +=
  477. dwc_otg_set_param_tx_thr_length(core_if,
  478. dwc_otg_module_params.tx_thr_length);
  479. }
  480. if (dwc_otg_module_params.rx_thr_length != -1) {
  481. retval +=
  482. dwc_otg_set_param_rx_thr_length(core_if,
  483. dwc_otg_module_params.
  484. rx_thr_length);
  485. }
  486. if (dwc_otg_module_params.ahb_thr_ratio != -1) {
  487. retval +=
  488. dwc_otg_set_param_ahb_thr_ratio(core_if,
  489. dwc_otg_module_params.ahb_thr_ratio);
  490. }
  491. if (dwc_otg_module_params.power_down != -1) {
  492. retval +=
  493. dwc_otg_set_param_power_down(core_if,
  494. dwc_otg_module_params.power_down);
  495. }
  496. if (dwc_otg_module_params.reload_ctl != -1) {
  497. retval +=
  498. dwc_otg_set_param_reload_ctl(core_if,
  499. dwc_otg_module_params.reload_ctl);
  500. }
  501. if (dwc_otg_module_params.dev_out_nak != -1) {
  502. retval +=
  503. dwc_otg_set_param_dev_out_nak(core_if,
  504. dwc_otg_module_params.dev_out_nak);
  505. }
  506. if (dwc_otg_module_params.cont_on_bna != -1) {
  507. retval +=
  508. dwc_otg_set_param_cont_on_bna(core_if,
  509. dwc_otg_module_params.cont_on_bna);
  510. }
  511. if (dwc_otg_module_params.ahb_single != -1) {
  512. retval +=
  513. dwc_otg_set_param_ahb_single(core_if,
  514. dwc_otg_module_params.ahb_single);
  515. }
  516. if (dwc_otg_module_params.otg_ver != -1) {
  517. retval +=
  518. dwc_otg_set_param_otg_ver(core_if,
  519. dwc_otg_module_params.otg_ver);
  520. }
  521. if (dwc_otg_module_params.adp_enable != -1) {
  522. retval +=
  523. dwc_otg_set_param_adp_enable(core_if,
  524. dwc_otg_module_params.
  525. adp_enable);
  526. }
  527. return retval;
  528. }
  529. #define FORCE_ID_CLEAR -1
  530. #define FORCE_ID_HOST 0
  531. #define FORCE_ID_SLAVE 1
  532. #define FORCE_ID_ERROR 2
  533. static void dwc_otg_set_force_id(dwc_otg_core_if_t *core_if,int mode)
  534. {
  535. gusbcfg_data_t gusbcfg_data;
  536. gusbcfg_data.d32 = DWC_READ_REG32(&core_if->core_global_regs->gusbcfg);
  537. switch(mode){
  538. case FORCE_ID_CLEAR:
  539. gusbcfg_data.b.force_host_mode = 0;
  540. gusbcfg_data.b.force_dev_mode = 0;
  541. break;
  542. case FORCE_ID_HOST:
  543. gusbcfg_data.b.force_host_mode = 1;
  544. gusbcfg_data.b.force_dev_mode = 0;
  545. break;
  546. case FORCE_ID_SLAVE:
  547. gusbcfg_data.b.force_host_mode = 0;
  548. gusbcfg_data.b.force_dev_mode = 1;
  549. break;
  550. default:
  551. DWC_ERROR("error id mode\n");
  552. return;
  553. break;
  554. }
  555. DWC_WRITE_REG32(&core_if->core_global_regs->gusbcfg,gusbcfg_data.d32);
  556. return;
  557. }
  558. static void dwc_otg_id_change_timer_handler(void * parg)
  559. {
  560. dwc_otg_device_t *otg_dev = (dwc_otg_device_t *)parg;
  561. struct lm_device * lmdev = otg_dev->os_dep.lmdev;
  562. usb_peri_reg_t * phy_peri = (usb_peri_reg_t * )lmdev->param.usb.phy_tune_reg;
  563. usb_adp_bc_data_t adp_bc;
  564. unsigned long flags;
  565. //DWC_DEBUGPL(DBG_HCDV, "%s() %p\n", __func__, otg_dev);
  566. local_irq_save(flags);
  567. adp_bc.d32 = phy_peri->adp_bc;
  568. if(adp_bc.b.iddig){
  569. dwc_otg_set_force_id(otg_dev->core_if, FORCE_ID_SLAVE);
  570. }else{
  571. dwc_otg_set_force_id(otg_dev->core_if, FORCE_ID_HOST);
  572. }
  573. DWC_TIMER_SCHEDULE(otg_dev->id_change_timer, 100 /* 100 ms */);
  574. local_irq_restore(flags);
  575. return;
  576. }
  577. /**
  578. * This function is the top level interrupt handler for the Common
  579. * (Device and host modes) interrupts.
  580. */
  581. static irqreturn_t dwc_otg_common_irq(int irq, void *dev)
  582. {
  583. int32_t retval = IRQ_NONE;
  584. retval = dwc_otg_handle_common_intr(dev);
  585. if (retval != 0) {
  586. S3C2410X_CLEAR_EINTPEND();
  587. }
  588. return IRQ_RETVAL(retval);
  589. }
  590. /**
  591. * This function is called when a lm_device is unregistered with the
  592. * dwc_otg_driver. This happens, for example, when the rmmod command is
  593. * executed. The device may or may not be electrically present. If it is
  594. * present, the driver stops device processing. Any resources used on behalf
  595. * of this device are freed.
  596. *
  597. * @param _dev
  598. */
  599. static void dwc_otg_driver_remove(
  600. #ifdef LM_INTERFACE
  601. struct lm_device *_dev
  602. #elif defined(PCI_INTERFACE)
  603. struct pci_dev *_dev
  604. #endif
  605. )
  606. {
  607. #ifdef LM_INTERFACE
  608. dwc_otg_device_t *otg_dev = lm_get_drvdata(_dev);
  609. #elif defined(PCI_INTERFACE)
  610. dwc_otg_device_t *otg_dev = pci_get_drvdata(_dev);
  611. #endif
  612. DWC_DEBUGPL(DBG_ANY, "%s(%p)\n", __func__, _dev);
  613. if (!otg_dev) {
  614. /* Memory allocation for the dwc_otg_device failed. */
  615. DWC_DEBUGPL(DBG_ANY, "%s: otg_dev NULL!\n", __func__);
  616. return;
  617. }
  618. #ifndef DWC_DEVICE_ONLY
  619. if (otg_dev->hcd) {
  620. hcd_remove(_dev);
  621. } else {
  622. DWC_DEBUGPL(DBG_ANY, "%s: otg_dev->hcd NULL!\n", __func__);
  623. return;
  624. }
  625. #endif
  626. #ifndef DWC_HOST_ONLY
  627. if (otg_dev->pcd) {
  628. pcd_remove(_dev);
  629. } else {
  630. DWC_DEBUGPL(DBG_ANY, "%s: otg_dev->pcd NULL!\n", __func__);
  631. return;
  632. }
  633. #endif
  634. /*
  635. * Free the IRQ
  636. */
  637. if (otg_dev->common_irq_installed) {
  638. free_irq(_dev->irq, otg_dev);
  639. } else {
  640. DWC_DEBUGPL(DBG_ANY, "%s: There is no installed irq!\n", __func__);
  641. return;
  642. }
  643. if (otg_dev->core_if) {
  644. dwc_otg_cil_remove(otg_dev->core_if);
  645. } else {
  646. DWC_DEBUGPL(DBG_ANY, "%s: otg_dev->core_if NULL!\n", __func__);
  647. return;
  648. }
  649. if(otg_dev->id_change_timer)
  650. DWC_TIMER_FREE(otg_dev->id_change_timer);
  651. /*
  652. * Remove the device attributes
  653. */
  654. dwc_otg_attr_remove(_dev);
  655. /*
  656. * Return the memory.
  657. */
  658. if (otg_dev->os_dep.base) {
  659. iounmap(otg_dev->os_dep.base);
  660. }
  661. DWC_FREE(otg_dev);
  662. /*
  663. * Clear the drvdata pointer.
  664. */
  665. #ifdef LM_INTERFACE
  666. lm_set_drvdata(_dev, 0);
  667. #elif defined(PCI_INTERFACE)
  668. release_mem_region(otg_dev->os_dep.rsrc_start, otg_dev->os_dep.rsrc_len);
  669. pci_set_drvdata(_dev, 0);
  670. #endif
  671. }
  672. #ifdef CONFIG_HAS_EARLYSUSPEND
  673. extern int get_pcd_ums_state(dwc_otg_pcd_t *pcd);
  674. static void usb_early_suspend(struct early_suspend *h)
  675. {
  676. int is_mount = 0;
  677. dwc_otg_device_t *dwc_otg_device;
  678. dwc_otg_device = (dwc_otg_device_t *)h->param;
  679. is_mount = get_pcd_ums_state(dwc_otg_device->pcd);
  680. printk("DWC_OTG: going early suspend! is_mount=%d\n",is_mount);
  681. if (dwc_otg_is_device_mode(dwc_otg_device->core_if) && !is_mount) {
  682. DWC_MODIFY_REG32(&dwc_otg_device->core_if->dev_if->dev_global_regs->dctl, 0, 2);
  683. }
  684. }
  685. static void usb_early_resume(struct early_suspend *h)
  686. {
  687. dwc_otg_device_t *dwc_otg_device;
  688. printk("DWC_OTG: going early resume\n");
  689. dwc_otg_device = (dwc_otg_device_t *)h->param;
  690. if (dwc_otg_is_device_mode(dwc_otg_device->core_if)) {
  691. DWC_MODIFY_REG32(&dwc_otg_device->core_if->dev_if->dev_global_regs->dctl, 2, 0);
  692. }
  693. }
  694. #endif
  695. /**
  696. * This function is called when an lm_device is bound to a
  697. * dwc_otg_driver. It creates the driver components required to
  698. * control the device (CIL, HCD, and PCD) and it initializes the
  699. * device. The driver components are stored in a dwc_otg_device
  700. * structure. A reference to the dwc_otg_device is saved in the
  701. * lm_device. This allows the driver to access the dwc_otg_device
  702. * structure on subsequent calls to driver methods for this device.
  703. *
  704. * @param _dev Bus device
  705. */
  706. static int dwc_otg_driver_probe(
  707. #ifdef LM_INTERFACE
  708. struct lm_device *_dev
  709. #elif defined(PCI_INTERFACE)
  710. struct pci_dev *_dev,
  711. const struct pci_device_id *id
  712. #endif
  713. )
  714. {
  715. int retval = 0;
  716. int port_type, id_mode;
  717. int port_speed;
  718. int dma_config;
  719. dwc_otg_device_t *dwc_otg_device;
  720. struct dwc_otg_driver_module_params *pcore_para;
  721. dev_dbg(&_dev->dev, "dwc_otg_driver_probe(%p)\n", _dev);
  722. #ifdef LM_INTERFACE
  723. dev_dbg(&_dev->dev, "start=0x%08x\n", (unsigned)_dev->resource.start);
  724. #elif defined(PCI_INTERFACE)
  725. if (!id) {
  726. DWC_ERROR("Invalid pci_device_id %p", id);
  727. return -EINVAL;
  728. }
  729. if (!_dev || (pci_enable_device(_dev) < 0)) {
  730. DWC_ERROR("Invalid pci_device %p", _dev);
  731. return -ENODEV;
  732. }
  733. dev_dbg(&_dev->dev, "start=0x%08x\n", (unsigned)pci_resource_start(_dev,0));
  734. /* other stuff needed as well? */
  735. #endif
  736. dwc_otg_device = DWC_ALLOC(sizeof(dwc_otg_device_t));
  737. if (!dwc_otg_device) {
  738. dev_err(&_dev->dev, "kmalloc of dwc_otg_device failed\n");
  739. return -ENOMEM;
  740. }
  741. memset(dwc_otg_device, 0, sizeof(*dwc_otg_device));
  742. dwc_otg_device->os_dep.reg_offset = 0xFFFFFFFF;
  743. /*
  744. * Map the DWC_otg Core memory into virtual address space.
  745. */
  746. #ifdef LM_INTERFACE
  747. if(set_usb_phy_clk(_dev,1)){
  748. dev_err(&_dev->dev, "Set dwc_otg PHY clock failed!\n");
  749. return -ENODEV;
  750. }
  751. dwc_otg_device->os_dep.base = (void*)_dev->resource.start;
  752. //ioremap(_dev->resource.start, SZ_256K);
  753. if (!dwc_otg_device->os_dep.base) {
  754. dev_err(&_dev->dev, "ioremap() failed\n");
  755. DWC_FREE(dwc_otg_device);
  756. return -ENOMEM;
  757. }
  758. dev_dbg(&_dev->dev, "base=0x%08x\n",
  759. (unsigned)dwc_otg_device->os_dep.base);
  760. #elif defined(PCI_INTERFACE)
  761. _dev->current_state = PCI_D0;
  762. _dev->dev.power.power_state = PMSG_ON;
  763. if (!_dev->irq) {
  764. DWC_ERROR("Found HC with no IRQ. Check BIOS/PCI %s setup!",
  765. pci_name(_dev));
  766. iounmap(dwc_otg_device->os_dep.base);
  767. DWC_FREE(dwc_otg_device);
  768. return -ENODEV;
  769. }
  770. dwc_otg_device->os_dep.rsrc_start = pci_resource_start(_dev, 0);
  771. dwc_otg_device->os_dep.rsrc_len = pci_resource_len(_dev, 0);
  772. DWC_DEBUGPL(DBG_ANY, "PCI resource: start=%08x, len=%08x\n",
  773. (unsigned)dwc_otg_device->os_dep.rsrc_start,
  774. (unsigned)dwc_otg_device->os_dep.rsrc_len);
  775. if (!request_mem_region
  776. (dwc_otg_device->os_dep.rsrc_start, dwc_otg_device->os_dep.rsrc_len,
  777. "dwc_otg")) {
  778. dev_dbg(&_dev->dev, "error requesting memory\n");
  779. iounmap(dwc_otg_device->os_dep.base);
  780. DWC_FREE(dwc_otg_device);
  781. return -EFAULT;
  782. }
  783. dwc_otg_device->os_dep.base =
  784. ioremap_nocache(dwc_otg_device->os_dep.rsrc_start,
  785. dwc_otg_device->os_dep.rsrc_len);
  786. if (dwc_otg_device->os_dep.base == NULL) {
  787. dev_dbg(&_dev->dev, "error mapping memory\n");
  788. release_mem_region(dwc_otg_device->os_dep.rsrc_start,
  789. dwc_otg_device->os_dep.rsrc_len);
  790. iounmap(dwc_otg_device->os_dep.base);
  791. DWC_FREE(dwc_otg_device);
  792. return -EFAULT;
  793. }
  794. dev_dbg(&_dev->dev, "base=0x%p (before adjust) \n",
  795. dwc_otg_device->os_dep.base);
  796. dwc_otg_device->os_dep.base = (char *)dwc_otg_device->os_dep.base;
  797. dev_dbg(&_dev->dev, "base=0x%p (after adjust) \n",
  798. dwc_otg_device->os_dep.base);
  799. dev_dbg(&_dev->dev, "%s: mapped PA 0x%x to VA 0x%p\n", __func__,
  800. (unsigned)dwc_otg_device->os_dep.rsrc_start,
  801. dwc_otg_device->os_dep.base);
  802. pci_set_master(_dev);
  803. pci_set_drvdata(_dev, dwc_otg_device);
  804. #endif
  805. /*
  806. * Initialize driver data to point to the global DWC_otg
  807. * Device structure.
  808. */
  809. #ifdef LM_INTERFACE
  810. lm_set_drvdata(_dev, dwc_otg_device);
  811. dwc_otg_device->os_dep.lmdev = _dev;
  812. #elif defined(PCI_INTERFACE)
  813. pci_set_drvdata(_dev, dwc_otg_device);
  814. dwc_otg_device->os_dep.pcidev = _dev;
  815. #endif
  816. port_type = _dev->param.usb.port_type;
  817. port_speed = _dev->param.usb.port_speed;
  818. dma_config = _dev->param.usb.dma_config;
  819. pcore_para = &dwc_otg_module_params;
  820. dev_dbg(&_dev->dev, "dwc_otg_device=0x%p\n", dwc_otg_device);
  821. dwc_otg_device->core_if = dwc_otg_cil_init(dwc_otg_device->os_dep.base);
  822. if (!dwc_otg_device->core_if) {
  823. dev_err(&_dev->dev, "CIL initialization failed!\n");
  824. retval = -ENOMEM;
  825. goto fail;
  826. }
  827. dwc_otg_device->core_if->usb_peri_reg = (usb_peri_reg_t *)_dev->param.usb.phy_tune_reg;
  828. /*
  829. * Attempt to ensure this device is really a DWC_otg Controller.
  830. * Read and verify the SNPSID register contents. The value should be
  831. * 0x45F42XXX, which corresponds to "OT2", as in "OTG version 2.XX".
  832. */
  833. if ((dwc_otg_get_gsnpsid(dwc_otg_device->core_if) & 0xFFFFF000) !=
  834. 0x4F542000) {
  835. dev_err(&_dev->dev, "Bad value for SNPSID: 0x%08x\n",
  836. dwc_otg_get_gsnpsid(dwc_otg_device->core_if));
  837. retval = -EINVAL;
  838. goto fail;
  839. }
  840. dev_dbg(&_dev->dev,"DMA config: %s\n",dma_config_name[dma_config]);
  841. if (dma_config == USB_DMA_DISABLE) {
  842. pcore_para->dma_enable = 0;
  843. _dev->dev.coherent_dma_mask = 0;
  844. _dev->dev.dma_mask = 0;
  845. } else {
  846. _dev->dev.dma_mask = &_dev->dma_mask_room;
  847. _dev->dev.coherent_dma_mask = *_dev->dev.dma_mask;
  848. //printk("_lmdev->dev.dma_mask %p (%llX)\n",_lmdev->dev.dma_mask,*_lmdev->dev.dma_mask);
  849. switch (dma_config) {
  850. case USB_DMA_BURST_INCR:
  851. pcore_para->dma_burst_size =
  852. DWC_GAHBCFG_INT_DMA_BURST_INCR;
  853. break;
  854. case USB_DMA_BURST_INCR4:
  855. pcore_para->dma_burst_size =
  856. DWC_GAHBCFG_INT_DMA_BURST_INCR4;
  857. break;
  858. case USB_DMA_BURST_INCR8:
  859. pcore_para->dma_burst_size =
  860. DWC_GAHBCFG_INT_DMA_BURST_INCR8;
  861. break;
  862. case USB_DMA_BURST_INCR16:
  863. pcore_para->dma_burst_size =
  864. DWC_GAHBCFG_INT_DMA_BURST_INCR16;
  865. break;
  866. case USB_DMA_BURST_SINGLE:
  867. pcore_para->dma_burst_size =
  868. DWC_GAHBCFG_INT_DMA_BURST_SINGLE;
  869. break;
  870. default:
  871. pcore_para->dma_burst_size =
  872. DWC_GAHBCFG_INT_DMA_BURST_INCR4;
  873. break;
  874. }
  875. }
  876. /*
  877. * Validate parameter values.
  878. */
  879. if (set_parameters(dwc_otg_device->core_if)) {
  880. retval = -EINVAL;
  881. goto fail;
  882. }
  883. /*
  884. * Create Device Attributes in sysfs
  885. */
  886. dwc_otg_attr_create(_dev);
  887. /*
  888. * Disable the global interrupt until all the interrupt
  889. * handlers are installed.
  890. */
  891. dwc_otg_disable_global_interrupts(dwc_otg_device->core_if);
  892. /*
  893. * Install the interrupt handler for the common interrupts before
  894. * enabling common interrupts in core_init below.
  895. */
  896. DWC_DEBUGPL(DBG_CIL, "registering (common) handler for irq%d\n",
  897. _dev->irq);
  898. retval = request_irq(_dev->irq, dwc_otg_common_irq,
  899. IRQF_SHARED | IRQF_DISABLED | IRQ_LEVEL, "dwc_otg",
  900. dwc_otg_device);
  901. if (retval) {
  902. DWC_ERROR("request of irq%d failed\n", _dev->irq);
  903. retval = -EBUSY;
  904. goto fail;
  905. } else {
  906. dwc_otg_device->common_irq_installed = 1;
  907. }
  908. #ifdef LM_INTERFACE
  909. // set_irq_type(_dev->irq, IRQT_LOW);
  910. #endif
  911. switch(port_type){
  912. case USB_PORT_TYPE_OTG:
  913. id_mode = FORCE_ID_CLEAR;
  914. break;
  915. case USB_PORT_TYPE_HOST:
  916. id_mode = FORCE_ID_HOST;
  917. break;
  918. case USB_PORT_TYPE_SLAVE:
  919. id_mode = FORCE_ID_SLAVE;
  920. break;
  921. default:
  922. id_mode = FORCE_ID_ERROR;
  923. break;
  924. }
  925. dwc_otg_set_force_id(dwc_otg_device->core_if,id_mode);
  926. /*
  927. * Initialize the DWC_otg core.
  928. */
  929. dwc_otg_core_init(dwc_otg_device->core_if);
  930. /*
  931. * Set VBus Power CallBack
  932. */
  933. dwc_otg_device->core_if->set_vbus_power = _dev->param.usb.set_vbus_power;
  934. if (port_type == USB_PORT_TYPE_HOST) {
  935. /*
  936. * Initialize the HCD
  937. */
  938. printk("Working on port type = HOST\n");
  939. if (!dwc_otg_is_host_mode(dwc_otg_device->core_if)) {
  940. printk
  941. ("Chip mode not match! -- Want HOST mode but not. --\n");
  942. goto fail;
  943. }
  944. retval = hcd_init(_dev);
  945. if (retval != 0) {
  946. DWC_ERROR("hcd_init failed\n");
  947. dwc_otg_device->hcd = NULL;
  948. goto fail;
  949. }
  950. } else if (port_type == USB_PORT_TYPE_SLAVE) {
  951. /*
  952. * Initialize the PCD
  953. */
  954. printk("Working on port type = SLAVE\n");
  955. if (!dwc_otg_is_device_mode(dwc_otg_device->core_if)) {
  956. DWC_ERROR
  957. ("Chip mode not match! -- Want Device mode but not. --\n");
  958. goto fail;
  959. }
  960. dwc_otg_device->core_if->charger_detect_cb = _dev->param.usb.charger_detect_cb;
  961. retval = pcd_init(_dev);
  962. if (retval != 0) {
  963. DWC_ERROR("pcd_init failed\n");
  964. dwc_otg_device->pcd = NULL;
  965. goto fail;
  966. }
  967. }
  968. else if (port_type == USB_PORT_TYPE_OTG) {
  969. printk("Working on port type = OTG\n");
  970. printk("Current port type: %s\n",
  971. dwc_otg_is_host_mode(dwc_otg_device->core_if)?"HOST":"SLAVE");
  972. retval = hcd_init(_dev);
  973. if (retval != 0) {
  974. DWC_ERROR("hcd_init failed(in otg mode)\n");
  975. dwc_otg_device->hcd = NULL;
  976. goto fail;
  977. }
  978. dwc_otg_device->core_if->charger_detect_cb = _dev->param.usb.charger_detect_cb;
  979. retval = pcd_init(_dev);
  980. if (retval != 0) {
  981. DWC_ERROR("pcd_init failed(in otg mode)\n");
  982. dwc_otg_device->pcd = NULL;
  983. goto fail;
  984. }
  985. if(!dwc_otg_get_param_adp_enable(dwc_otg_device->core_if)){
  986. DWC_PRINTF("using timer detect id change, %p\n",dwc_otg_device->core_if);
  987. dwc_otg_device->id_change_timer = DWC_TIMER_ALLOC("ID change timer",
  988. dwc_otg_id_change_timer_handler,dwc_otg_device);
  989. DWC_TIMER_SCHEDULE(dwc_otg_device->id_change_timer, 0);
  990. }
  991. }
  992. else {
  993. DWC_ERROR("can't config as right mode\n");
  994. goto fail;
  995. }
  996. dwc_otg_save_global_regs(dwc_otg_device->core_if);
  997. /*
  998. * Enable the global interrupt after all the interrupt
  999. * handlers are installed if there is no ADP support else
  1000. * perform initial actions required for Internal ADP logic.
  1001. */
  1002. if(port_type == USB_PORT_TYPE_OTG){
  1003. if (!dwc_otg_get_param_adp_enable(dwc_otg_device->core_if))
  1004. dwc_otg_enable_global_interrupts(dwc_otg_device->core_if);
  1005. else
  1006. dwc_otg_adp_start(dwc_otg_device->core_if,
  1007. dwc_otg_is_host_mode(dwc_otg_device->core_if));
  1008. }else{
  1009. dwc_otg_enable_global_interrupts(dwc_otg_device->core_if);
  1010. }
  1011. #ifdef CONFIG_HAS_EARLYSUSPEND
  1012. dwc_otg_device->usb_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
  1013. dwc_otg_device->usb_early_suspend.suspend = usb_early_suspend;
  1014. dwc_otg_device->usb_early_suspend.resume = usb_early_resume;
  1015. dwc_otg_device->usb_early_suspend.param = dwc_otg_device;
  1016. register_early_suspend(&dwc_otg_device->usb_early_suspend);
  1017. #endif
  1018. return 0;
  1019. fail:
  1020. dwc_otg_driver_remove(_dev);
  1021. return retval;
  1022. }
  1023. /**
  1024. * This structure defines the methods to be called by a bus driver
  1025. * during the lifecycle of a device on that bus. Both drivers and
  1026. * devices are registered with a bus driver. The bus driver matches
  1027. * devices to drivers based on information in the device and driver
  1028. * structures.
  1029. *
  1030. * The probe function is called when the bus driver matches a device
  1031. * to this driver. The remove function is called when a device is
  1032. * unregistered with the bus driver.
  1033. */
  1034. #ifdef LM_INTERFACE
  1035. static struct lm_driver dwc_otg_driver = {
  1036. .drv = {.name = (char *)dwc_driver_name,},
  1037. .probe = dwc_otg_driver_probe,
  1038. .remove = dwc_otg_driver_remove,
  1039. };
  1040. #elif defined(PCI_INTERFACE)
  1041. static const struct pci_device_id pci_ids[] = { {
  1042. PCI_DEVICE(0x16c3, 0xabcd),
  1043. .driver_data =
  1044. (unsigned long)0xdeadbeef,
  1045. }, { /* end: all zeroes */ }
  1046. };
  1047. MODULE_DEVICE_TABLE(pci, pci_ids);
  1048. /* pci driver glue; this is a "new style" PCI driver module */
  1049. static struct pci_driver dwc_otg_driver = {
  1050. .name = "dwc_otg",
  1051. .id_table = pci_ids,
  1052. .probe = dwc_otg_driver_probe,
  1053. .remove = dwc_otg_driver_remove,
  1054. .driver = {
  1055. .name = (char *)dwc_driver_name,
  1056. },
  1057. };
  1058. #endif
  1059. /**
  1060. * This function is called when the dwc_otg_driver is installed with the
  1061. * insmod command. It registers the dwc_otg_driver structure with the
  1062. * appropriate bus driver. This will cause the dwc_otg_driver_probe function
  1063. * to be called. In addition, the bus driver will automatically expose
  1064. * attributes defined for the device and driver in the special sysfs file
  1065. * system.
  1066. *
  1067. * @return
  1068. */
  1069. static int __init dwc_otg_driver_init(void)
  1070. {
  1071. int retval = 0;
  1072. int error;
  1073. printk(KERN_INFO "%s: version %s\n", dwc_driver_name,
  1074. DWC_DRIVER_VERSION);
  1075. #ifdef LM_INTERFACE
  1076. retval = lm_driver_register(&dwc_otg_driver);
  1077. #elif defined(PCI_INTERFACE)
  1078. retval = pci_register_driver(&dwc_otg_driver);
  1079. #endif
  1080. if (retval < 0) {
  1081. printk(KERN_ERR "%s retval=%d\n", __func__, retval);
  1082. return retval;
  1083. }
  1084. #ifdef LM_INTERFACE
  1085. error = driver_create_file(&dwc_otg_driver.drv, &driver_attr_version);
  1086. error = driver_create_file(&dwc_otg_driver.drv, &driver_attr_debuglevel);
  1087. #elif defined(PCI_INTERFACE)
  1088. error = driver_create_file(&dwc_otg_driver.driver, &driver_attr_version);
  1089. error = driver_create_file(&dwc_otg_driver.driver, &driver_attr_debuglevel);
  1090. #endif
  1091. return retval;
  1092. }
  1093. module_init(dwc_otg_driver_init);
  1094. /**
  1095. * This function is called when the driver is removed from the kernel
  1096. * with the rmmod command. The driver unregisters itself with its bus
  1097. * driver.
  1098. *
  1099. */
  1100. static void __exit dwc_otg_driver_cleanup(void)
  1101. {
  1102. printk(KERN_DEBUG "dwc_otg_driver_cleanup()\n");
  1103. #ifdef LM_INTERFACE
  1104. driver_remove_file(&dwc_otg_driver.drv, &driver_attr_debuglevel);
  1105. driver_remove_file(&dwc_otg_driver.drv, &driver_attr_version);
  1106. lm_driver_unregister(&dwc_otg_driver);
  1107. #elif defined(PCI_INTERFACE)
  1108. driver_remove_file(&dwc_otg_driver.driver, &driver_attr_debuglevel);
  1109. driver_remove_file(&dwc_otg_driver.driver, &driver_attr_version);
  1110. pci_unregister_driver(&dwc_otg_driver);
  1111. #endif
  1112. printk(KERN_INFO "%s module removed\n", dwc_driver_name);
  1113. }
  1114. module_exit(dwc_otg_driver_cleanup);
  1115. MODULE_DESCRIPTION(DWC_DRIVER_DESC);
  1116. MODULE_AUTHOR("Synopsys Inc.");
  1117. MODULE_LICENSE("GPL");
  1118. module_param_named(otg_cap, dwc_otg_module_params.otg_cap, int, 0444);
  1119. MODULE_PARM_DESC(otg_cap, "OTG Capabilities 0=HNP&SRP 1=SRP Only 2=None");
  1120. module_param_named(opt, dwc_otg_module_params.opt, int, 0444);
  1121. MODULE_PARM_DESC(opt, "OPT Mode");
  1122. module_param_named(dma_enable, dwc_otg_module_params.dma_enable, int, 0444);
  1123. MODULE_PARM_DESC(dma_enable, "DMA Mode 0=Slave 1=DMA enabled");
  1124. module_param_named(dma_desc_enable, dwc_otg_module_params.dma_desc_enable, int,
  1125. 0444);
  1126. MODULE_PARM_DESC(dma_desc_enable,
  1127. "DMA Desc Mode 0=Address DMA 1=DMA Descriptor enabled");
  1128. module_param_named(dma_burst_size, dwc_otg_module_params.dma_burst_size, int,
  1129. 0444);
  1130. MODULE_PARM_DESC(dma_burst_size,
  1131. "DMA Burst Size 1, 4, 8, 16, 32, 64, 128, 256");
  1132. module_param_named(speed, dwc_otg_module_params.speed, int, 0444);
  1133. MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed");
  1134. module_param_named(host_support_fs_ls_low_power,
  1135. dwc_otg_module_params.host_support_fs_ls_low_power, int,
  1136. 0444);
  1137. MODULE_PARM_DESC(host_support_fs_ls_low_power,
  1138. "Support Low Power w/FS or LS 0=Support 1=Don't Support");
  1139. module_param_named(host_ls_low_power_phy_clk,
  1140. dwc_otg_module_params.host_ls_low_power_phy_clk, int, 0444);
  1141. MODULE_PARM_DESC(host_ls_low_power_phy_clk,
  1142. "Low Speed Low Power Clock 0=48Mhz 1=6Mhz");
  1143. module_param_named(enable_dynamic_fifo,
  1144. dwc_otg_module_params.enable_dynamic_fifo, int, 0444);
  1145. MODULE_PARM_DESC(enable_dynamic_fifo, "0=cC Setting 1=Allow Dynamic Sizing");
  1146. module_param_named(data_fifo_size, dwc_otg_module_params.data_fifo_size, int,
  1147. 0444);
  1148. MODULE_PARM_DESC(data_fifo_size,
  1149. "Total number of words in the data FIFO memory 32-32768");
  1150. module_param_named(dev_rx_fifo_size, dwc_otg_module_params.dev_rx_fifo_size,
  1151. int, 0444);
  1152. MODULE_PARM_DESC(dev_rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
  1153. module_param_named(dev_nperio_tx_fifo_size,
  1154. dwc_otg_module_params.dev_nperio_tx_fifo_size, int, 0444);
  1155. MODULE_PARM_DESC(dev_nperio_tx_fifo_size,
  1156. "Number of words in the non-periodic Tx FIFO 16-32768");
  1157. module_param_named(dev_perio_tx_fifo_size_1,
  1158. dwc_otg_module_params.dev_perio_tx_fifo_size[0], int, 0444);
  1159. MODULE_PARM_DESC(dev_perio_tx_fifo_size_1,
  1160. "Number of words in the periodic Tx FIFO 4-768");
  1161. module_param_named(dev_perio_tx_fifo_size_2,
  1162. dwc_otg_module_params.dev_perio_tx_fifo_size[1], int, 0444);
  1163. MODULE_PARM_DESC(dev_perio_tx_fifo_size_2,
  1164. "Number of words in the periodic Tx FIFO 4-768");
  1165. module_param_named(dev_perio_tx_fifo_size_3,
  1166. dwc_otg_module_params.dev_perio_tx_fifo_size[2], int, 0444);
  1167. MODULE_PARM_DESC(dev_perio_tx_fifo_size_3,
  1168. "Number of words in the periodic Tx FIFO 4-768");
  1169. module_param_named(dev_perio_tx_fifo_size_4,
  1170. dwc_otg_module_params.dev_perio_tx_fifo_size[3], int, 0444);
  1171. MODULE_PARM_DESC(dev_perio_tx_fifo_size_4,
  1172. "Number of words in the periodic Tx FIFO 4-768");
  1173. module_param_named(dev_perio_tx_fifo_size_5,
  1174. dwc_otg_module_params.dev_perio_tx_fifo_size[4], int, 0444);
  1175. MODULE_PARM_DESC(dev_perio_tx_fifo_size_5,
  1176. "Number of words in the periodic Tx FIFO 4-768");
  1177. module_param_named(dev_perio_tx_fifo_size_6,
  1178. dwc_otg_module_params.dev_perio_tx_fifo_size[5], int, 0444);
  1179. MODULE_PARM_DESC(dev_perio_tx_fifo_size_6,
  1180. "Number of words in the periodic Tx FIFO 4-768");
  1181. module_param_named(dev_perio_tx_fifo_size_7,
  1182. dwc_otg_module_params.dev_perio_tx_fifo_size[6], int, 0444);
  1183. MODULE_PARM_DESC(dev_perio_tx_fifo_size_7,
  1184. "Number of words in the periodic Tx FIFO 4-768");
  1185. module_param_named(dev_perio_tx_fifo_size_8,
  1186. dwc_otg_module_params.dev_perio_tx_fifo_size[7], int, 0444);
  1187. MODULE_PARM_DESC(dev_perio_tx_fifo_size_8,
  1188. "Number of words in the periodic Tx FIFO 4-768");
  1189. module_param_named(dev_perio_tx_fifo_size_9,
  1190. dwc_otg_module_params.dev_perio_tx_fifo_size[8], int, 0444);
  1191. MODULE_PARM_DESC(dev_perio_tx_fifo_size_9,
  1192. "Number of words in the periodic Tx FIFO 4-768");
  1193. module_param_named(dev_perio_tx_fifo_size_10,
  1194. dwc_otg_module_params.dev_perio_tx_fifo_size[9], int, 0444);
  1195. MODULE_PARM_DESC(dev_perio_tx_fifo_size_10,
  1196. "Number of words in the periodic Tx FIFO 4-768");
  1197. module_param_named(dev_perio_tx_fifo_size_11,
  1198. dwc_otg_module_params.dev_perio_tx_fifo_size[10], int, 0444);
  1199. MODULE_PARM_DESC(dev_perio_tx_fifo_size_11,
  1200. "Number of words in the periodic Tx FIFO 4-768");
  1201. module_param_named(dev_perio_tx_fifo_size_12,
  1202. dwc_otg_module_params.dev_perio_tx_fifo_size[11], int, 0444);
  1203. MODULE_PARM_DESC(dev_perio_tx_fifo_size_12,
  1204. "Number of words in the periodic Tx FIFO 4-768");
  1205. module_param_named(dev_perio_tx_fifo_size_13,
  1206. dwc_otg_module_params.dev_perio_tx_fifo_size[12], int, 0444);
  1207. MODULE_PARM_DESC(dev_perio_tx_fifo_size_13,
  1208. "Number of words in the periodic Tx FIFO 4-768");
  1209. module_param_named(dev_perio_tx_fifo_size_14,
  1210. dwc_otg_module_params.dev_perio_tx_fifo_size[13], int, 0444);
  1211. MODULE_PARM_DESC(dev_perio_tx_fifo_size_14,
  1212. "Number of words in the periodic Tx FIFO 4-768");
  1213. module_param_named(dev_perio_tx_fifo_size_15,
  1214. dwc_otg_module_params.dev_perio_tx_fifo_size[14], int, 0444);
  1215. MODULE_PARM_DESC(dev_perio_tx_fifo_size_15,
  1216. "Number of words in the periodic Tx FIFO 4-768");
  1217. module_param_named(host_rx_fifo_size, dwc_otg_module_params.host_rx_fifo_size,
  1218. int, 0444);
  1219. MODULE_PARM_DESC(host_rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
  1220. module_param_named(host_nperio_tx_fifo_size,
  1221. dwc_otg_module_params.host_nperio_tx_fifo_size, int, 0444);
  1222. MODULE_PARM_DESC(host_nperio_tx_fifo_size,
  1223. "Number of words in the non-periodic Tx FIFO 16-32768");
  1224. module_param_named(host_perio_tx_fifo_size,
  1225. dwc_otg_module_params.host_perio_tx_fifo_size, int, 0444);
  1226. MODULE_PARM_DESC(host_perio_tx_fifo_size,
  1227. "Number of words in the host periodic Tx FIFO 16-32768");
  1228. module_param_named(max_transfer_size, dwc_otg_module_params.max_transfer_size,
  1229. int, 0444);
  1230. /** @todo Set the max to 512K, modify checks */
  1231. MODULE_PARM_DESC(max_transfer_size,
  1232. "The maximum transfer size supported in bytes 2047-65535");
  1233. module_param_named(max_packet_count, dwc_otg_module_params.max_packet_count,
  1234. int, 0444);
  1235. MODULE_PARM_DESC(max_packet_count,
  1236. "The maximum number of packets in a transfer 15-511");
  1237. module_param_named(host_channels, dwc_otg_module_params.host_channels, int,
  1238. 0444);
  1239. MODULE_PARM_DESC(host_channels,
  1240. "The number of host channel registers to use 1-16");
  1241. module_param_named(dev_endpoints, dwc_otg_module_params.dev_endpoints, int,
  1242. 0444);
  1243. MODULE_PARM_DESC(dev_endpoints,
  1244. "The number of endpoints in addition to EP0 available for device mode 1-15");
  1245. module_param_named(phy_type, dwc_otg_module_params.phy_type, int, 0444);
  1246. MODULE_PARM_DESC(phy_type, "0=Reserved 1=UTMI+ 2=ULPI");
  1247. module_param_named(phy_utmi_width, dwc_otg_module_params.phy_utmi_width, int,
  1248. 0444);
  1249. MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits");
  1250. module_param_named(phy_ulpi_ddr, dwc_otg_module_params.phy_ulpi_ddr, int, 0444);
  1251. MODULE_PARM_DESC(phy_ulpi_ddr,
  1252. "ULPI at double or single data rate 0=Single 1=Double");
  1253. module_param_named(phy_ulpi_ext_vbus, dwc_otg_module_params.phy_ulpi_ext_vbus,
  1254. int, 0444);
  1255. MODULE_PARM_DESC(phy_ulpi_ext_vbus,
  1256. "ULPI PHY using internal or external vbus 0=Internal");
  1257. module_param_named(i2c_enable, dwc_otg_module_params.i2c_enable, int, 0444);
  1258. MODULE_PARM_DESC(i2c_enable, "FS PHY Interface");
  1259. module_param_named(ulpi_fs_ls, dwc_otg_module_params.ulpi_fs_ls, int, 0444);
  1260. MODULE_PARM_DESC(ulpi_fs_ls, "ULPI PHY FS/LS mode only");
  1261. module_param_named(ts_dline, dwc_otg_module_params.ts_dline, int, 0444);
  1262. MODULE_PARM_DESC(ts_dline, "Term select Dline pulsing for all PHYs");
  1263. module_param_named(debug, g_dbg_lvl, int, 0444);
  1264. MODULE_PARM_DESC(debug, "");
  1265. module_param_named(en_multiple_tx_fifo,
  1266. dwc_otg_module_params.en_multiple_tx_fifo, int, 0444);
  1267. MODULE_PARM_DESC(en_multiple_tx_fifo,
  1268. "Dedicated Non Periodic Tx FIFOs 0=disabled 1=enabled");
  1269. module_param_named(dev_tx_fifo_size_1,
  1270. dwc_otg_module_params.dev_tx_fifo_size[0], int, 0444);
  1271. MODULE_PARM_DESC(dev_tx_fifo_size_1, "Number of words in the Tx FIFO 4-768");
  1272. module_param_named(dev_tx_fifo_size_2,
  1273. dwc_otg_module_params.dev_tx_fifo_size[1], int, 0444);
  1274. MODULE_PARM_DESC(dev_tx_fifo_size_2, "Number of words in the Tx FIFO 4-768");
  1275. module_param_named(dev_tx_fifo_size_3,
  1276. dwc_otg_module_params.dev_tx_fifo_size[2], int, 0444);
  1277. MODULE_PARM_DESC(dev_tx_fifo_size_3, "Number of words in the Tx FIFO 4-768");
  1278. module_param_named(dev_tx_fifo_size_4,
  1279. dwc_otg_module_params.dev_tx_fifo_size[3], int, 0444);
  1280. MODULE_PARM_DESC(dev_tx_fifo_size_4, "Number of words in the Tx FIFO 4-768");
  1281. module_param_named(dev_tx_fifo_size_5,
  1282. dwc_otg_module_params.dev_tx_fifo_size[4], int, 0444);
  1283. MODULE_PARM_DESC(dev_tx_fifo_size_5, "Number of words in the Tx FIFO 4-768");
  1284. module_param_named(dev_tx_fifo_size_6,
  1285. dwc_otg_module_params.dev_tx_fifo_size[5], int, 0444);
  1286. MODULE_PARM_DESC(dev_tx_fifo_size_6, "Number of words in the Tx FIFO 4-768");
  1287. module_param_named(dev_tx_fifo_size_7,
  1288. dwc_otg_module_params.dev_tx_fifo_size[6], int, 0444);
  1289. MODULE_PARM_DESC(dev_tx_fifo_size_7, "Number of words in the Tx FIFO 4-768");
  1290. module_param_named(dev_tx_fifo_size_8,
  1291. dwc_otg_module_params.dev_tx_fifo_size[7], int, 0444);
  1292. MODULE_PARM_DESC(dev_tx_fifo_size_8, "Number of words in the Tx FIFO 4-768");
  1293. module_param_named(dev_tx_fifo_size_9,
  1294. dwc_otg_module_params.dev_tx_fifo_size[8], int, 0444);
  1295. MODULE_PARM_DESC(dev_tx_fifo_size_9, "Number of words in the Tx FIFO 4-768");
  1296. module_param_named(dev_tx_fifo_size_10,
  1297. dwc_otg_module_params.dev_tx_fifo_size[9], int, 0444);
  1298. MODULE_PARM_DESC(dev_tx_fifo_size_10, "Number of words in the Tx FIFO 4-768");
  1299. module_param_named(dev_tx_fifo_size_11,
  1300. dwc_otg_module_params.dev_tx_fifo_size[10], int, 0444);
  1301. MODULE_PARM_DESC(dev_tx_fifo_size_11, "Number of words in the Tx FIFO 4-768");
  1302. module_param_named(dev_tx_fifo_size_12,
  1303. dwc_otg_module_params.dev_tx_fifo_size[11], int, 0444);
  1304. MODULE_PARM_DESC(dev_tx_fifo_size_12, "Number of words in the Tx FIFO 4-768");
  1305. module_param_named(dev_tx_fifo_size_13,
  1306. dwc_otg_module_params.dev_tx_fifo_size[12], int, 0444);
  1307. MODULE_PARM_DESC(dev_tx_fifo_size_13, "Number of words in the Tx FIFO 4-768");
  1308. module_param_named(dev_tx_fifo_size_14,
  1309. dwc_otg_module_params.dev_tx_fifo_size[13], int, 0444);
  1310. MODULE_PARM_DESC(dev_tx_fifo_size_14, "Number of words in the Tx FIFO 4-768");
  1311. module_param_named(dev_tx_fifo_size_15,
  1312. dwc_otg_module_params.dev_tx_fifo_size[14], int, 0444);
  1313. MODULE_PARM_DESC(dev_tx_fifo_size_15, "Number of words in the Tx FIFO 4-768");
  1314. module_param_named(thr_ctl, dwc_otg_module_params.thr_ctl, int, 0444);
  1315. MODULE_PARM_DESC(thr_ctl,
  1316. "Thresholding enable flag bit 0 - non ISO Tx thr., 1 - ISO Tx thr., 2 - Rx thr.- bit 0=disabled 1=enabled");
  1317. module_param_named(tx_thr_length, dwc_otg_module_params.tx_thr_length, int,
  1318. 0444);
  1319. MODULE_PARM_DESC(tx_thr_length, "Tx Threshold length in 32 bit DWORDs");
  1320. module_param_named(rx_thr_length, dwc_otg_module_params.rx_thr_length, int,
  1321. 0444);
  1322. MODULE_PARM_DESC(rx_thr_length, "Rx Threshold length in 32 bit DWORDs");
  1323. module_param_named(pti_enable, dwc_otg_module_params.pti_enable, int, 0444);
  1324. module_param_named(mpi_enable, dwc_otg_module_params.mpi_enable, int, 0444);
  1325. module_param_named(lpm_enable, dwc_otg_module_params.lpm_enable, int, 0444);
  1326. MODULE_PARM_DESC(lpm_enable, "LPM Enable 0=LPM Disabled 1=LPM Enabled");
  1327. module_param_named(ic_usb_cap, dwc_otg_module_params.ic_usb_cap, int, 0444);
  1328. MODULE_PARM_DESC(ic_usb_cap,
  1329. "IC_USB Capability 0=IC_USB Disabled 1=IC_USB Enabled");
  1330. module_param_named(ahb_thr_ratio, dwc_otg_module_params.ahb_thr_ratio, int,
  1331. 0444);
  1332. MODULE_PARM_DESC(ahb_thr_ratio, "AHB Threshold Ratio");
  1333. module_param_named(power_down, dwc_otg_module_params.power_down, int, 0444);
  1334. MODULE_PARM_DESC(power_down, "Power Down Mode");
  1335. module_param_named(reload_ctl, dwc_otg_module_params.reload_ctl, int, 0444);
  1336. MODULE_PARM_DESC(reload_ctl, "HFIR Reload Control");
  1337. module_param_named(dev_out_nak, dwc_otg_module_params.dev_out_nak, int, 0444);
  1338. MODULE_PARM_DESC(dev_out_nak, "Enable Device OUT NAK");
  1339. module_param_named(cont_on_bna, dwc_otg_module_params.cont_on_bna, int, 0444);
  1340. MODULE_PARM_DESC(cont_on_bna, "Enable Enable Continue on BNA");
  1341. module_param_named(ahb_single, dwc_otg_module_params.ahb_single, int, 0444);
  1342. MODULE_PARM_DESC(ahb_single, "Enable AHB Single Support");
  1343. module_param_named(adp_enable, dwc_otg_module_params.adp_enable, int, 0444);
  1344. MODULE_PARM_DESC(adp_enable, "ADP Enable 0=ADP Disabled 1=ADP Enabled");
  1345. module_param_named(otg_ver, dwc_otg_module_params.otg_ver, int, 0444);
  1346. MODULE_PARM_DESC(otg_ver, "OTG revision supported 0=OTG 1.3 1=OTG 2.0");
  1347. /** @page "Module Parameters"
  1348. *
  1349. * The following parameters may be specified when starting the module.
  1350. * These parameters define how the DWC_otg controller should be
  1351. * configured. Parameter values are passed to the CIL initialization
  1352. * function dwc_otg_cil_init
  1353. *
  1354. * Example: <code>modprobe dwc_otg speed=1 otg_cap=1</code>
  1355. *
  1356. <table>
  1357. <tr><td>Parameter Name</td><td>Meaning</td></tr>
  1358. <tr>
  1359. <td>otg_cap</td>
  1360. <td>Specifies the OTG capabilities. The driver will automatically detect the
  1361. value for this parameter if none is specified.
  1362. - 0: HNP and SRP capable (default, if available)
  1363. - 1: SRP Only capable
  1364. - 2: No HNP/SRP capable
  1365. </td></tr>
  1366. <tr>
  1367. <td>dma_enable</td>
  1368. <td>Specifies whether to use slave or DMA mode for accessing the data FIFOs.
  1369. The driver will automatically detect the value for this parameter if none is
  1370. specified.
  1371. - 0: Slave
  1372. - 1: DMA (default, if available)
  1373. </td></tr>
  1374. <tr>
  1375. <td>dma_burst_size</td>
  1376. <td>The DMA Burst size (applicable only for External DMA Mode).
  1377. - Values: 1, 4, 8 16, 32, 64, 128, 256 (default 32)
  1378. </td></tr>
  1379. <tr>
  1380. <td>speed</td>
  1381. <td>Specifies the maximum speed of operation in host and device mode. The
  1382. actual speed depends on the speed of the attached device and the value of
  1383. phy_type.
  1384. - 0: High Speed (default)
  1385. - 1: Full Speed
  1386. </td></tr>
  1387. <tr>
  1388. <td>host_support_fs_ls_low_power</td>
  1389. <td>Specifies whether low power mode is supported when attached to a Full
  1390. Speed or Low Speed device in host mode.
  1391. - 0: Don't support low power mode (default)
  1392. - 1: Support low power mode
  1393. </td></tr>
  1394. <tr>
  1395. <td>host_ls_low_power_phy_clk</td>
  1396. <td>Specifies the PHY clock rate in low power mode when connected to a Low
  1397. Speed device in host mode. This parameter is applicable only if
  1398. HOST_SUPPORT_FS_LS_LOW_POWER is enabled.
  1399. - 0: 48 MHz (default)
  1400. - 1: 6 MHz
  1401. </td></tr>
  1402. <tr>
  1403. <td>enable_dynamic_fifo</td>
  1404. <td> Specifies whether FIFOs may be resized by the driver software.
  1405. - 0: Use cC FIFO size parameters
  1406. - 1: Allow dynamic FIFO sizing (default)
  1407. </td></tr>
  1408. <tr>
  1409. <td>data_fifo_size</td>
  1410. <td>Total number of 4-byte words in the data FIFO memory. This memory
  1411. includes the Rx FIFO, non-periodic Tx FIFO, and periodic Tx FIFOs.
  1412. - Values: 32 to 32768 (default 8192)
  1413. Note: The total FIFO memory depth in the FPGA configuration is 8192.
  1414. </td></tr>
  1415. <tr>
  1416. <td>dev_rx_fifo_size</td>
  1417. <td>Number of 4-byte words in the Rx FIFO in device mode when dynamic
  1418. FIFO sizing is enabled.
  1419. - Values: 16 to 32768 (default 1064)
  1420. </td></tr>
  1421. <tr>
  1422. <td>dev_nperio_tx_fifo_size</td>
  1423. <td>Number of 4-byte words in the non-periodic Tx FIFO in device mode when
  1424. dynamic FIFO sizing is enabled.
  1425. - Values: 16 to 32768 (default 1024)
  1426. </td></tr>
  1427. <tr>
  1428. <td>dev_perio_tx_fifo_size_n (n = 1 to 15)</td>
  1429. <td>Number of 4-byte words in each of the periodic Tx FIFOs in device mode
  1430. when dynamic FIFO sizing is enabled.
  1431. - Values: 4 to 768 (default 256)
  1432. </td></tr>
  1433. <tr>
  1434. <td>host_rx_fifo_size</td>
  1435. <td>Number of 4-byte words in the Rx FIFO in host mode when dynamic FIFO
  1436. sizing is enabled.
  1437. - Values: 16 to 32768 (default 1024)
  1438. </td></tr>
  1439. <tr>
  1440. <td>host_nperio_tx_fifo_size</td>
  1441. <td>Number of 4-byte words in the non-periodic Tx FIFO in host mode when
  1442. dynamic FIFO sizing is enabled in the core.
  1443. - Values: 16 to 32768 (default 1024)
  1444. </td></tr>
  1445. <tr>
  1446. <td>host_perio_tx_fifo_size</td>
  1447. <td>Number of 4-byte words in the host periodic Tx FIFO when dynamic FIFO
  1448. sizing is enabled.
  1449. - Values: 16 to 32768 (default 1024)
  1450. </td></tr>
  1451. <tr>
  1452. <td>max_transfer_size</td>
  1453. <td>The maximum transfer size supported in bytes.
  1454. - Values: 2047 to 65,535 (default 65,535)
  1455. </td></tr>
  1456. <tr>
  1457. <td>max_packet_count</td>
  1458. <td>The maximum number of packets in a transfer.
  1459. - Values: 15 to 511 (default 511)
  1460. </td></tr>
  1461. <tr>
  1462. <td>host_channels</td>
  1463. <td>The number of host channel registers to use.
  1464. - Values: 1 to 16 (default 12)
  1465. Note: The FPGA configuration supports a maximum of 12 host channels.
  1466. </td></tr>
  1467. <tr>
  1468. <td>dev_endpoints</td>
  1469. <td>The number of endpoints in addition to EP0 available for device mode
  1470. operations.
  1471. - Values: 1 to 15 (default 6 IN and OUT)
  1472. Note: The FPGA configuration supports a maximum of 6 IN and OUT endpoints in
  1473. addition to EP0.
  1474. </td></tr>
  1475. <tr>
  1476. <td>phy_type</td>
  1477. <td>Specifies the type of PHY interface to use. By default, the driver will
  1478. automatically detect the phy_type.
  1479. - 0: Full Speed
  1480. - 1: UTMI+ (default, if available)
  1481. - 2: ULPI
  1482. </td></tr>
  1483. <tr>
  1484. <td>phy_utmi_width</td>
  1485. <td>Specifies the UTMI+ Data Width. This parameter is applicable for a
  1486. phy_type of UTMI+. Also, this parameter is applicable only if the
  1487. OTG_HSPHY_WIDTH cC parameter was set to "8 and 16 bits", meaning that the
  1488. core has been configured to work at either data path width.
  1489. - Values: 8 or 16 bits (default 16)
  1490. </td></tr>
  1491. <tr>
  1492. <td>phy_ulpi_ddr</td>
  1493. <td>Specifies whether the ULPI operates at double or single data rate. This
  1494. parameter is only applicable if phy_type is ULPI.
  1495. - 0: single data rate ULPI interface with 8 bit wide data bus (default)
  1496. - 1: double data rate ULPI interface with 4 bit wide data bus
  1497. </td></tr>
  1498. <tr>
  1499. <td>i2c_enable</td>
  1500. <td>Specifies whether to use the I2C interface for full speed PHY. This
  1501. parameter is only applicable if PHY_TYPE is FS.
  1502. - 0: Disabled (default)
  1503. - 1: Enabled
  1504. </td></tr>
  1505. <tr>
  1506. <td>ulpi_fs_ls</td>
  1507. <td>Specifies whether to use ULPI FS/LS mode only.
  1508. - 0: Disabled (default)
  1509. - 1: Enabled
  1510. </td></tr>
  1511. <tr>
  1512. <td>ts_dline</td>
  1513. <td>Specifies whether term select D-Line pulsing for all PHYs is enabled.
  1514. - 0: Disabled (default)
  1515. - 1: Enabled
  1516. </td></tr>
  1517. <tr>
  1518. <td>en_multiple_tx_fifo</td>
  1519. <td>Specifies whether dedicatedto tx fifos are enabled for non periodic IN EPs.
  1520. The driver will automatically detect the value for this parameter if none is
  1521. specified.
  1522. - 0: Disabled
  1523. - 1: Enabled (default, if available)
  1524. </td></tr>
  1525. <tr>
  1526. <td>dev_tx_fifo_size_n (n = 1 to 15)</td>
  1527. <td>Number of 4-byte words in each of the Tx FIFOs in device mode
  1528. when dynamic FIFO sizing is enabled.
  1529. - Values: 4 to 768 (default 256)
  1530. </td></tr>
  1531. <tr>
  1532. <td>tx_thr_length</td>
  1533. <td>Transmit Threshold length in 32 bit double words
  1534. - Values: 8 to 128 (default 64)
  1535. </td></tr>
  1536. <tr>
  1537. <td>rx_thr_length</td>
  1538. <td>Receive Threshold length in 32 bit double words
  1539. - Values: 8 to 128 (default 64)
  1540. </td></tr>
  1541. <tr>
  1542. <td>thr_ctl</td>
  1543. <td>Specifies whether to enable Thresholding for Device mode. Bits 0, 1, 2 of
  1544. this parmater specifies if thresholding is enabled for non-Iso Tx, Iso Tx and
  1545. Rx transfers accordingly.
  1546. The driver will automatically detect the value for this parameter if none is
  1547. specified.
  1548. - Values: 0 to 7 (default 0)
  1549. Bit values indicate:
  1550. - 0: Thresholding disabled
  1551. - 1: Thresholding enabled
  1552. </td></tr>
  1553. <tr>
  1554. <td>dma_desc_enable</td>
  1555. <td>Specifies whether to enable Descriptor DMA mode.
  1556. The driver will automatically detect the value for this parameter if none is
  1557. specified.
  1558. - 0: Descriptor DMA disabled
  1559. - 1: Descriptor DMA (default, if available)
  1560. </td></tr>
  1561. <tr>
  1562. <td>mpi_enable</td>
  1563. <td>Specifies whether to enable MPI enhancement mode.
  1564. The driver will automatically detect the value for this parameter if none is
  1565. specified.
  1566. - 0: MPI disabled (default)
  1567. - 1: MPI enable
  1568. </td></tr>
  1569. <tr>
  1570. <td>pti_enable</td>
  1571. <td>Specifies whether to enable PTI enhancement support.
  1572. The driver will automatically detect the value for this parameter if none is
  1573. specified.
  1574. - 0: PTI disabled (default)
  1575. - 1: PTI enable
  1576. </td></tr>
  1577. <tr>
  1578. <td>lpm_enable</td>
  1579. <td>Specifies whether to enable LPM support.
  1580. The driver will automatically detect the value for this parameter if none is
  1581. specified.
  1582. - 0: LPM disabled
  1583. - 1: LPM enable (default, if available)
  1584. </td></tr>
  1585. <tr>
  1586. <td>ic_usb_cap</td>
  1587. <td>Specifies whether to enable IC_USB capability.
  1588. The driver will automatically detect the value for this parameter if none is
  1589. specified.
  1590. - 0: IC_USB disabled (default, if available)
  1591. - 1: IC_USB enable
  1592. </td></tr>
  1593. <tr>
  1594. <td>ahb_thr_ratio</td>
  1595. <td>Specifies AHB Threshold ratio.
  1596. - Values: 0 to 3 (default 0)
  1597. </td></tr>
  1598. <tr>
  1599. <td>power_down</td>
  1600. <td>Specifies Power Down(Hibernation) Mode.
  1601. The driver will automatically detect the value for this parameter if none is
  1602. specified.
  1603. - 0: Power Down disabled (default)
  1604. - 2: Power Down enabled
  1605. </td></tr>
  1606. <tr>
  1607. <td>reload_ctl</td>
  1608. <td>Specifies whether dynamic reloading of the HFIR register is allowed during
  1609. run time. The driver will automatically detect the value for this parameter if
  1610. none is specified. In case the HFIR value is reloaded when HFIR.RldCtrl == 1'b0
  1611. the core might misbehave.
  1612. - 0: Reload Control disabled (default)
  1613. - 1: Reload Control enabled
  1614. </td></tr>
  1615. <tr>
  1616. <td>dev_out_nak</td>
  1617. <td>Specifies whether Device OUT NAK enhancement enabled or no.
  1618. The driver will automatically detect the value for this parameter if
  1619. none is specified. This parameter is valid only when OTG_EN_DESC_DMA == 1’b1.
  1620. - 0: The core does not set NAK after Bulk OUT transfer complete (default)
  1621. - 1: The core sets NAK after Bulk OUT transfer complete
  1622. </td></tr>
  1623. <tr>
  1624. <td>cont_on_bna</td>
  1625. <td>Specifies whether Enable Continue on BNA enabled or no.
  1626. After receiving BNA interrupt the core disables the endpoint,when the
  1627. endpoint is re-enabled by the application the
  1628. - 0: Core starts processing from the DOEPDMA descriptor (default)
  1629. - 1: Core starts processing from the descriptor which received the BNA.
  1630. This parameter is valid only when OTG_EN_DESC_DMA == 1’b1.
  1631. </td></tr>
  1632. <tr>
  1633. <td>ahb_single</td>
  1634. <td>This bit when programmed supports SINGLE transfers for remainder data
  1635. in a transfer for DMA mode of operation.
  1636. - 0: The remainder data will be sent using INCR burst size (default)
  1637. - 1: The remainder data will be sent using SINGLE burst size.
  1638. </td></tr>
  1639. <tr>
  1640. <td>adp_enable</td>
  1641. <td>Specifies whether ADP feature is enabled.
  1642. The driver will automatically detect the value for this parameter if none is
  1643. specified.
  1644. - 0: ADP feature disabled (default)
  1645. - 1: ADP feature enabled
  1646. </td></tr>
  1647. <tr>
  1648. <td>otg_ver</td>
  1649. <td>Specifies whether OTG is performing as USB OTG Revision 2.0 or Revision 1.3
  1650. USB OTG device.
  1651. - 0: OTG 2.0 support disabled (default)
  1652. - 1: OTG 2.0 support enabled
  1653. </td></tr>
  1654. */