arm: Remove rd6281a board
[platform/kernel/u-boot.git] / board / scb9328 / flash.c
index 1b56f8c..73bfa00 100644 (file)
@@ -4,26 +4,9 @@
  * This code was inspired by Marius Groeger and Kyle Harris code
  * available in other board ports for U-Boot
  *
- * 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+
  *
  * Written by Peter Figuli <peposh@etc.sk>, 2003.
- *
  */
 
 #include <common.h>
@@ -44,6 +27,7 @@
 
 #if ( SCB9328_FLASH_BUS_WIDTH == 1 )
 #  define FLASH_BUS vu_char
+#  define FLASH_BUS_RET u_char
 #  if ( SCB9328_FLASH_INTERLEAVE == 1 )
 #    define FLASH_CMD( x ) x
 #  else
@@ -53,6 +37,7 @@
 
 #elif ( SCB9328_FLASH_BUS_WIDTH == 2 )
 #  define FLASH_BUS vu_short
+#  define FLASH_BUS_RET u_short
 #  if ( SCB9328_FLASH_INTERLEAVE == 1 )
 #    define FLASH_CMD( x ) x
 #  elif ( SCB9328_FLASH_INTERLEAVE == 2 )
@@ -64,6 +49,7 @@
 
 #elif ( SCB9328_FLASH_BUS_WIDTH == 4 )
 #  define FLASH_BUS vu_long
+#  define FLASH_BUS_RET u_long
 #  if ( SCB9328_FLASH_INTERLEAVE == 1 )
 #    define FLASH_CMD( x ) x
 #  elif ( SCB9328_FLASH_INTERLEAVE == 2 )
 #endif
 
 
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
 
-static FLASH_BUS flash_status_reg (void)
+static FLASH_BUS_RET flash_status_reg (void)
 {
 
        FLASH_BUS *addr = (FLASH_BUS *) 0;
 
+       /* cppcheck-suppress nullPointer */
        *addr = FLASH_CMD (CFI_INTEL_CMD_READ_STATUS_REGISTER);
 
+       /* cppcheck-suppress nullPointer */
        return *addr;
 }
 
 static int flash_ready (ulong timeout)
 {
        int ok = 1;
+       ulong start;
 
-       reset_timer_masked ();
+       start = get_timer(0);
        while ((flash_status_reg () & FLASH_CMD (CFI_INTEL_SR_READY)) !=
                   FLASH_CMD (CFI_INTEL_SR_READY)) {
-               if (get_timer_masked () > timeout && timeout != 0) {
+               if (get_timer(start) > timeout && timeout != 0) {
                        ok = 0;
                        break;
                }
@@ -106,7 +95,7 @@ static int flash_ready (ulong timeout)
        return ok;
 }
 
-#if ( CFG_MAX_FLASH_BANKS != 1 )
+#if ( CONFIG_SYS_MAX_FLASH_BANKS != 1 )
 #  error "SCB9328 platform has only one flash bank!"
 #endif
 
@@ -117,11 +106,11 @@ ulong flash_init (void)
        unsigned long address = SCB9328_FLASH_BASE;
 
        flash_info[0].size = SCB9328_FLASH_BANK_SIZE;
-       flash_info[0].sector_count = CFG_MAX_FLASH_SECT;
+       flash_info[0].sector_count = CONFIG_SYS_MAX_FLASH_SECT;
        flash_info[0].flash_id = INTEL_MANUFACT;
-       memset (flash_info[0].protect, 0, CFG_MAX_FLASH_SECT);
+       memset (flash_info[0].protect, 0, CONFIG_SYS_MAX_FLASH_SECT);
 
-       for (i = 0; i < CFG_MAX_FLASH_SECT; i++) {
+       for (i = 0; i < CONFIG_SYS_MAX_FLASH_SECT; i++) {
                flash_info[0].start[i] = address;
 #ifdef SCB9328_FLASH_UNLOCK
                /* Some devices are hw locked after start. */
@@ -134,13 +123,13 @@ ulong flash_init (void)
        }
 
        flash_protect (FLAG_PROTECT_SET,
-                                  CFG_FLASH_BASE,
-                                  CFG_FLASH_BASE + monitor_flash_len - 1,
+                                  CONFIG_SYS_FLASH_BASE,
+                                  CONFIG_SYS_FLASH_BASE + monitor_flash_len - 1,
                                   &flash_info[0]);
 
        flash_protect (FLAG_PROTECT_SET,
-                                  CFG_ENV_ADDR,
-                                  CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
+                                  CONFIG_ENV_ADDR,
+                                  CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
 
        return SCB9328_FLASH_BANK_SIZE;
 }
@@ -206,7 +195,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 
                *address = FLASH_CMD (CFI_INTEL_CMD_BLOCK_ERASE);
                *address = FLASH_CMD (CFI_INTEL_CMD_CONFIRM);
-               if (flash_ready (CFG_FLASH_ERASE_TOUT)) {
+               if (flash_ready (CONFIG_SYS_FLASH_ERASE_TOUT)) {
                        *address = FLASH_CMD (CFI_INTEL_CMD_CLEAR_STATUS_REGISTER);
                        printf ("ok.\n");
                } else {
@@ -254,7 +243,7 @@ static int write_data (flash_info_t * info, ulong dest, FLASH_BUS data)
        *address = FLASH_CMD (CFI_INTEL_CMD_PROGRAM1);
        *address = data;
 
-       if (!flash_ready (CFG_FLASH_WRITE_TOUT)) {
+       if (!flash_ready (CONFIG_SYS_FLASH_WRITE_TOUT)) {
                *address = FLASH_CMD (CFI_INTEL_CMD_SUSPEND);
                rc = ERR_TIMOUT;
                printf ("timeout! Aborting...\n");