From 0a88c6e02330685cda8d14f09fb0daa0ab04c0bf Mon Sep 17 00:00:00 2001 From: Zhang Yubing Date: Fri, 18 Feb 2022 15:41:22 +0800 Subject: [PATCH] phy: rockchip: usbdp: Add phy initial status When DP show the uboot logo, the usbdp phy will work in uboot. In this case, the display on DP will be broken if we initialize the usbdp phy again when system enter kernel. Reading the lane mux and enable register when probe the usbdp phy driver. If DP used the usbdp phy in uboot, It should skip the initialization. Signed-off-by: Zhang Yubing Change-Id: I55dcf8bd9c0b8be94326dd17c53ad47237cd1975 --- drivers/phy/rockchip/phy-rockchip-usbdp.c | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c index 79a239ce4d91..5806ab18b068 100644 --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c @@ -410,7 +410,6 @@ static int udphy_reset_init(struct rockchip_udphy *udphy, struct device *dev) } udphy->rsts[idx] = rst; - reset_control_assert(udphy->rsts[idx]); } return 0; @@ -717,6 +716,30 @@ static int udphy_parse_lane_mux_data(struct rockchip_udphy *udphy, struct device return 0; } +static int udphy_get_initial_status(struct rockchip_udphy *udphy) +{ + const struct rockchip_udphy_cfg *cfg = udphy->cfgs; + int ret, i; + u32 value; + + ret = clk_bulk_prepare_enable(udphy->num_clks, udphy->clks); + if (ret) { + dev_err(udphy->dev, "failed to enable clk\n"); + return ret; + } + + for (i = 0; i < cfg->num_rsts; i++) + reset_control_deassert(udphy->rsts[i]); + + regmap_read(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, &value); + if (FIELD_GET(CMN_DP_LANE_MUX_ALL, value) && FIELD_GET(CMN_DP_LANE_EN_ALL, value)) + udphy->status = UDPHY_MODE_DP; + else + udphy_disable(udphy); + + return 0; +} + static int udphy_parse_dt(struct rockchip_udphy *udphy, struct device *dev) { struct device_node *np = dev->of_node; @@ -1155,6 +1178,10 @@ static int rockchip_udphy_probe(struct platform_device *pdev) if (ret) return ret; + ret = udphy_get_initial_status(udphy); + if (ret) + return ret; + mutex_init(&udphy->mutex); udphy->dev = dev; platform_set_drvdata(pdev, udphy); @@ -1182,9 +1209,10 @@ static int rockchip_udphy_probe(struct platform_device *pdev) for_each_available_child_of_node(np, child_np) { struct phy *phy; - if (of_node_name_eq(child_np, "dp-port")) + if (of_node_name_eq(child_np, "dp-port")) { phy = devm_phy_create(dev, child_np, &rockchip_dp_phy_ops); - else if (of_node_name_eq(child_np, "u3-port")) + phy_set_bus_width(phy, udphy_dplane_get(udphy)); + } else if (of_node_name_eq(child_np, "u3-port")) phy = devm_phy_create(dev, child_np, &rockchip_u3phy_ops); else continue;