Skip to content

Commit b996c10

Browse files
committed
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
2 parents f158bbe + a59e122 commit b996c10

File tree

11 files changed

+67
-39
lines changed

11 files changed

+67
-39
lines changed

drivers/platform/chrome/cros_ec.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ static struct cros_ec_platform pd_p = {
3232
.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX),
3333
};
3434

35-
static irqreturn_t ec_irq_handler(int irq, void *data)
35+
/**
36+
* cros_ec_irq_handler() - top half part of the interrupt handler
37+
* @irq: IRQ id
38+
* @data: (ec_dev) Device with events to process.
39+
*
40+
* Return: Wakeup the bottom half
41+
*/
42+
static irqreturn_t cros_ec_irq_handler(int irq, void *data)
3643
{
3744
struct cros_ec_device *ec_dev = data;
3845

@@ -51,7 +58,7 @@ static irqreturn_t ec_irq_handler(int irq, void *data)
5158
* Return: true if more events are still pending and this function should be
5259
* called again.
5360
*/
54-
bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
61+
static bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
5562
{
5663
bool wake_event;
5764
bool ec_has_more_events;
@@ -73,9 +80,15 @@ bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
7380

7481
return ec_has_more_events;
7582
}
76-
EXPORT_SYMBOL(cros_ec_handle_event);
7783

78-
static irqreturn_t ec_irq_thread(int irq, void *data)
84+
/**
85+
* cros_ec_irq_thread() - bottom half part of the interrupt handler
86+
* @irq: IRQ id
87+
* @data: (ec_dev) Device with events to process.
88+
*
89+
* Return: Interrupt handled.
90+
*/
91+
irqreturn_t cros_ec_irq_thread(int irq, void *data)
7992
{
8093
struct cros_ec_device *ec_dev = data;
8194
bool ec_has_more_events;
@@ -86,6 +99,7 @@ static irqreturn_t ec_irq_thread(int irq, void *data)
8699

87100
return IRQ_HANDLED;
88101
}
102+
EXPORT_SYMBOL(cros_ec_irq_thread);
89103

90104
static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
91105
{
@@ -194,8 +208,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
194208

195209
if (ec_dev->irq > 0) {
196210
err = devm_request_threaded_irq(dev, ec_dev->irq,
197-
ec_irq_handler,
198-
ec_irq_thread,
211+
cros_ec_irq_handler,
212+
cros_ec_irq_thread,
199213
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
200214
"chromeos-ec", ec_dev);
201215
if (err) {
@@ -269,6 +283,13 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
269283

270284
dev_info(dev, "Chrome EC device registered\n");
271285

286+
/*
287+
* Unlock EC that may be waiting for AP to process MKBP events.
288+
* If the AP takes to long to answer, the EC would stop sending events.
289+
*/
290+
if (ec_dev->mkbp_event_supported)
291+
cros_ec_irq_thread(0, ec_dev);
292+
272293
return 0;
273294
}
274295
EXPORT_SYMBOL(cros_ec_register);

drivers/platform/chrome/cros_ec.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
#ifndef __CROS_EC_H
99
#define __CROS_EC_H
1010

11+
#include <linux/interrupt.h>
12+
1113
int cros_ec_register(struct cros_ec_device *ec_dev);
1214
int cros_ec_unregister(struct cros_ec_device *ec_dev);
1315

1416
int cros_ec_suspend(struct cros_ec_device *ec_dev);
1517
int cros_ec_resume(struct cros_ec_device *ec_dev);
1618

17-
bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
19+
irqreturn_t cros_ec_irq_thread(int irq, void *data);
1820

1921
#endif /* __CROS_EC_H */

drivers/platform/chrome/cros_ec_ishtp.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,8 @@ static void ish_evt_handler(struct work_struct *work)
140140
{
141141
struct ishtp_cl_data *client_data =
142142
container_of(work, struct ishtp_cl_data, work_ec_evt);
143-
struct cros_ec_device *ec_dev = client_data->ec_dev;
144-
bool ec_has_more_events;
145143

146-
do {
147-
ec_has_more_events = cros_ec_handle_event(ec_dev);
148-
} while (ec_has_more_events);
144+
cros_ec_irq_thread(0, client_data->ec_dev);
149145
}
150146

151147
/**

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static struct attribute *__lb_cmds_attrs[] = {
523523
NULL,
524524
};
525525

526-
static struct attribute_group cros_ec_lightbar_attr_group = {
526+
static const struct attribute_group cros_ec_lightbar_attr_group = {
527527
.name = "lightbar",
528528
.attrs = __lb_cmds_attrs,
529529
};

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,13 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
526526
* power), not wake up.
527527
*/
528528
ec_dev->host_event_wake_mask = U32_MAX &
529-
~(BIT(EC_HOST_EVENT_AC_DISCONNECTED) |
530-
BIT(EC_HOST_EVENT_BATTERY_LOW) |
531-
BIT(EC_HOST_EVENT_BATTERY_CRITICAL) |
532-
BIT(EC_HOST_EVENT_PD_MCU) |
533-
BIT(EC_HOST_EVENT_BATTERY_STATUS));
529+
~(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED) |
530+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED) |
531+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW) |
532+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL) |
533+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY) |
534+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU) |
535+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS));
534536
/*
535537
* Old ECs may not support this command. Complain about all
536538
* other errors.

drivers/platform/chrome/cros_ec_rpmsg.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,8 @@ cros_ec_rpmsg_host_event_function(struct work_struct *host_event_work)
149149
struct cros_ec_rpmsg *ec_rpmsg = container_of(host_event_work,
150150
struct cros_ec_rpmsg,
151151
host_event_work);
152-
struct cros_ec_device *ec_dev = dev_get_drvdata(&ec_rpmsg->rpdev->dev);
153-
bool ec_has_more_events;
154152

155-
do {
156-
ec_has_more_events = cros_ec_handle_event(ec_dev);
157-
} while (ec_has_more_events);
153+
cros_ec_irq_thread(0, dev_get_drvdata(&ec_rpmsg->rpdev->dev));
158154
}
159155

160156
static int cros_ec_rpmsg_callback(struct rpmsg_device *rpdev, void *data,

drivers/platform/chrome/cros_ec_sysfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static ssize_t reboot_show(struct device *dev,
2828
int count = 0;
2929

3030
count += scnprintf(buf + count, PAGE_SIZE - count,
31-
"ro|rw|cancel|cold|disable-jump|hibernate");
31+
"ro|rw|cancel|cold|disable-jump|hibernate|cold-ap-off");
3232
count += scnprintf(buf + count, PAGE_SIZE - count,
3333
" [at-shutdown]\n");
3434
return count;
@@ -46,6 +46,7 @@ static ssize_t reboot_store(struct device *dev,
4646
{"cancel", EC_REBOOT_CANCEL, 0},
4747
{"ro", EC_REBOOT_JUMP_RO, 0},
4848
{"rw", EC_REBOOT_JUMP_RW, 0},
49+
{"cold-ap-off", EC_REBOOT_COLD_AP_OFF, 0},
4950
{"cold", EC_REBOOT_COLD, 0},
5051
{"disable-jump", EC_REBOOT_DISABLE_JUMP, 0},
5152
{"hibernate", EC_REBOOT_HIBERNATE, 0},
@@ -329,7 +330,7 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj,
329330
return a->mode;
330331
}
331332

332-
static struct attribute_group cros_ec_attr_group = {
333+
static const struct attribute_group cros_ec_attr_group = {
333334
.attrs = __ec_attrs,
334335
.is_visible = cros_ec_ctrl_visible,
335336
};

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,26 @@ static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int po
203203
}
204204
}
205205

206-
static void cros_typec_remove_partner(struct cros_typec_data *typec,
207-
int port_num)
206+
static int cros_typec_usb_disconnect_state(struct cros_typec_port *port)
208207
{
209-
struct cros_typec_port *port = typec->ports[port_num];
210-
211-
cros_typec_unregister_altmodes(typec, port_num, true);
212-
213208
port->state.alt = NULL;
214209
port->state.mode = TYPEC_STATE_USB;
215210
port->state.data = NULL;
216211

217212
usb_role_switch_set_role(port->role_sw, USB_ROLE_NONE);
218213
typec_switch_set(port->ori_sw, TYPEC_ORIENTATION_NONE);
219-
typec_mux_set(port->mux, &port->state);
214+
215+
return typec_mux_set(port->mux, &port->state);
216+
}
217+
218+
static void cros_typec_remove_partner(struct cros_typec_data *typec,
219+
int port_num)
220+
{
221+
struct cros_typec_port *port = typec->ports[port_num];
222+
223+
cros_typec_unregister_altmodes(typec, port_num, true);
224+
225+
cros_typec_usb_disconnect_state(port);
220226

221227
typec_unregister_partner(port->partner);
222228
port->partner = NULL;
@@ -536,8 +542,10 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
536542
enum typec_orientation orientation;
537543
int ret;
538544

539-
if (!port->partner)
540-
return 0;
545+
if (mux_flags == USB_PD_MUX_NONE) {
546+
ret = cros_typec_usb_disconnect_state(port);
547+
goto mux_ack;
548+
}
541549

542550
if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
543551
orientation = TYPEC_ORIENTATION_REVERSE;
@@ -572,6 +580,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
572580
mux_flags);
573581
}
574582

583+
mux_ack:
575584
if (!typec->needs_mux_ack)
576585
return ret;
577586

@@ -638,9 +647,8 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
638647
"Failed to register partner on port: %d\n",
639648
port_num);
640649
} else {
641-
if (!typec->ports[port_num]->partner)
642-
return;
643-
cros_typec_remove_partner(typec, port_num);
650+
if (typec->ports[port_num]->partner)
651+
cros_typec_remove_partner(typec, port_num);
644652

645653
if (typec->ports[port_num]->cable)
646654
cros_typec_remove_cable(typec, port_num);
@@ -1060,6 +1068,7 @@ static int cros_ec_typec_event(struct notifier_block *nb,
10601068
{
10611069
struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, nb);
10621070

1071+
flush_work(&typec->port_work);
10631072
schedule_work(&typec->port_work);
10641073

10651074
return NOTIFY_OK;

drivers/platform/chrome/cros_ec_vbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
101101
NULL
102102
};
103103

104-
static struct attribute_group cros_ec_vbc_attr_group = {
104+
static const struct attribute_group cros_ec_vbc_attr_group = {
105105
.name = "vbc",
106106
.bin_attrs = cros_ec_vbc_bin_attrs,
107107
};

drivers/platform/chrome/wilco_ec/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static struct attribute *wilco_dev_attrs[] = {
236236
NULL,
237237
};
238238

239-
static struct attribute_group wilco_dev_attr_group = {
239+
static const struct attribute_group wilco_dev_attr_group = {
240240
.attrs = wilco_dev_attrs,
241241
};
242242

0 commit comments

Comments
 (0)