MLK-18437-3 imx8mm_evk: Implement the PD switch callback for NX20P3483

Since the PD switch callback is added to tcpc driver, we move the
NX20P3483 settings to this callback to exit DB and set OVP.

Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 7be626ee7d565712db0aac12cf31f5d867275267)
This commit is contained in:
Ye Li 2018-05-29 20:50:57 -07:00
parent baf8c71cb5
commit bf43d98dbf
1 changed files with 36 additions and 30 deletions

View File

@ -213,26 +213,6 @@ int board_phy_config(struct phy_device *phydev)
struct tcpc_port port1;
struct tcpc_port port2;
struct tcpc_port_config port1_config = {
.i2c_bus = 1, /*i2c2*/
.addr = 0x50,
.port_type = TYPEC_PORT_UFP,
.max_snk_mv = 5000,
.max_snk_ma = 3000,
.max_snk_mw = 40000,
.op_snk_mv = 9000,
};
struct tcpc_port_config port2_config = {
.i2c_bus = 1, /*i2c2*/
.addr = 0x52,
.port_type = TYPEC_PORT_UFP,
.max_snk_mv = 5000,
.max_snk_ma = 3000,
.max_snk_mw = 40000,
.op_snk_mv = 9000,
};
static int setup_pd_switch(uint8_t i2c_bus, uint8_t addr)
{
struct udevice *bus;
@ -276,20 +256,45 @@ static int setup_pd_switch(uint8_t i2c_bus, uint8_t addr)
return 0;
}
int pd_switch_snk_enable(struct tcpc_port *port)
{
if (port == &port1) {
debug("Setup pd switch on port 1\n");
return setup_pd_switch(1, 0x72);
} else if (port == &port2) {
debug("Setup pd switch on port 2\n");
return setup_pd_switch(1, 0x73);
} else
return -EINVAL;
}
struct tcpc_port_config port1_config = {
.i2c_bus = 1, /*i2c2*/
.addr = 0x50,
.port_type = TYPEC_PORT_UFP,
.max_snk_mv = 5000,
.max_snk_ma = 3000,
.max_snk_mw = 40000,
.op_snk_mv = 9000,
.switch_setup_func = &pd_switch_snk_enable,
};
struct tcpc_port_config port2_config = {
.i2c_bus = 1, /*i2c2*/
.addr = 0x52,
.port_type = TYPEC_PORT_UFP,
.max_snk_mv = 5000,
.max_snk_ma = 3000,
.max_snk_mw = 40000,
.op_snk_mv = 9000,
.switch_setup_func = &pd_switch_snk_enable,
};
static int setup_typec(void)
{
int ret;
ret = setup_pd_switch(1, 0x73);
if (ret)
printf("%s: NX20P3484 setup 0x%x failed, err=%d\n",
__func__, 0x73, ret);
ret = setup_pd_switch(1, 0x72);
if (ret)
printf("%s: NX20P3484 setup 0x%x failed, err=%d\n",
__func__, 0x72, ret);
debug("tcpc_init port 2\n");
ret = tcpc_init(&port2, port2_config, NULL);
if (ret) {
printf("%s: tcpc port2 init failed, err=%d\n",
@ -300,6 +305,7 @@ static int setup_typec(void)
printf("Power supply on USB2\n");
}
debug("tcpc_init port 1\n");
ret = tcpc_init(&port1, port1_config, NULL);
if (ret) {
printf("%s: tcpc port1 init failed, err=%d\n",