diff options
4 files changed, 17 insertions, 216 deletions
diff --git a/src/mainboard/google/zork/variants/baseboard/devicetree_dalboz.cb b/src/mainboard/google/zork/variants/baseboard/devicetree_dalboz.cb index f1300c6f4b..9476723735 100644 --- a/src/mainboard/google/zork/variants/baseboard/devicetree_dalboz.cb +++ b/src/mainboard/google/zork/variants/baseboard/devicetree_dalboz.cb @@ -296,7 +296,7 @@ chip soc/amd/picasso register "desc" = ""Bluetooth"" register "type" = "UPC_TYPE_INTERNAL" register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_143)" - device usb 2.5 on end + device usb 2.5 alias xhci0_bt on end end chip drivers/usb/acpi register "desc" = ""Left Type-C Port"" @@ -338,7 +338,7 @@ chip soc/amd/picasso # Set low (0) = Select DMIC0 # Set high (1) = Select DMIC1 register "dmic_select_gpio" = "ACPI_GPIO_OUTPUT(GPIO_67)" - device generic 0.0 on end + device generic 0.0 alias acp_machine on end end end # Audio device ref hda off end # HDA @@ -364,7 +364,7 @@ chip soc/amd/picasso register "property_list[1].type" = "ACPI_DP_TYPE_STRING" register "property_list[1].name" = ""realtek,mclk-name"" register "property_list[1].string" = ""oscout1"" - device i2c 1a on end + device i2c 1a alias audio_rt5682 on end end end end diff --git a/src/mainboard/google/zork/variants/baseboard/devicetree_trembyle.cb b/src/mainboard/google/zork/variants/baseboard/devicetree_trembyle.cb index f8e5d9ad78..ce0121593b 100644 --- a/src/mainboard/google/zork/variants/baseboard/devicetree_trembyle.cb +++ b/src/mainboard/google/zork/variants/baseboard/devicetree_trembyle.cb @@ -321,7 +321,7 @@ chip soc/amd/picasso register "desc" = ""Bluetooth"" register "type" = "UPC_TYPE_INTERNAL" register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_14)" - device usb 2.5 on end + device usb 2.5 alias xhci0_bt on end end end end @@ -341,7 +341,7 @@ chip soc/amd/picasso register "desc" = ""Bluetooth"" register "type" = "UPC_TYPE_INTERNAL" register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_14)" - device usb 2.1 on end + device usb 2.1 alias xhci1_bt on end end chip drivers/usb/acpi register "desc" = ""World-Facing Camera"" @@ -364,7 +364,7 @@ chip soc/amd/picasso # Set low (0) = Select DMIC0 # Set high (1) = Select DMIC1 register "dmic_select_gpio" = "ACPI_GPIO_OUTPUT(GPIO_67)" - device generic 0.0 on end + device generic 0.0 alias acp_machine on end end end # Audio device ref hda off end # HDA @@ -390,7 +390,7 @@ chip soc/amd/picasso register "property_list[1].type" = "ACPI_DP_TYPE_STRING" register "property_list[1].name" = ""realtek,mclk-name"" register "property_list[1].string" = ""oscout1"" - device i2c 1a on end + device i2c 1a alias audio_rt5682 on end end end end diff --git a/src/mainboard/google/zork/variants/baseboard/ramstage_common.c b/src/mainboard/google/zork/variants/baseboard/ramstage_common.c index f7b8ed4253..afb890b698 100644 --- a/src/mainboard/google/zork/variants/baseboard/ramstage_common.c +++ b/src/mainboard/google/zork/variants/baseboard/ramstage_common.c @@ -13,34 +13,14 @@ #include <soc/iomap.h> #include <soc/pci_devs.h> -extern struct chip_operations drivers_amd_i2s_machine_dev_ops; extern struct chip_operations drivers_i2c_generic_ops; extern struct chip_operations drivers_i2c_hid_ops; +WEAK_DEV_PTR(xhci1_bt); + static void update_hp_int_odl(void) { - static const struct device_path rt5682_path[] = { - { - .type = DEVICE_PATH_PCI, - .pci.devfn = LPC_DEVFN - }, - { - .type = DEVICE_PATH_PNP, - .pnp.port = 0xc09, - .pnp.device = 0x0 - }, - { - .type = DEVICE_PATH_GENERIC, - .generic.id = 0, - .generic.subid = 0 - }, - { - .type = DEVICE_PATH_I2C, - .i2c.device = 0x1a - } - }; - - const struct device *rt5682_dev; + const struct device *rt5682_dev = DEV_PTR(audio_rt5682); struct drivers_i2c_generic_config *cfg; struct acpi_gpio *gpio; struct soc_amd_picasso_config *soc_cfg; @@ -48,19 +28,6 @@ static void update_hp_int_odl(void) if (!variant_uses_codec_gpi()) return; - rt5682_dev = find_dev_nested_path( - pci_root_bus(), rt5682_path, ARRAY_SIZE(rt5682_path)); - if (!rt5682_dev) { - printk(BIOS_ERR, "%s: Failed to find audio device\n", - __func__); - return; - } - - if (rt5682_dev->chip_ops != &drivers_i2c_generic_ops) { - printk(BIOS_ERR, "%s: Incorrect device found\n", __func__); - return; - } - cfg = config_of(rt5682_dev); gpio = &cfg->irq_gpio; gpio->pins[0] = 62; @@ -76,41 +43,13 @@ static void update_hp_int_odl(void) static void update_dmic_gpio(void) { - static const struct device_path acp_machine_path[] = { - { - .type = DEVICE_PATH_PCI, - .pci.devfn = PCIE_GPP_A_DEVFN - }, - { - .type = DEVICE_PATH_PCI, - .pci.devfn = AUDIO_DEVFN - }, - { - .type = DEVICE_PATH_GENERIC, - .generic.id = 0, - .generic.subid = 0 - } - }; - - const struct device *machine_dev; + const struct device *machine_dev = DEV_PTR(acp_machine); struct drivers_amd_i2s_machine_dev_config *cfg; struct acpi_gpio *gpio; if (variant_uses_v3_schematics()) return; - machine_dev = find_dev_nested_path( - pci_root_bus(), acp_machine_path, ARRAY_SIZE(acp_machine_path)); - if (!machine_dev) { - printk(BIOS_ERR, "%s: Failed to find ACP machine device\n", __func__); - return; - } - - if (machine_dev->chip_ops != &drivers_amd_i2s_machine_dev_ops) { - printk(BIOS_ERR, "%s: Incorrect device found\n", __func__); - return; - } - cfg = config_of(machine_dev); gpio = &cfg->dmic_select_gpio; @@ -132,18 +71,10 @@ void variant_audio_update(void) * * debug_device_name is used for debug messaging only. */ -static void remove_usb_device_reset_gpio(const struct device_path usb_path[], - size_t path_length, const char *debug_device_name) +static void remove_usb_device_reset_gpio(const struct device *usb_dev) { - const struct device *usb_dev; struct drivers_usb_acpi_config *usb_cfg; - - usb_dev = find_dev_nested_path(pci_root_bus(), usb_path, path_length); - if (!usb_dev) { - printk(BIOS_ERR, "%s: Failed to find %s!", __func__, debug_device_name); - return; - } /* config_of dies on failure, so a NULL check is not required */ usb_cfg = config_of(usb_dev); usb_cfg->reset_gpio.pin_count = 0; @@ -155,51 +86,8 @@ static void remove_usb_device_reset_gpio(const struct device_path usb_path[], */ static void baseboard_trembyle_remove_bluetooth_reset_gpio(void) { - static const struct device_path xhci0_bt_path[] = { - { - .type = DEVICE_PATH_PCI, - .pci.devfn = PCIE_GPP_A_DEVFN - }, - { - .type = DEVICE_PATH_PCI, - .pci.devfn = XHCI0_DEVFN - }, - { - .type = DEVICE_PATH_USB, - .usb.port_type = 0, - .usb.port_id = 0 - }, - { - .type = DEVICE_PATH_USB, - .usb.port_type = 2, - .usb.port_id = 5 - } - }; - static const struct device_path xhci1_bt_path[] = { - { - .type = DEVICE_PATH_PCI, - .pci.devfn = PCIE_GPP_A_DEVFN - }, - { - .type = DEVICE_PATH_PCI, - .pci.devfn = XHCI1_DEVFN - }, - { - .type = DEVICE_PATH_USB, - .usb.port_type = 0, - .usb.port_id = 0 - }, - { - .type = DEVICE_PATH_USB, - .usb.port_type = 2, - .usb.port_id = 1 - } - }; - - remove_usb_device_reset_gpio(xhci0_bt_path, ARRAY_SIZE(xhci0_bt_path), - "XHCI0 Bluetoth USB Device"); - remove_usb_device_reset_gpio(xhci1_bt_path, ARRAY_SIZE(xhci1_bt_path), - "XHCI1 Bluetoth USB Device"); + remove_usb_device_reset_gpio(DEV_PTR(xhci0_bt)); + remove_usb_device_reset_gpio(DEV_PTR(xhci1_bt)); } void variant_bluetooth_update(void) @@ -212,7 +100,7 @@ void variant_bluetooth_update(void) void variant_touchscreen_update(void) { - DEVTREE_CONST struct device *mmio_dev = NULL; + DEVTREE_CONST struct device *mmio_dev = DEV_PTR(i2c_2); struct device *child = NULL; /* @@ -227,17 +115,6 @@ void variant_touchscreen_update(void) if (variant_uses_v3_6_schematics()) return; - while (1) { - mmio_dev = dev_find_path(mmio_dev, DEVICE_PATH_MMIO); - if (mmio_dev == NULL) - break; - if (mmio_dev->path.mmio.addr == APU_I2C2_BASE) - break; - } - - if (mmio_dev == NULL) - return; - while ((child = dev_bus_each_child(mmio_dev->link_list, child)) != NULL) { struct drivers_i2c_generic_config *cfg; diff --git a/src/mainboard/google/zork/variants/dalboz/variant.c b/src/mainboard/google/zork/variants/dalboz/variant.c index 21aaec829a..b4e5bcc671 100644 --- a/src/mainboard/google/zork/variants/dalboz/variant.c +++ b/src/mainboard/google/zork/variants/dalboz/variant.c @@ -3,61 +3,12 @@ #include <baseboard/variants.h> #include <console/console.h> #include <device/device.h> -#include <drivers/i2c/generic/chip.h> -#include <soc/pci_devs.h> #include <ec/google/chromeec/ec.h> #include <ec/google/chromeec/i2c_tunnel/chip.h> #include <string.h> -#define EC_PNP_ID 0x0c09 -#define DALBOZ_DB_USBC 0x0 #define DALBOZ_DB_HDMI 0x1 -/* Look for an EC device of type PNP with id 0x0c09 */ -static bool match_ec_dev(DEVTREE_CONST struct device *dev) -{ - if (dev->path.type != DEVICE_PATH_PNP) - return false; - - if (dev->path.pnp.port != EC_PNP_ID) - return false; - - return true; -} - -extern struct chip_operations drivers_i2c_generic_ops; - -/* Look for an I2C device with HID "10EC5682" */ -static bool match_audio_dev(DEVTREE_CONST struct device *dev) -{ - struct drivers_i2c_generic_config *cfg; - - if (dev->chip_ops != &drivers_i2c_generic_ops) - return false; - - cfg = dev->chip_info; - - return !strcmp(cfg->hid, "10EC5682"); -} - -extern struct chip_operations ec_google_chromeec_i2c_tunnel_ops; - -/* Look for Cros EC tunnel device which has audio device under it. */ -static bool match_audio_tunnel(DEVTREE_CONST struct device *dev) -{ - const struct device *audio_dev; - - if (dev->chip_ops != &ec_google_chromeec_i2c_tunnel_ops) - return false; - - audio_dev = dev_find_matching_device_on_bus(dev->link_list, match_audio_dev); - - if (!audio_dev) - return false; - - return true; -} - /* * This is to allow support for audio on older board versions (< 2). [b/153458561]. This * should be removed once these boards are phased out. @@ -65,9 +16,7 @@ static bool match_audio_tunnel(DEVTREE_CONST struct device *dev) static void update_audio_configuration(void) { uint32_t board_version; - const struct device *lpc_controller; - const struct device *ec_dev; - const struct device *i2c_tunnel_dev; + const struct device *i2c_tunnel_dev = DEV_PTR(audio_rt5682); struct ec_google_chromeec_i2c_tunnel_config *cfg; /* If CBI board version cannot be read, assume this is an older revision of hardware. */ @@ -77,32 +26,7 @@ static void update_audio_configuration(void) if (board_version >= 2) return; - lpc_controller = SOC_LPC_DEV; - if (lpc_controller == NULL) { - printk(BIOS_ERR, "%s: LPC controller device not found!\n", __func__); - return; - } - - ec_dev = dev_find_matching_device_on_bus(lpc_controller->link_list, match_ec_dev); - - if (ec_dev == NULL) { - printk(BIOS_ERR, "%s: EC device not found!\n", __func__); - return; - } - - i2c_tunnel_dev = dev_find_matching_device_on_bus(ec_dev->link_list, match_audio_tunnel); - - if (i2c_tunnel_dev == NULL) { - printk(BIOS_ERR, "%s: I2C tunnel device not found!\n", __func__); - return; - } - - cfg = i2c_tunnel_dev->chip_info; - if (cfg == NULL) { - printk(BIOS_ERR, "%s: I2C tunnel device config not found!\n", __func__); - return; - } - + cfg = config_of(i2c_tunnel_dev); cfg->remote_bus = 5; } |