]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_pci.c
spi: omap3_spi: add am43xx support to omap3_spi
[karo-tx-uboot.git] / common / cmd_pci.c
index a1fe519f61d9cc3584f2e53540a5c4ef82daad5c..dcecef8da859b467e08cf3cf0434658b758fb668 100644 (file)
@@ -6,23 +6,7 @@
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  * Wolfgang Grandegger, DENX Software Engineering, wg@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+
  */
 
 /*
  */
 
 #include <common.h>
+#include <bootretry.h>
+#include <cli.h>
 #include <command.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 #include <pci.h>
 
-unsigned char  ShortPCIListing = 1;
-
 /*
  * Follows routines for the output of infos about devices on PCI bus.
  */
@@ -58,11 +42,16 @@ void pci_header_show_brief(pci_dev_t dev);
  */
 void pciinfo(int BusNum, int ShortPCIListing)
 {
+       struct pci_controller *hose = pci_bus_to_hose(BusNum);
        int Device;
        int Function;
        unsigned char HeaderType;
        unsigned short VendorID;
        pci_dev_t dev;
+       int ret;
+
+       if (!hose)
+               return;
 
        printf("Scanning PCI devices on bus %d\n", BusNum);
 
@@ -83,7 +72,13 @@ void pciinfo(int BusNum, int ShortPCIListing)
 
                        dev = PCI_BDF(BusNum, Device, Function);
 
-                       pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID);
+                       if (pci_skip_dev(hose, dev))
+                               continue;
+
+                       ret = pci_read_config_word(dev, PCI_VENDOR_ID,
+                                                  &VendorID);
+                       if (ret)
+                               goto error;
                        if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
                                continue;
 
@@ -100,8 +95,12 @@ void pciinfo(int BusNum, int ShortPCIListing)
                                       BusNum, Device, Function);
                                pci_header_show(dev);
                        }
-           }
-    }
+               }
+       }
+
+       return;
+error:
+       printf("Cannot read bus configuration: %d\n", ret);
 }
 
 
@@ -363,7 +362,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
                        printf(" %02x", val1);
                }
 
-               nbytes = readline (" ? ");
+               nbytes = cli_readline(" ? ");
                if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
                        /* <CR> pressed as only input, don't modify current
                         * location and move to next. "-" pressed will go back.
@@ -371,9 +370,8 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
                        if (incrflag)
                                addr += nbytes ? -size : size;
                        nbytes = 1;
-#ifdef CONFIG_BOOT_RETRY_TIME
-                       reset_cmd_timeout(); /* good enough to not time out */
-#endif
+                       /* good enough to not time out */
+                       bootretry_reset_cmd_timeout();
                }
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (nbytes == -2) {
@@ -385,11 +383,9 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
                        i = simple_strtoul(console_buffer, &endp, 16);
                        nbytes = endp - console_buffer;
                        if (nbytes) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                                /* good enough to not time out
                                 */
-                               reset_cmd_timeout();
-#endif
+                               bootretry_reset_cmd_timeout();
                                pci_cfg_write (bdf, addr, size, i);
                                if (incrflag)
                                        addr += size;
@@ -408,7 +404,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
  *      pci modify[.b, .w, .l] bus.device.function [addr]
  *      pci write[.b, .w, .l] bus.device.function addr value
  */
-int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong addr = 0, value = 0, size = 0;
        pci_dev_t bdf = 0;
@@ -485,10 +481,8 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 /***************************************************/
 
-
-U_BOOT_CMD(
-       pci,    5,      1,      do_pci,
-       "list and access PCI Configuration Space",
+#ifdef CONFIG_SYS_LONGHELP
+static char pci_help_text[] =
        "[bus] [long]\n"
        "    - short or long list of PCI devices on bus 'bus'\n"
 #ifdef CONFIG_CMD_PCI_ENUM
@@ -504,5 +498,10 @@ U_BOOT_CMD(
        "pci modify[.b, .w, .l] b.d.f address\n"
        "    -  modify, auto increment CFG address\n"
        "pci write[.b, .w, .l] b.d.f address value\n"
-       "    - write to CFG address"
+       "    - write to CFG address";
+#endif
+
+U_BOOT_CMD(
+       pci,    5,      1,      do_pci,
+       "list and access PCI Configuration Space", pci_help_text
 );