Merge branch 'master' of git://git.denx.de/u-boot-samsung
[platform/kernel/u-boot.git] / board / mpl / common / common_util.c
index a61a98c..31636b3 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2001
  * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
  *
- * 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>
 #include <pci.h>
 #include <malloc.h>
 #include <bzlib.h>
+#include <video.h>
 
 #ifdef CONFIG_PIP405
 #include "../pip405/pip405.h"
 #include <asm/4xx_pci.h>
 #endif
-#ifdef CONFIG_MIP405
+#if defined(CONFIG_TARGET_MIP405) || defined(CONFIG_TARGET_MIP405T)
 #include "../mip405/mip405.h"
 #include <asm/4xx_pci.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_PATI)
-#define FIRM_START 0xFFF00000
-#endif
-
 extern int mem_test(ulong start, ulong ramsize, int quiet);
 
 #define I2C_BACKUP_ADDR 0x7C00         /* 0x200 bytes for backup */
 #define IMAGE_SIZE CONFIG_SYS_MONITOR_LEN      /* ugly, but it works for now */
 
-#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
+#if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) \
+       || defined(CONFIG_TARGET_MIP405T)
 /*-----------------------------------------------------------------------
  * On PIP/MIP405 we have 3 (4) possible boot mode
  *
@@ -133,7 +114,7 @@ void setup_cs_reloc(void)
                mtdcr(EBC0_CFGDATA, FLASH_CR_B);
        }
 }
-#endif /* #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) */
+#endif /* #if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) */
 
 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
 /* adjust flash start and protection info */
@@ -204,15 +185,11 @@ mpl_prg(uchar *src, ulong size)
        ulong start;
        flash_info_t *info = &flash_info[0];
        int i, rc;
-#if defined(CONFIG_PATI)
-       int start_sect;
-#endif
-#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
+#if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) || \
+       defined(CONFIG_TARGET_MIP405T)
        char *copystr = (char *)src;
        ulong *magic = (ulong *)src;
-#endif
 
-#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
        if (uimage_to_cpu (magic[0]) != IH_MAGIC) {
                puts("Bad Magic number\n");
                return -1;
@@ -235,7 +212,6 @@ mpl_prg(uchar *src, ulong size)
                printf("Wrong Firmware Image: %s\n", &copystr[i]);
                return -1;
        }
-#if !defined(CONFIG_PATI)
        start = 0 - size;
 
        /* unprotect sectors used by u-boot */
@@ -257,61 +233,6 @@ mpl_prg(uchar *src, ulong size)
                flash_perror(rc);
                return (1);
        }
-
-#else /* #if !defined(CONFIG_PATI */
-       start = FIRM_START;
-       start_sect = -1;
-
-       /* search start sector */
-       for (i = info->sector_count-1; i > 0; i--)
-               if (start >= info->start[i])
-                       break;
-
-       start_sect = i;
-
-       for (i = info->sector_count-1; i > 0; i--)
-               if ((start + size) >= info->start[i])
-                       break;
-
-       /* unprotect sectors used by u-boot */
-       flash_protect(FLAG_PROTECT_CLEAR,
-                     start,
-                     start + size,
-                     info);
-
-       /* now erase flash */
-       printf ("Erasing at %lx to %lx (sector %d to %d) (%lx to %lx)\n",
-               start, start + size, start_sect, i,
-               info->start[start_sect], info->start[i]);
-       if ((rc = flash_erase (info, start_sect, i)) != 0) {
-               puts ("ERROR ");
-               flash_perror (rc);
-               return (1);
-       }
-#endif /* defined(CONFIG_PATI) */
-
-#elif defined(CONFIG_VCMA9)
-       start = 0;
-
-       /* search end sector */
-       for (i = 0; i < info->sector_count; i++)
-               if (size < info->start[i])
-                   break;
-
-       flash_protect(FLAG_PROTECT_CLEAR,
-                     start,
-                     size,
-                     info);
-
-       /* now erase flash */
-       printf("Erasing at %lx (sector %d) (start %lx)\n",
-                               start,0,info->start[0]);
-       if ((rc = flash_erase (info, 0, i)) != 0) {
-               puts("ERROR ");
-               flash_perror(rc);
-               return (1);
-       }
-
 #endif
        printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",
                (ulong)src, size);
@@ -419,7 +340,6 @@ mpl_prg_image(uchar *ld_addr)
        return(rc);
 }
 
-#if !defined(CONFIG_PATI)
 void get_backup_values(backup_t *buf)
 {
        i2c_read(CONFIG_SYS_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t));
@@ -580,17 +500,13 @@ void check_env(void)
        }
 }
 
-#endif /* #if !defined(CONFIG_PATI) */
-
 int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong ld_addr;
        int result;
-#if !defined(CONFIG_PATI)
        ulong size = IMAGE_SIZE;
        ulong src = MULTI_PURPOSE_SOCKET_ADDR;
        backup_t back;
-#endif
 
        if (strcmp(argv[1], "flash") == 0)
        {
@@ -626,15 +542,12 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        result=mpl_prg_image((uchar *)ld_addr);
                        return result;
                }
-#if !defined(CONFIG_PATI)
                if (strcmp(argv[2], "mps") == 0) {
                        puts("\nupdating bootloader image from MPS\n");
                        result=mpl_prg((uchar *)src,size);
                        return result;
                }
-#endif /* #if !defined(CONFIG_PATI)    */
        }
-#if !defined(CONFIG_PATI)
        if (strcmp(argv[1], "clearenvvalues") == 0)
        {
                if (strcmp(argv[2], "yes") == 0)
@@ -657,19 +570,9 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                set_backup_values(1);
                return 0;
        }
-#endif
        return cmd_usage(cmdtp);
 }
 
-
-#if defined(CONFIG_CMD_DOC)
-void doc_init (void)
-{
-  doc_probe(MULTI_PURPOSE_SOCKET_ADDR);
-}
-#endif
-
-
 #ifdef CONFIG_VIDEO
 /******************************************************
  * Routines to display the Board information
@@ -715,12 +618,12 @@ void video_get_info_str (int line_number, char *info)
                s=getenv ("serial#");
 #ifdef CONFIG_PIP405
                if (!s || strncmp (s, "PIP405", 6)) {
-                       sprintf(buf,"### No HW ID - assuming PIP405");
+                       strcpy(buf,"### No HW ID - assuming PIP405");
                }
 #endif
-#ifdef CONFIG_MIP405
+#if defined(CONFIG_TARGET_MIP405) || defined(CONFIG_TARGET_MIP405T)
                if (!s || strncmp (s, "MIP405", 6)) {
-                       sprintf(buf,"### No HW ID - assuming MIP405");
+                       strcpy(buf,"### No HW ID - assuming MIP405");
                }
 #endif
                else {
@@ -735,7 +638,7 @@ void video_get_info_str (int line_number, char *info)
                                }
                                buf[i++] = *s;
                        }
-                       sprintf(&buf[i]," SN ");
+                       strcpy(&buf[i]," SN ");
                        i+=4;
                        for (; s < e; ++s) {
                                buf[i++] = *s;
@@ -761,7 +664,7 @@ void video_get_info_str (int line_number, char *info)
                        ctfb.modeIdent);
                return;
        case 1:
-               sprintf (buf, "%s",CONFIG_IDENT_STRING);
+               strcpy(buf, CONFIG_IDENT_STRING);
                sprintf (info, " %s", &buf[1]);
                return;
     }