mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCHv2 02/12] PCM051: Add basic nand support
Date: Tue, 9 Jul 2013 11:23:12 +0200	[thread overview]
Message-ID: <1373361802-31080-2-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1373361802-31080-1-git-send-email-t.gamez@phytec.de>

Add basic NAND support for pcm051.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-07-09  9:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09  9:23 [PATCHv2 01/12] ARM: OMAP: AM33xx: Add basic NAND support Teresa Gámez
2013-07-09  9:23 ` Teresa Gámez [this message]
2013-07-09  9:23 ` [PATCHv2 03/12] ARM: AM33xx: Add gpio support Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 04/12] PCM051: Add muxing for user led and btn Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 05/12] PCM051: Update pcm051_defconfig Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 06/12] PCM051: Rename SPI NOR device Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 07/12] ARM: AM33xx: Enable clock for all GPIO banks Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 08/12] PCM051: Add first stage support Teresa Gámez
2013-07-10  7:21   ` Teresa Gamez
2013-07-10 21:31     ` Sascha Hauer
2013-07-09  9:23 ` [PATCHv2 09/12] ARM: AM33xx: Make mpu pll configurable by lowlevel board code Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 10/12] arm: omap: store boot source info from ROM loader Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 11/12] ARM OMAP: get barebox partion information from boardcode Teresa Gámez
2013-07-09  9:23 ` [PATCHv2 12/12] PCM051: Pass barebox partition information Teresa Gámez
2013-07-09 17:33 ` [PATCHv2 01/12] ARM: OMAP: AM33xx: Add basic NAND support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373361802-31080-2-git-send-email-t.gamez@phytec.de \
    --to=t.gamez@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox