Skip to content

Commit d7d170a

Browse files
committed
Merge tag 'tag-chrome-platform-for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Benson Leung "CrOS EC: - Add new CrOS ISHTP transport protocol - Add proper documentation for debugfs entries and expose resume and uptime files - Select LPC transport protocol variant at runtime. - Add lid angle sensor driver - Fix oops on suspend/resume for lightbar driver - Set CrOS SPI transport protol in realtime Wilco EC: - Add telemetry char device interface - Add support for event handling - Add new sysfs attributes Misc: - Contains ib-mfd-cros-v5.3 immutable branch from mfd, with cros_ec_commands.h header freshly synced with Chrome OS's EC project" * tag 'tag-chrome-platform-for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (54 commits) mfd / platform: cros_ec_debugfs: Expose resume result via debugfs platform/chrome: lightbar: Get drvdata from parent in suspend/resume iio: cros_ec: Add lid angle driver platform/chrome: wilco_ec: Add circular buffer as event queue platform/chrome: cros_ec_lpc_mec: Fix kernel-doc comment first line platform/chrome: cros_ec_lpc: Choose Microchip EC at runtime platform/chrome: cros_ec_lpc: Merge cros_ec_lpc and cros_ec_lpc_reg Input: cros_ec_keyb: mask out extra flags in event_type platform/chrome: wilco_ec: Fix unreleased lock in event_read() platform/chrome: cros_ec_debugfs: cros_ec_uptime_fops can be static platform/chrome: cros_ec_debugfs: Add debugfs ABI documentation platform/chrome: cros_ec_debugfs: Fix kernel-doc comment first line platform/chrome: cros_ec_debugfs: Add debugfs entry to retrieve EC uptime mfd: cros_ec: Update I2S API mfd: cros_ec: Add Management API entry points mfd: cros_ec: Add SKU ID and Secure storage API mfd: cros_ec: Add API for rwsig mfd: cros_ec: Add API for Fingerprint support mfd: cros_ec: Add API for Touchpad support mfd: cros_ec: Add API for EC-EC communication ...
2 parents d06e415 + 8c3166e commit d7d170a

33 files changed

Lines changed: 5666 additions & 1018 deletions
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
What: /sys/kernel/debug/<cros-ec-device>/console_log
2+
Date: September 2017
3+
KernelVersion: 4.13
4+
Description:
5+
If the EC supports the CONSOLE_READ command type, this file
6+
can be used to grab the EC logs. The kernel polls for the log
7+
and keeps its own buffer but userspace should grab this and
8+
write it out to some logs.
9+
10+
What: /sys/kernel/debug/<cros-ec-device>/panicinfo
11+
Date: September 2017
12+
KernelVersion: 4.13
13+
Description:
14+
This file dumps the EC panic information from the previous
15+
reboot. This file will only exist if the PANIC_INFO command
16+
type is supported by the EC.
17+
18+
What: /sys/kernel/debug/<cros-ec-device>/pdinfo
19+
Date: June 2018
20+
KernelVersion: 4.17
21+
Description:
22+
This file provides the port role, muxes and power debug
23+
information for all the USB PD/type-C ports available. If
24+
the are no ports available, this file will be just an empty
25+
file.
26+
27+
What: /sys/kernel/debug/<cros-ec-device>/uptime
28+
Date: June 2019
29+
KernelVersion: 5.3
30+
Description:
31+
A u32 providing the time since EC booted in ms. This is
32+
is used for synchronizing the AP host time with the EC
33+
log. An error is returned if the command is not supported
34+
by the EC or there is a communication problem.
35+
36+
What: /sys/kernel/debug/<cros-ec-device>/last_resume_result
37+
Date: June 2019
38+
KernelVersion: 5.3
39+
Description:
40+
Some ECs have a feature where they will track transitions to
41+
the (Intel) processor's SLP_S0 line, in order to detect cases
42+
where a system failed to go into S0ix. When the system resumes,
43+
an EC with this feature will return a summary of SLP_S0
44+
transitions that occurred. The last_resume_result file returns
45+
the most recent response from the AP's resume message to the EC.
46+
47+
The bottom 31 bits contain a count of the number of SLP_S0
48+
transitions that occurred since the suspend message was
49+
received. Bit 31 is set if the EC attempted to wake the
50+
system due to a timeout when watching for SLP_S0 transitions.
51+
Callers can use this to detect a wake from the EC due to
52+
S0ix timeouts. The result will be zero if no suspend
53+
transitions have been attempted, or the EC does not support
54+
this feature.
55+
56+
Output will be in the format: "0x%08x\n".

