summaryrefslogtreecommitdiff
path: root/src/mainboard/google/volteer
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2021-09-16 16:54:04 -0700
committerFurquan Shaikh <furquan@google.com>2021-09-20 23:08:42 +0000
commit522174ba382c4a75a49fe1116b320efbe9faa122 (patch)
treeec3fdfa775ebbf56397c71700c664ebb83dc4658 /src/mainboard/google/volteer
parent4aba7395b705725c5e441cce2fd269e734994939 (diff)
mb/google/volteer: Switch to using device pointers using alias names
This change replaces the device tree walks with device pointers by using alias names for the following devices: 1. PMC MUX connector 2. SPI TPM 3. I2C TPM Change-Id: I38f87d3a90a7253f2a29aba7db9a9f9744985494 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/57740 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/mainboard/google/volteer')
-rw-r--r--src/mainboard/google/volteer/mainboard.c31
-rw-r--r--src/mainboard/google/volteer/variants/baseboard/devicetree.cb2
-rw-r--r--src/mainboard/google/volteer/variants/volteer2/overridetree.cb2
-rw-r--r--src/mainboard/google/volteer/variants/volteer2/variant.c12
4 files changed, 7 insertions, 40 deletions
diff --git a/src/mainboard/google/volteer/mainboard.c b/src/mainboard/google/volteer/mainboard.c
index 74264451b6..9f8e646ae1 100644
--- a/src/mainboard/google/volteer/mainboard.c
+++ b/src/mainboard/google/volteer/mainboard.c
@@ -20,38 +20,13 @@
#include "drivers/intel/pmc_mux/conn/chip.h"
-extern struct chip_operations drivers_intel_pmc_mux_conn_ops;
-
-static bool is_port1(struct device *dev)
-{
- return dev->path.type == DEVICE_PATH_GENERIC && dev->path.generic.id == 1
- && dev->chip_ops == &drivers_intel_pmc_mux_conn_ops;
-}
+WEAK_DEV_PTR(conn1);
static void typec_orientation_fixup(void)
{
- /*
- * TODO: This is an ugly hack, see if there's a better way to accomplish this same thing
- * via fw_config + devicetree, i.e., change a register's value depending on fw_config
- * probing.
- */
- const struct device *pmc;
- const struct device *mux;
- const struct device *conn;
+ const struct device *conn = DEV_PTR(conn1);
- pmc = pcidev_path_on_root(PCH_DEVFN_PMC);
- if (!pmc || !pmc->link_list->children) {
- printk(BIOS_ERR, "%s: unable to find PMC device or its mux\n", __func__);
- return;
- }
-
- /*
- * Find port 1 underneath PMC.MUX; some variants may not have this defined, so it's okay
- * to just silently return here.
- */
- mux = pmc->link_list->children;
- conn = dev_find_matching_device_on_bus(mux->link_list, is_port1);
- if (!conn)
+ if (!is_dev_enabled(conn))
return;
if (fw_config_probe(FW_CONFIG(DB_USB, USB4_GEN2))
diff --git a/src/mainboard/google/volteer/variants/baseboard/devicetree.cb b/src/mainboard/google/volteer/variants/baseboard/devicetree.cb
index 0d067e6573..b4c4f6a41f 100644
--- a/src/mainboard/google/volteer/variants/baseboard/devicetree.cb
+++ b/src/mainboard/google/volteer/variants/baseboard/devicetree.cb
@@ -508,7 +508,7 @@ chip soc/intel/tigerlake
register "hid" = "ACPI_DT_NAMESPACE_HID"
register "compat_string" = ""google,cr50""
register "irq" = "ACPI_IRQ_EDGE_LOW(GPP_C21_IRQ)"
- device spi 0 on end
+ device spi 0 alias spi_tpm on end
end
end
device ref gspi1 on
diff --git a/src/mainboard/google/volteer/variants/volteer2/overridetree.cb b/src/mainboard/google/volteer/variants/volteer2/overridetree.cb
index 2654bd7a69..7fe38a93d4 100644
--- a/src/mainboard/google/volteer/variants/volteer2/overridetree.cb
+++ b/src/mainboard/google/volteer/variants/volteer2/overridetree.cb
@@ -207,7 +207,7 @@ chip soc/intel/tigerlake
chip drivers/i2c/tpm
register "hid" = ""GOOG0005""
register "irq" = "ACPI_IRQ_EDGE_LOW(GPP_C21_IRQ)"
- device i2c 50 off end
+ device i2c 50 alias i2c_tpm off end
end
end
device ref i2c2 on
diff --git a/src/mainboard/google/volteer/variants/volteer2/variant.c b/src/mainboard/google/volteer/variants/volteer2/variant.c
index 057bb8ad65..442402779d 100644
--- a/src/mainboard/google/volteer/variants/volteer2/variant.c
+++ b/src/mainboard/google/volteer/variants/volteer2/variant.c
@@ -4,22 +4,14 @@
#include <soc/pci_devs.h>
#include <acpi/acpi_device.h>
-extern struct chip_operations drivers_i2c_tpm_ops;
-
-static bool match_i2c_tpm(DEVTREE_CONST struct device *dev)
-{
- return dev->chip_ops == &drivers_i2c_tpm_ops;
-}
-
/*
* This function runs only on the volteer_ti50 variant, which has the GSC on a
* reworked I2C bus.
*/
static void devtree_enable_i2c_tpm(void)
{
- struct device *spi_tpm = pcidev_path_on_root(PCH_DEVFN_GSPI0)->link_list->children;
- struct device *i2c_tpm = dev_find_matching_device_on_bus(
- pcidev_path_on_root(PCH_DEVFN_I2C1)->link_list, match_i2c_tpm);
+ struct device *spi_tpm = DEV_PTR(spi_tpm);
+ struct device *i2c_tpm = DEV_PTR(i2c_tpm);
if (!i2c_tpm || !spi_tpm)
return;
spi_tpm->enabled = 0;