Skip to content

Commit

Permalink
ARM: Orion: Get address map from plat-orion instead of via platform_data
Browse files Browse the repository at this point in the history
Use an getter function in plat-orion/addr-map.c to get the address map
structure, rather than pass it to drivers in the platform_data
structures. When the drivers are built for none orion platforms, a
dummy function is provided instead which returns NULL.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Michael Walle <michael@walle.cc>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
  • Loading branch information
Andrew Lunn authored and Nicolas Pitre committed Dec 13, 2011
1 parent 45173d5 commit 63a9332
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 48 deletions.
3 changes: 1 addition & 2 deletions arch/arm/mach-dove/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/mbus.h>
#include <video/vga.h>
#include <asm/mach/pci.h>
#include <asm/mach/arch.h>
Expand Down Expand Up @@ -51,7 +50,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
*/
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);

orion_pcie_setup(pp->base, &orion_mbus_dram_info);
orion_pcie_setup(pp->base);

/*
* IORESOURCE_IO
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-kirkwood/mpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/gpio.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mbus.h>
#include <linux/io.h>
#include <mach/hardware.h>
#include <plat/mpp.h>
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/mach-kirkwood/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/mbus.h>
#include <video/vga.h>
#include <asm/irq.h>
#include <asm/mach/pci.h>
Expand Down Expand Up @@ -209,7 +208,7 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
*/
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);

orion_pcie_setup(pp->base, &orion_mbus_dram_info);
orion_pcie_setup(pp->base);

return 1;
}
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-mv78xx0/mpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/gpio.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mbus.h>
#include <linux/io.h>
#include <plat/mpp.h>
#include <mach/hardware.h>
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/mach-mv78xx0/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/mbus.h>
#include <video/vga.h>
#include <asm/irq.h>
#include <asm/mach/pci.h>
Expand Down Expand Up @@ -154,7 +153,7 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
* Generic PCIe unit setup.
*/
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
orion_pcie_setup(pp->base, &orion_mbus_dram_info);
orion_pcie_setup(pp->base);

sys->resource[0] = &pp->res[0];
sys->resource[1] = &pp->res[1];
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-orion5x/mpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mbus.h>
#include <linux/io.h>
#include <mach/hardware.h>
#include <plat/mpp.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-orion5x/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
/*
* Generic PCIe unit setup.
*/
orion_pcie_setup(PCIE_BASE, &orion_mbus_dram_info);
orion_pcie_setup(PCIE_BASE);

