+/*
+ * arch/arm/mach-mv78xx0/db78x00-bp-setup.c
+ *
+ * Marvell DB-78x00-BP Development Board Setup
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/ethtool.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/i2c.h>
+#include <linux/i2c/pca953x.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/partitions.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <mach/mv78xx0.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <plat/orion_nand.h>
+#include "common.h"
+#include "mpp.h"
+
+
+static unsigned int rdstor_mpp_config[] __initdata = {
+ /* GPIO8 - n.a. */
+ /* GPIO9 - n.a. */
+ /* GPI10 - n.a. */
+ /* GPI11 - n.a. */
+ MPP12_GPIO, /* parallel LCD */
+ MPP13_GPIO, /* parallel LCD */
+ MPP14_GPIO, /* parallel LCD */
+ MPP15_GPIO, /* parallel LCD */
+ MPP16_UNUSED, /* GPIO16 - n.a. */
+ MPP17_UNUSED, /* GPIO17 */
+ MPP18_GPIO, /* parallel LCD A0 */
+ MPP19_GPIO, /* parallel LCD R/W */
+ MPP20_GPIO, /* parallel LCD LCD_EN */
+ MPP21_GPIO, /* parallel LCD CSn */
+ MPP22_GPIO, /* GPIO22 WAKE0 PCI Express 0 Wake Input (on pin MPP22) */
+ MPP23_GPIO, /* GPIO23 WAKE0 PCI Express 0 Wake Input (on pin MPP23) */
+ MPP24_UA2_TXD,
+ MPP25_UA2_RXD,
+ MPP26_GPIO, /* LCD module RESETn */
+ MPP27_GPIO, /* LCD module switch */
+ MPP28_GPIO, /* parallel LCD */
+ MPP29_GPIO, /* parallel LCD */
+ MPP30_GPIO, /* parallel LCD */
+ MPP31_GPIO, /* parallel LCD */
+ MPP32_GPIO, /* GPIO0 I2C0_INT I2C IRQ */
+ MPP33_GPIO, /* GPIO1 T_CRIT LM86 thermal IRQ */
+ MPP34_GPIO, /* GPIO2 MII_INT PHY Interrupt for off module MII Bus */
+ MPP35_GPIO, /* GPIO3 PHY_INT 88E1121R Dual PHY Interrupt */
+ MPP36_GPIO, /* PS1 PF input, GPIO4 INTA MXM Interrupt A */
+ MPP37_GPIO, /* PWR SWITCH CSB, GPIO5 INTB MXM Interrupt B */
+ MPP38_GPIO, /* GPIO6 INTC MXM Interrupt C */
+ MPP39_GPIO, /* GPIO7 INTD MXM Interrupt D */
+ MPP47_GPIO, /* GPIO16 N_RDY NAND ready/busy */
+ MPP48_SATA1_ACTn,
+ MPP49_SATA0_ACTn,
+ 0,
+};
+
+
+/*
+ * GigE
+ */
+static struct mv643xx_eth_platform_data db78x00_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0 /*8*/),
+};
+
+static struct mv643xx_eth_platform_data db78x00_ge01_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(1 /*9*/),
+};
+
+
+/*
+ * SATA
+ */
+static struct mv_sata_platform_data db78x00_sata_data = {
+ .n_ports = 2,
+};
+
+
+/*
+ * GPIO
+ */
+static struct pca953x_platform_data rdstor_gpio_ext_pdata = {
+ .gpio_base = 128,
+};
+
+
+/*
+ * I2C
+ */
+static struct i2c_board_info __initdata rdstor_i2c_bus0[] = {
+ {
+ I2C_BOARD_INFO("pca9555", 0x27),
+ .platform_data = &rdstor_gpio_ext_pdata,
+ },
+};
+
+static struct i2c_board_info __initdata rdstor_i2c_bus1[] = {
+ {
+ I2C_BOARD_INFO("lm86", 0x4c)
+ }, {
+ I2C_BOARD_INFO("24aa00", 0x50)
+ }, {
+ I2C_BOARD_INFO("ds1338", 0x68)
+ }
+};
+
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition rdstor_nand_parts[] = {
+ {
+ .name = "nand-kernel",
+ .offset = 0,
+ .size = SZ_4M,
+ // .mask_flags = MTD_WRITEABLE
+ },
+ {
+ .name = "nand-kernel-fallback",
+ .offset = MTDPART_OFS_APPEND,
+ .size = SZ_4M,
+ // .mask_flags = MTD_WRITEABLE
+ },
+ {
+ .name = "nand-rootfs",
+ .offset = MTDPART_OFS_APPEND,
+ .size = MTDPART_SIZ_FULL,
+ // .mask_flags = MTD_WRITEABLE
+ }
+};
+
+static struct resource mv78xx0_nand_resource = {
+ .flags = IORESOURCE_MEM,
+ .start = MV78XX0_NAND_MEM_PHYS_BASE,
+ .end = MV78XX0_NAND_MEM_PHYS_BASE +
+ MV78XX0_NAND_MEM_SIZE - 1,
+};
+
+static struct orion_nand_data mv78xx0_nand_data = {
+ .cle = 0,
+ .ale = 1,
+ .width = 8,
+};
+
+static struct platform_device mv78xx0_nand_flash = {
+ .name = "orion_nand",
+ .id = -1,
+ .dev = {
+ .platform_data = &mv78xx0_nand_data,
+ },
+ .resource = &mv78xx0_nand_resource,
+ .num_resources = 1,
+};
+
+
+static int rdstor_nand_dev_ready(struct mtd_info *mtd)
+{
+ return gpio_get_value(16);
+}
+
+void __init mv78xx0_nand_init_rb(struct mtd_partition *parts, int nr_parts)
+{
+ mv78xx0_nand_data.parts = parts;
+ mv78xx0_nand_data.nr_parts = nr_parts;
+ mv78xx0_nand_data.dev_ready = rdstor_nand_dev_ready;
+
+ platform_device_register(&mv78xx0_nand_flash);
+}
+
+
+void __init mv78xx0_nand_init(struct mtd_partition *parts, int nr_parts,
+ int chip_delay)
+{
+ mv78xx0_nand_data.parts = parts;
+ mv78xx0_nand_data.nr_parts = nr_parts;
+ mv78xx0_nand_data.chip_delay = chip_delay;
+
+ platform_device_register(&mv78xx0_nand_flash);
+}
+
+/*
+ * NOR flash
+ */
+static struct resource rdstor_mtd_resource = {
+ /* NOR Flash 64MB */
+ .start = MV78XX0_BOOTCS_MEM_PHY_BASE /*0xfc000000*/,
+ .end = MV78XX0_BOOTCS_MEM_PHY_BASE + MV78XX0_BOOTCS_MEM_SIZE /*0xfc000000 + SZ_64M*/ - 1,
+ .flags = IORESOURCE_MEM,
+};
+
+static struct mtd_partition rdstor_nor_parts[] = {
+ {
+ .name = "nor-user",
+ .offset = 0,
+ .size = 0x3f60000,
+ //.mask_flags = MTD_WRITEABLE
+ },
+ {
+ .name = "nor-uboot-env",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 0x20000,
+ // .mask_flags = MTD_WRITEABLE
+ },
+ {
+ .name = "nor-uboot",
+ .offset = MTDPART_OFS_APPEND,
+ .size = MTDPART_SIZ_FULL,
+ .mask_flags = MTD_WRITEABLE
+ }
+};
+
+static struct physmap_flash_data rdstor_flash_data[] = {
+ {
+ .width = 2,
+ .parts = rdstor_nor_parts,
+ .nr_parts = 3,
+ }
+};
+
+static struct platform_device rdstor_mtd_device = {
+ .name = "physmap-flash",
+ .id = 0,
+ .dev = {
+ .platform_data = &rdstor_flash_data,
+ },
+ .resource = &rdstor_mtd_resource,
+ .num_resources = 1,
+};
+
+/* SPI flash */
+static struct mtd_partition rdstor_dataflash_partitions[] = {
+ {
+ .name = "dataflash",
+ .offset = 0,
+ .size = MTDPART_SIZ_FULL,
+ // .mask_flags = MTD_WRITEABLE
+ }
+};
+
+static struct flash_platform_data rdstor_spi_slave_data = {
+ // .type = "m25p64",
+ .nr_parts = ARRAY_SIZE(rdstor_dataflash_partitions),
+ .parts = rdstor_dataflash_partitions,
+};
+
+static struct spi_board_info rdstor_spi_devices[] = {
+ { /* DataFlash card */
+ .modalias = "m25p64",
+ .irq = NO_IRQ,
+ .chip_select = 0,
+ .max_speed_hz = 20000000,
+ .bus_num = 0,
+ .platform_data = &rdstor_spi_slave_data,
+ },
+};
+
+static void __init db78x00_init(void)
+{
+ /*
+ * Basic MV78xx0 setup. Needs to be called early.
+ */
+ mv78xx0_init();
+
+ /* setup MMPs */
+ mv78xx0_mpp_conf(rdstor_mpp_config);
+
+ /*
+ * Partition on-chip peripherals between the two CPU cores.
+ * On the RDstor we also have the single core option so for now
+ * all peripherals are assigned to core #0.
+ */
+ if (mv78xx0_core_index() == 0) {
+ mv78xx0_uart0_init();
+ mv78xx0_uart1_init();
+ mv78xx0_uart2_init();
+ //mv78xx0_uart3_init();
+
+ mv78xx0_i2c_init();
+
+ mv78xx0_ge00_init(&db78x00_ge00_data);
+ mv78xx0_ge01_init(&db78x00_ge01_data);
+
+ mv78xx0_sata_init(&db78x00_sata_data);
+
+ /*mv78xx0_ehci0_init();*/ /* somewhere? */
+ mv78xx0_ehci1_init(); /* ext USB */
+ /* USB2 is device mode */
+
+ i2c_register_board_info(0, ARRAY_AND_SIZE(rdstor_i2c_bus0));
+ i2c_register_board_info(1, ARRAY_AND_SIZE(rdstor_i2c_bus1));
+
+ /* NOR flash */
+ platform_device_register(&rdstor_mtd_device);
+
+ /* NAND flash */
+ #if 1
+ printk(KERN_ERR "NAND read params: 0x%08x\n", readl(MV78XX0_REGS_VIRT_BASE | 0x10418));
+ printk(KERN_ERR "NAND write params: 0x%08x\n", readl(MV78XX0_REGS_VIRT_BASE | 0x1041C));
+ printk(KERN_ERR "NAND control: 0x%08x\n", readl(MV78XX0_REGS_VIRT_BASE | 0x10470));
+ #endif
+ writel(0xfff40 /*0x07d940*/, MV78XX0_REGS_VIRT_BASE | 0x10470);
+ printk(KERN_ERR "NAND control: 0x%08x\n", readl(MV78XX0_REGS_VIRT_BASE | 0x10470));
+
+ if (/*1 ||*/ gpio_request(16, "NAND READY") != 0 ||
+ gpio_direction_input(16) != 0) {
+ printk(KERN_ERR "nand_init: failed to request GPIO16 for NAND_READY, falling back to udelay\n");
+ mv78xx0_nand_init(ARRAY_AND_SIZE(rdstor_nand_parts), 30);
+ } else
+ mv78xx0_nand_init_rb(ARRAY_AND_SIZE(rdstor_nand_parts));
+
+ spi_register_board_info(rdstor_spi_devices, ARRAY_SIZE(rdstor_spi_devices));
+ mv78x00_spi_init();
+
+ mv78xx0_crypto_init();
+
+ mv78xx0_xor0_init();
+
+ mv78xx0_wdt_init();
+ } else {
+ }
+}
+
+static int __init db78x00_pci_init(void)
+{
+ if (1 /*machine_is_db78x00_bp()*/ /*machine_is_rdstor()*/) {
+ /*
+ * Assign the x16 PCIe slot on the board to CPU core
+ * #0, and let CPU core #1 have the four x1 slots.
+ */
+ if (mv78xx0_core_index() == 0) {
+ printk(KERN_ERR "pcie_init core#0\n");
+ mv78xx0_pcie_init(1, 1);
+ } else {
+ mv78xx0_pcie_init(1, 0);
+ printk(KERN_ERR "pcie_init other core\n");
+ }
+ } else
+ printk(KERN_ERR "pcie_init machine mismatch\n");
+
+ return 0;
+}
+subsys_initcall(db78x00_pci_init);
+
+MACHINE_START(DB78X00_BP /*RDSTOR*/, "BDT RDStor, with CSB1725 module")
+ /* Maintainer: Nils Faerber <nils.faerber@kernelconcepts.de> */
+ .phys_io = MV78XX0_REGS_PHYS_BASE,
+ .io_pg_offst = ((MV78XX0_REGS_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .init_machine = db78x00_init,
+ .map_io = mv78xx0_map_io,
+ .init_irq = mv78xx0_init_irq,
+ .timer = &mv78xx0_timer,
+MACHINE_END