Commit dd860052 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'tag-chrome-platform-for-v5.13' of...

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
parents 1ad77a05 d61b3f9b
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* This mutex must be held while accessing the EMI unit. We can't rely on the * This mutex must be held while accessing the EMI unit. We can't rely on the
* EC mutex because memmap data may be accessed without it being held. * EC mutex because memmap data may be accessed without it being held.
*/ */
static struct mutex io_mutex; static DEFINE_MUTEX(io_mutex);
static u16 mec_emi_base, mec_emi_end; static u16 mec_emi_base, mec_emi_end;
/** /**
...@@ -142,7 +142,6 @@ EXPORT_SYMBOL(cros_ec_lpc_io_bytes_mec); ...@@ -142,7 +142,6 @@ EXPORT_SYMBOL(cros_ec_lpc_io_bytes_mec);
void cros_ec_lpc_mec_init(unsigned int base, unsigned int end) void cros_ec_lpc_mec_init(unsigned int base, unsigned int end)
{ {
mutex_init(&io_mutex);
mec_emi_base = base; mec_emi_base = base;
mec_emi_end = end; mec_emi_end = end;
} }
......
...@@ -58,6 +58,7 @@ struct cros_typec_port { ...@@ -58,6 +58,7 @@ struct cros_typec_port {
/* Variables keeping track of switch state. */ /* Variables keeping track of switch state. */
struct typec_mux_state state; struct typec_mux_state state;
uint8_t mux_flags; uint8_t mux_flags;
uint8_t role;
/* Port alt modes. */ /* Port alt modes. */
struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX]; struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];
...@@ -220,6 +221,9 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec, ...@@ -220,6 +221,9 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
{ {
struct cros_typec_port *port = typec->ports[port_num]; struct cros_typec_port *port = typec->ports[port_num];
if (!port->partner)
return;
cros_typec_unregister_altmodes(typec, port_num, true); cros_typec_unregister_altmodes(typec, port_num, true);
cros_typec_usb_disconnect_state(port); cros_typec_usb_disconnect_state(port);
...@@ -235,6 +239,9 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec, ...@@ -235,6 +239,9 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
{ {
struct cros_typec_port *port = typec->ports[port_num]; struct cros_typec_port *port = typec->ports[port_num];
if (!port->cable)
return;
cros_typec_unregister_altmodes(typec, port_num, false); cros_typec_unregister_altmodes(typec, port_num, false);
typec_unregister_plug(port->plug); typec_unregister_plug(port->plug);
...@@ -253,11 +260,8 @@ static void cros_unregister_ports(struct cros_typec_data *typec) ...@@ -253,11 +260,8 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
if (!typec->ports[i]) if (!typec->ports[i])
continue; continue;
if (typec->ports[i]->partner) cros_typec_remove_partner(typec, i);
cros_typec_remove_partner(typec, i); cros_typec_remove_cable(typec, i);
if (typec->ports[i]->cable)
cros_typec_remove_cable(typec, i);
usb_role_switch_put(typec->ports[i]->role_sw); usb_role_switch_put(typec->ports[i]->role_sw);
typec_switch_put(typec->ports[i]->ori_sw); typec_switch_put(typec->ports[i]->ori_sw);
...@@ -483,6 +487,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, ...@@ -483,6 +487,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec,
return -ENOTSUPP; return -ENOTSUPP;
} }
if (!pd_ctrl->dp_mode) {
dev_err(typec->dev, "No valid DP mode provided.\n");
return -EINVAL;
}
/* Status VDO. */ /* Status VDO. */
dp_data.status = DP_STATUS_ENABLED; dp_data.status = DP_STATUS_ENABLED;
if (port->mux_flags & USB_PD_MUX_HPD_IRQ) 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, ...@@ -647,11 +656,8 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
"Failed to register partner on port: %d\n", "Failed to register partner on port: %d\n",
port_num); port_num);
} else { } else {
if (typec->ports[port_num]->partner) cros_typec_remove_partner(typec, port_num);
cros_typec_remove_partner(typec, port_num); cros_typec_remove_cable(typec, port_num);
if (typec->ports[port_num]->cable)
cros_typec_remove_cable(typec, port_num);
} }
} }
...@@ -905,6 +911,19 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num ...@@ -905,6 +911,19 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
return; return;
} }
/* If we got a hard reset, unregister everything and return. */
if (resp.events & PD_STATUS_EVENT_HARD_RESET) {
cros_typec_remove_partner(typec, port_num);
cros_typec_remove_cable(typec, port_num);
ret = cros_typec_send_clear_event(typec, port_num,
PD_STATUS_EVENT_HARD_RESET);
if (ret < 0)
dev_warn(typec->dev,
"Failed hard reset event clear, port: %d\n", port_num);
return;
}
/* Handle any events appropriately. */ /* Handle any events appropriately. */
if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) { if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) {
u16 sop_revision; u16 sop_revision;
...@@ -995,10 +1014,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) ...@@ -995,10 +1014,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
} }
/* No change needs to be made, let's exit early. */ /* No change needs to be made, let's exit early. */
if (typec->ports[port_num]->mux_flags == mux_resp.flags) if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
typec->ports[port_num]->role == resp.role)
return 0; return 0;
typec->ports[port_num]->mux_flags = mux_resp.flags; typec->ports[port_num]->mux_flags = mux_resp.flags;
typec->ports[port_num]->role = resp.role;
ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp); ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
if (ret) if (ret)
dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); 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) ...@@ -1027,8 +1048,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
else else
typec->pd_ctrl_ver = 0; typec->pd_ctrl_ver = 0;
dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n", dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
typec->pd_ctrl_ver); typec->pd_ctrl_ver & 0xff);
return 0; return 0;
} }
......
...@@ -220,7 +220,8 @@ static int cros_usbpd_notify_plat(struct notifier_block *nb, ...@@ -220,7 +220,8 @@ static int cros_usbpd_notify_plat(struct notifier_block *nb,
if (!host_event) if (!host_event)
return NOTIFY_DONE; return NOTIFY_DONE;
if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { if (host_event & (EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU) |
EC_HOST_EVENT_MASK(EC_HOST_EVENT_USB_MUX))) {
cros_usbpd_get_event_and_notify(pdnotify->dev, ec_dev); cros_usbpd_get_event_and_notify(pdnotify->dev, ec_dev);
return NOTIFY_OK; return NOTIFY_OK;
} }
......
...@@ -256,7 +256,7 @@ static int telem_open(struct inode *inode, struct file *filp) ...@@ -256,7 +256,7 @@ static int telem_open(struct inode *inode, struct file *filp)
sess_data->dev_data = dev_data; sess_data->dev_data = dev_data;
sess_data->has_msg = false; sess_data->has_msg = false;
nonseekable_open(inode, filp); stream_open(inode, filp);
filp->private_data = sess_data; filp->private_data = sess_data;
return 0; return 0;
......
...@@ -5679,6 +5679,7 @@ enum tcpc_cc_polarity { ...@@ -5679,6 +5679,7 @@ enum tcpc_cc_polarity {
#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0) #define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)
#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1) #define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)
#define PD_STATUS_EVENT_HARD_RESET BIT(2)
struct ec_params_typec_status { struct ec_params_typec_status {
uint8_t port; uint8_t port;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment