]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - tools/updater/flash_hw.c
arm: mx5: Add fuse supply enable in fsl_iim
[karo-tx-uboot.git] / tools / updater / flash_hw.c
index 62d1083c4686eecf4e57c748c4613f0e27ab00b8..54a910b1780121d51060669d571c002ede543d66 100644 (file)
@@ -5,23 +5,7 @@
  * (C) Copyright 2002
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -39,7 +23,7 @@
 #endif
 /*---------------------------------------------------------------------*/
 
-flash_info_t   flash_info[CFG_MAX_FLASH_BANKS];
+flash_info_t   flash_info[];
 
 static ulong flash_get_size (ulong addr, flash_info_t *info);
 static int flash_get_offsets (ulong base, flash_info_t *info);
@@ -80,7 +64,7 @@ unsigned long flash_init_old(void)
 {
     int i;
 
-    for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
+    for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++)
     {
        flash_info[i].flash_id = FLASH_UNKNOWN;
        flash_info[i].sector_count = 0;
@@ -101,33 +85,33 @@ unsigned long flash_init (void)
        flash_to_xd();
 
        /* Init: no FLASHes known */
-       for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+       for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
                flash_info[i].flash_id = FLASH_UNKNOWN;
                flash_info[i].sector_count = 0;
                flash_info[i].size = 0;
        }
 
-       DEBUGF("\n## Get flash size @ 0x%08x\n", CFG_FLASH_BASE);
+       DEBUGF("\n## Get flash size @ 0x%08x\n", CONFIG_SYS_FLASH_BASE);
 
-       flash_size = flash_get_size (CFG_FLASH_BASE, flash_info);
+       flash_size = flash_get_size (CONFIG_SYS_FLASH_BASE, flash_info);
 
        DEBUGF("## Flash bank size: %08lx\n", flash_size);
 
        if (flash_size) {
-#if CFG_MONITOR_BASE >= CFG_FLASH_BASE && \
-    CFG_MONITOR_BASE < CFG_FLASH_BASE + CFG_FLASH_MAX_SIZE
+#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE && \
+    CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE + CONFIG_SYS_FLASH_MAX_SIZE
                /* monitor protection ON by default */
                flash_protect(FLAG_PROTECT_SET,
-                             CFG_MONITOR_BASE,
-                             CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+                             CONFIG_SYS_MONITOR_BASE,
+                             CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1,
                              &flash_info[0]);
 #endif
 
-#ifdef CFG_ENV_IS_IN_FLASH
+#ifdef CONFIG_ENV_IS_IN_FLASH
                /* ENV protection ON by default */
                flash_protect(FLAG_PROTECT_SET,
-                             CFG_ENV_ADDR,
-                             CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
+                             CONFIG_ENV_ADDR,
+                             CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
                              &flash_info[0]);
 #endif
 
@@ -153,14 +137,14 @@ static ulong flash_get_size (ulong addr, flash_info_t *info)
 
        /* Write auto select command: read Manufacturer ID */
        x[0x0555] =  0xAA;
-       __asm volatile ("sync\n eieio");
+       __asm__ volatile ("sync\n eieio");
        x[0x02AA] =  0x55;
-       __asm volatile ("sync\n eieio");
+       __asm__ volatile ("sync\n eieio");
        x[0x0555] =  0x90;
-       __asm volatile ("sync\n eieio");
+       __asm__ volatile ("sync\n eieio");
 
        value = x[0];
-       __asm volatile ("sync\n eieio");
+       __asm__ volatile ("sync\n eieio");
 
        DEBUGF("Manuf. ID @ 0x%08lx: 0x%08x\n", (ulong)addr, value);
 
@@ -186,7 +170,7 @@ static ulong flash_get_size (ulong addr, flash_info_t *info)
        }
 
        value = x[1];
-       __asm volatile ("sync\n eieio");
+       __asm__ volatile ("sync\n eieio");
 
        DEBUGF("Device ID @ 0x%08lx: 0x%08x\n", addr+1, value);
 
@@ -286,10 +270,10 @@ static ulong flash_get_size (ulong addr, flash_info_t *info)
 
        }
 
-       if (info->sector_count > CFG_MAX_FLASH_SECT) {
+       if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
                printf ("** ERROR: sector count %d > max (%d) **\n",
-                       info->sector_count, CFG_MAX_FLASH_SECT);
-               info->sector_count = CFG_MAX_FLASH_SECT;
+                       info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
+               info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
        }
 
        if (! flash_get_offsets (addr, info)) {
@@ -418,10 +402,10 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
        last  = start;
        addr = info->start[l_sect];
 
-       DEBUGF ("Start erase timeout: %d\n", CFG_FLASH_ERASE_TOUT);
+       DEBUGF ("Start erase timeout: %d\n", CONFIG_SYS_FLASH_ERASE_TOUT);
 
        while ((in8(addr) & 0x80) != 0x80) {
-               if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+               if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                        printf ("Timeout\n");
                        flash_reset (info->start[0]);
                        flash_to_mem();
@@ -570,7 +554,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
                /* data polling for D7 */
                start = get_timer (0);
                while ((in8(dest+i) & 0x80) != (data_ch[i] & 0x80)) {
-                       if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+                       if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
                                flash_reset (addr);
                                flash_to_mem();
                                return (1);