Skip to content

Commit

Permalink
[ARM] Kirkwood: rationalize NAND setup a bit
Browse files Browse the repository at this point in the history
Common resource and platform device structures are moved to common.c
and only the partition table and chip delay remains a per board
parameter.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
  • Loading branch information
Nicolas Pitre committed Jun 8, 2009
1 parent a886565 commit fb7b2d3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 91 deletions.
37 changes: 37 additions & 0 deletions arch/arm/mach-kirkwood/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/mv643xx_eth.h>
#include <linux/mv643xx_i2c.h>
#include <linux/ata_platform.h>
#include <linux/mtd/nand.h>
#include <linux/spi/orion_spi.h>
#include <net/dsa.h>
#include <asm/page.h>
Expand Down Expand Up @@ -257,6 +258,42 @@ void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
}


/*****************************************************************************
* NAND flash
****************************************************************************/
static struct resource kirkwood_nand_resource = {
.flags = IORESOURCE_MEM,
.start = KIRKWOOD_NAND_MEM_PHYS_BASE,
.end = KIRKWOOD_NAND_MEM_PHYS_BASE +
KIRKWOOD_NAND_MEM_SIZE - 1,
};

static struct orion_nand_data kirkwood_nand_data = {
.cle = 0,
.ale = 1,
.width = 8,
};

static struct platform_device kirkwood_nand_flash = {
.name = "orion_nand",
.id = -1,
.dev = {
.platform_data = &kirkwood_nand_data,
},
.resource = &kirkwood_nand_resource,
.num_resources = 1,
};

void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
int chip_delay)
{
kirkwood_nand_data.parts = parts;
kirkwood_nand_data.nr_parts = nr_parts;
kirkwood_nand_data.chip_delay = chip_delay;
platform_device_register(&kirkwood_nand_flash);
}


/*****************************************************************************
* SoC RTC
****************************************************************************/
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-kirkwood/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct dsa_platform_data;
struct mv643xx_eth_platform_data;
struct mv_sata_platform_data;
struct mvsdio_platform_data;
struct mtd_partition;

