]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
phy: rockchip: inno-usb2: Add support #address_cells = 2
authorJagan Teki <jagan@amarulasolutions.com>
Fri, 17 Feb 2023 11:58:39 +0000 (17:28 +0530)
committerKever Yang <kever.yang@rock-chips.com>
Tue, 28 Feb 2023 10:07:27 +0000 (18:07 +0800)
New Rockchip devices have the usb phy nodes as standalone devices.
These nodes have register nodes with #address_cells = 2, but only
use 32 bit addresses.

Adjust the driver to check if the returned address is "0", and adjust
the index in that case.

Derived and adjusted the similar change from linux-next with below
 commit <9c19c531dc98> ("phy: phy-rockchip-inno-usb2: support
 #address_cells = 2")

Co-developed-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/phy/rockchip/phy-rockchip-inno-usb2.c

index b32a498ea71923399a24da156ff65feb974465bb..a01148db220daeb40750c09ca32380c0c4669f3d 100644 (file)
@@ -179,12 +179,21 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
        if (IS_ERR(priv->reg_base))
                return PTR_ERR(priv->reg_base);
 
-       ret = ofnode_read_u32(dev_ofnode(dev), "reg", &reg);
+       ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &reg);
        if (ret) {
                dev_err(dev, "failed to read reg property (ret = %d)\n", ret);
                return ret;
        }
 
+       /* support address_cells=2 */
+       if (reg == 0) {
+               if (ofnode_read_u32_index(dev_ofnode(dev), "reg", 1, &reg)) {
+                       dev_err(dev, "%s must have reg[1]\n",
+                               ofnode_get_name(dev_ofnode(dev)));
+                       return -EINVAL;
+               }
+       }
+
        phy_cfgs = (const struct rockchip_usb2phy_cfg *)
                                        dev_get_driver_data(dev);
        if (!phy_cfgs)