From e98bc0e02ab2f4f2a5189090536e46c544b0bb5e Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sun, 11 Jan 2026 11:37:06 +0100 Subject: [PATCH] ec/lenovo/h8: Properly advertised used I/O Properly advertise I/O ports decoded by H8 and PMH7. Therefore implement read_resources() and set_resources() in coreboot and advertise the ports using ACPI. TEST=I/O ports are properly seen as fixed and assigned in coreboot and the OS. Change-Id: Iae1b72d2d565750020f2943804165b9d5d2efdfb Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/90723 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/ec/lenovo/h8/acpi/ec.asl | 49 ++++++++++++++++++++++++++++++++++++ src/ec/lenovo/h8/h8.c | 11 ++++++++ src/ec/lenovo/pmh7/pmh7.c | 21 ++++++++++------ src/ec/lenovo/pmh7/pmh7.h | 2 -- 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/src/ec/lenovo/h8/acpi/ec.asl b/src/ec/lenovo/h8/acpi/ec.asl index bc54d3b422..fe39c19761 100644 --- a/src/ec/lenovo/h8/acpi/ec.asl +++ b/src/ec/lenovo/h8/acpi/ec.asl @@ -335,3 +335,52 @@ Device(EC) #include "systemstatus.asl" #include "thinkpad.asl" } + +#if CONFIG(EC_LENOVO_H8) +// EC SMM interface +Device(ECMM) +{ + Name (_HID, EISAID("PNP0C02")) + Name (_UID, 10) + + Name (_CRS, ResourceTemplate() { + IO (Decode16, 0x1600, 0x1600, 1, 1) + IO (Decode16, 0x1604, 0x1604, 1, 1) + }) +} + +// EC Gravity sensor interface +Device(ECGS) +{ + Name (_HID, EISAID("PNP0C02")) + Name (_UID, 11) + + Name (_CRS, ResourceTemplate() { + IO (Decode16, 0x1602, 0x1602, 1, 1) + IO (Decode16, 0x1606, 0x1606, 1, 1) + }) +} + +// Battery two wire interface +Device(TWRI) +{ + Name (_HID, EISAID("PNP0C02")) + Name (_UID, 12) + + Name (_CRS, ResourceTemplate() { + IO (Decode16, 0x1610, 0x1610, 16, 16) + }) +} +#endif + +#if CONFIG(EC_LENOVO_PMH7) +Device(PMH7) +{ + Name (_HID, EISAID("PNP0C02")) + Name (_UID, 13) + + Name (_CRS, ResourceTemplate() { + IO (Decode16, 0x15e0, 0x15e0, 16, 16) + }) +} +#endif diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index 564ba85b89..1ea3ccfa40 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -213,6 +213,15 @@ static const char *h8_acpi_name(const struct device *dev) } #endif +static void h8_read_resources(struct device *dev) +{ + static const u16 ports[] = {0x60, 0x64, 0x62, 0x66, 0x1600, 0x1604, 0x1602, 0x1606}; + for (int i = 0; i < ARRAY_SIZE(ports); i++) + fixed_io_range_flags(dev, ports[i], ports[i], 1, IORESOURCE_ASSIGNED); + + fixed_io_range_flags(dev, 0x1610, 0x1610, 16, IORESOURCE_ASSIGNED); +} + struct device_operations h8_dev_ops = { #if CONFIG(GENERATE_SMBIOS_TABLES) .get_smbios_strings = h8_smbios_strings, @@ -221,6 +230,8 @@ struct device_operations h8_dev_ops = { .acpi_fill_ssdt = h8_ssdt_generator, .acpi_name = h8_acpi_name, #endif + .read_resources = h8_read_resources, + .set_resources = noop_set_resources, .init = h8_init, }; diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c index 95502f3d88..00d34edb56 100644 --- a/src/ec/lenovo/pmh7/pmh7.c +++ b/src/ec/lenovo/pmh7/pmh7.c @@ -101,17 +101,23 @@ void pmh7_register_write(int reg, int val) outb(val, EC_LENOVO_PMH7_DATA); } +#if ENV_RAMSTAGE +static void pmh7_read_resources(struct device *dev) +{ + fixed_io_range_flags(dev, EC_LENOVO_PMH7_BASE, EC_LENOVO_PMH7_BASE, + 16, IORESOURCE_ASSIGNED); +} + +struct device_operations pmh7_dev_ops = { + .read_resources = pmh7_read_resources, + .set_resources = noop_set_resources, +}; + static void enable_dev(struct device *dev) { const struct ec_lenovo_pmh7_config *conf = dev->chip_info; - struct resource *resource; - resource = new_resource(dev, EC_LENOVO_PMH7_INDEX); - resource->base = EC_LENOVO_PMH7_BASE; - resource->size = 16; - resource->align = 5; - resource->gran = 5; - resource->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_ASSIGNED; + dev->ops = &pmh7_dev_ops; pmh7_backlight_enable(conf->backlight_enable); pmh7_dock_event_enable(conf->dock_event_enable); @@ -129,3 +135,4 @@ struct chip_operations ec_lenovo_pmh7_ops = { .name = "Lenovo Power Management Hardware Hub 7", .enable_dev = enable_dev, }; +#endif diff --git a/src/ec/lenovo/pmh7/pmh7.h b/src/ec/lenovo/pmh7/pmh7.h index 61dc1137d3..b06e79920d 100644 --- a/src/ec/lenovo/pmh7/pmh7.h +++ b/src/ec/lenovo/pmh7/pmh7.h @@ -5,8 +5,6 @@ #include -#define EC_LENOVO_PMH7_INDEX 0x77 - #define EC_LENOVO_PMH7_BASE 0x15e0 #define EC_LENOVO_PMH7_ADDR_L (EC_LENOVO_PMH7_BASE + 0x0c) #define EC_LENOVO_PMH7_ADDR_H (EC_LENOVO_PMH7_BASE + 0x0d)