All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Schwarz <simonschwarzcor@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V3 3/5] nand spl: add NAND Library to new SPL
Date: Tue, 26 Jul 2011 12:22:17 +0200	[thread overview]
Message-ID: <1311675739-10966-4-git-send-email-simonschwarzcor@gmail.com> (raw)
In-Reply-To: <1311675739-10966-1-git-send-email-simonschwarzcor@gmail.com>

Insert some NAND driver sources into NAND SPL library.

Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com>
---
V1 changes:
CHG Default to HW ecc in SPL build
ADD nand_read_buf16 function, read buffer
ADD omap_dev_ready function, indicte if chip is ready

V2 changes:
DEL GPMC_WAIT0_PIN_ACTIVE define
CHG omap_dev_ready() renamed to  omap_spl_dev_ready(), does not use the
	GPMC_WAIT0_PIN_ACTIVE-define anymore
CHG ogpmc_read_buf16 renamed omap_spl_read_buf16
ADD omap_spl_read_buf, 8x buf read function
ADD CONFIG_SPL_POWER_SUPPORT and CONFIG_SPL_NAND_SUPPORT to SPL
CHG cosmetic
CHG nand_base and nand_bbt aren't needed for SPL anymore
CHG omap_nand_switch_ecc is not compiled for SPL
ADD entry for CONFIG_SPL_POWER_SUPPORT and CONFIG_SPL_NAND_SUPPORT to README.SPL

V3 changes:
DEL cosmetic (empty line)

Transition from V1 to V2 also includes that this patch is now based on
	- the new SPL layout by Aneesh V and Daniel Schwierzeck
	- the OMAP4 SPL patches by Aneesh V

This Patch is related to "[U-Boot,4/5] devkit8000 nand_spl: Add SPL NAND support
to omap_gpmc driver"
(http://article.gmane.org/gmane.comp.boot-loaders.u-boot/102115) in V1
---
 doc/README.SPL               |    2 +
 drivers/mtd/nand/Makefile    |    6 +++-
 drivers/mtd/nand/omap_gpmc.c |   68 ++++++++++++++++++++++++++++++++++++++++++
 spl/Makefile                 |    2 +
 4 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/doc/README.SPL b/doc/README.SPL
index ce8e19f..2987f43 100644
--- a/doc/README.SPL
+++ b/doc/README.SPL
@@ -60,3 +60,5 @@ CONFIG_SPL_SPI_FLASH_SUPPORT (drivers/mtd/spi/libspi_flash.o)
 CONFIG_SPL_SPI_SUPPORT (drivers/spi/libspi.o)
 CONFIG_SPL_FAT_SUPPORT (fs/fat/libfat.o)
 CONFIG_SPL_LIBGENERIC_SUPPORT (lib/libgeneric.o)
+CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o)
+CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o)
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 8b598f6..cdc9a14 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -26,12 +26,16 @@ include $(TOPDIR)/config.mk
 LIB	:= $(obj)libnand.o
 
 ifdef CONFIG_CMD_NAND
+ifdef CONFIG_SPL_BUILD
+COBJS-y += nand_spl.o
+else
 COBJS-y += nand.o
 COBJS-y += nand_base.o
 COBJS-y += nand_bbt.o
-COBJS-y += nand_ecc.o
 COBJS-y += nand_ids.o
 COBJS-y += nand_util.o
+endif
+COBJS-y += nand_ecc.o
 
 COBJS-$(CONFIG_NAND_ATMEL) += atmel_nand.o
 COBJS-$(CONFIG_DRIVER_NAND_BFIN) += bfin_nand.o
diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index 99b9cef..61eac35 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -61,6 +61,55 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,
 		writeb(cmd, this->IO_ADDR_W);
 }
 
