History

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

Linus Torvalds committed 5 years ago

Commit dd860052 parents 1ad77a0 d61b3f95 files · +39 −17Browse files

Unified · Split

5 files
  1. drivers/platform/chrome/cros_ec_lpc_mec.c +1 −2
  2. drivers/platform/chrome/cros_ec_typec.c +34 −13
  3. drivers/platform/chrome/cros_usbpd_notify.c +2 −1
  4. drivers/platform/chrome/wilco_ec/telemetry.c +1 −1
  5. include/linux/platform_data/cros_ec_commands.h +1 −0
drivers/platform/chrome/cros_ec_lpc_mec.c+1−2
@@ -14,7 +14,7 @@ · 13 unmodified lines
14 * This mutex must be held while accessing the EMI unit. We can't rely on the14 * This mutex must be held while accessing the EMI unit. We can't rely on the
15 * EC mutex because memmap data may be accessed without it being held.15 * EC mutex because memmap data may be accessed without it being held.
16 */16 */
17static struct mutex io_mutex;17static DEFINE_MUTEX(io_mutex);
18static u16 mec_emi_base, mec_emi_end;18static u16 mec_emi_base, mec_emi_end;
19 19
20/**20/**
@@ -142,7 +142,6 @@ EXPORT_SYMBOL(cros_ec_lpc_io_bytes_mec); · 121 unmodified lines
142 142
143void cros_ec_lpc_mec_init(unsigned int base, unsigned int end)143void cros_ec_lpc_mec_init(unsigned int base, unsigned int end)
144{144{
145 mutex_init(&io_mutex);
146 mec_emi_base = base;145 mec_emi_base = base;
147 mec_emi_end = end;146 mec_emi_end = end;
148}147}
drivers/platform/chrome/cros_ec_typec.c+34−13
@@ -58,6 +58,7 @@ struct cros_typec_port { · 57 unmodified lines
58 /* Variables keeping track of switch state. */58 /* Variables keeping track of switch state. */
59 struct typec_mux_state state;59 struct typec_mux_state state;
60 uint8_t mux_flags;60 uint8_t mux_flags;
61 uint8_t role;
61 62
62 /* Port alt modes. */63 /* Port alt modes. */
63 struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];64 struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];
@@ -220,6 +221,9 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec, · 156 unmodified lines
220{221{
221 struct cros_typec_port *port = typec->ports[port_num];222 struct cros_typec_port *port = typec->ports[port_num];
222 223
224 if (!port->partner)
225 return;
226
223 cros_typec_unregister_altmodes(typec, port_num, true);227 cros_typec_unregister_altmodes(typec, port_num, true);
224 228
225 cros_typec_usb_disconnect_state(port);229 cros_typec_usb_disconnect_state(port);
@@ -235,6 +239,9 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec, · 9 unmodified lines
235{239{
236 struct cros_typec_port *port = typec->ports[port_num];240 struct cros_typec_port *port = typec->ports[port_num];
237 241
242 if (!port->cable)
243 return;
244
238 cros_typec_unregister_altmodes(typec, port_num, false);245 cros_typec_unregister_altmodes(typec, port_num, false);
239 246
240 typec_unregister_plug(port->plug);247 typec_unregister_plug(port->plug);
@@ -253,11 +260,8 @@ static void cros_unregister_ports(struct cros_typec_data *typec) · 12 unmodified lines
253 if (!typec->ports[i])260 if (!typec->ports[i])
254 continue;261 continue;
255 262
256 if (typec->ports[i]->partner)263 cros_typec_remove_partner(typec, i);
257 cros_typec_remove_partner(typec, i);264 cros_typec_remove_cable(typec, i);
258
259 if (typec->ports[i]->cable)
260 cros_typec_remove_cable(typec, i);
261 265
262 usb_role_switch_put(typec->ports[i]->role_sw);266 usb_role_switch_put(typec->ports[i]->role_sw);
263 typec_switch_put(typec->ports[i]->ori_sw);267 typec_switch_put(typec->ports[i]->ori_sw);
@@ -483,6 +487,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, · 219 unmodified lines
483 return -ENOTSUPP;487 return -ENOTSUPP;
484 }488 }
485 489
490 if (!pd_ctrl->dp_mode) {
491 dev_err(typec->dev, "No valid DP mode provided.\n");
492 return -EINVAL;
493 }
494
486 /* Status VDO. */495 /* Status VDO. */
487 dp_data.status = DP_STATUS_ENABLED;496 dp_data.status = DP_STATUS_ENABLED;
488 if (port->mux_flags & USB_PD_MUX_HPD_IRQ)497 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, · 158 unmodified lines
647 "Failed to register partner on port: %d\n",656 "Failed to register partner on port: %d\n",
648 port_num);657 port_num);
649 } else {658 } else {
650 if (typec->ports[port_num]->partner)659 cros_typec_remove_partner(typec, port_num);
651 cros_typec_remove_partner(typec, port_num);660 cros_typec_remove_cable(typec, port_num);
652
653 if (typec->ports[port_num]->cable)
654 cros_typec_remove_cable(typec, port_num);
655 }661 }
656}662}
657 663
@@ -905,6 +911,19 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num · 247 unmodified lines
905 return;911 return;
906 }912 }
907 913
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
908 /* Handle any events appropriately. */927 /* Handle any events appropriately. */
909 if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) {928 if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) {
910 u16 sop_revision;929 u16 sop_revision;
@@ -995,10 +1014,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) · 84 unmodified lines
995 }1014 }
996 1015
997 /* No change needs to be made, let's exit early. */1016 /* 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)
999 return 0;1019 return 0;
1000 1020
1001 typec->ports[port_num]->mux_flags = mux_resp.flags;1021 typec->ports[port_num]->mux_flags = mux_resp.flags;
1022 typec->ports[port_num]->role = resp.role;
1002 ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);1023 ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
1003 if (ret)1024 if (ret)
1004 dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);1025 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) · 22 unmodified lines
1027 else1048 else
1028 typec->pd_ctrl_ver = 0;1049 typec->pd_ctrl_ver = 0;
1029 1050
1030 dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",1051 dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
1031 typec->pd_ctrl_ver);1052 typec->pd_ctrl_ver & 0xff);
1032 1053
1033 return 0;1054 return 0;
1034}1055}
drivers/platform/chrome/cros_usbpd_notify.c+2−1
@@ -220,7 +220,8 @@ static int cros_usbpd_notify_plat(struct notifier_block *nb, · 219 unmodified lines
220 if (!host_event)220 if (!host_event)
221 return NOTIFY_DONE;221 return NOTIFY_DONE;
222 222
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))) {
224 cros_usbpd_get_event_and_notify(pdnotify->dev, ec_dev);225 cros_usbpd_get_event_and_notify(pdnotify->dev, ec_dev);
225 return NOTIFY_OK;226 return NOTIFY_OK;
226 }227 }
drivers/platform/chrome/wilco_ec/telemetry.c+1−1
@@ -256,7 +256,7 @@ static int telem_open(struct inode *inode, struct file *filp) · 255 unmodified lines
256 sess_data->dev_data = dev_data;256 sess_data->dev_data = dev_data;
257 sess_data->has_msg = false;257 sess_data->has_msg = false;
258 258
259 nonseekable_open(inode, filp);259 stream_open(inode, filp);
260 filp->private_data = sess_data;260 filp->private_data = sess_data;
261 261
262 return 0;262 return 0;
include/linux/platform_data/cros_ec_commands.h+1−0
@@ -5679,6 +5679,7 @@ enum tcpc_cc_polarity { · 5678 unmodified lines
5679 5679
5680#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)5680#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)
5681#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)5681#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)
5682#define PD_STATUS_EVENT_HARD_RESET BIT(2)
5682 5683
5683struct ec_params_typec_status {5684struct ec_params_typec_status {
5684 uint8_t port;5685 uint8_t port;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t