au1x00_usb_ohci.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727
  1. /*
  2. * URB OHCI HCD (Host Controller Driver) for USB on the AU1x00.
  3. *
  4. * (C) Copyright 2003
  5. * Gary Jennejohn, DENX Software Engineering <gj@denx.de>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. *
  25. * Note: Part of this code has been derived from linux
  26. *
  27. */
  28. /*
  29. * IMPORTANT NOTES
  30. * 1 - you MUST define LITTLEENDIAN in the configuration file for the
  31. * board or this driver will NOT work!
  32. * 2 - this driver is intended for use with USB Mass Storage Devices
  33. * (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
  34. */
  35. #include <config.h>
  36. #if defined(CONFIG_SOC_AU1X00) && defined(CONFIG_USB_OHCI)
  37. /* #include <pci.h> no PCI on the AU1x00 */
  38. #include <common.h>
  39. #include <malloc.h>
  40. #include <asm/io.h>
  41. #include <asm/au1x00.h>
  42. #include <usb.h>
  43. #include "au1x00_usb_ohci.h"
  44. #define OHCI_USE_NPS /* force NoPowerSwitching mode */
  45. #define OHCI_VERBOSE_DEBUG /* not always helpful */
  46. #define OHCI_FILL_TRACE
  47. #define USBH_ENABLE_BE (1<<0)
  48. #define USBH_ENABLE_C (1<<1)
  49. #define USBH_ENABLE_E (1<<2)
  50. #define USBH_ENABLE_CE (1<<3)
  51. #define USBH_ENABLE_RD (1<<4)
  52. #ifdef LITTLEENDIAN
  53. #define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
  54. #else
  55. #define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | USBH_ENABLE_BE)
  56. #endif
  57. /* For initializing controller (mask in an HCFS mode too) */
  58. #define OHCI_CONTROL_INIT \
  59. (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
  60. #undef readl
  61. #undef writel
  62. #define readl(a) au_readl((long)(a))
  63. #define writel(v,a) au_writel((v),(int)(a))
  64. #define min_t(type,x,y) ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
  65. #define DEBUG
  66. #ifdef DEBUG
  67. #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
  68. #else
  69. #define dbg(format, arg...) do {} while(0)
  70. #endif /* DEBUG */
  71. #define err(format, arg...) printf("ERROR: " format "\n", ## arg)
  72. #define SHOW_INFO
  73. #ifdef SHOW_INFO
  74. #define info(format, arg...) printf("INFO: " format "\n", ## arg)
  75. #else
  76. #define info(format, arg...) do {} while(0)
  77. #endif
  78. #define m16_swap(x) swap_16(x)
  79. #define m32_swap(x) swap_32(x)
  80. /* global ohci_t */
  81. static ohci_t gohci;
  82. /* this must be aligned to a 256 byte boundary */
  83. struct ohci_hcca ghcca[1];
  84. /* a pointer to the aligned storage */
  85. struct ohci_hcca *phcca;
  86. /* this allocates EDs for all possible endpoints */
  87. struct ohci_device ohci_dev;
  88. /* urb_priv */
  89. urb_priv_t urb_priv;
  90. /* RHSC flag */
  91. int got_rhsc;
  92. /* device which was disconnected */
  93. struct usb_device *devgone;
  94. /*-------------------------------------------------------------------------*/
  95. /* AMD-756 (D2 rev) reports corrupt register contents in some cases.
  96. * The erratum (#4) description is incorrect. AMD's workaround waits
  97. * till some bits (mostly reserved) are clear; ok for all revs.
  98. */
  99. #define OHCI_QUIRK_AMD756 0xabcd
  100. #define read_roothub(hc, register, mask) ({ \
  101. u32 temp = readl (&hc->regs->roothub.register); \
  102. if (hc->flags & OHCI_QUIRK_AMD756) \
  103. while (temp & mask) \
  104. temp = readl (&hc->regs->roothub.register); \
  105. temp; })
  106. static u32 roothub_a (struct ohci *hc)
  107. { return read_roothub (hc, a, 0xfc0fe000); }
  108. static inline u32 roothub_b (struct ohci *hc)
  109. { return readl (&hc->regs->roothub.b); }
  110. static inline u32 roothub_status (struct ohci *hc)
  111. { return readl (&hc->regs->roothub.status); }
  112. static u32 roothub_portstatus (struct ohci *hc, int i)
  113. { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
  114. /* forward declaration */
  115. static int hc_interrupt (void);
  116. static void
  117. td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer,
  118. int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval);
  119. /*-------------------------------------------------------------------------*
  120. * URB support functions
  121. *-------------------------------------------------------------------------*/
  122. /* free HCD-private data associated with this URB */
  123. static void urb_free_priv (urb_priv_t * urb)
  124. {
  125. int i;
  126. int last;
  127. struct td * td;
  128. last = urb->length - 1;
  129. if (last >= 0) {
  130. for (i = 0; i <= last; i++) {
  131. td = urb->td[i];
  132. if (td) {
  133. td->usb_dev = NULL;
  134. urb->td[i] = NULL;
  135. }
  136. }
  137. }
  138. }
  139. /*-------------------------------------------------------------------------*/
  140. #ifdef DEBUG
  141. static int sohci_get_current_frame_number (struct usb_device * dev);
  142. /* debug| print the main components of an URB
  143. * small: 0) header + data packets 1) just header */
  144. static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
  145. int transfer_len, struct devrequest * setup, char * str, int small)
  146. {
  147. urb_priv_t * purb = &urb_priv;
  148. dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
  149. str,
  150. sohci_get_current_frame_number (dev),
  151. usb_pipedevice (pipe),
  152. usb_pipeendpoint (pipe),
  153. usb_pipeout (pipe)? 'O': 'I',
  154. usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
  155. (usb_pipecontrol (pipe)? "CTRL": "BULK"),
  156. purb->actual_length,
  157. transfer_len, dev->status);
  158. #ifdef OHCI_VERBOSE_DEBUG
  159. if (!small) {
  160. int i, len;
  161. if (usb_pipecontrol (pipe)) {
  162. printf (__FILE__ ": cmd(8):");
  163. for (i = 0; i < 8 ; i++)
  164. printf (" %02x", ((__u8 *) setup) [i]);
  165. printf ("\n");
  166. }
  167. if (transfer_len > 0 && buffer) {
  168. printf (__FILE__ ": data(%d/%d):",
  169. purb->actual_length,
  170. transfer_len);
  171. len = usb_pipeout (pipe)?
  172. transfer_len: purb->actual_length;
  173. for (i = 0; i < 16 && i < len; i++)
  174. printf (" %02x", ((__u8 *) buffer) [i]);
  175. printf ("%s\n", i < len? "...": "");
  176. }
  177. }
  178. #endif
  179. }
  180. /* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
  181. void ep_print_int_eds (ohci_t *ohci, char * str) {
  182. int i, j;
  183. __u32 * ed_p;
  184. for (i= 0; i < 32; i++) {
  185. j = 5;
  186. ed_p = &(ohci->hcca->int_table [i]);
  187. if (*ed_p == 0)
  188. continue;
  189. printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i);
  190. while (*ed_p != 0 && j--) {
  191. ed_t *ed = (ed_t *)m32_swap(ed_p);
  192. printf (" ed: %4x;", ed->hwINFO);
  193. ed_p = &ed->hwNextED;
  194. }
  195. printf ("\n");
  196. }
  197. }
  198. static void ohci_dump_intr_mask (char *label, __u32 mask)
  199. {
  200. dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s",
  201. label,
  202. mask,
  203. (mask & OHCI_INTR_MIE) ? " MIE" : "",
  204. (mask & OHCI_INTR_OC) ? " OC" : "",
  205. (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
  206. (mask & OHCI_INTR_FNO) ? " FNO" : "",
  207. (mask & OHCI_INTR_UE) ? " UE" : "",
  208. (mask & OHCI_INTR_RD) ? " RD" : "",
  209. (mask & OHCI_INTR_SF) ? " SF" : "",
  210. (mask & OHCI_INTR_WDH) ? " WDH" : "",
  211. (mask & OHCI_INTR_SO) ? " SO" : ""
  212. );
  213. }
  214. static void maybe_print_eds (char *label, __u32 value)
  215. {
  216. ed_t *edp = (ed_t *)value;
  217. if (value) {
  218. dbg ("%s %08x", label, value);
  219. dbg ("%08x", edp->hwINFO);
  220. dbg ("%08x", edp->hwTailP);
  221. dbg ("%08x", edp->hwHeadP);
  222. dbg ("%08x", edp->hwNextED);
  223. }
  224. }
  225. static char * hcfs2string (int state)
  226. {
  227. switch (state) {
  228. case OHCI_USB_RESET: return "reset";
  229. case OHCI_USB_RESUME: return "resume";
  230. case OHCI_USB_OPER: return "operational";
  231. case OHCI_USB_SUSPEND: return "suspend";
  232. }
  233. return "?";
  234. }
  235. /* dump control and status registers */
  236. static void ohci_dump_status (ohci_t *controller)
  237. {
  238. struct ohci_regs *regs = controller->regs;
  239. __u32 temp;
  240. temp = readl (&regs->revision) & 0xff;
  241. if (temp != 0x10)
  242. dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f));
  243. temp = readl (&regs->control);
  244. dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp,
  245. (temp & OHCI_CTRL_RWE) ? " RWE" : "",
  246. (temp & OHCI_CTRL_RWC) ? " RWC" : "",
  247. (temp & OHCI_CTRL_IR) ? " IR" : "",
  248. hcfs2string (temp & OHCI_CTRL_HCFS),
  249. (temp & OHCI_CTRL_BLE) ? " BLE" : "",
  250. (temp & OHCI_CTRL_CLE) ? " CLE" : "",
  251. (temp & OHCI_CTRL_IE) ? " IE" : "",
  252. (temp & OHCI_CTRL_PLE) ? " PLE" : "",
  253. temp & OHCI_CTRL_CBSR
  254. );
  255. temp = readl (&regs->cmdstatus);
  256. dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp,
  257. (temp & OHCI_SOC) >> 16,
  258. (temp & OHCI_OCR) ? " OCR" : "",
  259. (temp & OHCI_BLF) ? " BLF" : "",
  260. (temp & OHCI_CLF) ? " CLF" : "",
  261. (temp & OHCI_HCR) ? " HCR" : ""
  262. );
  263. ohci_dump_intr_mask ("intrstatus", readl (&regs->intrstatus));
  264. ohci_dump_intr_mask ("intrenable", readl (&regs->intrenable));
  265. maybe_print_eds ("ed_periodcurrent", readl (&regs->ed_periodcurrent));
  266. maybe_print_eds ("ed_controlhead", readl (&regs->ed_controlhead));
  267. maybe_print_eds ("ed_controlcurrent", readl (&regs->ed_controlcurrent));
  268. maybe_print_eds ("ed_bulkhead", readl (&regs->ed_bulkhead));
  269. maybe_print_eds ("ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
  270. maybe_print_eds ("donehead", readl (&regs->donehead));
  271. }
  272. static void ohci_dump_roothub (ohci_t *controller, int verbose)
  273. {
  274. __u32 temp, ndp, i;
  275. temp = roothub_a (controller);
  276. ndp = (temp & RH_A_NDP);
  277. if (verbose) {
  278. dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
  279. ((temp & RH_A_POTPGT) >> 24) & 0xff,
  280. (temp & RH_A_NOCP) ? " NOCP" : "",
  281. (temp & RH_A_OCPM) ? " OCPM" : "",
  282. (temp & RH_A_DT) ? " DT" : "",
  283. (temp & RH_A_NPS) ? " NPS" : "",
  284. (temp & RH_A_PSM) ? " PSM" : "",
  285. ndp
  286. );
  287. temp = roothub_b (controller);
  288. dbg ("roothub.b: %08x PPCM=%04x DR=%04x",
  289. temp,
  290. (temp & RH_B_PPCM) >> 16,
  291. (temp & RH_B_DR)
  292. );
  293. temp = roothub_status (controller);
  294. dbg ("roothub.status: %08x%s%s%s%s%s%s",
  295. temp,
  296. (temp & RH_HS_CRWE) ? " CRWE" : "",
  297. (temp & RH_HS_OCIC) ? " OCIC" : "",
  298. (temp & RH_HS_LPSC) ? " LPSC" : "",
  299. (temp & RH_HS_DRWE) ? " DRWE" : "",
  300. (temp & RH_HS_OCI) ? " OCI" : "",
  301. (temp & RH_HS_LPS) ? " LPS" : ""
  302. );
  303. }
  304. for (i = 0; i < ndp; i++) {
  305. temp = roothub_portstatus (controller, i);
  306. dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
  307. i,
  308. temp,
  309. (temp & RH_PS_PRSC) ? " PRSC" : "",
  310. (temp & RH_PS_OCIC) ? " OCIC" : "",
  311. (temp & RH_PS_PSSC) ? " PSSC" : "",
  312. (temp & RH_PS_PESC) ? " PESC" : "",
  313. (temp & RH_PS_CSC) ? " CSC" : "",
  314. (temp & RH_PS_LSDA) ? " LSDA" : "",
  315. (temp & RH_PS_PPS) ? " PPS" : "",
  316. (temp & RH_PS_PRS) ? " PRS" : "",
  317. (temp & RH_PS_POCI) ? " POCI" : "",
  318. (temp & RH_PS_PSS) ? " PSS" : "",
  319. (temp & RH_PS_PES) ? " PES" : "",
  320. (temp & RH_PS_CCS) ? " CCS" : ""
  321. );
  322. }
  323. }
  324. static void ohci_dump (ohci_t *controller, int verbose)
  325. {
  326. dbg ("OHCI controller usb-%s state", controller->slot_name);
  327. /* dumps some of the state we know about */
  328. ohci_dump_status (controller);
  329. if (verbose)
  330. ep_print_int_eds (controller, "hcca");
  331. dbg ("hcca frame #%04x", controller->hcca->frame_no);
  332. ohci_dump_roothub (controller, 1);
  333. }
  334. #endif /* DEBUG */
  335. /*-------------------------------------------------------------------------*
  336. * Interface functions (URB)
  337. *-------------------------------------------------------------------------*/
  338. /* get a transfer request */
  339. int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
  340. int transfer_len, struct devrequest *setup, int interval)
  341. {
  342. ohci_t *ohci;
  343. ed_t * ed;
  344. urb_priv_t *purb_priv;
  345. int i, size = 0;
  346. ohci = &gohci;
  347. /* when controller's hung, permit only roothub cleanup attempts
  348. * such as powering down ports */
  349. if (ohci->disabled) {
  350. err("sohci_submit_job: EPIPE");
  351. return -1;
  352. }
  353. /* every endpoint has a ed, locate and fill it */
  354. if (!(ed = ep_add_ed (dev, pipe))) {
  355. err("sohci_submit_job: ENOMEM");
  356. return -1;
  357. }
  358. /* for the private part of the URB we need the number of TDs (size) */
  359. switch (usb_pipetype (pipe)) {
  360. case PIPE_BULK: /* one TD for every 4096 Byte */
  361. size = (transfer_len - 1) / 4096 + 1;
  362. break;
  363. case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */
  364. size = (transfer_len == 0)? 2:
  365. (transfer_len - 1) / 4096 + 3;
  366. break;
  367. }
  368. if (size >= (N_URB_TD - 1)) {
  369. err("need %d TDs, only have %d", size, N_URB_TD);
  370. return -1;
  371. }
  372. purb_priv = &urb_priv;
  373. purb_priv->pipe = pipe;
  374. /* fill the private part of the URB */
  375. purb_priv->length = size;
  376. purb_priv->ed = ed;
  377. purb_priv->actual_length = 0;
  378. /* allocate the TDs */
  379. /* note that td[0] was allocated in ep_add_ed */
  380. for (i = 0; i < size; i++) {
  381. purb_priv->td[i] = td_alloc (dev);
  382. if (!purb_priv->td[i]) {
  383. purb_priv->length = i;
  384. urb_free_priv (purb_priv);
  385. err("sohci_submit_job: ENOMEM");
  386. return -1;
  387. }
  388. }
  389. if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
  390. urb_free_priv (purb_priv);
  391. err("sohci_submit_job: EINVAL");
  392. return -1;
  393. }
  394. /* link the ed into a chain if is not already */
  395. if (ed->state != ED_OPER)
  396. ep_link (ohci, ed);
  397. /* fill the TDs and link it to the ed */
  398. td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
  399. return 0;
  400. }
  401. /*-------------------------------------------------------------------------*/
  402. #ifdef DEBUG
  403. /* tell us the current USB frame number */
  404. static int sohci_get_current_frame_number (struct usb_device *usb_dev)
  405. {
  406. ohci_t *ohci = &gohci;
  407. return m16_swap (ohci->hcca->frame_no);
  408. }
  409. #endif
  410. /*-------------------------------------------------------------------------*
  411. * ED handling functions
  412. *-------------------------------------------------------------------------*/
  413. /* link an ed into one of the HC chains */
  414. static int ep_link (ohci_t *ohci, ed_t *edi)
  415. {
  416. volatile ed_t *ed = edi;
  417. ed->state = ED_OPER;
  418. switch (ed->type) {
  419. case PIPE_CONTROL:
  420. ed->hwNextED = 0;
  421. if (ohci->ed_controltail == NULL) {
  422. writel ((long)ed, &ohci->regs->ed_controlhead);
  423. } else {
  424. ohci->ed_controltail->hwNextED = m32_swap (ed);
  425. }
  426. ed->ed_prev = ohci->ed_controltail;
  427. if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
  428. !ohci->ed_rm_list[1] && !ohci->sleeping) {
  429. ohci->hc_control |= OHCI_CTRL_CLE;
  430. writel (ohci->hc_control, &ohci->regs->control);
  431. }
  432. ohci->ed_controltail = edi;
  433. break;
  434. case PIPE_BULK:
  435. ed->hwNextED = 0;
  436. if (ohci->ed_bulktail == NULL) {
  437. writel ((long)ed, &ohci->regs->ed_bulkhead);
  438. } else {
  439. ohci->ed_bulktail->hwNextED = m32_swap (ed);
  440. }
  441. ed->ed_prev = ohci->ed_bulktail;
  442. if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
  443. !ohci->ed_rm_list[1] && !ohci->sleeping) {
  444. ohci->hc_control |= OHCI_CTRL_BLE;
  445. writel (ohci->hc_control, &ohci->regs->control);
  446. }
  447. ohci->ed_bulktail = edi;
  448. break;
  449. }
  450. return 0;
  451. }
  452. /*-------------------------------------------------------------------------*/
  453. /* unlink an ed from one of the HC chains.
  454. * just the link to the ed is unlinked.
  455. * the link from the ed still points to another operational ed or 0
  456. * so the HC can eventually finish the processing of the unlinked ed */
  457. static int ep_unlink (ohci_t *ohci, ed_t *ed)
  458. {
  459. ed->hwINFO |= m32_swap (OHCI_ED_SKIP);
  460. switch (ed->type) {
  461. case PIPE_CONTROL:
  462. if (ed->ed_prev == NULL) {
  463. if (!ed->hwNextED) {
  464. ohci->hc_control &= ~OHCI_CTRL_CLE;
  465. writel (ohci->hc_control, &ohci->regs->control);
  466. }
  467. writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead);
  468. } else {
  469. ed->ed_prev->hwNextED = ed->hwNextED;
  470. }
  471. if (ohci->ed_controltail == ed) {
  472. ohci->ed_controltail = ed->ed_prev;
  473. } else {
  474. ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
  475. }
  476. break;
  477. case PIPE_BULK:
  478. if (ed->ed_prev == NULL) {
  479. if (!ed->hwNextED) {
  480. ohci->hc_control &= ~OHCI_CTRL_BLE;
  481. writel (ohci->hc_control, &ohci->regs->control);
  482. }
  483. writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead);
  484. } else {
  485. ed->ed_prev->hwNextED = ed->hwNextED;
  486. }
  487. if (ohci->ed_bulktail == ed) {
  488. ohci->ed_bulktail = ed->ed_prev;
  489. } else {
  490. ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
  491. }
  492. break;
  493. }
  494. ed->state = ED_UNLINK;
  495. return 0;
  496. }
  497. /*-------------------------------------------------------------------------*/
  498. /* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
  499. * but the USB stack is a little bit stateless so we do it at every transaction
  500. * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
  501. * in all other cases the state is left unchanged
  502. * the ed info fields are setted anyway even though most of them should not change */
  503. static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
  504. {
  505. td_t *td;
  506. ed_t *ed_ret;
  507. volatile ed_t *ed;
  508. ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) |
  509. (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))];
  510. if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
  511. err("ep_add_ed: pending delete");
  512. /* pending delete request */
  513. return NULL;
  514. }
  515. if (ed->state == ED_NEW) {
  516. ed->hwINFO = m32_swap (OHCI_ED_SKIP); /* skip ed */
  517. /* dummy td; end of td list for ed */
  518. td = td_alloc (usb_dev);
  519. ed->hwTailP = m32_swap (td);
  520. ed->hwHeadP = ed->hwTailP;
  521. ed->state = ED_UNLINK;
  522. ed->type = usb_pipetype (pipe);
  523. ohci_dev.ed_cnt++;
  524. }
  525. ed->hwINFO = m32_swap (usb_pipedevice (pipe)
  526. | usb_pipeendpoint (pipe) << 7
  527. | (usb_pipeisoc (pipe)? 0x8000: 0)
  528. | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000))
  529. | usb_pipeslow (pipe) << 13
  530. | usb_maxpacket (usb_dev, pipe) << 16);
  531. return ed_ret;
  532. }
  533. /*-------------------------------------------------------------------------*
  534. * TD handling functions
  535. *-------------------------------------------------------------------------*/
  536. /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
  537. static void td_fill (ohci_t *ohci, unsigned int info,
  538. void *data, int len,
  539. struct usb_device *dev, int index, urb_priv_t *urb_priv)
  540. {
  541. volatile td_t *td, *td_pt;
  542. #ifdef OHCI_FILL_TRACE
  543. int i;
  544. #endif
  545. if (index > urb_priv->length) {
  546. err("index > length");
  547. return;
  548. }
  549. /* use this td as the next dummy */
  550. td_pt = urb_priv->td [index];
  551. td_pt->hwNextTD = 0;
  552. /* fill the old dummy TD */
  553. td = urb_priv->td [index] = (td_t *)(m32_swap (urb_priv->ed->hwTailP) & ~0xf);
  554. td->ed = urb_priv->ed;
  555. td->next_dl_td = NULL;
  556. td->index = index;
  557. td->data = (__u32)data;
  558. #ifdef OHCI_FILL_TRACE
  559. if (1 || ((usb_pipetype(urb_priv->pipe) == PIPE_BULK) && usb_pipeout(urb_priv->pipe))) {
  560. for (i = 0; i < len; i++)
  561. printf("td->data[%d] %#2x\n",i, ((unsigned char *)(td->data+0x80000000))[i]);
  562. }
  563. #endif
  564. if (!len)
  565. data = 0;
  566. td->hwINFO = m32_swap (info);
  567. td->hwCBP = m32_swap (data);
  568. if (data)
  569. td->hwBE = m32_swap (data + len - 1);
  570. else
  571. td->hwBE = 0;
  572. td->hwNextTD = m32_swap (td_pt);
  573. td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
  574. /* append to queue */
  575. td->ed->hwTailP = td->hwNextTD;
  576. }
  577. /*-------------------------------------------------------------------------*/
  578. /* prepare all TDs of a transfer */
  579. #define kseg_to_phys(x) ((void *)((__u32)(x) - 0x80000000))
  580. static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer,
  581. int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval)
  582. {
  583. ohci_t *ohci = &gohci;
  584. int data_len = transfer_len;
  585. void *data;
  586. int cnt = 0;
  587. __u32 info = 0;
  588. unsigned int toggle = 0;
  589. /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
  590. if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) {
  591. toggle = TD_T_TOGGLE;
  592. } else {
  593. toggle = TD_T_DATA0;
  594. usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1);
  595. }
  596. urb->td_cnt = 0;
  597. if (data_len)
  598. data = kseg_to_phys(buffer);
  599. else
  600. data = 0;
  601. switch (usb_pipetype (pipe)) {
  602. case PIPE_BULK:
  603. info = usb_pipeout (pipe)?
  604. TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
  605. while(data_len > 4096) {
  606. td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb);
  607. data += 4096; data_len -= 4096; cnt++;
  608. }
  609. info = usb_pipeout (pipe)?
  610. TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ;
  611. td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb);
  612. cnt++;
  613. if (!ohci->sleeping)
  614. writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
  615. break;
  616. case PIPE_CONTROL:
  617. info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
  618. td_fill (ohci, info, kseg_to_phys(setup), 8, dev, cnt++, urb);
  619. if (data_len > 0) {
  620. info = usb_pipeout (pipe)?
  621. TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
  622. /* NOTE: mishandles transfers >8K, some >4K */
  623. td_fill (ohci, info, data, data_len, dev, cnt++, urb);
  624. }
  625. info = usb_pipeout (pipe)?
  626. TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
  627. td_fill (ohci, info, data, 0, dev, cnt++, urb);
  628. if (!ohci->sleeping)
  629. writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
  630. break;
  631. }
  632. if (urb->length != cnt)
  633. dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
  634. }
  635. /*-------------------------------------------------------------------------*
  636. * Done List handling functions
  637. *-------------------------------------------------------------------------*/
  638. /* calculate the transfer length and update the urb */
  639. static void dl_transfer_length(td_t * td)
  640. {
  641. __u32 tdINFO, tdBE, tdCBP;
  642. urb_priv_t *lurb_priv = &urb_priv;
  643. tdINFO = m32_swap (td->hwINFO);
  644. tdBE = m32_swap (td->hwBE);
  645. tdCBP = m32_swap (td->hwCBP);
  646. if (!(usb_pipetype (lurb_priv->pipe) == PIPE_CONTROL &&
  647. ((td->index == 0) || (td->index == lurb_priv->length - 1)))) {
  648. if (tdBE != 0) {
  649. if (td->hwCBP == 0)
  650. lurb_priv->actual_length += tdBE - td->data + 1;
  651. else
  652. lurb_priv->actual_length += tdCBP - td->data;
  653. }
  654. }
  655. }
  656. /*-------------------------------------------------------------------------*/
  657. /* replies to the request have to be on a FIFO basis so
  658. * we reverse the reversed done-list */
  659. static td_t * dl_reverse_done_list (ohci_t *ohci)
  660. {
  661. __u32 td_list_hc;
  662. td_t *td_rev = NULL;
  663. td_t *td_list = NULL;
  664. urb_priv_t *lurb_priv = NULL;
  665. td_list_hc = m32_swap (ohci->hcca->done_head) & 0xfffffff0;
  666. ohci->hcca->done_head = 0;
  667. while (td_list_hc) {
  668. td_list = (td_t *)td_list_hc;
  669. if (TD_CC_GET (m32_swap (td_list->hwINFO))) {
  670. lurb_priv = &urb_priv;
  671. dbg(" USB-error/status: %x : %p",
  672. TD_CC_GET (m32_swap (td_list->hwINFO)), td_list);
  673. if (td_list->ed->hwHeadP & m32_swap (0x1)) {
  674. if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) {
  675. td_list->ed->hwHeadP =
  676. (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & m32_swap (0xfffffff0)) |
  677. (td_list->ed->hwHeadP & m32_swap (0x2));
  678. lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1;
  679. } else
  680. td_list->ed->hwHeadP &= m32_swap (0xfffffff2);
  681. }
  682. }
  683. td_list->next_dl_td = td_rev;
  684. td_rev = td_list;
  685. td_list_hc = m32_swap (td_list->hwNextTD) & 0xfffffff0;
  686. }
  687. return td_list;
  688. }
  689. /*-------------------------------------------------------------------------*/
  690. /* td done list */
  691. static int dl_done_list (ohci_t *ohci, td_t *td_list)
  692. {
  693. td_t *td_list_next = NULL;
  694. ed_t *ed;
  695. int cc = 0;
  696. int stat = 0;
  697. /* urb_t *urb; */
  698. urb_priv_t *lurb_priv;
  699. __u32 tdINFO, edHeadP, edTailP;
  700. while (td_list) {
  701. td_list_next = td_list->next_dl_td;
  702. lurb_priv = &urb_priv;
  703. tdINFO = m32_swap (td_list->hwINFO);
  704. ed = td_list->ed;
  705. dl_transfer_length(td_list);
  706. /* error code of transfer */
  707. cc = TD_CC_GET (tdINFO);
  708. if (cc != 0) {
  709. dbg("ConditionCode %#x", cc);
  710. stat = cc_to_error[cc];
  711. }
  712. if (ed->state != ED_NEW) {
  713. edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
  714. edTailP = m32_swap (ed->hwTailP);
  715. /* unlink eds if they are not busy */
  716. if ((edHeadP == edTailP) && (ed->state == ED_OPER))
  717. ep_unlink (ohci, ed);
  718. }
  719. td_list = td_list_next;
  720. }
  721. return stat;
  722. }
  723. /*-------------------------------------------------------------------------*
  724. * Virtual Root Hub
  725. *-------------------------------------------------------------------------*/
  726. /* Device descriptor */
  727. static __u8 root_hub_dev_des[] =
  728. {
  729. 0x12, /* __u8 bLength; */
  730. 0x01, /* __u8 bDescriptorType; Device */
  731. 0x10, /* __u16 bcdUSB; v1.1 */
  732. 0x01,
  733. 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
  734. 0x00, /* __u8 bDeviceSubClass; */
  735. 0x00, /* __u8 bDeviceProtocol; */
  736. 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
  737. 0x00, /* __u16 idVendor; */
  738. 0x00,
  739. 0x00, /* __u16 idProduct; */
  740. 0x00,
  741. 0x00, /* __u16 bcdDevice; */
  742. 0x00,
  743. 0x00, /* __u8 iManufacturer; */
  744. 0x01, /* __u8 iProduct; */
  745. 0x00, /* __u8 iSerialNumber; */
  746. 0x01 /* __u8 bNumConfigurations; */
  747. };
  748. /* Configuration descriptor */
  749. static __u8 root_hub_config_des[] =
  750. {
  751. 0x09, /* __u8 bLength; */
  752. 0x02, /* __u8 bDescriptorType; Configuration */
  753. 0x19, /* __u16 wTotalLength; */
  754. 0x00,
  755. 0x01, /* __u8 bNumInterfaces; */
  756. 0x01, /* __u8 bConfigurationValue; */
  757. 0x00, /* __u8 iConfiguration; */
  758. 0x40, /* __u8 bmAttributes;
  759. Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */
  760. 0x00, /* __u8 MaxPower; */
  761. /* interface */
  762. 0x09, /* __u8 if_bLength; */
  763. 0x04, /* __u8 if_bDescriptorType; Interface */
  764. 0x00, /* __u8 if_bInterfaceNumber; */
  765. 0x00, /* __u8 if_bAlternateSetting; */
  766. 0x01, /* __u8 if_bNumEndpoints; */
  767. 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
  768. 0x00, /* __u8 if_bInterfaceSubClass; */
  769. 0x00, /* __u8 if_bInterfaceProtocol; */
  770. 0x00, /* __u8 if_iInterface; */
  771. /* endpoint */
  772. 0x07, /* __u8 ep_bLength; */
  773. 0x05, /* __u8 ep_bDescriptorType; Endpoint */
  774. 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
  775. 0x03, /* __u8 ep_bmAttributes; Interrupt */
  776. 0x02, /* __u16 ep_wMaxPacketSize; ((MAX_ROOT_PORTS + 1) / 8 */
  777. 0x00,
  778. 0xff /* __u8 ep_bInterval; 255 ms */
  779. };
  780. static unsigned char root_hub_str_index0[] =
  781. {
  782. 0x04, /* __u8 bLength; */
  783. 0x03, /* __u8 bDescriptorType; String-descriptor */
  784. 0x09, /* __u8 lang ID */
  785. 0x04, /* __u8 lang ID */
  786. };
  787. static unsigned char root_hub_str_index1[] =
  788. {
  789. 28, /* __u8 bLength; */
  790. 0x03, /* __u8 bDescriptorType; String-descriptor */
  791. 'O', /* __u8 Unicode */
  792. 0, /* __u8 Unicode */
  793. 'H', /* __u8 Unicode */
  794. 0, /* __u8 Unicode */
  795. 'C', /* __u8 Unicode */
  796. 0, /* __u8 Unicode */
  797. 'I', /* __u8 Unicode */
  798. 0, /* __u8 Unicode */
  799. ' ', /* __u8 Unicode */
  800. 0, /* __u8 Unicode */
  801. 'R', /* __u8 Unicode */
  802. 0, /* __u8 Unicode */
  803. 'o', /* __u8 Unicode */
  804. 0, /* __u8 Unicode */
  805. 'o', /* __u8 Unicode */
  806. 0, /* __u8 Unicode */
  807. 't', /* __u8 Unicode */
  808. 0, /* __u8 Unicode */
  809. ' ', /* __u8 Unicode */
  810. 0, /* __u8 Unicode */
  811. 'H', /* __u8 Unicode */
  812. 0, /* __u8 Unicode */
  813. 'u', /* __u8 Unicode */
  814. 0, /* __u8 Unicode */
  815. 'b', /* __u8 Unicode */
  816. 0, /* __u8 Unicode */
  817. };
  818. /* Hub class-specific descriptor is constructed dynamically */
  819. /*-------------------------------------------------------------------------*/
  820. #define OK(x) len = (x); break
  821. #ifdef DEBUG
  822. #define WR_RH_STAT(x) {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);}
  823. #define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);}
  824. #else
  825. #define WR_RH_STAT(x) writel((x), &gohci.regs->roothub.status)
  826. #define WR_RH_PORTSTAT(x) writel((x), &gohci.regs->roothub.portstatus[wIndex-1])
  827. #endif
  828. #define RD_RH_STAT roothub_status(&gohci)
  829. #define RD_RH_PORTSTAT roothub_portstatus(&gohci,wIndex-1)
  830. /* request to virtual root hub */
  831. int rh_check_port_status(ohci_t *controller)
  832. {
  833. __u32 temp, ndp, i;
  834. int res;
  835. res = -1;
  836. temp = roothub_a (controller);
  837. ndp = (temp & RH_A_NDP);
  838. for (i = 0; i < ndp; i++) {
  839. temp = roothub_portstatus (controller, i);
  840. /* check for a device disconnect */
  841. if (((temp & (RH_PS_PESC | RH_PS_CSC)) ==
  842. (RH_PS_PESC | RH_PS_CSC)) &&
  843. ((temp & RH_PS_CCS) == 0)) {
  844. res = i;
  845. break;
  846. }
  847. }
  848. return res;
  849. }
  850. static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
  851. void *buffer, int transfer_len, struct devrequest *cmd)
  852. {
  853. void * data = buffer;
  854. int leni = transfer_len;
  855. int len = 0;
  856. int stat = 0;
  857. __u32 datab[4];
  858. __u8 *data_buf = (__u8 *)datab;
  859. __u16 bmRType_bReq;
  860. __u16 wValue;
  861. __u16 wIndex;
  862. __u16 wLength;
  863. #ifdef DEBUG
  864. urb_priv.actual_length = 0;
  865. pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
  866. #else
  867. wait_ms(1);
  868. #endif
  869. if ((pipe & PIPE_INTERRUPT) == PIPE_INTERRUPT) {
  870. info("Root-Hub submit IRQ: NOT implemented");
  871. return 0;
  872. }
  873. bmRType_bReq = cmd->requesttype | (cmd->request << 8);
  874. wValue = m16_swap (cmd->value);
  875. wIndex = m16_swap (cmd->index);
  876. wLength = m16_swap (cmd->length);
  877. info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
  878. dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
  879. switch (bmRType_bReq) {
  880. /* Request Destination:
  881. without flags: Device,
  882. RH_INTERFACE: interface,
  883. RH_ENDPOINT: endpoint,
  884. RH_CLASS means HUB here,
  885. RH_OTHER | RH_CLASS almost ever means HUB_PORT here
  886. */
  887. case RH_GET_STATUS:
  888. *(__u16 *) data_buf = m16_swap (1); OK (2);
  889. case RH_GET_STATUS | RH_INTERFACE:
  890. *(__u16 *) data_buf = m16_swap (0); OK (2);
  891. case RH_GET_STATUS | RH_ENDPOINT:
  892. *(__u16 *) data_buf = m16_swap (0); OK (2);
  893. case RH_GET_STATUS | RH_CLASS:
  894. *(__u32 *) data_buf = m32_swap (
  895. RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
  896. OK (4);
  897. case RH_GET_STATUS | RH_OTHER | RH_CLASS:
  898. *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
  899. case RH_CLEAR_FEATURE | RH_ENDPOINT:
  900. switch (wValue) {
  901. case (RH_ENDPOINT_STALL): OK (0);
  902. }
  903. break;
  904. case RH_CLEAR_FEATURE | RH_CLASS:
  905. switch (wValue) {
  906. case RH_C_HUB_LOCAL_POWER:
  907. OK(0);
  908. case (RH_C_HUB_OVER_CURRENT):
  909. WR_RH_STAT(RH_HS_OCIC); OK (0);
  910. }
  911. break;
  912. case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
  913. switch (wValue) {
  914. case (RH_PORT_ENABLE):
  915. WR_RH_PORTSTAT (RH_PS_CCS ); OK (0);
  916. case (RH_PORT_SUSPEND):
  917. WR_RH_PORTSTAT (RH_PS_POCI); OK (0);
  918. case (RH_PORT_POWER):
  919. WR_RH_PORTSTAT (RH_PS_LSDA); OK (0);
  920. case (RH_C_PORT_CONNECTION):
  921. WR_RH_PORTSTAT (RH_PS_CSC ); OK (0);
  922. case (RH_C_PORT_ENABLE):
  923. WR_RH_PORTSTAT (RH_PS_PESC); OK (0);
  924. case (RH_C_PORT_SUSPEND):
  925. WR_RH_PORTSTAT (RH_PS_PSSC); OK (0);
  926. case (RH_C_PORT_OVER_CURRENT):
  927. WR_RH_PORTSTAT (RH_PS_OCIC); OK (0);
  928. case (RH_C_PORT_RESET):
  929. WR_RH_PORTSTAT (RH_PS_PRSC); OK (0);
  930. }
  931. break;
  932. case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
  933. switch (wValue) {
  934. case (RH_PORT_SUSPEND):
  935. WR_RH_PORTSTAT (RH_PS_PSS ); OK (0);
  936. case (RH_PORT_RESET): /* BUG IN HUP CODE *********/
  937. if (RD_RH_PORTSTAT & RH_PS_CCS)
  938. WR_RH_PORTSTAT (RH_PS_PRS);
  939. OK (0);
  940. case (RH_PORT_POWER):
  941. WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
  942. case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
  943. if (RD_RH_PORTSTAT & RH_PS_CCS)
  944. WR_RH_PORTSTAT (RH_PS_PES );
  945. OK (0);
  946. }
  947. break;
  948. case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0);
  949. case RH_GET_DESCRIPTOR:
  950. switch ((wValue & 0xff00) >> 8) {
  951. case (0x01): /* device descriptor */
  952. len = min_t(unsigned int,
  953. leni,
  954. min_t(unsigned int,
  955. sizeof (root_hub_dev_des),
  956. wLength));
  957. data_buf = root_hub_dev_des; OK(len);
  958. case (0x02): /* configuration descriptor */
  959. len = min_t(unsigned int,
  960. leni,
  961. min_t(unsigned int,
  962. sizeof (root_hub_config_des),
  963. wLength));
  964. data_buf = root_hub_config_des; OK(len);
  965. case (0x03): /* string descriptors */
  966. if(wValue==0x0300) {
  967. len = min_t(unsigned int,
  968. leni,
  969. min_t(unsigned int,
  970. sizeof (root_hub_str_index0),
  971. wLength));
  972. data_buf = root_hub_str_index0;
  973. OK(len);
  974. }
  975. if(wValue==0x0301) {
  976. len = min_t(unsigned int,
  977. leni,
  978. min_t(unsigned int,
  979. sizeof (root_hub_str_index1),
  980. wLength));
  981. data_buf = root_hub_str_index1;
  982. OK(len);
  983. }
  984. default:
  985. stat = USB_ST_STALLED;
  986. }
  987. break;
  988. case RH_GET_DESCRIPTOR | RH_CLASS:
  989. {
  990. __u32 temp = roothub_a (&gohci);
  991. data_buf [0] = 9; /* min length; */
  992. data_buf [1] = 0x29;
  993. data_buf [2] = temp & RH_A_NDP;
  994. data_buf [3] = 0;
  995. if (temp & RH_A_PSM) /* per-port power switching? */
  996. data_buf [3] |= 0x1;
  997. if (temp & RH_A_NOCP) /* no overcurrent reporting? */
  998. data_buf [3] |= 0x10;
  999. else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */
  1000. data_buf [3] |= 0x8;
  1001. /* corresponds to data_buf[4-7] */
  1002. datab [1] = 0;
  1003. data_buf [5] = (temp & RH_A_POTPGT) >> 24;
  1004. temp = roothub_b (&gohci);
  1005. data_buf [7] = temp & RH_B_DR;
  1006. if (data_buf [2] < 7) {
  1007. data_buf [8] = 0xff;
  1008. } else {
  1009. data_buf [0] += 2;
  1010. data_buf [8] = (temp & RH_B_DR) >> 8;
  1011. data_buf [10] = data_buf [9] = 0xff;
  1012. }
  1013. len = min_t(unsigned int, leni,
  1014. min_t(unsigned int, data_buf [0], wLength));
  1015. OK (len);
  1016. }
  1017. case RH_GET_CONFIGURATION: *(__u8 *) data_buf = 0x01; OK (1);
  1018. case RH_SET_CONFIGURATION: WR_RH_STAT (0x10000); OK (0);
  1019. default:
  1020. dbg ("unsupported root hub command");
  1021. stat = USB_ST_STALLED;
  1022. }
  1023. #ifdef DEBUG
  1024. ohci_dump_roothub (&gohci, 1);
  1025. #else
  1026. wait_ms(1);
  1027. #endif
  1028. len = min_t(int, len, leni);
  1029. if (data != data_buf)
  1030. memcpy (data, data_buf, len);
  1031. dev->act_len = len;
  1032. dev->status = stat;
  1033. #ifdef DEBUG
  1034. if (transfer_len)
  1035. urb_priv.actual_length = transfer_len;
  1036. pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
  1037. #else
  1038. wait_ms(1);
  1039. #endif
  1040. return stat;
  1041. }
  1042. /*-------------------------------------------------------------------------*/
  1043. /* common code for handling submit messages - used for all but root hub */
  1044. /* accesses. */
  1045. int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1046. int transfer_len, struct devrequest *setup, int interval)
  1047. {
  1048. int stat = 0;
  1049. int maxsize = usb_maxpacket(dev, pipe);
  1050. int timeout;
  1051. /* device pulled? Shortcut the action. */
  1052. if (devgone == dev) {
  1053. dev->status = USB_ST_CRC_ERR;
  1054. return 0;
  1055. }
  1056. #ifdef DEBUG
  1057. urb_priv.actual_length = 0;
  1058. pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
  1059. #else
  1060. wait_ms(1);
  1061. #endif
  1062. if (!maxsize) {
  1063. err("submit_common_message: pipesize for pipe %lx is zero",
  1064. pipe);
  1065. return -1;
  1066. }
  1067. if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
  1068. err("sohci_submit_job failed");
  1069. return -1;
  1070. }
  1071. wait_ms(10);
  1072. /* ohci_dump_status(&gohci); */
  1073. /* allow more time for a BULK device to react - some are slow */
  1074. #define BULK_TO 5000 /* timeout in milliseconds */
  1075. if (usb_pipetype (pipe) == PIPE_BULK)
  1076. timeout = BULK_TO;
  1077. else
  1078. timeout = 100;
  1079. timeout *= 4;
  1080. /* wait for it to complete */
  1081. for (;;) {
  1082. /* check whether the controller is done */
  1083. stat = hc_interrupt();
  1084. if (stat < 0) {
  1085. stat = USB_ST_CRC_ERR;
  1086. break;
  1087. }
  1088. if (stat >= 0 && stat != 0xff) {
  1089. /* 0xff is returned for an SF-interrupt */
  1090. break;
  1091. }
  1092. if (--timeout) {
  1093. udelay(250); /* wait_ms(1); */
  1094. } else {
  1095. err("CTL:TIMEOUT ");
  1096. stat = USB_ST_CRC_ERR;
  1097. break;
  1098. }
  1099. }
  1100. /* we got an Root Hub Status Change interrupt */
  1101. if (got_rhsc) {
  1102. #ifdef DEBUG
  1103. ohci_dump_roothub (&gohci, 1);
  1104. #endif
  1105. got_rhsc = 0;
  1106. /* abuse timeout */
  1107. timeout = rh_check_port_status(&gohci);
  1108. if (timeout >= 0) {
  1109. #if 0 /* this does nothing useful, but leave it here in case that changes */
  1110. /* the called routine adds 1 to the passed value */
  1111. usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
  1112. #endif
  1113. /*
  1114. * XXX
  1115. * This is potentially dangerous because it assumes
  1116. * that only one device is ever plugged in!
  1117. */
  1118. devgone = dev;
  1119. }
  1120. }
  1121. dev->status = stat;
  1122. dev->act_len = transfer_len;
  1123. #ifdef DEBUG
  1124. pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
  1125. #else
  1126. wait_ms(1);
  1127. #endif
  1128. /* free TDs in urb_priv */
  1129. urb_free_priv (&urb_priv);
  1130. return 0;
  1131. }
  1132. /* submit routines called from usb.c */
  1133. int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1134. int transfer_len)
  1135. {
  1136. info("submit_bulk_msg");
  1137. return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0);
  1138. }
  1139. int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1140. int transfer_len, struct devrequest *setup)
  1141. {
  1142. int maxsize = usb_maxpacket(dev, pipe);
  1143. info("submit_control_msg");
  1144. #ifdef DEBUG
  1145. urb_priv.actual_length = 0;
  1146. pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
  1147. #else
  1148. wait_ms(1);
  1149. #endif
  1150. if (!maxsize) {
  1151. err("submit_control_message: pipesize for pipe %lx is zero",
  1152. pipe);
  1153. return -1;
  1154. }
  1155. if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) {
  1156. gohci.rh.dev = dev;
  1157. /* root hub - redirect */
  1158. return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len,
  1159. setup);
  1160. }
  1161. return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0);
  1162. }
  1163. int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1164. int transfer_len, int interval)
  1165. {
  1166. info("submit_int_msg");
  1167. return -1;
  1168. }
  1169. /*-------------------------------------------------------------------------*
  1170. * HC functions
  1171. *-------------------------------------------------------------------------*/
  1172. /* reset the HC and BUS */
  1173. static int hc_reset (ohci_t *ohci)
  1174. {
  1175. int timeout = 30;
  1176. int smm_timeout = 50; /* 0,5 sec */
  1177. if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
  1178. writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */
  1179. info("USB HC TakeOver from SMM");
  1180. while (readl (&ohci->regs->control) & OHCI_CTRL_IR) {
  1181. wait_ms (10);
  1182. if (--smm_timeout == 0) {
  1183. err("USB HC TakeOver failed!");
  1184. return -1;
  1185. }
  1186. }
  1187. }
  1188. /* Disable HC interrupts */
  1189. writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
  1190. dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;",
  1191. ohci->slot_name,
  1192. readl (&ohci->regs->control));
  1193. /* Reset USB (needed by some controllers) */
  1194. writel (0, &ohci->regs->control);
  1195. /* HC Reset requires max 10 us delay */
  1196. writel (OHCI_HCR, &ohci->regs->cmdstatus);
  1197. while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
  1198. if (--timeout == 0) {
  1199. err("USB HC reset timed out!");
  1200. return -1;
  1201. }
  1202. udelay (1);
  1203. }
  1204. return 0;
  1205. }
  1206. /*-------------------------------------------------------------------------*/
  1207. /* Start an OHCI controller, set the BUS operational
  1208. * enable interrupts
  1209. * connect the virtual root hub */
  1210. static int hc_start (ohci_t * ohci)
  1211. {
  1212. __u32 mask;
  1213. unsigned int fminterval;
  1214. ohci->disabled = 1;
  1215. /* Tell the controller where the control and bulk lists are
  1216. * The lists are empty now. */
  1217. writel (0, &ohci->regs->ed_controlhead);
  1218. writel (0, &ohci->regs->ed_bulkhead);
  1219. writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */
  1220. fminterval = 0x2edf;
  1221. writel ((fminterval * 9) / 10, &ohci->regs->periodicstart);
  1222. fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
  1223. writel (fminterval, &ohci->regs->fminterval);
  1224. writel (0x628, &ohci->regs->lsthresh);
  1225. /* start controller operations */
  1226. ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
  1227. ohci->disabled = 0;
  1228. writel (ohci->hc_control, &ohci->regs->control);
  1229. /* disable all interrupts */
  1230. mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD |
  1231. OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC |
  1232. OHCI_INTR_OC | OHCI_INTR_MIE);
  1233. writel (mask, &ohci->regs->intrdisable);
  1234. /* clear all interrupts */
  1235. mask &= ~OHCI_INTR_MIE;
  1236. writel (mask, &ohci->regs->intrstatus);
  1237. /* Choose the interrupts we care about now - but w/o MIE */
  1238. mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO;
  1239. writel (mask, &ohci->regs->intrenable);
  1240. #ifdef OHCI_USE_NPS
  1241. /* required for AMD-756 and some Mac platforms */
  1242. writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM,
  1243. &ohci->regs->roothub.a);
  1244. writel (RH_HS_LPSC, &ohci->regs->roothub.status);
  1245. #endif /* OHCI_USE_NPS */
  1246. #define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
  1247. /* POTPGT delay is bits 24-31, in 2 ms units. */
  1248. mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
  1249. /* connect the virtual root hub */
  1250. ohci->rh.devnum = 0;
  1251. return 0;
  1252. }
  1253. /*-------------------------------------------------------------------------*/
  1254. /* an interrupt happens */
  1255. static int
  1256. hc_interrupt (void)
  1257. {
  1258. ohci_t *ohci = &gohci;
  1259. struct ohci_regs *regs = ohci->regs;
  1260. int ints;
  1261. int stat = -1;
  1262. if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
  1263. ints = OHCI_INTR_WDH;
  1264. } else {
  1265. ints = readl (&regs->intrstatus);
  1266. }
  1267. /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
  1268. if (ints & OHCI_INTR_RHSC) {
  1269. got_rhsc = 1;
  1270. }
  1271. if (ints & OHCI_INTR_UE) {
  1272. ohci->disabled++;
  1273. err ("OHCI Unrecoverable Error, controller usb-%s disabled",
  1274. ohci->slot_name);
  1275. /* e.g. due to PCI Master/Target Abort */
  1276. #ifdef DEBUG
  1277. ohci_dump (ohci, 1);
  1278. #else
  1279. wait_ms(1);
  1280. #endif
  1281. /* FIXME: be optimistic, hope that bug won't repeat often. */
  1282. /* Make some non-interrupt context restart the controller. */
  1283. /* Count and limit the retries though; either hardware or */
  1284. /* software errors can go forever... */
  1285. hc_reset (ohci);
  1286. return -1;
  1287. }
  1288. if (ints & OHCI_INTR_WDH) {
  1289. wait_ms(1);
  1290. writel (OHCI_INTR_WDH, &regs->intrdisable);
  1291. stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
  1292. writel (OHCI_INTR_WDH, &regs->intrenable);
  1293. }
  1294. if (ints & OHCI_INTR_SO) {
  1295. dbg("USB Schedule overrun\n");
  1296. writel (OHCI_INTR_SO, &regs->intrenable);
  1297. stat = -1;
  1298. }
  1299. /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */
  1300. if (ints & OHCI_INTR_SF) {
  1301. unsigned int frame = m16_swap (ohci->hcca->frame_no) & 1;
  1302. wait_ms(1);
  1303. writel (OHCI_INTR_SF, &regs->intrdisable);
  1304. if (ohci->ed_rm_list[frame] != NULL)
  1305. writel (OHCI_INTR_SF, &regs->intrenable);
  1306. stat = 0xff;
  1307. }
  1308. writel (ints, &regs->intrstatus);
  1309. return stat;
  1310. }
  1311. /*-------------------------------------------------------------------------*/
  1312. /*-------------------------------------------------------------------------*/
  1313. /* De-allocate all resources.. */
  1314. static void hc_release_ohci (ohci_t *ohci)
  1315. {
  1316. dbg ("USB HC release ohci usb-%s", ohci->slot_name);
  1317. if (!ohci->disabled)
  1318. hc_reset (ohci);
  1319. }
  1320. /*-------------------------------------------------------------------------*/
  1321. #define __read_32bit_c0_register(source, sel) \
  1322. ({ int __res; \
  1323. if (sel == 0) \
  1324. __asm__ __volatile__( \
  1325. "mfc0\t%0, " #source "\n\t" \
  1326. : "=r" (__res)); \
  1327. else \
  1328. __asm__ __volatile__( \
  1329. ".set\tmips32\n\t" \
  1330. "mfc0\t%0, " #source ", " #sel "\n\t" \
  1331. ".set\tmips0\n\t" \
  1332. : "=r" (__res)); \
  1333. __res; \
  1334. })
  1335. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  1336. /*
  1337. * low level initalisation routine, called from usb.c
  1338. */
  1339. static char ohci_inited = 0;
  1340. int usb_lowlevel_init(void)
  1341. {
  1342. u32 pin_func;
  1343. u32 sys_freqctrl, sys_clksrc;
  1344. u32 prid = read_c0_prid();
  1345. dbg("in usb_lowlevel_init\n");
  1346. /* zero and disable FREQ2 */
  1347. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  1348. sys_freqctrl &= ~0xFFF00000;
  1349. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1350. /* zero and disable USBH/USBD clocks */
  1351. sys_clksrc = au_readl(SYS_CLKSRC);
  1352. sys_clksrc &= ~0x00007FE0;
  1353. au_writel(sys_clksrc, SYS_CLKSRC);
  1354. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  1355. sys_freqctrl &= ~0xFFF00000;
  1356. sys_clksrc = au_readl(SYS_CLKSRC);
  1357. sys_clksrc &= ~0x00007FE0;
  1358. switch (prid & 0x000000FF) {
  1359. case 0x00: /* DA */
  1360. case 0x01: /* HA */
  1361. case 0x02: /* HB */
  1362. /* CPU core freq to 48MHz to slow it way down... */
  1363. au_writel(4, SYS_CPUPLL);
  1364. /*
  1365. * Setup 48MHz FREQ2 from CPUPLL for USB Host
  1366. */
  1367. /* FRDIV2=3 -> div by 8 of 384MHz -> 48MHz */
  1368. sys_freqctrl |= ((3<<22) | (1<<21) | (0<<20));
  1369. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1370. /* CPU core freq to 384MHz */
  1371. au_writel(0x20, SYS_CPUPLL);
  1372. printf("Au1000: 48MHz OHCI workaround enabled\n");
  1373. break;
  1374. default: /* HC and newer */
  1375. /* FREQ2 = aux/2 = 48 MHz */
  1376. sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20));
  1377. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1378. break;
  1379. }
  1380. /*
  1381. * Route 48MHz FREQ2 into USB Host and/or Device
  1382. */
  1383. sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
  1384. au_writel(sys_clksrc, SYS_CLKSRC);
  1385. /* configure pins GPIO[14:9] as GPIO */
  1386. pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080);
  1387. au_writel(pin_func, SYS_PINFUNC);
  1388. au_writel(0x2800, SYS_TRIOUTCLR);
  1389. au_writel(0x0030, SYS_OUTPUTCLR);
  1390. dbg("OHCI board setup complete\n");
  1391. /* enable host controller */
  1392. au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG);
  1393. udelay(1000);
  1394. au_writel(USBH_ENABLE_INIT, USB_HOST_CONFIG);
  1395. udelay(1000);
  1396. /* wait for reset complete (read register twice; see au1500 errata) */
  1397. while (au_readl(USB_HOST_CONFIG),
  1398. !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
  1399. udelay(1000);
  1400. dbg("OHCI clock running\n");
  1401. memset (&gohci, 0, sizeof (ohci_t));
  1402. memset (&urb_priv, 0, sizeof (urb_priv_t));
  1403. /* align the storage */
  1404. if ((__u32)&ghcca[0] & 0xff) {
  1405. err("HCCA not aligned!!");
  1406. return -1;
  1407. }
  1408. phcca = &ghcca[0];
  1409. info("aligned ghcca %p", phcca);
  1410. memset(&ohci_dev, 0, sizeof(struct ohci_device));
  1411. if ((__u32)&ohci_dev.ed[0] & 0x7) {
  1412. err("EDs not aligned!!");
  1413. return -1;
  1414. }
  1415. memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
  1416. if ((__u32)gtd & 0x7) {
  1417. err("TDs not aligned!!");
  1418. return -1;
  1419. }
  1420. ptd = gtd;
  1421. gohci.hcca = phcca;
  1422. memset (phcca, 0, sizeof (struct ohci_hcca));
  1423. gohci.disabled = 1;
  1424. gohci.sleeping = 0;
  1425. gohci.irq = -1;
  1426. gohci.regs = (struct ohci_regs *)(USB_OHCI_BASE | 0xA0000000);
  1427. gohci.flags = 0;
  1428. gohci.slot_name = "au1x00";
  1429. dbg("OHCI revision: 0x%08x\n"
  1430. " RH: a: 0x%08x b: 0x%08x\n",
  1431. readl(&gohci.regs->revision),
  1432. readl(&gohci.regs->roothub.a), readl(&gohci.regs->roothub.b));
  1433. if (hc_reset (&gohci) < 0)
  1434. goto errout;
  1435. /* FIXME this is a second HC reset; why?? */
  1436. writel (gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
  1437. wait_ms (10);
  1438. if (hc_start (&gohci) < 0)
  1439. goto errout;
  1440. #ifdef DEBUG
  1441. ohci_dump (&gohci, 1);
  1442. #else
  1443. wait_ms(1);
  1444. #endif
  1445. ohci_inited = 1;
  1446. return 0;
  1447. errout:
  1448. err("OHCI initialization error\n");
  1449. hc_release_ohci (&gohci);
  1450. /* Initialization failed */
  1451. au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
  1452. return -1;
  1453. }
  1454. int usb_lowlevel_stop(void)
  1455. {
  1456. /* this gets called really early - before the controller has */
  1457. /* even been initialized! */
  1458. if (!ohci_inited)
  1459. return 0;
  1460. /* TODO release any interrupts, etc. */
  1461. /* call hc_release_ohci() here ? */
  1462. hc_reset (&gohci);
  1463. /* may not want to do this */
  1464. /* Disable clock */
  1465. au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
  1466. return 0;
  1467. }
  1468. #endif /* CONFIG_USB_OHCI */