]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_tsi148.c
karo: tx51: remove duplicate CONFIG_SYS_SDRAM_CLK definition
[karo-tx-uboot.git] / common / cmd_tsi148.c
index 222938ce804924d529a2e7d809e4fec5612d79c9..317ba50fd19503c3ef473b742f2b2ad3a7483aa8 100644 (file)
@@ -5,27 +5,9 @@
  *
  * (C) Copyright 2003 Stefan Roese, 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+ 
  */
 
-#define DEBUG
-
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
 typedef struct _TSI148_DEV TSI148_DEV;
 
 struct _TSI148_DEV {
-       int            bus;
-       pci_dev_t      busdevfn;
-       TSI148        *uregs;
-       unsigned int   pci_bs;
+       int           bus;
+       pci_dev_t     busdevfn;
+       TSI148       *uregs;
+       unsigned int  pci_bs;
 };
 
 static TSI148_DEV *dev;
@@ -55,7 +37,7 @@ static TSI148_DEV *dev;
 
 int tsi148_init(void)
 {
-       int j, result, lastError = 0;
+       int j, result;
        pci_dev_t busdevfn;
        unsigned int val;
 
@@ -71,8 +53,7 @@ int tsi148_init(void)
        dev = malloc(sizeof(*dev));
        if (NULL == dev) {
                puts("Tsi148: No memory!\n");
-               result = -1;
-               goto break_20;
+               return -1;
        }
 
        memset(dev, 0, sizeof(*dev));
@@ -84,11 +65,12 @@ int tsi148_init(void)
 
        debug("Tsi148: Base    : %p\n", dev->uregs);
 
-       /* check mapping  */
-       debug("Tsi148: Read via mapping, PCI_ID = %08X\n", readl(&dev->uregs->pci_id));
-       if (((PCI_DEVICE << 16) | PCI_VENDOR) !=  readl(&dev->uregs->pci_id)) {
+       /* check mapping */
+       debug("Tsi148: Read via mapping, PCI_ID = %08X\n",
+             readl(&dev->uregs->pci_id));
+       if (((PCI_DEVICE << 16) | PCI_VENDOR) != readl(&dev->uregs->pci_id)) {
                printf("Tsi148: Cannot read PCI-ID via Mapping: %08x\n",
-                       readl(&dev->uregs->pci_id));
+                      readl(&dev->uregs->pci_id));
                result = -1;
                goto break_30;
        }
@@ -106,10 +88,12 @@ int tsi148_init(void)
        /* Tsi148 VME timeout etc */
        __raw_writel(htonl(0x00000084), &dev->uregs->vctrl);
 
+#ifdef DEBUG
        if ((__raw_readl(&dev->uregs->vstat) & 0x00000100) != 0)
-               debug("Tsi148: System Controller!\n");
+               printf("Tsi148: System Controller!\n");
        else
-               debug("Tsi148: Not System Controller!\n");
+               printf("Tsi148: Not System Controller!\n");
+#endif
 
        /*
         * Lets turn off interrupts
@@ -126,7 +110,7 @@ int tsi148_init(void)
        __raw_writel(htonl(0x00000000), &dev->uregs->intm2);
        eieio();
 
-       val  = __raw_readl(&dev->uregs->vstat);
+       val = __raw_readl(&dev->uregs->vstat);
        val &= ~(0x00004000);
        __raw_writel(val, &dev->uregs->vstat);
        eieio();
@@ -138,8 +122,6 @@ int tsi148_init(void)
  break_30:
        free(dev);
        dev = NULL;
- break_20:
-       lastError = result;
 
        return result;
 }
@@ -147,7 +129,8 @@ int tsi148_init(void)
 /*
  * Create pci slave window (access: pci -> vme)
  */
-int tsi148_pci_slave_window(unsigned int pciAddr, unsigned int vmeAddr, int size, int vam, int vdw)
+int tsi148_pci_slave_window(unsigned int pciAddr, unsigned int vmeAddr,
+                           int size, int vam, int vdw)
 {
        int result, i;
        unsigned int ctl = 0;
@@ -172,13 +155,12 @@ int tsi148_pci_slave_window(unsigned int pciAddr, unsigned int vmeAddr, int size
 
        printf("Tsi148: Pci addr %08x\n", pciAddr);
 
-
-       __raw_writel(htonl(pciAddr) , &dev->uregs->outbound[i].otsal);
-       __raw_writel(0x00000000 , &dev->uregs->outbound[i].otsau);
+       __raw_writel(htonl(pciAddr), &dev->uregs->outbound[i].otsal);
+       __raw_writel(0x00000000, &dev->uregs->outbound[i].otsau);
        __raw_writel(htonl(pciAddr + size), &dev->uregs->outbound[i].oteal);
-       __raw_writel(0x00000000 , &dev->uregs->outbound[i].oteau);
+       __raw_writel(0x00000000, &dev->uregs->outbound[i].oteau);
        __raw_writel(htonl(vmeAddr - pciAddr), &dev->uregs->outbound[i].otofl);
-       __raw_writel(0x00000000 , &dev->uregs->outbound[i].otofu);
+       __raw_writel(0x00000000, &dev->uregs->outbound[i].otofu);
 
        switch (vam & VME_AM_Axx) {
        case VME_AM_A16:
@@ -213,7 +195,7 @@ int tsi148_pci_slave_window(unsigned int pciAddr, unsigned int vmeAddr, int size
                break;
        }
 
-       ctl |= 0x80040000;    /* enable, no prefetch */
+       ctl |= 0x80040000;      /* enable, no prefetch */
 
        __raw_writel(htonl(ctl), &dev->uregs->outbound[i].otat);
 
@@ -272,7 +254,8 @@ unsigned int tsi148_eval_vam(int vam)
 /*
  * Create vme slave window (access: vme -> pci)
  */
-int tsi148_vme_slave_window(unsigned int vmeAddr, unsigned int pciAddr, int size, int vam)
+int tsi148_vme_slave_window(unsigned int vmeAddr, unsigned int pciAddr,
+                           int size, int vam)
 {
        int result, i;
        unsigned int ctl = 0;
@@ -306,13 +289,13 @@ int tsi148_vme_slave_window(unsigned int vmeAddr, unsigned int pciAddr, int size
                __raw_writel(0x00000000, &dev->uregs->inbound[i].itofu);
 
        ctl = tsi148_eval_vam(vam);
-       ctl |= 0x80000000;    /* enable */
+       ctl |= 0x80000000;      /* enable */
        __raw_writel(htonl(ctl), &dev->uregs->inbound[i].itat);
 
        debug("Tsi148: window-addr                =%p\n",
              &dev->uregs->inbound[i].itsau);
        debug("Tsi148: vme slave window[%d] attr  =%08x\n",
-             i, ntohl(__raw_readl(&dev->uregs->inbound[i].itat))) ;
+             i, ntohl(__raw_readl(&dev->uregs->inbound[i].itat)));
        debug("Tsi148: vme slave window[%d] start =%08x\n",
              i, ntohl(__raw_readl(&dev->uregs->inbound[i].itsal)));
        debug("Tsi148: vme slave window[%d] end   =%08x\n",
@@ -339,12 +322,12 @@ int tsi148_vme_gcsr_window(unsigned int vmeAddr, int vam)
        if (NULL == dev) {
                result = 1;
        } else {
-              __raw_writel(htonl(vmeAddr), &dev->uregs->gbal);
-              __raw_writel(0x00000000, &dev->uregs->gbau);
+               __raw_writel(htonl(vmeAddr), &dev->uregs->gbal);
+               __raw_writel(0x00000000, &dev->uregs->gbau);
 
-              ctl = tsi148_eval_vam(vam);
-              ctl |= 0x00000080;    /* enable */
-              __raw_writel(htonl(ctl), &dev->uregs->gcsrat);
+               ctl = tsi148_eval_vam(vam);
+               ctl |= 0x00000080;      /* enable */
+               __raw_writel(htonl(ctl), &dev->uregs->gcsrat);
        }
 
        return result;
@@ -363,17 +346,16 @@ int tsi148_vme_crcsr_window(unsigned int vmeAddr)
        if (NULL == dev) {
                result = 1;
        } else {
-              __raw_writel(htonl(vmeAddr), &dev->uregs->crol);
-              __raw_writel(0x00000000, &dev->uregs->crou);
+               __raw_writel(htonl(vmeAddr), &dev->uregs->crol);
+               __raw_writel(0x00000000, &dev->uregs->crou);
 
-              ctl = 0x00000080;    /* enable */
-              __raw_writel(htonl(ctl), &dev->uregs->crat);
+               ctl = 0x00000080;       /* enable */
+               __raw_writel(htonl(ctl), &dev->uregs->crat);
        }
 
        return result;
 }
 
-
 /*
  * Create vme slave window (access: vme -> crg)
  */
@@ -387,12 +369,12 @@ int tsi148_vme_crg_window(unsigned int vmeAddr, int vam)
        if (NULL == dev) {
                result = 1;
        } else {
-              __raw_writel(htonl(vmeAddr), &dev->uregs->cbal);
-              __raw_writel(0x00000000, &dev->uregs->cbau);
+               __raw_writel(htonl(vmeAddr), &dev->uregs->cbal);
+               __raw_writel(0x00000000, &dev->uregs->cbau);
 
-              ctl = tsi148_eval_vam(vam);
-              ctl |= 0x00000080;    /* enable */
-              __raw_writel(htonl(ctl), &dev->uregs->crgat);
+               ctl = tsi148_eval_vam(vam);
+               ctl |= 0x00000080;      /* enable */
+               __raw_writel(htonl(ctl), &dev->uregs->crgat);
        }
 
        return result;
@@ -401,7 +383,7 @@ int tsi148_vme_crg_window(unsigned int vmeAddr, int vam)
 /*
  * Tundra Tsi148 configuration
  */
-int do_tsi148(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_tsi148(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong addr1 = 0, addr2 = 0, size = 0, vam = 0, vdw = 0;
        char cmd = 'x';
@@ -418,17 +400,19 @@ int do_tsi148(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        if (argc > 5)
                vam = simple_strtoul(argv[5], NULL, 16);
        if (argc > 6)
-               vdw = simple_strtoul(argv[7], NULL, 16);
+               vdw = simple_strtoul(argv[6], NULL, 16);
 
        switch (cmd) {
        case 'c':
                if (strcmp(argv[1], "crg") == 0) {
                        vam = addr2;
-                       printf("Tsi148: Configuring VME CRG Window (VME->CRG):\n");
+                       printf("Tsi148: Configuring VME CRG Window "
+                              "(VME->CRG):\n");
                        printf("  vme=%08lx vam=%02lx\n", addr1, vam);
                        tsi148_vme_crg_window(addr1, vam);
                } else {
-                       printf("Tsi148: Configuring VME CR/CSR Window (VME->CR/CSR):\n");
+                       printf("Tsi148: Configuring VME CR/CSR Window "
+                              "(VME->CR/CSR):\n");
                        printf("  pci=%08lx\n", addr1);
                        tsi148_vme_crcsr_window(addr1);
                }
@@ -462,8 +446,8 @@ int do_tsi148(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 }
 
 U_BOOT_CMD(
-       tsi148, 8,      1,      do_tsi148,
-       "tsi148  - initialize and configure Turndra Tsi148\n",
+       tsi148, 7,      1,      do_tsi148,
+       "initialize and configure Turndra Tsi148\n",
        "init\n"
        "    - initialize tsi148\n"
        "tsi148 vme   [vme_addr] [pci_addr] [size] [vam]\n"