Skip to content

Commit

Permalink
ARM: orion: Consolidate ethernet platform data
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
  • Loading branch information
Andrew Lunn authored and Nicolas Pitre committed May 16, 2011
1 parent 4748058 commit 7e3819d
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 572 deletions.
53 changes: 3 additions & 50 deletions arch/arm/mach-dove/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <linux/serial_8250.h>
#include <linux/clk.h>
#include <linux/mbus.h>
#include <linux/mv643xx_eth.h>
#include <linux/mv643xx_i2c.h>
#include <linux/ata_platform.h>
#include <linux/serial_8250.h>
Expand Down Expand Up @@ -150,56 +149,11 @@ void __init dove_ehci1_init(void)
/*****************************************************************************
* GE00
****************************************************************************/
struct mv643xx_eth_shared_platform_data dove_ge00_shared_data = {
.t_clk = 0,
.dram = &dove_mbus_dram_info,
};

static struct resource dove_ge00_shared_resources[] = {
{
.name = "ge00 base",
.start = DOVE_GE00_PHYS_BASE + 0x2000,
.end = DOVE_GE00_PHYS_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
},
};

static struct platform_device dove_ge00_shared = {
.name = MV643XX_ETH_SHARED_NAME,
.id = 0,
.dev = {
.platform_data = &dove_ge00_shared_data,
},
.num_resources = 1,
.resource = dove_ge00_shared_resources,
};

static struct resource dove_ge00_resources[] = {
{
.name = "ge00 irq",
.start = IRQ_DOVE_GE00_SUM,
.end = IRQ_DOVE_GE00_SUM,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device dove_ge00 = {
.name = MV643XX_ETH_NAME,
.id = 0,
.num_resources = 1,
.resource = dove_ge00_resources,
.dev = {
.coherent_dma_mask = 0xffffffff,
},
};

void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
{
eth_data->shared = &dove_ge00_shared;
dove_ge00.dev.platform_data = eth_data;

platform_device_register(&dove_ge00_shared);
platform_device_register(&dove_ge00);
orion_ge00_init(eth_data, &dove_mbus_dram_info,
DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
0, get_tclk());
}

/*****************************************************************************
Expand Down Expand Up @@ -690,7 +644,6 @@ void __init dove_init(void)
#endif
dove_setup_cpu_mbus();

dove_ge00_shared_data.t_clk = tclk;
dove_spi0_data.tclk = tclk;
dove_spi1_data.tclk = tclk;

Expand Down
145 changes: 9 additions & 136 deletions arch/arm/mach-kirkwood/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/platform_device.h>
#include <linux/serial_8250.h>
#include <linux/mbus.h>
#include <linux/mv643xx_eth.h>
#include <linux/mv643xx_i2c.h>
#include <linux/ata_platform.h>
#include <linux/mtd/nand.h>
Expand Down Expand Up @@ -70,7 +69,7 @@ void __init kirkwood_map_io(void)
* registered. Some reserved bits must be set to 1.
*/
unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED;


/*****************************************************************************
* EHCI
Expand Down Expand Up @@ -120,160 +119,36 @@ void __init kirkwood_ehci_init(void)
/*****************************************************************************
* GE00
****************************************************************************/
struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
.dram = &kirkwood_mbus_dram_info,
};

static struct resource kirkwood_ge00_shared_resources[] = {
{
.name = "ge00 base",
.start = GE00_PHYS_BASE + 0x2000,
.end = GE00_PHYS_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
}, {
.name = "ge00 err irq",
.start = IRQ_KIRKWOOD_GE00_ERR,
.end = IRQ_KIRKWOOD_GE00_ERR,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device kirkwood_ge00_shared = {
.name = MV643XX_ETH_SHARED_NAME,
.id = 0,
.dev = {
.platform_data = &kirkwood_ge00_shared_data,
},
.num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
.resource = kirkwood_ge00_shared_resources,
};

static struct resource kirkwood_ge00_resources[] = {
{
.name = "ge00 irq",
.start = IRQ_KIRKWOOD_GE00_SUM,
.end = IRQ_KIRKWOOD_GE00_SUM,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device kirkwood_ge00 = {
.name = MV643XX_ETH_NAME,
.id = 0,
.num_resources = 1,
.resource = kirkwood_ge00_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};

void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
{
kirkwood_clk_ctrl |= CGC_GE0;
eth_data->shared = &kirkwood_ge00_shared;
kirkwood_ge00.dev.platform_data = eth_data;

platform_device_register(&kirkwood_ge00_shared);
platform_device_register(&kirkwood_ge00);
orion_ge00_init(eth_data, &kirkwood_mbus_dram_info,
GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
IRQ_KIRKWOOD_GE00_ERR, kirkwood_tclk);
}


/*****************************************************************************
* GE01
****************************************************************************/
struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
.dram = &kirkwood_mbus_dram_info,
.shared_smi = &kirkwood_ge00_shared,
};

static struct resource kirkwood_ge01_shared_resources[] = {
{
.name = "ge01 base",
.start = GE01_PHYS_BASE + 0x2000,
.end = GE01_PHYS_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
}, {
.name = "ge01 err irq",
.start = IRQ_KIRKWOOD_GE01_ERR,
.end = IRQ_KIRKWOOD_GE01_ERR,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device kirkwood_ge01_shared = {
.name = MV643XX_ETH_SHARED_NAME,
.id = 1,
.dev = {
.platform_data = &kirkwood_ge01_shared_data,
},
.num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
.resource = kirkwood_ge01_shared_resources,
};

static struct resource kirkwood_ge01_resources[] = {
{
.name = "ge01 irq",
.start = IRQ_KIRKWOOD_GE01_SUM,
.end = IRQ_KIRKWOOD_GE01_SUM,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device kirkwood_ge01 = {
.name = MV643XX_ETH_NAME,
.id = 1,
.num_resources = 1,
.resource = kirkwood_ge01_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};

void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
{

kirkwood_clk_ctrl |= CGC_GE1;
eth_data->shared = &kirkwood_ge01_shared;
kirkwood_ge01.dev.platform_data = eth_data;

platform_device_register(&kirkwood_ge01_shared);
platform_device_register(&kirkwood_ge01);
orion_ge01_init(eth_data, &kirkwood_mbus_dram_info,
GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
IRQ_KIRKWOOD_GE01_ERR, kirkwood_tclk);
}


/*****************************************************************************
* Ethernet switch
****************************************************************************/
static struct resource kirkwood_switch_resources[] = {
{
.start = 0,
.end = 0,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device kirkwood_switch_device = {
.name = "dsa",
.id = 0,
.num_resources = 0,
.resource = kirkwood_switch_resources,
};

void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
{
int i;

if (irq != NO_IRQ) {
kirkwood_switch_resources[0].start = irq;
kirkwood_switch_resources[0].end = irq;
kirkwood_switch_device.num_resources = 1;
}

d->netdev = &kirkwood_ge00.dev;
for (i = 0; i < d->nr_chips; i++)
d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
kirkwood_switch_device.dev.platform_data = d;

platform_device_register(&kirkwood_switch_device);
orion_ge00_switch_init(d, irq);
}


Expand Down Expand Up @@ -911,8 +786,6 @@ void __init kirkwood_init(void)
{
printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
kirkwood_id(), kirkwood_tclk);
kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
kirkwood_spi_plat_data.tclk = kirkwood_tclk;
kirkwood_i2s_data.tclk = kirkwood_tclk;

Expand Down
Loading

0 comments on commit 7e3819d

Please sign in to comment.