History

ARM: omap1: move omap15xx local bus handling to usb.c

Commit 38225f2ef2f4 ("ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets") removed a lot of mach/memory.h, but left the USB offset handling split into arch/arm/mach-omap1/usb.c and drivers/usb/host/ohci-omap.c. This can cause a randconfig build warning that now fails the build with -Werror: arch/arm/mach-omap1/usb.c:561:30: error: 'omap_1510_usb_ohci_nb' defined but not used [-Werror=unused-variable] 561 | static struct notifier_block omap_1510_usb_ohci_nb = { | ^~~~~~~~~~~~~~~~~~~~~ Move it all into the platform file to get rid of the final location that relies on mach/memory.h.

Arnd Bergmann committed 5 years ago

Commit 94ad8aa1 parent 6147eb54 files · +86 −116Browse files

Unified · Split

4 files
  1. arch/arm/mach-omap1/include/mach/memory.h +0 −12
  2. arch/arm/mach-omap1/usb.c +82 −34
  3. drivers/usb/host/ohci-omap.c +2 −70
  4. include/linux/platform_data/usb-omap1.h +2 −0
arch/arm/mach-omap1/include/mach/memory.h+0−12
@@ -9,16 +9,4 @@ · 8 unmodified lines
99 /* REVISIT: omap1 legacy drivers still rely on this */
1010 #include <mach/soc.h>
1111
12−/*
13− * Bus address is physical address, except for OMAP-1510 Local Bus.
14− * OMAP-1510 bus address is translated into a Local Bus address if the
15− * OMAP bus type is lbus. We do the address translation based on the
16− * device overriding the defaults used in the dma-mapping API.
17− */
18−
19−/*
20− * OMAP-1510 Local Bus address offset
21− */
22−#define OMAP1510_LB_OFFSET UL(0x30000000)
23−
2412 #endif
arch/arm/mach-omap1/usb.c+82−34
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <linux/platform_device.h>
1212 #include <linux/dma-map-ops.h>
1313 #include <linux/io.h>
14+#include <linux/delay.h>
1415
1516 #include <asm/irq.h>
1617
@@ -206,8 +207,6 @@ static inline void udc_device_init(struct omap_usb_config *pdata) · 189 unmodified lines
206207
207208 #endif
208209
209−#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
210−
211210 /* The dmamask must be set for OHCI to work */
212211 static u64 ohci_dmamask = ~(u32)0;
213212
@@ -236,20 +235,15 @@ static struct platform_device ohci_device = { · 22 unmodified lines
236235
237236 static inline void ohci_device_init(struct omap_usb_config *pdata)
238237 {
238+ if (!IS_ENABLED(CONFIG_USB_OHCI_HCD))
239+ return;
240+
239241 if (cpu_is_omap7xx())
240242 ohci_resources[1].start = INT_7XX_USB_HHC_1;
241243 pdata->ohci_device = &ohci_device;
242244 pdata->ocpi_enable = &ocpi_enable;
243245 }
244246
245−#else
246−
247−static inline void ohci_device_init(struct omap_usb_config *pdata)
248−{
249−}
250−
251−#endif
252−
253247 #if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
254248
255249 static struct resource otg_resources[] = {
@@ -534,33 +528,87 @@ bad: · 278 unmodified lines
534528 }
535529
536530 #ifdef CONFIG_ARCH_OMAP15XX
531+/* OMAP-1510 OHCI has its own MMU for DMA */
532+#define OMAP1510_LB_MEMSIZE 32 /* Should be same as SDRAM size */
533+#define OMAP1510_LB_CLOCK_DIV 0xfffec10c
534+#define OMAP1510_LB_MMU_CTL 0xfffec208
535+#define OMAP1510_LB_MMU_LCK 0xfffec224
536+#define OMAP1510_LB_MMU_LD_TLB 0xfffec228
537+#define OMAP1510_LB_MMU_CAM_H 0xfffec22c
538+#define OMAP1510_LB_MMU_CAM_L 0xfffec230
539+#define OMAP1510_LB_MMU_RAM_H 0xfffec234
540+#define OMAP1510_LB_MMU_RAM_L 0xfffec238
537541
538−/* ULPD_DPLL_CTRL */
539−#define DPLL_IOB (1 << 13)
540−#define DPLL_PLL_ENABLE (1 << 4)
541−#define DPLL_LOCK (1 << 0)
542+/*
543+ * Bus address is physical address, except for OMAP-1510 Local Bus.
544+ * OMAP-1510 bus address is translated into a Local Bus address if the
545+ * OMAP bus type is lbus.
546+ */
547+#define OMAP1510_LB_OFFSET UL(0x30000000)
542548
543−/* ULPD_APLL_CTRL */
544−#define APLL_NDPLL_SWITCH (1 << 0)
549+/*
550+ * OMAP-1510 specific Local Bus clock on/off
551+ */
552+static int omap_1510_local_bus_power(int on)
553+{
554+ if (on) {
555+ omap_writel((1 << 1) | (1 << 0), OMAP1510_LB_MMU_CTL);
556+ udelay(200);
557+ } else {
558+ omap_writel(0, OMAP1510_LB_MMU_CTL);
559+ }
545560
546−static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
547− unsigned long event, void *data)
561+ return 0;
562+}
563+
564+/*
565+ * OMAP-1510 specific Local Bus initialization
566+ * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE.
567+ * See also arch/mach-omap/memory.h for __virt_to_dma() and
568+ * __dma_to_virt() which need to match with the physical
569+ * Local Bus address below.
570+ */
571+static int omap_1510_local_bus_init(void)
548572 {
549− struct device *dev = data;
573+ unsigned int tlb;
574+ unsigned long lbaddr, physaddr;
575+
576+ omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4,
577+ OMAP1510_LB_CLOCK_DIV);
578+
579+ /* Configure the Local Bus MMU table */
580+ for (tlb = 0; tlb < OMAP1510_LB_MEMSIZE; tlb++) {
581+ lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET;
582+ physaddr = tlb * 0x00100000 + PHYS_OFFSET;
583+ omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H);
584+ omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc,
585+ OMAP1510_LB_MMU_CAM_L);
586+ omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H);
587+ omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L);
588+ omap_writel(tlb << 4, OMAP1510_LB_MMU_LCK);
589+ omap_writel(0x1, OMAP1510_LB_MMU_LD_TLB);
590+ }
550591
551− if (event != BUS_NOTIFY_ADD_DEVICE)
552− return NOTIFY_DONE;
592+ /* Enable the walking table */
593+ omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL);
594+ udelay(200);
553595
554− if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
555− dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
556− (u64)-1))
557− WARN_ONCE(1, "failed to set DMA offset\n");
558− return NOTIFY_OK;
596+ return 0;
559597 }
560598
561−static struct notifier_block omap_1510_usb_ohci_nb = {
562− .notifier_call = omap_1510_usb_ohci_notifier,
563−};
599+static void omap_1510_local_bus_reset(void)
600+{
601+ omap_1510_local_bus_power(1);
602+ omap_1510_local_bus_init();
603+}
604+
605+/* ULPD_DPLL_CTRL */
606+#define DPLL_IOB (1 << 13)
607+#define DPLL_PLL_ENABLE (1 << 4)
608+#define DPLL_LOCK (1 << 0)
609+
610+/* ULPD_APLL_CTRL */
611+#define APLL_NDPLL_SWITCH (1 << 0)
564612
565613 static void __init omap_1510_usb_init(struct omap_usb_config *config)
566614 {
@@ -616,19 +664,19 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config) · 49 unmodified lines
616664 }
617665 #endif
618666
619−#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
620− if (config->register_host) {
667+ if (IS_ENABLED(CONFIG_USB_OHCI_HCD) && config->register_host) {
621668 int status;
622669
623− bus_register_notifier(&platform_bus_type,
624− &omap_1510_usb_ohci_nb);
625670 ohci_device.dev.platform_data = config;
671+ dma_direct_set_offset(&ohci_device.dev, PHYS_OFFSET,
672+ OMAP1510_LB_OFFSET, (u64)-1);
626673 status = platform_device_register(&ohci_device);
627674 if (status)
628675 pr_debug("can't register OHCI device, %d\n", status);
629676 /* hcd explicitly gates 48MHz */
677+
678+ config->lb_reset = omap_1510_local_bus_reset;
630679 }
631−#endif
632680 }
633681
634682 #else
drivers/usb/host/ohci-omap.c+2−70
@@ -40,17 +40,6 @@ · 39 unmodified lines
4040 #include <mach/usb.h>
4141
4242
43−/* OMAP-1510 OHCI has its own MMU for DMA */
44−#define OMAP1510_LB_MEMSIZE 32 /* Should be same as SDRAM size */
45−#define OMAP1510_LB_CLOCK_DIV 0xfffec10c
46−#define OMAP1510_LB_MMU_CTL 0xfffec208
47−#define OMAP1510_LB_MMU_LCK 0xfffec224
48−#define OMAP1510_LB_MMU_LD_TLB 0xfffec228
49−#define OMAP1510_LB_MMU_CAM_H 0xfffec22c
50−#define OMAP1510_LB_MMU_CAM_L 0xfffec230
51−#define OMAP1510_LB_MMU_RAM_H 0xfffec234
52−#define OMAP1510_LB_MMU_RAM_L 0xfffec238
53−
5443 #define DRIVER_DESC "OHCI OMAP driver"
5544
5645 struct ohci_omap_priv {
@@ -104,61 +93,6 @@ static int omap_ohci_transceiver_power(struct ohci_omap_priv *priv, int on) · 47 unmodified lines
10493 return 0;
10594 }
10695
107−#ifdef CONFIG_ARCH_OMAP15XX
108−/*
109− * OMAP-1510 specific Local Bus clock on/off
110− */
111−static int omap_1510_local_bus_power(int on)
112−{
113− if (on) {
114− omap_writel((1 << 1) | (1 << 0), OMAP1510_LB_MMU_CTL);
115− udelay(200);
116− } else {
117− omap_writel(0, OMAP1510_LB_MMU_CTL);
118− }
119−
120− return 0;
121−}
122−
123−/*
124− * OMAP-1510 specific Local Bus initialization
125− * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE.
126− * See also arch/mach-omap/memory.h for __virt_to_dma() and
127− * __dma_to_virt() which need to match with the physical
128− * Local Bus address below.
129− */
130−static int omap_1510_local_bus_init(void)
131−{
132− unsigned int tlb;
133− unsigned long lbaddr, physaddr;
134−
135− omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4,
136− OMAP1510_LB_CLOCK_DIV);
137−
138− /* Configure the Local Bus MMU table */
139− for (tlb = 0; tlb < OMAP1510_LB_MEMSIZE; tlb++) {
140− lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET;
141− physaddr = tlb * 0x00100000 + PHYS_OFFSET;
142− omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H);
143− omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc,
144− OMAP1510_LB_MMU_CAM_L);
145− omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H);
146− omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L);
147− omap_writel(tlb << 4, OMAP1510_LB_MMU_LCK);
148− omap_writel(0x1, OMAP1510_LB_MMU_LD_TLB);
149− }
150−
151− /* Enable the walking table */
152− omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL);
153− udelay(200);
154−
155− return 0;
156−}
157−#else
158−#define omap_1510_local_bus_power(x) {}
159−#define omap_1510_local_bus_init() {}
160−#endif
161−
16296 #ifdef CONFIG_USB_OTG
16397
16498 static void start_hnp(struct ohci_hcd *ohci)
@@ -229,10 +163,8 @@ static int ohci_omap_reset(struct usb_hcd *hcd) · 64 unmodified lines
229163
230164 omap_ohci_clock_power(priv, 1);
231165
232− if (cpu_is_omap15xx()) {
233− omap_1510_local_bus_power(1);
234− omap_1510_local_bus_init();
235− }
166+ if (config->lb_reset)
167+ config->lb_reset();
236168
237169 ret = ohci_setup(hcd);
238170 if (ret < 0)
include/linux/platform_data/usb-omap1.h+2−0
@@ -48,6 +48,8 @@ struct omap_usb_config { · 47 unmodified lines
4848 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
4949
5050 int (*ocpi_enable)(void);
51+
52+ void (*lb_reset)(void);
5153 };
5254
5355 #endif /* __LINUX_USB_OMAP1_H */