diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c index c7712bf7cb03..4d04b2964b51 100644 --- a/drivers/phy/rockchip/phy-rockchip-usb.c +++ b/drivers/phy/rockchip/phy-rockchip-usb.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -40,14 +39,6 @@ #define SIDDQ_ON BIT(13) #define SIDDQ_OFF (0 << 13) -#define USB2_PHY_WRITE_ENA (0xffff << 16) -#define USB2_PHY_SUSPEND (0x5 << 0 | 0xd << 4 | 0x1 << 8) -#define USB2_PHY_RESUME (0) - -#define UTMI_SEL_GRF_WR_ENA (0x3 << 16) -#define UTMI_SEL_GRF_SUSPEND (0x1 << 0) -#define UTMI_SEL_GRF_RESUME (0x2 << 0) - struct rockchip_usb_phys { int reg; const char *pll_name; @@ -55,15 +46,11 @@ struct rockchip_usb_phys { struct rockchip_usb_phy_pdata { struct rockchip_usb_phys *phys; - unsigned int phy_pw_on; - unsigned int phy_pw_off; - bool siddq_ctl; }; struct rockchip_usb_phy_base { struct device *dev; struct regmap *reg_base; - struct gpio_desc *vbus_drv_gpio; const struct rockchip_usb_phy_pdata *pdata; }; @@ -79,12 +66,10 @@ struct rockchip_usb_phy { }; static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy, - bool off) + bool siddq) { - unsigned int val; - - val = !off ? phy->base->pdata->phy_pw_on : phy->base->pdata->phy_pw_off; - return regmap_write(phy->base->reg_base, phy->reg_offset, val); + return regmap_write(phy->base->reg_base, phy->reg_offset, + SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF)); } static unsigned long rockchip_usb_phy480m_recalc_rate(struct clk_hw *hw, @@ -100,22 +85,17 @@ static void rockchip_usb_phy480m_disable(struct clk_hw *hw) clk480m_hw); /* Power down usb phy analog blocks by set siddq 1 */ - if (phy->base->pdata->siddq_ctl) - rockchip_usb_phy_power(phy, 1); + rockchip_usb_phy_power(phy, 1); } static int rockchip_usb_phy480m_enable(struct clk_hw *hw) { - int ret = 0; struct rockchip_usb_phy *phy = container_of(hw, struct rockchip_usb_phy, clk480m_hw); /* Power up usb phy analog blocks by set siddq 0 */ - if (phy->base->pdata->siddq_ctl) - ret = rockchip_usb_phy_power(phy, 0); - - return ret; + return rockchip_usb_phy_power(phy, 0); } static int rockchip_usb_phy480m_is_enabled(struct clk_hw *hw) @@ -123,18 +103,14 @@ static int rockchip_usb_phy480m_is_enabled(struct clk_hw *hw) struct rockchip_usb_phy *phy = container_of(hw, struct rockchip_usb_phy, clk480m_hw); - int ret = 1; + int ret; u32 val; - if (phy->base->pdata->siddq_ctl) { - ret = regmap_read(phy->base->reg_base, phy->reg_offset, &val); - if (ret < 0) - return ret; + ret = regmap_read(phy->base->reg_base, phy->reg_offset, &val); + if (ret < 0) + return ret; - ret = (val & SIDDQ_ON) ? 0 : 1; - } - - return ret; + return (val & SIDDQ_ON) ? 0 : 1; } static const struct clk_ops rockchip_usb_phy480m_ops = { @@ -146,32 +122,18 @@ static const struct clk_ops rockchip_usb_phy480m_ops = { static int rockchip_usb_phy_power_off(struct phy *_phy) { - int ret = 0; struct rockchip_usb_phy *phy = phy_get_drvdata(_phy); - if (!phy->base->pdata->siddq_ctl) { - ret = rockchip_usb_phy_power(phy, 1); - if (ret) - return ret; - } - clk_disable_unprepare(phy->clk480m); + return 0; } static int rockchip_usb_phy_power_on(struct phy *_phy) { - int ret = 0; struct rockchip_usb_phy *phy = phy_get_drvdata(_phy); - ret = clk_prepare_enable(phy->clk480m); - if (ret) - return ret; - - if (!phy->base->pdata->siddq_ctl) - ret = rockchip_usb_phy_power(phy, 0); - - return ret; + return clk_prepare_enable(phy->clk480m); } static int rockchip_usb_phy_reset(struct phy *_phy) @@ -323,9 +285,6 @@ static const struct rockchip_usb_phy_pdata rk3066a_pdata = { { .reg = 0x188, .pll_name = "sclk_otgphy1_480m" }, { /* sentinel */ } }, - .phy_pw_on = SIDDQ_WRITE_ENA | SIDDQ_OFF, - .phy_pw_off = SIDDQ_WRITE_ENA | SIDDQ_ON, - .siddq_ctl = true, }; static const struct rockchip_usb_phy_pdata rk3188_pdata = { @@ -334,9 +293,6 @@ static const struct rockchip_usb_phy_pdata rk3188_pdata = { { .reg = 0x11c, .pll_name = "sclk_otgphy1_480m" }, { /* sentinel */ } }, - .phy_pw_on = SIDDQ_WRITE_ENA | SIDDQ_OFF, - .phy_pw_off = SIDDQ_WRITE_ENA | SIDDQ_ON, - .siddq_ctl = true, }; static const struct rockchip_usb_phy_pdata rk3288_pdata = { @@ -346,31 +302,6 @@ static const struct rockchip_usb_phy_pdata rk3288_pdata = { { .reg = 0x348, .pll_name = "sclk_otgphy2_480m" }, { /* sentinel */ } }, - .phy_pw_on = SIDDQ_WRITE_ENA | SIDDQ_OFF, - .phy_pw_off = SIDDQ_WRITE_ENA | SIDDQ_ON, - .siddq_ctl = true, -}; - -static const struct rockchip_usb_phy_pdata rk336x_pdata = { - .phys = (struct rockchip_usb_phys[]){ - { .reg = 0x700, .pll_name = "sclk_otgphy0_480m" }, - { .reg = 0x728, .pll_name = "sclk_otgphy1_480m" }, - { /* sentinel */ } - }, - .phy_pw_on = USB2_PHY_WRITE_ENA | USB2_PHY_RESUME, - .phy_pw_off = USB2_PHY_WRITE_ENA | USB2_PHY_SUSPEND, - .siddq_ctl = false, -}; - -static const struct rockchip_usb_phy_pdata rk3399_pdata = { - .phys = (struct rockchip_usb_phys[]){ - { .reg = 0xe458, .pll_name = "sclk_otgphy0_480m" }, - { .reg = 0xe468, .pll_name = "sclk_otgphy1_480m" }, - { /* sentinel */ } - }, - .phy_pw_on = UTMI_SEL_GRF_WR_ENA | UTMI_SEL_GRF_RESUME, - .phy_pw_off = UTMI_SEL_GRF_WR_ENA | UTMI_SEL_GRF_SUSPEND, - .siddq_ctl = false, }; static int rockchip_usb_phy_probe(struct platform_device *pdev) @@ -407,14 +338,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) return PTR_ERR(phy_base->reg_base); } - /* Request the vbus_drv GPIO asserted */ - phy_base->vbus_drv_gpio = - devm_gpiod_get_optional(dev, "vbus_drv", GPIOD_OUT_HIGH); - if (!phy_base->vbus_drv_gpio) - dev_info(&pdev->dev, "vbus_drv is not assigned!\n"); - else if (IS_ERR(phy_base->vbus_drv_gpio)) - return PTR_ERR(phy_base->vbus_drv_gpio); - for_each_available_child_of_node(dev->of_node, child) { err = rockchip_usb_phy_init(phy_base, child); if (err) {