Skip to content

Commit 5f5ce6b

Browse files
committed
Merge tag 'tag-chrome-platform-for-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Tzung-Bi Shih: "New drivers: - cros_ec_uart for ChromeOS EC protocol over UART - cros_typec_vdm for USB PD Vendor Defined Message Improvements: - Preserve logs as much as possible when EC panics - Shutdown to refrain from potential HW damages when EC panics Fixes: - Fix DP_PORT_VDO to include DP_CAP_RECEPTACLE - Fix a lockdep false positive Cleanups: - Use sysfs_emit*() instead of scnprintf() - Use asm instead of asm-generic for unaligned.h Misc: - Rename module name from cros_ec_typec to cros-ec-typec - Minor fixes" * tag 'tag-chrome-platform-for-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (34 commits) platform/chrome: cros_ec_typec: Fix spelling mistake platform/chrome: cros_typec_vdm: Add Attention support platform/chrome: cros_ec: Add VDM attention headers platform/chrome: cros_typec_vdm: Fix VDO copy platform/chrome: cros_ec_typec: allow deferred probe of switch handles platform/chrome: cros_ec_proto: remove big stub objects from stack platform/chrome: cros_ec_uart: fix negative type promoted to high platform/chrome: cros_ec: Use per-device lockdep key platform/chrome: fix kernel-doc warnings for cros_ec_command platform/chrome: fix kernel-doc warning for last_resume_result platform/chrome: fix kernel-doc warning for suspend_timeout_ms platform/chrome: fix kernel-doc warnings for panic notifier platform/chrome: cros_ec_lpc: initialize the buf variable platform/chrome: cros_ec: Fix panic notifier registration platform/chrome: cros_typec_switch: Check for retimer flag platform/chrome: cros_typec_switch: Use fwnode* prop check platform/chrome: cros_typec_vdm: Add VDM send support platform/chrome: cros_typec_vdm: Add VDM reply support platform/chrome: cros_ec_typec: Add initial VDM support platform/chrome: cros_ec_typec: Alter module name with hyphens ...
2 parents 239451e + b0d8a67 commit 5f5ce6b

19 files changed

+846
-147
lines changed

MAINTAINERS

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4823,6 +4823,13 @@ S: Maintained
48234823
F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml
48244824
F: sound/soc/codecs/cros_ec_codec.*
48254825

4826+
CHROMEOS EC UART DRIVER
4827+
M: Bhanu Prakash Maiya <[email protected]>
4828+
R: Benson Leung <[email protected]>
4829+
R: Tzung-Bi Shih <[email protected]>
4830+
S: Maintained
4831+
F: drivers/platform/chrome/cros_ec_uart.c
4832+
48264833
CHROMEOS EC SUBDRIVERS
48274834
M: Benson Leung <[email protected]>
48284835
R: Guenter Roeck <[email protected]>
@@ -4836,8 +4843,9 @@ CHROMEOS EC USB TYPE-C DRIVER
48364843
M: Prashant Malani <[email protected]>
48374844
48384845
S: Maintained
4839-
F: drivers/platform/chrome/cros_ec_typec.c
4846+
F: drivers/platform/chrome/cros_ec_typec.*
48404847
F: drivers/platform/chrome/cros_typec_switch.c
4848+
F: drivers/platform/chrome/cros_typec_vdm.*
48414849

48424850
CHROMEOS EC USB PD NOTIFY DRIVER
48434851
M: Prashant Malani <[email protected]>