‎Documentation/ABI/testing/debugfs-wilco-ec‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ Description:
2323

2424
For writing, bytes 0-1 indicate the message type, one of enum
2525
wilco_ec_msg_type. Byte 2+ consist of the data passed in the
26-
request, starting at MBOX[0]
27-
28-
At least three bytes are required for writing, two for the type
29-
and at least a single byte of data. Only the first
30-
EC_MAILBOX_DATA_SIZE bytes of MBOX will be used.
26+
request, starting at MBOX[0]. At least three bytes are required
27+
for writing, two for the type and at least a single byte of
28+
data.
3129

3230
Example:
3331
// Request EC info type 3 (EC firmware build date)
@@ -40,7 +38,7 @@ Description:
4038
$ cat /sys/kernel/debug/wilco_ec/raw
4139
00 00 31 32 2f 32 31 2f 31 38 00 38 00 01 00 2f 00 ..12/21/18.8...
4240

43-
Note that the first 32 bytes of the received MBOX[] will be
44-
printed, even if some of the data is junk. It is up to you to
45-
know how many of the first bytes of data are the actual
46-
response.
41+
Note that the first 16 bytes of the received MBOX[] will be
42+
printed, even if some of the data is junk, and skipping bytes
43+
17 to 32. It is up to you to know how many of the first bytes of
44+
data are the actual response.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
What: /sys/bus/platform/devices/GOOG000C\:00/boot_on_ac
2+
Date: April 2019
3+
KernelVersion: 5.3
4+
Description:
5+
Boot on AC is a policy which makes the device boot from S5
6+
when AC power is connected. This is useful for users who
7+
want to run their device headless or with a dock.
8+
9+
Input should be parseable by kstrtou8() to 0 or 1.
10+
11+
What: /sys/bus/platform/devices/GOOG000C\:00/build_date
12+
Date: May 2019
13+
KernelVersion: 5.3
14+
Description:
15+
Display Wilco Embedded Controller firmware build date.
16+
Output will a MM/DD/YY string.
17+
18+
What: /sys/bus/platform/devices/GOOG000C\:00/build_revision
19+
Date: May 2019
20+
KernelVersion: 5.3
21+
Description:
22+
Display Wilco Embedded Controller build revision.
23+
Output will a version string be similar to the example below:
24+
d2592cae0
25+
26+
What: /sys/bus/platform/devices/GOOG000C\:00/model_number
27+
Date: May 2019
28+
KernelVersion: 5.3
29+
Description:
30+
Display Wilco Embedded Controller model number.
31+
Output will a version string be similar to the example below:
32+
08B6
33+
34+
What: /sys/bus/platform/devices/GOOG000C\:00/version
35+
Date: May 2019
36+
KernelVersion: 5.3
37+
Description:
38+
Display Wilco Embedded Controller firmware version.
39+
The format of the string is x.y.z. Where x is major, y is minor
40+
and z is the build number. For example: 95.00.06

‎drivers/iio/common/cros_ec_sensors/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ config IIO_CROS_EC_SENSORS
2121
Accelerometers, Gyroscope and Magnetometer that are
2222
presented by the ChromeOS EC Sensor hub.
2323
Creates an IIO device for each functions.
24+
25+
config IIO_CROS_EC_SENSORS_LID_ANGLE
26+
tristate "ChromeOS EC Sensor for lid angle"
27+
depends on IIO_CROS_EC_SENSORS_CORE
28+
help
29+
Module to report the angle between lid and base for some
30+
convertible devices.
31+
This module is loaded when the EC can calculate the angle between the base
32+
and the lid.

‎drivers/iio/common/cros_ec_sensors/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55

