Skip to content

Commit c31b670

Browse files
committed
rk3528-10-phy-rockchip-inno-usb2: fix usbgrf regmap split (6.18 + 7.0 + 7.1)
The merged RK3528 USB2 PHY support patch (PR armbian#9500) collapsed rphy->grf onto rphy->phy_base when the DT node had rockchip,usbgrf, making GRF/port-control register accesses hit the standalone PHY MMIO window instead of the syscon. On NanoPi Zero2 this prevents the USB-C gadget from completing high-speed NCM enumeration: the UDC stays at default/full-speed, Windows does not enumerate a usable UsbNcm adapter, and usb0 stays DOWN/NO-CARRIER. The patch description already documented the intended topology (phy_base for the standalone PHY window, grf via the rockchip,usbgrf phandle for port-control fields), but the implementation drifted. Restore the split: keep phy_base mapped to the PHY node, and resolve rphy->grf from the rockchip,usbgrf phandle. Fall back to the parent syscon for older SoC layouts without the phandle. Apply identically to rockchip64-6.18, rockchip64-7.0, and the rockchip64-7.1 archive (added in 9d967ec, inherited the bug). Tested on FriendlyElec NanoPi Zero2 (RK3528) with a configfs NCM gadget over /sys/kernel/config/usb_gadget: Before this patch: /sys/class/udc/fe500000.usb/state = default /sys/class/udc/fe500000.usb/current_speed = full-speed usb0: DOWN, NO-CARRIER Windows host: no UsbNcm Host Device After this patch: /sys/class/udc/fe500000.usb/state = configured /sys/class/udc/fe500000.usb/current_speed = high-speed usb0: UP, LOWER_UP, 10.10.10.1/24, fe80::12:34ff:fe56:789a/64 Windows host: UsbNcm Host Device armbian#5, Up, 426.0 Mbps ping fe80::12:34ff:fe56:789a%122: 3 sent / 3 received / 0% loss Note: a separate u_ether NULL-deref on gadget teardown is tracked under PR armbian#9608 and is not addressed here. Signed-off-by: Shlomi Marco <s.marco@rubycomm.com>
1 parent 3ae6351 commit c31b670

3 files changed

Lines changed: 30 additions & 27 deletions

File tree

patch/kernel/archive/rockchip64-6.18/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patch

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ next-20250910-rk3528 branch.
2121

2222
Signed-off-by: Shlomi Marco <s.marco@rubycomm.com>
2323
---
24-
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 160 ++++++++--
25-
1 file changed, 127 insertions(+), 33 deletions(-)
24+
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 162 ++++++++--
25+
1 file changed, 129 insertions(+), 33 deletions(-)
2626

2727
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
2828
index 111111111111..222222222222 100644
@@ -141,7 +141,7 @@ index 111111111111..222222222222 100644
141141
}
142142

143143
static unsigned long
144-
@@ -1360,27 +1381,18 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
144+
@@ -1360,27 +1381,20 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
145145
if (!rphy)
146146
return -ENOMEM;
147147

@@ -156,7 +156,7 @@ index 111111111111..222222222222 100644
156156
+ rphy->phy_base = device_node_to_regmap(np);
157157
+ if (IS_ERR(rphy->phy_base))
158158
+ return PTR_ERR(rphy->phy_base);
159-
+ rphy->grf = rphy->phy_base;
159+
+ rphy->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf");
160160
} else {
161161
rphy->grf = syscon_node_to_regmap(dev->parent->of_node);
162162
- if (IS_ERR(rphy->grf))
@@ -173,12 +173,14 @@ index 111111111111..222222222222 100644
173173
- rphy->usbgrf = NULL;
174174
+ rphy->phy_base = rphy->grf;
175175
}
176-
+ if (IS_ERR(rphy->grf))
176+
+ if (IS_ERR(rphy->grf)) {
177+
+ dev_err(dev, "failed to locate usbgrf\n");
177178
+ return PTR_ERR(rphy->grf);
179+
+ }
178180

