bank = dectoul(str, &ep);
if (ep == str || *ep != '\0' ||
- bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS)
+ bank < 1 || bank > CFI_FLASH_BANKS)
return -1;
fp = &flash_info[bank - 1];
/* find the end addr of the sector where the *addr is */
found = 0;
- for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS && !found; ++bank) {
+ for (bank = 0; bank < CFI_FLASH_BANKS && !found; ++bank) {
info = &flash_info[bank];
for (i = 0; i < info->sector_count && !found; ++i) {
/* get the end address of the sector */
*s_count = 0;
- for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
+ for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) {
s_first[bank] = -1; /* first sector to erase */
s_last[bank] = -1; /* last sector to erase */
}
for (bank = 0, info = &flash_info[0];
- (bank < CONFIG_SYS_MAX_FLASH_BANKS) && (addr_first <= addr_last);
+ (bank < CFI_FLASH_BANKS) && (addr_first <= addr_last);
++bank, ++info) {
ulong b_end;
int sect;
#ifdef CONFIG_MTD_NOR_FLASH
if (argc == 1) { /* print info for all FLASH banks */
- for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
+ for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) {
printf("\nBank # %ld: ", bank + 1);
flash_print_info(&flash_info[bank]);
}
bank = hextoul(argv[1], NULL);
- if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) {
+ if (bank < 1 || bank > CFI_FLASH_BANKS) {
printf("Only FLASH Banks # 1 ... # %d supported\n",
- CONFIG_SYS_MAX_FLASH_BANKS);
+ CFI_FLASH_BANKS);
return 1;
}
printf("\nBank # %ld: ", bank);
return CMD_RET_USAGE;
if (strcmp(argv[1], "all") == 0) {
- for (bank = 1; bank <= CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
+ for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) {
printf("Erase Flash Bank # %ld ", bank);
info = &flash_info[bank - 1];
rcode = flash_erase(info, 0, info->sector_count - 1);
if (strcmp(argv[1], "bank") == 0) {
bank = hextoul(argv[2], NULL);
- if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) {
+ if (bank < 1 || bank > CFI_FLASH_BANKS) {
printf("Only FLASH Banks # 1 ... # %d supported\n",
- CONFIG_SYS_MAX_FLASH_BANKS);
+ CFI_FLASH_BANKS);
return 1;
}
printf("Erase Flash Bank # %ld ", bank);
{
flash_info_t *info;
ulong bank;
- int s_first[CONFIG_SYS_MAX_FLASH_BANKS], s_last[CONFIG_SYS_MAX_FLASH_BANKS];
+ int s_first[CFI_FLASH_BANKS], s_last[CFI_FLASH_BANKS];
int erased = 0;
int planned;
int rcode = 0;
if (planned && rcode == 0) {
for (bank = 0, info = &flash_info[0];
- bank < CONFIG_SYS_MAX_FLASH_BANKS && rcode == 0;
+ bank < CFI_FLASH_BANKS && rcode == 0;
++bank, ++info) {
if (s_first[bank] >= 0) {
erased += s_last[bank] - s_first[bank] + 1;
#ifdef CONFIG_MTD_NOR_FLASH
if (strcmp(argv[2], "all") == 0) {
- for (bank = 1; bank <= CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
+ for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) {
info = &flash_info[bank - 1];
if (info->flash_id == FLASH_UNKNOWN)
continue;
if (strcmp(argv[2], "bank") == 0) {
bank = hextoul(argv[3], NULL);
- if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) {
+ if (bank < 1 || bank > CFI_FLASH_BANKS) {
printf("Only FLASH Banks # 1 ... # %d supported\n",
- CONFIG_SYS_MAX_FLASH_BANKS);
+ CFI_FLASH_BANKS);
return 1;
}
printf("%sProtect Flash Bank # %ld\n",
{
flash_info_t *info;
ulong bank;
- int s_first[CONFIG_SYS_MAX_FLASH_BANKS], s_last[CONFIG_SYS_MAX_FLASH_BANKS];
+ int s_first[CFI_FLASH_BANKS], s_last[CFI_FLASH_BANKS];
int protected, i;
int planned;
int rcode;
if (planned && rcode == 0) {
for (bank = 0, info = &flash_info[0];
- bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank, ++info) {
+ bank < CFI_FLASH_BANKS; ++bank, ++info) {
if (info->flash_id == FLASH_UNKNOWN)
continue;
/*
* CFI_MAX_FLASH_BANKS only used for flash_info struct declaration.
*
- * Use CONFIG_SYS_MAX_FLASH_BANKS_DETECT if defined
+ * CFI_FLASH_BANKS selects the correct number of available banks =
+ * cfi_flash_num_flash_banks when CONFIG_SYS_MAX_FLASH_BANKS_DETECT is defined
+ * or CONFIG_SYS_MAX_FLASH_BANKS
*/
#if defined(CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
#define CFI_MAX_FLASH_BANKS CONFIG_SYS_MAX_FLASH_BANKS_DETECT
/* map to cfi_flash_num_flash_banks only when supported */
#if IS_ENABLED(CONFIG_FLASH_CFI_DRIVER) && \
(!IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_SPL_MTD_SUPPORT))
-#define CONFIG_SYS_MAX_FLASH_BANKS (cfi_flash_num_flash_banks)
+#define CFI_FLASH_BANKS (cfi_flash_num_flash_banks)
/* board code can update this variable before CFI detection */
extern int cfi_flash_num_flash_banks;
#else
-#define CONFIG_SYS_MAX_FLASH_BANKS CONFIG_SYS_MAX_FLASH_BANKS_DETECT
+#define CFI_FLASH_BANKS CONFIG_SYS_MAX_FLASH_BANKS_DETECT
#endif
#else
#define CFI_MAX_FLASH_BANKS CONFIG_SYS_MAX_FLASH_BANKS
+#define CFI_FLASH_BANKS CONFIG_SYS_MAX_FLASH_BANKS
#endif
phys_addr_t cfi_flash_bank_addr(int i);