Skip to contentSkip to conversation

platform/chrome: cros_ec_lpc: Match on Framework ACPI device

PATCH In review Daniel Schaefer 2 participants 4 messages Jan 28, 2025 – Feb 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/chrome: cros_ec_lpc: Match on Framework ACPI device

Load the cros_ec_lpc driver based on a Framework FRMWC006 ACPI device, which mirrors GOOG0004, but also applies npcx quirks for Framework systems.

Matching on ACPI will let us avoid having to change the SMBIOS match rules again and again.

---
V1->V2: Remove platform_set_drvdata, handle it by acpi_device_id table instead

I tested all new possible combinations and they all behave as expected. If there is any match, /dev/cros_ec will be present, with the below dmesg.
I did not test any device with GOOG0004.

| DMI match | FRMWC004 match | Notes
| False     | False          | 3rdparty
| True      | False          | Current framework
| False     | True           | Possible future framework
| True      | True           | Future framework
```
> sudo dmesg | grep cros_ec_lpcs
[   17.521972] cros_ec_lpcs FRMWC004:00: loaded with quirks 00000001
[   17.534012] cros_ec_lpcs FRMWC004:00: Chrome EC device registered
```
```
[   74.366596] cros_ec_lpcs cros_ec_lpcs.0: loaded with quirks 00000001
[   74.377921] cros_ec_lpcs cros_ec_lpcs.0: Chrome EC device registered
```
---
 drivers/platform/chrome/cros_ec_lpc.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/platform/chrome/cros_ec_lpc.c +14 -8
index 5a2f1d98b350..ea569037b6b2 100644
@@ -30,6 +30,7 @@
 
 #define DRV_NAME "cros_ec_lpcs"
 #define ACPI_DRV_NAME "GOOG0004"
+#define FRMW_ACPI_DRV_NAME "FRMWC004"
 
 /* True if ACPI device is present */
 static bool cros_ec_lpc_acpi_device_found;
@@ -514,7 +515,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
 	struct cros_ec_lpc *ec_lpc;
-	struct lpc_driver_data *driver_data;
+	const struct lpc_driver_data *driver_data;
 	u8 buf[2] = {};
 	int irq, ret;
 	u32 quirks;
@@ -526,6 +527,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
 
 	driver_data = platform_get_drvdata(pdev);
+	if (!driver_data) {
+		driver_data = acpi_device_get_match_data(dev);
+	}
 	if (driver_data) {
 		quirks = driver_data->quirks;
 
@@ -696,12 +700,6 @@ static void cros_ec_lpc_remove(struct platform_device *pdev)
 	cros_ec_unregister(ec_dev);
 }
 
-static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
-	{ ACPI_DRV_NAME, 0 },
-	{ }
-};
-MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
-
 static const struct lpc_driver_data framework_laptop_npcx_lpc_driver_data __initconst = {
 	.quirks = CROS_EC_LPC_QUIRK_REMAP_MEMORY,
 	.quirk_mmio_memory_base = 0xE00,
@@ -713,6 +711,13 @@ static const struct lpc_driver_data framework_laptop_mec_lpc_driver_data __initc
 	.quirk_aml_mutex_name = "ECMT",
 };
 
+static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
+	{ ACPI_DRV_NAME, 0 },
+	{ FRMW_ACPI_DRV_NAME, (kernel_ulong_t)&framework_laptop_npcx_lpc_driver_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
+
 static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
 	{
 		/*
@@ -866,7 +871,8 @@ static int __init cros_ec_lpc_init(void)
 	int ret;
 	const struct dmi_system_id *dmi_match;
 
-	cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME);
+	cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME) ||
+		!!cros_ec_lpc_get_device(FRMW_ACPI_DRV_NAME);
 
 	dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
 
Signature · 1 line
2.45.2
maintainer
#1 lore raw
Quoted 1 line · Daniel Schaefer

Load the cros_ec_lpc driver based on a Framework FRMWC006 ACPI device,

[...]

Quoted 3 lines
Quoted 1 line

sudo dmesg | grep cros_ec_lpcs

[   17.521972] cros_ec_lpcs FRMWC004:00: loaded with quirks 00000001
[   17.534012] cros_ec_lpcs FRMWC004:00: Chrome EC device registered

I believe it's a typo. Fixed s/FRMWC006/FRMWC004/ in the commit message.

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/1] platform/chrome: cros_ec_lpc: Match on Framework ACPI device

      commit: d83c45aeec9b223fe6db4175e9d1c4f5699cc37a

Thanks!

#2 lore raw

Hi Tzung-Bi,

Quoted 1 line

I believe it's a typo. Fixed s/FRMWC006/FRMWC004/ in the commit message.

Oh yes that's right, thanks.

Is there a chance this can still get into 6.14? I see it just barely missed going into your for-6.14 - is that right?
6.14 will be included in the upcoming releases of Fedora 42 and Ubuntu 25.04 and we'll need it for some of our upcoming products.

Thanks,
Daniel

Quoted 20 lines · Tzung-Bi Shih
Quoted 1 line · Daniel Schaefer

Load the cros_ec_lpc driver based on a Framework FRMWC006 ACPI device,

[...]

Quoted 3 lines
Quoted 1 line

sudo dmesg | grep cros_ec_lpcs

[   17.521972] cros_ec_lpcs FRMWC004:00: loaded with quirks 00000001
[   17.534012] cros_ec_lpcs FRMWC004:00: Chrome EC device registered

I believe it's a typo. Fixed s/FRMWC006/FRMWC004/ in the commit message.

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/1] platform/chrome: cros_ec_lpc: Match on Framework ACPI device

      commit: d83c45aeec9b223fe6db4175e9d1c4f5699cc37a

Thanks!

maintainer
#3 lore raw
Quoted 1 line · Daniel Schaefer

Is there a chance this can still get into 6.14? I see it just barely

Sorry, no. The patch just missed the previous merge window and it has to wait for the next one unless it's a critical fix.

We want to queue patches a bit time to provide testing robots or pioneers enough time to report if any issues.

Thank you for understanding.