179181
if (of_property_read_u32_index(np, "reg", 0, &reg)) {
180182
dev_err(dev, "the reg property is not assigned in %pOFn node\n", np);
181-
@@ -1521,6 +1533,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
183+
@@ -1521,6 +1535,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
182184
BIT(2) << BIT_WRITEABLE_SHIFT | 0);
183185
}
184186

@@ -215,7 +217,7 @@ index 111111111111..222222222222 100644
215217
static int rk3576_usb2phy_tuning(struct rockchip_usb2phy *rphy)
216218
{
217219
int ret;
218-
@@ -1934,6 +1976,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
220+
@@ -1934,6 +1978,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
219221
{ /* sentinel */ }
220222
};
221223

@@ -273,7 +275,7 @@ index 111111111111..222222222222 100644
273275
static const struct rockchip_usb2phy_cfg rk3562_phy_cfgs[] = {
274276
{
275277
.reg = 0xff740000,
276-
@@ -2301,6 +2394,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
278+
@@ -2301,6 +2396,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
277279
{ .compatible = "rockchip,rk3328-usb2phy", .data = &rk3328_phy_cfgs },
278280
{ .compatible = "rockchip,rk3366-usb2phy", .data = &rk3366_phy_cfgs },
279281
{ .compatible = "rockchip,rk3399-usb2phy", .data = &rk3399_phy_cfgs },
@@ -283,4 +285,3 @@ index 111111111111..222222222222 100644
283285
{ .compatible = "rockchip,rk3576-usb2phy", .data = &rk3576_phy_cfgs },
284286
--
285287
Armbian
286-

patch/kernel/archive/rockchip64-7.0/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patch

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ next-20250910-rk3528 branch.
2121

2222
Signed-off-by: Shlomi Marco <s.marco@rubycomm.com>
2323
---
24-
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 160 ++++++++--
25-
1 file changed, 127 insertions(+), 33 deletions(-)
24+
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 162 ++++++++--
25+
1 file changed, 129 insertions(+), 33 deletions(-)
2626

2727
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
2828
index 111111111111..222222222222 100644
@@ -141,7 +141,7 @@ index 111111111111..222222222222 100644
141141
}
142142

143143
static unsigned long
144-
@@ -1360,27 +1381,18 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
144+
@@ -1360,27 +1381,20 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
145145
if (!rphy)
146146
return -ENOMEM;
147147

@@ -156,7 +156,7 @@ index 111111111111..222222222222 100644
156156
+ rphy->phy_base = device_node_to_regmap(np);
157157
+ if (IS_ERR(rphy->phy_base))
158158
+ return PTR_ERR(rphy->phy_base);
159-
+ rphy->grf = rphy->phy_base;
159+
+ rphy->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf");
160160
} else {
161161
rphy->grf = syscon_node_to_regmap(dev->parent->of_node);
162162
- if (IS_ERR(rphy->grf))
@@ -173,12 +173,14 @@ index 111111111111..222222222222 100644
173173
- rphy->usbgrf = NULL;
174174
+ rphy->phy_base = rphy->grf;
175175
}
176-
+ if (IS_ERR(rphy->grf))
176+
+ if (IS_ERR(rphy->grf)) {
177+
+ dev_err(dev, "failed to locate usbgrf\n");
177178
+ return PTR_ERR(rphy->grf);
179+
+ }
178180

179181
if (of_property_read_u32_index(np, "reg", 0, &reg)) {
180182
dev_err(dev, "the reg property is not assigned in %pOFn node\n", np);
181-
@@ -1521,6 +1533,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
183+
@@ -1521,6 +1535,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
182184
BIT(2) << BIT_WRITEABLE_SHIFT | 0);
183185
}
184186

@@ -215,7 +217,7 @@ index 111111111111..222222222222 100644
215217
static int rk3576_usb2phy_tuning(struct rockchip_usb2phy *rphy)
216218
{
217219
int ret;
218-
@@ -1934,6 +1976,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
220+
@@ -1934,6 +1978,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
219221
{ /* sentinel */ }
220222
};
221223