66
obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
77
obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
8+
obj-$(CONFIG_IIO_CROS_EC_SENSORS_LID_ANGLE) += cros_ec_lid_angle.o
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
/*
4+
* cros_ec_lid_angle - Driver for CrOS EC lid angle sensor.
5+
*
6+
* Copyright 2018 Google, Inc
7+
*
8+
* This driver uses the cros-ec interface to communicate with the Chrome OS
9+
* EC about counter sensors. Counters are presented through
10+
* iio sysfs.
11+
*/
12+
13+
#include <linux/delay.h>
14+
#include <linux/device.h>
15+
#include <linux/iio/buffer.h>
16+
#include <linux/iio/common/cros_ec_sensors_core.h>
17+
#include <linux/iio/iio.h>
18+
#include <linux/iio/kfifo_buf.h>
19+
#include <linux/iio/trigger.h>
20+
#include <linux/iio/triggered_buffer.h>
21+
#include <linux/iio/trigger_consumer.h>
22+
#include <linux/kernel.h>
23+
#include <linux/mfd/cros_ec.h>
24+
#include <linux/mfd/cros_ec_commands.h>
25+
#include <linux/module.h>
26+
#include <linux/platform_device.h>
27+
#include <linux/slab.h>
28+
29+
#define DRV_NAME "cros-ec-lid-angle"
30+
31+
/*
32+
* One channel for the lid angle, the other for timestamp.
33+
*/
34+
static const struct iio_chan_spec cros_ec_lid_angle_channels[] = {
35+
{
36+
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
37+
.scan_type.realbits = CROS_EC_SENSOR_BITS,
38+
.scan_type.storagebits = CROS_EC_SENSOR_BITS,
39+
.scan_type.sign = 'u',
40+
.type = IIO_ANGL
41+
},
42+
IIO_CHAN_SOFT_TIMESTAMP(1)
43+
};
44+
45+
/* State data for ec_sensors iio driver. */
46+
struct cros_ec_lid_angle_state {
47+
/* Shared by all sensors */
48+
struct cros_ec_sensors_core_state core;
49+
};
50+
51+
static int cros_ec_sensors_read_lid_angle(struct iio_dev *indio_dev,
52+
unsigned long scan_mask, s16 *data)
53+
{
54+
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
55+
int ret;
56+
57+
st->param.cmd = MOTIONSENSE_CMD_LID_ANGLE;
58+
ret = cros_ec_motion_send_host_cmd(st, sizeof(st->resp->lid_angle));
59+
if (ret) {
60+
dev_warn(&indio_dev->dev, "Unable to read lid angle\n");
61+
return ret;
62+
}
63+
64+
*data = st->resp->lid_angle.value;
65+
return 0;
66+
}
67+
68+
static int cros_ec_lid_angle_read(struct iio_dev *indio_dev,
69+
struct iio_chan_spec const *chan,
70+
int *val, int *val2, long mask)
71+
{
72+
struct cros_ec_lid_angle_state *st = iio_priv(indio_dev);
73+
s16 data;
74+
int ret;
75+
76+
mutex_lock(&st->core.cmd_lock);
77+
ret = cros_ec_sensors_read_lid_angle(indio_dev, 1, &data);
78+
if (ret == 0) {
79+
*val = data;
80+
ret = IIO_VAL_INT;
81+
}
82+
mutex_unlock(&st->core.cmd_lock);
83+
return ret;
84+
}
85+
86+
static const struct iio_info cros_ec_lid_angle_info = {
87+
.read_raw = &cros_ec_lid_angle_read,
88+
};
89+
90+
static int cros_ec_lid_angle_probe(struct platform_device *pdev)
91+
{
92+
struct device *dev = &pdev->dev;
93+
struct iio_dev *indio_dev;
94+
struct cros_ec_lid_angle_state *state;
95+
int ret;
96+
97+
indio_dev = devm_iio_device_alloc(dev, sizeof(*state));
98+
if (!indio_dev)
99+
return -ENOMEM;
100+
101+
ret = cros_ec_sensors_core_init(pdev, indio_dev, false);
102+
if (ret)
103+
return ret;
104+
105+
indio_dev->info = &cros_ec_lid_angle_info;
106+
state = iio_priv(indio_dev);
107+
indio_dev->channels = cros_ec_lid_angle_channels;
108+
indio_dev->num_channels = ARRAY_SIZE(cros_ec_lid_angle_channels);
109+
110+
state->core.read_ec_sensors_data = cros_ec_sensors_read_lid_angle;
111+
112+
ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
113+
cros_ec_sensors_capture, NULL);
114+
if (ret)
115+
return ret;
116+
117+
return devm_iio_device_register(dev, indio_dev);
118+
}
119+
120+
static const struct platform_device_id cros_ec_lid_angle_ids[] = {
121+
{
122+
.name = DRV_NAME,
123+
},
124+
{ /* sentinel */ }
125+
};
126+
MODULE_DEVICE_TABLE(platform, cros_ec_lid_angle_ids);
127+
128+
static struct platform_driver cros_ec_lid_angle_platform_driver = {
129+
.driver = {
130+
.name = DRV_NAME,
131+
.pm = &cros_ec_sensors_pm_ops,
132+
},
133+
.probe = cros_ec_lid_angle_probe,
134+
.id_table = cros_ec_lid_angle_ids,
135+
};
136+
module_platform_driver(cros_ec_lid_angle_platform_driver);
137+
138+
MODULE_DESCRIPTION("ChromeOS EC driver for reporting convertible lid angle.");
139+
MODULE_LICENSE("GPL v2");

