Rob Barnes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43777 )
Change subject: mb/google/zork: Remove reset_gpio from bt when not supported ......................................................................
mb/google/zork: Remove reset_gpio from bt when not supported
Remove bluetooth reset_gpio when not supported on a specfic board variant.
BUG=b:157580724 TEST=Boot dalboz, observe log
Signed-off-by: Rob Barnes robbarnes@google.com Change-Id: I64f100645dcab947bb45dbf8e8617fbef16dcb8a --- M src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c M src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c M src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h M src/mainboard/google/zork/variants/berknip/Makefile.inc A src/mainboard/google/zork/variants/berknip/variant.c M src/mainboard/google/zork/variants/dalboz/variant.c M src/mainboard/google/zork/variants/ezkinil/variant.c M src/mainboard/google/zork/variants/morphius/Makefile.inc A src/mainboard/google/zork/variants/morphius/variant.c M src/mainboard/google/zork/variants/trembyle/Makefile.inc A src/mainboard/google/zork/variants/trembyle/variant.c 11 files changed, 221 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/43777/1
diff --git a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c index 5568194..8557e6d 100644 --- a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c +++ b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c @@ -1,9 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <baseboard/variants.h> +#include <console/console.h> #include <delay.h> +#include <device/device.h> +#include <drivers/usb/acpi/chip.h> #include <gpio.h> #include <soc/gpio.h> +#include <soc/pci_devs.h> #include <soc/smi.h> #include <stdlib.h> #include <boardid.h> @@ -311,3 +315,45 @@ *size = ARRAY_SIZE(gpio_sleep_table); return gpio_sleep_table; } + +#if !DEVTREE_EARLY +static const struct device_path bt_dev_path[] = { + { + // BUS A + .type = DEVICE_PATH_PCI, + .pci.devfn = PCIE_GPP_A_DEVFN + }, + { + // XHCI0 + .type = DEVICE_PATH_PCI, + .pci.devfn = XHCI0_DEVFN + }, + { + // USB HUB + .type = DEVICE_PATH_USB, + .usb.port_type = 0, + .usb.port_id = 0 + }, + { + // USB Bluetooth Device + .type = DEVICE_PATH_USB, + .usb.port_type = 2, + .usb.port_id = 5 + } +}; + +/* Removes reset_gpio from bluetooth device in device tree */ +void baseboard_remove_bluetooth_reset_gpio(void) +{ + const struct device *bt_dev; + struct drivers_usb_acpi_config *bt_cfg; + + bt_dev = find_dev_nested_path(pci_root_bus(), bt_dev_path, ARRAY_SIZE(bt_dev_path)); + if (!bt_dev) { + printk(BIOS_ERR, "%s: Failed to find bluetooth device!", __func__); + return; + } + bt_cfg = config_of(bt_dev); + bt_cfg->reset_gpio.pin_count=0; +} +#endif /* !DEVTREE_EARLY */ \ No newline at end of file diff --git a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c index c10c9f4..5247935 100644 --- a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c +++ b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c @@ -1,14 +1,19 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <baseboard/variants.h> +#include <console/console.h> #include <delay.h> +#include <device/device.h> +#include <drivers/usb/acpi/chip.h> #include <gpio.h> #include <soc/gpio.h> +#include <soc/pci_devs.h> #include <soc/smi.h> #include <stdlib.h> #include <boardid.h> #include <variant/gpio.h>
+ static const struct soc_amd_gpio gpio_set_stage_ram[] = { /* PWR_BTN_L */ PAD_NF(GPIO_0, PWR_BTN_L, PULL_NONE), @@ -312,3 +317,78 @@ *size = ARRAY_SIZE(gpio_sleep_table); return gpio_sleep_table; } + +#if !DEVTREE_EARLY +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 + } +}; + +/* + * Removes reset_gpio from bluetooth device in device tree. + * + * The bluetooth device may be on XHCI0 or XHCI1 depending on SOC. + * There's no harm in removing from both here. + */ +void baseboard_remove_bluetooth_reset_gpio(void) +{ + const struct device *xhci0_bt_dev, *xhci1_bt_dev; + struct drivers_usb_acpi_config *xhci0_bt_cfg, *xhci1_bt_cfg; + + xhci0_bt_dev = find_dev_nested_path(pci_root_bus(), xhci0_bt_path, ARRAY_SIZE(xhci0_bt_path)); + if (!xhci0_bt_dev) { + printk(BIOS_ERR, "%s: Failed to find bluetooth device on XHCI0!", __func__); + return; + } + xhci1_bt_dev = find_dev_nested_path(pci_root_bus(), xhci1_bt_path, ARRAY_SIZE(xhci1_bt_path)); + if (!xhci1_bt_dev) { + printk(BIOS_ERR, "%s: Failed to find bluetooth device on XHCI1!", __func__); + return; + } + + /* config_of dies on failure, so no NULL check on return */ + xhci0_bt_cfg = config_of(xhci0_bt_dev); + xhci1_bt_cfg = config_of(xhci1_bt_dev); + + xhci0_bt_cfg->reset_gpio.pin_count = 0; + xhci1_bt_cfg->reset_gpio.pin_count = 0; +} + +#endif /* !DEVTREE_EARLY */ \ No newline at end of file diff --git a/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h index aa1a3c8..54327d4 100644 --- a/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h @@ -67,4 +67,7 @@ /* Return true if variant has active low power enable fow WiFi. */ bool variant_has_active_low_wifi_power(void);
+/* Removes reset gpio from bluetooth device in device tree */ +void baseboard_remove_bluetooth_reset_gpio(void); + #endif /* __BASEBOARD_VARIANTS_H__ */ diff --git a/src/mainboard/google/zork/variants/berknip/Makefile.inc b/src/mainboard/google/zork/variants/berknip/Makefile.inc index 57e7136..51d19fe 100644 --- a/src/mainboard/google/zork/variants/berknip/Makefile.inc +++ b/src/mainboard/google/zork/variants/berknip/Makefile.inc @@ -3,3 +3,4 @@ subdirs-y += ./spd
ramstage-y += gpio.c +ramstage-y += variant.c diff --git a/src/mainboard/google/zork/variants/berknip/variant.c b/src/mainboard/google/zork/variants/berknip/variant.c new file mode 100644 index 0000000..f56e2c3 --- /dev/null +++ b/src/mainboard/google/zork/variants/berknip/variant.c @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <baseboard/gpio.h> +#include <baseboard/variants.h> +#include <ec/google/chromeec/ec.h> + +static void update_bluetooth_configuration(void) +{ + uint32_t board_version; + + if (google_chromeec_cbi_get_board_version(&board_version)) + board_version = 1; + + if (board_version <= 1) { + baseboard_remove_bluetooth_reset_gpio(); + } +} + +void variant_devtree_update(void) +{ + update_bluetooth_configuration(); +} \ No newline at end of file diff --git a/src/mainboard/google/zork/variants/dalboz/variant.c b/src/mainboard/google/zork/variants/dalboz/variant.c index 0212161..1874aa0 100644 --- a/src/mainboard/google/zork/variants/dalboz/variant.c +++ b/src/mainboard/google/zork/variants/dalboz/variant.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <baseboard/variants.h> +#include <baseboard/gpio.h> #include <console/console.h> #include <device/device.h> #include <drivers/i2c/generic/chip.h> @@ -104,6 +105,18 @@ cfg->remote_bus = 5; }
+static void update_bluetooth_configuration(void) +{ + uint32_t board_version; + + if (google_chromeec_cbi_get_board_version(&board_version)) + board_version = 1; + + if (board_version <= 1) { + baseboard_remove_bluetooth_reset_gpio(); + } +} + static int sku_has_emmc(void) { uint32_t board_sku = sku_id(); @@ -135,6 +148,7 @@ }
update_audio_configuration(); + update_bluetooth_configuration(); }
/* FIXME: Comments seem to suggest these are not entirely correct. */ diff --git a/src/mainboard/google/zork/variants/ezkinil/variant.c b/src/mainboard/google/zork/variants/ezkinil/variant.c index d7cf5a8..c10aa5c 100644 --- a/src/mainboard/google/zork/variants/ezkinil/variant.c +++ b/src/mainboard/google/zork/variants/ezkinil/variant.c @@ -23,6 +23,17 @@ return 0; }
+static void update_bluetooth_configuration(void) +{ + uint32_t board_version; + if (google_chromeec_cbi_get_board_version(&board_version)) + board_version = 1; + + if (board_version <= 1) { + baseboard_remove_bluetooth_reset_gpio(); + } +} + void variant_devtree_update(void) { struct soc_amd_picasso_config *cfg; @@ -31,4 +42,6 @@
if (!sku_has_emmc()) cfg->sd_emmc_config = SD_EMMC_DISABLE; + + update_bluetooth_configuration(); } diff --git a/src/mainboard/google/zork/variants/morphius/Makefile.inc b/src/mainboard/google/zork/variants/morphius/Makefile.inc index 57e7136..51d19fe 100644 --- a/src/mainboard/google/zork/variants/morphius/Makefile.inc +++ b/src/mainboard/google/zork/variants/morphius/Makefile.inc @@ -3,3 +3,4 @@ subdirs-y += ./spd
ramstage-y += gpio.c +ramstage-y += variant.c diff --git a/src/mainboard/google/zork/variants/morphius/variant.c b/src/mainboard/google/zork/variants/morphius/variant.c new file mode 100644 index 0000000..ccbace2 --- /dev/null +++ b/src/mainboard/google/zork/variants/morphius/variant.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <baseboard/gpio.h> +#include <baseboard/variants.h> +#include <ec/google/chromeec/ec.h> + +static void update_bluetooth_configuration() { + uint32_t board_version; + + if (google_chromeec_cbi_get_board_version(&board_version)) + board_version = 1; + + if (board_version <= 2) { + baseboard_remove_bluetooth_reset_gpio(); + } +} + +void variant_devtree_update(void) +{ + update_bluetooth_configuration(); +} diff --git a/src/mainboard/google/zork/variants/trembyle/Makefile.inc b/src/mainboard/google/zork/variants/trembyle/Makefile.inc index 0b6bc4b..7f94d3c 100644 --- a/src/mainboard/google/zork/variants/trembyle/Makefile.inc +++ b/src/mainboard/google/zork/variants/trembyle/Makefile.inc @@ -3,3 +3,4 @@ subdirs-y += ../baseboard/spd
ramstage-y += gpio.c +ramstate-y += variant.c diff --git a/src/mainboard/google/zork/variants/trembyle/variant.c b/src/mainboard/google/zork/variants/trembyle/variant.c new file mode 100644 index 0000000..69a4b35 --- /dev/null +++ b/src/mainboard/google/zork/variants/trembyle/variant.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <baseboard/gpio.h> +#include <baseboard/variants.h> +#include <ec/google/chromeec/ec.h> + +static void update_bluetooth_configuration(void) { + if (google_chromeec_cbi_get_board_version(&board_version)) + board_version = 1; + + if (board_version <= 1) { + baseboard_remove_bluetooth_reset_gpio(); + } +} + +void variant_devtree_update(void) +{ + update_bluetooth_configuration(); +}