Skip to content

Commit d48d838

Browse files
committed
Merge tag 'chrome-platform-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome-platform updates from Tzung-Bi Shih: "New: - Support MT8192 Spherion and MT8186 Corsola devices in of_hw_prober - Turn cros_ec_proto from bool into tristate - Support Pin Assignment E in cros_ec_typec for USB-C to DP cables Improvements: - Avoid -Wflex-array-member-not-at-end warnings Cleanups: - Remove a redundant dependency in Kconfig for cros_kbd_led_backlight" * tag 'chrome-platform-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: kunit: Avoid -Wflex-array-member-not-at-end platform/chrome: cros_ec_typec: Set Pin Assignment E in DP PORT VDO platform/chrome: of_hw_prober: Support touchscreen probing on Squirtle platform/chrome: of_hw_prober: Support trackpad probing on Corsola family platform/chrome: cros_kbd_led_backlight: Fix build dependencies platform/chrome: cros_kbd_led_backlight: Remove CROS_EC dependency platform/chrome: cros_ec_proto: Allow to build as module platform/chrome: cros_ec_debugfs: Avoid -Wflex-array-member-not-at-end warnings platform/chrome: cros_kbd_led_backlight: Avoid -Wflex-array-member-not-at-end warnings platform/chrome: cros_ec_proto: Avoid -Wflex-array-member-not-at-end warnings platform/chrome: of_hw_prober: Support Google Spherion
2 parents bad14b5 + 3e552cc commit d48d838

File tree

8 files changed

+85
-67
lines changed

8 files changed

+85
-67
lines changed

drivers/platform/chrome/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,14 @@ config CROS_EC_LPC
155155
module will be called cros_ec_lpcs.
156156

157157
config CROS_EC_PROTO
158-
bool
158+
tristate
159159
help
160160
ChromeOS EC communication protocol helpers.
161161

162162
config CROS_KBD_LED_BACKLIGHT
163163
tristate "Backlight LED support for Chrome OS keyboards"
164-
depends on LEDS_CLASS && (ACPI || CROS_EC || MFD_CROS_EC_DEV)
164+
depends on LEDS_CLASS
165+
depends on MFD_CROS_EC_DEV || (MFD_CROS_EC_DEV=n && ACPI)
165166
help
166167
This option enables support for the keyboard backlight LEDs on
167168
select Chrome OS systems.

drivers/platform/chrome/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ endif
2525
obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
2626

2727
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
28-
obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
28+
cros-ec-proto-objs := cros_ec_proto.o cros_ec_trace.o
29+
obj-$(CONFIG_CROS_EC_PROTO) += cros-ec-proto.o
2930
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
3031
obj-$(CONFIG_CROS_EC_CHARDEV) += cros_ec_chardev.o
3132
obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o

drivers/platform/chrome/chromeos_of_hw_prober.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ static int chromeos_i2c_component_prober(struct device *dev, const void *_data)
5757
}
5858

5959
DEFINE_CHROMEOS_I2C_PROBE_DATA_DUMB_BY_TYPE(touchscreen);
60+
DEFINE_CHROMEOS_I2C_PROBE_DATA_DUMB_BY_TYPE(trackpad);
6061

62+
DEFINE_CHROMEOS_I2C_PROBE_CFG_SIMPLE_BY_TYPE(touchscreen);
6163
DEFINE_CHROMEOS_I2C_PROBE_CFG_SIMPLE_BY_TYPE(trackpad);
6264

6365
static const struct chromeos_i2c_probe_data chromeos_i2c_probe_hana_trackpad = {
@@ -75,6 +77,17 @@ static const struct chromeos_i2c_probe_data chromeos_i2c_probe_hana_trackpad = {
7577
},
7678
};
7779

