Skip to content

Commit 59729c8

Browse files
committed
Merge tag 'tag-chrome-platform-for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Tzung-Bi Shih: "New: - Support Framework Laptop 13 and 16 (AMD Ryzen) Improvements: - Use sysfs_emit() instead of sprintf() for sysfs' show() Fixes: - Fix flex-array-member-not-at-end compiler warnings by using DEFINE_RAW_FLEX() - Add HAS_IOPORT dependencies - Fix long pending events during suspend after resume Misc cleanups: - Provide ID tables for avoiding fallback match - Replace deprecated UNIVERSAL_DEV_PM_OPS()" * tag 'tag-chrome-platform-for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (22 commits) platform/chrome: cros_ec: Handle events during suspend after resume completion platform/chrome: cros_ec_lpc: add quirks for the Framework Laptop (AMD) platform/chrome: cros_ec_lpc: add a "quirks" system platform/chrome: cros_ec_lpc: pass driver_data from DMI to the device platform/chrome: cros_ec_lpc: introduce a priv struct for the lpc device platform/chrome: add HAS_IOPORT dependencies platform/chrome: cros_hps_i2c: Replace deprecated UNIVERSAL_DEV_PM_OPS() platform/chrome: cros_kbd_led_backlight: provide ID table for avoiding fallback match platform/chrome: wilco_ec: core: provide ID table for avoiding fallback match platform/chrome: wilco_ec: event: remove redundant MODULE_ALIAS platform/chrome: wilco_ec: debugfs: provide ID table for avoiding fallback match platform/chrome: wilco_ec: telemetry: provide ID table for avoiding fallback match platform/chrome: cros_ec_vbc: provide ID table for avoiding fallback match platform/chrome: cros_ec_lightbar: provide ID table for avoiding fallback match platform/chrome: cros_ec_sysfs: provide ID table for avoiding fallback match platform/chrome: cros_ec_debugfs: provide ID table for avoiding fallback match platform/chrome: cros_ec_chardev: provide ID table for avoiding fallback match platform/chrome: cros_usbpd_notify: provide ID table for avoiding fallback match platform/chrome: cros_usbpd_logger: provide ID table for avoiding fallback match platform/chrome: cros_ec_sensorhub: provide ID table for avoiding fallback match ...
2 parents 8f5b5f7 + 2fbe479 commit 59729c8

20 files changed

+214
-74
lines changed

drivers/platform/chrome/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ config CROS_EC_UART
132132
config CROS_EC_LPC
133133
tristate "ChromeOS Embedded Controller (LPC)"
134134
depends on CROS_EC && ACPI && (X86 || COMPILE_TEST)
135+
depends on HAS_IOPORT
135136
help
136137
If you say Y here, you get support for talking to the ChromeOS EC
137138
over an LPC bus, including the LPC Microchip EC (MEC) variant.

drivers/platform/chrome/cros_ec.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ static void cros_ec_send_resume_event(struct cros_ec_device *ec_dev)
432432
void cros_ec_resume_complete(struct cros_ec_device *ec_dev)
433433
{
434434
cros_ec_send_resume_event(ec_dev);
435+
436+
/*
437+
* Let the mfd devices know about events that occur during
438+
* suspend. This way the clients know what to do with them.
439+
*/
440+
cros_ec_report_events_during_suspend(ec_dev);
435441
}
436442
EXPORT_SYMBOL(cros_ec_resume_complete);
437443

@@ -442,12 +448,6 @@ static void cros_ec_enable_irq(struct cros_ec_device *ec_dev)
442448

443449
if (ec_dev->wake_enabled)
444450
disable_irq_wake(ec_dev->irq);
445-
446-
/*
447-
* Let the mfd devices know about events that occur during
448-
* suspend. This way the clients know what to do with them.
449-
*/
450-
cros_ec_report_events_during_suspend(ec_dev);
451451
}
452452

453453
/**
@@ -475,8 +475,8 @@ EXPORT_SYMBOL(cros_ec_resume_early);
475475
*/
476476
int cros_ec_resume(struct cros_ec_device *ec_dev)
477477
{
478-
cros_ec_enable_irq(ec_dev);
479-
cros_ec_send_resume_event(ec_dev);
478+
cros_ec_resume_early(ec_dev);
479+
cros_ec_resume_complete(ec_dev);
480480
return 0;
481481
}
482482
EXPORT_SYMBOL(cros_ec_resume);

drivers/platform/chrome/cros_ec_chardev.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/device.h>
1515
#include <linux/fs.h>
1616
#include <linux/miscdevice.h>
17+
#include <linux/mod_devicetable.h>
1718
#include <linux/module.h>
1819
#include <linux/notifier.h>
1920
#include <linux/platform_data/cros_ec_chardev.h>
@@ -403,17 +404,23 @@ static void cros_ec_chardev_remove(struct platform_device *pdev)
403404
misc_deregister(&data->misc);
404405
}
405406

