ohci-pci.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
  5. * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
  6. *
  7. * [ Initialisation is based on Linus' ]
  8. * [ uhci code and gregs ohci fragments ]
  9. * [ (C) Copyright 1999 Linus Torvalds ]
  10. * [ (C) Copyright 1999 Gregory P. Smith]
  11. *
  12. * PCI Bus Glue
  13. *
  14. * This file is licenced under the GPL.
  15. */
  16. #include <linux/io.h>
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/pci.h>
  20. #include <linux/usb.h>
  21. #include <linux/usb/hcd.h>
  22. #include "ohci.h"
  23. #include "pci-quirks.h"
  24. #define DRIVER_DESC "OHCI PCI platform driver"
  25. static const char hcd_name[] = "ohci-pci";
  26. /*-------------------------------------------------------------------------*/
  27. static int broken_suspend(struct usb_hcd *hcd)
  28. {
  29. device_init_wakeup(&hcd->self.root_hub->dev, 0);
  30. return 0;
  31. }
  32. /* AMD 756, for most chips (early revs), corrupts register
  33. * values on read ... so enable the vendor workaround.
  34. */
  35. static int ohci_quirk_amd756(struct usb_hcd *hcd)
  36. {
  37. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  38. ohci->flags = OHCI_QUIRK_AMD756;
  39. ohci_dbg (ohci, "AMD756 erratum 4 workaround\n");
  40. /* also erratum 10 (suspend/resume issues) */
  41. return broken_suspend(hcd);
  42. }
  43. /* Apple's OHCI driver has a lot of bizarre workarounds
  44. * for this chip. Evidently control and bulk lists
  45. * can get confused. (B&W G3 models, and ...)
  46. */
  47. static int ohci_quirk_opti(struct usb_hcd *hcd)
  48. {
  49. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  50. ohci_dbg (ohci, "WARNING: OPTi workarounds unavailable\n");
  51. return 0;
  52. }
  53. /* Check for NSC87560. We have to look at the bridge (fn1) to
  54. * identify the USB (fn2). This quirk might apply to more or
  55. * even all NSC stuff.
  56. */
  57. static int ohci_quirk_ns(struct usb_hcd *hcd)
  58. {
  59. struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
  60. struct pci_dev *b;
  61. b = pci_get_slot (pdev->bus, PCI_DEVFN (PCI_SLOT (pdev->devfn), 1));
  62. if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO
  63. && b->vendor == PCI_VENDOR_ID_NS) {
  64. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  65. ohci->flags |= OHCI_QUIRK_SUPERIO;
  66. ohci_dbg (ohci, "Using NSC SuperIO setup\n");
  67. }
  68. pci_dev_put(b);
  69. return 0;
  70. }
  71. /* Check for Compaq's ZFMicro chipset, which needs short
  72. * delays before control or bulk queues get re-activated
  73. * in finish_unlinks()
  74. */
  75. static int ohci_quirk_zfmicro(struct usb_hcd *hcd)
  76. {
  77. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  78. ohci->flags |= OHCI_QUIRK_ZFMICRO;
  79. ohci_dbg(ohci, "enabled Compaq ZFMicro chipset quirks\n");
  80. return 0;
  81. }
  82. /* Check for Toshiba SCC OHCI which has big endian registers
  83. * and little endian in memory data structures
  84. */
  85. static int ohci_quirk_toshiba_scc(struct usb_hcd *hcd)
  86. {
  87. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  88. /* That chip is only present in the southbridge of some
  89. * cell based platforms which are supposed to select
  90. * CONFIG_USB_OHCI_BIG_ENDIAN_MMIO. We verify here if
  91. * that was the case though.
  92. */
  93. #ifdef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
  94. ohci->flags |= OHCI_QUIRK_BE_MMIO;
  95. ohci_dbg (ohci, "enabled big endian Toshiba quirk\n");
  96. return 0;
  97. #else
  98. ohci_err (ohci, "unsupported big endian Toshiba quirk\n");
  99. return -ENXIO;
  100. #endif
  101. }
  102. /* Check for NEC chip and apply quirk for allegedly lost interrupts.
  103. */
  104. static void ohci_quirk_nec_worker(struct work_struct *work)
  105. {
  106. struct ohci_hcd *ohci = container_of(work, struct ohci_hcd, nec_work);
  107. int status;
  108. status = ohci_restart(ohci);
  109. if (status != 0)
  110. ohci_err(ohci, "Restarting NEC controller failed in %s, %d\n",
  111. "ohci_restart", status);
  112. }
  113. static int ohci_quirk_nec(struct usb_hcd *hcd)
  114. {
  115. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  116. ohci->flags |= OHCI_QUIRK_NEC;
  117. INIT_WORK(&ohci->nec_work, ohci_quirk_nec_worker);
  118. ohci_dbg (ohci, "enabled NEC chipset lost interrupt quirk\n");
  119. return 0;
  120. }
  121. static int ohci_quirk_amd700(struct usb_hcd *hcd)
  122. {
  123. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  124. if (usb_amd_find_chipset_info())
  125. ohci->flags |= OHCI_QUIRK_AMD_PLL;
  126. /* SB800 needs pre-fetch fix */
  127. if (usb_amd_prefetch_quirk()) {
  128. ohci->flags |= OHCI_QUIRK_AMD_PREFETCH;
  129. ohci_dbg(ohci, "enabled AMD prefetch quirk\n");
  130. }
  131. ohci->flags |= OHCI_QUIRK_GLOBAL_SUSPEND;
  132. return 0;
  133. }
  134. /* List of quirks for OHCI */
  135. static const struct pci_device_id ohci_pci_quirks[] = {
  136. {
  137. PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x740c),
  138. .driver_data = (unsigned long)ohci_quirk_amd756,
  139. },
  140. {
  141. PCI_DEVICE(PCI_VENDOR_ID_OPTI, 0xc861),
  142. .driver_data = (unsigned long)ohci_quirk_opti,
  143. },
  144. {
  145. PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_ANY_ID),
  146. .driver_data = (unsigned long)ohci_quirk_ns,
  147. },
  148. {
  149. PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xa0f8),
  150. .driver_data = (unsigned long)ohci_quirk_zfmicro,
  151. },
  152. {
  153. PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, 0x01b6),
  154. .driver_data = (unsigned long)ohci_quirk_toshiba_scc,
  155. },
  156. {
  157. PCI_DEVICE(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB),
  158. .driver_data = (unsigned long)ohci_quirk_nec,
  159. },
  160. {
  161. /* Toshiba portege 4000 */
  162. .vendor = PCI_VENDOR_ID_AL,
  163. .device = 0x5237,
  164. .subvendor = PCI_VENDOR_ID_TOSHIBA,
  165. .subdevice = 0x0004,
  166. .driver_data = (unsigned long) broken_suspend,
  167. },
  168. {
  169. PCI_DEVICE(PCI_VENDOR_ID_ITE, 0x8152),
  170. .driver_data = (unsigned long) broken_suspend,
  171. },
  172. {
  173. PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4397),
  174. .driver_data = (unsigned long)ohci_quirk_amd700,
  175. },
  176. {
  177. PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4398),
  178. .driver_data = (unsigned long)ohci_quirk_amd700,
  179. },
  180. {
  181. PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
  182. .driver_data = (unsigned long)ohci_quirk_amd700,
  183. },
  184. /* FIXME for some of the early AMD 760 southbridges, OHCI
  185. * won't work at all. blacklist them.
  186. */
  187. {},
  188. };
  189. static int ohci_pci_reset (struct usb_hcd *hcd)
  190. {
  191. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  192. struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
  193. int ret = 0;
  194. if (hcd->self.controller) {
  195. const struct pci_device_id *quirk_id;
  196. quirk_id = pci_match_id(ohci_pci_quirks, pdev);
  197. if (quirk_id != NULL) {
  198. int (*quirk)(struct usb_hcd *ohci);
  199. quirk = (void *)quirk_id->driver_data;
  200. ret = quirk(hcd);
  201. }
  202. }
  203. if (ret == 0)
  204. ret = ohci_setup(hcd);
  205. /*
  206. * After ohci setup RWC may not be set for add-in PCI cards.
  207. * This transfers PCI PM wakeup capabilities.
  208. */
  209. if (device_can_wakeup(&pdev->dev))
  210. ohci->hc_control |= OHCI_CTRL_RWC;
  211. return ret;
  212. }
  213. static struct hc_driver __read_mostly ohci_pci_hc_driver;
  214. static const struct ohci_driver_overrides pci_overrides __initconst = {
  215. .product_desc = "OHCI PCI host controller",
  216. .reset = ohci_pci_reset,
  217. };
  218. static const struct pci_device_id pci_ids [] = { {
  219. /* handle any USB OHCI controller */
  220. PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0),
  221. .driver_data = (unsigned long) &ohci_pci_hc_driver,
  222. }, {
  223. /* The device in the ConneXT I/O hub has no class reg */
  224. PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI),
  225. .driver_data = (unsigned long) &ohci_pci_hc_driver,
  226. }, { /* end: all zeroes */ }
  227. };
  228. MODULE_DEVICE_TABLE (pci, pci_ids);
  229. /* pci driver glue; this is a "new style" PCI driver module */
  230. static struct pci_driver ohci_pci_driver = {
  231. .name = (char *) hcd_name,
  232. .id_table = pci_ids,
  233. .probe = usb_hcd_pci_probe,
  234. .remove = usb_hcd_pci_remove,
  235. .shutdown = usb_hcd_pci_shutdown,
  236. #ifdef CONFIG_PM
  237. .driver = {
  238. .pm = &usb_hcd_pci_pm_ops
  239. },
  240. #endif
  241. };
  242. static int __init ohci_pci_init(void)
  243. {
  244. if (usb_disabled())
  245. return -ENODEV;
  246. pr_info("%s: " DRIVER_DESC "\n", hcd_name);
  247. ohci_init_driver(&ohci_pci_hc_driver, &pci_overrides);
  248. #ifdef CONFIG_PM
  249. /* Entries for the PCI suspend/resume callbacks are special */
  250. ohci_pci_hc_driver.pci_suspend = ohci_suspend;
  251. ohci_pci_hc_driver.pci_resume = ohci_resume;
  252. #endif
  253. return pci_register_driver(&ohci_pci_driver);
  254. }
  255. module_init(ohci_pci_init);
  256. static void __exit ohci_pci_cleanup(void)
  257. {
  258. pci_unregister_driver(&ohci_pci_driver);
  259. }
  260. module_exit(ohci_pci_cleanup);
  261. MODULE_DESCRIPTION(DRIVER_DESC);
  262. MODULE_LICENSE("GPL");
  263. MODULE_SOFTDEP("pre: ehci_pci");