80+
static const struct chromeos_i2c_probe_data chromeos_i2c_probe_squirtle_touchscreen = {
81+
.cfg = &chromeos_i2c_probe_simple_touchscreen_cfg,
82+
.opts = &(const struct i2c_of_probe_simple_opts) {
83+
.res_node_compatible = "elan,ekth6a12nay",
84+
.supply_name = "vcc33",
85+
.gpio_name = "reset",
86+
.post_power_on_delay_ms = 10,
87+
.post_gpio_config_delay_ms = 300,
88+
},
89+
};
90+
7891
static const struct hw_prober_entry hw_prober_platforms[] = {
7992
{
8093
.compatible = "google,hana",
@@ -84,6 +97,26 @@ static const struct hw_prober_entry hw_prober_platforms[] = {
8497
.compatible = "google,hana",
8598
.prober = chromeos_i2c_component_prober,
8699
.data = &chromeos_i2c_probe_hana_trackpad,
100+
}, {
101+
.compatible = "google,spherion",
102+
.prober = chromeos_i2c_component_prober,
103+
.data = &chromeos_i2c_probe_hana_trackpad,
104+
}, {
105+
.compatible = "google,squirtle",
106+
.prober = chromeos_i2c_component_prober,
107+
.data = &chromeos_i2c_probe_dumb_trackpad,
108+
}, {
109+
.compatible = "google,squirtle",
110+
.prober = chromeos_i2c_component_prober,
111+
.data = &chromeos_i2c_probe_squirtle_touchscreen,
112+
}, {
113+
.compatible = "google,steelix",
114+
.prober = chromeos_i2c_component_prober,
115+
.data = &chromeos_i2c_probe_dumb_trackpad,
116+
}, {
117+
.compatible = "google,voltorb",
118+
.prober = chromeos_i2c_component_prober,
119+
.data = &chromeos_i2c_probe_dumb_trackpad,
87120
},
88121
};
89122

drivers/platform/chrome/cros_ec_debugfs.c

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,15 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
207207
char read_buf[EC_USB_PD_MAX_PORTS * 40], *p = read_buf;
208208
struct cros_ec_debugfs *debug_info = file->private_data;
209209
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
210-
struct {
211-
struct cros_ec_command msg;
212-
union {
213-
struct ec_response_usb_pd_control_v1 resp;
214-
struct ec_params_usb_pd_control params;
215-
};
216-
} __packed ec_buf;
217-
struct cros_ec_command *msg;
218-
struct ec_response_usb_pd_control_v1 *resp;
219-
struct ec_params_usb_pd_control *params;
210+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
211+
MAX(sizeof(struct ec_response_usb_pd_control_v1),
212+
sizeof(struct ec_params_usb_pd_control)));
213+
struct ec_response_usb_pd_control_v1 *resp =
214+
(struct ec_response_usb_pd_control_v1 *)msg->data;
215+
struct ec_params_usb_pd_control *params =
216+
(struct ec_params_usb_pd_control *)msg->data;
220217
int i;
221218

222-
msg = &ec_buf.msg;
223-
params = (struct ec_params_usb_pd_control *)msg->data;
224-
resp = (struct ec_response_usb_pd_control_v1 *)msg->data;
225-
226219
msg->command = EC_CMD_USB_PD_CONTROL;
227220
msg->version = 1;
228221
msg->insize = sizeof(*resp);
@@ -253,17 +246,15 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
253246

254247
static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
255248
{
256-
struct {
257-
struct cros_ec_command cmd;
258-
struct ec_response_uptime_info resp;
259-
} __packed msg = {};
249+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
250+
sizeof(struct ec_response_uptime_info));
260251
int ret;
261252

262-
msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
263-
msg.cmd.insize = sizeof(msg.resp);
253+
msg->command = EC_CMD_GET_UPTIME_INFO;
254+
msg->insize = sizeof(struct ec_response_uptime_info);
264255

265-
ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
266-
if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND)
256+
ret = cros_ec_cmd_xfer_status(ec_dev, msg);
257+
if (ret == -EPROTO && msg->result == EC_RES_INVALID_COMMAND)
267258
return false;
268259

269260
/* Other errors maybe a transient error, do not rule about support. */
@@ -275,20 +266,17 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
275266
{
276267
struct cros_ec_debugfs *debug_info = file->private_data;
277268
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
278-
struct {
279-
struct cros_ec_command cmd;
280-
struct ec_response_uptime_info resp;
281-
} __packed msg = {};
282-
struct ec_response_uptime_info *resp;
269+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
270+
sizeof(struct ec_response_uptime_info));
271+
struct ec_response_uptime_info *resp =
272+
(struct ec_response_uptime_info *)msg->data;
283273
char read_buf[32];
284274
int ret;
285275

286-
resp = (struct ec_response_uptime_info *)&msg.resp;
287-
288-
msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
289-
msg.cmd.insize = sizeof(*resp);
276+
msg->command = EC_CMD_GET_UPTIME_INFO;
277+
msg->insize = sizeof(*resp);
290278

291-
ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
279+
ret = cros_ec_cmd_xfer_status(ec_dev, msg);
292280
if (ret < 0)
293281
return ret;
294282

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_co
139139

140140
static int cros_ec_wait_until_complete(struct cros_ec_device *ec_dev, uint32_t *result)
141141
{
142-
struct {
143-
struct cros_ec_command msg;
144-
struct ec_response_get_comms_status status;
145-
} __packed buf;
146-
struct cros_ec_command *msg = &buf.msg;
147-
struct ec_response_get_comms_status *status = &buf.status;
142+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
143+
sizeof(struct ec_response_get_comms_status));
144+
struct ec_response_get_comms_status *status =
145+
(struct ec_response_get_comms_status *)msg->data;
148146
int ret = 0, i;
149147

