From: Daniel Schaefer <dhs@frame.work>
To: chrome-platform@lists.linux.dev
Cc: Daniel Schaefer <dhs@frame.work>,
Tzung-Bi Shih <tzungbi@kernel.org>,
linux@frame.work, "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH] chrome/cros_ec_lpc: Match on Framework ACPI device
Date: Fri, 24 Jan 2025 10:30:21 +0800 [thread overview]
Message-ID: <20250124023021.9418-1-dhs@frame.work> (raw)
This patch loads 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.
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
```
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: linux@frame.work
Cc: Dustin L. Howett <dustin@howett.net>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
---
drivers/platform/chrome/cros_ec_lpc.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 5a2f1d98b350..ac951ab26ddf 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -30,9 +30,11 @@
#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;
+static bool cros_ec_lpc_frmw_acpi_device_found;
/*
* Indicates that lpc_driver_data.quirk_mmio_memory_base should
@@ -507,6 +509,10 @@ static acpi_status cros_ec_lpc_resources(struct acpi_resource *res, void *data)
return AE_OK;
}
+static struct platform_device cros_ec_lpc_device = {
+ .name = DRV_NAME
+};
+
static int cros_ec_lpc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -526,6 +532,8 @@ 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 = platform_get_drvdata(&cros_ec_lpc_device);
if (driver_data) {
quirks = driver_data->quirks;
@@ -698,6 +706,7 @@ static void cros_ec_lpc_remove(struct platform_device *pdev)
static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
{ ACPI_DRV_NAME, 0 },
+ { FRMW_ACPI_DRV_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
@@ -857,20 +866,20 @@ static struct platform_driver cros_ec_lpc_driver = {
.remove = cros_ec_lpc_remove,
};
-static struct platform_device cros_ec_lpc_device = {
- .name = DRV_NAME
-};
-
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_frmw_acpi_device_found = !!cros_ec_lpc_get_device(FRMW_ACPI_DRV_NAME);
dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
- if (!cros_ec_lpc_acpi_device_found && !dmi_match) {
+ if (cros_ec_lpc_frmw_acpi_device_found) {
+ platform_set_drvdata(&cros_ec_lpc_device,
+ (void *)&framework_laptop_npcx_lpc_driver_data);
+ } else if (!cros_ec_lpc_acpi_device_found && !dmi_match) {
pr_err(DRV_NAME ": unsupported system.\n");
return -ENODEV;
}
@@ -882,7 +891,7 @@ static int __init cros_ec_lpc_init(void)
return ret;
}
- if (!cros_ec_lpc_acpi_device_found) {
+ if (!cros_ec_lpc_acpi_device_found && !cros_ec_lpc_frmw_acpi_device_found) {
/* Pass the DMI match's driver data down to the platform device */
platform_set_drvdata(&cros_ec_lpc_device, dmi_match->driver_data);
@@ -899,7 +908,7 @@ static int __init cros_ec_lpc_init(void)
static void __exit cros_ec_lpc_exit(void)
{
- if (!cros_ec_lpc_acpi_device_found)
+ if (!cros_ec_lpc_acpi_device_found && !cros_ec_lpc_frmw_acpi_device_found)
platform_device_unregister(&cros_ec_lpc_device);
platform_driver_unregister(&cros_ec_lpc_driver);
}
--
2.47.1
next reply other threads:[~2025-01-24 2:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 2:30 Daniel Schaefer [this message]
2025-01-27 16:22 ` [PATCH] chrome/cros_ec_lpc: Match on Framework ACPI device Tzung-Bi Shih
2025-01-28 18:12 ` Daniel Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250124023021.9418-1-dhs@frame.work \
--to=dhs@frame.work \
--cc=chrome-platform@lists.linux.dev \
--cc=dustin@howett.net \
--cc=linux@frame.work \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.