407+
static const struct platform_device_id cros_ec_chardev_id[] = {
408+
{ DRV_NAME, 0 },
409+
{}
410+
};
411+
MODULE_DEVICE_TABLE(platform, cros_ec_chardev_id);
412+
406413
static struct platform_driver cros_ec_chardev_driver = {
407414
.driver = {
408415
.name = DRV_NAME,
409416
},
410417
.probe = cros_ec_chardev_probe,
411418
.remove_new = cros_ec_chardev_remove,
419+
.id_table = cros_ec_chardev_id,
412420
};
413421

414422
module_platform_driver(cros_ec_chardev_driver);
415423

416-
MODULE_ALIAS("platform:" DRV_NAME);
417424
MODULE_AUTHOR("Enric Balletbo i Serra <[email protected]>");
418425
MODULE_DESCRIPTION("ChromeOS EC Miscellaneous Character Driver");
419426
MODULE_LICENSE("GPL");

drivers/platform/chrome/cros_ec_debugfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/debugfs.h>
88
#include <linux/delay.h>
99
#include <linux/fs.h>
10+
#include <linux/mod_devicetable.h>
1011
#include <linux/module.h>
1112
#include <linux/mutex.h>
1213
#include <linux/platform_data/cros_ec_commands.h>
@@ -564,6 +565,12 @@ static int __maybe_unused cros_ec_debugfs_resume(struct device *dev)
564565
static SIMPLE_DEV_PM_OPS(cros_ec_debugfs_pm_ops,
565566
cros_ec_debugfs_suspend, cros_ec_debugfs_resume);
566567

568+
static const struct platform_device_id cros_ec_debugfs_id[] = {
569+
{ DRV_NAME, 0 },
570+
{}
571+
};
572+
MODULE_DEVICE_TABLE(platform, cros_ec_debugfs_id);
573+
567574
static struct platform_driver cros_ec_debugfs_driver = {
568575
.driver = {
569576
.name = DRV_NAME,
@@ -572,10 +579,10 @@ static struct platform_driver cros_ec_debugfs_driver = {
572579
},
573580
.probe = cros_ec_debugfs_probe,
574581
.remove_new = cros_ec_debugfs_remove,
582+
.id_table = cros_ec_debugfs_id,
575583
};
576584

577585
module_platform_driver(cros_ec_debugfs_driver);
578586

579587
MODULE_LICENSE("GPL");
580588
MODULE_DESCRIPTION("Debug logs for ChromeOS EC");
581-
MODULE_ALIAS("platform:" DRV_NAME);

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/fs.h>
1010
#include <linux/kobject.h>
1111
#include <linux/kstrtox.h>
12+
#include <linux/mod_devicetable.h>
1213
#include <linux/module.h>
1314
#include <linux/platform_data/cros_ec_commands.h>
1415
#include <linux/platform_data/cros_ec_proto.h>
@@ -594,6 +595,12 @@ static int __maybe_unused cros_ec_lightbar_suspend(struct device *dev)
594595
static SIMPLE_DEV_PM_OPS(cros_ec_lightbar_pm_ops,
595596
cros_ec_lightbar_suspend, cros_ec_lightbar_resume);
596597

598+
static const struct platform_device_id cros_ec_lightbar_id[] = {
599+
{ DRV_NAME, 0 },
600+
{}
601+
};
602+
MODULE_DEVICE_TABLE(platform, cros_ec_lightbar_id);
603+
597604
static struct platform_driver cros_ec_lightbar_driver = {
598605
.driver = {
599606
.name = DRV_NAME,
@@ -602,10 +609,10 @@ static struct platform_driver cros_ec_lightbar_driver = {
602609
},
603610
.probe = cros_ec_lightbar_probe,
604611
.remove_new = cros_ec_lightbar_remove,
612+
.id_table = cros_ec_lightbar_id,
605613
};
606614

607615
module_platform_driver(cros_ec_lightbar_driver);
608616

609617
MODULE_LICENSE("GPL");
610618
MODULE_DESCRIPTION("Expose the Chromebook Pixel's lightbar to userspace");
611-
MODULE_ALIAS("platform:" DRV_NAME);

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,32 @@
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+
55+
/**
56+
* struct cros_ec_lpc - LPC device-specific data
57+
* @mmio_memory_base: The first I/O port addressing EC mapped memory.
58+
*/
59+
struct cros_ec_lpc {
60+
u16 mmio_memory_base;
61+
};
62+
3763
/**
3864
* struct lpc_driver_ops - LPC driver operations
3965
* @read: Copy length bytes from EC address offset into buffer dest. Returns
@@ -290,6 +316,7 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec,
290316
static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
291317
unsigned int bytes, void *dest)
292318
{
319+
struct cros_ec_lpc *ec_lpc = ec->priv;
293320
int i = offset;
294321
char *s = dest;
295322
int cnt = 0;
@@ -299,13 +326,13 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
299326

300327
/* fixed length */
301328
if (bytes) {
302-
cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + offset, bytes, s);
329+
cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + offset, bytes, s);
303330
return bytes;
304331
}
305332

