mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
typec: improve rt1715 code
/* Release Version + * 2.0.16_G + * (1) Check the return value of wait_event_interruptible() + * (2) Revise *_get_cc() + * (3) Revise role_def + * (4) Fix COMMON.CHECK.PD.10 this changes come from richtek patch05 Change-Id: Ic9bc97a980859003bb8a4417bc76b1ec52a2dc46 Reviewed-on: https://gerrit.mot.com/2057498 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Reviewed-by: Huosheng Liao <liaohs@motorola.com> Tested-by: Jira Key Submit-Approved: Jira Key
This commit is contained in:
parent
6678d3f37e
commit
b3de4df72d
8 changed files with 54 additions and 37 deletions
|
|
@ -274,8 +274,6 @@ struct pd_country_info {
|
|||
|
||||
/* SDB, Status */
|
||||
|
||||
#define PD_SDB_SIZE 6
|
||||
|
||||
#define PD_STATUS_INPUT_EXT_POWER (1<<1)
|
||||
#define PD_STATUS_INPUT_EXT_POWER_FROM_AC (1<<2)
|
||||
#define PD_STATUS_INPUT_INT_POWER_BAT (1<<3)
|
||||
|
|
@ -299,12 +297,15 @@ struct pd_country_info {
|
|||
struct pd_status {
|
||||
uint8_t internal_temp; /* 0 means no support */
|
||||
uint8_t present_input; /* bit filed */
|
||||
uint8_t present_battey_input; /* bit filed */
|
||||
uint8_t present_battery_input;
|
||||
uint8_t event_flags; /* bit filed */
|
||||
uint8_t temp_status; /* bit filed */
|
||||
uint8_t power_status; /* bit filed */
|
||||
uint8_t power_state_change;
|
||||
};
|
||||
|
||||
#define PD_SDB_SIZE sizeof(struct pd_status)
|
||||
|
||||
/* PPSSDB, PPSStatus */
|
||||
|
||||
#define PD_PPSSDB_SIZE 4 /* PPS_Status */
|
||||
|
|
|
|||
|
|
@ -88,12 +88,16 @@ static inline bool pd_dbg_print_out(void)
|
|||
|
||||
static int print_out_thread_fn(void *data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (true) {
|
||||
wait_event_interruptible(print_out_wait_que,
|
||||
atomic_read(&pending_print_out) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop())
|
||||
ret = wait_event_interruptible(print_out_wait_que,
|
||||
atomic_read(&pending_print_out) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop() || ret) {
|
||||
pr_notice("%s exits(%d)\n", __func__, ret);
|
||||
break;
|
||||
}
|
||||
do {
|
||||
atomic_dec_if_positive(&pending_print_out);
|
||||
} while (pd_dbg_print_out() && !kthread_should_stop());
|
||||
|
|
|
|||
|
|
@ -248,26 +248,25 @@ static int pps_request_thread_fn(void *data)
|
|||
{
|
||||
struct tcpc_device *tcpc = data;
|
||||
struct pd_port *pd_port = &tcpc->pd_port;
|
||||
long ret = 0;
|
||||
int ret = 0;
|
||||
struct tcp_dpm_event tcp_event = {
|
||||
.event_id = TCP_DPM_EVT_REQUEST_AGAIN,
|
||||
};
|
||||
|
||||
while (true) {
|
||||
wait_event_interruptible(pd_port->pps_request_wait_que,
|
||||
atomic_read(&pd_port->pps_request) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop())
|
||||
ret = wait_event_interruptible(pd_port->pps_request_wait_que,
|
||||
atomic_read(&pd_port->pps_request) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop() || ret) {
|
||||
dev_notice(&tcpc->dev, "%s exits(%d)\n", __func__, ret);
|
||||
break;
|
||||
do {
|
||||
ret = wait_event_timeout(pd_port->pps_request_wait_que,
|
||||
}
|
||||
while (!wait_event_timeout(pd_port->pps_request_wait_que,
|
||||
!atomic_read(&pd_port->pps_request) ||
|
||||
kthread_should_stop(),
|
||||
msecs_to_jiffies(7*1000));
|
||||
if (ret)
|
||||
break;
|
||||
msecs_to_jiffies(7*1000))) {
|
||||
pd_put_deferred_tcp_event(tcpc, &tcp_event);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -2017,7 +2016,7 @@ void pd_dpm_inform_status(struct pd_port *pd_port)
|
|||
sdb = pd_get_msg_data_payload(pd_port);
|
||||
DPM_INFO2("Temp=%d, IN=0x%x, BAT_IN=0x%x, EVT=0x%x, PTF=0x%x\n",
|
||||
sdb->internal_temp, sdb->present_input,
|
||||
sdb->present_battey_input, sdb->event_flags,
|
||||
sdb->present_battery_input, sdb->event_flags,
|
||||
PD_STATUS_TEMP_PTF(sdb->temp_status));
|
||||
|
||||
tcpci_notify_status(tcpc, sdb);
|
||||
|
|
@ -2031,14 +2030,14 @@ int pd_dpm_send_status(struct pd_port *pd_port)
|
|||
struct pd_status sdb;
|
||||
struct pe_data *pe_data = &pd_port->pe_data;
|
||||
|
||||
memset(&sdb, 0, sizeof(struct pd_status));
|
||||
memset(&sdb, 0, PD_SDB_SIZE);
|
||||
|
||||
sdb.present_input = pd_port->pd_status_present_in;
|
||||
|
||||
#ifdef CONFIG_USB_PD_REV30_BAT_INFO
|
||||
if (sdb.present_input &
|
||||
PD_STATUS_INPUT_INT_POWER_BAT) {
|
||||
sdb.present_battey_input = pd_port->pd_status_bat_in;
|
||||
sdb.present_battery_input = pd_port->pd_status_bat_in;
|
||||
}
|
||||
#endif /* CONFIG_USB_PD_REV30_BAT_INFO */
|
||||
|
||||
|
|
@ -2314,11 +2313,9 @@ int pd_dpm_core_init(struct pd_port *pd_port)
|
|||
int i, j;
|
||||
bool ret;
|
||||
uint8_t svid_ops_nr = ARRAY_SIZE(svdm_svid_ops);
|
||||
#ifdef CONFIG_USB_PD_REV30
|
||||
struct tcpc_device *tcpc = pd_port->tcpc;
|
||||
#endif /* CONFIG_USB_PD_REV30 */
|
||||
|
||||
pd_port->svid_data = devm_kzalloc(&pd_port->tcpc->dev,
|
||||
pd_port->svid_data = devm_kzalloc(&tcpc->dev,
|
||||
sizeof(struct svdm_svid_data) * svid_ops_nr, GFP_KERNEL);
|
||||
|
||||
if (!pd_port->svid_data)
|
||||
|
|
|
|||
|
|
@ -758,13 +758,12 @@ const struct typec_operations tcpc_typec_ops = {
|
|||
static int typec_init(struct rt_pd_manager_data *rpmd)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t typec_role = tcpm_inquire_typec_role(rpmd->tcpc);
|
||||
|
||||
rpmd->typec_caps.type = TYPEC_PORT_DRP;
|
||||
rpmd->typec_caps.data = TYPEC_PORT_DRD;
|
||||
rpmd->typec_caps.revision = 0x0120;
|
||||
rpmd->typec_caps.pd_revision = 0x0300;
|
||||
switch (typec_role) {
|
||||
switch (rpmd->tcpc->desc.role_def) {
|
||||
case TYPEC_ROLE_SRC:
|
||||
case TYPEC_ROLE_TRY_SRC:
|
||||
rpmd->typec_caps.prefer_role = TYPEC_SOURCE;
|
||||
|
|
|
|||
|
|
@ -964,7 +964,10 @@ static int rt1711_get_cc(struct tcpc_device *tcpc, int *cc1, int *cc2)
|
|||
if (act_as_drp) {
|
||||
act_as_sink = TCPC_V10_REG_CC_STATUS_DRP_RESULT(status);
|
||||
} else {
|
||||
cc_role = TCPC_V10_REG_CC_STATUS_CC1(role_ctrl);
|
||||
if (tcpc->typec_polarity)
|
||||
cc_role = TCPC_V10_REG_CC_STATUS_CC2(role_ctrl);
|
||||
else
|
||||
cc_role = TCPC_V10_REG_CC_STATUS_CC1(role_ctrl);
|
||||
if (cc_role == TYPEC_CC_RP)
|
||||
act_as_sink = false;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include "inc/pd_dbg_info.h"
|
||||
#include "inc/rt-regmap.h"
|
||||
|
||||
#define TCPC_CORE_VERSION "2.0.15_G"
|
||||
#define TCPC_CORE_VERSION "2.0.16_G"
|
||||
|
||||
static ssize_t tcpc_show_property(struct device *dev,
|
||||
struct device_attribute *attr, char *buf);
|
||||
|
|
@ -86,6 +86,7 @@ static const struct attribute_group *tcpc_attr_groups[] = {
|
|||
};
|
||||
|
||||
static const char * const role_text[] = {
|
||||
"Unknown",
|
||||
"SNK Only",
|
||||
"SRC Only",
|
||||
"DRP",
|
||||
|
|
@ -443,7 +444,7 @@ int tcpc_device_irq_enable(struct tcpc_device *tcpc)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = tcpc_typec_init(tcpc, tcpc->desc.role_def + 1);
|
||||
ret = tcpc_typec_init(tcpc, tcpc->desc.role_def);
|
||||
tcpci_unlock_typec(tcpc);
|
||||
if (ret < 0) {
|
||||
pr_err("%s : tcpc typec init fail\n", __func__);
|
||||
|
|
@ -873,6 +874,12 @@ MODULE_VERSION(TCPC_CORE_VERSION);
|
|||
MODULE_LICENSE("GPL");
|
||||
|
||||
/* Release Version
|
||||
* 2.0.16_G
|
||||
* (1) Check the return value of wait_event_interruptible()
|
||||
* (2) Revise *_get_cc()
|
||||
* (3) Revise role_def
|
||||
* (4) Fix COMMON.CHECK.PD.10
|
||||
*
|
||||
* 2.0.15_G
|
||||
* (1) undef CONFIG_COMPATIBLE_APPLE_TA
|
||||
* (2) Fix TEST.PD.PROT.ALL.5 Unrecognized Message (PD2)
|
||||
|
|
|
|||
|
|
@ -1306,6 +1306,7 @@ static int tcpc_event_thread_fn(void *data)
|
|||
{
|
||||
struct tcpc_device *tcpc = data;
|
||||
struct sched_param sch_param = {.sched_priority = MAX_RT_PRIO - 2};
|
||||
int ret = 0;
|
||||
|
||||
/* set_user_nice(current, -20); */
|
||||
/* current->flags |= PF_NOFREEZE;*/
|
||||
|
|
@ -1313,11 +1314,13 @@ static int tcpc_event_thread_fn(void *data)
|
|||
sched_setscheduler(current, SCHED_FIFO, &sch_param);
|
||||
|
||||
while (true) {
|
||||
wait_event_interruptible(tcpc->event_wait_que,
|
||||
atomic_read(&tcpc->pending_event) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop())
|
||||
ret = wait_event_interruptible(tcpc->event_wait_que,
|
||||
atomic_read(&tcpc->pending_event) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop() || ret) {
|
||||
dev_notice(&tcpc->dev, "%s exits(%d)\n", __func__, ret);
|
||||
break;
|
||||
}
|
||||
do {
|
||||
atomic_dec_if_positive(&tcpc->pending_event);
|
||||
} while (pd_policy_engine_run(tcpc) && !kthread_should_stop());
|
||||
|
|
|
|||
|
|
@ -1337,15 +1337,18 @@ static int tcpc_timer_thread_fn(void *data)
|
|||
{
|
||||
struct tcpc_device *tcpc = data;
|
||||
struct sched_param sch_param = {.sched_priority = MAX_RT_PRIO - 1};
|
||||
int ret = 0;
|
||||
|
||||
sched_setscheduler(current, SCHED_FIFO, &sch_param);
|
||||
|
||||
while (true) {
|
||||
wait_event_interruptible(tcpc->timer_wait_que,
|
||||
tcpc_get_timer_tick(tcpc) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop())
|
||||
ret = wait_event_interruptible(tcpc->timer_wait_que,
|
||||
tcpc_get_timer_tick(tcpc) ||
|
||||
kthread_should_stop());
|
||||
if (kthread_should_stop() || ret) {
|
||||
dev_notice(&tcpc->dev, "%s exits(%d)\n", __func__, ret);
|
||||
break;
|
||||
}
|
||||
tcpc_handle_timer_triggered(tcpc);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue