Commit f35574a3abe4fc85db6d3d7f7915f7e857373155
Committed by
Ralf Baechle
1 parent
c5a48ff81e
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 2 changed files with 91 additions and 0 deletions Side-by-side Diff
arch/mips/Kconfig
... | ... | @@ -787,6 +787,8 @@ |
787 | 787 | select ZONE_DMA if 64BIT |
788 | 788 | select SYNC_R4K |
789 | 789 | select SYS_HAS_EARLY_PRINTK |
790 | + select USB_ARCH_HAS_OHCI if USB_SUPPORT | |
791 | + select USB_ARCH_HAS_EHCI if USB_SUPPORT | |
790 | 792 | help |
791 | 793 | Support for systems based on Netlogic XLR and XLS processors. |
792 | 794 | Say Y here if you have a XLR or XLS based board. |
arch/mips/netlogic/xlr/platform.c
... | ... | @@ -97,4 +97,93 @@ |
97 | 97 | } |
98 | 98 | |
99 | 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 |