diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-22 09:36:23 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-22 09:36:23 -0800 |
commit | b996c10e0f5b2cfd5b2cbf048cce83982bfe662d (patch) | |
tree | ab8fd03ea3b223b80800d912867007d88c3552bc /drivers/platform/chrome | |
parent | f158bbee9403b7bd2ad22f0c03b7e9762c20ad18 (diff) | |
parent | a59e12218c4f5498d5669a0ee0c725101ca89d52 (diff) |
Merge tag 'tag-chrome-platform-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Benson Leung:
"Lots of changes to the cros_ec_typec driver for 5.12.
A portion of this this set of cros_ec_typec driver's changes was
merged through GregKH's USB tree in order to satisfy cros_ec_typec
driver and typec connector class subsystem dependencies of subsequent
changes.
Summary:
cros_ec_typec:
- Registration of cable plug information
- Support for SOP' plug registration and altmodes
- Support for reporting number of altmodes supported by partners and
plugs
- Send mux configuration ack to EC via a new host command
- Support mux control with no port partner present
- Decouple cable removal from partner removal
cros_ec misc:
- Fix some event masking in cros_ec_proto.
- Gwendal reworked cros_ec's top and bottom half for consistency in
ishtp and rpmsg
- Constify static attribute_group structs"
* tag 'tag-chrome-platform-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
platform/chrome: cros_ec_typec: Flush pending work
platform/chrome: cros_ec_types: Support disconnect events without partners
platform/chrome: cros_ec_typec: Skip port partner check in configure_mux()
platform/chrome: cros_ec_typec: Decouple partner removal
platform/chrome: cros_ec: Call interrupt bottom half at probe time
platform/chrome: cros_ec: Call interrupt bottom half in ISH or RPMSG mode
platform/chrome: cros_ec_sysfs: Add cold-ap-off to sysfs reboot.
platform/chrome: cros_ec_commands: Add host command to keep AP off after EC reset.
platform/chrome: Constify static attribute_group structs
platform/chrome: cros_ec_proto: Add LID and BATTERY to default mask
platform/chrome: cros_ec_proto: Use EC_HOST_EVENT_MASK not BIT
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r-- | drivers/platform/chrome/cros_ec.c | 33 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec.h | 4 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_ishtp.c | 6 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_lightbar.c | 2 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_proto.c | 12 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_rpmsg.c | 6 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_sysfs.c | 5 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_typec.c | 33 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_vbc.c | 2 | ||||
-rw-r--r-- | drivers/platform/chrome/wilco_ec/sysfs.c | 2 |
10 files changed, 66 insertions, 39 deletions
diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c index 3104680b7485..fc5aa1525d13 100644 --- a/drivers/platform/chrome/cros_ec.c +++ b/drivers/platform/chrome/cros_ec.c @@ -32,7 +32,14 @@ static struct cros_ec_platform pd_p = { .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), }; -static irqreturn_t ec_irq_handler(int irq, void *data) +/** + * cros_ec_irq_handler() - top half part of the interrupt handler + * @irq: IRQ id + * @data: (ec_dev) Device with events to process. + * + * Return: Wakeup the bottom half + */ +static irqreturn_t cros_ec_irq_handler(int irq, void *data) { struct cros_ec_device *ec_dev = data; @@ -51,7 +58,7 @@ static irqreturn_t ec_irq_handler(int irq, void *data) * Return: true if more events are still pending and this function should be * called again. */ -bool cros_ec_handle_event(struct cros_ec_device *ec_dev) +static bool cros_ec_handle_event(struct cros_ec_device *ec_dev) { bool wake_event; bool ec_has_more_events; @@ -73,9 +80,15 @@ bool cros_ec_handle_event(struct cros_ec_device *ec_dev) return ec_has_more_events; } -EXPORT_SYMBOL(cros_ec_handle_event); -static irqreturn_t ec_irq_thread(int irq, void *data) +/** + * cros_ec_irq_thread() - bottom half part of the interrupt handler + * @irq: IRQ id + * @data: (ec_dev) Device with events to process. + * + * Return: Interrupt handled. + */ +irqreturn_t cros_ec_irq_thread(int irq, void *data) { struct cros_ec_device *ec_dev = data; bool ec_has_more_events; @@ -86,6 +99,7 @@ static irqreturn_t ec_irq_thread(int irq, void *data) return IRQ_HANDLED; } +EXPORT_SYMBOL(cros_ec_irq_thread); static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) { @@ -194,8 +208,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) if (ec_dev->irq > 0) { err = devm_request_threaded_irq(dev, ec_dev->irq, - ec_irq_handler, - ec_irq_thread, + cros_ec_irq_handler, + cros_ec_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "chromeos-ec", ec_dev); if (err) { @@ -269,6 +283,13 @@ int cros_ec_register(struct cros_ec_device *ec_dev) dev_info(dev, "Chrome EC device registered\n"); + /* + * Unlock EC that may be waiting for AP to process MKBP events. + * If the AP takes to long to answer, the EC would stop sending events. + */ + if (ec_dev->mkbp_event_supported) + cros_ec_irq_thread(0, ec_dev); + return 0; } EXPORT_SYMBOL(cros_ec_register); diff --git a/drivers/platform/chrome/cros_ec.h b/drivers/platform/chrome/cros_ec.h index e69fc1ff68b4..78363dcfdf23 100644 --- a/drivers/platform/chrome/cros_ec.h +++ b/drivers/platform/chrome/cros_ec.h @@ -8,12 +8,14 @@ #ifndef __CROS_EC_H #define __CROS_EC_H +#include <linux/interrupt.h> + int cros_ec_register(struct cros_ec_device *ec_dev); int cros_ec_unregister(struct cros_ec_device *ec_dev); int cros_ec_suspend(struct cros_ec_device *ec_dev); int cros_ec_resume(struct cros_ec_device *ec_dev); -bool cros_ec_handle_event(struct cros_ec_device *ec_dev); +irqreturn_t cros_ec_irq_thread(int irq, void *data); #endif /* __CROS_EC_H */ diff --git a/drivers/platform/chrome/cros_ec_ishtp.c b/drivers/platform/chrome/cros_ec_ishtp.c index 81364029af36..f00107017318 100644 --- a/drivers/platform/chrome/cros_ec_ishtp.c +++ b/drivers/platform/chrome/cros_ec_ishtp.c @@ -140,12 +140,8 @@ static void ish_evt_handler(struct work_struct *work) { struct ishtp_cl_data *client_data = container_of(work, struct ishtp_cl_data, work_ec_evt); - struct cros_ec_device *ec_dev = client_data->ec_dev; - bool ec_has_more_events; - do { - ec_has_more_events = cros_ec_handle_event(ec_dev); - } while (ec_has_more_events); + cros_ec_irq_thread(0, client_data->ec_dev); } /** diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index de8dfb12e486..469dfc7a4a03 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -523,7 +523,7 @@ static struct attribute *__lb_cmds_attrs[] = { NULL, }; -static struct attribute_group cros_ec_lightbar_attr_group = { +static const struct attribute_group cros_ec_lightbar_attr_group = { .name = "lightbar", .attrs = __lb_cmds_attrs, }; diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index 7c92a6e22d75..aa7f7aa77297 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -526,11 +526,13 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) * power), not wake up. */ ec_dev->host_event_wake_mask = U32_MAX & - ~(BIT(EC_HOST_EVENT_AC_DISCONNECTED) | - BIT(EC_HOST_EVENT_BATTERY_LOW) | - BIT(EC_HOST_EVENT_BATTERY_CRITICAL) | - BIT(EC_HOST_EVENT_PD_MCU) | - BIT(EC_HOST_EVENT_BATTERY_STATUS)); + ~(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS)); /* * Old ECs may not support this command. Complain about all * other errors. diff --git a/drivers/platform/chrome/cros_ec_rpmsg.c b/drivers/platform/chrome/cros_ec_rpmsg.c index 30d0ba3b8889..d96d15b8ca94 100644 --- a/drivers/platform/chrome/cros_ec_rpmsg.c +++ b/drivers/platform/chrome/cros_ec_rpmsg.c @@ -149,12 +149,8 @@ cros_ec_rpmsg_host_event_function(struct work_struct *host_event_work) struct cros_ec_rpmsg *ec_rpmsg = container_of(host_event_work, struct cros_ec_rpmsg, host_event_work); - struct cros_ec_device *ec_dev = dev_get_drvdata(&ec_rpmsg->rpdev->dev); - bool ec_has_more_events; - do { - ec_has_more_events = cros_ec_handle_event(ec_dev); - } while (ec_has_more_events); + cros_ec_irq_thread(0, dev_get_drvdata(&ec_rpmsg->rpdev->dev)); } static int cros_ec_rpmsg_callback(struct rpmsg_device *rpdev, void *data, diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index f521a5c65091..f07eabcf9494 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -28,7 +28,7 @@ static ssize_t reboot_show(struct device *dev, int count = 0; count += scnprintf(buf + count, PAGE_SIZE - count, - "ro|rw|cancel|cold|disable-jump|hibernate"); + "ro|rw|cancel|cold|disable-jump|hibernate|cold-ap-off"); count += scnprintf(buf + count, PAGE_SIZE - count, " [at-shutdown]\n"); return count; @@ -46,6 +46,7 @@ static ssize_t reboot_store(struct device *dev, {"cancel", EC_REBOOT_CANCEL, 0}, {"ro", EC_REBOOT_JUMP_RO, 0}, {"rw", EC_REBOOT_JUMP_RW, 0}, + {"cold-ap-off", EC_REBOOT_COLD_AP_OFF, 0}, {"cold", EC_REBOOT_COLD, 0}, {"disable-jump", EC_REBOOT_DISABLE_JUMP, 0}, {"hibernate", EC_REBOOT_HIBERNATE, 0}, @@ -329,7 +330,7 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj, return a->mode; } -static struct attribute_group cros_ec_attr_group = { +static const struct attribute_group cros_ec_attr_group = { .attrs = __ec_attrs, .is_visible = cros_ec_ctrl_visible, }; diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 0abd21044882..0811562deecc 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -203,20 +203,26 @@ static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int po } } -static void cros_typec_remove_partner(struct cros_typec_data *typec, - int port_num) +static int cros_typec_usb_disconnect_state(struct cros_typec_port *port) { - struct cros_typec_port *port = typec->ports[port_num]; - - cros_typec_unregister_altmodes(typec, port_num, true); - port->state.alt = NULL; port->state.mode = TYPEC_STATE_USB; port->state.data = NULL; usb_role_switch_set_role(port->role_sw, USB_ROLE_NONE); typec_switch_set(port->ori_sw, TYPEC_ORIENTATION_NONE); - typec_mux_set(port->mux, &port->state); + + return typec_mux_set(port->mux, &port->state); +} + +static void cros_typec_remove_partner(struct cros_typec_data *typec, + int port_num) +{ + struct cros_typec_port *port = typec->ports[port_num]; + + cros_typec_unregister_altmodes(typec, port_num, true); + + cros_typec_usb_disconnect_state(port); typec_unregister_partner(port->partner); port->partner = NULL; @@ -536,8 +542,10 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, enum typec_orientation orientation; int ret; - if (!port->partner) - return 0; + if (mux_flags == USB_PD_MUX_NONE) { + ret = cros_typec_usb_disconnect_state(port); + goto mux_ack; + } if (mux_flags & USB_PD_MUX_POLARITY_INVERTED) orientation = TYPEC_ORIENTATION_REVERSE; @@ -572,6 +580,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, mux_flags); } +mux_ack: if (!typec->needs_mux_ack) return ret; @@ -638,9 +647,8 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec, "Failed to register partner on port: %d\n", port_num); } else { - if (!typec->ports[port_num]->partner) - return; - cros_typec_remove_partner(typec, port_num); + if (typec->ports[port_num]->partner) + cros_typec_remove_partner(typec, port_num); if (typec->ports[port_num]->cable) cros_typec_remove_cable(typec, port_num); @@ -1060,6 +1068,7 @@ static int cros_ec_typec_event(struct notifier_block *nb, { struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, nb); + flush_work(&typec->port_work); schedule_work(&typec->port_work); return NOTIFY_OK; diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c index f3a70a312b43..c859c862d7ac 100644 --- a/drivers/platform/chrome/cros_ec_vbc.c +++ b/drivers/platform/chrome/cros_ec_vbc.c @@ -101,7 +101,7 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { NULL }; -static struct attribute_group cros_ec_vbc_attr_group = { +static const struct attribute_group cros_ec_vbc_attr_group = { .name = "vbc", .bin_attrs = cros_ec_vbc_bin_attrs, }; diff --git a/drivers/platform/chrome/wilco_ec/sysfs.c b/drivers/platform/chrome/wilco_ec/sysfs.c index 3c587b4054a5..79a5e8fa680f 100644 --- a/drivers/platform/chrome/wilco_ec/sysfs.c +++ b/drivers/platform/chrome/wilco_ec/sysfs.c @@ -236,7 +236,7 @@ static struct attribute *wilco_dev_attrs[] = { NULL, }; -static struct attribute_group wilco_dev_attr_group = { +static const struct attribute_group wilco_dev_attr_group = { .attrs = wilco_dev_attrs, }; |