]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - board/esd/cpci405/cpci405.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / esd / cpci405 / cpci405.c
index 0aca825c12a13f54fdb2b204554c91feb5921eb0..63cd862d2d2ff6b31dc94042eee924b430cc0c49 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2001-2003
  * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  *
- * 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 <libfdt.h>
@@ -32,7 +16,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 extern void __ft_board_setup(void *blob, bd_t *bd);
 
 #undef FPGA_DEBUG
@@ -89,7 +72,6 @@ int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
 
 /* Prototypes */
 int cpci405_version(void);
-int gunzip(void *, int, unsigned char *, unsigned long *);
 void lxt971_no_sleep(void);
 
 int board_early_init_f(void)
@@ -111,10 +93,10 @@ int board_early_init_f(void)
         * First pull fpga-prg pin low,
         * to disable fpga logic (on version 2 board)
         */
-       out32(GPIO0_ODR, 0x00000000);        /* no open drain pins      */
-       out32(GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output      */
-       out32(GPIO0_OR, CONFIG_SYS_FPGA_PRG); /* set output pins to high */
-       out32(GPIO0_OR, 0);                  /* pull prg low            */
+       out_be32((void *)GPIO0_ODR, 0x00000000);             /* no open drain pins      */
+       out_be32((void *)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output   */
+       out_be32((void *)GPIO0_OR, CONFIG_SYS_FPGA_PRG); /* set output pins to high */
+       out_be32((void *)GPIO0_OR, 0);               /* pull prg low            */
 
        /*
         * Boot onboard FPGA
@@ -179,22 +161,22 @@ int board_early_init_f(void)
         * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
         * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
         */
-       mtdcr(uicsr, 0xFFFFFFFF);       /* clear all ints */
-       mtdcr(uicer, 0x00000000);       /* disable all ints */
-       mtdcr(uiccr, 0x00000000);       /* set all to be non-critical*/
+       mtdcr(UIC0SR, 0xFFFFFFFF);      /* clear all ints */
+       mtdcr(UIC0ER, 0x00000000);      /* disable all ints */
+       mtdcr(UIC0CR, 0x00000000);      /* set all to be non-critical*/
 #if defined(CONFIG_CPCI405_6U)
        if (cpci405_version() == 3) {
-               mtdcr(uicpr, 0xFFFFFF99);       /* set int polarities */
+               mtdcr(UIC0PR, 0xFFFFFF99);      /* set int polarities */
        } else {
-               mtdcr(uicpr, 0xFFFFFF81);       /* set int polarities */
+               mtdcr(UIC0PR, 0xFFFFFF81);      /* set int polarities */
        }
 #else
-       mtdcr(uicpr, 0xFFFFFF81);       /* set int polarities */
+       mtdcr(UIC0PR, 0xFFFFFF81);      /* set int polarities */
 #endif
-       mtdcr(uictr, 0x10000000);       /* set int trigger levels */
-       mtdcr(uicvcr, 0x00000001);      /* set vect base=0,
+       mtdcr(UIC0TR, 0x10000000);      /* set int trigger levels */
+       mtdcr(UIC0VCR, 0x00000001);     /* set vect base=0,
                                         * INT0 highest priority */
-       mtdcr(uicsr, 0xFFFFFFFF);       /* clear all ints */
+       mtdcr(UIC0SR, 0xFFFFFFFF);      /* clear all ints */
 
        return 0;
 }
@@ -214,7 +196,7 @@ int ctermm2(void)
 
 int cpci405_host(void)
 {
-       if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
+       if (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN)
                return -1;              /* yes, board is cpci405 host */
        else
                return 0;               /* no, board is cpci405 adapter */
@@ -222,14 +204,14 @@ int cpci405_host(void)
 
 int cpci405_version(void)
 {
-       unsigned long cntrl0Reg;
+       unsigned long CPC0_CR0Reg;
        unsigned long value;
 
        /*
         * Setup GPIO pins (CS2/GPIO11 and CS3/GPIO12 as GPIO)
         */
-       cntrl0Reg = mfdcr(cntrl0);
-       mtdcr(cntrl0, cntrl0Reg | 0x03000000);
+       CPC0_CR0Reg = mfdcr(CPC0_CR0);
+       mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03000000);
        out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x00180000);
        out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x00180000);
        udelay(1000); /* wait some time before reading input */
@@ -238,7 +220,7 @@ int cpci405_version(void)
        /*
         * Restore GPIO settings
         */
