Skip to content

Commit e4dbf9d

Browse files
DHowettTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_lpc: add a "quirks" system
Some devices ship a ChromeOS EC in a non-standard configuration. Quirks allow cros_ec_lpc to account for these non-standard configurations. It only supports one quirk right now: - CROS_EC_LPC_QUIRK_REMAP_MEMORY: use a different port I/O base for MMIO to the EC's memory region Signed-off-by: Dustin L. Howett <[email protected]> Reviewed-by: Thomas Weißschuh <[email protected]> Tested-by: Thomas Weißschuh <[email protected]> Tested-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent c0e6ba2 commit e4dbf9d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@
3434
/* True if ACPI device is present */
3535
static bool cros_ec_lpc_acpi_device_found;
3636

37+
/*
38+
* Indicates that lpc_driver_data.quirk_mmio_memory_base should
39+
* be used as the base port for EC mapped memory.
40+
*/
41+
#define CROS_EC_LPC_QUIRK_REMAP_MEMORY BIT(0)
42+
43+
/**
44+
* struct lpc_driver_data - driver data attached to a DMI device ID to indicate
45+
* hardware quirks.
46+
* @quirks: a bitfield composed of quirks from CROS_EC_LPC_QUIRK_*
47+
* @quirk_mmio_memory_base: The first I/O port addressing EC mapped memory (used
48+
* when quirk ...REMAP_MEMORY is set.)
49+
*/
50+
struct lpc_driver_data {
51+
u32 quirks;
52+
u16 quirk_mmio_memory_base;
53+
};
54+
3755
/**
3856
* struct cros_ec_lpc - LPC device-specific data
3957
* @mmio_memory_base: The first I/O port addressing EC mapped memory.
@@ -363,15 +381,28 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
363381
acpi_status status;
364382
struct cros_ec_device *ec_dev;
365383
struct cros_ec_lpc *ec_lpc;
384+
struct lpc_driver_data *driver_data;
366385
u8 buf[2] = {};
367386
int irq, ret;
387+
u32 quirks;
368388

369389
ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL);
370390
if (!ec_lpc)
371391
return -ENOMEM;
372392

373393
ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
374394

395+
driver_data = platform_get_drvdata(pdev);
396+
if (driver_data) {
397+
quirks = driver_data->quirks;
398+
399+
if (quirks)
400+
dev_info(dev, "loaded with quirks %8.08x\n", quirks);
401+
402+
if (quirks & CROS_EC_LPC_QUIRK_REMAP_MEMORY)
403+
ec_lpc->mmio_memory_base = driver_data->quirk_mmio_memory_base;
404+
}
405+
375406
/*
376407
* The Framework Laptop (and possibly other non-ChromeOS devices)
377408
* only exposes the eight I/O ports that are required for the Microchip EC.

0 commit comments

Comments
 (0)