From dbcd409a06b0143c41ea35c0c1f618e14ac1d7b8 Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Wed, 23 Mar 2016 15:36:21 +0800 Subject: [PATCH] phy: rockchip-usb: support usb2.0 phy for rk3399 SoC 1. Add a new compatible for rk3399; 2. Support gpio operation for vbus-drv. Change-Id: I2eb1ac377db0bcb907d009c56fba22f1951c128e Signed-off-by: Frank Wang --- drivers/phy/phy-rockchip-usb.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) mode change 100644 => 100755 drivers/phy/phy-rockchip-usb.c diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c old mode 100644 new mode 100755 index 4b407d385c91..55d3ea07110b --- a/drivers/phy/phy-rockchip-usb.c +++ b/drivers/phy/phy-rockchip-usb.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,10 @@ #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 (0x3 << 0) + struct rockchip_usb_phys { int reg; const char *pll_name; @@ -57,6 +62,7 @@ struct rockchip_usb_phy_pdata { 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; }; @@ -320,6 +326,17 @@ static const struct rockchip_usb_phy_pdata rk336x_pdata = { .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) { struct device *dev = &pdev->dev; @@ -349,6 +366,14 @@ 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) { @@ -366,6 +391,7 @@ static const struct of_device_id rockchip_usb_phy_dt_ids[] = { { .compatible = "rockchip,rk3188-usb-phy", .data = &rk3188_pdata }, { .compatible = "rockchip,rk3288-usb-phy", .data = &rk3288_pdata }, { .compatible = "rockchip,rk336x-usb-phy", .data = &rk336x_pdata }, + { .compatible = "rockchip,rk3399-usb-phy", .data = &rk3399_pdata }, {} }; -- 2.34.1