Merge branch 'master' of git://www.denx.de/git/u-boot-cfi-flash
[platform/kernel/u-boot.git] / board / eltec / elppc / misc.c
index 1505660..d80eaba 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2002 ELTEC Elektronik AG
  * Frank Gottschling <fgottschling@eltec.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+
  */
 
 /* includes */
@@ -29,7 +13,6 @@
 #include "srom.h"
 
 /* imports  */
-extern char console_buffer[CFG_CBSIZE];
 extern int l2_cache_enable (int l2control);
 extern int eepro100_write_eeprom (struct eth_device *dev, int location,
                                  int addr_len, unsigned short data);
@@ -42,7 +25,7 @@ extern int read_eeprom (struct eth_device *dev, int location, int addr_len);
 void *nvram_read (void *dest, const long src, size_t count)
 {
        uchar *d = (uchar *) dest;
-       uchar *s = (uchar *) (CFG_ENV_MAP_ADRS + src);
+       uchar *s = (uchar *) (CONFIG_ENV_MAP_ADRS + src);
 
        while (count--)
                *d++ = *s++;
@@ -52,7 +35,7 @@ void *nvram_read (void *dest, const long src, size_t count)
 
 void nvram_write (long dest, const void *src, size_t count)
 {
-       uchar *d = (uchar *) (CFG_ENV_MAP_ADRS + dest);
+       uchar *d = (uchar *) (CONFIG_ENV_MAP_ADRS + dest);
        uchar *s = (uchar *) src;
 
        while (count--)
@@ -95,7 +78,7 @@ int misc_init_r (void)
                          SECOND_DEVICE, FIRST_BLOCK);
 
        /* read out current nvram shadow image */
-       nvram_read (buf, CFG_NV_SROM_COPY_ADDR, CFG_SROM_SIZE);
+       nvram_read (buf, CONFIG_SYS_NV_SROM_COPY_ADDR, CONFIG_SYS_SROM_SIZE);
 
        if (strcmp (eerev.magic, "ELTEC") != 0) {
                /* srom is not initialized -> create a default revision info */
@@ -117,15 +100,15 @@ int misc_init_r (void)
                eerev.etheraddr[5] = 0x4D;
 
                /* cache config word for ELPPC */
-               *(int *) &eerev.res[0] = 0;
+               memset(&eerev.res[0], 0, 4);
 
                initSrom = 1;   /* force dialog */
                copyNv = 1;     /* copy to nvram */
        }
 
        if ((copyNv == 0)
-           && (el_srom_checksum ((u_char *) & eerev, CFG_SROM_SIZE) !=
-               el_srom_checksum ((u_char *) buf, CFG_SROM_SIZE))) {
+           && (el_srom_checksum ((u_char *) & eerev, CONFIG_SYS_SROM_SIZE) !=
+               el_srom_checksum ((u_char *) buf, CONFIG_SYS_SROM_SIZE))) {
                printf ("Invalid revision info copy in nvram !\n");
                printf ("Press key:\n  <c> to copy current revision info to nvram.\n");
                printf ("  <r> to reenter revision info.\n");
@@ -208,9 +191,14 @@ int misc_init_r (void)
                buf[4] = eerev.etheraddr[5];
                buf[5] = eerev.etheraddr[4];
 
-               *(unsigned short *) &buf[20] = 0x48B2;
-               *(unsigned short *) &buf[22] = 0x0004;
-               *(unsigned short *) &buf[24] = 0x1433;
+               buf[20] = 0x48;
+               buf[21] = 0xB2;
+
+               buf[22] = 0x00;
+               buf[23] = 0x04;
+
+               buf[24] = 0x14;
+               buf[25] = 0x33;
 
                printf ("\nSRom:  Writing i82559 info ........ ");
                if (eepro100_srom_store ((unsigned short *) buf) == -1)
@@ -232,16 +220,16 @@ int misc_init_r (void)
                        printf ("OK\n\n");
 
                /* write new values as shadow image to nvram */
-               nvram_write (CFG_NV_SROM_COPY_ADDR, (void *) &eerev,
-                            CFG_SROM_SIZE);
+               nvram_write (CONFIG_SYS_NV_SROM_COPY_ADDR, (void *) &eerev,
+                            CONFIG_SYS_SROM_SIZE);
 
        }
 
        /*if (initSrom) */
        /* copy current values as shadow image to nvram */
        if (initSrom == 0 && copyNv == 1)
-               nvram_write (CFG_NV_SROM_COPY_ADDR, (void *) &eerev,
-                            CFG_SROM_SIZE);
+               nvram_write (CONFIG_SYS_NV_SROM_COPY_ADDR, (void *) &eerev,
+                            CONFIG_SYS_SROM_SIZE);
 
        /* update environment */
        sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x",
@@ -250,10 +238,6 @@ int misc_init_r (void)
                 eerev.etheraddr[4], eerev.etheraddr[5]);
        setenv ("ethaddr", buf);
 
-       /* set serial console as default */
-       if ((ptr = getenv ("console")) == NULL)
-               setenv ("console", "serial");
-
        /* print actual board identification */
        printf ("Ident: %s  Ser %s  Rev %c%c\n",
                eerev.board, (char *) &eerev.serial,