‎drivers/input/keyboard/cros_ec_keyb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
237237
if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
238238
return NOTIFY_OK;
239239

240-
switch (ckdev->ec->event_data.event_type) {
240+
switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
241241
case EC_MKBP_EVENT_KEY_MATRIX:
242242
pm_wakeup_event(ckdev->dev, 0);
243243

‎drivers/mfd/cros_ec.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
102102

103103
/* For now, report failure to transition to S0ix with a warning. */
104104
if (ret >= 0 && ec_dev->host_sleep_v1 &&
105-
(sleep_event == HOST_SLEEP_EVENT_S0IX_RESUME))
105+
(sleep_event == HOST_SLEEP_EVENT_S0IX_RESUME)) {
106+
ec_dev->last_resume_result =
107+
buf.u.resp1.resume_response.sleep_transitions;
108+
106109
WARN_ONCE(buf.u.resp1.resume_response.sleep_transitions &
107110
EC_HOST_RESUME_SLEEP_TIMEOUT,
108111
"EC detected sleep transition timeout. Total slp_s0 transitions: %d",
109112
buf.u.resp1.resume_response.sleep_transitions &
110113
EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK);
114+
}
111115

112116
return ret;
113117
}

‎drivers/platform/chrome/Kconfig‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ config CROS_EC_RPMSG
7272
To compile this driver as a module, choose M here: the
7373
module will be called cros_ec_rpmsg.
7474

75+
config CROS_EC_ISHTP
76+
tristate "ChromeOS Embedded Controller (ISHTP)"
77+
depends on MFD_CROS_EC
78+
depends on INTEL_ISH_HID
79+
help
80+
If you say Y here, you get support for talking to the ChromeOS EC
81+
firmware running on Intel Integrated Sensor Hub (ISH), using the
82+
ISH Transport protocol (ISH-TP). This uses a simple byte-level
83+
protocol with a checksum.
84+
85+
To compile this driver as a module, choose M here: the
86+
module will be called cros_ec_ishtp.
87+
7588
config CROS_EC_SPI
7689
tristate "ChromeOS Embedded Controller (SPI)"
7790
depends on MFD_CROS_EC && SPI
@@ -83,28 +96,17 @@ config CROS_EC_SPI
8396
'pre-amble' bytes before the response actually starts.
8497

8598
config CROS_EC_LPC
86-
tristate "ChromeOS Embedded Controller (LPC)"
87-
depends on MFD_CROS_EC && ACPI && (X86 || COMPILE_TEST)
88-
help
89-
If you say Y here, you get support for talking to the ChromeOS EC
90-
over an LPC bus. This uses a simple byte-level protocol with a
91-
checksum. This is used for userspace access only. The kernel
92-
typically has its own communication methods.
93-
94-
To compile this driver as a module, choose M here: the
95-
module will be called cros_ec_lpc.
96-
97-
config CROS_EC_LPC_MEC
98-
bool "ChromeOS Embedded Controller LPC Microchip EC (MEC) variant"
99-
depends on CROS_EC_LPC
100-
default n
99+
tristate "ChromeOS Embedded Controller (LPC)"
100+
depends on MFD_CROS_EC && ACPI && (X86 || COMPILE_TEST)
101101
help
102-
If you say Y here, a variant LPC protocol for the Microchip EC
103-
will be used. Note that this variant is not backward compatible
104-
with non-Microchip ECs.
102+
If you say Y here, you get support for talking to the ChromeOS EC
103+
over an LPC bus, including the LPC Microchip EC (MEC) variant.
104+
This uses a simple byte-level protocol with a checksum. This is
105+
used for userspace access only. The kernel typically has its own
106+
communication methods.
105107

106-
If you have a ChromeOS Embedded Controller Microchip EC variant
107-
choose Y here.
108+
To compile this driver as a module, choose M here: the
109+
module will be called cros_ec_lpcs.
108110

109111
config CROS_EC_PROTO
110112
bool

‎drivers/platform/chrome/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
77
obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
88
obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
99
obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
10+
obj-$(CONFIG_CROS_EC_ISHTP) += cros_ec_ishtp.o
1011
obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
1112
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
12-
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o
13-
cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC) += cros_ec_lpc_mec.o
13+
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
1414
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
1515
obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
1616
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o

0 commit comments

Comments
 (0)