/*
* Check whether to apply Orion-1/Orion-NAS PCIe config
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/plat-orion/addr-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/mbus.h>
#include <linux/io.h>
#include <plat/addr-map.h>

struct mbus_dram_target_info orion_mbus_dram_info;

const struct mbus_dram_target_info *mv_mbus_dram_info(void)
{
return &orion_mbus_dram_info;
}
EXPORT_SYMBOL_GPL(mv_mbus_dram_info);

/*
* DDR target is the same on all Orion platforms.
*/
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/plat-orion/include/plat/pcie.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ int orion_pcie_x4_mode(void __iomem *base);
int orion_pcie_get_local_bus_nr(void __iomem *base);
void orion_pcie_set_local_bus_nr(void __iomem *base, int nr);
void orion_pcie_reset(void __iomem *base);
void orion_pcie_setup(void __iomem *base,
struct mbus_dram_target_info *dram);
void orion_pcie_setup(void __iomem *base);
int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,
u32 devfn, int where, int size, u32 *val);
int orion_pcie_rd_conf_tlp(void __iomem *base, struct pci_bus *bus,
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/plat-orion/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/mbus.h>
#include <asm/mach/pci.h>
#include <plat/pcie.h>
#include <plat/addr-map.h>
#include <linux/delay.h>

/*
Expand Down Expand Up @@ -175,16 +176,15 @@ static void __init orion_pcie_setup_wins(void __iomem *base,
writel(((size - 1) & 0xffff0000) | 1, base + PCIE_BAR_CTRL_OFF(1));
}

void __init orion_pcie_setup(void __iomem *base,
struct mbus_dram_target_info *dram)
void __init orion_pcie_setup(void __iomem *base)
{
u16 cmd;
u32 mask;

/*
* Point PCIe unit MBUS decode windows to DRAM space.
*/
orion_pcie_setup_wins(base, dram);
orion_pcie_setup_wins(base, &orion_mbus_dram_info);

/*
* Master + slave enable.
Expand Down
19 changes: 11 additions & 8 deletions drivers/ata/sata_mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3988,7 +3988,7 @@ static int mv_create_dma_pools(struct mv_host_priv *hpriv, struct device *dev)
}

static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
struct mbus_dram_target_info *dram)
const struct mbus_dram_target_info *dram)
{
int i;

Expand All @@ -3998,7 +3998,7 @@ static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
}

for (i = 0; i < dram->num_cs; i++) {
struct mbus_dram_window *cs = dram->cs + i;
const struct mbus_dram_window *cs = dram->cs + i;

writel(((cs->size - 1) & 0xffff0000) |
(cs->mbus_attr << 8) |
Expand All @@ -4019,6 +4019,7 @@ static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
static int mv_platform_probe(struct platform_device *pdev)
{
const struct mv_sata_platform_data *mv_platform_data;
const struct mbus_dram_target_info *dram;
const struct ata_port_info *ppi[] =
{ &mv_port_info[chip_soc], NULL };
struct ata_host *host;
Expand Down Expand Up @@ -4072,8 +4073,9 @@ static int mv_platform_probe(struct platform_device *pdev)
/*
* (Re-)program MBUS remapping windows if we are asked to.
*/
if (mv_platform_data->dram != NULL)
mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
dram = mv_mbus_dram_info();
if (dram)
mv_conf_mbus_windows(hpriv, dram);

rc = mv_create_dma_pools(hpriv, &pdev->dev);
if (rc)
Expand Down Expand Up @@ -4141,17 +4143,18 @@ static int mv_platform_suspend(struct platform_device *pdev, pm_message_t state)
static int mv_platform_resume(struct platform_device *pdev)
{
struct ata_host *host = platform_get_drvdata(pdev);
const struct mbus_dram_target_info *dram;
int ret;

if (host) {
struct mv_host_priv *hpriv = host->private_data;
const struct mv_sata_platform_data *mv_platform_data = \
pdev->dev.platform_data;

/*
* (Re-)program MBUS remapping windows if we are asked to.
*/
if (mv_platform_data->dram != NULL)
mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
dram = mv_mbus_dram_info();
if (dram)
mv_conf_mbus_windows(hpriv, dram);

/* initialize adapter */
ret = mv_init_host(host);
Expand Down
11 changes: 6 additions & 5 deletions drivers/dma/mv_xor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ static int __devinit mv_xor_probe(struct platform_device *pdev)

static void
mv_xor_conf_mbus_windows(struct mv_xor_shared_private *msp,
struct mbus_dram_target_info *dram)
const struct mbus_dram_target_info *dram)
{
void __iomem *base = msp->xor_base;
u32 win_enable = 0;
Expand All @@ -1264,7 +1264,7 @@ mv_xor_conf_mbus_windows(struct mv_xor_shared_private *msp,
}

for (i = 0; i < dram->num_cs; i++) {
struct mbus_dram_window *cs = dram->cs + i;
const struct mbus_dram_window *cs = dram->cs + i;

writel((cs->base & 0xffff0000) |
(cs->mbus_attr << 8) |
Expand All @@ -1290,7 +1290,7 @@ static struct platform_driver mv_xor_driver = {

static int mv_xor_shared_probe(struct platform_device *pdev)
{
struct mv_xor_platform_shared_data *msd = pdev->dev.platform_data;
const struct mbus_dram_target_info *dram;
struct mv_xor_shared_private *msp;
struct resource *res;

Expand Down Expand Up @@ -1323,8 +1323,9 @@ static int mv_xor_shared_probe(struct platform_device *pdev)
/*
* (Re-)program MBUS remapping windows if we are asked to.
*/
if (msd != NULL && msd->dram != NULL)
mv_xor_conf_mbus_windows(msp, msd->dram);
dram = mv_mbus_dram_info();
if (dram)
mv_xor_conf_mbus_windows(msp, dram);

return 0;
}
Expand Down
13 changes: 8 additions & 5 deletions drivers/mmc/host/mvsdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,9 @@ static const struct mmc_host_ops mvsd_ops = {
.enable_sdio_irq = mvsd_enable_sdio_irq,
};

static void __init mv_conf_mbus_windows(struct mvsd_host *host,
struct mbus_dram_target_info *dram)
static void __init
mv_conf_mbus_windows(struct mvsd_host *host,
const struct mbus_dram_target_info *dram)
{
void __iomem *iobase = host->base;
int i;
Expand All @@ -691,7 +692,7 @@ static void __init mv_conf_mbus_windows(struct mvsd_host *host,
}

for (i = 0; i < dram->num_cs; i++) {
struct mbus_dram_window *cs = dram->cs + i;
const struct mbus_dram_window *cs = dram->cs + i;
writel(((cs->size - 1) & 0xffff0000) |
(cs->mbus_attr << 8) |
(dram->mbus_dram_target_id << 4) | 1,
Expand All @@ -705,6 +706,7 @@ static int __init mvsd_probe(struct platform_device *pdev)
struct mmc_host *mmc = NULL;
struct mvsd_host *host = NULL;
const struct mvsdio_platform_data *mvsd_data;
const struct mbus_dram_target_info *dram;
struct resource *r;
int ret, irq;

Expand Down Expand Up @@ -755,8 +757,9 @@ static int __init mvsd_probe(struct platform_device *pdev)
}

/* (Re-)program MBUS remapping windows if we are asked to. */
if (mvsd_data->dram != NULL)
mv_conf_mbus_windows(host, mvsd_data->dram);
dram = mv_mbus_dram_info();
if (dram)
mv_conf_mbus_windows(host, dram);

mvsd_power_down(host);

Expand Down
10 changes: 6 additions & 4 deletions drivers/net/ethernet/marvell/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,7 @@ static void mv643xx_eth_netpoll(struct net_device *dev)
/* platform glue ************************************************************/
static void
mv643xx_eth_conf_mbus_windows(struct mv643xx_eth_shared_private *msp,
struct mbus_dram_target_info *dram)
const struct mbus_dram_target_info *dram)
{
void __iomem *base = msp->base;
u32 win_enable;
Expand All @@ -2527,7 +2527,7 @@ mv643xx_eth_conf_mbus_windows(struct mv643xx_eth_shared_private *msp,
win_protect = 0;

for (i = 0; i < dram->num_cs; i++) {
struct mbus_dram_window *cs = dram->cs + i;
const struct mbus_dram_window *cs = dram->cs + i;

writel((cs->base & 0xffff0000) |
(cs->mbus_attr << 8) |
Expand Down Expand Up @@ -2577,6 +2577,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
static int mv643xx_eth_version_printed;
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
int ret;

Expand Down Expand Up @@ -2641,8 +2642,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
/*
* (Re-)program MBUS remapping windows if we are asked to.
*/
if (pd != NULL && pd->dram != NULL)
mv643xx_eth_conf_mbus_windows(msp, pd->dram);
dram = mv_mbus_dram_info();
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);

/*
* Detect hardware parameters.
Expand Down
10 changes: 6 additions & 4 deletions drivers/usb/host/ehci-orion.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static const struct hc_driver ehci_orion_hc_driver = {

static void __init
ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
struct mbus_dram_target_info *dram)
const struct mbus_dram_target_info *dram)
{
int i;

Expand All @@ -182,7 +182,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
}

for (i = 0; i < dram->num_cs; i++) {
struct mbus_dram_window *cs = dram->cs + i;
const struct mbus_dram_window *cs = dram->cs + i;

wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) |
(cs->mbus_attr << 8) |
Expand All @@ -194,6 +194,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
{
struct orion_ehci_data *pd = pdev->dev.platform_data;
const struct mbus_dram_target_info *dram;
struct resource *res;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
Expand Down Expand Up @@ -259,8 +260,9 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
/*
* (Re-)program MBUS remapping windows if we are asked to.
*/
if (pd != NULL && pd->dram != NULL)
ehci_orion_conf_mbus_windows(hcd, pd->dram);
dram = mv_mbus_dram_info();
if (dram)
ehci_orion_conf_mbus_windows(hcd, dram);

/*
* setup Orion USB controller.
Expand Down
13 changes: 12 additions & 1 deletion include/linux/mbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,16 @@ struct mbus_dram_target_info
} cs[4];
};


/*
* The Marvell mbus is to be found only on SOCs from the Orion family
* at the moment. Provide a dummy stub for other architectures.
*/
#ifdef CONFIG_PLAT_ORION
extern const struct mbus_dram_target_info *mv_mbus_dram_info(void);
#else
static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void)
{
return NULL;
}
#endif
#endif
Loading

0 comments on commit 63a9332

Please sign in to comment.