From 8913b783b9d3ffea2eda7cfd1c9e7319ae889246 Mon Sep 17 00:00:00 2001 From: Michael Niewöhner Date: Fri, 11 Dec 2020 22:13:44 +0100 Subject: soc/intel: hook up new gpio device in the soc chips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds the required gpio operations struct to soc/common gpio code and hooks them up in all socs currently using the gpio block code, except DNV-NS, which is handled in a separate change. Also, add the gpio device to existing chipset devicetrees. Successfully tested on Supermicro X11SSM-F with CB:48097, X11SSH-TF with CB:48711 and OCP DeltaLake with CB:48672. Change-Id: I81dbbf5397b28ffa7537465c53332779245b39f6 Tested-by: Johnny Lin Tested-by: Michael Niewöhner Tested-by: Patrick Rudolph Signed-off-by: Michael Niewöhner Reviewed-on: https://review.coreboot.org/c/coreboot/+/48583 Reviewed-by: Paul Menzel Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/soc/intel/alderlake/chip.c | 3 +++ src/soc/intel/alderlake/chipset.cb | 1 + src/soc/intel/apollolake/chip.c | 3 +++ src/soc/intel/cannonlake/chip.c | 3 +++ src/soc/intel/common/block/gpio/Makefile.inc | 2 ++ src/soc/intel/common/block/gpio/gpio.c | 1 + src/soc/intel/common/block/gpio/gpio_dev.c | 28 ++++++++++++++++++++++ .../intel/common/block/include/intelblocks/gpio.h | 7 ++++++ src/soc/intel/elkhartlake/chip.c | 3 +++ src/soc/intel/icelake/chip.c | 3 +++ src/soc/intel/icelake/chip.h | 1 + src/soc/intel/jasperlake/chip.c | 3 +++ src/soc/intel/jasperlake/chip.h | 1 + src/soc/intel/skylake/chip.c | 3 +++ src/soc/intel/skylake/chipset.cb | 1 + src/soc/intel/tigerlake/chip.c | 3 +++ src/soc/intel/tigerlake/chip.h | 1 + src/soc/intel/tigerlake/chipset.cb | 1 + src/soc/intel/xeon_sp/cpx/chip.c | 3 +++ src/soc/intel/xeon_sp/cpx/chip.h | 1 + src/soc/intel/xeon_sp/skx/chip.c | 3 +++ src/soc/intel/xeon_sp/skx/chip.h | 1 + 22 files changed, 76 insertions(+) create mode 100644 src/soc/intel/common/block/gpio/gpio_dev.c diff --git a/src/soc/intel/alderlake/chip.c b/src/soc/intel/alderlake/chip.c index 794c3bae0f..95b6b8f307 100644 --- a/src/soc/intel/alderlake/chip.c +++ b/src/soc/intel/alderlake/chip.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -182,6 +183,8 @@ static void soc_enable(struct device *dev) else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCH_DEVFN_PMC) dev->ops = &pmc_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_alderlake_ops = { diff --git a/src/soc/intel/alderlake/chipset.cb b/src/soc/intel/alderlake/chipset.cb index de97a5780b..173d3e037f 100644 --- a/src/soc/intel/alderlake/chipset.cb +++ b/src/soc/intel/alderlake/chipset.cb @@ -1,5 +1,6 @@ chip soc/intel/alderlake device domain 0 on + device gpio 0 alias pch_gpio on end device pci 00.0 alias system_agent on end device pci 01.0 alias pcie5 off end device pci 02.0 alias igpu off end diff --git a/src/soc/intel/apollolake/chip.c b/src/soc/intel/apollolake/chip.c index a4ed8bdcbb..fdbeef2d88 100644 --- a/src/soc/intel/apollolake/chip.c +++ b/src/soc/intel/apollolake/chip.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -216,6 +217,8 @@ static void enable_dev(struct device *dev) dev->ops = &pci_domain_ops; else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) dev->ops = &cpu_bus_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } /* diff --git a/src/soc/intel/cannonlake/chip.c b/src/soc/intel/cannonlake/chip.c index 17698460f7..0958aace02 100644 --- a/src/soc/intel/cannonlake/chip.c +++ b/src/soc/intel/cannonlake/chip.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -209,6 +210,8 @@ static void soc_enable(struct device *dev) dev->ops = &pci_domain_ops; else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) dev->ops = &cpu_bus_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_cannonlake_ops = { diff --git a/src/soc/intel/common/block/gpio/Makefile.inc b/src/soc/intel/common/block/gpio/Makefile.inc index b0ffee308a..0379e92250 100644 --- a/src/soc/intel/common/block/gpio/Makefile.inc +++ b/src/soc/intel/common/block/gpio/Makefile.inc @@ -3,3 +3,5 @@ ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c verstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c + +ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio_dev.c diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c index fb9287c1f7..28e78fb366 100644 --- a/src/soc/intel/common/block/gpio/gpio.c +++ b/src/soc/intel/common/block/gpio/gpio.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include diff --git a/src/soc/intel/common/block/gpio/gpio_dev.c b/src/soc/intel/common/block/gpio/gpio_dev.c new file mode 100644 index 0000000000..c47d3a28ff --- /dev/null +++ b/src/soc/intel/common/block/gpio/gpio_dev.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +static struct gpio_operations gpio_ops = { + .get = gpio_get, + .set = gpio_set, + .input_pulldown = gpio_input_pulldown, + .input_pullup = gpio_input_pullup, + .input = gpio_input, + .output = gpio_output, +}; + +static struct device_operations block_gpio_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .ops_gpio = &gpio_ops, +}; + +void block_gpio_enable(struct device *dev) +{ + assert(dev->path.type == DEVICE_PATH_GPIO); + dev->ops = &block_gpio_ops; +} diff --git a/src/soc/intel/common/block/include/intelblocks/gpio.h b/src/soc/intel/common/block/include/intelblocks/gpio.h index 173a383f1e..4c29a0c5ba 100644 --- a/src/soc/intel/common/block/include/intelblocks/gpio.h +++ b/src/soc/intel/common/block/include/intelblocks/gpio.h @@ -25,6 +25,7 @@ #ifndef __ACPI__ #include +#include /* * GPIO numbers may not be contiguous and instead will have a different @@ -222,5 +223,11 @@ void gpi_clear_int_cfg(void); /* The function performs GPIO Power Management programming. */ void gpio_pm_configure(const uint8_t *misccfg_pm_values, size_t num); +/* + * Set gpio ops of the device to gpio block ops. + * Shall be called by all SoCs that use intelblocks/gpio. + */ +void block_gpio_enable(struct device *dev); + #endif #endif /* _SOC_INTELBLOCKS_GPIO_H_ */ diff --git a/src/soc/intel/elkhartlake/chip.c b/src/soc/intel/elkhartlake/chip.c index 8b4cf0cad9..359aa11c07 100644 --- a/src/soc/intel/elkhartlake/chip.c +++ b/src/soc/intel/elkhartlake/chip.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -163,6 +164,8 @@ static void soc_enable(struct device *dev) else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCH_DEVFN_PMC) dev->ops = &pmc_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_elkhartlake_ops = { diff --git a/src/soc/intel/icelake/chip.c b/src/soc/intel/icelake/chip.c index d0ea732df3..d493f81bba 100644 --- a/src/soc/intel/icelake/chip.c +++ b/src/soc/intel/icelake/chip.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -144,6 +145,8 @@ static void soc_enable(struct device *dev) dev->ops = &pci_domain_ops; else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) dev->ops = &cpu_bus_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_icelake_ops = { diff --git a/src/soc/intel/icelake/chip.h b/src/soc/intel/icelake/chip.h index cd0a9b03d8..64bc70ba53 100644 --- a/src/soc/intel/icelake/chip.h +++ b/src/soc/intel/icelake/chip.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/soc/intel/jasperlake/chip.c b/src/soc/intel/jasperlake/chip.c index d34ef557df..1f58f84c18 100644 --- a/src/soc/intel/jasperlake/chip.c +++ b/src/soc/intel/jasperlake/chip.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,8 @@ static void soc_enable(struct device *dev) else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCH_DEVFN_PMC) dev->ops = &pmc_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_jasperlake_ops = { diff --git a/src/soc/intel/jasperlake/chip.h b/src/soc/intel/jasperlake/chip.h index 9d4bc5c80a..884071fdbd 100644 --- a/src/soc/intel/jasperlake/chip.h +++ b/src/soc/intel/jasperlake/chip.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/soc/intel/skylake/chip.c b/src/soc/intel/skylake/chip.c index 2707353225..5b05dd20b2 100644 --- a/src/soc/intel/skylake/chip.c +++ b/src/soc/intel/skylake/chip.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,8 @@ static void soc_enable(struct device *dev) dev->ops = &pci_domain_ops; else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) dev->ops = &cpu_bus_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_skylake_ops = { diff --git a/src/soc/intel/skylake/chipset.cb b/src/soc/intel/skylake/chipset.cb index 28ee53d3ad..428db67d3a 100644 --- a/src/soc/intel/skylake/chipset.cb +++ b/src/soc/intel/skylake/chipset.cb @@ -1,5 +1,6 @@ chip soc/intel/skylake device domain 0 on + device gpio 0 alias pch_gpio on end # GPIO device pci 00.0 alias system_agent on end # Host Bridge device pci 01.0 alias peg0 off end # PEG0 device pci 01.1 alias peg1 off end # PEG1 diff --git a/src/soc/intel/tigerlake/chip.c b/src/soc/intel/tigerlake/chip.c index 62201a2f4f..f07cc58c95 100644 --- a/src/soc/intel/tigerlake/chip.c +++ b/src/soc/intel/tigerlake/chip.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,8 @@ static void soc_enable(struct device *dev) else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCH_DEVFN_PMC) dev->ops = &pmc_ops; + else if (dev->path.type == DEVICE_PATH_GPIO) + block_gpio_enable(dev); } struct chip_operations soc_intel_tigerlake_ops = { diff --git a/src/soc/intel/tigerlake/chip.h b/src/soc/intel/tigerlake/chip.h index fe10d0dbcb..f38330b988 100644 --- a/src/soc/intel/tigerlake/chip.h +++ b/src/soc/intel/tigerlake/chip.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/soc/intel/tigerlake/chipset.cb b/src/soc/intel/tigerlake/chipset.cb index 54f7924b37..d4bc76c2a4 100644 --- a/src/soc/intel/tigerlake/chipset.cb +++ b/src/soc/intel/tigerlake/chipset.cb @@ -1,5 +1,6 @@ chip soc/intel/tigerlake device domain 0 on + device gpio 0 alias pch_gpio on end device pci 00.0 alias system_agent on end device pci 02.0 alias igpu off end device pci 04.0 alias dptf off end diff --git a/src/soc/intel/xeon_sp/cpx/chip.c b/src/soc/intel/xeon_sp/cpx/chip.c index a3076a8035..778d277a0c 100644 --- a/src/soc/intel/xeon_sp/cpx/chip.c +++ b/src/soc/intel/xeon_sp/cpx/chip.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,8 @@ static void chip_enable_dev(struct device *dev) attach_iio_stacks(dev); } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { dev->ops = &cpu_bus_ops; + } else if (dev->path.type == DEVICE_PATH_GPIO) { + block_gpio_enable(dev); } } diff --git a/src/soc/intel/xeon_sp/cpx/chip.h b/src/soc/intel/xeon_sp/cpx/chip.h index 434b343bb2..630bc8e979 100644 --- a/src/soc/intel/xeon_sp/cpx/chip.h +++ b/src/soc/intel/xeon_sp/cpx/chip.h @@ -4,6 +4,7 @@ #define _SOC_CHIP_H_ #include +#include #include #include diff --git a/src/soc/intel/xeon_sp/skx/chip.c b/src/soc/intel/xeon_sp/skx/chip.c index f101973864..8b08326fb6 100644 --- a/src/soc/intel/xeon_sp/skx/chip.c +++ b/src/soc/intel/xeon_sp/skx/chip.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,8 @@ static void soc_enable_dev(struct device *dev) attach_iio_stacks(dev); } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { dev->ops = &cpu_bus_ops; + } else if (dev->path.type == DEVICE_PATH_GPIO) { + block_gpio_enable(dev); } } diff --git a/src/soc/intel/xeon_sp/skx/chip.h b/src/soc/intel/xeon_sp/skx/chip.h index 08608997b3..4ee1ac0a0d 100644 --- a/src/soc/intel/xeon_sp/skx/chip.h +++ b/src/soc/intel/xeon_sp/skx/chip.h @@ -5,6 +5,7 @@ #include #include +#include #include struct soc_intel_xeon_sp_skx_config { -- cgit v1.2.3