]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/devs/flash/arm/mxc/v2_0/src/mxc_nfc.c
RedBoot STK5 Release 2010-03-04
[karo-tx-redboot.git] / packages / devs / flash / arm / mxc / v2_0 / src / mxc_nfc.c
index fbeffcc19f19808424e7d165a723fda2721f1014..683b954ee9c2e2ca013f596c47fa184f72937db6 100644 (file)
@@ -84,6 +84,7 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.h>
 #include <cyg/hal/hal_cache.h>
+#include <cyg/hal/hal_misc.h>
 #include <cyg/io/nand_bbt.h>
 #include <redboot.h>
 #include <stdlib.h>
@@ -94,7 +95,9 @@
 #define         _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
 
+#ifdef CYGHWR_FLASH_NAND_BBT_HEADER
 #include CYGHWR_FLASH_NAND_BBT_HEADER
+#endif
 
 #include <cyg/io/imx_nfc.h>
 
@@ -411,9 +414,6 @@ nandflash_hwr_init(void)
        u32 id[2];
        int i;
 
-#if 0
-       return FLASH_ERR_DRV_WRONG_PART;
-#endif
        nfc_printf(NFC_DEBUG_MAX, "%s()\n", __FUNCTION__);
 
        if (nfc_iomux_setup)
@@ -701,35 +701,7 @@ static void read_nflash_id(u32 *id, u32 cs_line)
 
        nfc_printf(NFC_DEBUG_MIN, "%s: read flash id from chip %d @ %p\n",
                           __FUNCTION__, cs_line, ptr);
-#if 0
-#if 1
-       {
-               int i;
-               const int nwords = 512 >> 2;
-
-               for (i = 0; i < 8; i++) {
-                       int j;
-
-                       for (j = 0; j < nwords; j++) {
-                               ptr[i * nwords + j] = 0xdeadbeef;
-                       }
-               }
-       }
-#else
-       {
-               int i;
-               const int nwords = 512 >> 2;
-
-               for (i = 0; i < 8; i++) {
-                       int j;
 
-                       for (j = 0; j < nwords; j++) {
-                               id[i * nwords + j] = 0xdeadbeef;
-                       }
-               }
-       }
-#endif
-#endif
        NFC_PRESET(MXC_UNLOCK_BLK_END);
        NFC_SET_NFC_ACTIVE_CS(cs_line);
        NFC_CMD_INPUT(FLASH_Read_ID);
@@ -849,6 +821,19 @@ static int nfc_is_badblock(u32 block, u8 *buf)
        return 0;
 }
 
+static inline void mxc_nfc_buf_clear(unsigned long buf, u8 pattern, int size)
+{
+       int i;
+       u16 *p = (u16 *)buf;
+       u16 fill = pattern;
+
+       fill = (fill << 8) | pattern;
+       for (i = 0; i < size >> 1; i++) {
+               p[i] = fill;
+       }
+}
+
+#ifdef CYGHWR_FLASH_NAND_BBT_HEADER
 /*
  * check_short_pattern - [GENERIC] check if a pattern is in the buffer
  * @buf:       the buffer to search
@@ -902,18 +887,6 @@ static int mxc_nfc_write_bbt_page(struct nand_bbt_descr *td)
        return 0;
 }
 
-static inline void mxc_nfc_buf_clear(unsigned long buf, u8 pattern, int size)
-{
-       int i;
-       u16 *p = (u16 *)buf;
-       u16 fill = pattern;
-
-       fill = (fill << 8) | pattern;
-       for (i = 0; i < size >> 1; i++) {
-               p[i] = fill;
-       }
-}
-
 static int mxc_nfc_write_bbt(struct nand_bbt_descr *td, struct nand_bbt_descr *md)
 {
        int ret = -1;
@@ -1012,6 +985,12 @@ static int program_bbt_to_flash(void)
 {
        return mxc_nfc_update_bbt(g_mxc_nfc_bbt_main_descr, g_mxc_nfc_bbt_mirror_descr);
 }
+#else
+static int program_bbt_to_flash(void)
+{
+       return 0;
+}
+#endif
 
 /*!
  * Unconditionally erase a block without checking the BI field.
@@ -2447,24 +2426,6 @@ static void nand_bad(int argc, char *argv[])
 static void do_nand_cmds(int argc, char *argv[])
 {
        struct cmd *cmd;
-#if 0
-       unsigned long ctrl, l2, sid, cs;
-       unsigned int d, i;
-
-       HAL_FLASH_CACHES_OFF(d, i);
-       diag_printf("DCACHE: %d ICACHE: %d\n", d, i);
-       HAL_FLASH_CACHES_ON(d, i);
-
-       asm volatile(
-               "MRC p15, 0, %0, c1, c0, 0;"
-               "MRC p15, 0, %1, c1, c0, 1;"
-               "MRC p15, 1, %2, c0, c0, 7;"
-               "MRC p15, 1, %3, c0, c0, 0;"
-               : "=r"(ctrl), "=r"(l2), "=r"(sid), "=r"(cs)
-               );
-
-       diag_printf("ctrl: %08lx aux: %08lx sid: %08lx cs: %08lx\n", ctrl, l2, sid, cs);
-#endif
 
        if (!mxcnfc_init_ok) {
                flash_hwr_init();