From 430c7a643396a93da8d5a1d026ced06afae9c57d Mon Sep 17 00:00:00 2001 From: Steve Sakoman Date: Mon, 28 Apr 2008 16:29:14 -0700 Subject: [PATCH] OMAP3 EVM: add onenand flash support Add onenand support for OMAP3 EVM Signed-off-by: Steve Sakoman Acked-by: Syed Mohammed Khasim Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/Makefile | 3 +- arch/arm/mach-omap2/board-omap3evm-flash.c | 117 +++++++++++++++++++++ arch/arm/mach-omap2/board-omap3evm.c | 1 + include/asm-arm/arch-omap/board-omap3evm.h | 4 + 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-omap2/board-omap3evm-flash.c diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 3b8d194b022..552664c73d9 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -39,7 +39,8 @@ obj-$(CONFIG_MACH_OMAP_3430SDP) += board-3430sdp.o \ board-3430sdp-flash.o obj-$(CONFIG_MACH_OMAP3EVM) += board-omap3evm.o \ hsmmc.o \ - usb-musb.o usb-ehci.o + usb-musb.o usb-ehci.o \ + board-omap3evm-flash.o obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \ usb-musb.o usb-ehci.o \ hsmmc.o diff --git a/arch/arm/mach-omap2/board-omap3evm-flash.c b/arch/arm/mach-omap2/board-omap3evm-flash.c new file mode 100644 index 00000000000..109d8f22abd --- /dev/null +++ b/arch/arm/mach-omap2/board-omap3evm-flash.c @@ -0,0 +1,117 @@ +/* + * board-omap3evm-flash.c + * + * Copyright (c) 2008 Texas Instruments, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +static int omap3evm_onenand_setup(void __iomem *); + +static struct mtd_partition omap3evm_onenand_partitions[] = { + { + .name = "xloader", + .offset = 0, + .size = 4*(64*2048), + .mask_flags = MTD_WRITEABLE + }, + { + .name = "uboot", + .offset = MTDPART_OFS_APPEND, + .size = 15*(64*2048), + .mask_flags = MTD_WRITEABLE + }, + { + .name = "params", + .offset = MTDPART_OFS_APPEND, + .size = 1*(64*2048), + }, + { + .name = "linux", + .offset = MTDPART_OFS_APPEND, + .size = 40*(64*2048), + }, + { + .name = "jffs2", + .offset = MTDPART_OFS_APPEND, + .size = MTDPART_SIZ_FULL, + }, +}; + +static struct omap_onenand_platform_data omap3evm_onenand_data = { + .parts = omap3evm_onenand_partitions, + .nr_parts = ARRAY_SIZE(omap3evm_onenand_partitions), + .onenand_setup = omap3evm_onenand_setup, + .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */ +}; + +static struct platform_device omap3evm_onenand_device = { + .name = "omap2-onenand", + .id = -1, + .dev = { + .platform_data = &omap3evm_onenand_data, + }, +}; + +/* + * omap3evm_onenand_setup - Set the onenand sync mode + * @onenand_base: The onenand base address in GPMC memory map + * + */ + +static int omap3evm_onenand_setup(void __iomem *onenand_base) + { + /* nothing is required to be setup for onenand as of now */ + return 0; +} + +void __init omap3evm_flash_init(void) +{ + u8 cs = 0; + u8 onenandcs = GPMC_CS_NUM + 1; + + while (cs < GPMC_CS_NUM) { + u32 ret = 0; + ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); + + /* + * xloader/Uboot would have programmed the oneNAND + * base address for us This is a ugly hack. The proper + * way of doing this is to pass the setup of u-boot up + * to kernel using kernel params - something on the + * lines of machineID. Check if oneNAND is configured + */ + if ((ret & 0x3F) == (ONENAND_MAP >> 24)) + onenandcs = cs; + cs++; + } + if (onenandcs > GPMC_CS_NUM) { + printk(KERN_INFO "OneNAND: Unable to find configuration " + " in GPMC\n "); + return; + } + + if (onenandcs < GPMC_CS_NUM) { + omap3evm_onenand_data.cs = onenandcs; + if (platform_device_register(&omap3evm_onenand_device) < 0) + printk(KERN_ERR "Unable to register OneNAND device\n"); + } +} + diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index 5fafcdb0e3d..152e8af88e5 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c @@ -71,6 +71,7 @@ static void __init omap3_evm_init(void) hsmmc_init(); usb_musb_init(); usb_ehci_init(); + omap3evm_flash_init(); } arch_initcall(omap3_evm_i2c_init); diff --git a/include/asm-arm/arch-omap/board-omap3evm.h b/include/asm-arm/arch-omap/board-omap3evm.h index c90ffc01997..c8f2446b7df 100644 --- a/include/asm-arm/arch-omap/board-omap3evm.h +++ b/include/asm-arm/arch-omap/board-omap3evm.h @@ -29,7 +29,11 @@ #ifndef __ASM_ARCH_OMAP3_EVM_H #define __ASM_ARCH_OMAP3_EVM_H +extern void omap3evm_flash_init(void); + #define TWL4030_IRQNUM INT_34XX_SYS_NIRQ +#define ONENAND_MAP 0x20000000 + #endif /* __ASM_ARCH_OMAP3_EVM_H */ -- 2.41.0