From 56fd6419c33ae648b96dc876d35c78d3f85d4acb Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Thu, 16 Sep 2021 20:38:24 -0700 Subject: [PATCH] mb/google/guybrush: Switch to using device pointers This change replaces the device tree walks with device pointers by adding alias for following devices: 1. FPMCU 2. WWAN Additionally, this change drops the __weak attribute for variant_has_* functions as there is no need for different implementations for the variants. Change-Id: I8af5e27f226270e6b40a50640c87de99a5a703f7 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/c/coreboot/+/57743 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Karthik Ramasubramanian --- .../guybrush/variants/baseboard/helpers.c | 41 +++---------------- .../variants/guybrush/overridetree.cb | 2 +- .../variants/nipperkin/overridetree.cb | 2 +- 3 files changed, 8 insertions(+), 37 deletions(-) diff --git a/src/mainboard/google/guybrush/variants/baseboard/helpers.c b/src/mainboard/google/guybrush/variants/baseboard/helpers.c index cde31c22d9..881c556f70 100644 --- a/src/mainboard/google/guybrush/variants/baseboard/helpers.c +++ b/src/mainboard/google/guybrush/variants/baseboard/helpers.c @@ -6,43 +6,14 @@ #include #include -static bool variant_has_device_enabled(const struct device_path *device_path, size_t path_length) -{ - const struct device *dev = - find_dev_nested_path(all_devices->link_list, device_path, path_length); +WEAK_DEV_PTR(fpmcu); - return is_dev_enabled(dev); +bool variant_has_fpmcu(void) +{ + return is_dev_enabled(DEV_PTR(fpmcu)); } -__weak bool variant_has_fpmcu(void) +bool variant_has_pcie_wwan(void) { - static const struct device_path fpmcu_path[] = { - { - .type = DEVICE_PATH_MMIO, - .mmio.addr = APU_UART1_BASE - }, - { - .type = DEVICE_PATH_GENERIC, - .generic.id = 0, - .generic.subid = 0 - }, - }; - - return variant_has_device_enabled(fpmcu_path, ARRAY_SIZE(fpmcu_path)); -} - -__weak bool variant_has_pcie_wwan(void) -{ - static const struct device_path pcie_wwan_path[] = { - { - .type = DEVICE_PATH_DOMAIN, - .domain.domain = 0x0, - }, - { - .type = DEVICE_PATH_PCI, - .pci.devfn = WWAN_DEVFN - }, -}; - - return variant_has_device_enabled(pcie_wwan_path, ARRAY_SIZE(pcie_wwan_path)); + return is_dev_enabled(DEV_PTR(gpp_bridge_2)); } diff --git a/src/mainboard/google/guybrush/variants/guybrush/overridetree.cb b/src/mainboard/google/guybrush/variants/guybrush/overridetree.cb index d889245264..41b3733e7e 100644 --- a/src/mainboard/google/guybrush/variants/guybrush/overridetree.cb +++ b/src/mainboard/google/guybrush/variants/guybrush/overridetree.cb @@ -163,7 +163,7 @@ chip soc/amd/cezanne register "irq_gpio" = "ACPI_GPIO_IRQ_LEVEL_LOW(GPIO_21)" register "wake" = "GEVENT_5" register "uart" = "ACPI_UART_RAW_DEVICE(3000000, 64)" - device generic 0 on + device generic 0 alias fpmcu on probe FP FP_PRESENT end end diff --git a/src/mainboard/google/guybrush/variants/nipperkin/overridetree.cb b/src/mainboard/google/guybrush/variants/nipperkin/overridetree.cb index 6de2545a1a..afe5673d65 100644 --- a/src/mainboard/google/guybrush/variants/nipperkin/overridetree.cb +++ b/src/mainboard/google/guybrush/variants/nipperkin/overridetree.cb @@ -122,7 +122,7 @@ chip soc/amd/cezanne register "irq_gpio" = "ACPI_GPIO_IRQ_LEVEL_LOW(GPIO_21)" register "wake" = "GEVENT_5" register "uart" = "ACPI_UART_RAW_DEVICE(3000000, 64)" - device generic 0 on + device generic 0 alias fpmcu on probe FP FP_PRESENT end end