mb/google/zork: Switch to using device pointers

This change replaces the device tree walks with device pointers by
using alias for following devices:
1. audio_rt5682
2. xhci0_bt
3. xhci1_bt
4. acp_machine
5. i2c2

Change-Id: I56921ab54716e4d771d9de1a479f191ca5657eba
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57845
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Furquan Shaikh
2021-09-22 13:32:34 -07:00
committed by Paul Fagerburg
parent 6fa72c7f4c
commit 0f73791606
4 changed files with 17 additions and 216 deletions

View File

@ -296,7 +296,7 @@ chip soc/amd/picasso
register "desc" = ""Bluetooth"" register "desc" = ""Bluetooth""
register "type" = "UPC_TYPE_INTERNAL" register "type" = "UPC_TYPE_INTERNAL"
register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_143)" 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 end
chip drivers/usb/acpi chip drivers/usb/acpi
register "desc" = ""Left Type-C Port"" register "desc" = ""Left Type-C Port""
@ -338,7 +338,7 @@ chip soc/amd/picasso
# Set low (0) = Select DMIC0 # Set low (0) = Select DMIC0
# Set high (1) = Select DMIC1 # Set high (1) = Select DMIC1
register "dmic_select_gpio" = "ACPI_GPIO_OUTPUT(GPIO_67)" 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
end # Audio end # Audio
device ref hda off end # HDA 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].type" = "ACPI_DP_TYPE_STRING"
register "property_list[1].name" = ""realtek,mclk-name"" register "property_list[1].name" = ""realtek,mclk-name""
register "property_list[1].string" = ""oscout1"" register "property_list[1].string" = ""oscout1""
device i2c 1a on end device i2c 1a alias audio_rt5682 on end
end end
end end
end end

View File

@ -321,7 +321,7 @@ chip soc/amd/picasso
register "desc" = ""Bluetooth"" register "desc" = ""Bluetooth""
register "type" = "UPC_TYPE_INTERNAL" register "type" = "UPC_TYPE_INTERNAL"
register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_14)" 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 end
end end
@ -341,7 +341,7 @@ chip soc/amd/picasso
register "desc" = ""Bluetooth"" register "desc" = ""Bluetooth""
register "type" = "UPC_TYPE_INTERNAL" register "type" = "UPC_TYPE_INTERNAL"
register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_14)" 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 end
chip drivers/usb/acpi chip drivers/usb/acpi
register "desc" = ""World-Facing Camera"" register "desc" = ""World-Facing Camera""
@ -364,7 +364,7 @@ chip soc/amd/picasso
# Set low (0) = Select DMIC0 # Set low (0) = Select DMIC0
# Set high (1) = Select DMIC1 # Set high (1) = Select DMIC1
register "dmic_select_gpio" = "ACPI_GPIO_OUTPUT(GPIO_67)" 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
end # Audio end # Audio
device ref hda off end # HDA 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].type" = "ACPI_DP_TYPE_STRING"
register "property_list[1].name" = ""realtek,mclk-name"" register "property_list[1].name" = ""realtek,mclk-name""
register "property_list[1].string" = ""oscout1"" register "property_list[1].string" = ""oscout1""
device i2c 1a on end device i2c 1a alias audio_rt5682 on end
end end
end end
end end

View File

