[v3,5/7] phy: rockchip: inno-usb2: Add support #address_cells = 2

Message ID 20230209143100.113376-5-jagan@amarulasolutions.com
State New
Headers show
Series
  • [v3,1/7] dt-bindings: rockchip: Sync rockchip, vop2.h from Linux
Related show

Commit Message

Jagan Teki Feb. 9, 2023, 2:30 p.m. UTC
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>
---
Changes for v3:
- new patch

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index b32a498ea7..a01148db22 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -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)