]> git.sur5r.net Git - u-boot/blobdiff - drivers/pch/pch7.c
dwc2 USB controller hangs with lan78xx
[u-boot] / drivers / pch / pch7.c
index ef724221c2e6df224f4a4f317c48428ec5afb62b..268edb3f8fbe94dd47b68639755c8c954534a90e 100644 (file)
@@ -1,16 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2014 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm.h>
 #include <pch.h>
 
+#define GPIO_BASE      0x44
 #define BIOS_CTRL      0xd8
 
-static int pch7_get_sbase(struct udevice *dev, ulong *sbasep)
+static int pch7_get_spi_base(struct udevice *dev, ulong *sbasep)
 {
        u32 rcba;
 
@@ -22,11 +22,6 @@ static int pch7_get_sbase(struct udevice *dev, ulong *sbasep)
        return 0;
 }
 
-static enum pch_version pch7_get_version(struct udevice *dev)
-{
-       return PCHV_7;
-}
-
 static int pch7_set_spi_protect(struct udevice *dev, bool protect)
 {
        uint8_t bios_cntl;
@@ -42,10 +37,41 @@ static int pch7_set_spi_protect(struct udevice *dev, bool protect)
        return 0;
 }
 
+static int pch7_get_gpio_base(struct udevice *dev, u32 *gbasep)
+{
+       u32 base;
+
+       /*
+        * GPIO_BASE moved to its current offset with ICH6, but prior to
+        * that it was unused (or undocumented). Check that it looks
+        * okay: not all ones or zeros.
+        *
+        * Note we don't need check bit0 here, because the Tunnel Creek
+        * GPIO base address register bit0 is reserved (read returns 0),
+        * while on the Ivybridge the bit0 is used to indicate it is an
+        * I/O space.
+        */
+       dm_pci_read_config32(dev, GPIO_BASE, &base);
+       if (base == 0x00000000 || base == 0xffffffff) {
+               debug("%s: unexpected BASE value\n", __func__);
+               return -ENODEV;
+       }
+
+       /*
+        * Okay, I guess we're looking at the right device. The actual
+        * GPIO registers are in the PCI device's I/O space, starting
+        * at the offset that we just read. Bit 0 indicates that it's
+        * an I/O address, not a memory address, so mask that off.
+        */
+       *gbasep = base & 1 ? base & ~3 : base & ~15;
+
+       return 0;
+}
+
 static const struct pch_ops pch7_ops = {
-       .get_sbase      = pch7_get_sbase,
-       .get_version    = pch7_get_version,
+       .get_spi_base   = pch7_get_spi_base,
        .set_spi_protect = pch7_set_spi_protect,
+       .get_gpio_base  = pch7_get_gpio_base,
 };
 
 static const struct udevice_id pch7_ids[] = {