]> git.sur5r.net Git - u-boot/blobdiff - board/hymod/flash.c
ARM: mxs: Add Creative ZEN XFi3 board
[u-boot] / board / hymod / flash.c
index 7d1ae30e48c31e4f794055517901e9dde3a7fe91..02e519c695e7b5fc7977c94ac0e59ee8b41a4e8f 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2000
  * 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+
  *
  * Hacked for the Hymod board by Murray.Jensen@csiro.au, 20-Oct-00
  */
@@ -27,7 +11,7 @@
 #include <mpc8260.h>
 #include <board/hymod/flash.h>
 
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS];  /* info for FLASH chips */
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];   /* info for FLASH chips */
 
 /*-----------------------------------------------------------------------
  * Protection Flags:
@@ -43,29 +27,26 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];       /* info for FLASH chips */
  * in the flash_info entry "fip". Fatal error if nothing there.
  */
 static void
-bank_probe (flash_info_t *fip, bank_addr_t base)
+bank_probe (flash_info_t *fip, volatile bank_addr_t base)
 {
-       bank_addr_t addr;
+       volatile bank_addr_t addr;
        bank_word_t word;
        int i;
 
        /* reset the flash */
        *base = BANK_CMD_RST;
 
-       /* check the manufacturer id - must be intel */
+       /* put flash into read id mode */
        *base = BANK_CMD_RD_ID;
-       word = *BANK_REG_MAN_CODE (base);
-       *base = BANK_CMD_RST;
 
+       /* check the manufacturer id - must be intel */
+       word = *BANK_REG_MAN_CODE (base);
        if (word != BANK_FILL_WORD (INTEL_MANUFACT&0xff))
                panic ("\nbad manufacturer's code (0x%08lx) at addr 0x%08lx",
                        (unsigned long)word, (unsigned long)base);
 
        /* check the device id */
-       *base = BANK_CMD_RD_ID;
        word = *BANK_REG_DEV_CODE (base);
-       *base = BANK_CMD_RST;
-
        switch (word) {
 
        case BANK_FILL_WORD (INTEL_ID_28F320J5&0xff):
@@ -98,7 +79,7 @@ bank_probe (flash_info_t *fip, bank_addr_t base)
                        (unsigned long)word, (unsigned long)base);
        }
 
-       if (fip->sector_count >= CFG_MAX_FLASH_SECT)
+       if (fip->sector_count >= CONFIG_SYS_MAX_FLASH_SECT)
                panic ("\ntoo many sectors (%d) in flash at address 0x%08lx",
                        fip->sector_count, (unsigned long)base);
 
@@ -110,12 +91,15 @@ bank_probe (flash_info_t *fip, bank_addr_t base)
        }
 
        fip->size = (bank_size_t)addr - (bank_size_t)base;
+
+       /* reset the flash */
+       *base = BANK_CMD_RST;
 }
 
 static void
 bank_reset (flash_info_t *info, int sect)
 {
-       bank_addr_t addr = (bank_addr_t)info->start[sect];
+       volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
 
 #ifdef FLASH_DEBUG
        printf ("writing reset cmd to addr 0x%08lx\n", (unsigned long)addr);
@@ -127,7 +111,7 @@ bank_reset (flash_info_t *info, int sect)
 static void
 bank_erase_init (flash_info_t *info, int sect)
 {
-       bank_addr_t addr = (bank_addr_t)info->start[sect];
+       volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
        int flag;
 
 #ifdef FLASH_DEBUG
@@ -152,7 +136,7 @@ bank_erase_init (flash_info_t *info, int sect)
 static int
 bank_erase_poll (flash_info_t *info, int sect)
 {
-       bank_addr_t addr = (bank_addr_t)info->start[sect];
+       volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
        bank_word_t stat = *addr;
 
 #ifdef FLASH_DEBUG
@@ -176,7 +160,7 @@ bank_erase_poll (flash_info_t *info, int sect)
 }
 
 static int
-bank_write_word (bank_addr_t addr, bank_word_t value)
+bank_write_word (volatile bank_addr_t addr, bank_word_t value)
 {
        bank_word_t stat;
        ulong start;
@@ -198,7 +182,7 @@ bank_write_word (bank_addr_t addr, bank_word_t value)
        /* data polling for D7 */
        start = get_timer (0);
        do {
-               if (get_timer (start) > CFG_FLASH_WRITE_TOUT) {
+               if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
                        retval = 1;
                        goto done;
                }
@@ -228,30 +212,30 @@ flash_init (void)
        int i;
 
        /* 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;
        }
 
-       bank_probe (&flash_info[0], (bank_addr_t)CFG_FLASH_BASE);
+       bank_probe (&flash_info[0], (bank_addr_t)CONFIG_SYS_FLASH_BASE);
 
        /*
         * protect monitor and environment sectors
         */
 
-#if CFG_MONITOR_BASE == CFG_FLASH_BASE
+#if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
        (void)flash_protect (FLAG_PROTECT_SET,
-                     CFG_MONITOR_BASE,
-                     CFG_MONITOR_BASE+monitor_flash_len-1,
+                     CONFIG_SYS_MONITOR_BASE,
+                     CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
                      &flash_info[0]);
 #endif
 
-#if defined(CFG_FLASH_ENV_ADDR)
+#if defined(CONFIG_SYS_FLASH_ENV_ADDR)
        (void)flash_protect (FLAG_PROTECT_SET,
-                     CFG_FLASH_ENV_ADDR,
-#if defined(CFG_FLASH_ENV_BUF)
-                     CFG_FLASH_ENV_ADDR + CFG_FLASH_ENV_BUF - 1,
+                     CONFIG_SYS_FLASH_ENV_ADDR,
+#if defined(CONFIG_SYS_FLASH_ENV_BUF)
+                     CONFIG_SYS_FLASH_ENV_ADDR + CONFIG_SYS_FLASH_ENV_BUF - 1,
 #else
-                     CFG_FLASH_ENV_ADDR + CFG_FLASH_ENV_SIZE - 1,
+                     CONFIG_SYS_FLASH_ENV_ADDR + CONFIG_SYS_FLASH_ENV_SIZE - 1,
 #endif
                      &flash_info[0]);
 #endif
@@ -368,7 +352,7 @@ flash_erase (flash_info_t *info, int s_first, int s_last)
                        do {
                                now = get_timer (start);
 
-                               if (now - estart > CFG_FLASH_ERASE_TOUT) {
+                               if (now - estart > CONFIG_SYS_FLASH_ERASE_TOUT) {
                                        printf ("Timeout (sect %d)\n", sect);
                                        haderr = 1;
                                        rcode = 1;