@@ -27,6 +27,7 @@
#include <asm/utils.h>
#include <asm/arch/sys_proto.h>
#include <nand.h>
+#include <nand_interface.h>
#include <mmc.h>
#include <fat.h>
#include <timestamp_autogenerated.h>
@@ -25,6 +25,7 @@
#include <asm/utils.h>
#include <asm/arch/sys_proto.h>
#include <nand.h>
+#include <nand_interface.h>
#include <timestamp_autogenerated.h>
#include <version_autogenerated.h>
#include <asm/omap_common.h>
@@ -46,6 +46,7 @@
#include <net.h>
#include <serial.h>
#include <nand.h>
+#include <nand_interface.h>
#include <onenand_uboot.h>
#include <mmc.h>
@@ -25,7 +25,8 @@
#include <kgdb.h>
#ifdef CONFIG_CMD_NAND
-#include <nand.h> /* cannot even include nand.h if it isnt configured */
+#include <nand.h>
+#include <nand_interface.h> /* cannot even include nand.h if it isnt configured */
#endif
#ifdef CONFIG_BITBANGMII
@@ -68,6 +68,7 @@
#endif
#include <nand.h>
+#include <nand_interface.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -29,6 +29,7 @@
#include <net.h>
#include <environment.h>
#include <nand.h>
+#include <nand_interface.h>
#include <onenand_uboot.h>
#include <spi.h>
@@ -37,7 +37,8 @@
#include <nios2-epcs.h>
#endif
#ifdef CONFIG_CMD_NAND
-#include <nand.h> /* cannot even include nand.h if it isnt configured */
+#include <nand.h>
+#include <nand_interface.h> /* cannot even include nand.h if it isnt configured */
#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -39,6 +39,7 @@
#include "mp.h"
#ifdef CONFIG_SYS_QE_FW_IN_NAND
#include <nand.h>
+#include <nand_interface.h>
#include <errno.h>
#endif
@@ -104,6 +104,7 @@ void doc_init (void);
#endif
#include <spi.h>
#include <nand.h>
+#include <nand_interface.h>
static char *failed = "*** failed ***\n";
@@ -27,6 +27,7 @@
#include <net.h>
#include <netdev.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
@@ -212,6 +212,7 @@ static void at91sam9261ek_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
void lcd_show_board_info(void)
@@ -200,6 +200,7 @@ static void at91sam9263ek_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
#ifndef CONFIG_SYS_NO_FLASH
@@ -222,6 +222,7 @@ static void at91sam9m10g45ek_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
void lcd_show_board_info(void)
@@ -150,6 +150,7 @@ static void at91sam9rlek_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
void lcd_show_board_info(void)
@@ -26,6 +26,7 @@
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
/*
* hardware specific access to control-lines
@@ -27,6 +27,7 @@
#include <asm/arch/imx-regs.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
#include <fsl_pmic.h>
#include <asm/gpio.h>
#include "qong_fpga.h"
@@ -29,6 +29,7 @@
#include <asm/arch/davinci_misc.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -18,6 +18,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/emif_defs.h>
@@ -18,6 +18,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/gpio.h>
@@ -18,6 +18,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/emif_defs.h>
@@ -20,6 +20,7 @@
#include <netdev.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/nand_defs.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -26,6 +26,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/nand_defs.h>
#include <asm/arch/hardware.h>
#include <asm/arch/davinci_misc.h>
@@ -26,6 +26,7 @@
#if defined(CONFIG_CMD_NAND)
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
/*
* hardware specific access to control-lines
@@ -33,6 +33,7 @@ DECLARE_GLOBAL_DATA_PTR;
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/mtd.h>
#define SET_CLE 0x10
@@ -33,6 +33,7 @@ DECLARE_GLOBAL_DATA_PTR;
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/mtd.h>
#define SET_CLE 0x10
@@ -31,6 +31,7 @@
#include <vsc7385.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -34,6 +34,7 @@
#include <asm/io.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -17,6 +17,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/fsl_upm.h>
#include <nand.h>
+#include <nand_interface.h>
static struct immap *im = (struct immap *)CONFIG_SYS_IMMR;
@@ -309,6 +309,7 @@ int misc_init_r (void)
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/mtd.h>
#include <asm/io.h>
@@ -31,6 +31,7 @@
#include <common.h>
#include <i2c.h>
#include <nand.h>
+#include <nand_interface.h>
#include <netdev.h>
#include <miiphy.h>
#include <asm/io.h>
@@ -30,6 +30,7 @@
#include <asm/processor.h>
#include <nand.h>
+#include <nand_interface.h>
struct alpr_ndfc_regs {
u8 cmd[4];
@@ -26,6 +26,7 @@
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
struct pdnb3_ndfc_regs {
uchar cmd;
@@ -27,6 +27,7 @@
#include <asm/ppc4xx-gpio.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
/*
* hardware specific access to control-lines
@@ -192,6 +192,7 @@ static void pm9261_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
extern flash_info_t flash_info[];
@@ -292,6 +292,7 @@ static void pm9263_lcd_hw_init(void)
#ifdef CONFIG_LCD_INFO
#include <nand.h>
+#include <nand_interface.h>
#include <version.h>
extern flash_info_t flash_info[];
@@ -26,6 +26,7 @@
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
#include <asm/processor.h>
#define readb(addr) *(volatile u_char *)(addr)
@@ -29,6 +29,7 @@
#include <mpc83xx.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -25,6 +25,7 @@
#if defined(CONFIG_SYS_NAND_BASE)
#include <nand.h>
+#include <nand_interface.h>
#include <asm/errno.h>
#include <asm/io.h>
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/spr_defs.h>
@@ -24,6 +24,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/spr_defs.h>
@@ -24,6 +24,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/spr_defs.h>
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/spr_defs.h>
@@ -134,6 +134,7 @@ static int chipsel = 0;
#if defined(CONFIG_CMD_NAND)
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/mtd.h>
static u8 hwctl = 0;
@@ -35,6 +35,7 @@
#include <ioports.h>
#include <nand.h>
+#include <nand_interface.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -31,6 +31,7 @@
#include <mpc83xx.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/bitops.h>
#include <asm/io.h>
@@ -25,6 +25,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
/*
@@ -98,6 +98,7 @@
#if defined(CONFIG_CMD_NAND)
#include <linux/mtd/nand.h>
#include <nand.h>
+#include <nand_interface.h>
#endif
#if defined(CONFIG_CMD_ONENAND)
@@ -99,6 +99,7 @@
#if defined(CONFIG_CMD_NAND)
#include <linux/mtd/nand.h>
#include <nand.h>
+#include <nand_interface.h>
#endif
#if defined(CONFIG_CMD_ONENAND)
@@ -27,6 +27,7 @@
#include <asm/byteorder.h>
#include <jffs2/jffs2.h>
#include <nand.h>
+#include <nand_interface.h>
#if defined(CONFIG_CMD_MTDPARTS)
@@ -16,6 +16,7 @@
#include <exports.h>
#include <nand.h>
+#include <nand_interface.h>
#include <onenand_uboot.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
@@ -38,6 +38,7 @@
#include <linux/stddef.h>
#include <malloc.h>
#include <nand.h>
+#include <nand_interface.h>
#include <search.h>
#include <errno.h>
@@ -30,6 +30,7 @@
#include <asm/arch/at91_pio.h>
#include <nand.h>
+#include <nand_interface.h>
#ifdef CONFIG_ATMEL_NAND_HWECC
@@ -24,6 +24,7 @@
#endif
#include <nand.h>
+#include <nand_interface.h>
#include <asm/blackfin.h>
#include <asm/portmux.h>
@@ -44,6 +44,7 @@
#include <common.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/nand_defs.h>
#include <asm/arch/emif_defs.h>
@@ -17,6 +17,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/fsl_upm.h>
#include <nand.h>
+#include <nand_interface.h>
static void fsl_upm_start_pattern(struct fsl_upm *upm, u32 pat_offset)
{
@@ -30,6 +30,7 @@
#include <asm/arch/hardware.h>
#include <nand.h>
+#include <nand_interface.h>
/*
* hardware specific access to control-lines
@@ -26,6 +26,7 @@
#include <asm/io.h>
#include <asm/arch/kirkwood.h>
#include <nand.h>
+#include <nand_interface.h>
/* NAND Flash Soc registers */
struct kwnandf_registers {
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
#define CONFIG_NAND_MODE_REG (void *)(CONFIG_SYS_NAND_BASE + 0x20000)
@@ -35,6 +35,7 @@
#include <asm/io.h>
#include <asm/processor.h>
#include <nand.h>
+#include <nand_interface.h>
#define DRV_NAME "mpc5121_nfc"
@@ -20,6 +20,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <linux/err.h>
#include <asm/io.h>
#if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX35)
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#ifndef CONFIG_SYS_NAND_BASE_LIST
#define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
@@ -51,6 +51,8 @@
#include <asm/io.h>
#include <asm/errno.h>
+#include <nand_base.h>
+
/*
* CONFIG_SYS_NAND_RESET_CNT is used as a timeout mechanism when resetting
* a flash. NAND flash is initialized prior to interrupts so standard timers
@@ -63,7 +65,7 @@
#endif
/* Define default oob placement schemes for large and small page devices */
-static struct nand_ecclayout nand_oob_8 = {
+struct nand_ecclayout nand_oob_8 = {
.eccbytes = 3,
.eccpos = {0, 1, 2},
.oobfree = {
@@ -73,7 +75,7 @@ static struct nand_ecclayout nand_oob_8 = {
.length = 2}}
};
-static struct nand_ecclayout nand_oob_16 = {
+struct nand_ecclayout nand_oob_16 = {
.eccbytes = 6,
.eccpos = {0, 1, 2, 3, 6, 7},
.oobfree = {
@@ -81,7 +83,7 @@ static struct nand_ecclayout nand_oob_16 = {
. length = 8}}
};
-static struct nand_ecclayout nand_oob_64 = {
+struct nand_ecclayout nand_oob_64 = {
.eccbytes = 24,
.eccpos = {
40, 41, 42, 43, 44, 45, 46, 47,
@@ -92,7 +94,7 @@ static struct nand_ecclayout nand_oob_64 = {
.length = 38}}
};
-static struct nand_ecclayout nand_oob_128 = {
+struct nand_ecclayout nand_oob_128 = {
.eccbytes = 48,
.eccpos = {
80, 81, 82, 83, 84, 85, 86, 87,
@@ -107,13 +109,13 @@ static struct nand_ecclayout nand_oob_128 = {
};
-static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
+int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
int new_state);
-static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
+int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops);
-static int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
+int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
/**
* nand_release_device - [GENERIC] release chip
@@ -121,7 +123,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
*
* Deselect, release chip lock and wake up anyone waiting on the device
*/
-static void nand_release_device (struct mtd_info *mtd)
+void nand_release_device (struct mtd_info *mtd)
{
struct nand_chip *this = mtd->priv;
this->select_chip(mtd, -1); /* De-select the NAND device */
@@ -133,7 +135,7 @@ static void nand_release_device (struct mtd_info *mtd)
*
* Default read function for 8bit buswith
*/
-static uint8_t nand_read_byte(struct mtd_info *mtd)
+uint8_t nand_read_byte(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
return readb(chip->IO_ADDR_R);
@@ -146,7 +148,7 @@ static uint8_t nand_read_byte(struct mtd_info *mtd)
* Default read function for 16bit buswith with
* endianess conversion
*/
-static uint8_t nand_read_byte16(struct mtd_info *mtd)
+uint8_t nand_read_byte16(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R));
@@ -159,7 +161,7 @@ static uint8_t nand_read_byte16(struct mtd_info *mtd)
* Default read function for 16bit buswith without
* endianess conversion
*/
-static u16 nand_read_word(struct mtd_info *mtd)
+u16 nand_read_word(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
return readw(chip->IO_ADDR_R);
@@ -172,7 +174,7 @@ static u16 nand_read_word(struct mtd_info *mtd)
*
* Default select function for 1 chip devices.
*/
-static void nand_select_chip(struct mtd_info *mtd, int chipnr)
+void nand_select_chip(struct mtd_info *mtd, int chipnr)
{
struct nand_chip *chip = mtd->priv;
@@ -196,7 +198,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chipnr)
*
* Default write function for 8bit buswith
*/
-static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
+void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
{
int i;
struct nand_chip *chip = mtd->priv;
@@ -230,7 +232,7 @@ void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
*
* Default verify function for 8bit buswith
*/
-static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
+int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
{
int i;
struct nand_chip *chip = mtd->priv;
@@ -249,7 +251,7 @@ static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
*
* Default write function for 16bit buswith
*/
-static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
+void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
{
int i;
struct nand_chip *chip = mtd->priv;
@@ -288,7 +290,7 @@ void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
*
* Default verify function for 16bit buswith
*/
-static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
+int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
{
int i;
struct nand_chip *chip = mtd->priv;
@@ -310,7 +312,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
*
* Check, if the block is bad.
*/
-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
+int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
{
int page, chipnr, res = 0;
struct nand_chip *chip = mtd->priv;
@@ -355,7 +357,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
* This is the default implementation, which can be overridden by
* a hardware specific driver.
*/
-static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
+int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
{
struct nand_chip *chip = mtd->priv;
uint8_t buf[2] = { 0, 0 };
@@ -396,7 +398,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
*
* The function expects, that the device is already selected
*/
-static int nand_check_wp(struct mtd_info *mtd)
+int nand_check_wp(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
/* Check the WP bit */
@@ -414,7 +416,7 @@ static int nand_check_wp(struct mtd_info *mtd)
* Check, if the block is bad. Either by reading the bad block table or
* calling of the scan function.
*/
-static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
+int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
int allowbbt)
{
struct nand_chip *chip = mtd->priv;
@@ -461,7 +463,7 @@ void nand_wait_ready(struct mtd_info *mtd)
* Send command to NAND device. This function is used for small page
* devices (256/512 Bytes per page)
*/
-static void nand_command(struct mtd_info *mtd, unsigned int command,
+void nand_command(struct mtd_info *mtd, unsigned int command,
int column, int page_addr)
{
register struct nand_chip *chip = mtd->priv;
@@ -566,8 +568,8 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
* devices We dont have the separate regions as we have in the small page
* devices. We must emulate NAND_CMD_READOOB to keep the code compatible.
*/
-static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
- int column, int page_addr)
+void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column,
+ int page_addr)
{
register struct nand_chip *chip = mtd->priv;
uint32_t rst_sts_cnt = CONFIG_SYS_NAND_RESET_CNT;
@@ -686,7 +688,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
*
* Get the device and lock it for exclusive access
*/
-static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
+int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
{
this->state = new_state;
return 0;
@@ -701,7 +703,7 @@ static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int ne
* Erase can take up to 400ms and program up to 20ms according to
* general NAND and SmartMedia specs
*/
-static int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
+int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
{
unsigned long timeo;
int state = this->state;
@@ -751,7 +753,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
*
* Not for syndrome calculating ecc controllers, which use a special oob layout
*/
-static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int page)
{
chip->read_buf(mtd, buf, mtd->writesize);
@@ -768,7 +770,7 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
*
* We need a special oob layout and handling even when OOB isn't used.
*/
-static int nand_read_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int page)
{
int eccsize = chip->ecc.size;
@@ -808,7 +810,7 @@ static int nand_read_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *c
* @buf: buffer to store read data
* @page: page number to read
*/
-static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int page)
{
int i, eccsize = chip->ecc.size;
@@ -850,7 +852,8 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
* @readlen: data length
* @bufpoi: buffer to store read data
*/
-static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi)
+int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi)
{
int start_step, end_step, num_steps;
uint32_t *eccpos = chip->ecc.layout->eccpos;
@@ -932,7 +935,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint3
*
* Not for syndrome calculating ecc controllers which need a special oob layout
*/
-static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int page)
{
int i, eccsize = chip->ecc.size;
@@ -982,7 +985,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
* "infix ECC" scheme and reads/writes ECC from the data area, by
* overwriting the NAND manufacturer bad block markings.
*/
-static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
struct nand_chip *chip, uint8_t *buf, int page)
{
int i, eccsize = chip->ecc.size;
@@ -1027,7 +1030,7 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
* The hw generator calculates the error syndrome automatically. Therefor
* we need a special oob layout and handling.
*/
-static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int page)
{
int i, eccsize = chip->ecc.size;
@@ -1079,7 +1082,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
* @ops: oob ops structure
* @len: size of oob to transfer
*/
-static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
+uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
struct mtd_oob_ops *ops, size_t len)
{
switch(ops->mode) {
@@ -1129,7 +1132,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
*
* Internal function. Called with chip held.
*/
-static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
{
int chipnr, page, realpage, col, bytes, aligned;
@@ -1272,7 +1275,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
*
* Get hold of the chip and call nand_do_read
*/
-static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
+int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, uint8_t *buf)
{
struct nand_chip *chip = mtd->priv;
@@ -1306,7 +1309,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
* @page: page number to read
* @sndcmd: flag whether to issue read command or not
*/
-static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
int page, int sndcmd)
{
if (sndcmd) {
@@ -1325,7 +1328,7 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
* @page: page number to read
* @sndcmd: flag whether to issue read command or not
*/
-static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
int page, int sndcmd)
{
uint8_t *buf = chip->oob_poi;
@@ -1362,7 +1365,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure
* @page: page number to write
*/
-static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
int page)
{
int status = 0;
@@ -1386,7 +1389,7 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure
* @page: page number to write
*/
-static int nand_write_oob_syndrome(struct mtd_info *mtd,
+int nand_write_oob_syndrome(struct mtd_info *mtd,
struct nand_chip *chip, int page)
{
int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
@@ -1446,8 +1449,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
*
* NAND read out-of-band data from the spare area
*/
-static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
- struct mtd_oob_ops *ops)
+int nand_do_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
{
int page, realpage, chipnr, sndcmd = 1;
struct nand_chip *chip = mtd->priv;
@@ -1540,8 +1542,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
*
* NAND read data and/or out-of-band data
*/
-static int nand_read_oob(struct mtd_info *mtd, loff_t from,
- struct mtd_oob_ops *ops)
+int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
{
struct nand_chip *chip = mtd->priv;
int ret = -ENOTSUPP;
@@ -1586,7 +1587,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
*
* Not for syndrome calculating ecc controllers, which use a special oob layout
*/
-static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf)
{
chip->write_buf(mtd, buf, mtd->writesize);
@@ -1601,7 +1602,7 @@ static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
*
* We need a special oob layout and handling even when ECC isn't checked.
*/
-static void nand_write_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+void nand_write_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf)
{
int eccsize = chip->ecc.size;
@@ -1637,7 +1638,7 @@ static void nand_write_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip
* @chip: nand chip info structure
* @buf: data buffer
*/
-static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf)
{
int i, eccsize = chip->ecc.size;
@@ -1663,7 +1664,7 @@ static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure
* @buf: data buffer
*/
-static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf)
{
int i, eccsize = chip->ecc.size;
@@ -1694,8 +1695,8 @@ static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
* The hw generator calculates the error syndrome automatically. Therefor
* we need a special oob layout and handling.
*/
-static void nand_write_page_syndrome(struct mtd_info *mtd,
- struct nand_chip *chip, const uint8_t *buf)
+void nand_write_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf)
{
int i, eccsize = chip->ecc.size;
int eccbytes = chip->ecc.bytes;
@@ -1738,7 +1739,7 @@ static void nand_write_page_syndrome(struct mtd_info *mtd,
* @cached: cached programming
* @raw: use _raw version of write_page
*/
-static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf, int page, int cached, int raw)
{
int status;
@@ -1791,7 +1792,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
* @oob: oob data buffer
* @ops: oob ops structure
*/
-static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
+uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
struct mtd_oob_ops *ops)
{
size_t len = ops->ooblen;
@@ -1844,7 +1845,7 @@ static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
*
* NAND write with ECC
*/
-static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
+int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
{
int chipnr, realpage, page, blockmask, column;
@@ -1944,7 +1945,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
*
* NAND write with ECC
*/
-static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
+int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const uint8_t *buf)
{
struct nand_chip *chip = mtd->priv;
@@ -1979,7 +1980,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
*
* NAND write out-of-band
*/
-static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
+int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
{
int chipnr, page, status, len;
@@ -2057,7 +2058,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
* @to: offset to write to
* @ops: oob operation description structure
*/
-static int nand_write_oob(struct mtd_info *mtd, loff_t to,
+int nand_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
{
struct nand_chip *chip = mtd->priv;
@@ -2101,7 +2102,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
*
* Standard erase command for NAND chips
*/
-static void single_erase_cmd(struct mtd_info *mtd, int page)
+void single_erase_cmd(struct mtd_info *mtd, int page)
{
struct nand_chip *chip = mtd->priv;
/* Send commands to erase a block */
@@ -2117,7 +2118,7 @@ static void single_erase_cmd(struct mtd_info *mtd, int page)
* AND multi block erase command function
* Erase 4 consecutive blocks
*/
-static void multi_erase_cmd(struct mtd_info *mtd, int page)
+void multi_erase_cmd(struct mtd_info *mtd, int page)
{
struct nand_chip *chip = mtd->priv;
/* Send commands to erase a block */
@@ -2135,7 +2136,7 @@ static void multi_erase_cmd(struct mtd_info *mtd, int page)
*
* Erase one ore more blocks
*/
-static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
+int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
{
return nand_erase_nand(mtd, instr, 0);
}
@@ -2330,7 +2331,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
*
* Sync is actually a wait for chip ready function
*/
-static void nand_sync(struct mtd_info *mtd)
+void nand_sync(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
@@ -2347,7 +2348,7 @@ static void nand_sync(struct mtd_info *mtd)
* @mtd: MTD device structure
* @offs: offset relative to mtd start
*/
-static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
+int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
{
/* Check for invalid offset */
if (offs > mtd->size)
@@ -2361,7 +2362,7 @@ static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
* @mtd: MTD device structure
* @ofs: offset relative to mtd start
*/
-static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
+int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
{
struct nand_chip *chip = mtd->priv;
int ret;
@@ -2379,7 +2380,7 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
/*
* Set default functions
*/
-static void nand_set_defaults(struct nand_chip *chip, int busw)
+void nand_set_defaults(struct nand_chip *chip, int busw)
{
/* check for proper chip_delay setup, set 20us if not */
if (!chip->chip_delay)
@@ -2416,7 +2417,7 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
}
#ifdef CONFIG_SYS_NAND_ONFI_DETECTION
-static u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
+u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
{
int i;
@@ -2432,9 +2433,8 @@ static u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
/*
* Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise
*/
-static int nand_flash_detect_onfi(struct mtd_info *mtd,
- struct nand_chip *chip,
- int *busw)
+int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ int *busw)
{
struct nand_onfi_params *p = &chip->onfi_params;
int i;
@@ -2494,7 +2494,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd,
return 1;
}
#else
-static inline int nand_flash_detect_onfi(struct mtd_info *mtd,
+inline int nand_flash_detect_onfi(struct mtd_info *mtd,
struct nand_chip *chip,
int *busw)
{
@@ -2502,10 +2502,8 @@ static inline int nand_flash_detect_onfi(struct mtd_info *mtd,
}
#endif
-static void nand_flash_detect_non_onfi(struct mtd_info *mtd,
- struct nand_chip *chip,
- const struct nand_flash_dev *type,
- int *busw)
+void nand_flash_detect_non_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ const struct nand_flash_dev *type, int *busw)
{
/* Newer devices have all the information in additional id bytes */
if (!type->pagesize) {
@@ -2540,7 +2538,7 @@ static void nand_flash_detect_non_onfi(struct mtd_info *mtd,
/*
* Get the flash and manufacturer id and lookup if the type is supported
*/
-static const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
+const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
struct nand_chip *chip,
int busw,
int *maf_id, int *dev_id,
@@ -22,6 +22,7 @@
#endif
#include <nand.h>
+#include <nand_interface.h>
static void plat_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
@@ -20,6 +20,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
@@ -48,6 +48,7 @@
#include <asm/errno.h>
#include <linux/mtd/mtd.h>
#include <nand.h>
+#include <nand_interface.h>
#include <jffs2/jffs2.h>
typedef struct erase_info erase_info_t;
@@ -31,6 +31,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/ndfc.h>
#include <linux/mtd/nand_ecc.h>
#include <asm/processor.h>
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
static inline int parity(int b) /* b is really a byte; returns 0 or ~0 */
@@ -28,6 +28,7 @@
#include <asm/arch/omap_gpmc.h>
#include <linux/mtd/nand_ecc.h>
#include <nand.h>
+#include <nand_base.h>
static uint8_t cs;
static struct nand_ecclayout hw_nand_oob = GPMC_NAND_HW_ECC_LAYOUT;
@@ -21,6 +21,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/s3c24x0_cpu.h>
#include <asm/io.h>
@@ -28,6 +28,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/s3c6400.h>
#include <asm/io.h>
@@ -60,32 +61,6 @@ static void print_oob(const char *header, struct mtd_info *mtd)
}
#endif /* S3C_NAND_DEBUG */
-#ifdef CONFIG_NAND_SPL
-static u_char nand_read_byte(struct mtd_info *mtd)
-{
- struct nand_chip *this = mtd->priv;
- return readb(this->IO_ADDR_R);
-}
-
-static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
-{
- int i;
- struct nand_chip *this = mtd->priv;
-
- for (i = 0; i < len; i++)
- writeb(buf[i], this->IO_ADDR_W);
-}
-
-static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
-{
- int i;
- struct nand_chip *this = mtd->priv;
-
- for (i = 0; i < len; i++)
- buf[i] = readb(this->IO_ADDR_R);
-}
-#endif
-
static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
{
int ctrl = readl(NFCONT);
@@ -23,6 +23,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <linux/mtd/nand_ecc.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
@@ -148,6 +148,7 @@ static struct part_info *current_part;
#if (defined(CONFIG_JFFS2_NAND) && \
defined(CONFIG_CMD_NAND) )
#include <nand.h>
+#include <nand_interface.h>
/*
* Support for jffs2 on top of NAND-flash
*
@@ -7,6 +7,7 @@
#include <jffs2/jffs2.h>
#include <jffs2/jffs2_1pass.h>
#include <nand.h>
+#include <nand_interface.h>
#include "jffs2_nand_private.h"
@@ -37,34 +37,6 @@ typedef struct mtd_info nand_info_t;
extern int nand_curr_device;
extern nand_info_t nand_info[];
-static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
-{
- return info->read(info, ofs, *len, (size_t *)len, buf);
-}
-
-static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
-{
- return info->write(info, ofs, *len, (size_t *)len, buf);
-}
-
-static inline int nand_block_isbad(nand_info_t *info, loff_t ofs)
-{
- return info->block_isbad(info, ofs);
-}
-
-static inline int nand_erase(nand_info_t *info, loff_t off, size_t size)
-{
- struct erase_info instr;
-
- instr.mtd = info;
- instr.addr = off;
- instr.len = size;
- instr.callback = 0;
-
- return info->erase(info, &instr);
-}
-
-
/*****************************************************************************
* declarations from nand_util.c
****************************************************************************/
@@ -135,8 +107,6 @@ int nand_get_lock_status(nand_info_t *meminfo, loff_t offset);
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
void nand_deselect(void);
-void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len);
-void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE
void board_nand_select_device(struct nand_chip *nand, int chip);
@@ -153,4 +123,106 @@ __attribute__((noreturn)) void nand_boot(void);
stored as byte number */
#define ENV_OFFSET_SIZE 8
int get_nand_env_oob(nand_info_t *nand, unsigned long *result);
+
+/* nand_base.c Standard implementation of nand functions */
+void nand_release_device (struct mtd_info *mtd);
+uint8_t nand_read_byte(struct mtd_info *mtd);
+uint8_t nand_read_byte16(struct mtd_info *mtd);
+u16 nand_read_word(struct mtd_info *mtd);
+void nand_select_chip(struct mtd_info *mtd, int chipnr);
+void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
+int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len);
+int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
+int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip);
+int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs);
+int nand_check_wp(struct mtd_info *mtd);
+int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
+ int allowbbt);
+void nand_wait_ready(struct mtd_info *mtd);
+void nand_command(struct mtd_info *mtd, unsigned int command, int column,
+ int page_addr);
+void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column,
+ int page_addr);
+int nand_get_device (struct nand_chip *this, struct mtd_info *mtd,
+ int new_state);
+int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
+int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
+int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
+int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+int nand_read_page_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
+ struct mtd_oob_ops *ops, size_t len);
+int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+ struct mtd_oob_ops *ops);
+int nand_read(struct mtd_info *mtd, loff_t from, size_t len,i
+ size_t *retlen, uint8_t *buf);
+int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+ int page, int sndcmd);
+int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ int page, int sndcmd);
+int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+ int page);
+int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ int page);
+int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
+ struct mtd_oob_ops *ops);
+int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
+void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_raw_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, const uint8_t *buf);
+void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf, int page, int cached, int raw);
+uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
+ struct mtd_oob_ops *ops);
+int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
+ struct mtd_oob_ops *ops);
+int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
+ const uint8_t *buf);
+int nand_do_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
+int nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
+void single_erase_cmd(struct mtd_info *mtd, int page);
+void multi_erase_cmd(struct mtd_info *mtd, int page);
+int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
+int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
+ int allowbbt);
+
+void nand_sync(struct mtd_info *mtd);
+int nand_block_isbad(struct mtd_info *mtd, loff_t offs);
+int nand_block_markbad(struct mtd_info *mtd, loff_t ofs);
+void nand_set_defaults(struct nand_chip *chip, int busw);
+u16 onfi_crc16(u16 crc, u8 const *p, size_t len);
+int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ int *busw);
+void nand_flash_detect_non_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ const struct nand_flash_dev *type, int *busw);
+const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
+ struct nand_chip *chip, int busw, int *maf_id, int *dev_id,
+ const struct nand_flash_dev *type);
+int nand_scan_ident(struct mtd_info *mtd, int maxchips,
+ const struct nand_flash_dev *table);
+int nand_scan_tail(struct mtd_info *mtd);
+int nand_scan(struct mtd_info *mtd, int maxchips);
+void nand_release(struct mtd_info *mtd);
#endif
new file mode 100644
@@ -0,0 +1,127 @@
+/*
+ * (C) Copyright 2005
+ * 2N Telekomunikace, a.s. <www.2n.cz>
+ * Ladislav Michl <michl@2n.cz>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _NAND_BASE_H_
+#define _NAND_BASE_H_
+
+/* nand_base.c Standard implementation of nand functions */
+void nand_release_device (struct mtd_info *mtd);
+uint8_t nand_read_byte(struct mtd_info *mtd);
+uint8_t nand_read_byte16(struct mtd_info *mtd);
+u16 nand_read_word(struct mtd_info *mtd);
+void nand_select_chip(struct mtd_info *mtd, int chipnr);
+void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
+int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
+void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len);
+int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
+int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip);
+int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs);
+int nand_check_wp(struct mtd_info *mtd);
+int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
+ int allowbbt);
+void nand_wait_ready(struct mtd_info *mtd);
+void nand_command(struct mtd_info *mtd, unsigned int command, int column,
+ int page_addr);
+void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column,
+ int page_addr);
+int nand_get_device (struct nand_chip *this, struct mtd_info *mtd,
+ int new_state);
+int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
+int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
+int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
+int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+ uint8_t *buf, int page);
+int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+int nand_read_page_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, uint8_t *buf, int page);
+uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
+ struct mtd_oob_ops *ops, size_t len);
+int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+ struct mtd_oob_ops *ops);
+int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+ int page, int sndcmd);
+int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ int page, int sndcmd);
+int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+ int page);
+int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ int page);
+int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
+ struct mtd_oob_ops *ops);
+int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
+void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_raw_syndrome(struct mtd_info *mtd,
+ struct nand_chip *chip, const uint8_t *buf);
+void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+void nand_write_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf);
+int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+ const uint8_t *buf, int page, int cached, int raw);
+uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
+ struct mtd_oob_ops *ops);
+int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
+ struct mtd_oob_ops *ops);
+int nand_do_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
+int nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
+void single_erase_cmd(struct mtd_info *mtd, int page);
+void multi_erase_cmd(struct mtd_info *mtd, int page);
+int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
+ int allowbbt);
+int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, uint8_t *buf);
+int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const uint8_t *buf);
+int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
+void nand_sync(struct mtd_info *mtd);
+int nand_block_isbad(struct mtd_info *mtd, loff_t offs);
+int nand_block_markbad(struct mtd_info *mtd, loff_t ofs);
+void nand_set_defaults(struct nand_chip *chip, int busw);
+u16 onfi_crc16(u16 crc, u8 const *p, size_t len);
+int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ int *busw);
+void nand_flash_detect_non_onfi(struct mtd_info *mtd, struct nand_chip *chip,
+ const struct nand_flash_dev *type, int *busw);
+const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
+ struct nand_chip *chip, int busw, int *maf_id, int *dev_id,
+ const struct nand_flash_dev *type);
+int nand_scan_ident(struct mtd_info *mtd, int maxchips,
+ const struct nand_flash_dev *table);
+int nand_scan_tail(struct mtd_info *mtd);
+int nand_scan(struct mtd_info *mtd, int maxchips);
+void nand_release(struct mtd_info *mtd);
+#endif /* NAND_BASE_H */
new file mode 100644
@@ -0,0 +1,32 @@
+#ifndef NAND_INTERFACE_H
+#define NAND_INTERFACE_H
+static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len,
+ u_char *buf)
+{
+ return info->read(info, ofs, *len, (size_t *)len, buf);
+}
+
+static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len,
+ u_char *buf)
+{
+ return info->write(info, ofs, *len, (size_t *)len, buf);
+}
+
+static inline int nand_block_isbad(nand_info_t *info, loff_t ofs)
+{
+ return info->block_isbad(info, ofs);
+}
+
+static inline int nand_erase(nand_info_t *info, loff_t off,
+ size_t size)
+{
+ struct erase_info instr;
+
+ instr.mtd = info;
+ instr.addr = off;
+ instr.len = size;
+ instr.callback = 0;
+
+ return info->erase(info, &instr);
+}
+#endif /* NAND_INTERFACE_H */
@@ -23,6 +23,7 @@
#include <ns16550.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
u32 sysclk_tbl[] = {
33333000, 39999600, 49999500, 66666000,
@@ -23,6 +23,7 @@
#include <asm/io.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/fsl_ddr_sdram.h>
@@ -23,6 +23,7 @@
#include <ns16550.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
u32 sysclk_tbl[] = {
33333000, 39999600, 49999500, 66666000,
@@ -24,6 +24,7 @@
#include <ns16550.h>
#include <asm/io.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/fsl_law.h>
/* Fixed sdram init -- doesn't use serial presence detect. */
@@ -23,6 +23,7 @@
#include <asm/io.h>
#include <ns16550.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/fsl_ddr_sdram.h>
@@ -33,12 +33,12 @@ nandobj := $(OBJTREE)/nand_spl/
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
- $(LDFLAGS_FINAL)
+ $(LDFLAGS_FINAL) -gc-sections
AFLAGS += -DCONFIG_NAND_SPL
-CFLAGS += -DCONFIG_NAND_SPL
+CFLAGS += -DCONFIG_NAND_SPL -ffunction-sections
SOBJS = start.o cpu_init.o lowlevel_init.o
-COBJS = nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o
+COBJS = nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o nand_base.o
SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
@@ -98,6 +98,10 @@ $(obj)smdk6400_nand_spl.c:
@rm -f $@
@ln -s $(TOPDIR)/board/samsung/smdk6400/smdk6400_nand_spl.c $@
+$(obj)nand_base.c:
+ @rm -f $@
+ @ln -s $(TOPDIR)/drivers/mtd/nand/nand_base.c $@
+
#########################################################################
$(obj)%.o: $(obj)%.S
@@ -20,6 +20,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/io.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
@@ -26,6 +26,7 @@
#include <common.h>
#include <nand.h>
+#include <nand_interface.h>
#include <asm/arch/imx-regs.h>
#include <asm/io.h>
#include <fsl_nfc.h>
Added a nand_base.h header that defines all prototypes of nand_base.c functions. This is necessary because these functions were often copied in SPLs. This patch also removes the static definition of these functions in nand_base.c It was necessary to also add nand_interface.c. This now defines static inline functions former defined in nand.h - theses functions had name conflicts with these in nand_base.c/h. Files former included nand.h now include also nand_interface.h Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com> Cc: scottwood@freescale.com Cc: albert.u.boot@aribaud.net --- arch/arm/cpu/armv7/omap-common/spl.c | 1 + arch/arm/cpu/armv7/omap-common/spl_nand.c | 1 + arch/arm/lib/board.c | 1 + arch/blackfin/lib/board.c | 3 +- arch/m68k/lib/board.c | 1 + arch/mips/lib/board.c | 1 + arch/nios2/lib/board.c | 3 +- arch/powerpc/cpu/mpc85xx/cpu_init.c | 1 + arch/powerpc/lib/board.c | 1 + board/BuS/eb_cpux9k2/cpux9k2.c | 1 + board/atmel/at91sam9261ek/at91sam9261ek.c | 1 + board/atmel/at91sam9263ek/at91sam9263ek.c | 1 + board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 1 + board/atmel/at91sam9rlek/at91sam9rlek.c | 1 + board/dave/PPChameleonEVB/nand.c | 1 + board/davedenx/qong/qong.c | 1 + board/davinci/da8xxevm/hawkboard_nand_spl.c | 1 + board/davinci/dm355evm/dm355evm.c | 1 + board/davinci/dm355leopard/dm355leopard.c | 1 + board/davinci/dm365evm/dm365evm.c | 1 + board/davinci/dm6467evm/dm6467evm.c | 1 + board/davinci/sonata/sonata.c | 1 + board/esd/common/esd405ep_nand.c | 1 + board/freescale/m5329evb/nand.c | 1 + board/freescale/m5373evb/nand.c | 1 + board/freescale/mpc8313erdb/mpc8313erdb.c | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/freescale/mpc8360erdk/nand.c | 1 + board/ids8247/ids8247.c | 1 + board/keymile/km_arm/km_arm.c | 1 + board/prodrive/alpr/nand.c | 1 + board/prodrive/pdnb3/nand.c | 1 + board/quad100hd/nand.c | 1 + board/ronetix/pm9261/pm9261.c | 1 + board/ronetix/pm9263/pm9263.c | 1 + board/sc3/sc3nand.c | 1 + board/sheldon/simpc8313/simpc8313.c | 1 + board/socrates/nand.c | 1 + board/spear/spear300/spear300.c | 1 + board/spear/spear310/spear310.c | 1 + board/spear/spear320/spear320.c | 1 + board/spear/spear600/spear600.c | 1 + board/tqc/tqm8272/nand.c | 1 + board/tqc/tqm85xx/nand.c | 1 + board/ve8313/ve8313.c | 1 + board/xes/common/actl_nand.c | 1 + common/cmd_jffs2.c | 1 + common/cmd_mtdparts.c | 1 + common/cmd_nand.c | 1 + common/cmd_ubi.c | 1 + common/env_nand.c | 1 + drivers/mtd/nand/atmel_nand.c | 1 + drivers/mtd/nand/bfin_nand.c | 1 + drivers/mtd/nand/davinci_nand.c | 1 + drivers/mtd/nand/fsl_upm.c | 1 + drivers/mtd/nand/kb9202_nand.c | 1 + drivers/mtd/nand/kirkwood_nand.c | 1 + drivers/mtd/nand/kmeter1_nand.c | 1 + drivers/mtd/nand/mpc5121_nfc.c | 1 + drivers/mtd/nand/mxc_nand.c | 1 + drivers/mtd/nand/nand.c | 1 + drivers/mtd/nand/nand_base.c | 142 +++++++++++------------ drivers/mtd/nand/nand_plat.c | 1 + drivers/mtd/nand/nand_spl_simple.c | 1 + drivers/mtd/nand/nand_util.c | 1 + drivers/mtd/nand/ndfc.c | 1 + drivers/mtd/nand/nomadik.c | 1 + drivers/mtd/nand/omap_gpmc.c | 1 + drivers/mtd/nand/s3c2410_nand.c | 1 + drivers/mtd/nand/s3c64xx.c | 27 +---- drivers/mtd/nand/spr_nand.c | 1 + fs/jffs2/jffs2_1pass.c | 1 + fs/jffs2/jffs2_nand_1pass.c | 1 + include/nand.h | 132 ++++++++++++++++----- include/nand_base.h | 127 ++++++++++++++++++++ include/nand_interface.h | 32 +++++ nand_spl/board/freescale/mpc8536ds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8569mds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8572ds/nand_boot.c | 1 + nand_spl/board/freescale/p1023rds/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb/nand_boot.c | 1 + nand_spl/board/samsung/smdk6400/Makefile | 10 +- nand_spl/nand_boot.c | 1 + nand_spl/nand_boot_fsl_nfc.c | 1 + 84 files changed, 419 insertions(+), 133 deletions(-) create mode 100644 include/nand_base.h create mode 100644 include/nand_interface.h