phy: sun4i-usb: add support for missing USB PHY index
authorIcenowy Zheng <icenowy@aosc.io>
Thu, 4 Oct 2018 12:28:47 +0000 (20:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 18:46:03 +0000 (19:46 +0100)
[ Upstream commit 2659392e5c08dff626e6db1d739adff58a94604d ]

The new Allwinner H6 SoC's USB2 PHY has two holes -- USB1 (which is a
3.0 port with dedicated PHY) and USB2 (which doesn't exist at all).

Add support for this kind of missing USB PHY index.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/allwinner/phy-sun4i-usb.c

index afedb8c..d1ccff5 100644 (file)
@@ -125,6 +125,7 @@ struct sun4i_usb_phy_cfg {
        bool dedicated_clocks;
        bool enable_pmu_unk1;
        bool phy0_dual_route;
+       int missing_phys;
 };
 
 struct sun4i_usb_phy_data {
@@ -645,6 +646,9 @@ static struct phy *sun4i_usb_phy_xlate(struct device *dev,
        if (args->args[0] >= data->cfg->num_phys)
                return ERR_PTR(-ENODEV);
 
+       if (data->cfg->missing_phys & BIT(args->args[0]))
+               return ERR_PTR(-ENODEV);
+
        return data->phys[args->args[0]].phy;
 }
 
@@ -740,6 +744,9 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
                struct sun4i_usb_phy *phy = data->phys + i;
                char name[16];
 
+               if (data->cfg->missing_phys & BIT(i))
+                       continue;
+
                snprintf(name, sizeof(name), "usb%d_vbus", i);
                phy->vbus = devm_regulator_get_optional(dev, name);
                if (IS_ERR(phy->vbus)) {