Skip to content

Commit dd86005

Browse files
committed
Merge tag 'tag-chrome-platform-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Benson Leung: "cros_ec_typec: - Changes around DP mode check, hard reset, tracking port change. cros_ec misc: - wilco_ec: Convert stream-like files from nonseekable to stream open - cros_usbpd_notify: Listen to EC_HSOT_EVENT_USB_MUX host event - fix format warning in cros_ec_typec" * tag 'tag-chrome-platform-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: cros_ec_lpc: Use DEFINE_MUTEX() for mutex lock platform/chrome: cros_usbpd_notify: Listen to EC_HOST_EVENT_USB_MUX host event platform/chrome: cros_ec_typec: Add DP mode check platform/chrome: cros_ec_typec: Handle hard reset platform/chrome: cros_ec: Add Type C hard reset platform/chrome: cros_ec_typec: Track port role platform/chrome: cros_ec_typec: fix clang -Wformat warning platform/chrome: cros_ec_typec: Check for device within remove function platform/chrome: wilco_ec: convert stream-like files from nonseekable_open -> stream_open
2 parents 1ad77a0 + d61b3f9 commit dd86005

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

drivers/platform/chrome/cros_ec_lpc_mec.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* This mutex must be held while accessing the EMI unit. We can't rely on the
1515
* EC mutex because memmap data may be accessed without it being held.
1616
*/
17-
static struct mutex io_mutex;
17+
static DEFINE_MUTEX(io_mutex);
1818
static u16 mec_emi_base, mec_emi_end;
1919

2020
/**
@@ -142,7 +142,6 @@ EXPORT_SYMBOL(cros_ec_lpc_io_bytes_mec);
142142

143143
void cros_ec_lpc_mec_init(unsigned int base, unsigned int end)
144144
{
145-
mutex_init(&io_mutex);
146145
mec_emi_base = base;
147146
mec_emi_end = end;
148147
}

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct cros_typec_port {
5858
/* Variables keeping track of switch state. */
5959
struct typec_mux_state state;
6060
uint8_t mux_flags;
61+
uint8_t role;
6162

6263
/* Port alt modes. */
6364
struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];
@@ -220,6 +221,9 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
220221
{
221222
struct cros_typec_port *port = typec->ports[port_num];
222223

224+
if (!port->partner)
225+
return;
226+
223227
cros_typec_unregister_altmodes(typec, port_num, true);
224228

225229
cros_typec_usb_disconnect_state(port);
@@ -235,6 +239,9 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
235239
{
236240
struct cros_typec_port *port = typec->ports[port_num];
237241

242+
if (!port->cable)
243+
return;
244+
238245
cros_typec_unregister_altmodes(typec, port_num, false);
239246

240247
typec_unregister_plug(port->plug);
@@ -253,11 +260,8 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
253260
if (!typec->ports[i])
254261
continue;
255262

256-
if (typec->ports[i]->partner)
257-
cros_typec_remove_partner(typec, i);
258-
259-
if (typec->ports[i]->cable)
260-
cros_typec_remove_cable(typec, i);
263+
cros_typec_remove_partner(typec, i);
264+
cros_typec_remove_cable(typec, i);
261265

262266
usb_role_switch_put(typec->ports[i]->role_sw);
263267
typec_switch_put(typec->ports[i]->ori_sw);
@@ -483,6 +487,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec,
483487
return -ENOTSUPP;
484488
}
485489

490+
if (!pd_ctrl->dp_mode) {
491+
dev_err(typec->dev, "No valid DP mode provided.\n");
492+
return -EINVAL;
493+
}
494+
486495
/* Status VDO. */
487496
dp_data.status = DP_STATUS_ENABLED;
488497
if (port->mux_flags & USB_PD_MUX_HPD_IRQ)
@@ -647,11 +656,8 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
647656
"Failed to register partner on port: %d\n",
648657
port_num);
649658
} else {
650-
if (typec->ports[port_num]->partner)
651-
cros_typec_remove_partner(typec, port_num);
652-
653-
if (typec->ports[port_num]->cable)
654-
cros_typec_remove_cable(typec, port_num);
659+
cros_typec_remove_partner(typec, port_num);
660+
cros_typec_remove_cable(typec, port_num);
655661
}
656662
}
657663

@@ -905,6 +911,19 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
905911
return;
906912
}
907913

914+
/* If we got a hard reset, unregister everything and return. */
915+
if (resp.events & PD_STATUS_EVENT_HARD_RESET) {
916+
cros_typec_remove_partner(typec, port_num);
917+
cros_typec_remove_cable(typec, port_num);
918+
919+
ret = cros_typec_send_clear_event(typec, port_num,
920+
PD_STATUS_EVENT_HARD_RESET);
921+
if (ret < 0)
922+
dev_warn(typec->dev,
923+
"Failed hard reset event clear, port: %d\n", port_num);
924+
return;
925+
}
926+
908927
/* Handle any events appropriately. */
909928
if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) {
910929
u16 sop_revision;
@@ -995,10 +1014,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
9951014
}
9961015

9971016
/* No change needs to be made, let's exit early. */
998-
if (typec->ports[port_num]->mux_flags == mux_resp.flags)
1017+
if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
1018+
typec->ports[port_num]->role == resp.role)
9991019
return 0;
10001020

10011021
typec->ports[port_num]->mux_flags = mux_resp.flags;
1022+
typec->ports[port_num]->role = resp.role;
10021023
ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
10031024
if (ret)
10041025
dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);
@@ -1027,8 +1048,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
10271048
else
10281049
typec->pd_ctrl_ver = 0;
10291050

1030-
dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
1031-
typec->pd_ctrl_ver);
1051+
dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
1052+
typec->pd_ctrl_ver & 0xff);
10321053

10331054
return 0;
10341055
}

drivers/platform/chrome/cros_usbpd_notify.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ static int cros_usbpd_notify_plat(struct notifier_block *nb,
220220
if (!host_event)
221221
return NOTIFY_DONE;
222222

223-
if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) {
223+
if (host_event & (EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU) |
224+
EC_HOST_EVENT_MASK(EC_HOST_EVENT_USB_MUX))) {
224225
cros_usbpd_get_event_and_notify(pdnotify->dev, ec_dev);
225226
return NOTIFY_OK;
226227
}

drivers/platform/chrome/wilco_ec/telemetry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static int telem_open(struct inode *inode, struct file *filp)
256256
sess_data->dev_data = dev_data;
257257
sess_data->has_msg = false;
258258

259-
nonseekable_open(inode, filp);
259+
stream_open(inode, filp);
260260
filp->private_data = sess_data;
261261

262262
return 0;

include/linux/platform_data/cros_ec_commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5679,6 +5679,7 @@ enum tcpc_cc_polarity {
56795679

56805680
#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)
56815681
#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)
5682+
#define PD_STATUS_EVENT_HARD_RESET BIT(2)
56825683

56835684
struct ec_params_typec_status {
56845685
uint8_t port;

0 commit comments

Comments
 (0)