]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/devs/flash/arm/mxc/v2_0/src/mxc_nfc.c
TX51 Release 2011-07-27
[karo-tx-redboot.git] / packages / devs / flash / arm / mxc / v2_0 / src / mxc_nfc.c
index 7b19ff0ef19488de8046f03c2bdb61a9a955644e..683b954ee9c2e2ca013f596c47fa184f72937db6 100644 (file)
@@ -167,7 +167,7 @@ CYG_MACRO_END
 #define NAND_CONFIGURATION1_REG                0xDEADEEEE
 #define NFC_FLASH_CONFIG2_REG          0xDEADEEEE
 #define NFC_FLASH_CONFIG2_ECC_EN       0xDEADEEEE
-#define write_nfc_ip_reg(a, b)         CYG_EMPTY_STATEMENT
+#define write_nfc_ip_reg(a, b)
 #endif
 
 #ifndef MXCFLASH_SELECT_MULTI
@@ -188,7 +188,7 @@ void nandflash_query(void *data)
                                __FUNCTION__, __LINE__, &id[0], data);
                memcpy(data, id, sizeof(id));
        }
-       nfc_printf(NFC_DEBUG_MAX, "%s@%d called from %p\n", __FUNCTION__, __LINE__,
+       nfc_printf(NFC_DEBUG_MAX, "%s@%d %p\n", __FUNCTION__, __LINE__,
                        __builtin_return_address(0));
 }
 
@@ -290,21 +290,21 @@ static const flash_dev_info_t *flash_dev_info;
 static const flash_dev_info_t supported_devices[] = {
 #include <cyg/io/mxc_nand_parts.inl>
 };
-#define NUM_DEVICES                                            NUM_ELEMS(supported_devices)
-
-#define COL_CYCLE                                              flash_dev_info->col_cycle
-#define ROW_CYCLE                                              flash_dev_info->row_cycle
-#define NF_PG_SZ                                               (flash_dev_info->page_size * num_of_nand_chips)
-#define NF_SPARE_SZ                                            (flash_dev_info->spare_size * num_of_nand_chips)
-#define NF_PG_PER_BLK                                  flash_dev_info->pages_per_block
-#define NF_DEV_SZ                                              (flash_dev_info->device_size * num_of_nand_chips_for_nandsize)
-#define NF_BLK_SZ                                              (flash_dev_info->block_size * num_of_nand_chips)
-#define NF_BLK_CNT                                             (flash_dev_info->block_count / scale_block_cnt)
-#define NF_VEND_INFO                                   flash_dev_info->vendor_info
-#define NF_OPTIONS                                             flash_dev_info->options
-#define NF_BBT_MAX_NR                                  flash_dev_info->bbt_blk_max_nr
-#define NF_OPTIONS                                             flash_dev_info->options
-#define NF_BI_OFF                                              flash_dev_info->bi_off
+#define NUM_DEVICES NUM_ELEMS(supported_devices)
+
+#define COL_CYCLE                                      flash_dev_info->col_cycle
+#define ROW_CYCLE                                      flash_dev_info->row_cycle
+#define NF_PG_SZ                                       ((flash_dev_info->page_size) * num_of_nand_chips)
+#define NF_SPARE_SZ                                    ((flash_dev_info->spare_size) * num_of_nand_chips)
+#define NF_PG_PER_BLK                          flash_dev_info->pages_per_block
+#define NF_DEV_SZ                                      ((flash_dev_info->device_size) * num_of_nand_chips_for_nandsize)
+#define NF_BLK_SZ                                      ((flash_dev_info->block_size) * num_of_nand_chips)
+#define NF_BLK_CNT                                     ((flash_dev_info->block_count) / scale_block_cnt)
+#define NF_VEND_INFO                           flash_dev_info->vendor_info
+#define NF_OPTIONS                                     flash_dev_info->options
+#define NF_BBT_MAX_NR                          flash_dev_info->bbt_blk_max_nr
+#define NF_OPTIONS                                     flash_dev_info->options
+#define NF_BI_OFF                                      flash_dev_info->bi_off
 
 #define MXC_NAND_ADDR_MASK                             (NF_DEV_SZ - 1)
 #define BLOCK_TO_OFFSET(blk)                   ((blk) * NF_PG_PER_BLK * NF_PG_SZ)
@@ -315,7 +315,7 @@ static const flash_dev_info_t supported_devices[] = {
 
 static u8 *g_bbt, *g_page_buf;
 static u32 g_bbt_sz;
-static bool mxcnfc_init_ok;
+static bool mxcnfc_init_ok = false;
 static bool mxc_nfc_scan_done;
 
 // this callback allows the platform specific function to be called right
@@ -369,8 +369,6 @@ void mxc_flash_enable(void *start, void *end)
        flash_addr_t s = (unsigned long)start & MXC_NAND_ADDR_MASK;
        flash_addr_t e = ((unsigned long)end - 1) & MXC_NAND_ADDR_MASK;
 
-       if (start == end)
-               return;
        if (flash_enable++ == 0) {
                flash_region_start = s;
                flash_region_end = e;
@@ -391,8 +389,6 @@ void mxc_flash_disable(void *start, void *end)
        flash_addr_t s = (unsigned long)start & MXC_NAND_ADDR_MASK;
        flash_addr_t e = ((unsigned long)end - 1) & MXC_NAND_ADDR_MASK;
 
-       if (start == end)
-               return;
        if (flash_enable) {
                if (--flash_enable == 0) {
                        diag_printf1("Disabling flash region 0x%08llx..0x%08llx\n",
@@ -427,7 +423,9 @@ nandflash_hwr_init(void)
        NFC_CMD_INPUT(FLASH_Reset);
 
        // Look through table for device data
+       nfc_printf(NFC_DEBUG_MAX, "%s@%d %p\n", __FUNCTION__, __LINE__, &id[0]);
        flash_dev_query(&id[0]);
+       nfc_printf(NFC_DEBUG_MAX, "%s@%d\n", __FUNCTION__, __LINE__);
 
        flash_dev_info = supported_devices;
        for (i = 0; i < NUM_DEVICES; i++) {
@@ -437,6 +435,7 @@ nandflash_hwr_init(void)
                        break;
                flash_dev_info++;
        }
+       nfc_printf(NFC_DEBUG_MAX, "%s@%d\n", __FUNCTION__, __LINE__);
 
        // Did we find the device? If not, return error.
        if (NUM_DEVICES == i) {
@@ -459,10 +458,12 @@ nandflash_hwr_init(void)
        nfc_printf(NFC_DEBUG_MED, "%s(): %d out of NUM_DEVICES=%d, id=0x%02x\n",
                           __FUNCTION__, i, NUM_DEVICES, flash_dev_info->device_id);
 
-       if (nfc_setup)
+       if (nfc_setup) {
+               nfc_printf(NFC_DEBUG_MAX, "%s@%d\n", __FUNCTION__, __LINE__);
                g_nfc_version = nfc_setup(NF_PG_SZ / num_of_nand_chips, flash_dev_info->port_size,
-                                                               flash_dev_info->type, num_of_nand_chips);
-
+                                                                 flash_dev_info->type, num_of_nand_chips);
+       }
+       nfc_printf(NFC_DEBUG_MAX, "%s@%d\n", __FUNCTION__, __LINE__);
        diag_printf1("NFC version: %02x\n", g_nfc_version);
        if (g_nfc_version >= MXC_NFC_V3) {
                for (i = 2; i <= NUM_OF_CS_LINES; i++) {