Commit 27ffe4ff authored by Diogo Ivo's avatar Diogo Ivo Committed by Greg Kroah-Hartman

usb: typec: ucsi: Only enable supported notifications

The UCSI specification defines some notifications to be optional for the
PPM to support. From these only enable the ones the PPM informs us are
actually supported.
Signed-off-by: default avatarDiogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/yhz7nq622mbg3rqsyvqz632pc756niagpfbnzayfswhzo7esho@vrdtx5c3hjgxSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a2723e29
......@@ -1672,6 +1672,27 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
return ret;
}
static u64 ucsi_get_supported_notifications(struct ucsi *ucsi)
{
u8 features = ucsi->cap.features;
u64 ntfy = UCSI_ENABLE_NTFY_ALL;
if (!(features & UCSI_CAP_ALT_MODE_DETAILS))
ntfy &= ~UCSI_ENABLE_NTFY_CAM_CHANGE;
if (!(features & UCSI_CAP_PDO_DETAILS))
ntfy &= ~(UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE |
UCSI_ENABLE_NTFY_CAP_CHANGE);
if (!(features & UCSI_CAP_EXT_SUPPLY_NOTIFICATIONS))
ntfy &= ~UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE;
if (!(features & UCSI_CAP_PD_RESET))
ntfy &= ~UCSI_ENABLE_NTFY_PD_RESET_COMPLETE;
return ntfy;
}
/**
* ucsi_init - Initialize UCSI interface
* @ucsi: UCSI to be initialized
......@@ -1726,8 +1747,8 @@ static int ucsi_init(struct ucsi *ucsi)
goto err_unregister;
}
/* Enable all notifications */
ntfy = UCSI_ENABLE_NTFY_ALL;
/* Enable all supported notifications */
ntfy = ucsi_get_supported_notifications(ucsi);
command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
ret = ucsi_send_command(ucsi, command, NULL, 0);
if (ret < 0)
......
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