mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 05:39:54 -04:00
PD: apply sc2150A vendor patch
Apply sc2150A vendor patch @ 2022/03/11 : SC2150_compatible_patch_V1.4 SC2150_compatible_patch_V1.5 To fix Apple's 30W adapter stop charging issue when phone reboot Change-Id: I89171071a683e95b3693e2c15637c59cd75222da Signed-off-by: mahj8 <mahj8@motorola.com> Reviewed-on: https://gerrit.mot.com/2213778 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:
parent
a8a1ee44bf
commit
5cc70eeec3
6 changed files with 84 additions and 1 deletions
|
|
@ -854,6 +854,9 @@ struct pd_port {
|
|||
struct tcpc_device *tcpc;
|
||||
struct mutex pd_lock;
|
||||
|
||||
/* miss msg */
|
||||
bool miss_msg;
|
||||
uint8_t rx_cap;
|
||||
/* PD */
|
||||
bool msg_output_lock;
|
||||
|
||||
|
|
@ -1613,6 +1616,9 @@ enum { /* pd_traffic_control */
|
|||
#define PD30_SINK_TX_OK TYPEC_CC_RP_3_0
|
||||
#define PD30_SINK_TX_NG TYPEC_CC_RP_1_5
|
||||
|
||||
void pd_add_miss_msg(struct pd_port *pd_port,struct pd_event *pd_event,
|
||||
uint8_t msg);
|
||||
|
||||
void pd_set_sink_tx(struct pd_port *pd_port, uint8_t cc);
|
||||
void pd_sync_sop_spec_revision(struct pd_port *pd_port);
|
||||
void pd_sync_sop_prime_spec_revision(struct pd_port *pd_port, uint8_t rev);
|
||||
|
|
|
|||
|
|
@ -785,6 +785,7 @@ int pd_reset_protocol_layer(struct pd_port *pd_port, bool sop_only)
|
|||
|
||||
int pd_set_rx_enable(struct pd_port *pd_port, uint8_t enable)
|
||||
{
|
||||
pd_port->rx_cap = enable;
|
||||
return tcpci_set_rx_enable(pd_port->tcpc, enable);
|
||||
}
|
||||
|
||||
|
|
@ -1361,6 +1362,33 @@ void pd_lock_msg_output(struct pd_port *pd_port)
|
|||
pd_dbg_info_lock();
|
||||
}
|
||||
|
||||
void pd_add_miss_msg(struct pd_port *pd_port,struct pd_event *pd_event,
|
||||
uint8_t msg)
|
||||
{
|
||||
struct pd_msg *pd_msg = pd_event->pd_msg;
|
||||
struct pd_msg * miss_msg = NULL;
|
||||
uint8_t sop_type = 0;
|
||||
struct pd_event evt = {
|
||||
.event_type = PD_EVT_CTRL_MSG,
|
||||
.msg = msg,
|
||||
.pd_msg = NULL,
|
||||
};
|
||||
if (pd_msg != NULL) {
|
||||
sop_type = pd_msg->frame_type;
|
||||
}
|
||||
pd_put_event(pd_port->tcpc,&evt,true);
|
||||
miss_msg = pd_alloc_msg(pd_port->tcpc);
|
||||
if (miss_msg == NULL) {
|
||||
return;
|
||||
}
|
||||
if (pd_msg != NULL)
|
||||
memcpy(miss_msg,pd_msg,sizeof(struct pd_msg));
|
||||
|
||||
pd_put_pd_msg_event(pd_port->tcpc,miss_msg);
|
||||
pd_port->pe_data.msg_id_rx[sop_type]--;
|
||||
return;
|
||||
}
|
||||
|
||||
void pd_unlock_msg_output(struct pd_port *pd_port)
|
||||
{
|
||||
if (!pd_port->msg_output_lock)
|
||||
|
|
|
|||
|
|
@ -1065,9 +1065,17 @@ static inline bool pd_try_get_vdm_event(
|
|||
{
|
||||
bool ret = false;
|
||||
struct pd_port *pd_port = &tcpc->pd_port;
|
||||
int rv = 0;
|
||||
uint32_t chip_id;
|
||||
rv = tcpci_get_chip_id(tcpc, &chip_id);
|
||||
|
||||
switch (pd_port->pe_pd_state) {
|
||||
#ifdef CONFIG_USB_PD_PE_SINK
|
||||
case PE_SNK_TRANSITION_SINK:
|
||||
if (!rv && SC2150A_DID == chip_id) {
|
||||
ret = pd_get_vdm_event(tcpc, pd_event);
|
||||
}
|
||||
break;
|
||||
case PE_SNK_READY:
|
||||
ret = pd_get_vdm_event(tcpc, pd_event);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -569,6 +569,12 @@ static inline bool pe_is_valid_pd_msg_id(struct pd_port *pd_port,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (((pd_port->pe_data.msg_id_rx[sop_type] + 2) % PD_MSG_ID_MAX)
|
||||
== msg_id) {
|
||||
PE_INFO("Miss Msg!!!\n");
|
||||
pd_port->miss_msg = true;
|
||||
}
|
||||
|
||||
pd_port->pe_data.msg_id_rx[sop_type] = msg_id;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -767,6 +773,8 @@ bool pd_process_event(
|
|||
bool ret = false;
|
||||
struct pd_msg *pd_msg = pd_event->pd_msg;
|
||||
uint8_t tii = pe_check_trap_in_idle_state(pd_port, pd_event);
|
||||
int rv = 0;
|
||||
uint32_t chip_id = 0;
|
||||
|
||||
if (tii < TII_PE_RUNNING)
|
||||
return tii;
|
||||
|
|
@ -790,6 +798,23 @@ bool pd_process_event(
|
|||
PE_TRANSIT_STATE(pd_port, PE_ERROR_RECOVERY);
|
||||
return true;
|
||||
}
|
||||
rv = tcpci_get_chip_id(pd_port->tcpc, &chip_id);
|
||||
if (!rv && (SC2150A_DID == chip_id) &&pd_port->miss_msg) {
|
||||
if (pd_port->pe_pd_state == PE_SNK_TRANSITION_SINK) {
|
||||
pd_add_miss_msg(pd_port,pd_event,PD_CTRL_PS_RDY);
|
||||
} else if (pd_port->pe_pd_state == PE_SNK_SELECT_CAPABILITY){
|
||||
switch (pd_event->msg) {
|
||||
case PD_CTRL_PS_RDY:
|
||||
pd_add_miss_msg(pd_port,pd_event,PD_CTRL_ACCEPT);
|
||||
break;
|
||||
case PD_DATA_SOURCE_CAP:
|
||||
pd_add_miss_msg(pd_port,pd_event,PD_CTRL_REJECT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pd_port->miss_msg = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pd_copy_msg_data_from_evt(pd_port, pd_event);
|
||||
|
|
|
|||
|
|
@ -958,7 +958,14 @@ static int rt1711_get_cc(struct tcpc_device *tcpc, int *cc1, int *cc2)
|
|||
static int rt1711_enable_vsafe0v_detect(
|
||||
struct tcpc_device *tcpc, bool enable)
|
||||
{
|
||||
int ret = rt1711_i2c_read8(tcpc, RT1711H_REG_RT_MASK);
|
||||
int ret = 0;
|
||||
struct rt1711_chip *chip = tcpc_get_dev_data(tcpc);
|
||||
|
||||
if (chip->chip_id == SC2150A_DID) {
|
||||
enable = true;
|
||||
}
|
||||
|
||||
ret = rt1711_i2c_read8(tcpc, RT1711H_REG_RT_MASK);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -209,6 +209,12 @@ static int tcpci_alert_recv_msg(struct tcpc_device *tcpc)
|
|||
int rv = 0;
|
||||
struct pd_msg *pd_msg = NULL;
|
||||
enum tcpm_transmit_type type = TCPC_TX_SOP;
|
||||
uint32_t chip_id = 0;
|
||||
|
||||
rv = tcpci_get_chip_id(tcpc, &chip_id);
|
||||
if (!rv && (SC2150A_DID == chip_id)) {
|
||||
tcpci_set_rx_enable(tcpc, PD_RX_CAP_PE_STARTUP);
|
||||
}
|
||||
|
||||
pd_msg = pd_alloc_msg(tcpc);
|
||||
if (pd_msg == NULL) {
|
||||
|
|
@ -223,6 +229,9 @@ static int tcpci_alert_recv_msg(struct tcpc_device *tcpc)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!rv && (SC2150A_DID == chip_id)) {
|
||||
tcpci_set_rx_enable(tcpc, tcpc->pd_port.rx_cap);
|
||||
}
|
||||
pd_msg->frame_type = type;
|
||||
pd_put_pd_msg_event(tcpc, pd_msg);
|
||||
out:
|
||||
|
|
|
|||
Loading…
Reference in a new issue