Commit 384980c687ca38c028bdf40f59a38b3f52105884

Authored by Bin Meng
1 parent 3e389d8ba6

dm: pch: Add get_gpio_base op

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>

Showing 2 changed files with 29 additions and 0 deletions Side-by-side Diff

drivers/pch/pch-uclass.c
... ... @@ -33,6 +33,17 @@
33 33 return ops->set_spi_protect(dev, protect);
34 34 }
35 35  
  36 +int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
  37 +{
  38 + struct pch_ops *ops = pch_get_ops(dev);
  39 +
  40 + *gbasep = 0;
  41 + if (!ops->get_gpio_base)
  42 + return -ENOSYS;
  43 +
  44 + return ops->get_gpio_base(dev, gbasep);
  45 +}
  46 +
36 47 static int pch_uclass_post_bind(struct udevice *bus)
37 48 {
38 49 /*
... ... @@ -32,6 +32,15 @@
32 32 * @return 0 on success, -ENOSYS if not implemented
33 33 */
34 34 int (*set_spi_protect)(struct udevice *dev, bool protect);
  35 +
  36 + /**
  37 + * get_gpio_base() - get the address of GPIO base
  38 + *
  39 + * @dev: PCH device to check
  40 + * @gbasep: Returns address of GPIO base if available, else 0
  41 + * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
  42 + */
  43 + int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
35 44 };
36 45  
37 46 #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
... ... @@ -54,6 +63,15 @@
54 63 * @return 0 on success, -ENOSYS if not implemented
55 64 */
56 65 int pch_set_spi_protect(struct udevice *dev, bool protect);
  66 +
  67 +/**
  68 + * pch_get_gpio_base() - get the address of GPIO base
  69 + *
  70 + * @dev: PCH device to check
  71 + * @gbasep: Returns address of GPIO base if available, else 0
  72 + * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
  73 + */
  74 +int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
57 75  
58 76 #endif