/*
* Basic Kirkwood init functions used early by machine-setup.
Expand All @@ -40,9 +41,11 @@ void kirkwood_spi_init(void);
void kirkwood_i2c_init(void);
void kirkwood_uart0_init(void);
void kirkwood_uart1_init(void);
void kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, int delay);

extern int kirkwood_tclk;
extern struct sys_timer kirkwood_timer;

#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)

#endif
31 changes: 1 addition & 30 deletions arch/arm/mach-kirkwood/db88f6281-bp-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/ata_platform.h>
#include <linux/mv643xx_eth.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <mach/kirkwood.h>
#include <plat/orion_nand.h>
#include <plat/mvsdio.h>
#include "common.h"
#include "mpp.h"
Expand All @@ -39,32 +37,6 @@ static struct mtd_partition db88f6281_nand_parts[] = {
},
};

static struct resource db88f6281_nand_resource = {
.flags = IORESOURCE_MEM,
.start = KIRKWOOD_NAND_MEM_PHYS_BASE,
.end = KIRKWOOD_NAND_MEM_PHYS_BASE +
KIRKWOOD_NAND_MEM_SIZE - 1,
};

static struct orion_nand_data db88f6281_nand_data = {
.parts = db88f6281_nand_parts,
.nr_parts = ARRAY_SIZE(db88f6281_nand_parts),
.cle = 0,
.ale = 1,
.width = 8,
.chip_delay = 25,
};

static struct platform_device db88f6281_nand_flash = {
.name = "orion_nand",
.id = -1,
.dev = {
.platform_data = &db88f6281_nand_data,
},
.resource = &db88f6281_nand_resource,
.num_resources = 1,
};

static struct mv643xx_eth_platform_data db88f6281_ge00_data = {
.phy_addr = MV643XX_ETH_PHY_ADDR(8),
};
Expand Down Expand Up @@ -92,13 +64,12 @@ static void __init db88f6281_init(void)
kirkwood_init();
kirkwood_mpp_conf(db88f6281_mpp_config);

kirkwood_nand_init(ARRAY_AND_SIZE(db88f6281_nand_parts), 25);
kirkwood_ehci_init();
kirkwood_ge00_init(&db88f6281_ge00_data);
kirkwood_sata_init(&db88f6281_sata_data);
kirkwood_uart0_init();
kirkwood_sdio_init(&db88f6281_mvsdio_data);

platform_device_register(&db88f6281_nand_flash);
}

static int __init db88f6281_pci_init(void)
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/ata_platform.h>
#include <linux/mv643xx_eth.h>
#include <linux/spi/flash.h>
Expand Down
31 changes: 1 addition & 30 deletions arch/arm/mach-kirkwood/rd88f6281-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/irq.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/ata_platform.h>
#include <linux/mv643xx_eth.h>
Expand All @@ -22,7 +21,6 @@
#include <asm/mach/arch.h>
#include <mach/kirkwood.h>
#include <plat/mvsdio.h>
#include <plat/orion_nand.h>
#include "common.h"
#include "mpp.h"

Expand All @@ -42,32 +40,6 @@ static struct mtd_partition rd88f6281_nand_parts[] = {
},
};

static struct resource rd88f6281_nand_resource = {
.flags = IORESOURCE_MEM,
.start = KIRKWOOD_NAND_MEM_PHYS_BASE,
.end = KIRKWOOD_NAND_MEM_PHYS_BASE +
KIRKWOOD_NAND_MEM_SIZE - 1,
};

static struct orion_nand_data rd88f6281_nand_data = {
.parts = rd88f6281_nand_parts,
.nr_parts = ARRAY_SIZE(rd88f6281_nand_parts),
.cle = 0,
.ale = 1,
.width = 8,
.chip_delay = 25,
};

static struct platform_device rd88f6281_nand_flash = {
.name = "orion_nand",
.id = -1,
.dev = {
.platform_data = &rd88f6281_nand_data,
},
.resource = &rd88f6281_nand_resource,
.num_resources = 1,
};

static struct mv643xx_eth_platform_data rd88f6281_ge00_data = {
.phy_addr = MV643XX_ETH_PHY_NONE,
.speed = SPEED_1000,
Expand Down Expand Up @@ -114,6 +86,7 @@ static void __init rd88f6281_init(void)
kirkwood_init();
kirkwood_mpp_conf(rd88f6281_mpp_config);

kirkwood_nand_init(ARRAY_AND_SIZE(rd88f6281_nand_parts), 25);
kirkwood_ehci_init();

kirkwood_ge00_init(&rd88f6281_ge00_data);
Expand All @@ -129,8 +102,6 @@ static void __init rd88f6281_init(void)
kirkwood_sata_init(&rd88f6281_sata_data);
kirkwood_sdio_init(&rd88f6281_mvsdio_data);
kirkwood_uart0_init();

platform_device_register(&rd88f6281_nand_flash);
}

static int __init rd88f6281_pci_init(void)
Expand Down
30 changes: 1 addition & 29 deletions arch/arm/mach-kirkwood/sheevaplug-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
Expand All @@ -20,7 +19,6 @@
#include <asm/mach/arch.h>
#include <mach/kirkwood.h>
#include <plat/mvsdio.h>
#include <plat/orion_nand.h>
#include "common.h"
#include "mpp.h"

Expand All @@ -40,32 +38,6 @@ static struct mtd_partition sheevaplug_nand_parts[] = {
},
};

static struct resource sheevaplug_nand_resource = {
.flags = IORESOURCE_MEM,
.start = KIRKWOOD_NAND_MEM_PHYS_BASE,
.end = KIRKWOOD_NAND_MEM_PHYS_BASE +
KIRKWOOD_NAND_MEM_SIZE - 1,
};

static struct orion_nand_data sheevaplug_nand_data = {
.parts = sheevaplug_nand_parts,
.nr_parts = ARRAY_SIZE(sheevaplug_nand_parts),
.cle = 0,
.ale = 1,
.width = 8,
.chip_delay = 25,
};

static struct platform_device sheevaplug_nand_flash = {
.name = "orion_nand",
.id = -1,
.dev = {
.platform_data = &sheevaplug_nand_data,
},
.resource = &sheevaplug_nand_resource,
.num_resources = 1,
};

static struct mv643xx_eth_platform_data sheevaplug_ge00_data = {
.phy_addr = MV643XX_ETH_PHY_ADDR(0),
};
Expand Down Expand Up @@ -111,6 +83,7 @@ static void __init sheevaplug_init(void)
kirkwood_mpp_conf(sheevaplug_mpp_config);

kirkwood_uart0_init();
kirkwood_nand_init(ARRAY_AND_SIZE(sheevaplug_nand_parts), 25);

if (gpio_request(29, "USB Power Enable") != 0 ||
gpio_direction_output(29, 1) != 0)
Expand All @@ -120,7 +93,6 @@ static void __init sheevaplug_init(void)
kirkwood_ge00_init(&sheevaplug_ge00_data);
kirkwood_sdio_init(&sheevaplug_mvsdio_data);

platform_device_register(&sheevaplug_nand_flash);
platform_device_register(&sheevaplug_leds);
}

Expand Down

0 comments on commit fb7b2d3

Please sign in to comment.