<!-- Generator: GNU source-highlight 2.4
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>#
#
# add_dir "packages/u-boot/u-boot-1.3.2"

# add_file "packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-autoboot.patch"
#  content [d10d1edb2510c27cbbfca47e962cfc8da45f0788]

# add_file "packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-mtdparts.patch"
#  content [20746984bb1c6ef2789381da1283a8e06a74b0ac]

# add_file "packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-nand.patch"
#  content [64eee6cc9ba75710f130f074b0632df44049ca14]

# patch "packages/u-boot/u-boot_1.3.2.bb"
#  from [8cfd5293c0214179a38b2304fbd10c77a3912aff]
#    to [33ac513192e4695c4ea43a787d866c98c2a011ef]
#
============================================================
<font color="#FF6600">--- packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-autoboot.patch        d10d1edb2510c27cbbfca47e962cfc8da45f0788</font>
<font color="#009900">+++ packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-autoboot.patch        d10d1edb2510c27cbbfca47e962cfc8da45f0788</font>
<font color="#0000FF">@@ -0,0 +1,12 @@</font>
<font color="#009900">+diff -urN u-boot-1.3.1.orig/include/configs/MPC8313ERDB.h u-boot-1.3.1/include/configs/MPC8313ERDB.h</font>
<font color="#009900">+--- u-boot-1.3.1.orig/include/configs/MPC8313ERDB.h        2007-12-06 10:21:19.000000000 +0100</font>
<font color="#009900">++++ u-boot-1.3.1/include/configs/MPC8313ERDB.h        2008-01-31 17:38:10.000000000 +0100</font>
<font color="#009900">+@@ -522,7 +522,7 @@</font>
<font color="#009900">+ #define CONFIG_FDTFILE                mpc8313erdb.dtb</font>
<font color="#009900">+ </font>
<font color="#009900">+ #define CONFIG_LOADADDR                200000        /* default location for tftp and bootm */</font>
<font color="#009900">+-#define CONFIG_BOOTDELAY        -1        /* -1 disables auto-boot */</font>
<font color="#009900">++#define CONFIG_BOOTDELAY        3        /* autoboot after 3 seconds     */</font>
<font color="#009900">+ #define CONFIG_BAUDRATE                115200</font>
<font color="#009900">+ </font>
<font color="#009900">+ #define XMK_STR(x)        #x</font>
============================================================
<font color="#FF6600">--- packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-mtdparts.patch        20746984bb1c6ef2789381da1283a8e06a74b0ac</font>
<font color="#009900">+++ packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-mtdparts.patch        20746984bb1c6ef2789381da1283a8e06a74b0ac</font>
<font color="#0000FF">@@ -0,0 +1,35 @@</font>
<font color="#009900">+diff -urN u-boot-1.3.2.orig/include/configs/MPC8313ERDB.h u-boot-1.3.2/include/configs/MPC8313ERDB.h</font>
<font color="#009900">+--- u-boot-1.3.2.orig/include/configs/MPC8313ERDB.h        2008-03-09 16:20:02.000000000 +0100</font>
<font color="#009900">++++ u-boot-1.3.2/include/configs/MPC8313ERDB.h        2008-04-21 19:20:51.000000000 +0200</font>
<font color="#009900">+@@ -179,7 +179,7 @@</font>
<font color="#009900">+ #define CFG_INIT_SP_OFFSET        CFG_GBL_DATA_OFFSET</font>
<font color="#009900">+ </font>
<font color="#009900">+ /* CFG_MONITOR_LEN must be a multiple of CFG_ENV_SECT_SIZE */</font>
<font color="#009900">+-#define CFG_MONITOR_LEN                (256 * 1024)        /* Reserve 256 kB for Mon */</font>
<font color="#009900">++#define CFG_MONITOR_LEN                (384 * 1024)        /* Reserve 384 kB for Mon */</font>
<font color="#009900">+ #define CFG_MALLOC_LEN                (512 * 1024)        /* Reserved for malloc */</font>
<font color="#009900">+ </font>
<font color="#009900">+ /*</font>
<font color="#009900">+@@ -354,6 +354,7 @@</font>
<font color="#009900">+ #define CONFIG_CMD_PING</font>
<font color="#009900">+ #define CONFIG_CMD_DHCP</font>
<font color="#009900">+ #define CONFIG_CMD_I2C</font>
<font color="#009900">++#define CONFIG_CMD_JFFS2</font>
<font color="#009900">+ #define CONFIG_CMD_MII</font>
<font color="#009900">+ #define CONFIG_CMD_DATE</font>
<font color="#009900">+ #define CONFIG_CMD_PCI</font>
<font color="#009900">+@@ -365,6 +366,14 @@</font>
<font color="#009900">+ </font>
<font color="#009900">+ #define CONFIG_CMDLINE_EDITING 1</font>
<font color="#009900">+ </font>
<font color="#009900">++/*</font>
<font color="#009900">++ * JFFS2 partitions (mtdparts command line support)</font>
<font color="#009900">++ */</font>
<font color="#009900">++#define CONFIG_JFFS2_CMDLINE</font>
<font color="#009900">++#define CONFIG_JFFS2_NAND</font>
<font color="#009900">++#define MTDIDS_DEFAULT                "nor0=physmap-flash.0,nand0=nand0"</font>
<font color="#009900">++#define MTDPARTS_DEFAULT        "mtdparts=physmap-flash.0:384k(uboot),64k(env)"</font>
<font color="#009900">++</font>
<font color="#009900">+ </font>
<font color="#009900">+ /*</font>
<font color="#009900">+  * Miscellaneous configurable options</font>
============================================================
<font color="#FF6600">--- packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-nand.patch        64eee6cc9ba75710f130f074b0632df44049ca14</font>
<font color="#009900">+++ packages/u-boot/u-boot-1.3.2/mpc8313e-rdb-nand.patch        64eee6cc9ba75710f130f074b0632df44049ca14</font>
<font color="#0000FF">@@ -0,0 +1,895 @@</font>
<font color="#009900">+diff -urN u-boot-1.3.1.orig/board/freescale/mpc8313erdb/Makefile u-boot-1.3.1/board/freescale/mpc8313erdb/Makefile</font>
<font color="#009900">+--- u-boot-1.3.1.orig/board/freescale/mpc8313erdb/Makefile        2007-12-06 10:21:19.000000000 +0100</font>
<font color="#009900">++++ u-boot-1.3.1/board/freescale/mpc8313erdb/Makefile        2008-01-31 17:35:43.000000000 +0100</font>
<font color="#009900">+@@ -25,7 +25,7 @@</font>
<font color="#009900">+ </font>
<font color="#009900">+ LIB        = $(obj)lib$(BOARD).a</font>
<font color="#009900">+ </font>
<font color="#009900">+-COBJS        := $(BOARD).o sdram.o</font>
<font color="#009900">++COBJS        := $(BOARD).o sdram.o nand.o</font>
<font color="#009900">+ </font>
<font color="#009900">+ SRCS        := $(SOBJS:.o=.S) $(COBJS:.o=.c)</font>
<font color="#009900">+ OBJS        := $(addprefix $(obj),$(COBJS))</font>
<font color="#009900">+diff -urN u-boot-1.3.1.orig/board/freescale/mpc8313erdb/nand.c u-boot-1.3.1/board/freescale/mpc8313erdb/nand.c</font>
<font color="#009900">+--- u-boot-1.3.1.orig/board/freescale/mpc8313erdb/nand.c        1970-01-01 01:00:00.000000000 +0100</font>
<font color="#009900">++++ u-boot-1.3.1/board/freescale/mpc8313erdb/nand.c        2008-01-31 17:35:26.000000000 +0100</font>
<font color="#009900">+@@ -0,0 +1,868 @@</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Copyright (C) Freescale Semiconductor, Inc. 2006. </font>
<font color="#009900">++ * </font>
<font color="#009900">++ * Initialized by Nick.Spence@freescale.com</font>
<font color="#009900">++ *                Wilson.Lo@freescale.com</font>
<font color="#009900">++ *</font>
<font color="#009900">++ * See file CREDITS for list of people who contributed to this</font>
<font color="#009900">++ * project.</font>
<font color="#009900">++ *</font>
<font color="#009900">++ * This program is free software; you can redistribute it and/or</font>
<font color="#009900">++ * modify it under the terms of the GNU General Public License as</font>
<font color="#009900">++ * published by the Free Software Foundation; either version 2 of</font>
<font color="#009900">++ * the License, or (at your option) any later version.</font>
<font color="#009900">++ *</font>
<font color="#009900">++ * This program is distributed in the hope that it will be useful,</font>
<font color="#009900">++ * but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
<font color="#009900">++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</font>
<font color="#009900">++ * GNU General Public License for more details.</font>
<font color="#009900">++ *</font>
<font color="#009900">++ * You should have received a copy of the GNU General Public License</font>
<font color="#009900">++ * along with this program; if not, write to the Free Software</font>
<font color="#009900">++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,</font>
<font color="#009900">++ * MA 02111-1307 USA</font>
<font color="#009900">++ */</font>
<font color="#009900">++</font>
<font color="#009900">++#include &lt;common.h&gt;</font>
<font color="#009900">++</font>
<font color="#009900">++#if defined(CONFIG_CMD_NAND)</font>
<font color="#009900">++#if defined(CFG_NAND_LEGACY)</font>
<font color="#009900">++ #error "U-Boot legacy NAND commands not supported."</font>
<font color="#009900">++#else</font>
<font color="#009900">++</font>
<font color="#009900">++#include &lt;malloc.h&gt;</font>
<font color="#009900">++#include &lt;asm/errno.h&gt;</font>
<font color="#009900">++#include &lt;nand.h&gt;</font>
<font color="#009900">++</font>
<font color="#009900">++#undef CFG_FCM_DEBUG</font>
<font color="#009900">++#define CFG_FCM_DEBUG_LVL 1</font>
<font color="#009900">++#ifdef CFG_FCM_DEBUG</font>
<font color="#009900">++#define FCM_DEBUG(n, args...)                                \</font>
<font color="#009900">++        do {                                                \</font>
<font color="#009900">++                if (n &lt;= (CFG_FCM_DEBUG_LVL + 0))        \</font>
<font color="#009900">++                        printf(args);                        \</font>
<font color="#009900">++        } while(0)</font>
<font color="#009900">++#else /* CONFIG_FCM_DEBUG */</font>
<font color="#009900">++#define FCM_DEBUG(n, args...) do { } while(0)</font>
<font color="#009900">++#endif</font>
<font color="#009900">++</font>
<font color="#009900">++#define MIN(x, y)                ((x &lt; y) ? x : y)</font>
<font color="#009900">++</font>
<font color="#009900">++#define ERR_BYTE 0xFF        /* Value returned for read bytes when read failed */</font>
<font color="#009900">++</font>
<font color="#009900">++#define FCM_TIMEOUT_USECS 100000 /* Maximum number of uSecs to wait for FCM */</font>
<font color="#009900">++</font>
<font color="#009900">++/* Private structure holding NAND Flash device specific information */</font>
<font color="#009900">++struct fcm_nand {</font>
<font color="#009900">++        int                bank;       /* Chip select bank number             */</font>
<font color="#009900">++        unsigned int        base;       /* Chip select base address            */</font>
<font color="#009900">++        int                pgs;        /* NAND page size                      */</font>
<font color="#009900">++        int                oobbuf;     /* Pointer to OOB block                */</font>
<font color="#009900">++        unsigned int        page;       /* Last page written to / read from    */</font>
<font color="#009900">++        unsigned int        fmr;        /* FCM Flash Mode Register value       */</font>
<font color="#009900">++        unsigned int        mdr;        /* UPM/FCM Data Register value         */</font>
<font color="#009900">++        unsigned int        use_mdr;    /* Non zero if the MDR is to be set    */</font>
<font color="#009900">++        u_char               *addr;       /* Address of assigned FCM buffer      */</font>
<font color="#009900">++        unsigned int        read_bytes; /* Number of bytes read during command */</font>
<font color="#009900">++        unsigned int        index;      /* Pointer to next byte to 'read'      */</font>
<font color="#009900">++        unsigned int        req_bytes;  /* Number of bytes read if command ok  */</font>
<font color="#009900">++        unsigned int        req_index;  /* New read index if command ok        */</font>
<font color="#009900">++        unsigned int        status;     /* status read from LTESR after last op*/</font>
<font color="#009900">++};</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/* These map to the positions used by the FCM hardware ECC generator */</font>
<font color="#009900">++</font>
<font color="#009900">++/* Small Page FLASH with FMR[ECCM] = 0 */</font>
<font color="#009900">++static struct nand_oobinfo fcm_oob_sp_eccm0 = { /* TODO */</font>
<font color="#009900">++        .useecc = MTD_NANDECC_AUTOPL_USR, /* MTD_NANDECC_PLACEONLY, */</font>
<font color="#009900">++        .eccbytes = 3,</font>
<font color="#009900">++        .eccpos = {6, 7, 8},</font>
<font color="#009900">++        .oobfree = { {0, 5}, {9, 7} }</font>
<font color="#009900">++};</font>
<font color="#009900">++</font>
<font color="#009900">++/* Small Page FLASH with FMR[ECCM] = 1 */</font>
<font color="#009900">++static struct nand_oobinfo fcm_oob_sp_eccm1 = { /* TODO */</font>
<font color="#009900">++        .useecc = MTD_NANDECC_AUTOPL_USR, /* MTD_NANDECC_PLACEONLY, */</font>
<font color="#009900">++        .eccbytes = 3,</font>
<font color="#009900">++        .eccpos = {8, 9, 10},</font>
<font color="#009900">++        .oobfree = { {0, 5}, {6, 2}, {11, 5} }</font>
<font color="#009900">++};</font>
<font color="#009900">++</font>
<font color="#009900">++/* Large Page FLASH with FMR[ECCM] = 0 */</font>
<font color="#009900">++static struct nand_oobinfo fcm_oob_lp_eccm0 = {</font>
<font color="#009900">++        .useecc = MTD_NANDECC_AUTOPL_USR, /* MTD_NANDECC_PLACEONLY, */</font>
<font color="#009900">++        .eccbytes = 12,</font>
<font color="#009900">++        .eccpos = {6, 7, 8, 22, 23, 24, 38, 39, 40, 54, 55, 56},</font>
<font color="#009900">++        .oobfree = { {1, 5}, {9, 13}, {25, 13}, {41, 13}, {57, 7} }</font>
<font color="#009900">++};</font>
<font color="#009900">++</font>
<font color="#009900">++/* Large Page FLASH with FMR[ECCM] = 1 */</font>
<font color="#009900">++static struct nand_oobinfo fcm_oob_lp_eccm1 = {</font>
<font color="#009900">++        .useecc = MTD_NANDECC_AUTOPL_USR, /* MTD_NANDECC_PLACEONLY, */</font>
<font color="#009900">++        .eccbytes = 12,</font>
<font color="#009900">++        .eccpos = {8, 9, 10, 24, 25, 26, 40, 41, 42, 56, 57, 58},</font>
<font color="#009900">++        .oobfree = { {1, 7}, {11, 13}, {27, 13}, {43, 13}, {59, 5} }</font>
<font color="#009900">++};</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * execute FCM command and wait for it to complete</font>
<font color="#009900">++ */</font>
<font color="#009900">++static int fcm_run_command(struct mtd_info *mtd)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        long long end_tick;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* Setup the FMR[OP] to execute without write protection */</font>
<font color="#009900">++        lbc-&gt;fmr = fcm-&gt;fmr | 3;</font>
<font color="#009900">++        if (fcm-&gt;use_mdr)</font>
<font color="#009900">++                lbc-&gt;mdr = fcm-&gt;mdr;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(5,"fcm_run_command: fmr= %08X fir= %08X fcr= %08X\n",</font>
<font color="#009900">++                lbc-&gt;fmr, lbc-&gt;fir, lbc-&gt;fcr);</font>
<font color="#009900">++        FCM_DEBUG(5,"fcm_run_command: fbar=%08X fpar=%08X fbcr=%08X bank=%d\n",</font>
<font color="#009900">++                lbc-&gt;fbar, lbc-&gt;fpar, lbc-&gt;fbcr, fcm-&gt;bank);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* clear event registers */</font>
<font color="#009900">++        lbc-&gt;lteatr = 0;</font>
<font color="#009900">++        lbc-&gt;ltesr |= (LTESR_FCT | LTESR_PAR | LTESR_CC);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* execute special operation */</font>
<font color="#009900">++        lbc-&gt;lsor = fcm-&gt;bank;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* wait for FCM complete flag or timeout */</font>
<font color="#009900">++        fcm-&gt;status = 0;</font>
<font color="#009900">++        end_tick = usec2ticks(FCM_TIMEOUT_USECS) + get_ticks();</font>
<font color="#009900">++</font>
<font color="#009900">++        while (end_tick &gt; get_ticks()) {</font>
<font color="#009900">++                if (lbc-&gt;ltesr &amp; LTESR_CC) {</font>
<font color="#009900">++                        fcm-&gt;status = lbc-&gt;ltesr &amp;</font>
<font color="#009900">++                                        (LTESR_FCT | LTESR_PAR | LTESR_CC);</font>
<font color="#009900">++                        break;</font>
<font color="#009900">++                }</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* store mdr value in case it was needed */</font>
<font color="#009900">++        if (fcm-&gt;use_mdr)</font>
<font color="#009900">++                fcm-&gt;mdr = lbc-&gt;mdr;</font>
<font color="#009900">++</font>
<font color="#009900">++        fcm-&gt;use_mdr = 0;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(5,"fcm_run_command: stat=%08X mdr= %08X fmr= %08X\n",</font>
<font color="#009900">++                fcm-&gt;status, fcm-&gt;mdr, lbc-&gt;fmr);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* if the operation completed ok then set the read buffer pointers */</font>
<font color="#009900">++        if (fcm-&gt;status == LTESR_CC) {</font>
<font color="#009900">++                fcm-&gt;read_bytes = fcm-&gt;req_bytes;</font>
<font color="#009900">++                fcm-&gt;index      = fcm-&gt;req_index;</font>
<font color="#009900">++                return 0;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        return -1;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Set up the FCM hardware block and page address fields, and the fcm</font>
<font color="#009900">++ * structure addr field to point to the correct FCM buffer in memory</font>
<font color="#009900">++ */</font>
<font color="#009900">++static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        int buf_num;</font>
<font color="#009900">++</font>
<font color="#009900">++        fcm-&gt;page = page_addr;</font>
<font color="#009900">++</font>
<font color="#009900">++        lbc-&gt;fbar = page_addr &gt;&gt; (this-&gt;phys_erase_shift - this-&gt;page_shift);</font>
<font color="#009900">++        if (fcm-&gt;pgs) {</font>
<font color="#009900">++                lbc-&gt;fpar = ((page_addr &lt;&lt; FPAR_LP_PI_SHIFT) &amp; FPAR_LP_PI) |</font>
<font color="#009900">++                            ( oob ? FPAR_LP_MS : 0) |</font>
<font color="#009900">++                              column;</font>
<font color="#009900">++                buf_num = (page_addr &amp; 1) &lt;&lt; 2;</font>
<font color="#009900">++        } else {</font>
<font color="#009900">++                lbc-&gt;fpar = ((page_addr &lt;&lt; FPAR_SP_PI_SHIFT) &amp; FPAR_SP_PI) |</font>
<font color="#009900">++                            ( oob ? FPAR_SP_MS : 0) |</font>
<font color="#009900">++                              column;</font>
<font color="#009900">++                buf_num = page_addr &amp; 7;</font>
<font color="#009900">++        }</font>
<font color="#009900">++        fcm-&gt;addr = (unsigned char*)(fcm-&gt;base + (buf_num * 1024));</font>
<font color="#009900">++</font>
<font color="#009900">++        /* for OOB data point to the second half of the buffer */</font>
<font color="#009900">++        if (oob) {</font>
<font color="#009900">++                fcm-&gt;addr += (fcm-&gt;pgs ? 2048 : 512);</font>
<font color="#009900">++        }</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/* not required for FCM */</font>
<font color="#009900">++static void fcm_hwcontrol(struct mtd_info *mtdinfo, int cmd)</font>
<font color="#009900">++{</font>
<font color="#009900">++        return;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * FCM does not support 16 bit data busses</font>
<font color="#009900">++ */</font>
<font color="#009900">++static u16 fcm_read_word(struct mtd_info *mtd)</font>
<font color="#009900">++{</font>
<font color="#009900">++        printf("fcm_read_word: UNIMPLEMENTED.\n");</font>
<font color="#009900">++        return 0;</font>
<font color="#009900">++}</font>
<font color="#009900">++static void fcm_write_word(struct mtd_info *mtd, u16 word)</font>
<font color="#009900">++{</font>
<font color="#009900">++        printf("fcm_write_word: UNIMPLEMENTED.\n");</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Write buf to the FCM Controller Data Buffer</font>
<font color="#009900">++ */</font>
<font color="#009900">++static void fcm_write_buf(struct mtd_info *mtd, const u_char *buf, int len)</font>
<font color="#009900">++{</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(3,"fcm_write_buf: writing %d bytes starting with 0x%x"</font>
<font color="#009900">++                    " at %d.\n", len, *((unsigned long*) buf), fcm-&gt;index);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* If armed catch the address of the OOB buffer so that it can be */</font>
<font color="#009900">++        /* updated with the real signature after the program comletes */</font>
<font color="#009900">++        if (!fcm-&gt;oobbuf)</font>
<font color="#009900">++                fcm-&gt;oobbuf = (int) buf;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* copy the data into the FCM hardware buffer and update the index */</font>
<font color="#009900">++        memcpy(&amp;(fcm-&gt;addr[fcm-&gt;index]), buf, len);</font>
<font color="#009900">++        fcm-&gt;index += len;</font>
<font color="#009900">++        return;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * FCM does not support individual writes. Instead these are either commands</font>
<font color="#009900">++ * or data being written, both of which are handled through the cmdfunc</font>
<font color="#009900">++ * handler.</font>
<font color="#009900">++ */</font>
<font color="#009900">++static void fcm_write_byte(struct mtd_info *mtd, u_char byte)</font>
<font color="#009900">++{</font>
<font color="#009900">++        printf("fcm_write_byte: UNIMPLEMENTED.\n");</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * read a byte from either the FCM hardware buffer if it has any data left</font>
<font color="#009900">++ * otherwise issue a command to read a single byte.</font>
<font color="#009900">++ */</font>
<font color="#009900">++static u_char fcm_read_byte(struct mtd_info *mtd)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        unsigned char byte;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* If there are still bytes in the FCM then use the next byte */</font>
<font color="#009900">++        if(fcm-&gt;index &lt; fcm-&gt;read_bytes) {</font>
<font color="#009900">++                byte = fcm-&gt;addr[(fcm-&gt;index)++];</font>
<font color="#009900">++                FCM_DEBUG(4,"fcm_read_byte: byte %u (%02X): %d of %d.\n",</font>
<font color="#009900">++                          byte, byte, fcm-&gt;index-1, fcm-&gt;read_bytes);</font>
<font color="#009900">++        } else {</font>
<font color="#009900">++                /* otherwise issue a command to read 1 byte */</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_RSW &lt;&lt; FIR_OP0_SHIFT);</font>
<font color="#009900">++                fcm-&gt;use_mdr = 1;</font>
<font color="#009900">++                fcm-&gt;read_bytes = 0;</font>
<font color="#009900">++                fcm-&gt;index = 0;</font>
<font color="#009900">++                fcm-&gt;req_bytes = 0;</font>
<font color="#009900">++                fcm-&gt;req_index = 0;</font>
<font color="#009900">++                byte = fcm_run_command(mtd) ? ERR_BYTE : fcm-&gt;mdr &amp; 0xff;</font>
<font color="#009900">++                FCM_DEBUG(4,"fcm_read_byte: byte %u (%02X) from bus.\n",</font>
<font color="#009900">++                          byte, byte);</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        return byte;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Read from the FCM Controller Data Buffer</font>
<font color="#009900">++ */</font>
<font color="#009900">++static void fcm_read_buf(struct mtd_info *mtd, u_char* buf, int len)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        int i;</font>
<font color="#009900">++        int rest;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(3,"fcm_read_buf: reading %d bytes.\n", len);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* If last read failed then return error bytes */</font>
<font color="#009900">++        if (fcm-&gt;status != LTESR_CC) {</font>
<font color="#009900">++                /* just keep copying bytes so that the oob works */</font>
<font color="#009900">++                memcpy(buf, &amp;(fcm-&gt;addr[(fcm-&gt;index)]), len);</font>
<font color="#009900">++                fcm-&gt;index += len;</font>
<font color="#009900">++        }</font>
<font color="#009900">++        else</font>
<font color="#009900">++        {</font>
<font color="#009900">++                /* see how much is still in the FCM buffer */</font>
<font color="#009900">++                i = min(len, (fcm-&gt;read_bytes - fcm-&gt;index));</font>
<font color="#009900">++                rest = i - len;</font>
<font color="#009900">++                len = i;</font>
<font color="#009900">++</font>
<font color="#009900">++                memcpy(buf, &amp;(fcm-&gt;addr[(fcm-&gt;index)]), len);</font>
<font color="#009900">++                fcm-&gt;index += len;</font>
<font color="#009900">++</font>
<font color="#009900">++                /* If more data is needed then issue another block read */</font>
<font color="#009900">++                if (rest) {</font>
<font color="#009900">++                        FCM_DEBUG(3,"fcm_read_buf: getting %d more bytes.\n",</font>
<font color="#009900">++                                    rest);</font>
<font color="#009900">++                        buf += len;</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_RBW &lt;&lt; FIR_OP0_SHIFT);</font>
<font color="#009900">++                        set_addr(mtd, 0, 0, 0);</font>
<font color="#009900">++                        lbc-&gt;fbcr = rest;</font>
<font color="#009900">++                        fcm-&gt;req_bytes = lbc-&gt;fbcr;</font>
<font color="#009900">++                        fcm-&gt;req_index = 0;</font>
<font color="#009900">++                        fcm-&gt;use_mdr = 0;</font>
<font color="#009900">++                        if (!fcm_run_command(mtd))</font>
<font color="#009900">++                                fcm_read_buf(mtd, buf, rest);</font>
<font color="#009900">++                        else</font>
<font color="#009900">++                                memcpy(buf, fcm-&gt;addr, rest);</font>
<font color="#009900">++                }</font>
<font color="#009900">++        }</font>
<font color="#009900">++        return;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Verify buffer against the FCM Controller Data Buffer</font>
<font color="#009900">++ */</font>
<font color="#009900">++static int fcm_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        int i;</font>
<font color="#009900">++        int rest;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(3,"fcm_verify_buf: checking %d bytes starting with 0x%02x.\n",</font>
<font color="#009900">++                len, *((unsigned long*) buf));</font>
<font color="#009900">++        /* If last read failed then return error bytes */</font>
<font color="#009900">++        if (fcm-&gt;status != LTESR_CC) {</font>
<font color="#009900">++                return EFAULT;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* see how much is still in the FCM buffer */</font>
<font color="#009900">++        i = min(len, (fcm-&gt;read_bytes - fcm-&gt;index));</font>
<font color="#009900">++        rest = i - len;</font>
<font color="#009900">++        len = i;</font>
<font color="#009900">++</font>
<font color="#009900">++        if (memcmp(buf,        &amp;(fcm-&gt;addr[(fcm-&gt;index)]), len)) {</font>
<font color="#009900">++                return EFAULT;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        fcm-&gt;index += len;</font>
<font color="#009900">++        if (rest) {</font>
<font color="#009900">++                FCM_DEBUG(3,"fcm_verify_buf: getting %d more bytes.\n", rest);</font>
<font color="#009900">++                buf += len;</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_RBW &lt;&lt; FIR_OP0_SHIFT);</font>
<font color="#009900">++                set_addr(mtd, 0, 0, 0);</font>
<font color="#009900">++                lbc-&gt;fbcr = rest;</font>
<font color="#009900">++                fcm-&gt;req_bytes = lbc-&gt;fbcr;</font>
<font color="#009900">++                fcm-&gt;req_index = 0;</font>
<font color="#009900">++                fcm-&gt;use_mdr = 0;</font>
<font color="#009900">++                if (fcm_run_command(mtd))</font>
<font color="#009900">++                        return EFAULT;</font>
<font color="#009900">++                return fcm_verify_buf(mtd, buf, rest);</font>
<font color="#009900">++</font>
<font color="#009900">++        }</font>
<font color="#009900">++        return 0;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/* this function is called after Program and Erase Operations to</font>
<font color="#009900">++ * check for success or failure */</font>
<font color="#009900">++static int fcm_wait(struct mtd_info *mtd, struct nand_chip *this, int state)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++</font>
<font color="#009900">++        if (fcm-&gt;status != LTESR_CC) {</font>
<font color="#009900">++                return(0x1); /* Status Read error */</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* Use READ_STATUS command, but wait for the device to be ready */</font>
<font color="#009900">++        fcm-&gt;use_mdr = 0;</font>
<font color="#009900">++        fcm-&gt;req_index = 0;</font>
<font color="#009900">++        fcm-&gt;read_bytes = 0;</font>
<font color="#009900">++        fcm-&gt;index = 0;</font>
<font color="#009900">++        fcm-&gt;oobbuf = -1;</font>
<font color="#009900">++        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                   (FIR_OP_RBW &lt;&lt; FIR_OP1_SHIFT);</font>
<font color="#009900">++        lbc-&gt;fcr = (NAND_CMD_STATUS &lt;&lt; FCR_CMD0_SHIFT);</font>
<font color="#009900">++        set_addr(mtd, 0, 0, 0);</font>
<font color="#009900">++        lbc-&gt;fbcr = 1;</font>
<font color="#009900">++        fcm-&gt;req_bytes = lbc-&gt;fbcr;</font>
<font color="#009900">++        fcm_run_command(mtd);</font>
<font color="#009900">++        if (fcm-&gt;status != LTESR_CC) {</font>
<font color="#009900">++                return(0x1); /* Status Read error */</font>
<font color="#009900">++        }</font>
<font color="#009900">++        return this-&gt;read_byte(mtd);</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/* cmdfunc send commands to the FCM */</font>
<font color="#009900">++static void fcm_cmdfunc(struct mtd_info *mtd, unsigned command,</font>
<font color="#009900">++                        int column, int page_addr)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++</font>
<font color="#009900">++        fcm-&gt;use_mdr = 0;</font>
<font color="#009900">++        fcm-&gt;req_index = 0;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* clear the read buffer */</font>
<font color="#009900">++        fcm-&gt;read_bytes = 0;</font>
<font color="#009900">++        if (command != NAND_CMD_PAGEPROG) {</font>
<font color="#009900">++                fcm-&gt;index = 0;</font>
<font color="#009900">++                fcm-&gt;oobbuf = -1;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        switch (command) {</font>
<font color="#009900">++        /* READ0 and READ1 read the entire buffer to use hardware ECC */</font>
<font color="#009900">++        case NAND_CMD_READ1:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_READ1, page_addr:"</font>
<font color="#009900">++                            " 0x%x, column: 0x%x.\n", page_addr, column);</font>
<font color="#009900">++                fcm-&gt;req_index = column + 256;</font>
<font color="#009900">++                goto read0;</font>
<font color="#009900">++        case NAND_CMD_READ0:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_READ0, page_addr:"</font>
<font color="#009900">++                            " 0x%x, column: 0x%x.\n", page_addr, column);</font>
<font color="#009900">++                fcm-&gt;req_index = column;</font>
<font color="#009900">++read0:</font>
<font color="#009900">++                if (fcm-&gt;pgs) {</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CW1 &lt;&lt; FIR_OP3_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_RBW &lt;&lt; FIR_OP4_SHIFT);</font>
<font color="#009900">++                } else {</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_RBW &lt;&lt; FIR_OP3_SHIFT);</font>
<font color="#009900">++                }</font>
<font color="#009900">++                lbc-&gt;fcr = (NAND_CMD_READ0     &lt;&lt; FCR_CMD0_SHIFT) |</font>
<font color="#009900">++                           (NAND_CMD_READSTART &lt;&lt; FCR_CMD1_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fbcr = 0; /* read entire page to enable ECC */</font>
<font color="#009900">++                set_addr(mtd, 0, page_addr, 0);</font>
<font color="#009900">++                fcm-&gt;req_bytes = mtd-&gt;oobblock + mtd-&gt;oobsize;</font>
<font color="#009900">++                goto write_cmd2;</font>
<font color="#009900">++        /* READOOB read only the OOB becasue no ECC is performed */</font>
<font color="#009900">++        case NAND_CMD_READOOB:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_READOOB, page_addr:"</font>
<font color="#009900">++                            " 0x%x, column: 0x%x.\n", page_addr, column);</font>
<font color="#009900">++                if (fcm-&gt;pgs) {</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CW1 &lt;&lt; FIR_OP3_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_RBW &lt;&lt; FIR_OP4_SHIFT);</font>
<font color="#009900">++                        lbc-&gt;fcr = (NAND_CMD_READ0     &lt;&lt; FCR_CMD0_SHIFT) |</font>
<font color="#009900">++                                   (NAND_CMD_READSTART &lt;&lt; FCR_CMD1_SHIFT);</font>
<font color="#009900">++                } else {</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_RBW &lt;&lt; FIR_OP3_SHIFT);</font>
<font color="#009900">++                        lbc-&gt;fcr = (NAND_CMD_READOOB &lt;&lt; FCR_CMD0_SHIFT);</font>
<font color="#009900">++                }</font>
<font color="#009900">++                lbc-&gt;fbcr = mtd-&gt;oobsize - column;</font>
<font color="#009900">++                set_addr(mtd, column, page_addr, 1);</font>
<font color="#009900">++                goto write_cmd1;</font>
<font color="#009900">++        /* READID must read all 5 possible bytes while CEB is active */</font>
<font color="#009900">++        case NAND_CMD_READID:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_READID.\n");</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                           (FIR_OP_UA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                           (FIR_OP_RBW &lt;&lt; FIR_OP2_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fcr = (NAND_CMD_READID &lt;&lt; FCR_CMD0_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fbcr = 5; /* 5 bytes for manuf, device and exts */</font>
<font color="#009900">++                fcm-&gt;use_mdr = 1;</font>
<font color="#009900">++                fcm-&gt;mdr = 0;</font>
<font color="#009900">++                goto write_cmd0;</font>
<font color="#009900">++        /* ERASE1 stores the block and page address */</font>
<font color="#009900">++        case NAND_CMD_ERASE1:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_ERASE1, page_addr:"</font>
<font color="#009900">++                            " 0x%x.\n", page_addr);</font>
<font color="#009900">++                set_addr(mtd, 0, page_addr, 0);</font>
<font color="#009900">++                goto end;</font>
<font color="#009900">++        /* ERASE2 uses the block and page address from ERASE1 */</font>
<font color="#009900">++        case NAND_CMD_ERASE2:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_ERASE2.\n");</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                           (FIR_OP_PA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                           (FIR_OP_CM1 &lt;&lt; FIR_OP2_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fcr = (NAND_CMD_ERASE1 &lt;&lt; FCR_CMD0_SHIFT) |</font>
<font color="#009900">++                           (NAND_CMD_ERASE2 &lt;&lt; FCR_CMD1_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fbcr = 0;</font>
<font color="#009900">++                goto write_cmd1;</font>
<font color="#009900">++        /* SEQIN sets up the addr buffer and all registers except the length */</font>
<font color="#009900">++        case NAND_CMD_SEQIN:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_SEQIN/PAGE_PROG, page_addr:"</font>
<font color="#009900">++                            " 0x%x, column: 0x%x.\n", page_addr, column);</font>
<font color="#009900">++                if (column == 0) {</font>
<font color="#009900">++                        lbc-&gt;fbcr = 0; /* write entire page to enable ECC */</font>
<font color="#009900">++                } else {</font>
<font color="#009900">++                        lbc-&gt;fbcr = 1; /* mark as partial page so no HW ECC */</font>
<font color="#009900">++                }</font>
<font color="#009900">++                if (fcm-&gt;pgs) {</font>
<font color="#009900">++                        /* always use READ0 for large page devices */</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_WB  &lt;&lt; FIR_OP3_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CW1 &lt;&lt; FIR_OP4_SHIFT);</font>
<font color="#009900">++                        lbc-&gt;fcr = (NAND_CMD_SEQIN &lt;&lt; FCR_CMD0_SHIFT) |</font>
<font color="#009900">++                                   (NAND_CMD_PAGEPROG &lt;&lt; FCR_CMD1_SHIFT);</font>
<font color="#009900">++                        set_addr(mtd, column, page_addr, 0);</font>
<font color="#009900">++                } else {</font>
<font color="#009900">++                        lbc-&gt;fir = (FIR_OP_CW0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CM2 &lt;&lt; FIR_OP1_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CA  &lt;&lt; FIR_OP2_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_PA  &lt;&lt; FIR_OP3_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_WB  &lt;&lt; FIR_OP4_SHIFT) |</font>
<font color="#009900">++                                   (FIR_OP_CW1 &lt;&lt; FIR_OP5_SHIFT);</font>
<font color="#009900">++                        if (column &gt;= mtd-&gt;oobblock) {</font>
<font color="#009900">++                                /* OOB area --&gt; READOOB */</font>
<font color="#009900">++                                column -= mtd-&gt;oobblock;</font>
<font color="#009900">++                                lbc-&gt;fcr = (NAND_CMD_READOOB &lt;&lt; FCR_CMD0_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_PAGEPROG&lt;&lt; FCR_CMD1_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_SEQIN &lt;&lt; FCR_CMD2_SHIFT);</font>
<font color="#009900">++                                set_addr(mtd, column, page_addr, 1);</font>
<font color="#009900">++                        } else if (column &lt; 256) {</font>
<font color="#009900">++                                /* First 256 bytes --&gt; READ0 */</font>
<font color="#009900">++                                lbc-&gt;fcr = (NAND_CMD_READ0 &lt;&lt; FCR_CMD0_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_PAGEPROG&lt;&lt; FCR_CMD1_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_SEQIN &lt;&lt; FCR_CMD2_SHIFT);</font>
<font color="#009900">++                                set_addr(mtd, column, page_addr, 0);</font>
<font color="#009900">++                        } else {</font>
<font color="#009900">++                                /* Second 256 bytes --&gt; READ1 */</font>
<font color="#009900">++                                column -= 256;</font>
<font color="#009900">++                                lbc-&gt;fcr = (NAND_CMD_READ1 &lt;&lt; FCR_CMD0_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_PAGEPROG&lt;&lt; FCR_CMD1_SHIFT)</font>
<font color="#009900">++                                         | (NAND_CMD_SEQIN &lt;&lt; FCR_CMD2_SHIFT);</font>
<font color="#009900">++                                set_addr(mtd, column, page_addr, 0);</font>
<font color="#009900">++                        }</font>
<font color="#009900">++                }</font>
<font color="#009900">++                goto end;</font>
<font color="#009900">++        /* PAGEPROG reuses all of the setup from SEQIN and adds the length */</font>
<font color="#009900">++        case NAND_CMD_PAGEPROG:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_PAGEPROG"</font>
<font color="#009900">++                            " writing %d bytes.\n",fcm-&gt;index);</font>
<font color="#009900">++                /* if the write did not start at 0 or is not a full page */</font>
<font color="#009900">++                /* then set the exact length, otherwise use a full page  */</font>
<font color="#009900">++                /* write so the HW generates the ECC. */</font>
<font color="#009900">++                if (lbc-&gt;fbcr ||</font>
<font color="#009900">++                   (fcm-&gt;index != (mtd-&gt;oobblock + mtd-&gt;oobsize)))</font>
<font color="#009900">++                        lbc-&gt;fbcr = fcm-&gt;index;</font>
<font color="#009900">++                fcm-&gt;req_bytes = 0;</font>
<font color="#009900">++                goto write_cmd2;</font>
<font color="#009900">++        /* CMD_STATUS must read the status byte while CEB is active */</font>
<font color="#009900">++        /* Note - it does not wait for the ready line */</font>
<font color="#009900">++        case NAND_CMD_STATUS:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_STATUS.\n");</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_CM0 &lt;&lt; FIR_OP0_SHIFT) |</font>
<font color="#009900">++                           (FIR_OP_RBW &lt;&lt; FIR_OP1_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fcr = (NAND_CMD_STATUS &lt;&lt; FCR_CMD0_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fbcr = 1;</font>
<font color="#009900">++                goto write_cmd0;</font>
<font color="#009900">++        /* RESET without waiting for the ready line */</font>
<font color="#009900">++        case NAND_CMD_RESET:</font>
<font color="#009900">++                FCM_DEBUG(2,"fcm_cmdfunc: NAND_CMD_RESET.\n");</font>
<font color="#009900">++                lbc-&gt;fir = (FIR_OP_CM0 &lt;&lt; FIR_OP0_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fcr = (NAND_CMD_RESET &lt;&lt; FCR_CMD0_SHIFT);</font>
<font color="#009900">++                lbc-&gt;fbcr = 0;</font>
<font color="#009900">++                goto write_cmd0;</font>
<font color="#009900">++        default:</font>
<font color="#009900">++                printk("fcm_cmdfunc: error, unsupported command.\n");</font>
<font color="#009900">++                goto end;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* Short cuts fall through to save code */</font>
<font color="#009900">++ write_cmd0:</font>
<font color="#009900">++        set_addr(mtd, 0, 0, 0);</font>
<font color="#009900">++ write_cmd1:</font>
<font color="#009900">++        fcm-&gt;req_bytes = lbc-&gt;fbcr;</font>
<font color="#009900">++ write_cmd2:</font>
<font color="#009900">++        fcm_run_command(mtd);</font>
<font color="#009900">++</font>
<font color="#009900">++#ifdef CONFIG_MTD_NAND_VERIFY_WRITE</font>
<font color="#009900">++        /* if we wrote a page then read back the oob to get the ECC */</font>
<font color="#009900">++        if ((command == NAND_CMD_PAGEPROG) &amp;&amp;</font>
<font color="#009900">++            (this-&gt;eccmode &gt; NAND_ECC_SOFT) &amp;&amp;</font>
<font color="#009900">++            (lbc-&gt;fbcr == 0) &amp;&amp;</font>
<font color="#009900">++            (fcm-&gt;oobbuf != 0) &amp;&amp;</font>
<font color="#009900">++            (fcm-&gt;oobbuf != -1)) {</font>
<font color="#009900">++                int i;</font>
<font color="#009900">++                uint *oob_config;</font>
<font color="#009900">++                unsigned char *oob_buf;</font>
<font color="#009900">++</font>
<font color="#009900">++                i = fcm-&gt;page;</font>
<font color="#009900">++                oob_buf = (unsigned char*) fcm-&gt;oobbuf;</font>
<font color="#009900">++                oob_config = this-&gt;autooob-&gt;eccpos;</font>
<font color="#009900">++</font>
<font color="#009900">++                /* wait for the write to complete and check it passed */</font>
<font color="#009900">++                if (!(this-&gt;waitfunc(mtd, this, FL_WRITING) &amp; 0x01)) {</font>
<font color="#009900">++                        /* read back the OOB */</font>
<font color="#009900">++                        fcm_cmdfunc(mtd, NAND_CMD_READOOB, 0, i);</font>
<font color="#009900">++                        /* if it succeeded then copy the ECC bytes */</font>
<font color="#009900">++                        if (fcm-&gt;status == LTESR_CC) {</font>
<font color="#009900">++                                for (i = 0; i &lt; this-&gt;eccbytes; i++) {</font>
<font color="#009900">++                                        oob_buf[oob_config[i]] =</font>
<font color="#009900">++                                                fcm-&gt;addr[oob_config[i]];</font>
<font color="#009900">++                                }</font>
<font color="#009900">++                        }</font>
<font color="#009900">++                }</font>
<font color="#009900">++        }</font>
<font color="#009900">++#endif</font>
<font color="#009900">++</font>
<font color="#009900">++ end:</font>
<font color="#009900">++        return;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * fcm_enable_hwecc - start ECC generation</font>
<font color="#009900">++ */</font>
<font color="#009900">++static void fcm_enable_hwecc(struct mtd_info *mtd, int mode)</font>
<font color="#009900">++{</font>
<font color="#009900">++        return;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * fcm_calculate_ecc - Calculate the ECC bytes</font>
<font color="#009900">++ * This is done by hardware during the write process, so we use this</font>
<font color="#009900">++ * to arm the oob buf capture on the next write_buf() call. The ECC bytes</font>
<font color="#009900">++ * only need to be captured if CONFIG_MTD_NAND_VERIFY_WRITE is defined which</font>
<font color="#009900">++ * reads back the pages and checks they match the data and oob buffers.</font>
<font color="#009900">++ */</font>
<font color="#009900">++static int fcm_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)</font>
<font color="#009900">++{</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++</font>
<font color="#009900">++#ifdef CONFIG_MTD_NAND_VERIFY_WRITE</font>
<font color="#009900">++        /* arm capture of oob buf ptr on next write_buf */</font>
<font color="#009900">++        fcm-&gt;oobbuf = 0;</font>
<font color="#009900">++#endif</font>
<font color="#009900">++        return 0;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * fcm_correct_data - Detect and correct bit error(s)</font>
<font color="#009900">++ * The detection and correction is done automatically by the hardware,</font>
<font color="#009900">++ * if the complete page was read. If the status code is okay then there</font>
<font color="#009900">++ * was no error, otherwise we return an error code indicating an uncorrectable</font>
<font color="#009900">++ * error.</font>
<font color="#009900">++ */</font>
<font color="#009900">++static int fcm_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)</font>
<font color="#009900">++{</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* No errors */</font>
<font color="#009900">++        if (fcm-&gt;status == LTESR_CC)</font>
<font color="#009900">++                return 0;</font>
<font color="#009900">++</font>
<font color="#009900">++        return -1; /* uncorrectable error */</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Dummy scan_bbt to complete setup of the FMR based on NAND size</font>
<font color="#009900">++ */</font>
<font color="#009900">++static int fcm_scan_bbt (struct mtd_info *mtd)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        register struct nand_chip *this = mtd-&gt;priv;</font>
<font color="#009900">++        struct fcm_nand *fcm = this-&gt;priv;</font>
<font color="#009900">++        unsigned int i;</font>
<font color="#009900">++        unsigned int al;</font>
<font color="#009900">++</font>
<font color="#009900">++        if (!fcm) {</font>
<font color="#009900">++                printk (KERN_ERR "fcm_scan_bbt():" \</font>
<font color="#009900">++                        " Failed to allocate chip specific data structure\n");</font>
<font color="#009900">++                return -1;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* calculate FMR Address Length field */</font>
<font color="#009900">++        al = 0;</font>
<font color="#009900">++        for (i = this-&gt;pagemask &gt;&gt; 16; i ; i &gt;&gt;= 8) {</font>
<font color="#009900">++                al++;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* add to ECCM mode set in fcm_init */</font>
<font color="#009900">++        fcm-&gt;fmr |= 12 &lt;&lt; FMR_CWTO_SHIFT |  /* Timeout &gt; 12 mSecs */</font>
<font color="#009900">++                    al &lt;&lt; FMR_AL_SHIFT;</font>
<font color="#009900">++</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;options  =   %08X\n", this-&gt;options);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;numchips = %10d\n", this-&gt;numchips);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;chipsize = %10d\n", this-&gt;chipsize);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;pagemask = %10X\n", this-&gt;pagemask);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;eccmode  = %10d\n", this-&gt;eccmode );</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;eccsize  = %10d\n", this-&gt;eccsize );</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;eccbytes = %10d\n", this-&gt;eccbytes);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;eccsteps = %10d\n", this-&gt;eccsteps);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;chip_delay = %8d\n", this-&gt;chip_delay);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;badblockpos = %7d\n", this-&gt;badblockpos);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;chip_shift = %8d\n", this-&gt;chip_shift);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;page_shift = %8d\n", this-&gt;page_shift);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: nand-&gt;phys_erase_shift = %2d\n",</font>
<font color="#009900">++                                                      this-&gt;phys_erase_shift);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;flags     =   %08X\n", mtd-&gt;flags);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;size      = %10d\n", mtd-&gt;size);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;erasesize = %10d\n", mtd-&gt;erasesize);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;oobblock  = %10d\n", mtd-&gt;oobblock);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;oobsize   = %10d\n", mtd-&gt;oobsize);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;oobavail  = %10d\n", mtd-&gt;oobavail);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;ecctype   = %10d\n", mtd-&gt;ecctype);</font>
<font color="#009900">++        FCM_DEBUG(1,"fcm_init: mtd-&gt;eccsize   = %10d\n", mtd-&gt;eccsize);</font>
<font color="#009900">++</font>
<font color="#009900">++        /* adjust Option Register and ECC to match Flash page size */</font>
<font color="#009900">++        if (mtd-&gt;oobblock == 512)</font>
<font color="#009900">++                lbc-&gt;bank[fcm-&gt;bank].or &amp;= ~(OR_FCM_PGS);</font>
<font color="#009900">++        else if (mtd-&gt;oobblock == 2048) {</font>
<font color="#009900">++                lbc-&gt;bank[fcm-&gt;bank].or |= OR_FCM_PGS;</font>
<font color="#009900">++                /* adjust ecc setup if needed */</font>
<font color="#009900">++                if ( (lbc-&gt;bank[fcm-&gt;bank].br &amp; BR_DECC) == BR_DECC_CHK_GEN) {</font>
<font color="#009900">++                        mtd-&gt;eccsize = 2048;</font>
<font color="#009900">++                        mtd-&gt;oobavail -= 9;</font>
<font color="#009900">++                        this-&gt;eccmode = NAND_ECC_HW12_2048;</font>
<font color="#009900">++                        this-&gt;eccsize = 2048;</font>
<font color="#009900">++                        this-&gt;eccbytes += 9;</font>
<font color="#009900">++                        this-&gt;eccsteps = 1;</font>
<font color="#009900">++                        this-&gt;autooob = (fcm-&gt;fmr &amp; FMR_ECCM) ?</font>
<font color="#009900">++                                        &amp;fcm_oob_lp_eccm1 : &amp;fcm_oob_lp_eccm0;</font>
<font color="#009900">++                        memcpy(&amp;mtd-&gt;oobinfo, this-&gt;autooob,</font>
<font color="#009900">++                                        sizeof(mtd-&gt;oobinfo));</font>
<font color="#009900">++                }</font>
<font color="#009900">++        }</font>
<font color="#009900">++        else {</font>
<font color="#009900">++                printf("fcm_init: page size %d is not supported\n",</font>
<font color="#009900">++                        mtd-&gt;oobblock);</font>
<font color="#009900">++                return -1;</font>
<font color="#009900">++        }</font>
<font color="#009900">++        fcm-&gt;pgs = (lbc-&gt;bank[fcm-&gt;bank].or&gt;&gt;OR_FCM_PGS_SHIFT) &amp; 1;</font>
<font color="#009900">++</font>
<font color="#009900">++        if (al &gt; 2) {</font>
<font color="#009900">++                printf("fcm_init: %d address bytes is not supported\n", al+2);</font>
<font color="#009900">++                return -1;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* restore default scan_bbt function and call it */</font>
<font color="#009900">++        this-&gt;scan_bbt = nand_default_bbt;</font>
<font color="#009900">++        return nand_default_bbt(mtd);</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++/*</font>
<font color="#009900">++ * Board-specific NAND initialization. The following members of the</font>
<font color="#009900">++ * argument are board-specific (per include/linux/mtd/nand_new.h):</font>
<font color="#009900">++ * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device</font>
<font color="#009900">++ * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device</font>
<font color="#009900">++ * - hwcontrol: hardwarespecific function for accesing control-lines</font>
<font color="#009900">++ * - dev_ready: hardwarespecific function for accesing device ready/busy line</font>
<font color="#009900">++ * - enable_hwecc: function to enable (reset) hardware ecc generator. Must</font>
<font color="#009900">++ *   only be provided if a hardware ECC is available</font>
<font color="#009900">++ * - eccmode: mode of ecc, see defines</font>
<font color="#009900">++ * - chip_delay: chip dependent delay for transfering data from array to</font>
<font color="#009900">++ *   read regs (tR)</font>
<font color="#009900">++ * - options: various chip options. They can partly be set to inform</font>
<font color="#009900">++ *   nand_scan about special functionality. See the defines for further</font>
<font color="#009900">++ *   explanation</font>
<font color="#009900">++ * Members with a "?" were not set in the merged testing-NAND branch,</font>
<font color="#009900">++ * so they are not set here either.</font>
<font color="#009900">++ */</font>
<font color="#009900">++int board_nand_init(struct nand_chip *nand)</font>
<font color="#009900">++{</font>
<font color="#009900">++        volatile immap_t *im = (immap_t *) CFG_IMMR;</font>
<font color="#009900">++        volatile lbus83xx_t *lbc= &amp;im-&gt;lbus;</font>
<font color="#009900">++        struct fcm_nand *fcm;</font>
<font color="#009900">++        unsigned int bank;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* Enable FCM detection of timeouts, ECC errors and completion */</font>
<font color="#009900">++        lbc-&gt;ltedr &amp;= ~(LTESR_FCT | LTESR_PAR | LTESR_CC);</font>
<font color="#009900">++</font>
<font color="#009900">++        fcm = kmalloc (sizeof(struct fcm_nand), GFP_KERNEL);</font>
<font color="#009900">++        if (!fcm) {</font>
<font color="#009900">++                printk (KERN_ERR "board_nand_init():" \</font>
<font color="#009900">++                        " Cannot allocate read buffer data structure\n");</font>
<font color="#009900">++                return;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* Find which chip select bank is being used for this device */</font>
<font color="#009900">++        for (bank=0; bank&lt;8; bank++) {</font>
<font color="#009900">++                if ( (lbc-&gt;bank[bank].br &amp; BR_V) &amp;&amp;</font>
<font color="#009900">++                   ( (lbc-&gt;bank[bank].br &amp; BR_MSEL) == BR_MS_FCM ) &amp;&amp;</font>
<font color="#009900">++                   ( (lbc-&gt;bank[bank].br &amp; BR_BA) ==</font>
<font color="#009900">++                     (lbc-&gt;bank[bank].or &amp; OR_FCM_AM &amp;</font>
<font color="#009900">++                        (unsigned int)(nand-&gt;IO_ADDR_R) ) ) ) {</font>
<font color="#009900">++                        fcm-&gt;bank = bank;</font>
<font color="#009900">++// TODO                        fcm-&gt;fmr = FMR_ECCM; /* rest filled in later */</font>
<font color="#009900">++                        fcm-&gt;fmr = 0; /* rest filled in later */</font>
<font color="#009900">++                        fcm-&gt;read_bytes = 0;</font>
<font color="#009900">++                        fcm-&gt;index = 0;</font>
<font color="#009900">++                        fcm-&gt;pgs = (lbc-&gt;bank[bank].or&gt;&gt;OR_FCM_PGS_SHIFT) &amp; 1;</font>
<font color="#009900">++                        fcm-&gt;base = lbc-&gt;bank[bank].br &amp; BR_BA;</font>
<font color="#009900">++                        fcm-&gt;addr = (unsigned char*) (fcm-&gt;base);</font>
<font color="#009900">++                        nand-&gt;priv = fcm;</font>
<font color="#009900">++                        fcm-&gt;oobbuf = -1;</font>
<font color="#009900">++                        break;</font>
<font color="#009900">++                }</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        if (!nand-&gt;priv) {</font>
<font color="#009900">++                printk (KERN_ERR "board_nand_init():" \</font>
<font color="#009900">++                        " Could not find matching Chip Select\n");</font>
<font color="#009900">++                return -1;</font>
<font color="#009900">++        }</font>
<font color="#009900">++</font>
<font color="#009900">++        /* set up nand options */</font>
<font color="#009900">++        nand-&gt;options = 0;</font>
<font color="#009900">++        /* set up function call table */</font>
<font color="#009900">++        nand-&gt;hwcontrol = fcm_hwcontrol;</font>
<font color="#009900">++        nand-&gt;waitfunc = fcm_wait;</font>
<font color="#009900">++        nand-&gt;read_byte = fcm_read_byte;</font>
<font color="#009900">++        nand-&gt;write_byte = fcm_write_byte;</font>
<font color="#009900">++        nand-&gt;read_word = fcm_read_word;</font>
<font color="#009900">++        nand-&gt;write_word = fcm_write_word;</font>
<font color="#009900">++        nand-&gt;read_buf = fcm_read_buf;</font>
<font color="#009900">++        nand-&gt;verify_buf = fcm_verify_buf;</font>
<font color="#009900">++        nand-&gt;write_buf = fcm_write_buf;</font>
<font color="#009900">++        nand-&gt;cmdfunc = fcm_cmdfunc;</font>
<font color="#009900">++        nand-&gt;scan_bbt = fcm_scan_bbt;</font>
<font color="#009900">++</font>
<font color="#009900">++        /* If CS Base Register selects full hardware ECC then use it */</font>
<font color="#009900">++        if ( ( (lbc-&gt;bank[bank].br &amp; BR_DECC) &gt;&gt; BR_DECC_SHIFT) == 2) {</font>
<font color="#009900">++                /* put in small page settings and adjust later if needed */</font>
<font color="#009900">++                nand-&gt;eccmode = NAND_ECC_HW3_512;</font>
<font color="#009900">++                nand-&gt;autooob = (fcm-&gt;fmr &amp; FMR_ECCM) ?</font>
<font color="#009900">++                                &amp;fcm_oob_sp_eccm1 : &amp;fcm_oob_sp_eccm0;</font>
<font color="#009900">++                nand-&gt;calculate_ecc = fcm_calculate_ecc;</font>
<font color="#009900">++                nand-&gt;correct_data = fcm_correct_data;</font>
<font color="#009900">++                nand-&gt;enable_hwecc = fcm_enable_hwecc;</font>
<font color="#009900">++        } else {</font>
<font color="#009900">++                /* otherwise fall back to default software ECC */</font>
<font color="#009900">++                nand-&gt;eccmode = NAND_ECC_SOFT;</font>
<font color="#009900">++        }</font>
<font color="#009900">++        return 0;</font>
<font color="#009900">++}</font>
<font color="#009900">++</font>
<font color="#009900">++#endif</font>
<font color="#009900">++#endif</font>
<font color="#009900">+diff -urN u-boot-1.3.1.orig/include/configs/MPC8313ERDB.h u-boot-1.3.1/include/configs/MPC8313ERDB.h</font>
<font color="#009900">+--- u-boot-1.3.1.orig/include/configs/MPC8313ERDB.h        2007-12-06 10:21:19.000000000 +0100</font>
<font color="#009900">++++ u-boot-1.3.1/include/configs/MPC8313ERDB.h        2008-01-31 17:36:18.000000000 +0100</font>
<font color="#009900">+@@ -360,6 +360,7 @@</font>
<font color="#009900">+ #define CONFIG_CMD_MII</font>
<font color="#009900">+ #define CONFIG_CMD_DATE</font>
<font color="#009900">+ #define CONFIG_CMD_PCI</font>
<font color="#009900">++#define CONFIG_CMD_NAND</font>
<font color="#009900">+ </font>
<font color="#009900">+ #if defined(CFG_RAMBOOT)</font>
<font color="#009900">+     #undef CONFIG_CMD_ENV</font>
============================================================
<font color="#FF6600">--- packages/u-boot/u-boot_1.3.2.bb        8cfd5293c0214179a38b2304fbd10c77a3912aff</font>
<font color="#009900">+++ packages/u-boot/u-boot_1.3.2.bb        33ac513192e4695c4ea43a787d866c98c2a011ef</font>
<font color="#0000FF">@@ -2,6 +2,11 @@ DEFAULT_PREFERENCE = "-1"</font>
 
 DEFAULT_PREFERENCE = "-1"
 
<font color="#FF6600">-SRC_URI = "ftp://ftp.denx.de/pub/u-boot/u-boot-${PV}.tar.bz2"</font>
<font color="#009900">+PR = "r1"</font>
 
<font color="#009900">+SRC_URI = "ftp://ftp.denx.de/pub/u-boot/u-boot-${PV}.tar.bz2 \</font>
<font color="#009900">+           file://mpc8313e-rdb-autoboot.patch;patch=1 \</font>
<font color="#009900">+           file://mpc8313e-rdb-mtdparts.patch;patch=1 \</font>
<font color="#009900">+           file://mpc8313e-rdb-nand.patch;patch=1"</font>
<font color="#009900">+</font>
 PACKAGE_ARCH = "${MACHINE_ARCH}"
</tt></pre>