diff options
Diffstat (limited to 'drivers/phy/rockchip/phy-rockchip-inno-usb2.c')
-rw-r--r-- | drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index bb1a5c747e..34abbd85db 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -11,10 +11,11 @@ #include <errno.h> #include <driver.h> #include <malloc.h> -#include <usb/phy.h> +#include <linux/usb/phy.h> #include <linux/phy/phy.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <regulator.h> @@ -166,7 +167,7 @@ struct rockchip_usb2phy { struct phy_provider *provider; struct clk *clk480m; struct clk_hw clk480m_hw; - struct device_d *dev; + struct device *dev; struct clk *clk; }; @@ -255,8 +256,8 @@ static int rockchip_usb2phy_power_off(struct phy *phy) return 0; } -static struct phy *rockchip_usb2phy_of_xlate(struct device_d *dev, - struct of_phandle_args *args) +static struct phy *rockchip_usb2phy_of_xlate(struct device *dev, + struct of_phandle_args *args) { struct rockchip_usb2phy *rphy = dev->priv; struct device_node *phynode = args->np; @@ -264,7 +265,10 @@ static struct phy *rockchip_usb2phy_of_xlate(struct device_d *dev, int port; for (port = 0; port < 2; port++) { - if (phynode == rphy->phys[port].phy->dev.device_node) { + if (!rphy->phys[port].phy) + continue; + + if (phynode == rphy->phys[port].phy->dev.of_node) { p = &rphy->phys[port]; return p->phy; } @@ -335,7 +339,7 @@ static const struct clk_ops rockchip_usb2phy_clkout_ops = { static int rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy) { - struct device_node *node = rphy->dev->device_node; + struct device_node *node = rphy->dev->of_node; struct clk_init_data init = {}; const char *clk_name; int ret; @@ -376,20 +380,25 @@ err_ret: return ret; } -static int rockchip_usb2phy_probe(struct device_d *dev) +static int rockchip_usb2phy_probe(struct device *dev) { const struct rockchip_usb2phy_cfg *phy_cfgs; struct rockchip_usb2phy *rphy; u32 reg, index; - int ret, port = 0; - struct device_node *child, *np = dev->device_node; + int port = 0; + struct device_node *child, *np = dev->of_node; struct resource *iores; rphy = xzalloc(sizeof(*rphy)); rphy->dev = dev; - rphy->grf_base = syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf"); + if (of_device_is_compatible(np, "rockchip,rv1108-usb2phy") || + of_device_is_compatible(np, "rockchip,rk3568-usb2phy")) + rphy->grf_base = syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf"); + else + rphy->grf_base = syscon_node_to_regmap(dev->parent->of_node); + if (IS_ERR(rphy->grf_base)) return PTR_ERR(rphy->grf_base); @@ -423,6 +432,7 @@ static int rockchip_usb2phy_probe(struct device_d *dev) for_each_child_of_node(np, child) { struct rockchip_usb2phy_phy *p; struct phy *phy; + struct device *phydev; if (!strcmp(child->name, "host-port")) { port = USB2PHY_PORT_OTG; @@ -436,14 +446,15 @@ static int rockchip_usb2phy_probe(struct device_d *dev) if (rphy->phys[port].phy) return -EINVAL; - phy = phy_create(dev, child, &rockchip_usb2phy_ops); - if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - if (ret != -EPROBE_DEFER) - dev_err(dev, "failed to create phy%d: %d\n", - port, ret); - return ret; - } + phydev = of_platform_device_create(child, dev); + if (!phydev) + continue; + + of_platform_device_dummy_drv(phydev); + + phy = phy_create(phydev, child, &rockchip_usb2phy_ops); + if (IS_ERR(phy)) + return dev_errp_probe(dev, phy, "creating phy%d\n", port); p = xzalloc(sizeof(*p)); @@ -972,8 +983,9 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = { { .compatible = "rockchip,rv1108-usb2phy", .data = &rv1108_phy_cfgs }, { } }; +MODULE_DEVICE_TABLE(of, rockchip_usb2phy_dt_match); -static struct driver_d rockchip_usb2phy_driver = { +static struct driver rockchip_usb2phy_driver = { .probe = rockchip_usb2phy_probe, .name = "rockchip-usb2phy", .of_compatible = rockchip_usb2phy_dt_match, |