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
9/* REVISIT: omap1 legacy drivers still rely on this */9/* REVISIT: omap1 legacy drivers still rely on this */
10#include <mach/soc.h>10#include <mach/soc.h>
11 11
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
24#endif12#endif
arch/arm/mach-omap1/usb.c+82−34
@@ -11,6 +11,7 @@ · 10 unmodified lines
11#include <linux/platform_device.h>11#include <linux/platform_device.h>
12#include <linux/dma-map-ops.h>12#include <linux/dma-map-ops.h>
13#include <linux/io.h>13#include <linux/io.h>
14#include <linux/delay.h>
14 15
15#include <asm/irq.h>16#include <asm/irq.h>
16 17
@@ -206,8 +207,6 @@ static inline void udc_device_init(struct omap_usb_config *pdata) · 189 unmodified lines
206 207
207#endif208#endif
208 209
209#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
210
211/* The dmamask must be set for OHCI to work */210/* The dmamask must be set for OHCI to work */
212static u64 ohci_dmamask = ~(u32)0;211static u64 ohci_dmamask = ~(u32)0;
213 212
@@ -236,20 +235,15 @@ static struct platform_device ohci_device = { · 22 unmodified lines
236 235
237static inline void ohci_device_init(struct omap_usb_config *pdata)236static inline void ohci_device_init(struct omap_usb_config *pdata)
238{237{
238 if (!IS_ENABLED(CONFIG_USB_OHCI_HCD))
239 return;
240
239 if (cpu_is_omap7xx())241 if (cpu_is_omap7xx())
240 ohci_resources[1].start = INT_7XX_USB_HHC_1;242 ohci_resources[1].start = INT_7XX_USB_HHC_1;
241 pdata->ohci_device = &ohci_device;243 pdata->ohci_device = &ohci_device;
242 pdata->ocpi_enable = &ocpi_enable;244 pdata->ocpi_enable = &ocpi_enable;
243}245}
244 246
245#else
246
247static inline void ohci_device_init(struct omap_usb_config *pdata)
248{
249}
250
251#endif
252
253#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)247#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
254 248
255static struct resource otg_resources[] = {249static struct resource otg_resources[] = {
@@ -534,33 +528,87 @@ bad: · 278 unmodified lines
534}528}
535 529
536#ifdef CONFIG_ARCH_OMAP15XX530#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
537 541
538/* ULPD_DPLL_CTRL */542/*
539#define DPLL_IOB (1 << 13)543 * Bus address is physical address, except for OMAP-1510 Local Bus.
540#define DPLL_PLL_ENABLE (1 << 4)544 * OMAP-1510 bus address is translated into a Local Bus address if the
541#define DPLL_LOCK (1 << 0)545 * OMAP bus type is lbus.
546 */
547#define OMAP1510_LB_OFFSET UL(0x30000000)
542 548
543/* ULPD_APLL_CTRL */549/*
544#define APLL_NDPLL_SWITCH (1 << 0)550 * OMAP-1510 specific Local Bus clock on/off
551 */
552static 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 }
545 560
546static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,561 return 0;
547 unsigned long event, void *data)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 */
571static int omap_1510_local_bus_init(void)
548{572{
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 }
550 591
551 if (event != BUS_NOTIFY_ADD_DEVICE)592 /* Enable the walking table */
552 return NOTIFY_DONE;593 omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL);
594 udelay(200);
553 595
554 if (strncmp(dev_name(dev), "ohci", 4) == 0 &&596 return 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;
559}597}
560 598
561static struct notifier_block omap_1510_usb_ohci_nb = {599static void omap_1510_local_bus_reset(void)
562 .notifier_call = omap_1510_usb_ohci_notifier,600{
563};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)
564 612
565static void __init omap_1510_usb_init(struct omap_usb_config *config)613static void __init omap_1510_usb_init(struct omap_usb_config *config)
566{614{
@@ -616,19 +664,19 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config) · 49 unmodified lines
616 }664 }
617#endif665#endif
618 666
619#if IS_ENABLED(CONFIG_USB_OHCI_HCD)667 if (IS_ENABLED(CONFIG_USB_OHCI_HCD) && config->register_host) {
620 if (config->register_host) {
621 int status;668 int status;
622 669
623 bus_register_notifier(&platform_bus_type,
624 &omap_1510_usb_ohci_nb);
625 ohci_device.dev.platform_data = config;670 ohci_device.dev.platform_data = config;
671 dma_direct_set_offset(&ohci_device.dev, PHYS_OFFSET,
672 OMAP1510_LB_OFFSET, (u64)-1);
626 status = platform_device_register(&ohci_device);673 status = platform_device_register(&ohci_device);
627 if (status)674 if (status)
628 pr_debug("can't register OHCI device, %d\n", status);675 pr_debug("can't register OHCI device, %d\n", status);
629 /* hcd explicitly gates 48MHz */676 /* hcd explicitly gates 48MHz */
677
678 config->lb_reset = omap_1510_local_bus_reset;
630 }679 }
631#endif
632}680}
633 681
634#else682#else
drivers/usb/host/ohci-omap.c+2−70
@@ -40,17 +40,6 @@ · 39 unmodified lines
40#include <mach/usb.h>40#include <mach/usb.h>
41 41
42 42
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
54#define DRIVER_DESC "OHCI OMAP driver"43#define DRIVER_DESC "OHCI OMAP driver"
55 44
56struct ohci_omap_priv {45struct ohci_omap_priv {
@@ -104,61 +93,6 @@ static int omap_ohci_transceiver_power(struct ohci_omap_priv *priv, int on) · 47 unmodified lines
104 return 0;93 return 0;
105}94}
106 95
107#ifdef CONFIG_ARCH_OMAP15XX
108/*
109 * OMAP-1510 specific Local Bus clock on/off
110 */
111static 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 */
130static 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
162#ifdef CONFIG_USB_OTG96#ifdef CONFIG_USB_OTG
163 97
164static void start_hnp(struct ohci_hcd *ohci)98static void start_hnp(struct ohci_hcd *ohci)
@@ -229,10 +163,8 @@ static int ohci_omap_reset(struct usb_hcd *hcd) · 64 unmodified lines
229 163
230 omap_ohci_clock_power(priv, 1);164 omap_ohci_clock_power(priv, 1);
231 165
232 if (cpu_is_omap15xx()) {166 if (config->lb_reset)
233 omap_1510_local_bus_power(1);167 config->lb_reset();
234 omap_1510_local_bus_init();
235 }
236 168
237 ret = ohci_setup(hcd);169 ret = ohci_setup(hcd);
238 if (ret < 0)170 if (ret < 0)
include/linux/platform_data/usb-omap1.h+2−0
@@ -48,6 +48,8 @@ struct omap_usb_config { · 47 unmodified lines
48 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);48 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
49 49
50 int (*ocpi_enable)(void);50 int (*ocpi_enable)(void);
51
52 void (*lb_reset)(void);
51};53};
52 54
53#endif /* __LINUX_USB_OMAP1_H */55#endif /* __LINUX_USB_OMAP1_H */