tcpc: add typeC mode switch interface

add typec mode switch interface
this interface for only typeC and not support PD product.

Change-Id: I5e5b352504e475a755561dc4875fea1b576417c1
Signed-off-by: chailu1 <chailu1@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2105408
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
chailu1 2021-11-02 13:45:13 +08:00 • committed by Lu Chai
commit ea948fedb6
6 changed files with 40 additions and 1 deletions

View file

@ -87,6 +87,7 @@ int tcpci_init_alert_mask(struct tcpc_device *tcpc);
int tcpci_get_cc(struct tcpc_device *tcpc);
int tcpci_set_cc(struct tcpc_device *tcpc, int pull);
int tcpci_set_polarity(struct tcpc_device *tcpc, int polarity);
int tcpci_set_port_type(struct tcpc_device *tcpc, int mode);
int tcpci_set_low_rp_duty(struct tcpc_device *tcpc, bool low_rp);
int tcpci_set_vconn(struct tcpc_device *tcpc, int enable);

View file

@ -214,7 +214,7 @@ struct tcpc_ops {
int (*set_vconn)(struct tcpc_device *tcpc, int enable);
int (*deinit)(struct tcpc_device *tcpc);
int (*alert_vendor_defined_handler)(struct tcpc_device *tcpc);
int (*set_port_type)(struct tcpc_device *tcpc, int mode);
#ifdef CONFIG_TCPC_VSAFE0V_DETECT_IC
int (*is_vsafe0v)(struct tcpc_device *tcpc);
#endif /* CONFIG_TCPC_VSAFE0V_DETECT_IC */

View file

@ -874,6 +874,9 @@ extern int tcpm_typec_role_swap(
extern int tcpm_typec_change_role(
struct tcpc_device *tcpc, uint8_t typec_role);
extern int tcpm_typec_change_mode(
struct tcpc_device *tcpc, uint8_t mode);
extern int tcpm_typec_change_role_postpone(
struct tcpc_device *tcpc, uint8_t typec_role, bool postpone);
@ -1369,6 +1372,12 @@ static inline int tcpm_typec_change_role(
return TCPM_ERROR_NO_IMPLEMENT;
}
static inline int tcpm_typec_change_mode(
struct tcpc_device *tcpc, uint8_t mode)
{
return TCPM_ERROR_NO_IMPLEMENT;
}
static inline int tcpm_typec_change_role_postpone(
struct tcpc_device *tcpc, uint8_t typec_role, bool postpone)
{

View file

@ -770,6 +770,12 @@ static int tcpc_typec_port_type_set(const struct typec_capability *cap,
dev_info(rpmd->dev, "%s type = %d, as_sink = %d\n",
__func__, type, as_sink);
if (0 == tcpm_typec_change_mode(rpmd->tcpc, type)) {
dev_info(rpmd->dev, "%s Only type C mode and not support PD\n",
__func__);
return 0;
}
switch (type) {
case TYPEC_PORT_SNK:
if (as_sink)

View file

@ -268,6 +268,16 @@ int tcpci_set_polarity(struct tcpc_device *tcpc, int polarity)
return tcpc->ops->set_polarity(tcpc, polarity);
}
int tcpci_set_port_type(struct tcpc_device *tcpc, int mode)
{
if (tcpc->ops->set_port_type == NULL)
return -ENOTSUPP;
else
tcpc->ops->set_port_type(tcpc, mode);
return 0;
}
int tcpci_set_low_rp_duty(struct tcpc_device *tcpc, bool low_rp)
{
#ifdef CONFIG_TYPEC_CAP_LOW_RP_DUTY

View file

@ -288,6 +288,19 @@ int tcpm_typec_role_swap(struct tcpc_device *tcpc)
}
EXPORT_SYMBOL(tcpm_typec_role_swap);
int tcpm_typec_change_mode(
struct tcpc_device *tcpc, uint8_t mode)
{
int ret = 0;
tcpci_lock_typec(tcpc);
ret = tcpci_set_port_type(tcpc, mode);
tcpci_unlock_typec(tcpc);
return ret;
}
EXPORT_SYMBOL(tcpm_typec_change_mode);
int tcpm_typec_change_role(
struct tcpc_device *tcpc, uint8_t typec_role)
{