diff mbox

[1/1] Add support for Nand flash on Hawkboard.

Message ID 1296669194-11926-1-git-send-email-urwithsughosh@gmail.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Sughosh Ganu Feb. 2, 2011, 5:53 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 32f1479..e13b7e0 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -213,6 +213,16 @@  config MACH_MITYOMAPL138
 config MACH_OMAPL138_HAWKBOARD
 	bool "TI AM1808 / OMAPL-138 Hawkboard platform"
 	depends on ARCH_DAVINCI_DA850
+	select MTD
+	select MTD_PARTITIONS
+	select MTD_CHAR
+	select MTD_BLKDEVS
+	select MTD_BLOCK
+	select MTD_PHYSMAP
+	select MTD_CFI
+	select MTD_NAND
+	select MTD_NAND_IDS
+	select MTD_NAND_DAVINCI
 	help
 	  Say Y here to select the TI AM1808 / OMAPL-138 Hawkboard platform .
 	  Information of this board may be found at
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index 67c38d0..eac2d69 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -13,6 +13,10 @@ 
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -20,6 +24,7 @@ 
 #include <mach/cp_intc.h>
 #include <mach/da8xx.h>
 #include <mach/mux.h>
+#include <mach/nand.h>
 
 #define HAWKBOARD_PHY_ID		"0:07"
 #define DA850_HAWK_MMCSD_CD_PIN		GPIO_TO_PIN(3, 12)
@@ -28,6 +33,81 @@ 
 #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
 #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
 
+static struct mtd_partition omapl_hawk_nandflash_partition[] = {
+	{
+		.name		= "u-boot env",
+		.offset		= 0,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	 },
+	{
+		.name		= "nand_spl",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "u-boot",
+		.offset		= 0xe0000,
+		.size		= 2 * SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "kernel",
+		.offset		= 0x200000,
+		.size		= SZ_2M,
+		.mask_flags	= 0,
+	},
+	{
+		.name		= "filesystem",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0,
+	},
+};
+
+static struct davinci_nand_pdata omapl_hawk_nandflash_data = {
+	.parts		= omapl_hawk_nandflash_partition,
+	.nr_parts	= ARRAY_SIZE(omapl_hawk_nandflash_partition),
+	.ecc_mode	= NAND_ECC_HW,
+	.ecc_bits	= 4,
+	.options	= NAND_USE_FLASH_BBT,
+};
+
+static struct resource omapl_hawk_nandflash_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CS3_BASE,
+		.end	= DA8XX_AEMIF_CS3_BASE + PAGE_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device omapl_hawk_nandflash_device = {
+	.name		= "davinci_nand",
+	.id		= 1,
+	.dev		= {
+		.platform_data	= &omapl_hawk_nandflash_data,
+	},
+	.num_resources	= ARRAY_SIZE(omapl_hawk_nandflash_resource),
+	.resource	= omapl_hawk_nandflash_resource,
+};
+
+static struct platform_device *omapl_hawk_devices[] __initdata = {
+	&omapl_hawk_nandflash_device,
+};
+
+static const short omapl_hawk_nand_pins[] = {
+	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
+	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
+	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_WE,
+	DA850_NEMA_OE, -1
+};
+
 static short omapl138_hawk_mii_pins[] __initdata = {
 	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
 	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
@@ -37,6 +117,19 @@  static short omapl138_hawk_mii_pins[] __initdata = {
 	-1
 };
 
+static void omapl_hawk_nand_setup(void)
+{
+	int ret = 0;
+
+	ret = davinci_cfg_reg_list(omapl_hawk_nand_pins);
+	if (ret)
+		pr_warning("da850_evm_init: nand mux setup failed: "
+			   "%d\n", ret);
+
+	platform_add_devices(omapl_hawk_devices,
+			     ARRAY_SIZE(omapl_hawk_devices));
+}
+
 static __init void omapl138_hawk_config_emac(void)
 {
 	void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
@@ -314,6 +407,8 @@  static __init void omapl138_hawk_init(void)
 
 	omapl138_hawk_usb_init();
 
+	omapl_hawk_nand_setup();
+
 	ret = da8xx_register_watchdog();
 	if (ret)
 		pr_warning("omapl138_hawk_init: "