drivers/mfd/cros_ec_dev.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ static const struct cros_feature_to_name cros_mcu_devices[] = {
6464
.name = CROS_EC_DEV_SCP_NAME,
6565
.desc = "System Control Processor",
6666
},
67-
{
68-
.id = EC_FEATURE_SCP_C1,
69-
.name = CROS_EC_DEV_SCP_C1_NAME,
70-
.desc = "System Control Processor 2nd Core",
71-
},
7267
{
7368
.id = EC_FEATURE_TOUCHPAD,
7469
.name = CROS_EC_DEV_TP_NAME,

drivers/platform/chrome/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ config CROS_EC_SPI
119119
response time cannot be guaranteed, we support ignoring
120120
'pre-amble' bytes before the response actually starts.
121121

122+
config CROS_EC_UART
123+
tristate "ChromeOS Embedded Controller (UART)"
124+
depends on CROS_EC && ACPI && SERIAL_DEV_BUS
125+
help
126+
If you say Y here, you get support for talking to the ChromeOS EC
127+
through a UART, using a byte-level protocol.
128+
129+
To compile this driver as a module, choose M here: the
130+
module will be called cros_ec_uart.
131+
122132
config CROS_EC_LPC
123133
tristate "ChromeOS Embedded Controller (LPC)"
124134
depends on CROS_EC && ACPI && (X86 || COMPILE_TEST)
@@ -226,7 +236,7 @@ config CROS_EC_TYPEC
226236
information from the Chrome OS EC.
227237

228238
To compile this driver as a module, choose M here: the module will be
229-
called cros_ec_typec.
239+
called cros-ec-typec.
230240

231241
config CROS_HPS_I2C
232242
tristate "ChromeOS HPS device"

drivers/platform/chrome/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ obj-$(CONFIG_CROS_EC_ISHTP) += cros_ec_ishtp.o
1515
obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o
1616
obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
1717
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
18+
obj-$(CONFIG_CROS_EC_UART) += cros_ec_uart.o
1819
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
19-
obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o
20+
cros-ec-typec-objs := cros_ec_typec.o cros_typec_vdm.o
21+
obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
2022
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
2123
obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
2224
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o

drivers/platform/chrome/cros_ec.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
182182
int err = 0;
183183

184184
BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier);
185+
BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->panic_notifier);
185186

186187
ec_dev->max_request = sizeof(struct ec_params_hello);
187188
ec_dev->max_response = sizeof(struct ec_response_get_protocol_info);
@@ -198,12 +199,14 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
198199
if (!ec_dev->dout)
199200
return -ENOMEM;
200201

202+
lockdep_register_key(&ec_dev->lockdep_key);
201203
mutex_init(&ec_dev->lock);
204+
lockdep_set_class(&ec_dev->lock, &ec_dev->lockdep_key);
202205

203206
err = cros_ec_query_all(ec_dev);
204207
if (err) {
205208
dev_err(dev, "Cannot identify the EC: error %d\n", err);
206-
return err;
209+
goto destroy_mutex;
207210
}
208211

209212
if (ec_dev->irq > 0) {
@@ -215,7 +218,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
215218
if (err) {
216219
dev_err(dev, "Failed to request IRQ %d: %d\n",
217220
ec_dev->irq, err);
218-
return err;
221+
goto destroy_mutex;
219222
}
220223
}
221224

@@ -226,7 +229,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
226229
if (IS_ERR(ec_dev->ec)) {
227230
dev_err(ec_dev->dev,
228231
"Failed to create CrOS EC platform device\n");
229-
return PTR_ERR(ec_dev->ec);
232+
err = PTR_ERR(ec_dev->ec);
233+
goto destroy_mutex;
230234
}
231235

232236
if (ec_dev->max_passthru) {
@@ -292,6 +296,9 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
292296
exit:
293297
platform_device_unregister(ec_dev->ec);
294298
platform_device_unregister(ec_dev->pd);
299+
destroy_mutex:
300+
mutex_destroy(&ec_dev->lock);
301+
lockdep_unregister_key(&ec_dev->lockdep_key);
295302
return err;
296303
}
297304
EXPORT_SYMBOL(cros_ec_register);
@@ -309,6 +316,8 @@ void cros_ec_unregister(struct cros_ec_device *ec_dev)
309316
if (ec_dev->pd)
310317
platform_device_unregister(ec_dev->pd);
311318
platform_device_unregister(ec_dev->ec);
319+
mutex_destroy(&ec_dev->lock);
320+
lockdep_unregister_key(&ec_dev->lockdep_key);
312321
}
313322
EXPORT_SYMBOL(cros_ec_unregister);
314323