+#ifdef CONFIG_SPL_BUILD
+/* Check wait pin as dev ready indicator */
+int omap_spl_dev_ready(struct mtd_info *mtd)
+{
+	return gpmc_cfg->status & (1 << 8);
+}
+
+/*
+ * omap_spl_read_buf16 - [DEFAULT] read chip data into buffer
+ * @mtd:    MTD device structure
+ * @buf:    buffer to store date
+ * @len:    number of bytes to read
+ *
+ * Default read function for 16bit buswith
+ *
+ * This function is based on nand_read_buf16 from nand_base.c. This version
+ * reads 32bit not 16bit although the bus only has 16bit.
+ */
+static void omap_spl_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+	int i;
+	struct nand_chip *chip = mtd->priv;
+	u32 *p = (u32 *) buf;
+	len >>= 2;
+
+	for (i = 0; i < len; i++)
+		p[i] = readl(chip->IO_ADDR_R);
+}
+
+/*
+ * omap_spl_read_buf - [DEFAULT] read chip data into buffer
+ * @mtd:    MTD device structure
+ * @buf:    buffer to store date
+ * @len:    number of bytes to read
+ *
+ * Default read function for 8bit buswith
+ *
+ * This is the same function as this from nand_base.c nand_read_buf
+ */
+static void omap_spl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+	int i;
+	struct nand_chip *chip = mtd->priv;
+
+	for (i = 0; i < len; i++)
+		buf[i] = readb(chip->IO_ADDR_R);
+}
+#endif
+
 /*
  * omap_hwecc_init - Initialize the Hardware ECC for NAND flash in
  *                   GPMC controller
@@ -224,6 +273,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)
 	}
 }
 
+#ifndef CONFIG_SPL_BUILD
 /*
  * omap_nand_switch_ecc - switch the ECC operation b/w h/w ecc and s/w ecc.
  * The default is to come up on s/w ecc
@@ -280,6 +330,7 @@ void omap_nand_switch_ecc(int32_t hardware)
 
 	nand->options &= ~NAND_OWN_BUFFERS;
 }
+#endif /* CONFIG_SPL_BUILD */
 
 /*
  * Board-specific NAND initialization. The following members of the
@@ -338,7 +389,24 @@ int board_nand_init(struct nand_chip *nand)
 
 	nand->chip_delay = 100;
 	/* Default ECC mode */
+#ifndef CONFIG_SPL_BUILD
 	nand->ecc.mode = NAND_ECC_SOFT;
+#else
+	nand->ecc.mode = NAND_ECC_HW;
+	nand->ecc.layout = &hw_nand_oob;
+	nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+	nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+	nand->ecc.hwctl = omap_enable_hwecc;
+	nand->ecc.correct = omap_correct_data;
+	nand->ecc.calculate = omap_calculate_ecc;
+	omap_hwecc_init(nand);
+
+	if (nand->options & NAND_BUSWIDTH_16)
+		nand->read_buf = omap_spl_read_buf16;
+	else
+		nand->read_buf = omap_spl_read_buf;
+	nand->dev_ready = omap_spl_dev_ready;
+#endif
 
 	return 0;
 }
diff --git a/spl/Makefile b/spl/Makefile
index 87f13f6..0c0d3c4 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -46,6 +46,8 @@ LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
 LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
 LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
+LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
+LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 
 ifeq ($(SOC),omap3)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
