Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: amlogic: enable/disable clkin during Amlogic USB PHY init/exit

Previously, all Amlogic boards used the XTAL clock as the default board
clock for the USB PHY input, so there was no need to enable it.
However, with the introduction of new Amlogic SoCs like the A1 family,
the USB PHY now uses a gated clock. Hence, it is necessary to enable
this gated clock during the PHY initialization sequence, or disable it
during the PHY exit, as appropriate.

Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20230426102922.19705-2-ddrokosov@sberdevices.ru
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dmitry Rokosov and committed by
Vinod Koul
58247b9f ac9a7868

+13 -2
+13 -2
drivers/phy/amlogic/phy-meson-g12a-usb2.c
··· 172 172 int ret; 173 173 unsigned int value; 174 174 175 - ret = reset_control_reset(priv->reset); 175 + ret = clk_prepare_enable(priv->clk); 176 176 if (ret) 177 177 return ret; 178 + 179 + ret = reset_control_reset(priv->reset); 180 + if (ret) { 181 + clk_disable_unprepare(priv->clk); 182 + return ret; 183 + } 178 184 179 185 udelay(RESET_COMPLETE_TIME); 180 186 ··· 283 277 static int phy_meson_g12a_usb2_exit(struct phy *phy) 284 278 { 285 279 struct phy_meson_g12a_usb2_priv *priv = phy_get_drvdata(phy); 280 + int ret; 286 281 287 - return reset_control_reset(priv->reset); 282 + ret = reset_control_reset(priv->reset); 283 + if (!ret) 284 + clk_disable_unprepare(priv->clk); 285 + 286 + return ret; 288 287 } 289 288 290 289 /* set_mode is not needed, mode setting is handled via the UTMI bus */