pd: add pd vdm verify notify passageway

add pd vdm verify notify passageway to
mmi discrete charger core.

Change-Id: Ia7989b11f425f86085e398bafdfd2b14e0d18c3a
Signed-off-by: mahj8 <mahj8@motorola.com>
Reviewed-on: https://gerrit.mot.com/2258492
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Lu Chai <chailu1@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
mahj8 2022-05-03 11:25:41 +08:00 • committed by Haijian Ma
commit 7c90ce4083
8 changed files with 43 additions and 0 deletions

View file

@ -868,6 +868,7 @@ struct pd_port {
uint8_t state_machine;
uint8_t pd_connect_state;
uint8_t pd_vdm_verify_state;
uint8_t pe_pd_state;
uint8_t pe_vdm_state;
@ -1233,6 +1234,7 @@ void pd_lock_msg_output(struct pd_port *pd_port);
void pd_unlock_msg_output(struct pd_port *pd_port);
int pd_update_connect_state(struct pd_port *pd_port, uint8_t state);
int pd_update_vdm_verify_state(struct pd_port *pd_port, uint8_t state);
/* ---- PD notify TCPC Policy Engine State Changed ---- */

View file

@ -154,6 +154,7 @@ int tcpci_notify_typec_state(struct tcpc_device *tcpc);
int tcpci_notify_role_swap(
struct tcpc_device *tcpc, uint8_t event, uint8_t role);
int tcpci_notify_pd_state(struct tcpc_device *tcpc, uint8_t connect);
int tcpci_notify_pd_vdm_verify(struct tcpc_device *tcpc, uint8_t vdm_verify);
int tcpci_set_intrst(struct tcpc_device *tcpc, bool en);
int tcpci_enable_watchdog(struct tcpc_device *tcpc, bool en);

View file

@ -146,10 +146,14 @@ enum {
TCP_NOTIFY_WD_STATUS,
TCP_NOTIFY_CABLE_TYPE,
TCP_NOTIFY_MISC_END = TCP_NOTIFY_CABLE_TYPE,
/*mmi pd vdm verify*/
TCP_NOTIFY_PD_VDM_VERIFY,
};
struct tcp_ny_pd_state {
uint8_t connected;
uint8_t vdm_verify;
};
struct tcp_ny_swap_state {

View file

@ -1410,6 +1410,18 @@ int pd_update_connect_state(struct pd_port *pd_port, uint8_t state)
return tcpci_notify_pd_state(tcpc, state);
}
int pd_update_vdm_verify_state(struct pd_port *pd_port, uint8_t state)
{
struct tcpc_device __maybe_unused *tcpc = pd_port->tcpc;
if (pd_port->pd_vdm_verify_state == state)
return 0;
pd_port->pd_vdm_verify_state = state;
PE_INFO("pd_vdm_verify_state=%d\n", state);
return tcpci_notify_pd_vdm_verify(tcpc, state);
}
#ifdef CONFIG_USB_PD_REV30
/*

View file

@ -280,6 +280,9 @@ int mmi_notify_pe_ready(struct pd_port *pd_port,
case MMI_VERIFY:
mmi_adapter_verify(pd_port,svid_data);
break;
case MMI_READY:
pd_update_vdm_verify_state(pd_port, true);
break;
default:
break;
}

View file

@ -81,11 +81,13 @@ enum iio_psy_property {
POWER_SUPPLY_IIO_OTG_ENABLE,
POWER_SUPPLY_IIO_TYPEC_MODE,
POWER_SUPPLY_IIO_PD_ACTIVE,
POWER_SUPPLY_IIO_MMI_PD_VDM_VERIFY,
POWER_SUPPLY_IIO_PROP_MAX,
};
static const char * const iio_channel_map[] = {
"usb_real_type", "otg_enable", "typec_mode", "pd_active",
"mmi_pd_vdm_verify",
};
static int mmi_get_psy_iio_property(struct rt_pd_manager_data *rpmd,
@ -635,6 +637,13 @@ static int pd_tcp_notifier_call(struct notifier_block *nb,
break;
}
break;
case TCP_NOTIFY_PD_VDM_VERIFY:
dev_info(rpmd->dev, "%s mmi pd vdm verify state = %d\n",
__func__, noti->pd_state.vdm_verify);
val.intval = noti->pd_state.vdm_verify;
mmi_set_psy_iio_property(rpmd,
POWER_SUPPLY_IIO_MMI_PD_VDM_VERIFY, &val);
break;
default:
break;
};

View file

@ -531,6 +531,17 @@ int tcpci_notify_pd_state(struct tcpc_device *tcpc, uint8_t connect)
return ret;
}
int tcpci_notify_pd_vdm_verify(struct tcpc_device *tcpc, uint8_t vdm_verify)
{
struct tcp_notify tcp_noti;
int ret;
tcp_noti.pd_state.vdm_verify = vdm_verify;
ret = tcpc_check_notify_time(tcpc, &tcp_noti,
TCP_NOTIFY_IDX_USB, TCP_NOTIFY_PD_VDM_VERIFY);
return ret;
}
int tcpci_set_intrst(struct tcpc_device *tcpc, bool en)
{
#ifdef CONFIG_TCPC_INTRST_EN

View file

@ -1029,6 +1029,7 @@ void pd_notify_pe_idle(struct pd_port *pd_port)
mutex_unlock(&tcpc->access_lock);
pd_update_connect_state(pd_port, PD_CONNECT_NONE);
pd_update_vdm_verify_state(pd_port, false);
if (notify_pe_idle)
tcpc_enable_timer(tcpc, TYPEC_RT_TIMER_PE_IDLE);