@ -13,34 +13,14 @@
#include <soc/iomap.h> #include <soc/iomap.h>
#include <soc/pci_devs.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_generic_ops;
extern struct chip_operations drivers_i2c_hid_ops; extern struct chip_operations drivers_i2c_hid_ops;
WEAK_DEV_PTR(xhci1_bt);
static void update_hp_int_odl(void) static void update_hp_int_odl(void)
{ {
static const struct device_path rt5682_path[] = { const struct device *rt5682_dev = DEV_PTR(audio_rt5682);
{
.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;
struct drivers_i2c_generic_config *cfg; struct drivers_i2c_generic_config *cfg;
struct acpi_gpio *gpio; struct acpi_gpio *gpio;
struct soc_amd_picasso_config *soc_cfg; struct soc_amd_picasso_config *soc_cfg;
@ -48,19 +28,6 @@ static void update_hp_int_odl(void)
if (!variant_uses_codec_gpi()) if (!variant_uses_codec_gpi())
return; 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); cfg = config_of(rt5682_dev);
gpio = &cfg->irq_gpio; gpio = &cfg->irq_gpio;
gpio->pins[0] = 62; gpio->pins[0] = 62;
@ -76,41 +43,13 @@ static void update_hp_int_odl(void)
static void update_dmic_gpio(void) static void update_dmic_gpio(void)
{ {
static const struct device_path acp_machine_path[] = { const struct device *machine_dev = DEV_PTR(acp_machine);
{
.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;
struct drivers_amd_i2s_machine_dev_config *cfg; struct drivers_amd_i2s_machine_dev_config *cfg;
struct acpi_gpio *gpio; struct acpi_gpio *gpio;
if (variant_uses_v3_schematics()) if (variant_uses_v3_schematics())
return; 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); cfg = config_of(machine_dev);
gpio = &cfg->dmic_select_gpio; gpio = &cfg->dmic_select_gpio;
@ -132,18 +71,10 @@ void variant_audio_update(void)
* *
* debug_device_name is used for debug messaging only. * debug_device_name is used for debug messaging only.
*/ */
static void remove_usb_device_reset_gpio(const struct device_path usb_path[], static void remove_usb_device_reset_gpio(const struct device *usb_dev)
size_t path_length, const char *debug_device_name)
{ {
const struct device *usb_dev;
struct drivers_usb_acpi_config *usb_cfg; 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 */ /* config_of dies on failure, so a NULL check is not required */
usb_cfg = config_of(usb_dev); usb_cfg = config_of(usb_dev);
usb_cfg->reset_gpio.pin_count = 0; 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 void baseboard_trembyle_remove_bluetooth_reset_gpio(void)
{ {
static const struct device_path xhci0_bt_path[] = { remove_usb_device_reset_gpio(DEV_PTR(xhci0_bt));
{ remove_usb_device_reset_gpio(DEV_PTR(xhci1_bt));
.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");
} }
void variant_bluetooth_update(void) void variant_bluetooth_update(void)
@ -212,7 +100,7 @@ void variant_bluetooth_update(void)
void variant_touchscreen_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; struct device *child = NULL;
/* /*
@ -227,17 +115,6 @@ void variant_touchscreen_update(void)
if (variant_uses_v3_6_schematics()) if (variant_uses_v3_6_schematics())
return; 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) { while ((child = dev_bus_each_child(mmio_dev->link_list, child)) != NULL) {
struct drivers_i2c_generic_config *cfg; struct drivers_i2c_generic_config *cfg;

View File

@ -3,61 +3,12 @@
#include <baseboard/variants.h> #include <baseboard/variants.h>
#include <console/console.h> #include <console/console.h>
#include <device/device.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/ec.h>
#include <ec/google/chromeec/i2c_tunnel/chip.h> #include <ec/google/chromeec/i2c_tunnel/chip.h>
#include <string.h> #include <string.h>
#define EC_PNP_ID 0x0c09
#define DALBOZ_DB_USBC 0x0
#define DALBOZ_DB_HDMI 0x1 #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 * This is to allow support for audio on older board versions (< 2). [b/153458561]. This
* should be removed once these boards are phased out. * 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) static void update_audio_configuration(void)
{ {
uint32_t board_version; uint32_t board_version;
const struct device *lpc_controller; const struct device *i2c_tunnel_dev = DEV_PTR(audio_rt5682);
const struct device *ec_dev;
const struct device *i2c_tunnel_dev;
struct ec_google_chromeec_i2c_tunnel_config *cfg; struct ec_google_chromeec_i2c_tunnel_config *cfg;
/* If CBI board version cannot be read, assume this is an older revision of hardware. */ /* 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) if (board_version >= 2)
return; return;
lpc_controller = SOC_LPC_DEV; cfg = config_of(i2c_tunnel_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->remote_bus = 5; cfg->remote_bus = 5;
} }