[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260206100009.873182-2-amadeus@jmu.edu.cn>
Date: Fri, 6 Feb 2026 18:00:09 +0800
From: Chukun Pan <amadeus@....edu.cn>
To: Yixun Lan <dlan@...nel.org>,
Vinod Koul <vkoul@...nel.org>,
Ze Huang <huang.ze@...ux.dev>
Cc: Rob Herring <robh@...nel.org>,
Chukun Pan <amadeus@....edu.cn>,
Mark Brown <broonie@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Neil Armstrong <neil.armstrong@...aro.org>,
linux-riscv@...ts.infradead.org,
linux-phy@...ts.infradead.org,
linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
spacemit@...ts.linux.dev
Subject: [PATCH 2/2] phy: spacemit: add regulator support to K1 USB2 PHY
USB VBUS may have a regulator supply. Add optional phy-supply
support to avoid the need for the regulator to be always-on.
Signed-off-by: Chukun Pan <amadeus@....edu.cn>
---
drivers/phy/spacemit/phy-k1-usb2.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/phy/spacemit/phy-k1-usb2.c b/drivers/phy/spacemit/phy-k1-usb2.c
index 342061380012..c163a29dabf9 100644
--- a/drivers/phy/spacemit/phy-k1-usb2.c
+++ b/drivers/phy/spacemit/phy-k1-usb2.c
@@ -75,6 +75,7 @@ struct spacemit_usb2phy {
struct phy *phy;
struct clk *clk;
struct regmap *regmap_base;
+ struct regulator *regulator;
};
static const struct regmap_config phy_regmap_config = {
@@ -98,6 +99,12 @@ static int spacemit_usb2phy_init(struct phy *phy)
return ret;
}
+ if (sphy->regulator) {
+ ret = regulator_enable(sphy->regulator);
+ if (ret)
+ return ret;
+ }
+
/*
* make sure the usb controller is not under reset process before
* any configuration
@@ -139,6 +146,9 @@ static int spacemit_usb2phy_exit(struct phy *phy)
clk_disable(sphy->clk);
+ if (sphy->regulator)
+ return regulator_disable(sphy->regulator);
+
return 0;
}
@@ -171,6 +181,16 @@ static int spacemit_usb2phy_probe(struct platform_device *pdev)
if (IS_ERR(sphy->regmap_base))
return dev_err_probe(dev, PTR_ERR(sphy->regmap_base), "Failed to init regmap\n");
+ sphy->regulator = devm_regulator_get_optional(dev, "phy");
+ if (IS_ERR(sphy->regulator)) {
+ int ret = PTR_ERR(sphy->regulator);
+
+ if (ret != -ENODEV)
+ return dev_err_probe(dev, ret, "Failed to get regulator\n");
+
+ sphy->regulator = NULL;
+ }
+
sphy->phy = devm_phy_create(dev, NULL, &spacemit_usb2phy_ops);
if (IS_ERR(sphy->phy))
return dev_err_probe(dev, PTR_ERR(sphy->phy), "Failed to create phy\n");
--
2.34.1
Powered by blists - more mailing lists