Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: rockchip-typec: support DP phy switch

There are 2 Type-c PHYs in RK3399, but only one DP controller. Hence
only one PHY can connect to DP controller at one time, the other should
be disconnected. The GRF_SOC_CON26 register has a switch bit to do it,
set this bit means enable PHY 1, clear this bit means enable PHY 0.

Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Chris Zhong and committed by
Kishon Vijay Abraham I
866d4087 5eac5e9c

+8 -1
+8 -1
drivers/phy/rockchip/phy-rockchip-typec.c
··· 364 364 * @pipe_status: the register of type-c phy pipe status. 365 365 * @usb3_host_disable: the register of type-c usb3 host disable. 366 366 * @usb3_host_port: the register of type-c usb3 host port. 367 + * @uphy_dp_sel: the register of type-c phy DP select control. 367 368 */ 368 369 struct rockchip_usb3phy_port_cfg { 369 370 unsigned int reg; ··· 374 373 struct usb3phy_reg pipe_status; 375 374 struct usb3phy_reg usb3_host_disable; 376 375 struct usb3phy_reg usb3_host_port; 376 + struct usb3phy_reg uphy_dp_sel; 377 377 }; 378 378 379 379 struct rockchip_typec_phy { ··· 448 446 .pipe_status = { 0xe5c0, 0, 0 }, 449 447 .usb3_host_disable = { 0x2434, 0, 16 }, 450 448 .usb3_host_port = { 0x2434, 12, 28 }, 449 + .uphy_dp_sel = { 0x6268, 19, 19 }, 451 450 }, 452 451 { 453 452 .reg = 0xff800000, ··· 458 455 .pipe_status = { 0xe5c0, 16, 16 }, 459 456 .usb3_host_disable = { 0x2444, 0, 16 }, 460 457 .usb3_host_port = { 0x2444, 12, 28 }, 458 + .uphy_dp_sel = { 0x6268, 3, 19 }, 461 459 }, 462 460 { /* sentinel */ } 463 461 }; ··· 860 856 static int tcphy_cfg_usb3_to_usb2_only(struct rockchip_typec_phy *tcphy, 861 857 bool value) 862 858 { 863 - struct rockchip_usb3phy_port_cfg *cfg = tcphy->port_cfgs; 859 + const struct rockchip_usb3phy_port_cfg *cfg = tcphy->port_cfgs; 864 860 865 861 property_enable(tcphy, &cfg->usb3tousb2_en, value); 866 862 property_enable(tcphy, &cfg->usb3_host_disable, value); ··· 951 947 static int rockchip_dp_phy_power_on(struct phy *phy) 952 948 { 953 949 struct rockchip_typec_phy *tcphy = phy_get_drvdata(phy); 950 + const struct rockchip_usb3phy_port_cfg *cfg = tcphy->port_cfgs; 954 951 int new_mode, ret = 0; 955 952 u32 val; 956 953 ··· 983 978 } 984 979 if (ret) 985 980 goto unlock_ret; 981 + 982 + property_enable(tcphy, &cfg->uphy_dp_sel, 1); 986 983 987 984 ret = readx_poll_timeout(readl, tcphy->base + DP_MODE_CTL, 988 985 val, val & DP_MODE_A2, 1000,