-       mtdcr(cntrl0, cntrl0Reg);
+       mtdcr(CPC0_CR0, CPC0_CR0Reg);
 
        switch (value) {
        case 0x00180000:
@@ -261,7 +243,7 @@ int cpci405_version(void)
 
 int misc_init_r (void)
 {
-       unsigned long cntrl0Reg;
+       unsigned long CPC0_CR0Reg;
 
        /* adjust flash start and offset */
        gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
@@ -283,8 +265,8 @@ int misc_init_r (void)
                /*
                 * Setup GPIO pins (CS6+CS7 as GPIO)
                 */
-               cntrl0Reg = mfdcr(cntrl0);
-               mtdcr(cntrl0, cntrl0Reg | 0x00300000);
+               CPC0_CR0Reg = mfdcr(CPC0_CR0);
+               mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000);
 
                dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
                if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE,
@@ -330,7 +312,7 @@ int misc_init_r (void)
                }
 
                /* restore gpio/cs settings */
-               mtdcr(cntrl0, cntrl0Reg);
+               mtdcr(CPC0_CR0, CPC0_CR0Reg);
 
                puts("FPGA:  ");
 
@@ -400,8 +382,8 @@ int misc_init_r (void)
        /*
         * Select cts (and not dsr) on uart1
         */
-       cntrl0Reg = mfdcr(cntrl0);
-       mtdcr(cntrl0, cntrl0Reg | 0x00001000);
+       CPC0_CR0Reg = mfdcr(CPC0_CR0);
+       mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00001000);
 
        return 0;
 }
@@ -417,7 +399,7 @@ int checkboard(void)
        int len;
 #endif
        char str[64];
-       int i = getenv_r("serial#", str, sizeof(str));
+       int i = getenv_f("serial#", str, sizeof(str));
        unsigned short ver;
 
        puts("Board: ");
@@ -651,14 +633,13 @@ int OWReadByte(void)
        return result;
 }
 
-int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        unsigned short val;
        int result;
        int i;
        unsigned char ow_id[6];
        char str[32];
-       unsigned char ow_crc;
 
        /*
         * Clear 1-wire bit (open drain with pull-up)
@@ -677,11 +658,10 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        OWReadByte(); /* skip family code ( == 0x01) */
        for (i = 0; i < 6; i++)
                ow_id[i] = OWReadByte();
-       ow_crc = OWReadByte(); /* read crc */
+       OWReadByte(); /* read crc */
 
-       sprintf(str, "%08X%04X",
-               *(unsigned int *)&ow_id[0],
-               *(unsigned short *)&ow_id[4]);
+       sprintf(str, "%02X%02X%02X%02X%02X%02X",
+               ow_id[0], ow_id[1], ow_id[2], ow_id[3], ow_id[4], ow_id[5]);
        printf("Setting environment variable 'ow_id' to %s\n", str);
        setenv("ow_id", str);
 
@@ -690,8 +670,8 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
        onewire,        1,      1,      do_onewire,
        "Read 1-write ID",
-       NULL
-       );
+       ""
+);
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR_2 0x51 /* EEPROM CAT24WC32 */
 #define CONFIG_ENV_SIZE_2 0x800 /* 2048 bytes may be used for env vars */
@@ -699,9 +679,8 @@ U_BOOT_CMD(
 /*
  * Write backplane ip-address...
  */
-int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       bd_t *bd = gd->bd;
        char *buf;
        ulong crc;
        char str[32];
@@ -734,12 +713,7 @@ int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                /*
                 * Update whole ip-addr
                 */
-               bd->bi_ip_addr = ipaddr;
-               sprintf(str, "%ld.%ld.%ld.%ld",
-                       (bd->bi_ip_addr & 0xff000000) >> 24,
-                       (bd->bi_ip_addr & 0x00ff0000) >> 16,
-                       (bd->bi_ip_addr & 0x0000ff00) >> 8,
-                       (bd->bi_ip_addr & 0x000000ff));
+               sprintf(str, "%pI4", &ipaddr);
                setenv("ipaddr", str);
                printf("Updated ip_addr from bp_eeprom to %s!\n", str);
        }
@@ -751,13 +725,13 @@ int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
        getbpip,        1,      1,      do_get_bpip,
        "Update IP-Address with Backplane IP-Address",
-       NULL
-       );
+       ""
+);
 
 /*
  * Set and print backplane ip...
  */
-int do_set_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_set_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        char *buf;
        char str[32];
@@ -787,7 +761,7 @@ int do_set_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
        setbpip,        2,      1,      do_set_bpip,
        "Write Backplane IP-Address",
-       NULL
-       );
+       ""
+);
 
 #endif /* CONFIG_CPCI405AB */