From 8333dbdeb288739b899f97220aa5667bf2acf65e Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Mon, 2 Nov 2020 21:19:55 +0100 Subject: verdin-imx8mm.c: drop code releated to usbc port manager Drop code ifdefed by CONFIG_USB_TCPC. Currently there are no plans to extend the module HW to include such a chip. Signed-off-by: Max Krummenacher --- board/toradex/verdin-imx8mm/verdin-imx8mm.c | 159 ---------------------------- 1 file changed, 159 deletions(-) diff --git a/board/toradex/verdin-imx8mm/verdin-imx8mm.c b/board/toradex/verdin-imx8mm/verdin-imx8mm.c index cc7c8819b2..c088db1f22 100644 --- a/board/toradex/verdin-imx8mm/verdin-imx8mm.c +++ b/board/toradex/verdin-imx8mm/verdin-imx8mm.c @@ -152,141 +152,15 @@ int board_phy_config(struct phy_device *phydev) } #endif -#ifdef CONFIG_USB_TCPC -struct tcpc_port port1; -struct tcpc_port port2; - -static int setup_pd_switch(uint8_t i2c_bus, uint8_t addr) -{ - struct udevice *bus; - struct udevice *i2c_dev = NULL; - int ret; - uint8_t valb; - - ret = uclass_get_device_by_seq(UCLASS_I2C, i2c_bus, &bus); - if (ret) { - printf("%s: Can't find bus\n", __func__); - return -EINVAL; - } - - ret = dm_i2c_probe(bus, addr, 0, &i2c_dev); - if (ret) { - printf("%s: Can't find device id=0x%x\n", - __func__, addr); - return -ENODEV; - } - - ret = dm_i2c_read(i2c_dev, 0xB, &valb, 1); - if (ret) { - printf("%s dm_i2c_read failed, err %d\n", __func__, ret); - return -EIO; - } - valb |= 0x4; /* Set DB_EXIT to exit dead battery mode */ - ret = dm_i2c_write(i2c_dev, 0xB, (const uint8_t *)&valb, 1); - if (ret) { - printf("%s dm_i2c_write failed, err %d\n", __func__, ret); - return -EIO; - } - - /* Set OVP threshold to 23V */ - valb = 0x6; - ret = dm_i2c_write(i2c_dev, 0x8, (const uint8_t *)&valb, 1); - if (ret) { - printf("%s dm_i2c_write failed, err %d\n", __func__, ret); - return -EIO; - } - - 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; - - debug("tcpc_init port 2\n"); - ret = tcpc_init(&port2, port2_config, NULL); - if (ret) { - printf("%s: tcpc port2 init failed, err=%d\n", - __func__, ret); - } else if (tcpc_pd_sink_check_charging(&port2)) { - /* Disable PD for USB1, since USB2 has priority */ - port1_config.disable_pd = true; - 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", - __func__, ret); - } else { - if (!port1_config.disable_pd) - printf("Power supply on USB1\n"); - return ret; - } - - return ret; -} -#endif /* CONFIG_USB_TCPC */ - #ifdef CONFIG_USB_EHCI_HCD int board_usb_init(int index, enum usb_init_type init) { int ret = 0; -#ifdef CONFIG_USB_TCPC - struct tcpc_port *port_ptr; -#endif debug("board_usb_init %d, type %d\n", index, init); imx8m_usb_power(index, true); -#ifdef CONFIG_USB_TCPC - if (index == 0) - port_ptr = &port1; - else - port_ptr = &port2; - - if (init == USB_INIT_HOST) - tcpc_setup_dfp_mode(port_ptr); - else - tcpc_setup_ufp_mode(port_ptr); -#endif - return ret; } @@ -296,15 +170,6 @@ int board_usb_cleanup(int index, enum usb_init_type init) debug("board_usb_cleanup %d, type %d\n", index, init); -#ifdef CONFIG_USB_TCPC - if (init == USB_INIT_HOST) { - if (index == 0) - ret = tcpc_disable_src_vbus(&port1); - else - ret = tcpc_disable_src_vbus(&port2); - } -#endif - imx8m_usb_power(index, false); return ret; } @@ -315,36 +180,12 @@ int board_usb_phy_mode(struct udevice *dev) int board_ehci_usb_phy_mode(struct udevice *dev) #endif { -#ifdef CONFIG_USB_TCPC - int ret = 0; - enum typec_cc_polarity pol; - enum typec_cc_state state; - struct tcpc_port *port_ptr; - - if (dev->seq == 0) - port_ptr = &port1; - else - port_ptr = &port2; - - tcpc_setup_ufp_mode(port_ptr); - - ret = tcpc_get_cc_status(port_ptr, &pol, &state); - if (!ret) { - if (state == TYPEC_STATE_SRC_RD_RA || state == TYPEC_STATE_SRC_RD) - return USB_INIT_HOST; - } -#endif /* CONFIG_USB_TCPC */ - return USB_INIT_DEVICE; } #endif int board_init(void) { -#ifdef CONFIG_USB_TCPC - setup_typec(); -#endif - #ifdef CONFIG_FEC_MXC setup_fec(); #endif -- cgit v1.2.3