14 #include <linux/module.h>
20 #define AU1000_OHCICFG 0x7fffc
21 #define AU1550_OHCICFG 0x07ffc
22 #define AU1200_USBCFG 0x04
25 #define USBHEN_RD (1 << 4)
26 #define USBHEN_CE (1 << 3)
27 #define USBHEN_E (1 << 2)
28 #define USBHEN_C (1 << 1)
29 #define USBHEN_BE (1 << 0)
32 #define USBCFG_PFEN (1 << 31)
33 #define USBCFG_RDCOMB (1 << 30)
34 #define USBCFG_UNKNOWN (5 << 20)
35 #define USBCFG_SSD (1 << 23)
36 #define USBCFG_PPE (1 << 19)
37 #define USBCFG_UCE (1 << 18)
38 #define USBCFG_ECE (1 << 17)
39 #define USBCFG_OCE (1 << 16)
40 #define USBCFG_FLA(x) (((x) & 0x3f) << 8)
41 #define USBCFG_UCAM (1 << 7)
42 #define USBCFG_GME (1 << 6)
43 #define USBCFG_DBE (1 << 5)
44 #define USBCFG_DME (1 << 4)
45 #define USBCFG_EBE (1 << 3)
46 #define USBCFG_EME (1 << 2)
47 #define USBCFG_OBE (1 << 1)
48 #define USBCFG_OME (1 << 0)
49 #define USBCFG_INIT_AU1200 (USBCFG_PFEN | USBCFG_RDCOMB | USBCFG_UNKNOWN |\
50 USBCFG_SSD | USBCFG_FLA(0x20) | USBCFG_UCAM | \
51 USBCFG_GME | USBCFG_DBE | USBCFG_DME | \
52 USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \
56 #define USB_DWC_CTRL1 0x00
57 #define USB_DWC_CTRL2 0x04
58 #define USB_VBUS_TIMER 0x10
59 #define USB_SBUS_CTRL 0x14
60 #define USB_MSR_ERR 0x18
61 #define USB_DWC_CTRL3 0x1C
62 #define USB_DWC_CTRL4 0x20
63 #define USB_OTG_STATUS 0x28
64 #define USB_DWC_CTRL5 0x2C
65 #define USB_DWC_CTRL6 0x30
66 #define USB_DWC_CTRL7 0x34
67 #define USB_PHY_STATUS 0xC0
68 #define USB_INT_STATUS 0xC4
69 #define USB_INT_ENABLE 0xC8
71 #define USB_DWC_CTRL1_OTGD 0x04
72 #define USB_DWC_CTRL1_HSTRS 0x02
73 #define USB_DWC_CTRL1_DCRS 0x01
75 #define USB_DWC_CTRL2_PHY1RS 0x04
76 #define USB_DWC_CTRL2_PHY0RS 0x02
77 #define USB_DWC_CTRL2_PHYRS 0x01
79 #define USB_DWC_CTRL3_OHCI1_CKEN (1 << 19)
80 #define USB_DWC_CTRL3_OHCI0_CKEN (1 << 18)
81 #define USB_DWC_CTRL3_EHCI0_CKEN (1 << 17)
82 #define USB_DWC_CTRL3_OTG0_CKEN (1 << 16)
84 #define USB_SBUS_CTRL_SBCA 0x04
86 #define USB_INTEN_FORCE 0x20
87 #define USB_INTEN_PHY 0x10
88 #define USB_INTEN_UDC 0x08
89 #define USB_INTEN_EHCI 0x04
90 #define USB_INTEN_OHCI1 0x02
91 #define USB_INTEN_OHCI0 0x01
95 static inline void __au1300_usb_phyctl(
void __iomem *base,
int enable)
120 static inline void __au1300_ohci_control(
void __iomem *base,
int enable,
int id)
134 __au1300_usb_phyctl(base, enable);
156 __au1300_usb_phyctl(base, enable);
160 static inline void __au1300_ehci_control(
void __iomem *base,
int enable)
175 __au1300_usb_phyctl(base, enable);
197 __au1300_usb_phyctl(base, enable);
201 static inline void __au1300_udc_control(
void __iomem *base,
int enable)
211 __au1300_usb_phyctl(base, enable);
228 __au1300_usb_phyctl(base, enable);
232 static inline void __au1300_otg_control(
void __iomem *base,
int enable)
246 __au1300_usb_phyctl(base, enable);
258 __au1300_usb_phyctl(base, enable);
262 static inline int au1300_usb_control(
int block,
int enable)
270 __au1300_ohci_control(base, enable, 0);
273 __au1300_ohci_control(base, enable, 1);
276 __au1300_ehci_control(base, enable);
279 __au1300_udc_control(base, enable);
282 __au1300_otg_control(base, enable);
290 static inline void au1300_usb_init(
void)
313 static inline void __au1200_ohci_control(
void __iomem *base,
int enable)
327 static inline void __au1200_ehci_control(
void __iomem *base,
int enable)
343 static inline void __au1200_udc_control(
void __iomem *base,
int enable)
357 static inline int au1200_coherency_bug(
void)
359 #if defined(CONFIG_DMA_COHERENT)
371 static inline int au1200_usb_control(
int block,
int enable)
379 ret = au1200_coherency_bug();
382 __au1200_ohci_control(base, enable);
385 __au1200_udc_control(base, enable);
388 ret = au1200_coherency_bug();
391 __au1200_ehci_control(base, enable);
402 static inline void au1200_usb_init(
void)
411 static inline void au1000_usb_init(
unsigned long rb,
int reg)
416 #if defined(__BIG_ENDIAN)
427 static inline void __au1xx0_ohci_control(
int enable,
unsigned long rb,
int creg)
450 static inline int au1000_usb_control(
int block,
int enable,
unsigned long rb,
457 __au1xx0_ohci_control(enable, rb, creg);
476 switch (alchemy_get_cputype()) {
480 ret = au1000_usb_control(block, enable,
484 ret = au1000_usb_control(block, enable,
488 ret = au1200_usb_control(block, enable);
491 ret = au1300_usb_control(block, enable);
496 spin_unlock_irqrestore(&alchemy_usb_lock, flags);
502 static unsigned long alchemy_usb_pmdata[2];
504 static void au1000_usb_pm(
unsigned long br,
int creg,
int susp)
521 static void au1200_usb_pm(
int susp)
541 static void au1300_usb_pm(
int susp)
555 static void alchemy_usb_pm(
int susp)
557 switch (alchemy_get_cputype()) {
575 static int alchemy_usb_suspend(
void)
581 static void alchemy_usb_resume(
void)
587 .suspend = alchemy_usb_suspend,
588 .resume = alchemy_usb_resume,
591 static int __init alchemy_usb_init(
void)
593 switch (alchemy_get_cputype()) {