@@ -273,7 +275,7 @@ index 111111111111..222222222222 100644
273275
static const struct rockchip_usb2phy_cfg rk3562_phy_cfgs[] = {
274276
{
275277
.reg = 0xff740000,
276-
@@ -2301,6 +2394,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
278+
@@ -2301,6 +2396,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
277279
{ .compatible = "rockchip,rk3328-usb2phy", .data = &rk3328_phy_cfgs },
278280
{ .compatible = "rockchip,rk3366-usb2phy", .data = &rk3366_phy_cfgs },
279281
{ .compatible = "rockchip,rk3399-usb2phy", .data = &rk3399_phy_cfgs },
@@ -283,4 +285,3 @@ index 111111111111..222222222222 100644
283285
{ .compatible = "rockchip,rk3576-usb2phy", .data = &rk3576_phy_cfgs },
284286
--
285287
Armbian
286-

patch/kernel/archive/rockchip64-7.1/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patch

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ next-20250910-rk3528 branch.
2121

2222
Signed-off-by: Shlomi Marco <s.marco@rubycomm.com>
2323
---
24-
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 160 ++++++++--
25-
1 file changed, 127 insertions(+), 33 deletions(-)
24+
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 162 ++++++++--
25+
1 file changed, 129 insertions(+), 33 deletions(-)
2626

2727
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
2828
index 111111111111..222222222222 100644
@@ -141,7 +141,7 @@ index 111111111111..222222222222 100644
141141
}
142142

143143
static unsigned long
144-
@@ -1360,27 +1381,18 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
144+
@@ -1360,27 +1381,20 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
145145
if (!rphy)
146146
return -ENOMEM;
147147

@@ -156,7 +156,7 @@ index 111111111111..222222222222 100644
156156
+ rphy->phy_base = device_node_to_regmap(np);
157157
+ if (IS_ERR(rphy->phy_base))
158158
+ return PTR_ERR(rphy->phy_base);
159-
+ rphy->grf = rphy->phy_base;
159+
+ rphy->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf");
160160
} else {
161161
rphy->grf = syscon_node_to_regmap(dev->parent->of_node);
162162
- if (IS_ERR(rphy->grf))
@@ -173,12 +173,14 @@ index 111111111111..222222222222 100644
173173
- rphy->usbgrf = NULL;
174174
+ rphy->phy_base = rphy->grf;
175175
}
176-
+ if (IS_ERR(rphy->grf))
176+
+ if (IS_ERR(rphy->grf)) {
177+
+ dev_err(dev, "failed to locate usbgrf\n");
177178
+ return PTR_ERR(rphy->grf);
179+
+ }
178180

179181
if (of_property_read_u32_index(np, "reg", 0, &reg)) {
180182
dev_err(dev, "the reg property is not assigned in %pOFn node\n", np);
181-
@@ -1521,6 +1533,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
183+
@@ -1521,6 +1535,36 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
182184
BIT(2) << BIT_WRITEABLE_SHIFT | 0);
183185
}
184186

@@ -215,7 +217,7 @@ index 111111111111..222222222222 100644
215217
static int rk3576_usb2phy_tuning(struct rockchip_usb2phy *rphy)
216218
{
217219
int ret;
218-
@@ -1934,6 +1976,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
220+
@@ -1934,6 +1978,57 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
219221
{ /* sentinel */ }
220222
};
221223

@@ -273,7 +275,7 @@ index 111111111111..222222222222 100644
273275
static const struct rockchip_usb2phy_cfg rk3562_phy_cfgs[] = {
274276
{
275277
.reg = 0xff740000,
276-
@@ -2301,6 +2394,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
278+
@@ -2301,6 +2396,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = {
277279
{ .compatible = "rockchip,rk3328-usb2phy", .data = &rk3328_phy_cfgs },
278280
{ .compatible = "rockchip,rk3366-usb2phy", .data = &rk3366_phy_cfgs },
279281
{ .compatible = "rockchip,rk3399-usb2phy", .data = &rk3399_phy_cfgs },
@@ -283,4 +285,3 @@ index 111111111111..222222222222 100644
283285
{ .compatible = "rockchip,rk3576-usb2phy", .data = &rk3576_phy_cfgs },
284286
--
285287
Armbian
286-

0 commit comments

Comments
 (0)