drivers/platform/chrome/cros_ec_debugfs.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ static DECLARE_WAIT_QUEUE_HEAD(cros_ec_debugfs_log_wq);
3838
* @log_mutex: mutex to protect circular buffer
3939
* @log_poll_work: recurring task to poll EC for new console log data
4040
* @panicinfo_blob: panicinfo debugfs blob
41+
* @notifier_panic: notifier_block to let kernel to flush buffered log
42+
* when EC panic
4143
*/
4244
struct cros_ec_debugfs {
4345
struct cros_ec_dev *ec;
@@ -49,6 +51,7 @@ struct cros_ec_debugfs {
4951
struct delayed_work log_poll_work;
5052
/* EC panicinfo */
5153
struct debugfs_blob_wrapper panicinfo_blob;
54+
struct notifier_block notifier_panic;
5255
};
5356

5457
/*
@@ -437,6 +440,22 @@ static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
437440
return ret;
438441
}
439442

443+
static int cros_ec_debugfs_panic_event(struct notifier_block *nb,
444+
unsigned long queued_during_suspend, void *_notify)
445+
{
446+
struct cros_ec_debugfs *debug_info =
447+
container_of(nb, struct cros_ec_debugfs, notifier_panic);
448+
449+
if (debug_info->log_buffer.buf) {
450+
/* Force log poll work to run immediately */
451+
mod_delayed_work(debug_info->log_poll_work.wq, &debug_info->log_poll_work, 0);
452+
/* Block until log poll work finishes */
453+
flush_delayed_work(&debug_info->log_poll_work);
454+
}
455+
456+
return NOTIFY_DONE;
457+
}
458+
440459
static int cros_ec_debugfs_probe(struct platform_device *pd)
441460
{
442461
struct cros_ec_dev *ec = dev_get_drvdata(pd->dev.parent);
@@ -473,6 +492,12 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
473492
debugfs_create_u16("suspend_timeout_ms", 0664, debug_info->dir,
474493
&ec->ec_dev->suspend_timeout_ms);
475494

495+
debug_info->notifier_panic.notifier_call = cros_ec_debugfs_panic_event;
496+
ret = blocking_notifier_chain_register(&ec->ec_dev->panic_notifier,
497+
&debug_info->notifier_panic);
498+
if (ret)
499+
goto remove_debugfs;
500+
476501
ec->debug_info = debug_info;
477502

478503
dev_set_drvdata(&pd->dev, ec);

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static ssize_t interval_msec_show(struct device *dev,
3434
{
3535
unsigned long msec = lb_interval_jiffies * 1000 / HZ;
3636

37-
return scnprintf(buf, PAGE_SIZE, "%lu\n", msec);
37+
return sysfs_emit(buf, "%lu\n", msec);
3838
}
3939

4040
static ssize_t interval_msec_store(struct device *dev,
@@ -169,7 +169,7 @@ static ssize_t version_show(struct device *dev,
169169
if (!get_lightbar_version(ec, &version, &flags))
170170
return -EIO;
171171

172-
return scnprintf(buf, PAGE_SIZE, "%d %d\n", version, flags);
172+
return sysfs_emit(buf, "%d %d\n", version, flags);
173173
}
174174

175175
static ssize_t brightness_store(struct device *dev,
@@ -302,17 +302,15 @@ static ssize_t sequence_show(struct device *dev,
302302

303303
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
304304
if (ret < 0) {
305-
ret = scnprintf(buf, PAGE_SIZE, "XFER / EC ERROR %d / %d\n",
306-
ret, msg->result);
305+
ret = sysfs_emit(buf, "XFER / EC ERROR %d / %d\n", ret, msg->result);
307306
goto exit;
308307
}
309308

310309
resp = (struct ec_response_lightbar *)msg->data;
311310
if (resp->get_seq.num >= ARRAY_SIZE(seqname))
312-
ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->get_seq.num);
311+
ret = sysfs_emit(buf, "%d\n", resp->get_seq.num);
313312
else
314-
ret = scnprintf(buf, PAGE_SIZE, "%s\n",
315-
seqname[resp->get_seq.num]);
313+
ret = sysfs_emit(buf, "%s\n", seqname[resp->get_seq.num]);
316314

317315
exit:
318316
kfree(msg);
@@ -483,7 +481,7 @@ static ssize_t userspace_control_show(struct device *dev,
483481
struct device_attribute *attr,
484482
char *buf)
485483
{
486-
return scnprintf(buf, PAGE_SIZE, "%d\n", userspace_control);
484+
return sysfs_emit(buf, "%d\n", userspace_control);
487485
}
488486

489487
static ssize_t userspace_control_store(struct device *dev,

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/platform_data/cros_ec_proto.h>
2222
#include <linux/platform_device.h>
2323
#include <linux/printk.h>
24+
#include <linux/reboot.h>
2425
#include <linux/suspend.h>
2526

2627
#include "cros_ec.h"
@@ -320,6 +321,15 @@ static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data)
320321

321322
ec_dev->last_event_time = cros_ec_get_time_ns();
322323

324+
if (value == ACPI_NOTIFY_CROS_EC_PANIC) {
325+
dev_emerg(ec_dev->dev, "CrOS EC Panic Reported. Shutdown is imminent!");
326+
blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev);
327+
/* Begin orderly shutdown. Force shutdown after 1 second. */
328+
hw_protection_shutdown("CrOS EC Panic", 1000);
329+
/* Do not query for other events after a panic is reported */
330+
return;
331+
}
332+
323333
if (ec_dev->mkbp_event_supported)
324334
do {
325335
ret = cros_ec_get_next_event(ec_dev, NULL,
@@ -340,7 +350,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
340350
struct acpi_device *adev;
341351
acpi_status status;
342352
struct cros_ec_device *ec_dev;
343-
u8 buf[2];
353+
u8 buf[2] = {};
344354
int irq, ret;
345355

346356
/*

drivers/platform/chrome/cros_ec_proto_test.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
#include <kunit/test.h>
77

8-
#include <asm-generic/unaligned.h>
8+
#include <asm/unaligned.h>
9+
910
#include <linux/platform_data/cros_ec_commands.h>
1011
#include <linux/platform_data/cros_ec_proto.h>
1112

@@ -2370,7 +2371,7 @@ static void cros_ec_proto_test_get_host_event_normal(struct kunit *test)
23702371
static void cros_ec_proto_test_check_features_cached(struct kunit *test)
23712372
{
23722373
int ret, i;
2373-
struct cros_ec_dev ec;
2374+
static struct cros_ec_dev ec;
23742375

23752376
ec.features.flags[0] = EC_FEATURE_MASK_0(EC_FEATURE_FINGERPRINT);
23762377
ec.features.flags[1] = EC_FEATURE_MASK_0(EC_FEATURE_SCP);
@@ -2395,7 +2396,7 @@ static void cros_ec_proto_test_check_features_not_cached(struct kunit *test)
23952396
struct cros_ec_device *ec_dev = &priv->ec_dev;
23962397
struct ec_xfer_mock *mock;
23972398
int ret, i;
2398-
struct cros_ec_dev ec;
2399+
static struct cros_ec_dev ec;
23992400

24002401
ec_dev->max_request = 0xff;
24012402
ec_dev->max_response = 0xee;
@@ -2448,7 +2449,7 @@ static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test)
24482449
struct cros_ec_device *ec_dev = &priv->ec_dev;
24492450
struct ec_xfer_mock *mock;
24502451
int ret;
2451-
struct cros_ec_dev ec;
2452+
static struct cros_ec_dev ec;
24522453

24532454
ec_dev->max_request = 0xff;
24542455
ec_dev->max_response = 0xee;
@@ -2493,7 +2494,7 @@ static void cros_ec_proto_test_get_sensor_count_xfer_error(struct kunit *test)
24932494
struct cros_ec_device *ec_dev = &priv->ec_dev;
24942495
struct ec_xfer_mock *mock;
24952496
int ret;
2496-
struct cros_ec_dev ec;
2497+
static struct cros_ec_dev ec;
24972498

24982499
ec_dev->max_request = 0xff;
24992500
ec_dev->max_response = 0xee;
@@ -2533,7 +2534,7 @@ static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test)
25332534
struct cros_ec_device *ec_dev = &priv->ec_dev;
25342535
struct ec_xfer_mock *mock;
25352536
int ret, i;
2536-
struct cros_ec_dev ec;
2537+
static struct cros_ec_dev ec;
25372538
struct {
25382539
u8 readmem_data;
25392540
int expected_result;

0 commit comments

Comments
 (0)