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 <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90723
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
673ce1845e
commit
e98bc0e02a
4 changed files with 74 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue