diff options
author | Jayachandran C <jayachandranc@netlogicmicro.com> | 2012-07-24 11:28:53 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-24 11:28:53 -0400 |
commit | f35574a3abe4fc85db6d3d7f7915f7e857373155 (patch) | |
tree | 8298fd312ec1331aec44a47b47302e072df36926 /arch/mips/netlogic/xlr/platform.c | |
parent | c5a48ff81e25c8585dae981a6cc19ed55788cadf (diff) |
MIPS: Netlogic: Platform changes for XLS USB
Add USB initialization code, setup resources and add USB platform
driver in mips/netlogic/xlr/platform.c.
Add USB support for XLR/XLS platform in Kconfig.
Signed-off-by: Jayachandran C <jayachandranc@netlogicmicro.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3759/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/netlogic/xlr/platform.c')
-rw-r--r-- | arch/mips/netlogic/xlr/platform.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/arch/mips/netlogic/xlr/platform.c b/arch/mips/netlogic/xlr/platform.c index eab64b45dffd..cb0ab63089db 100644 --- a/arch/mips/netlogic/xlr/platform.c +++ b/arch/mips/netlogic/xlr/platform.c | |||
@@ -97,3 +97,92 @@ static int __init nlm_uart_init(void) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | arch_initcall(nlm_uart_init); | 99 | arch_initcall(nlm_uart_init); |
100 | |||
101 | #ifdef CONFIG_USB | ||
102 | /* Platform USB devices, only on XLS chips */ | ||
103 | static u64 xls_usb_dmamask = ~(u32)0; | ||
104 | #define USB_PLATFORM_DEV(n, i, irq) \ | ||
105 | { \ | ||
106 | .name = n, \ | ||
107 | .id = i, \ | ||
108 | .num_resources = 2, \ | ||
109 | .dev = { \ | ||
110 | .dma_mask = &xls_usb_dmamask, \ | ||
111 | .coherent_dma_mask = 0xffffffff, \ | ||
112 | }, \ | ||
113 | .resource = (struct resource[]) { \ | ||
114 | { \ | ||
115 | .flags = IORESOURCE_MEM, \ | ||
116 | }, \ | ||
117 | { \ | ||
118 | .start = irq, \ | ||
119 | .end = irq, \ | ||
120 | .flags = IORESOURCE_IRQ, \ | ||
121 | }, \ | ||
122 | }, \ | ||
123 | } | ||
124 | |||
125 | static struct platform_device xls_usb_ehci_device = | ||
126 | USB_PLATFORM_DEV("ehci-xls", 0, PIC_USB_IRQ); | ||
127 | static struct platform_device xls_usb_ohci_device_0 = | ||
128 | USB_PLATFORM_DEV("ohci-xls-0", 1, PIC_USB_IRQ); | ||
129 | static struct platform_device xls_usb_ohci_device_1 = | ||
130 | USB_PLATFORM_DEV("ohci-xls-1", 2, PIC_USB_IRQ); | ||
131 | |||
132 | static struct platform_device *xls_platform_devices[] = { | ||
133 | &xls_usb_ehci_device, | ||
134 | &xls_usb_ohci_device_0, | ||
135 | &xls_usb_ohci_device_1, | ||
136 | }; | ||
137 | |||
138 | int xls_platform_usb_init(void) | ||
139 | { | ||
140 | uint64_t usb_mmio, gpio_mmio; | ||
141 | unsigned long memres; | ||
142 | uint32_t val; | ||
143 | |||
144 | if (!nlm_chip_is_xls()) | ||
145 | return 0; | ||
146 | |||
147 | gpio_mmio = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET); | ||
148 | usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_1_OFFSET); | ||
149 | |||
150 | /* Clear Rogue Phy INTs */ | ||
151 | nlm_write_reg(usb_mmio, 49, 0x10000000); | ||
152 | /* Enable all interrupts */ | ||
153 | nlm_write_reg(usb_mmio, 50, 0x1f000000); | ||
154 | |||
155 | /* Enable ports */ | ||
156 | nlm_write_reg(usb_mmio, 1, 0x07000500); | ||
157 | |||
158 | val = nlm_read_reg(gpio_mmio, 21); | ||
159 | if (((val >> 22) & 0x01) == 0) { | ||
160 | pr_info("Detected USB Device mode - Not supported!\n"); | ||
161 | nlm_write_reg(usb_mmio, 0, 0x01000000); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | pr_info("Detected USB Host mode - Adding XLS USB devices.\n"); | ||
166 | /* Clear reset, host mode */ | ||
167 | nlm_write_reg(usb_mmio, 0, 0x02000000); | ||
168 | |||
169 | /* Memory resource for various XLS usb ports */ | ||
170 | usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_0_OFFSET); | ||
171 | memres = CPHYSADDR((unsigned long)usb_mmio); | ||
172 | xls_usb_ehci_device.resource[0].start = memres; | ||
173 | xls_usb_ehci_device.resource[0].end = memres + 0x400 - 1; | ||
174 | |||
175 | memres += 0x400; | ||
176 | xls_usb_ohci_device_0.resource[0].start = memres; | ||
177 | xls_usb_ohci_device_0.resource[0].end = memres + 0x400 - 1; | ||
178 | |||
179 | memres += 0x400; | ||
180 | xls_usb_ohci_device_1.resource[0].start = memres; | ||
181 | xls_usb_ohci_device_1.resource[0].end = memres + 0x400 - 1; | ||
182 | |||
183 | return platform_add_devices(xls_platform_devices, | ||
184 | ARRAY_SIZE(xls_platform_devices)); | ||
185 | } | ||
186 | |||
187 | arch_initcall(xls_platform_usb_init); | ||
188 | #endif | ||