]> git.sur5r.net Git - u-boot/commitdiff
dm: pch: Add get_gpio_base op
authorBin Meng <bmeng.cn@gmail.com>
Mon, 1 Feb 2016 09:40:43 +0000 (01:40 -0800)
committerBin Meng <bmeng.cn@gmail.com>
Fri, 5 Feb 2016 04:47:21 +0000 (12:47 +0800)
x86 GPIO registers are accessed via I/O port whose base address is
configured in a PCI configuration register on the PCH device. Add
an op get_gpio_base to get the GPIO base address from PCH.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
drivers/pch/pch-uclass.c
include/pch.h

index b33d50201b8f8ac2a86229e2e274b4ee7d9bbbba..48a3965a7644e6e00e30b4250d7b023d043f8555 100644 (file)
@@ -33,6 +33,17 @@ int pch_set_spi_protect(struct udevice *dev, bool protect)
        return ops->set_spi_protect(dev, protect);
 }
 
+int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
+{
+       struct pch_ops *ops = pch_get_ops(dev);
+
+       *gbasep = 0;
+       if (!ops->get_gpio_base)
+               return -ENOSYS;
+
+       return ops->get_gpio_base(dev, gbasep);
+}
+
 static int pch_uclass_post_bind(struct udevice *bus)
 {
        /*
index c04cfa32bc92b58376101f488071a62525400862..b378865c67cf69ae9a409d16eef7d80137d72dc5 100644 (file)
@@ -32,6 +32,15 @@ struct pch_ops {
         * @return 0 on success, -ENOSYS if not implemented
         */
        int (*set_spi_protect)(struct udevice *dev, bool protect);
+
+       /**
+        * get_gpio_base() - get the address of GPIO base
+        *
+        * @dev:        PCH device to check
+        * @gbasep:     Returns address of GPIO base if available, else 0
+        * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
+        */
+       int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
 };
 
 #define pch_get_ops(dev)        ((struct pch_ops *)(dev)->driver->ops)
@@ -55,4 +64,13 @@ int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
  */
 int pch_set_spi_protect(struct udevice *dev, bool protect);
 
+/**
+ * pch_get_gpio_base() - get the address of GPIO base
+ *
+ * @dev:       PCH device to check
+ * @gbasep:    Returns address of GPIO base if available, else 0
+ * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
+ */
+int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
+
 #endif