-- 
1.7.4.1

  parent reply	other threads:[~2011-07-26 10:22 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28 14:14 [U-Boot] [0/5]devkit8000 nand_spl support simonschwarzcor at googlemail.com
2011-06-28 14:14 ` [U-Boot] [1/5]devkit8000 nand_spl: armv7 support nand_spl boot simonschwarzcor at googlemail.com
2011-06-29  8:27   ` Andreas Bießmann
2011-06-30 11:10     ` Aneesh V
2011-06-28 14:14 ` [U-Boot] [2/5]devkit8000 nand_spl: omap3 " simonschwarzcor at googlemail.com
2011-06-29  8:43   ` Andreas Bießmann
2011-06-30  9:06     ` Simon Schwarz
2011-06-30 10:38   ` Aneesh V
2011-06-28 14:14 ` [U-Boot] [3/5]devkit8000 nand_spl: Add RAM configuration independent of x-loader or CH simonschwarzcor at googlemail.com
2011-06-28 14:14 ` [U-Boot] [4/5]devkit8000 nand_spl: Add SPL NAND support to omap_gpmc driver simonschwarzcor at googlemail.com
2011-06-29  8:58   ` Andreas Bießmann
2011-06-30 11:01     ` Simon Schwarz
2011-06-28 14:14 ` [U-Boot] [5/5]devkit8000 nand_spl: add nand_spl support simonschwarzcor at googlemail.com
2011-06-28 15:01   ` Andreas Bießmann
2011-07-25 18:05 ` [U-Boot] [PATCH V2 0/5] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-07-25 18:05   ` [U-Boot] [PATCH V2 1/5] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-25 18:05   ` [U-Boot] [PATCH V2 2/5] omap-common: add nand spl support Simon Schwarz
2011-07-26  6:07     ` Andreas Bießmann
2011-07-26  8:42       ` Simon Schwarz
2011-07-28  6:20         ` Aneesh V
2011-07-25 18:05   ` [U-Boot] [PATCH V2 3/5] nand spl: add NAND Library to new SPL Simon Schwarz
2011-07-26  5:59     ` Andreas Bießmann
2011-07-26  8:47       ` Simon Schwarz
2011-07-25 18:05   ` [U-Boot] [PATCH V2 4/5] omap3: new SPL structure support Simon Schwarz
2011-07-26  6:11     ` Andreas Bießmann
2011-07-25 18:05   ` [U-Boot] [PATCH V2 5/5] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-07-26  6:17     ` Andreas Bießmann
2011-07-26  9:09       ` Simon Schwarz
2011-07-26 10:22   ` [U-Boot] [PATCH V3 0/5] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-07-26 10:22     ` [U-Boot] [PATCH V3 1/5] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-26 10:22     ` [U-Boot] [PATCH V3 2/5] omap-common: add nand spl support Simon Schwarz
2011-07-26 10:22     ` Simon Schwarz [this message]
2011-07-26 10:22     ` [U-Boot] [PATCH V3 4/5] omap3: new SPL structure support Simon Schwarz
2011-07-26 10:22     ` [U-Boot] [PATCH V3 5/5] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-07-26 10:42       ` Andreas Bießmann
2011-07-26 12:34         ` Simon Schwarz
2011-07-26 11:04       ` Wolfgang Denk
2011-07-26 11:06     ` [U-Boot] [PATCH V3 0/5] OMAP3 and devkit8000 SPL support Wolfgang Denk
2011-07-26 12:31       ` Simon Schwarz
2011-07-26 12:09     ` [U-Boot] [PATCH V4 " Simon Schwarz
2011-07-26 12:09       ` [U-Boot] [PATCH V4 1/5] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-26 12:09       ` [U-Boot] [PATCH V4 2/5] omap-common: add nand spl support Simon Schwarz
2011-07-26 18:06         ` Scott Wood
     [not found]           ` <4E2FCF6E.10701@gmail.com>
     [not found]             ` <20110727163839.736d5bed@schlenkerla.am.freescale.net>
2011-07-28  7:51               ` Simon Schwarz
2011-07-28 18:56                 ` Scott Wood
2011-07-29  8:48                   ` Simon Schwarz
2011-07-26 12:09       ` [U-Boot] [PATCH V4 3/5] nand spl: add NAND Library to new SPL Simon Schwarz
2011-07-26 18:04         ` Scott Wood
2011-07-26 18:12           ` Scott Wood
2011-07-27  9:22           ` Simon Schwarz
2011-07-27 14:55             ` V, Aneesh
2011-07-27 22:01               ` Scott Wood
2011-07-28  7:27                 ` Aneesh V
2011-07-26 12:09       ` [U-Boot] [PATCH V4 4/5] omap3: new SPL structure support Simon Schwarz
2011-07-26 12:09       ` [U-Boot] [PATCH V4 5/5] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-07-27 12:50       ` [U-Boot] [PATCH V5 0/5] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-07-27 12:50         ` [U-Boot] [PATCH V5 1/5] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-27 12:50         ` [U-Boot] [PATCH V5 2/5] omap-common: add nand spl support Simon Schwarz
2011-07-27 12:50         ` [U-Boot] [PATCH V5 3/5] nand spl: add NAND Library to new SPL Simon Schwarz
2011-07-27 12:50         ` [U-Boot] [PATCH V5 4/5] omap3: new SPL structure support Simon Schwarz
2011-07-27 12:50         ` [U-Boot] [PATCH V5 5/5] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-07-28  8:38         ` [U-Boot] [PATCH V6 0/5] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-07-28  8:38           ` [U-Boot] [PATCH V6 1/5] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-28  8:50             ` Aneesh V
2011-07-28  9:42               ` Simon Schwarz
2011-07-29 16:53                 ` Simon Schwarz
2011-07-28  8:38           ` [U-Boot] [PATCH V6 2/5] omap-common: add nand spl support Simon Schwarz
2011-07-28  9:42             ` Aneesh V
2011-07-28 12:44               ` Simon Schwarz
2011-07-28 14:24                 ` Aneesh V
2011-07-28 14:34                   ` Simon Schwarz
2011-08-02 12:03               ` Simon Schwarz
2011-08-02 12:18                 ` Aneesh V
2011-08-02 12:30                   ` Simon Schwarz
2011-07-28  9:58             ` Aneesh V
2011-07-28 12:54               ` Simon Schwarz
2011-07-28 14:16             ` Aneesh V
2011-07-28 18:50               ` Scott Wood
2011-07-28 19:07                 ` Wolfgang Denk
2011-07-29  7:34                 ` Aneesh V
2011-07-29  8:19                   ` Simon Schwarz
2011-07-28  8:38           ` [U-Boot] [PATCH V6 3/5] nand spl: add NAND Library to new SPL Simon Schwarz
2011-07-28 11:54             ` Aneesh V
2011-07-28 14:04               ` Simon Schwarz
2011-07-28 16:18                 ` Aneesh V
2011-07-29 12:17                   ` Simon Schwarz
2011-07-28 19:16             ` Scott Wood
2011-07-29  9:12               ` Simon Schwarz
2011-07-29  9:27                 ` Wolfgang Denk
2011-07-29 12:27                   ` Simon Schwarz
2011-07-28  8:38           ` [U-Boot] [PATCH V6 4/5] omap3: new SPL structure support Simon Schwarz
2011-07-28  8:38           ` [U-Boot] [PATCH V6 5/5] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-07-28 10:51             ` Aneesh V
2011-07-28 11:54               ` Simon Schwarz
2011-07-29 16:53           ` [U-Boot] [PATCH V7 0/7] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 1/7] omap-common/omap4: relocate early UART clock setup Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 2/7] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 3/7] omap-common: add nand spl support Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 4/7] spl: add NAND Library to new SPL Simon Schwarz
2011-08-01 17:58               ` Scott Wood
2011-08-02  8:15                 ` Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 5/7] spl: Add POWER library to new spl Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 6/7] omap3: new SPL structure support Simon Schwarz
2011-07-29 16:53             ` [U-Boot] [PATCH V7 7/7] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-08-01 16:23             ` [U-Boot] [PATCH V7 0/7] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-08-02 15:59             ` [U-Boot] [PATCH V8 0/9] " Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 1/9] omap-common/omap4: relocate early UART clock setup Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 2/9] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 3/9] omap-common: add nand spl support Simon Schwarz
2011-08-05  7:30                 ` Aneesh V
2011-08-08  7:50                   ` Simon Schwarz
2011-08-08  9:04                     ` Aneesh V
2011-08-02 15:59               ` [U-Boot] [PATCH V8 4/9] spl: add NAND Library to new SPL Simon Schwarz
2011-08-02 16:12                 ` Scott Wood
2011-08-02 15:59               ` [U-Boot] [PATCH V8 5/9] spl: Add POWER library to new spl Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 6/9] omap3: new SPL structure support Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 7/9] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 8/9] omap3: implement boot parameter saving Simon Schwarz
2011-08-05  7:41                 ` Aneesh V
2011-08-08  8:03                   ` Simon Schwarz
2011-08-08  8:44                     ` Aneesh V
2011-08-08 10:59                       ` Simon Schwarz
2011-08-02 15:59               ` [U-Boot] [PATCH V8 9/9] omap-common: reorganize spl.c Simon Schwarz
2011-08-08 13:11               ` [U-Boot] [PATCH V9 0/9] OMAP3 and devkit8000 SPL support Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 1/9] omap-common/omap4: relocate early UART clock setup Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 2/9] omap3: Configure RAM bank 0 if in SPL Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 3/9] omap-common: add nand spl support Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 4/9] spl: add NAND Library to new SPL Simon Schwarz
2011-08-08 23:34                   ` Scott Wood
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 5/9] spl: Add POWER library to new spl Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 6/9] omap3: new SPL structure support Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 7/9] devkit8000: Add nand-spl support for new SPL Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 8/9] omap3: implement boot parameter saving Simon Schwarz
2011-08-08 13:11                 ` [U-Boot] [PATCH V9 9/9] omap-common: reorganize spl.c Simon Schwarz

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=1311675739-10966-4-git-send-email-simonschwarzcor@gmail.com \
    --to=simonschwarzcor@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.