phy: starfive: jh7110-usb: Fix link configuration to controller

In order to connect the USB 2.0 PHY to its controller, we also need to
set "u0_pdrstn_split_sw_usbpipe_plugen" [1]. Some downstream U-Boot
versions did that, but upstream firmware does not, and the kernel must
not rely on such behavior anyway. Failing to set this left the USB
gadget port invisible to connected hosts behind.

Link: https://doc-en.rvspace.org/JH7110/TRM/JH7110_TRM/sys_syscon.html#sys_syscon__section_b3l_fqs_wsb [1]
Fixes: 16d3a71c20cf ("phy: starfive: Add JH7110 USB 2.0 PHY driver")
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20241015070444.20972-2-minda.chen@starfivetech.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by Jan Kiszka and committed by Vinod Koul e10c52e7 031b46b4

+16
+16
drivers/phy/starfive/phy-jh7110-usb.c
··· 10 #include <linux/clk.h> 11 #include <linux/err.h> 12 #include <linux/io.h> 13 #include <linux/module.h> 14 #include <linux/phy/phy.h> 15 #include <linux/platform_device.h> 16 #include <linux/usb/of.h> 17 18 #define USB_125M_CLK_RATE 125000000 19 #define USB_LS_KEEPALIVE_OFF 0x4 20 #define USB_LS_KEEPALIVE_ENABLE BIT(4) 21 22 struct jh7110_usb2_phy { 23 struct phy *phy; 24 void __iomem *regs; 25 struct clk *usb_125m_clk; 26 struct clk *app_125m; 27 enum phy_mode mode; ··· 66 phy->mode = mode; 67 usb2_set_ls_keepalive(phy, (mode != PHY_MODE_USB_DEVICE)); 68 } 69 70 return 0; 71 } ··· 138 139 phy_set_drvdata(phy->phy, phy); 140 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 141 142 return PTR_ERR_OR_ZERO(phy_provider); 143 }
··· 10 #include <linux/clk.h> 11 #include <linux/err.h> 12 #include <linux/io.h> 13 + #include <linux/mfd/syscon.h> 14 #include <linux/module.h> 15 #include <linux/phy/phy.h> 16 #include <linux/platform_device.h> 17 + #include <linux/regmap.h> 18 #include <linux/usb/of.h> 19 20 #define USB_125M_CLK_RATE 125000000 21 #define USB_LS_KEEPALIVE_OFF 0x4 22 #define USB_LS_KEEPALIVE_ENABLE BIT(4) 23 24 + #define USB_PDRSTN_SPLIT BIT(17) 25 + #define SYSCON_USB_SPLIT_OFFSET 0x18 26 + 27 struct jh7110_usb2_phy { 28 struct phy *phy; 29 void __iomem *regs; 30 + struct regmap *sys_syscon; 31 struct clk *usb_125m_clk; 32 struct clk *app_125m; 33 enum phy_mode mode; ··· 60 phy->mode = mode; 61 usb2_set_ls_keepalive(phy, (mode != PHY_MODE_USB_DEVICE)); 62 } 63 + 64 + /* Connect usb 2.0 phy mode */ 65 + regmap_update_bits(phy->sys_syscon, SYSCON_USB_SPLIT_OFFSET, 66 + USB_PDRSTN_SPLIT, USB_PDRSTN_SPLIT); 67 68 return 0; 69 } ··· 128 129 phy_set_drvdata(phy->phy, phy); 130 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 131 + 132 + phy->sys_syscon = 133 + syscon_regmap_lookup_by_compatible("starfive,jh7110-sys-syscon"); 134 + if (IS_ERR(phy->sys_syscon)) 135 + return dev_err_probe(dev, PTR_ERR(phy->sys_syscon), 136 + "Failed to get sys-syscon\n"); 137 138 return PTR_ERR_OR_ZERO(phy_provider); 139 }