usb: phy: mxs: enable regulator phy-3p0 to improve signal qualilty

Enable regulator 'phy-3p0' to pass eye diagram test since it improve signal
qualilty.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20240726113207.3393247-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Xu Yang 2024-07-26 19:32:02 +08:00 committed by Greg Kroah-Hartman
parent c6a6c7d0c0
commit 966d731520

View file

@ -18,6 +18,7 @@
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/regulator/consumer.h>
#define DRIVER_NAME "mxs_phy" #define DRIVER_NAME "mxs_phy"
@ -204,6 +205,7 @@ struct mxs_phy {
int port_id; int port_id;
u32 tx_reg_set; u32 tx_reg_set;
u32 tx_reg_mask; u32 tx_reg_mask;
struct regulator *phy_3p0;
}; };
static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy) static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
@ -288,6 +290,16 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
if (ret) if (ret)
goto disable_pll; goto disable_pll;
if (mxs_phy->phy_3p0) {
ret = regulator_enable(mxs_phy->phy_3p0);
if (ret) {
dev_err(mxs_phy->phy.dev,
"Failed to enable 3p0 regulator, ret=%d\n",
ret);
return ret;
}
}
/* Power up the PHY */ /* Power up the PHY */
writel(0, base + HW_USBPHY_PWD); writel(0, base + HW_USBPHY_PWD);
@ -448,6 +460,9 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
if (is_imx7ulp_phy(mxs_phy)) if (is_imx7ulp_phy(mxs_phy))
mxs_phy_pll_enable(phy->io_priv, false); mxs_phy_pll_enable(phy->io_priv, false);
if (mxs_phy->phy_3p0)
regulator_disable(mxs_phy->phy_3p0);
clk_disable_unprepare(mxs_phy->clk); clk_disable_unprepare(mxs_phy->clk);
} }
@ -789,6 +804,17 @@ static int mxs_phy_probe(struct platform_device *pdev)
mxs_phy->clk = clk; mxs_phy->clk = clk;
mxs_phy->data = of_device_get_match_data(&pdev->dev); mxs_phy->data = of_device_get_match_data(&pdev->dev);
mxs_phy->phy_3p0 = devm_regulator_get(&pdev->dev, "phy-3p0");
if (PTR_ERR(mxs_phy->phy_3p0) == -ENODEV)
/* not exist */
mxs_phy->phy_3p0 = NULL;
else if (IS_ERR(mxs_phy->phy_3p0))
return dev_err_probe(&pdev->dev, PTR_ERR(mxs_phy->phy_3p0),
"Getting regulator error\n");
if (mxs_phy->phy_3p0)
regulator_set_voltage(mxs_phy->phy_3p0, 3200000, 3200000);
platform_set_drvdata(pdev, mxs_phy); platform_set_drvdata(pdev, mxs_phy);
device_set_wakeup_capable(&pdev->dev, true); device_set_wakeup_capable(&pdev->dev, true);