usb.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. * USB block power/access management abstraction.
  3. *
  4. * Au1000+: The OHCI block control register is at the far end of the OHCI memory
  5. * area. Au1550 has OHCI on different base address. No need to handle
  6. * UDC here.
  7. * Au1200: one register to control access and clocks to O/EHCI, UDC and OTG
  8. * as well as the PHY for EHCI and UDC.
  9. *
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/module.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/syscore_ops.h>
  17. #include <asm/cpu.h>
  18. #include <asm/mach-au1x00/au1000.h>
  19. /* control register offsets */
  20. #define AU1000_OHCICFG 0x7fffc
  21. #define AU1550_OHCICFG 0x07ffc
  22. #define AU1200_USBCFG 0x04
  23. /* Au1000 USB block config bits */
  24. #define USBHEN_RD (1 << 4) /* OHCI reset-done indicator */
  25. #define USBHEN_CE (1 << 3) /* OHCI block clock enable */
  26. #define USBHEN_E (1 << 2) /* OHCI block enable */
  27. #define USBHEN_C (1 << 1) /* OHCI block coherency bit */
  28. #define USBHEN_BE (1 << 0) /* OHCI Big-Endian */
  29. /* Au1200 USB config bits */
  30. #define USBCFG_PFEN (1 << 31) /* prefetch enable (undoc) */
  31. #define USBCFG_RDCOMB (1 << 30) /* read combining (undoc) */
  32. #define USBCFG_UNKNOWN (5 << 20) /* unknown, leave this way */
  33. #define USBCFG_SSD (1 << 23) /* serial short detect en */
  34. #define USBCFG_PPE (1 << 19) /* HS PHY PLL */
  35. #define USBCFG_UCE (1 << 18) /* UDC clock enable */
  36. #define USBCFG_ECE (1 << 17) /* EHCI clock enable */
  37. #define USBCFG_OCE (1 << 16) /* OHCI clock enable */
  38. #define USBCFG_FLA(x) (((x) & 0x3f) << 8)
  39. #define USBCFG_UCAM (1 << 7) /* coherent access (undoc) */
  40. #define USBCFG_GME (1 << 6) /* OTG mem access */
  41. #define USBCFG_DBE (1 << 5) /* UDC busmaster enable */
  42. #define USBCFG_DME (1 << 4) /* UDC mem enable */
  43. #define USBCFG_EBE (1 << 3) /* EHCI busmaster enable */
  44. #define USBCFG_EME (1 << 2) /* EHCI mem enable */
  45. #define USBCFG_OBE (1 << 1) /* OHCI busmaster enable */
  46. #define USBCFG_OME (1 << 0) /* OHCI mem enable */
  47. #define USBCFG_INIT_AU1200 (USBCFG_PFEN | USBCFG_RDCOMB | USBCFG_UNKNOWN |\
  48. USBCFG_SSD | USBCFG_FLA(0x20) | USBCFG_UCAM | \
  49. USBCFG_GME | USBCFG_DBE | USBCFG_DME | \
  50. USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \
  51. USBCFG_OME)
  52. /* Au1300 USB config registers */
  53. #define USB_DWC_CTRL1 0x00
  54. #define USB_DWC_CTRL2 0x04
  55. #define USB_VBUS_TIMER 0x10
  56. #define USB_SBUS_CTRL 0x14
  57. #define USB_MSR_ERR 0x18
  58. #define USB_DWC_CTRL3 0x1C
  59. #define USB_DWC_CTRL4 0x20
  60. #define USB_OTG_STATUS 0x28
  61. #define USB_DWC_CTRL5 0x2C
  62. #define USB_DWC_CTRL6 0x30
  63. #define USB_DWC_CTRL7 0x34
  64. #define USB_PHY_STATUS 0xC0
  65. #define USB_INT_STATUS 0xC4
  66. #define USB_INT_ENABLE 0xC8
  67. #define USB_DWC_CTRL1_OTGD 0x04 /* set to DISable OTG */
  68. #define USB_DWC_CTRL1_HSTRS 0x02 /* set to ENable EHCI */
  69. #define USB_DWC_CTRL1_DCRS 0x01 /* set to ENable UDC */
  70. #define USB_DWC_CTRL2_PHY1RS 0x04 /* set to enable PHY1 */
  71. #define USB_DWC_CTRL2_PHY0RS 0x02 /* set to enable PHY0 */
  72. #define USB_DWC_CTRL2_PHYRS 0x01 /* set to enable PHY */
  73. #define USB_DWC_CTRL3_OHCI1_CKEN (1 << 19)
  74. #define USB_DWC_CTRL3_OHCI0_CKEN (1 << 18)
  75. #define USB_DWC_CTRL3_EHCI0_CKEN (1 << 17)
  76. #define USB_DWC_CTRL3_OTG0_CKEN (1 << 16)
  77. #define USB_SBUS_CTRL_SBCA 0x04 /* coherent access */
  78. #define USB_INTEN_FORCE 0x20
  79. #define USB_INTEN_PHY 0x10
  80. #define USB_INTEN_UDC 0x08
  81. #define USB_INTEN_EHCI 0x04
  82. #define USB_INTEN_OHCI1 0x02
  83. #define USB_INTEN_OHCI0 0x01
  84. static DEFINE_SPINLOCK(alchemy_usb_lock);
  85. static inline void __au1300_usb_phyctl(void __iomem *base, int enable)
  86. {
  87. unsigned long r, s;
  88. r = __raw_readl(base + USB_DWC_CTRL2);
  89. s = __raw_readl(base + USB_DWC_CTRL3);
  90. s &= USB_DWC_CTRL3_OHCI1_CKEN | USB_DWC_CTRL3_OHCI0_CKEN |
  91. USB_DWC_CTRL3_EHCI0_CKEN | USB_DWC_CTRL3_OTG0_CKEN;
  92. if (enable) {
  93. /* simply enable all PHYs */
  94. r |= USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS |
  95. USB_DWC_CTRL2_PHYRS;
  96. __raw_writel(r, base + USB_DWC_CTRL2);
  97. wmb();
  98. } else if (!s) {
  99. /* no USB block active, do disable all PHYs */
  100. r &= ~(USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS |
  101. USB_DWC_CTRL2_PHYRS);
  102. __raw_writel(r, base + USB_DWC_CTRL2);
  103. wmb();
  104. }
  105. }
  106. static inline void __au1300_ohci_control(void __iomem *base, int enable, int id)
  107. {
  108. unsigned long r;
  109. if (enable) {
  110. __raw_writel(1, base + USB_DWC_CTRL7); /* start OHCI clock */
  111. wmb();
  112. r = __raw_readl(base + USB_DWC_CTRL3); /* enable OHCI block */
  113. r |= (id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN
  114. : USB_DWC_CTRL3_OHCI1_CKEN;
  115. __raw_writel(r, base + USB_DWC_CTRL3);
  116. wmb();
  117. __au1300_usb_phyctl(base, enable); /* power up the PHYs */
  118. r = __raw_readl(base + USB_INT_ENABLE);
  119. r |= (id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1;
  120. __raw_writel(r, base + USB_INT_ENABLE);
  121. wmb();
  122. /* reset the OHCI start clock bit */
  123. __raw_writel(0, base + USB_DWC_CTRL7);
  124. wmb();
  125. } else {
  126. r = __raw_readl(base + USB_INT_ENABLE);
  127. r &= ~((id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1);
  128. __raw_writel(r, base + USB_INT_ENABLE);
  129. wmb();
  130. r = __raw_readl(base + USB_DWC_CTRL3);
  131. r &= ~((id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN
  132. : USB_DWC_CTRL3_OHCI1_CKEN);
  133. __raw_writel(r, base + USB_DWC_CTRL3);
  134. wmb();
  135. __au1300_usb_phyctl(base, enable);
  136. }
  137. }
  138. static inline void __au1300_ehci_control(void __iomem *base, int enable)
  139. {
  140. unsigned long r;
  141. if (enable) {
  142. r = __raw_readl(base + USB_DWC_CTRL3);
  143. r |= USB_DWC_CTRL3_EHCI0_CKEN;
  144. __raw_writel(r, base + USB_DWC_CTRL3);
  145. wmb();
  146. r = __raw_readl(base + USB_DWC_CTRL1);
  147. r |= USB_DWC_CTRL1_HSTRS;
  148. __raw_writel(r, base + USB_DWC_CTRL1);
  149. wmb();
  150. __au1300_usb_phyctl(base, enable);
  151. r = __raw_readl(base + USB_INT_ENABLE);
  152. r |= USB_INTEN_EHCI;
  153. __raw_writel(r, base + USB_INT_ENABLE);
  154. wmb();
  155. } else {
  156. r = __raw_readl(base + USB_INT_ENABLE);
  157. r &= ~USB_INTEN_EHCI;
  158. __raw_writel(r, base + USB_INT_ENABLE);
  159. wmb();
  160. r = __raw_readl(base + USB_DWC_CTRL1);
  161. r &= ~USB_DWC_CTRL1_HSTRS;
  162. __raw_writel(r, base + USB_DWC_CTRL1);
  163. wmb();
  164. r = __raw_readl(base + USB_DWC_CTRL3);
  165. r &= ~USB_DWC_CTRL3_EHCI0_CKEN;
  166. __raw_writel(r, base + USB_DWC_CTRL3);
  167. wmb();
  168. __au1300_usb_phyctl(base, enable);
  169. }
  170. }
  171. static inline void __au1300_udc_control(void __iomem *base, int enable)
  172. {
  173. unsigned long r;
  174. if (enable) {
  175. r = __raw_readl(base + USB_DWC_CTRL1);
  176. r |= USB_DWC_CTRL1_DCRS;
  177. __raw_writel(r, base + USB_DWC_CTRL1);
  178. wmb();
  179. __au1300_usb_phyctl(base, enable);
  180. r = __raw_readl(base + USB_INT_ENABLE);
  181. r |= USB_INTEN_UDC;
  182. __raw_writel(r, base + USB_INT_ENABLE);
  183. wmb();
  184. } else {
  185. r = __raw_readl(base + USB_INT_ENABLE);
  186. r &= ~USB_INTEN_UDC;
  187. __raw_writel(r, base + USB_INT_ENABLE);
  188. wmb();
  189. r = __raw_readl(base + USB_DWC_CTRL1);
  190. r &= ~USB_DWC_CTRL1_DCRS;
  191. __raw_writel(r, base + USB_DWC_CTRL1);
  192. wmb();
  193. __au1300_usb_phyctl(base, enable);
  194. }
  195. }
  196. static inline void __au1300_otg_control(void __iomem *base, int enable)
  197. {
  198. unsigned long r;
  199. if (enable) {
  200. r = __raw_readl(base + USB_DWC_CTRL3);
  201. r |= USB_DWC_CTRL3_OTG0_CKEN;
  202. __raw_writel(r, base + USB_DWC_CTRL3);
  203. wmb();
  204. r = __raw_readl(base + USB_DWC_CTRL1);
  205. r &= ~USB_DWC_CTRL1_OTGD;
  206. __raw_writel(r, base + USB_DWC_CTRL1);
  207. wmb();
  208. __au1300_usb_phyctl(base, enable);
  209. } else {
  210. r = __raw_readl(base + USB_DWC_CTRL1);
  211. r |= USB_DWC_CTRL1_OTGD;
  212. __raw_writel(r, base + USB_DWC_CTRL1);
  213. wmb();
  214. r = __raw_readl(base + USB_DWC_CTRL3);
  215. r &= ~USB_DWC_CTRL3_OTG0_CKEN;
  216. __raw_writel(r, base + USB_DWC_CTRL3);
  217. wmb();
  218. __au1300_usb_phyctl(base, enable);
  219. }
  220. }
  221. static inline int au1300_usb_control(int block, int enable)
  222. {
  223. void __iomem *base =
  224. (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
  225. int ret = 0;
  226. switch (block) {
  227. case ALCHEMY_USB_OHCI0:
  228. __au1300_ohci_control(base, enable, 0);
  229. break;
  230. case ALCHEMY_USB_OHCI1:
  231. __au1300_ohci_control(base, enable, 1);
  232. break;
  233. case ALCHEMY_USB_EHCI0:
  234. __au1300_ehci_control(base, enable);
  235. break;
  236. case ALCHEMY_USB_UDC0:
  237. __au1300_udc_control(base, enable);
  238. break;
  239. case ALCHEMY_USB_OTG0:
  240. __au1300_otg_control(base, enable);
  241. break;
  242. default:
  243. ret = -ENODEV;
  244. }
  245. return ret;
  246. }
  247. static inline void au1300_usb_init(void)
  248. {
  249. void __iomem *base =
  250. (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
  251. /* set some sane defaults. Note: we don't fiddle with DWC_CTRL4
  252. * here at all: Port 2 routing (EHCI or UDC) must be set either
  253. * by boot firmware or platform init code; I can't autodetect
  254. * a sane setting.
  255. */
  256. __raw_writel(0, base + USB_INT_ENABLE); /* disable all USB irqs */
  257. wmb();
  258. __raw_writel(0, base + USB_DWC_CTRL3); /* disable all clocks */
  259. wmb();
  260. __raw_writel(~0, base + USB_MSR_ERR); /* clear all errors */
  261. wmb();
  262. __raw_writel(~0, base + USB_INT_STATUS); /* clear int status */
  263. wmb();
  264. /* set coherent access bit */
  265. __raw_writel(USB_SBUS_CTRL_SBCA, base + USB_SBUS_CTRL);
  266. wmb();
  267. }
  268. static inline void __au1200_ohci_control(void __iomem *base, int enable)
  269. {
  270. unsigned long r = __raw_readl(base + AU1200_USBCFG);
  271. if (enable) {
  272. __raw_writel(r | USBCFG_OCE, base + AU1200_USBCFG);
  273. wmb();
  274. udelay(2000);
  275. } else {
  276. __raw_writel(r & ~USBCFG_OCE, base + AU1200_USBCFG);
  277. wmb();
  278. udelay(1000);
  279. }
  280. }
  281. static inline void __au1200_ehci_control(void __iomem *base, int enable)
  282. {
  283. unsigned long r = __raw_readl(base + AU1200_USBCFG);
  284. if (enable) {
  285. __raw_writel(r | USBCFG_ECE | USBCFG_PPE, base + AU1200_USBCFG);
  286. wmb();
  287. udelay(1000);
  288. } else {
  289. if (!(r & USBCFG_UCE)) /* UDC also off? */
  290. r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */
  291. __raw_writel(r & ~USBCFG_ECE, base + AU1200_USBCFG);
  292. wmb();
  293. udelay(1000);
  294. }
  295. }
  296. static inline void __au1200_udc_control(void __iomem *base, int enable)
  297. {
  298. unsigned long r = __raw_readl(base + AU1200_USBCFG);
  299. if (enable) {
  300. __raw_writel(r | USBCFG_UCE | USBCFG_PPE, base + AU1200_USBCFG);
  301. wmb();
  302. } else {
  303. if (!(r & USBCFG_ECE)) /* EHCI also off? */
  304. r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */
  305. __raw_writel(r & ~USBCFG_UCE, base + AU1200_USBCFG);
  306. wmb();
  307. }
  308. }
  309. static inline int au1200_usb_control(int block, int enable)
  310. {
  311. void __iomem *base =
  312. (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR);
  313. switch (block) {
  314. case ALCHEMY_USB_OHCI0:
  315. __au1200_ohci_control(base, enable);
  316. break;
  317. case ALCHEMY_USB_UDC0:
  318. __au1200_udc_control(base, enable);
  319. break;
  320. case ALCHEMY_USB_EHCI0:
  321. __au1200_ehci_control(base, enable);
  322. break;
  323. default:
  324. return -ENODEV;
  325. }
  326. return 0;
  327. }
  328. /* initialize USB block(s) to a known working state */
  329. static inline void au1200_usb_init(void)
  330. {
  331. void __iomem *base =
  332. (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR);
  333. __raw_writel(USBCFG_INIT_AU1200, base + AU1200_USBCFG);
  334. wmb();
  335. udelay(1000);
  336. }
  337. static inline int au1000_usb_init(unsigned long rb, int reg)
  338. {
  339. void __iomem *base = (void __iomem *)KSEG1ADDR(rb + reg);
  340. unsigned long r = __raw_readl(base);
  341. struct clk *c;
  342. /* 48MHz check. Don't init if no one can provide it */
  343. c = clk_get(NULL, "usbh_clk");
  344. if (IS_ERR(c))
  345. return -ENODEV;
  346. if (clk_round_rate(c, 48000000) != 48000000) {
  347. clk_put(c);
  348. return -ENODEV;
  349. }
  350. if (clk_set_rate(c, 48000000)) {
  351. clk_put(c);
  352. return -ENODEV;
  353. }
  354. clk_put(c);
  355. #if defined(__BIG_ENDIAN)
  356. r |= USBHEN_BE;
  357. #endif
  358. r |= USBHEN_C;
  359. __raw_writel(r, base);
  360. wmb();
  361. udelay(1000);
  362. return 0;
  363. }
  364. static inline void __au1xx0_ohci_control(int enable, unsigned long rb, int creg)
  365. {
  366. void __iomem *base = (void __iomem *)KSEG1ADDR(rb);
  367. unsigned long r = __raw_readl(base + creg);
  368. struct clk *c = clk_get(NULL, "usbh_clk");
  369. if (IS_ERR(c))
  370. return;
  371. if (enable) {
  372. if (clk_prepare_enable(c))
  373. goto out;
  374. __raw_writel(r | USBHEN_CE, base + creg);
  375. wmb();
  376. udelay(1000);
  377. __raw_writel(r | USBHEN_CE | USBHEN_E, base + creg);
  378. wmb();
  379. udelay(1000);
  380. /* wait for reset complete (read reg twice: au1500 erratum) */
  381. while (__raw_readl(base + creg),
  382. !(__raw_readl(base + creg) & USBHEN_RD))
  383. udelay(1000);
  384. } else {
  385. __raw_writel(r & ~(USBHEN_CE | USBHEN_E), base + creg);
  386. wmb();
  387. clk_disable_unprepare(c);
  388. }
  389. out:
  390. clk_put(c);
  391. }
  392. static inline int au1000_usb_control(int block, int enable, unsigned long rb,
  393. int creg)
  394. {
  395. int ret = 0;
  396. switch (block) {
  397. case ALCHEMY_USB_OHCI0:
  398. __au1xx0_ohci_control(enable, rb, creg);
  399. break;
  400. default:
  401. ret = -ENODEV;
  402. }
  403. return ret;
  404. }
  405. /*
  406. * alchemy_usb_control - control Alchemy on-chip USB blocks
  407. * @block: USB block to target
  408. * @enable: set 1 to enable a block, 0 to disable
  409. */
  410. int alchemy_usb_control(int block, int enable)
  411. {
  412. unsigned long flags;
  413. int ret;
  414. spin_lock_irqsave(&alchemy_usb_lock, flags);
  415. switch (alchemy_get_cputype()) {
  416. case ALCHEMY_CPU_AU1000:
  417. case ALCHEMY_CPU_AU1500:
  418. case ALCHEMY_CPU_AU1100:
  419. ret = au1000_usb_control(block, enable,
  420. AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG);
  421. break;
  422. case ALCHEMY_CPU_AU1550:
  423. ret = au1000_usb_control(block, enable,
  424. AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG);
  425. break;
  426. case ALCHEMY_CPU_AU1200:
  427. ret = au1200_usb_control(block, enable);
  428. break;
  429. case ALCHEMY_CPU_AU1300:
  430. ret = au1300_usb_control(block, enable);
  431. break;
  432. default:
  433. ret = -ENODEV;
  434. }
  435. spin_unlock_irqrestore(&alchemy_usb_lock, flags);
  436. return ret;
  437. }
  438. EXPORT_SYMBOL_GPL(alchemy_usb_control);
  439. static unsigned long alchemy_usb_pmdata[2];
  440. static void au1000_usb_pm(unsigned long br, int creg, int susp)
  441. {
  442. void __iomem *base = (void __iomem *)KSEG1ADDR(br);
  443. if (susp) {
  444. alchemy_usb_pmdata[0] = __raw_readl(base + creg);
  445. /* There appears to be some undocumented reset register.... */
  446. __raw_writel(0, base + 0x04);
  447. wmb();
  448. __raw_writel(0, base + creg);
  449. wmb();
  450. } else {
  451. __raw_writel(alchemy_usb_pmdata[0], base + creg);
  452. wmb();
  453. }
  454. }
  455. static void au1200_usb_pm(int susp)
  456. {
  457. void __iomem *base =
  458. (void __iomem *)KSEG1ADDR(AU1200_USB_OTG_PHYS_ADDR);
  459. if (susp) {
  460. /* save OTG_CAP/MUX registers which indicate port routing */
  461. /* FIXME: write an OTG driver to do that */
  462. alchemy_usb_pmdata[0] = __raw_readl(base + 0x00);
  463. alchemy_usb_pmdata[1] = __raw_readl(base + 0x04);
  464. } else {
  465. /* restore access to all MMIO areas */
  466. au1200_usb_init();
  467. /* restore OTG_CAP/MUX registers */
  468. __raw_writel(alchemy_usb_pmdata[0], base + 0x00);
  469. __raw_writel(alchemy_usb_pmdata[1], base + 0x04);
  470. wmb();
  471. }
  472. }
  473. static void au1300_usb_pm(int susp)
  474. {
  475. void __iomem *base =
  476. (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
  477. /* remember Port2 routing */
  478. if (susp) {
  479. alchemy_usb_pmdata[0] = __raw_readl(base + USB_DWC_CTRL4);
  480. } else {
  481. au1300_usb_init();
  482. __raw_writel(alchemy_usb_pmdata[0], base + USB_DWC_CTRL4);
  483. wmb();
  484. }
  485. }
  486. static void alchemy_usb_pm(int susp)
  487. {
  488. switch (alchemy_get_cputype()) {
  489. case ALCHEMY_CPU_AU1000:
  490. case ALCHEMY_CPU_AU1500:
  491. case ALCHEMY_CPU_AU1100:
  492. au1000_usb_pm(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG, susp);
  493. break;
  494. case ALCHEMY_CPU_AU1550:
  495. au1000_usb_pm(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG, susp);
  496. break;
  497. case ALCHEMY_CPU_AU1200:
  498. au1200_usb_pm(susp);
  499. break;
  500. case ALCHEMY_CPU_AU1300:
  501. au1300_usb_pm(susp);
  502. break;
  503. }
  504. }
  505. static int alchemy_usb_suspend(void)
  506. {
  507. alchemy_usb_pm(1);
  508. return 0;
  509. }
  510. static void alchemy_usb_resume(void)
  511. {
  512. alchemy_usb_pm(0);
  513. }
  514. static struct syscore_ops alchemy_usb_pm_ops = {
  515. .suspend = alchemy_usb_suspend,
  516. .resume = alchemy_usb_resume,
  517. };
  518. static int __init alchemy_usb_init(void)
  519. {
  520. int ret = 0;
  521. switch (alchemy_get_cputype()) {
  522. case ALCHEMY_CPU_AU1000:
  523. case ALCHEMY_CPU_AU1500:
  524. case ALCHEMY_CPU_AU1100:
  525. ret = au1000_usb_init(AU1000_USB_OHCI_PHYS_ADDR,
  526. AU1000_OHCICFG);
  527. break;
  528. case ALCHEMY_CPU_AU1550:
  529. ret = au1000_usb_init(AU1550_USB_OHCI_PHYS_ADDR,
  530. AU1550_OHCICFG);
  531. break;
  532. case ALCHEMY_CPU_AU1200:
  533. au1200_usb_init();
  534. break;
  535. case ALCHEMY_CPU_AU1300:
  536. au1300_usb_init();
  537. break;
  538. }
  539. if (!ret)
  540. register_syscore_ops(&alchemy_usb_pm_ops);
  541. return ret;
  542. }
  543. arch_initcall(alchemy_usb_init);