Add basic NAND support for pcm051. Signed-off-by: Teresa Gámez <t.gamez@xxxxxxxxx> --- arch/arm/boards/pcm051/board.c | 54 +++++++++++++++++++++++- arch/arm/boards/pcm051/env/boot/nand-ubi | 10 +++++ arch/arm/boards/pcm051/env/init/mtdparts-nand | 11 +++++ arch/arm/configs/pcm051_defconfig | 3 + 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 arch/arm/boards/pcm051/env/boot/nand-ubi create mode 100644 arch/arm/boards/pcm051/env/init/mtdparts-nand diff --git a/arch/arm/boards/pcm051/board.c b/arch/arm/boards/pcm051/board.c index eea5ebb..db371e5 100644 --- a/arch/arm/boards/pcm051/board.c +++ b/arch/arm/boards/pcm051/board.c @@ -17,9 +17,11 @@ * */ +#include <bootsource.h> #include <common.h> #include <init.h> #include <io.h> +#include <nand.h> #include <sizes.h> #include <ns16550.h> #include <asm/armlinux.h> @@ -30,6 +32,8 @@ #include <mach/am33xx-mux.h> #include <mach/am33xx-silicon.h> #include <mach/cpsw.h> +#include <mach/gpmc.h> +#include <mach/gpmc_nand.h> #include <spi/spi.h> #include <spi/flash.h> #include <i2c/i2c.h> @@ -97,6 +101,25 @@ static struct i2c_board_info i2c0_devices[] = { }, }; +static struct gpmc_config pcm051_nand_cfg = { + .cfg = { + 0x00000800, /* CONF1 */ + 0x00030300, /* CONF2 */ + 0x00030300, /* CONF3 */ + 0x02000311, /* CONF4 */ + 0x00030303, /* CONF5 */ + 0x03000540, /* CONF6 */ + }, + .base = 0x08000000, + .size = GPMC_SIZE_16M, +}; + +static struct gpmc_nand_platform_data nand_plat = { + .wait_mon_pin = 1, + .ecc_mode = OMAP_ECC_BCH8_CODE_HW, + .nand_cfg = &pcm051_nand_cfg, +}; + static void pcm051_spi_init(void) { int ret; @@ -128,6 +151,15 @@ static void pcm051_i2c_init(void) am33xx_add_i2c0(NULL); } +static void pcm051_nand_init(void) +{ + am33xx_enable_nand_pin_mux(); + + gpmc_generic_init(0x12); + + omap_add_gpmc_nand_device(&nand_plat); +} + static int pcm051_devices_init(void) { pcm051_enable_mmc0_pin_mux(); @@ -137,13 +169,29 @@ static int pcm051_devices_init(void) pcm051_spi_init(); pcm051_eth_init(); pcm051_i2c_init(); + pcm051_nand_init(); - devfs_add_partition("nor0", 0x00000, SZ_128K, + switch (bootsource_get()) { + case BOOTSOURCE_SPI: + devfs_add_partition("nor0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "xload"); - devfs_add_partition("nor0", SZ_128K, SZ_512K, + devfs_add_partition("nor0", SZ_128K, SZ_512K, DEVFS_PARTITION_FIXED, "self0"); - devfs_add_partition("nor0", SZ_128K + SZ_512K, SZ_128K, + devfs_add_partition("nor0", SZ_128K + SZ_512K, SZ_128K, DEVFS_PARTITION_FIXED, "env0"); + break; + default: + devfs_add_partition("nand0", 0x00000, SZ_128K, + DEVFS_PARTITION_FIXED, "xload_raw"); + dev_add_bb_dev("xload_raw", "xload"); + devfs_add_partition("nand0", SZ_512K, SZ_512K, + DEVFS_PARTITION_FIXED, "self_raw"); + dev_add_bb_dev("self_raw", "self0"); + devfs_add_partition("nand0", SZ_512K + SZ_512K, SZ_128K, + DEVFS_PARTITION_FIXED, "env_raw"); + dev_add_bb_dev("env_raw", "env0"); + break; + } armlinux_set_bootparams((void *)(AM33XX_DRAM_ADDR_SPACE_START + 0x100)); armlinux_set_architecture(MACH_TYPE_PCM051); diff --git a/arch/arm/boards/pcm051/env/boot/nand-ubi b/arch/arm/boards/pcm051/env/boot/nand-ubi new file mode 100644 index 0000000..efea518 --- /dev/null +++ b/arch/arm/boards/pcm051/env/boot/nand-ubi @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "nand (UBI)" + exit +fi + +global.bootm.image="/dev/nand0.kernel.bb" +#global.bootm.oftree="/env/oftree" +bootargs-root-ubi -r root -m nand0.root,2048 diff --git a/arch/arm/boards/pcm051/env/init/mtdparts-nand b/arch/arm/boards/pcm051/env/init/mtdparts-nand new file mode 100644 index 0000000..12f0ffd --- /dev/null +++ b/arch/arm/boards/pcm051/env/init/mtdparts-nand @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "NAND partitions" + exit +fi + +mtdparts="128k(nand0.xload),128k(nand0.xload_backup1),128k(nand0.xload_backup2),128k(nand0.xload_backup3),512k(nand0.barebox)ro,128k(nand0.bareboxenv),8M(nand0.kernel),-(nand0.root)" +kernelname="omap2-nand.0" + +mtdparts-add -b -d nand0 -k ${kernelname} -p ${mtdparts} diff --git a/arch/arm/configs/pcm051_defconfig b/arch/arm/configs/pcm051_defconfig index 8de3714..e90e27f 100644 --- a/arch/arm/configs/pcm051_defconfig +++ b/arch/arm/configs/pcm051_defconfig @@ -33,6 +33,7 @@ CONFIG_CMD_CRC=y CONFIG_CMD_CRC_CMP=y CONFIG_CMD_MD5SUM=y CONFIG_CMD_FLASH=y +CONFIG_CMD_UBIFORMAT=y CONFIG_CMD_BOOTM_SHOW_TYPE=y CONFIG_CMD_UIMAGE=y CONFIG_CMD_BOOTZ=y @@ -56,6 +57,8 @@ CONFIG_I2C_OMAP=y CONFIG_MTD=y CONFIG_MTD_M25P80=y CONFIG_NAND=y +CONFIG_NAND_OMAP_GPMC=y +CONFIG_UBI=y CONFIG_USB=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y -- 1.7.0.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox