1
0
Fork 0

MLK-17921-1 staging: typec: tcpci: improve properties parse

Current typec and PD properties parse can't work well for sink or source
only port, this patch is to improve it.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
pull/10/head
Li Jun 2018-06-26 17:48:22 +08:00 committed by Jason Liu
parent f076675de1
commit 0d2d088b62
1 changed files with 15 additions and 10 deletions

View File

@ -658,18 +658,13 @@ static int tcpci_parse_config(struct tcpci *tcpci)
return -EINVAL;
}
/* Get the default-role */
tcfg->default_role = typec_get_power_role(tcpci->dev);
if (tcfg->default_role == TYPEC_ROLE_UNKNOWN) {
dev_err(tcpci->dev, "typec power role is NOT correct!\n");
return -EINVAL;
}
if (tcfg->type == TYPEC_PORT_UFP)
goto sink;
/* Check source pdo array size */
tcfg->nr_src_pdo = device_property_read_u32_array(tcpci->dev,
"src-pdos", NULL, 0);
if (tcfg->nr_src_pdo <= 0 && (tcfg->type == TYPEC_PORT_DRP ||
tcfg->type == TYPEC_PORT_DFP)) {
if (tcfg->nr_src_pdo <= 0) {
dev_err(tcpci->dev, "typec source pdo is missing!\n");
return -EINVAL;
}
@ -688,6 +683,16 @@ static int tcpci_parse_config(struct tcpci *tcpci)
return -EINVAL;
}
if (tcfg->type == TYPEC_PORT_DFP)
return 0;
/* Get the default-role */
tcfg->default_role = typec_get_power_role(tcpci->dev);
if (tcfg->default_role == TYPEC_ROLE_UNKNOWN) {
dev_err(tcpci->dev, "typec power role is NOT correct!\n");
return -EINVAL;
}
/*
* In case DRP only for data role, power role is source only
* we can use this property to disable power sink.
@ -721,11 +726,11 @@ static int tcpci_parse_config(struct tcpci *tcpci)
return 0;
}
sink:
/* Check the num of snk pdo */
tcfg->nr_snk_pdo = device_property_read_u32_array(tcpci->dev,
"snk-pdos", NULL, 0);
if (tcfg->nr_snk_pdo <= 0 && (tcfg->type == TYPEC_PORT_DRP ||
tcfg->type == TYPEC_PORT_UFP)) {
if (tcfg->nr_snk_pdo <= 0) {
dev_err(tcpci->dev, "typec sink pdo is missing!\n");
return -EINVAL;
}