306333
/* string */
307334
for (; i < EC_MEMMAP_SIZE; i++, s++) {
308-
cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + i, 1, s);
335+
cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + i, 1, s);
309336
cnt++;
310337
if (!*s)
311338
break;
@@ -353,8 +380,28 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
353380
struct acpi_device *adev;
354381
acpi_status status;
355382
struct cros_ec_device *ec_dev;
383+
struct cros_ec_lpc *ec_lpc;
384+
struct lpc_driver_data *driver_data;
356385
u8 buf[2] = {};
357386
int irq, ret;
387+
u32 quirks;
388+
389+
ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL);
390+
if (!ec_lpc)
391+
return -ENOMEM;
392+
393+
ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
394+
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+
}
358405

359406
/*
360407
* The Framework Laptop (and possibly other non-ChromeOS devices)
@@ -380,7 +427,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
380427
cros_ec_lpc_ops.write = cros_ec_lpc_mec_write_bytes;
381428
cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2, buf);
382429
if (buf[0] != 'E' || buf[1] != 'C') {
383-
if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
430+
if (!devm_request_region(dev, ec_lpc->mmio_memory_base, EC_MEMMAP_SIZE,
384431
dev_name(dev))) {
385432
dev_err(dev, "couldn't reserve memmap region\n");
386433
return -EBUSY;
@@ -389,7 +436,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
389436
/* Re-assign read/write operations for the non MEC variant */
390437
cros_ec_lpc_ops.read = cros_ec_lpc_read_bytes;
391438
cros_ec_lpc_ops.write = cros_ec_lpc_write_bytes;
392-
cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2,
439+
cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2,
393440
buf);
394441
if (buf[0] != 'E' || buf[1] != 'C') {
395442
dev_err(dev, "EC ID not detected\n");
@@ -423,6 +470,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
423470
ec_dev->din_size = sizeof(struct ec_host_response) +
424471
sizeof(struct ec_response_get_protocol_info);
425472
ec_dev->dout_size = sizeof(struct ec_host_request);
473+
ec_dev->priv = ec_lpc;
426474

427475
/*
428476
* Some boards do not have an IRQ allotted for cros_ec_lpc,
@@ -479,6 +527,11 @@ static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
479527
};
480528
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
481529

530+
static const struct lpc_driver_data framework_laptop_amd_lpc_driver_data __initconst = {
531+
.quirks = CROS_EC_LPC_QUIRK_REMAP_MEMORY,
532+
.quirk_mmio_memory_base = 0xE00,
533+
};
534+
482535
static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
483536
{
484537
/*
@@ -533,7 +586,16 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
533586
},
534587
/* A small number of non-Chromebook/box machines also use the ChromeOS EC */
535588
{
536-
/* the Framework Laptop */
589+
/* the Framework Laptop 13 (AMD Ryzen) and 16 (AMD Ryzen) */
590+
.matches = {
591+
DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
592+
DMI_MATCH(DMI_PRODUCT_NAME, "AMD Ryzen"),
593+
DMI_MATCH(DMI_PRODUCT_FAMILY, "Laptop"),
594+
},
595+
.driver_data = (void *)&framework_laptop_amd_lpc_driver_data,
596+
},
597+
{
598+
/* the Framework Laptop (Intel 11th, 12th, 13th Generation) */
537599
.matches = {
538600
DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
539601
DMI_MATCH(DMI_PRODUCT_NAME, "Laptop"),
@@ -610,14 +672,16 @@ static int __init cros_ec_lpc_init(void)
610672
{
611673
int ret;
612674
acpi_status status;
675+
const struct dmi_system_id *dmi_match;
613676

614677
status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
615678
&cros_ec_lpc_acpi_device_found, NULL);
616679
if (ACPI_FAILURE(status))
617680
pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
618681

619-
if (!cros_ec_lpc_acpi_device_found &&
620-
!dmi_check_system(cros_ec_lpc_dmi_table)) {
682+
dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
683+
684+
if (!cros_ec_lpc_acpi_device_found && !dmi_match) {
621685
pr_err(DRV_NAME ": unsupported system.\n");
622686
return -ENODEV;
623687
}
@@ -630,6 +694,9 @@ static int __init cros_ec_lpc_init(void)
630694
}
631695

632696
if (!cros_ec_lpc_acpi_device_found) {
697+
/* Pass the DMI match's driver data down to the platform device */
698+
platform_set_drvdata(&cros_ec_lpc_device, dmi_match->driver_data);
699+
633700
/* Register the device, and it'll get hooked up automatically */
634701
ret = platform_device_register(&cros_ec_lpc_device);
635702
if (ret) {

0 commit comments

Comments
 (0)