forked from Minki/linux
clear-pd-discovery-events
This pair of patches fixes an issue where cros_ec_typec creates stale cable nodes on detach because of uncleared pd discovery status events. -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCYBxH/QAKCRBzbaomhzOw wr9vAQC/mts0FPAvWh2aIrSmsb7FdzRonPYcVlPcyHe2K4ihPAD7BEjnNsRmUNFb FmBSkA7TSMpLLprkfG1xi+vSZUFDewo= =kXCq -----END PGP SIGNATURE----- Merge tag 'tag-ib-usb-typec-chrome-platform-cros-ec-typec-clear-pd-discovery-events-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux into usb-next Benson writes: clear-pd-discovery-events This pair of patches fixes an issue where cros_ec_typec creates stale cable nodes on detach because of uncleared pd discovery status events. * tag 'tag-ib-usb-typec-chrome-platform-cros-ec-typec-clear-pd-discovery-events-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: cros_ec_typec: Clear Type C disc events platform/chrome: cros_ec: Import Type C control command
This commit is contained in:
commit
89451aabea
@ -870,6 +870,18 @@ disc_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_num, u32 events_mask)
|
||||
{
|
||||
struct ec_params_typec_control req = {
|
||||
.port = port_num,
|
||||
.command = TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
|
||||
.clear_events_mask = events_mask,
|
||||
};
|
||||
|
||||
return cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_CONTROL, &req,
|
||||
sizeof(req), NULL, 0);
|
||||
}
|
||||
|
||||
static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
|
||||
{
|
||||
struct ec_response_typec_status resp;
|
||||
@ -894,9 +906,14 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
|
||||
ret = cros_typec_handle_sop_disc(typec, port_num, sop_revision);
|
||||
if (ret < 0)
|
||||
dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num);
|
||||
else
|
||||
else {
|
||||
typec->ports[port_num]->sop_disc_done = true;
|
||||
|
||||
ret = cros_typec_send_clear_event(typec, port_num,
|
||||
PD_STATUS_EVENT_SOP_DISC_DONE);
|
||||
if (ret < 0)
|
||||
dev_warn(typec->dev,
|
||||
"Failed SOP Disc event clear, port: %d\n", port_num);
|
||||
}
|
||||
if (resp.sop_connected)
|
||||
typec_set_pwr_opmode(typec->ports[port_num]->port, TYPEC_PWR_MODE_PD);
|
||||
}
|
||||
@ -910,8 +927,14 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
|
||||
ret = cros_typec_handle_sop_prime_disc(typec, port_num, sop_prime_revision);
|
||||
if (ret < 0)
|
||||
dev_err(typec->dev, "Couldn't parse SOP' Disc data, port: %d\n", port_num);
|
||||
else
|
||||
else {
|
||||
typec->ports[port_num]->sop_prime_disc_done = true;
|
||||
ret = cros_typec_send_clear_event(typec, port_num,
|
||||
PD_STATUS_EVENT_SOP_PRIME_DISC_DONE);
|
||||
if (ret < 0)
|
||||
dev_warn(typec->dev,
|
||||
"Failed SOP Disc event clear, port: %d\n", port_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5577,6 +5577,32 @@ struct ec_response_typec_discovery {
|
||||
struct svid_mode_info svids[0];
|
||||
} __ec_align1;
|
||||
|
||||
/* USB Type-C commands for AP-controlled device policy. */
|
||||
#define EC_CMD_TYPEC_CONTROL 0x0132
|
||||
|
||||
enum typec_control_command {
|
||||
TYPEC_CONTROL_COMMAND_EXIT_MODES,
|
||||
TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
|
||||
TYPEC_CONTROL_COMMAND_ENTER_MODE,
|
||||
};
|
||||
|
||||
struct ec_params_typec_control {
|
||||
uint8_t port;
|
||||
uint8_t command; /* enum typec_control_command */
|
||||
uint16_t reserved;
|
||||
|
||||
/*
|
||||
* This section will be interpreted based on |command|. Define a
|
||||
* placeholder structure to avoid having to increase the size and bump
|
||||
* the command version when adding new sub-commands.
|
||||
*/
|
||||
union {
|
||||
uint32_t clear_events_mask;
|
||||
uint8_t mode_to_enter; /* enum typec_mode */
|
||||
uint8_t placeholder[128];
|
||||
};
|
||||
} __ec_align1;
|
||||
|
||||
/*
|
||||
* Gather all status information for a port.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user