ARM: omap1: move omap15xx local bus handling to usb.c
Commit 38225f2ef2 ("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.
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210927144118.2464881-1-arnd@kernel.org'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -9,16 +9,4 @@
|
|||||||
/* REVISIT: omap1 legacy drivers still rely on this */
|
/* REVISIT: omap1 legacy drivers still rely on this */
|
||||||
#include <mach/soc.h>
|
#include <mach/soc.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Bus address is physical address, except for OMAP-1510 Local Bus.
|
|
||||||
* OMAP-1510 bus address is translated into a Local Bus address if the
|
|
||||||
* OMAP bus type is lbus. We do the address translation based on the
|
|
||||||
* device overriding the defaults used in the dma-mapping API.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* OMAP-1510 Local Bus address offset
|
|
||||||
*/
|
|
||||||
#define OMAP1510_LB_OFFSET UL(0x30000000)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/dma-map-ops.h>
|
#include <linux/dma-map-ops.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#include <asm/irq.h>
|
#include <asm/irq.h>
|
||||||
|
|
||||||
@@ -206,8 +207,6 @@ static inline void udc_device_init(struct omap_usb_config *pdata)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
|
|
||||||
|
|
||||||
/* The dmamask must be set for OHCI to work */
|
/* The dmamask must be set for OHCI to work */
|
||||||
static u64 ohci_dmamask = ~(u32)0;
|
static u64 ohci_dmamask = ~(u32)0;
|
||||||
|
|
||||||
@@ -236,20 +235,15 @@ static struct platform_device ohci_device = {
|
|||||||
|
|
||||||
static inline void ohci_device_init(struct omap_usb_config *pdata)
|
static inline void ohci_device_init(struct omap_usb_config *pdata)
|
||||||
{
|
{
|
||||||
|
if (!IS_ENABLED(CONFIG_USB_OHCI_HCD))
|
||||||
|
return;
|
||||||
|
|
||||||
if (cpu_is_omap7xx())
|
if (cpu_is_omap7xx())
|
||||||
ohci_resources[1].start = INT_7XX_USB_HHC_1;
|
ohci_resources[1].start = INT_7XX_USB_HHC_1;
|
||||||
pdata->ohci_device = &ohci_device;
|
pdata->ohci_device = &ohci_device;
|
||||||
pdata->ocpi_enable = &ocpi_enable;
|
pdata->ocpi_enable = &ocpi_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static inline void ohci_device_init(struct omap_usb_config *pdata)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
|
#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
|
||||||
|
|
||||||
static struct resource otg_resources[] = {
|
static struct resource otg_resources[] = {
|
||||||
@@ -534,6 +528,79 @@ bad:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_OMAP15XX
|
#ifdef CONFIG_ARCH_OMAP15XX
|
||||||
|
/* OMAP-1510 OHCI has its own MMU for DMA */
|
||||||
|
#define OMAP1510_LB_MEMSIZE 32 /* Should be same as SDRAM size */
|
||||||
|
#define OMAP1510_LB_CLOCK_DIV 0xfffec10c
|
||||||
|
#define OMAP1510_LB_MMU_CTL 0xfffec208
|
||||||
|
#define OMAP1510_LB_MMU_LCK 0xfffec224
|
||||||
|
#define OMAP1510_LB_MMU_LD_TLB 0xfffec228
|
||||||
|
#define OMAP1510_LB_MMU_CAM_H 0xfffec22c
|
||||||
|
#define OMAP1510_LB_MMU_CAM_L 0xfffec230
|
||||||
|
#define OMAP1510_LB_MMU_RAM_H 0xfffec234
|
||||||
|
#define OMAP1510_LB_MMU_RAM_L 0xfffec238
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bus address is physical address, except for OMAP-1510 Local Bus.
|
||||||
|
* OMAP-1510 bus address is translated into a Local Bus address if the
|
||||||
|
* OMAP bus type is lbus.
|
||||||
|
*/
|
||||||
|
#define OMAP1510_LB_OFFSET UL(0x30000000)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OMAP-1510 specific Local Bus clock on/off
|
||||||
|
*/
|
||||||
|
static int omap_1510_local_bus_power(int on)
|
||||||
|
{
|
||||||
|
if (on) {
|
||||||
|
omap_writel((1 << 1) | (1 << 0), OMAP1510_LB_MMU_CTL);
|
||||||
|
udelay(200);
|
||||||
|
} else {
|
||||||
|
omap_writel(0, OMAP1510_LB_MMU_CTL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OMAP-1510 specific Local Bus initialization
|
||||||
|
* NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE.
|
||||||
|
* See also arch/mach-omap/memory.h for __virt_to_dma() and
|
||||||
|
* __dma_to_virt() which need to match with the physical
|
||||||
|
* Local Bus address below.
|
||||||
|
*/
|
||||||
|
static int omap_1510_local_bus_init(void)
|
||||||
|
{
|
||||||
|
unsigned int tlb;
|
||||||
|
unsigned long lbaddr, physaddr;
|
||||||
|
|
||||||
|
omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4,
|
||||||
|
OMAP1510_LB_CLOCK_DIV);
|
||||||
|
|
||||||
|
/* Configure the Local Bus MMU table */
|
||||||
|
for (tlb = 0; tlb < OMAP1510_LB_MEMSIZE; tlb++) {
|
||||||
|
lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET;
|
||||||
|
physaddr = tlb * 0x00100000 + PHYS_OFFSET;
|
||||||
|
omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H);
|
||||||
|
omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc,
|
||||||
|
OMAP1510_LB_MMU_CAM_L);
|
||||||
|
omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H);
|
||||||
|
omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L);
|
||||||
|
omap_writel(tlb << 4, OMAP1510_LB_MMU_LCK);
|
||||||
|
omap_writel(0x1, OMAP1510_LB_MMU_LD_TLB);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable the walking table */
|
||||||
|
omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL);
|
||||||
|
udelay(200);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void omap_1510_local_bus_reset(void)
|
||||||
|
{
|
||||||
|
omap_1510_local_bus_power(1);
|
||||||
|
omap_1510_local_bus_init();
|
||||||
|
}
|
||||||
|
|
||||||
/* ULPD_DPLL_CTRL */
|
/* ULPD_DPLL_CTRL */
|
||||||
#define DPLL_IOB (1 << 13)
|
#define DPLL_IOB (1 << 13)
|
||||||
@@ -543,25 +610,6 @@ bad:
|
|||||||
/* ULPD_APLL_CTRL */
|
/* ULPD_APLL_CTRL */
|
||||||
#define APLL_NDPLL_SWITCH (1 << 0)
|
#define APLL_NDPLL_SWITCH (1 << 0)
|
||||||
|
|
||||||
static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
|
|
||||||
unsigned long event, void *data)
|
|
||||||
{
|
|
||||||
struct device *dev = data;
|
|
||||||
|
|
||||||
if (event != BUS_NOTIFY_ADD_DEVICE)
|
|
||||||
return NOTIFY_DONE;
|
|
||||||
|
|
||||||
if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
|
|
||||||
dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
|
|
||||||
(u64)-1))
|
|
||||||
WARN_ONCE(1, "failed to set DMA offset\n");
|
|
||||||
return NOTIFY_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct notifier_block omap_1510_usb_ohci_nb = {
|
|
||||||
.notifier_call = omap_1510_usb_ohci_notifier,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void __init omap_1510_usb_init(struct omap_usb_config *config)
|
static void __init omap_1510_usb_init(struct omap_usb_config *config)
|
||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
@@ -616,19 +664,19 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
|
if (IS_ENABLED(CONFIG_USB_OHCI_HCD) && config->register_host) {
|
||||||
if (config->register_host) {
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
bus_register_notifier(&platform_bus_type,
|
|
||||||
&omap_1510_usb_ohci_nb);
|
|
||||||
ohci_device.dev.platform_data = config;
|
ohci_device.dev.platform_data = config;
|
||||||
|
dma_direct_set_offset(&ohci_device.dev, PHYS_OFFSET,
|
||||||
|
OMAP1510_LB_OFFSET, (u64)-1);
|
||||||
status = platform_device_register(&ohci_device);
|
status = platform_device_register(&ohci_device);
|
||||||
if (status)
|
if (status)
|
||||||
pr_debug("can't register OHCI device, %d\n", status);
|
pr_debug("can't register OHCI device, %d\n", status);
|
||||||
/* hcd explicitly gates 48MHz */
|
/* hcd explicitly gates 48MHz */
|
||||||
|
|
||||||
|
config->lb_reset = omap_1510_local_bus_reset;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -40,17 +40,6 @@
|
|||||||
#include <mach/usb.h>
|
#include <mach/usb.h>
|
||||||
|
|
||||||
|
|
||||||
/* OMAP-1510 OHCI has its own MMU for DMA */
|
|
||||||
#define OMAP1510_LB_MEMSIZE 32 /* Should be same as SDRAM size */
|
|
||||||
#define OMAP1510_LB_CLOCK_DIV 0xfffec10c
|
|
||||||
#define OMAP1510_LB_MMU_CTL 0xfffec208
|
|
||||||
#define OMAP1510_LB_MMU_LCK 0xfffec224
|
|
||||||
#define OMAP1510_LB_MMU_LD_TLB 0xfffec228
|
|
||||||
#define OMAP1510_LB_MMU_CAM_H 0xfffec22c
|
|
||||||
#define OMAP1510_LB_MMU_CAM_L 0xfffec230
|
|
||||||
#define OMAP1510_LB_MMU_RAM_H 0xfffec234
|
|
||||||
#define OMAP1510_LB_MMU_RAM_L 0xfffec238
|
|
||||||
|
|
||||||
#define DRIVER_DESC "OHCI OMAP driver"
|
#define DRIVER_DESC "OHCI OMAP driver"
|
||||||
|
|
||||||
struct ohci_omap_priv {
|
struct ohci_omap_priv {
|
||||||
@@ -104,61 +93,6 @@ static int omap_ohci_transceiver_power(struct ohci_omap_priv *priv, int on)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_OMAP15XX
|
|
||||||
/*
|
|
||||||
* OMAP-1510 specific Local Bus clock on/off
|
|
||||||
*/
|
|
||||||
static int omap_1510_local_bus_power(int on)
|
|
||||||
{
|
|
||||||
if (on) {
|
|
||||||
omap_writel((1 << 1) | (1 << 0), OMAP1510_LB_MMU_CTL);
|
|
||||||
udelay(200);
|
|
||||||
} else {
|
|
||||||
omap_writel(0, OMAP1510_LB_MMU_CTL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* OMAP-1510 specific Local Bus initialization
|
|
||||||
* NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE.
|
|
||||||
* See also arch/mach-omap/memory.h for __virt_to_dma() and
|
|
||||||
* __dma_to_virt() which need to match with the physical
|
|
||||||
* Local Bus address below.
|
|
||||||
*/
|
|
||||||
static int omap_1510_local_bus_init(void)
|
|
||||||
{
|
|
||||||
unsigned int tlb;
|
|
||||||
unsigned long lbaddr, physaddr;
|
|
||||||
|
|
||||||
omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4,
|
|
||||||
OMAP1510_LB_CLOCK_DIV);
|
|
||||||
|
|
||||||
/* Configure the Local Bus MMU table */
|
|
||||||
for (tlb = 0; tlb < OMAP1510_LB_MEMSIZE; tlb++) {
|
|
||||||
lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET;
|
|
||||||
physaddr = tlb * 0x00100000 + PHYS_OFFSET;
|
|
||||||
omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H);
|
|
||||||
omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc,
|
|
||||||
OMAP1510_LB_MMU_CAM_L);
|
|
||||||
omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H);
|
|
||||||
omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L);
|
|
||||||
omap_writel(tlb << 4, OMAP1510_LB_MMU_LCK);
|
|
||||||
omap_writel(0x1, OMAP1510_LB_MMU_LD_TLB);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable the walking table */
|
|
||||||
omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL);
|
|
||||||
udelay(200);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define omap_1510_local_bus_power(x) {}
|
|
||||||
#define omap_1510_local_bus_init() {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_USB_OTG
|
#ifdef CONFIG_USB_OTG
|
||||||
|
|
||||||
static void start_hnp(struct ohci_hcd *ohci)
|
static void start_hnp(struct ohci_hcd *ohci)
|
||||||
@@ -229,10 +163,8 @@ static int ohci_omap_reset(struct usb_hcd *hcd)
|
|||||||
|
|
||||||
omap_ohci_clock_power(priv, 1);
|
omap_ohci_clock_power(priv, 1);
|
||||||
|
|
||||||
if (cpu_is_omap15xx()) {
|
if (config->lb_reset)
|
||||||
omap_1510_local_bus_power(1);
|
config->lb_reset();
|
||||||
omap_1510_local_bus_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ohci_setup(hcd);
|
ret = ohci_setup(hcd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ struct omap_usb_config {
|
|||||||
u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
|
u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
|
||||||
|
|
||||||
int (*ocpi_enable)(void);
|
int (*ocpi_enable)(void);
|
||||||
|
|
||||||
|
void (*lb_reset)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __LINUX_USB_OMAP1_H */
|
#endif /* __LINUX_USB_OMAP1_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user