150148
msg->version = 0;
@@ -757,16 +755,13 @@ static int get_next_event_xfer(struct cros_ec_device *ec_dev,
757755

758756
static int get_next_event(struct cros_ec_device *ec_dev)
759757
{
760-
struct {
761-
struct cros_ec_command msg;
762-
struct ec_response_get_next_event_v3 event;
763-
} __packed buf;
764-
struct cros_ec_command *msg = &buf.msg;
765-
struct ec_response_get_next_event_v3 *event = &buf.event;
758+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
759+
sizeof(struct ec_response_get_next_event_v3));
760+
struct ec_response_get_next_event_v3 *event =
761+
(struct ec_response_get_next_event_v3 *)msg->data;
766762
int cmd_version = ec_dev->mkbp_event_supported - 1;
767763
u32 size;
768764

769-
memset(msg, 0, sizeof(*msg));
770765
if (ec_dev->suspended) {
771766
dev_dbg(ec_dev->dev, "Device suspended.\n");
772767
return -EHOSTDOWN;
@@ -1157,3 +1152,6 @@ int cros_ec_get_cmd_versions(struct cros_ec_device *ec_dev, u16 cmd)
11571152
return resp.version_mask;
11581153
}
11591154
EXPORT_SYMBOL_GPL(cros_ec_get_cmd_versions);
1155+
1156+
MODULE_LICENSE("GPL");
1157+
MODULE_DESCRIPTION("ChromeOS EC communication protocol helpers");

drivers/platform/chrome/cros_ec_proto_test_util.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ struct ec_xfer_mock {
1313
struct kunit *test;
1414

1515
/* input */
16-
struct cros_ec_command msg;
1716
void *i_data;
1817

1918
/* output */
2019
int ret;
2120
int result;
2221
void *o_data;
2322
u32 o_data_len;
23+
24+
/* input */
25+
/* Must be last -ends in a flexible-array member. */
26+
struct cros_ec_command msg;
2427
};
2528

2629
extern int cros_kunit_ec_xfer_mock_default_result;

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222

2323
#define DRV_NAME "cros-ec-typec"
2424

25-
#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \
26-
DP_CAP_DFP_D | DP_CAP_RECEPTACLE)
25+
#define DP_PORT_VDO (DP_CAP_DFP_D | DP_CAP_RECEPTACLE | \
26+
DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | \
27+
BIT(DP_PIN_ASSIGN_D) | \
28+
BIT(DP_PIN_ASSIGN_E)))
2729

2830
static void cros_typec_role_switch_quirk(struct fwnode_handle *fwnode)
2931
{

drivers/platform/chrome/cros_kbd_led_backlight.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,12 @@ static int
137137
keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
138138
enum led_brightness brightness)
139139
{
140-
struct {
141-
struct cros_ec_command msg;
142-
struct ec_params_pwm_set_keyboard_backlight params;
143-
} __packed buf;
144-
struct ec_params_pwm_set_keyboard_backlight *params = &buf.params;
145-
struct cros_ec_command *msg = &buf.msg;
140+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
141+
sizeof(struct ec_params_pwm_set_keyboard_backlight));
142+
struct ec_params_pwm_set_keyboard_backlight *params =
143+
(struct ec_params_pwm_set_keyboard_backlight *)msg->data;
146144
struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
147145

148-
memset(&buf, 0, sizeof(buf));
149-
150146
msg->command = EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT;
151147
msg->outsize = sizeof(*params);
152148

@@ -158,17 +154,13 @@ keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
158154
static enum led_brightness
159155
keyboard_led_get_brightness_ec_pwm(struct led_classdev *cdev)
160156
{
161-
struct {
162-
struct cros_ec_command msg;
163-
struct ec_response_pwm_get_keyboard_backlight resp;
164-
} __packed buf;
165-
struct ec_response_pwm_get_keyboard_backlight *resp = &buf.resp;
166-
struct cros_ec_command *msg = &buf.msg;
157+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
158+
sizeof(struct ec_response_pwm_get_keyboard_backlight));
159+
struct ec_response_pwm_get_keyboard_backlight *resp =
160+
(struct ec_response_pwm_get_keyboard_backlight *)msg->data;
167161
struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
168162
int ret;
169163

170-
memset(&buf, 0, sizeof(buf));
171-
172164
msg->command = EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT;
173165
msg->insize = sizeof(*resp);
174166

0 commit comments

Comments
 (0)