Convert CONFIG_SYS_FLASH_CFI_WIDTH to Kconfig
[platform/kernel/u-boot.git] / drivers / mtd / cfi_flash.c
index 9642d7c..4950410 100644 (file)
@@ -68,13 +68,6 @@ static uint flash_verbose = 1;
 
 flash_info_t flash_info[CFI_MAX_FLASH_BANKS];  /* FLASH chips info */
 
-/*
- * Check if chip width is defined. If not, start detecting with 8bit.
- */
-#ifndef CONFIG_SYS_FLASH_CFI_WIDTH
-#define CONFIG_SYS_FLASH_CFI_WIDTH     FLASH_CFI_8BIT
-#endif
-
 #ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
 #define __maybe_weak __weak
 #else
@@ -96,7 +89,7 @@ static u16 cfi_flash_config_reg(int i)
 }
 
 #if defined(CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
-int cfi_flash_num_flash_banks = CONFIG_SYS_MAX_FLASH_BANKS_DETECT;
+int cfi_flash_num_flash_banks = CFI_MAX_FLASH_BANKS;
 #else
 int cfi_flash_num_flash_banks;
 #endif
@@ -191,7 +184,7 @@ static flash_info_t *flash_get_info(ulong base)
        int i;
        flash_info_t *info;
 
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
+       for (i = 0; i < CFI_FLASH_BANKS; i++) {
                info = &flash_info[i];
                if (info->size && info->start[0] <= base &&
                    base <= info->start[0] + info->size - 1)
@@ -2276,12 +2269,12 @@ ulong flash_get_size(phys_addr_t base, int banknum)
                                        flash_unlock_seq(info, 0);
                                        flash_write_cmd(info, 0,
                                                        info->addr_unlock1,
-                                                       FLASH_CMD_READ_ID);
+                                                       AMD_CMD_SET_PPB_ENTRY);
                                        info->protect[sect_cnt] =
-                                               flash_isset(
-                                                       info, sect_cnt,
-                                                       FLASH_OFFSET_PROTECT,
-                                                       FLASH_STATUS_PROTECT);
+                                               !flash_isset(info, sect_cnt,
+                                                            0, 0x01);
+                                       flash_write_cmd(info, 0, 0,
+                                                       info->cmd_reset);
                                        break;
                                default:
                                        /* default: not protected */
@@ -2419,7 +2412,7 @@ unsigned long flash_init(void)
 #endif
 
        /* Init: no FLASHes known */
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
+       for (i = 0; i < CFI_FLASH_BANKS; ++i) {
                flash_info[i].flash_id = FLASH_UNKNOWN;
 
                /* Optionally write flash configuration register */