Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32188
Change subject: WIP: Power resource stub ......................................................................
WIP: Power resource stub
Change-Id: I253a11e24a086792e151c3e47335586d43c3fce0 Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M src/device/device_util.c A src/drivers/generic/power_resource/Kconfig A src/drivers/generic/power_resource/Makefile.inc A src/drivers/generic/power_resource/chip.h A src/drivers/generic/power_resource/power_resource.c M src/drivers/i2c/generic/chip.h M src/drivers/i2c/generic/generic.c M src/include/device/device.h M src/include/device/path.h M src/mainboard/google/hatch/variants/baseboard/devicetree.cb M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.y 14 files changed, 256 insertions(+), 54 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/88/32188/1
diff --git a/src/device/device_util.c b/src/device/device_util.c index 5c4f911..f6474ef 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -232,6 +232,8 @@ snprintf(buffer, sizeof(buffer), "MMIO: %08x", dev->path.mmio.addr); break; + case DEVICE_PATH_POWER_RES: + snprintf(buffer, sizeof(buffer), "POWER_RES"); default: printk(BIOS_ERR, "Unknown device path type: %d\n", dev->path.type); diff --git a/src/drivers/generic/power_resource/Kconfig b/src/drivers/generic/power_resource/Kconfig new file mode 100644 index 0000000..f0d4769 --- /dev/null +++ b/src/drivers/generic/power_resource/Kconfig @@ -0,0 +1,3 @@ +config DRIVERS_GENERIC_POWER_RESOURCE + bool + depends on HAVE_ACPI_TABLES diff --git a/src/drivers/generic/power_resource/Makefile.inc b/src/drivers/generic/power_resource/Makefile.inc new file mode 100644 index 0000000..e076252 --- /dev/null +++ b/src/drivers/generic/power_resource/Makefile.inc @@ -0,0 +1 @@ +ramstage-y += power_resource.c diff --git a/src/drivers/generic/power_resource/chip.h b/src/drivers/generic/power_resource/chip.h new file mode 100644 index 0000000..49ce49f --- /dev/null +++ b/src/drivers/generic/power_resource/chip.h @@ -0,0 +1,51 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __GENERIC_POWER_RESOURCE_CHIP_H__ +#define __GENERIC_POWER_RESOURCE_CHIP_H__ + +#include <arch/acpi_device.h> + +struct drivers_generic_power_resource_config { + /* GPIO used to take device out of reset or to put it into reset. */ + struct acpi_gpio reset_gpio; + /* Delay to be inserted after device is taken out of reset. */ + unsigned int reset_delay_ms; + /* Delay to be inserted after device is put into reset. */ + unsigned int reset_off_delay_ms; + /* GPIO used to enable device. */ + struct acpi_gpio enable_gpio; + /* Delay to be inserted after device is enabled. */ + unsigned int enable_delay_ms; + /* Delay to be inserted after device is disabled. */ + unsigned int enable_off_delay_ms; + /* GPIO used to stop operation of device. */ + struct acpi_gpio stop_gpio; + /* Delay to be inserted after disabling stop. */ + unsigned int stop_delay_ms; + /* Delay to be inserted after enabling stop. */ + unsigned int stop_off_delay_ms; +}; + +#if CONFIG(HAVE_ACPI_TABLES) + +/* + * + */ +void power_resource_generic_fill_ssdt(struct device *dev); + +#endif /* #if CONFIG(HAVE_ACPI_TABLES) */ + +#endif /* __GENERIC_POWER_RESOURCE_CHIP_H__ */ diff --git a/src/drivers/generic/power_resource/power_resource.c b/src/drivers/generic/power_resource/power_resource.c new file mode 100644 index 0000000..13f922e --- /dev/null +++ b/src/drivers/generic/power_resource/power_resource.c @@ -0,0 +1,66 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <device/device.h> +#include <device/path.h> +#include <console/console.h> +#include "chip.h" + +static struct device_operations power_resource_dev_ops = { + .read_resources = DEVICE_NOOP, + .set_resources = DEVICE_NOOP, + .enable_resources = DEVICE_NOOP, + .scan_bus = &scan_generic_bus, + .acpi_fill_ssdt_generator = &power_resource_generic_fill_ssdt +}; + +static void power_resource_dev_enable(struct device *dev) +{ + printk(BIOS_WARNING, "@@ in power_resource_dev_enable\n"); + dev->ops = &power_resource_dev_ops; +} + +struct chip_operations drivers_generic_power_resource_ops = { + CHIP_NAME("Power resource") + .enable_dev = power_resource_dev_enable +}; + +#if CONFIG(HAVE_ACPI_TABLES) + +static void fill_ssdt(struct device *dev, + struct drivers_generic_power_resource_config *config) +{ + const struct acpi_power_res_params power_res_params = { + &config->reset_gpio, + config->reset_delay_ms, + config->reset_off_delay_ms, + &config->enable_gpio, + config->enable_delay_ms, + config->enable_off_delay_ms, + &config->stop_gpio, + config->stop_delay_ms, + config->stop_off_delay_ms + }; + + acpi_device_add_power_res(&power_res_params); +} + +void power_resource_generic_fill_ssdt(struct device *dev) +{ + printk(BIOS_WARNING, "@@ in power_resource fill ssdt\n"); + fill_ssdt(dev, dev->chip_info); +} + +#endif /* CONFIG(HAVE_ACPI_TABLES) */ diff --git a/src/drivers/i2c/generic/chip.h b/src/drivers/i2c/generic/chip.h index 9e2abb9..ec83365 100644 --- a/src/drivers/i2c/generic/chip.h +++ b/src/drivers/i2c/generic/chip.h @@ -50,28 +50,6 @@ /* Disable reset and enable GPIO export in _CRS */ bool disable_gpio_export_in_crs;
- /* Does the device have a power resource? */ - bool has_power_resource; - - /* GPIO used to take device out of reset or to put it into reset. */ - struct acpi_gpio reset_gpio; - /* Delay to be inserted after device is taken out of reset. */ - unsigned int reset_delay_ms; - /* Delay to be inserted after device is put into reset. */ - unsigned int reset_off_delay_ms; - /* GPIO used to enable device. */ - struct acpi_gpio enable_gpio; - /* Delay to be inserted after device is enabled. */ - unsigned int enable_delay_ms; - /* Delay to be inserted after device is disabled. */ - unsigned int enable_off_delay_ms; - /* GPIO used to stop operation of device. */ - struct acpi_gpio stop_gpio; - /* Delay to be inserted after disabling stop. */ - unsigned int stop_delay_ms; - /* Delay to be inserted after enabling stop. */ - unsigned int stop_off_delay_ms; - /* Generic properties for exporting device-specific data to the OS */ struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST]; int property_count; diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c index 598f211..161086e 100644 --- a/src/drivers/i2c/generic/generic.c +++ b/src/drivers/i2c/generic/generic.c @@ -23,19 +23,24 @@ #include <stdint.h> #include <string.h> #include "chip.h" +#include <drivers/generic/power_resource/chip.h>
#if CONFIG(HAVE_ACPI_TABLES)
-static bool i2c_generic_add_gpios_to_crs(struct drivers_i2c_generic_config *cfg) +static bool i2c_generic_add_gpios_to_crs(struct drivers_generic_power_resource_config *pr_config, + struct drivers_i2c_generic_config *cfg) { /* * Return false if: * 1. Request to explicitly disable export of GPIOs in CRS, or * 2. Both reset and enable GPIOs are not provided. */ + if (!pr_config) + return false; + if (cfg->disable_gpio_export_in_crs || - ((cfg->reset_gpio.pin_count == 0) && - (cfg->enable_gpio.pin_count == 0))) + ((pr_config->reset_gpio.pin_count == 0) && + (pr_config->enable_gpio.pin_count == 0))) return false;
return true; @@ -70,6 +75,10 @@ int curr_index = 0; int reset_gpio_index = -1, enable_gpio_index = -1, irq_gpio_index = -1; const char *path = acpi_device_path(dev); + struct device *pr_dev; + struct drivers_generic_power_resource_config *pr_config; + struct acpi_gpio *reset_gpio; + struct acpi_gpio *enable_gpio;
if (!dev->enabled || !scope) return; @@ -79,6 +88,20 @@ return; }
+ /* Check for an associated power resource device */ + if (dev->link_list && dev->link_list->children && + dev->link_list->children->path.type == DEVICE_PATH_POWER_RES) { + pr_dev = dev->link_list->children; + pr_config = pr_dev->chip_info; + reset_gpio = &pr_config->reset_gpio; + enable_gpio = &pr_config->enable_gpio; + } else { + pr_dev = NULL; + pr_config = NULL; + reset_gpio = NULL; + enable_gpio = NULL; + } + /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); @@ -101,10 +124,10 @@ else acpi_device_write_interrupt(&config->irq);
- if (i2c_generic_add_gpios_to_crs(config) == true) { - reset_gpio_index = i2c_generic_write_gpio(&config->reset_gpio, + if (pr_config && i2c_generic_add_gpios_to_crs(pr_config, config) == true) { + reset_gpio_index = i2c_generic_write_gpio(reset_gpio, &curr_index); - enable_gpio_index = i2c_generic_write_gpio(&config->enable_gpio, + enable_gpio_index = i2c_generic_write_gpio(enable_gpio, &curr_index); } acpigen_write_resourcetemplate_footer(); @@ -120,8 +143,15 @@ (reset_gpio_index != -1) || (enable_gpio_index != -1) || (irq_gpio_index != -1)) { dsd = acpi_dp_new_table("_DSD"); + + /* + TODO: tdw + remove this + */ if (config->probed) acpi_dp_add_integer(dsd, "linux,probed", 1); + /* end remove */ + if (irq_gpio_index != -1) acpi_dp_add_gpio(dsd, "irq-gpios", path, irq_gpio_index, 0, @@ -130,11 +160,11 @@ if (reset_gpio_index != -1) acpi_dp_add_gpio(dsd, "reset-gpios", path, reset_gpio_index, 0, - config->reset_gpio.polarity); + reset_gpio->polarity); if (enable_gpio_index != -1) acpi_dp_add_gpio(dsd, "enable-gpios", path, enable_gpio_index, 0, - config->enable_gpio.polarity); + enable_gpio->polarity); /* Add generic property list */ acpi_dp_add_property_list(dsd, config->property_list, config->property_count); @@ -142,20 +172,8 @@ }
/* Power Resource */ - if (config->has_power_resource) { - const struct acpi_power_res_params power_res_params = { - &config->reset_gpio, - config->reset_delay_ms, - config->reset_off_delay_ms, - &config->enable_gpio, - config->enable_delay_ms, - config->enable_off_delay_ms, - &config->stop_gpio, - config->stop_delay_ms, - config->stop_off_delay_ms - }; - acpi_device_add_power_res(&power_res_params); - } + if (pr_dev) + power_resource_generic_fill_ssdt(pr_dev);
/* Callback if any. */ if (callback) diff --git a/src/include/device/device.h b/src/include/device/device.h index 39a4d56..6a24365 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -126,6 +126,7 @@ unsigned int on_mainboard : 1; unsigned int disable_pcie_aspm : 1; unsigned int hidden : 1; /* set if we should hide from UI */ + unsigned int probed : 1; /* set if device's presence should be probed */ struct pci_irq_info pci_irq_info[4]; u8 command;
diff --git a/src/include/device/path.h b/src/include/device/path.h index 6736bed..46180d7 100644 --- a/src/include/device/path.h +++ b/src/include/device/path.h @@ -19,6 +19,7 @@ DEVICE_PATH_SPI, DEVICE_PATH_USB, DEVICE_PATH_MMIO, + DEVICE_PATH_POWER_RES
/* * When adding path types to this table, please also update the @@ -42,6 +43,7 @@ "DEVICE_PATH_SPI", \ "DEVICE_PATH_USB", \ "DEVICE_PATH_MMIO", \ + "DEVICE_PATH_POWER_RES", \ }
struct domain_path { diff --git a/src/mainboard/google/hatch/variants/baseboard/devicetree.cb b/src/mainboard/google/hatch/variants/baseboard/devicetree.cb index 2f1120a..2562cfb 100644 --- a/src/mainboard/google/hatch/variants/baseboard/devicetree.cb +++ b/src/mainboard/google/hatch/variants/baseboard/devicetree.cb @@ -185,11 +185,75 @@ register "wake" = "GPE0_PME_B0" device pci 14.3 on end # CNVi wifi end - device pci 14.5 on end # SDCard - device pci 15.0 on end # I2C #0 - device pci 15.1 on end # I2C #1 - device pci 15.2 on end # I2C #2 - device pci 15.3 on end # I2C #3 + device pci 15.0 on + chip drivers/i2c/generic + register "hid" = ""ELAN0000"" + register "desc" = ""ELAN Touchpad"" + register "irq" = "ACPI_IRQ_EDGE_LOW(GPP_D21_IRQ)" + register "wake" = "GPE0_DW0_21" + device i2c 15 on end + end + end # I2C #0 + device pci 15.1 on + chip drivers/i2c/generic + register "hid" = ""ELAN0001"" + register "desc" = ""ELAN Touchscreen"" + register "irq" = "ACPI_IRQ_EDGE_LOW(GPP_D16_IRQ)" + device i2c 49 on #probed + chip drivers/generic/power_resource + register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_D15)" + register "reset_delay_ms" = "100" + register "reset_off_delay_ms" = "5" + register "stop_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_C4)" + register "stop_off_delay_ms" = "5" + device power_resource 0 on end + end + end + end + end # I2C #1 + device pci 15.2 on + chip drivers/generic/gpio_keys + register "name" = ""PENH"" + register "gpio" = "ACPI_GPIO_INPUT_ACTIVE_HIGH(GPP_A8)" + register "key.dev_name" = ""EJCT"" + register "key.linux_code" = "SW_PEN_INSERTED" + register "key.linux_input_type" = "EV_SW" + register "key.label" = ""pen_eject"" + device generic 0 on end + end + end # I2C #2 + device pci 15.3 on + chip drivers/i2c/sx9310 + register "desc" = ""SAR Proximity Sensor"" + register "irq" = "ACPI_IRQ_LEVEL_LOW(GPP_A0_IRQ)" + register "speed" = "I2C_SPEED_FAST" + register "uid" = "1" + register "reg_prox_ctrl0" = "0x10" + register "reg_prox_ctrl1" = "0x00" + register "reg_prox_ctrl2" = "0x84" + register "reg_prox_ctrl3" = "0x0e" + register "reg_prox_ctrl4" = "0x07" + register "reg_prox_ctrl5" = "0xc6" + register "reg_prox_ctrl6" = "0x20" + register "reg_prox_ctrl7" = "0x0d" + register "reg_prox_ctrl8" = "0x8d" + register "reg_prox_ctrl9" = "0x43" + register "reg_prox_ctrl10" = "0x1f" + register "reg_prox_ctrl11" = "0x00" + register "reg_prox_ctrl12" = "0x00" + register "reg_prox_ctrl13" = "0x00" + register "reg_prox_ctrl14" = "0x00" + register "reg_prox_ctrl15" = "0x00" + register "reg_prox_ctrl16" = "0x00" + register "reg_prox_ctrl17" = "0x00" + register "reg_prox_ctrl18" = "0x00" + register "reg_prox_ctrl19" = "0x00" + register "reg_sar_ctrl0" = "0x50" + register "reg_sar_ctrl1" = "0x8a" + register "reg_sar_ctrl2" = "0x3c" + device i2c 28 on end + end + end # I2C #3 device pci 16.0 on end # Management Engine Interface 1 device pci 16.1 off end # Management Engine Interface 2 device pci 16.2 off end # Management Engine IDE-R diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 4ac935e..c66e66e 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -511,8 +511,17 @@ sprintf(name, "_dev%d", new_d->id); new_d->name = name;
- new_d->enabled = status & 0x01; - new_d->hidden = (status >> 1) & 0x01; + /* probed? */ + if (status == 2) { + new_d->probed = 1; + new_d->enabled = 0; + new_d->hidden = 0; + } else { + new_d->enabled = status & 0x01; + new_d->hidden = (status >> 1) & 0x01; + new_d->probed = 0; + } + new_d->chip_instance = chip_instance; chip_instance->ref_count++;
@@ -566,6 +575,9 @@ case MMIO: new_d->path = ".type=DEVICE_PATH_MMIO,{.mmio={ .addr = 0x%x }}"; break; + + case POWER_RESOURCE: + new_d->path = ".type=DEVICE_PATH_POWER_RES,"; }
return new_d; @@ -789,6 +801,7 @@ fprintf(fil, "},\n"); fprintf(fil, "\t.enabled = %d,\n", ptr->enabled); fprintf(fil, "\t.hidden = %d,\n", ptr->hidden); + fprintf(fil, "\t.probed = %d,\n", ptr->probed); fprintf(fil, "\t.on_mainboard = 1,\n"); if (ptr->subsystem_vendor > 0) fprintf(fil, "\t.subsystem_vendor = 0x%04x,\n", diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index 389d697..5aae51ad 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -102,9 +102,10 @@ /* Monotonically increasing ID for the device. */ int id;
- /* Indicates device status (enabled / hidden or not). */ + /* Indicates device status (enabled / hidden / probed or not). */ int enabled; int hidden; + int probed;
/* Subsystem IDs for the device. */ int subsystem_vendor; diff --git a/util/sconfig/sconfig.l b/util/sconfig/sconfig.l index b21cca5..32ecd57 100755 --- a/util/sconfig/sconfig.l +++ b/util/sconfig/sconfig.l @@ -29,11 +29,13 @@ register {return(REGISTER);} on {yylval.number=1; return(BOOL);} off {yylval.number=0; return(BOOL);} +probed {yylval.number=2; return(PROBED);} hidden {yylval.number=3; return(HIDDEN);} pci {yylval.number=PCI; return(BUS);} ioapic {yylval.number=IOAPIC; return(BUS);} pnp {yylval.number=PNP; return(BUS);} i2c {yylval.number=I2C; return(BUS);} +power_resource {yylval.number=POWER_RESOURCE; return(BUS);} lapic {yylval.number=APIC; return(BUS);} cpu_cluster {yylval.number=CPU_CLUSTER; return(BUS);} cpu {yylval.number=CPU; return(BUS);} diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y index 3a6e9ab..ce0f111 100755 --- a/util/sconfig/sconfig.y +++ b/util/sconfig/sconfig.y @@ -31,7 +31,7 @@ int number; }
-%token CHIP DEVICE REGISTER BOOL HIDDEN BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO +%token CHIP DEVICE REGISTER BOOL HIDDEN PROBED BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO POWER_RESOURCE %% devtree: { cur_parent = root_parent; } chip;
@@ -56,7 +56,7 @@ cur_parent = $<dev>5->parent; };
-status: BOOL | HIDDEN; +status: BOOL | HIDDEN | PROBED;
resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */ { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
Tim Wawrzynczak has removed Martin Roth from this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Removed reviewer Martin Roth.
Tim Wawrzynczak has removed Patrick Georgi from this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Removed reviewer Patrick Georgi.
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 1:
(4 comments)
https://review.coreboot.org/#/c/32188/1/src/drivers/generic/power_resource/p... File src/drivers/generic/power_resource/power_resource.c:
https://review.coreboot.org/#/c/32188/1/src/drivers/generic/power_resource/p... PS1, Line 31: printk(BIOS_WARNING, "@@ in power_resource_dev_enable\n"); Prefer using '"%s...", __func__' to using 'power_resource_dev_enable', this function's name, in a string
https://review.coreboot.org/#/c/32188/1/src/drivers/i2c/generic/generic.c File src/drivers/i2c/generic/generic.c:
https://review.coreboot.org/#/c/32188/1/src/drivers/i2c/generic/generic.c@30 PS1, Line 30: static bool i2c_generic_add_gpios_to_crs(struct drivers_generic_power_resource_config *pr_config, line over 80 characters
https://review.coreboot.org/#/c/32188/1/src/drivers/i2c/generic/generic.c@12... PS1, Line 127: if (pr_config && i2c_generic_add_gpios_to_crs(pr_config, config) == true) { line over 80 characters
https://review.coreboot.org/#/c/32188/1/src/include/device/device.h File src/include/device/device.h:
https://review.coreboot.org/#/c/32188/1/src/include/device/device.h@129 PS1, Line 129: unsigned int probed : 1; /* set if device's presence should be probed */ line over 80 characters
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 1:
Here's what I have so far w/r/t coreboot Device Probing
https://docs.google.com/document/d/1Fiy2W5mCRwDbhza6dGG98n08H6DhUap8hUdqzr8M...
If you have a chance to take a look and see what I have so far, please let me know!
Paul Fagerburg has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/32188/1/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/#/c/32188/1/util/sconfig/main.c@514 PS1, Line 514: /* probed? */ Please explain in more detail why status==2 gets treated specially, rather than extracting bits from the value as happens in the 'else' clause.
Hello Paul Fagerburg, Shelley Chen, build bot (Jenkins), Furquan Shaikh, Martin Roth, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32188
to look at the new patch set (#2).
Change subject: WIP: Power resource stub ......................................................................
WIP: Power resource stub
Currently: 1) Bootblock reset deassertion is done. 2) Power resource implementation: a) sconfig is DONE b) i2c generic is DONE c) power_resource is DONE d) ... others are TODO 3) Initial probing implementation is functional a) scans busses for probed devices b) calls get_probe_info() c) for i2c generic, calls fake i2c probe to verify it works.
Change-Id: I253a11e24a086792e151c3e47335586d43c3fce0 Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M src/device/device_const.c M src/device/device_util.c A src/drivers/generic/power_resource/Kconfig A src/drivers/generic/power_resource/Makefile.inc A src/drivers/generic/power_resource/chip.h A src/drivers/generic/power_resource/power_resource.c A src/drivers/generic/power_resource/power_resource.h M src/drivers/i2c/generic/chip.h M src/drivers/i2c/generic/generic.c M src/include/device/device.h M src/include/device/path.h A src/include/device_power.h A src/include/power_resource.h M src/lib/Makefile.inc M src/lib/bootblock.c A src/lib/device_power.c M src/mainboard/google/hatch/variants/baseboard/devicetree.cb M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.y 21 files changed, 396 insertions(+), 54 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/88/32188/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
(4 comments)
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c File src/drivers/i2c/generic/generic.c:
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c@31 PS2, Line 31: static bool i2c_generic_add_gpios_to_crs(struct drivers_generic_power_resource_config *pr_config, line over 80 characters
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c@12... PS2, Line 128: if (pr_config && i2c_generic_add_gpios_to_crs(pr_config, config) == true) { line over 80 characters
https://review.coreboot.org/#/c/32188/2/src/include/device/device.h File src/include/device/device.h:
https://review.coreboot.org/#/c/32188/2/src/include/device/device.h@129 PS2, Line 129: unsigned int probed : 1; /* set if device's presence should be probed */ line over 80 characters
https://review.coreboot.org/#/c/32188/2/src/lib/bootblock.c File src/lib/bootblock.c:
https://review.coreboot.org/#/c/32188/2/src/lib/bootblock.c@66 PS2, Line 66: /* walk the device tree and enable devices that contain power resources */ line over 80 characters
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
(21 comments)
This CL should be broken down into multiple smaller CLs:
1. Adding probed property to sconfig to support probed devices 2. Adding power resource device to device tree 3. Adding power resource driver for ACPI 4. Adding helper function for enabling power in bootblock 5. Moving all mainboards using power resource to the newly added device 6. Get rid of power resource properties from I2C generic and SPI devices. 7. Get rid of probed property
https://review.coreboot.org/#/c/32188/2/src/device/device_const.c File src/device/device_const.c:
https://review.coreboot.org/#/c/32188/2/src/device/device_const.c@94 PS2, Line 94: ) || !filter
https://review.coreboot.org/#/c/32188/2/src/device/device_const.c@183 PS2, Line 183: 0 This should use the power resource instance for comparison.
https://review.coreboot.org/#/c/32188/2/src/device/device_util.c File src/device/device_util.c:
https://review.coreboot.org/#/c/32188/2/src/device/device_util.c@236 PS2, Line 236: snprintf(buffer, sizeof(buffer), "POWER_RES"); break;
https://review.coreboot.org/#/c/32188/2/src/device/device_util.c@236 PS2, Line 236: " print power resource instance as well.
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/M... File src/drivers/generic/power_resource/Makefile.inc:
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/M... PS2, Line 1: y $(DRIVERS_GENERIC_POWER_RESOURCE)
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/c... File src/drivers/generic/power_resource/chip.h:
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/c... PS2, Line 19: device_power Why is this required?
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/c... PS2, Line 21: #if CONFIG(HAVE_ACPI_TABLES) No need to guard.
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/c... PS2, Line 22: You will need a config structure to associate with this device.
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/c... PS2, Line 23: power_resource_fill_ssdt Can you please provide some description as to what this function does?
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/p... File src/drivers/generic/power_resource/power_resource.h:
PS2: Why is this file required when there is a chip.h?
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/p... File src/drivers/generic/power_resource/power_resource.c:
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/p... PS2, Line 26: #if CONFIG(HAVE_ACPI_TABLES) This file should be compiled in only if HAVE_ACPI_TABLES is enabled. No need to guard here.
https://review.coreboot.org/#/c/32188/2/src/drivers/generic/power_resource/p... PS2, Line 48: fill_ssdt Why not just add the content of fill_ssdt here directly?
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/chip.h File src/drivers/i2c/generic/chip.h:
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/chip.h@a53 PS2, Line 53: This change needs to be done in multiple CLs: 1. Add power resource device in one CL 2. Move all mainboards using power resource to use the new device in next 3. Remove these objects in next CL
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c File src/drivers/i2c/generic/generic.c:
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c@27 PS2, Line 27: power_resource.h> Just include chip.h here
https://review.coreboot.org/#/c/32188/2/src/drivers/i2c/generic/generic.c@12... PS2, Line 128: pr_config && pr_config is already checked for NULL in i2c_generic_add_gpios_to_crs.
https://review.coreboot.org/#/c/32188/2/src/include/device_power.h File src/include/device_power.h:
PS2: Why is this file required? Definition for drivers_generic_power_resource_config should be part of chip.h in device/power_resource
https://review.coreboot.org/#/c/32188/2/src/lib/bootblock.c File src/lib/bootblock.c:
https://review.coreboot.org/#/c/32188/2/src/lib/bootblock.c@34 PS2, Line 34: enable_power_resources I think it would be better to guard this with a special Kconfig so that it is done only on boards that need it.
https://review.coreboot.org/#/c/32188/2/src/lib/bootblock.c@36 PS2, Line 36: power_resource_deassert_reset First step should be to enable power in bootblock. Deassert reset needs to happen in ramstage before probing.
https://review.coreboot.org/#/c/32188/2/src/lib/device_power.c File src/lib/device_power.c:
https://review.coreboot.org/#/c/32188/2/src/lib/device_power.c@21 PS2, Line 21: power_resource_deassert_reset This function should enable power to the device.
https://review.coreboot.org/#/c/32188/2/src/lib/device_power.c@34 PS2, Line 34: if (dev->link_list->children->path.type != : DEVICE_PATH_POWER_RES) It would be better to scan through all children of current device to find the power resource.
https://review.coreboot.org/#/c/32188/2/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/#/c/32188/2/util/sconfig/main.c@518 PS2, Line 518: 2 bit 1 is used by hidden property. So, this won't work. Also, why does this override enabled and hidden?
I think it would be better to use bit 2 for probed and continue using bit 0 for on/off and bit 1 for hidden. And if device status is probed, you can set it to on = 1 and probed = 1 which would set enabled and probed flags. Later after probing if device is not found then enabled can be set to 0.
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
Patch Set 2:
(21 comments)
This CL should be broken down into multiple smaller CLs:
- Adding probed property to sconfig to support probed devices
- Adding power resource device to device tree
- Adding power resource driver for ACPI
- Adding helper function for enabling power in bootblock
- Moving all mainboards using power resource to the newly added device
- Get rid of power resource properties from I2C generic and SPI devices.
- Get rid of probed property
If power is enabled in bootblock, and probing is done in ramstage, when is the appropriate time to deassert reset?
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
Patch Set 2:
Patch Set 2:
(21 comments)
This CL should be broken down into multiple smaller CLs:
- Adding probed property to sconfig to support probed devices
- Adding power resource device to device tree
- Adding power resource driver for ACPI
- Adding helper function for enabling power in bootblock
- Moving all mainboards using power resource to the newly added device
- Get rid of power resource properties from I2C generic and SPI devices.
- Get rid of probed property
If power is enabled in bootblock, and probing is done in ramstage, when is the appropriate time to deassert reset?
I think typically it is the reset time which is longer? i.e. enable time is typically 1 or 2ms I believe? If that is correct, then I would expect reset to be de-asserted in bootblock too.
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
Patch Set 2:
Patch Set 2:
(21 comments)
This CL should be broken down into multiple smaller CLs:
- Adding probed property to sconfig to support probed devices
- Adding power resource device to device tree
- Adding power resource driver for ACPI
- Adding helper function for enabling power in bootblock
- Moving all mainboards using power resource to the newly added device
- Get rid of power resource properties from I2C generic and SPI devices.
- Get rid of probed property
If power is enabled in bootblock, and probing is done in ramstage, when is the appropriate time to deassert reset?
So you think it would be appropriate to assert enable GPIOs first, then sleep() until the max() of the enable times has elapsed, and then deassert resets?
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Patch Set 2:
Patch Set 2:
Patch Set 2:
Patch Set 2:
(21 comments)
This CL should be broken down into multiple smaller CLs:
- Adding probed property to sconfig to support probed devices
- Adding power resource device to device tree
- Adding power resource driver for ACPI
- Adding helper function for enabling power in bootblock
- Moving all mainboards using power resource to the newly added device
- Get rid of power resource properties from I2C generic and SPI devices.
- Get rid of probed property
If power is enabled in bootblock, and probing is done in ramstage, when is the appropriate time to deassert reset?
So you think it would be appropriate to assert enable GPIOs first, then sleep() until the max() of the enable times has elapsed, and then deassert resets?
Yes. grepping for enable_delay_ms in coreboot and ignoring the values of 1:
git grep ""enable_delay_ms"" | grep -v "1" src/mainboard/google/octopus/variants/bobba/overridetree.cb: register "enable_delay_ms" = "50" src/mainboard/google/octopus/variants/phaser/overridetree.cb: register "enable_delay_ms" = "50" src/mainboard/google/poppy/variants/baseboard/devicetree.cb: register "enable_delay_ms" = "250" src/mainboard/google/poppy/variants/nami/devicetree.cb: register "enable_delay_ms" = "5" src/mainboard/google/reef/variants/coral/devicetree.cb: register "enable_delay_ms" = "50" src/mainboard/google/reef/variants/snappy/devicetree.cb: register "enable_delay_ms" = "5" src/mainboard/google/reef/variants/snappy/devicetree.cb: register "enable_delay_ms" = "50" src/mainboard/google/sarien/variants/sarien/devicetree.cb: register "enable_delay_ms" = "5"
Looking closely at each of these, I think most of them are incorrect configurations. Same device is being used on other mainboards with enable delay of 1. I understand it is difficult to predict what a device in future would require for enable delay, but sprinkling the logic in more places seems to make it just more complicated than necessary. Thoughts?
Tim Wawrzynczak has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/32188 )
Change subject: WIP: Power resource stub ......................................................................
Abandoned