linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Anand Moon <linux.amoon@gmail.com>
To: --to=linux-phy@lists.infradead.org,
	--to=linux-arm-kernel@lists.infradead.org,
	--to=linux-amlogic@lists.infradead.org,
	--to=linux-kernel@vger.kernel.org
Cc: Anand Moon <linux.amoon@gmail.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-phy@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [RFCv1 1/8] phy: amlogic: meson8b-usb2: Use clock bulk to get clocks for phy
Date: Thu, 17 Jun 2021 19:41:36 +0000	[thread overview]
Message-ID: <20210617194154.2397-2-linux.amoon@gmail.com> (raw)
In-Reply-To: <20210617194154.2397-1-linux.amoon@gmail.com>

Use clock bulk helpers to get/enable/disable clocks,
it will be easier to handle clocks. No functional change intended.

Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 drivers/phy/amlogic/phy-meson8b-usb2.c | 44 ++++++++++++++------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index 03c061dd5f0d..771b73f3b44e 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -121,11 +121,16 @@ struct phy_meson8b_usb2_match_data {
 	bool			host_enable_aca;
 };
 
+static const char * const meson_phy_clks[] = {
+	"usb_general",
+	"usb",
+};
+
 struct phy_meson8b_usb2_priv {
 	struct regmap					*regmap;
 	enum usb_dr_mode				dr_mode;
-	struct clk					*clk_usb_general;
-	struct clk					*clk_usb;
+	int                                             num_clks;
+	struct clk_bulk_data                            *clks;
 	struct reset_control				*reset;
 	const struct phy_meson8b_usb2_match_data	*match;
 };
@@ -151,16 +156,9 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
 		}
 	}
 
-	ret = clk_prepare_enable(priv->clk_usb_general);
+	ret = clk_bulk_prepare_enable(priv->num_clks, priv->clks);
 	if (ret) {
-		dev_err(&phy->dev, "Failed to enable USB general clock\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(priv->clk_usb);
-	if (ret) {
-		dev_err(&phy->dev, "Failed to enable USB DDR clock\n");
-		clk_disable_unprepare(priv->clk_usb_general);
+		dev_err(&phy->dev, "Failed to enable USB clock\n");
 		return ret;
 	}
 
@@ -197,8 +195,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
 			regmap_read(priv->regmap, REG_ADP_BC, &reg);
 			if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
 				dev_warn(&phy->dev, "USB ID detect failed!\n");
-				clk_disable_unprepare(priv->clk_usb);
-				clk_disable_unprepare(priv->clk_usb_general);
+				clk_bulk_disable_unprepare(priv->num_clks, priv->clks);
 				return -EINVAL;
 			}
 		}
@@ -216,8 +213,7 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
 				   REG_DBG_UART_SET_IDDQ,
 				   REG_DBG_UART_SET_IDDQ);
 
-	clk_disable_unprepare(priv->clk_usb);
-	clk_disable_unprepare(priv->clk_usb_general);
+	clk_bulk_disable_unprepare(priv->num_clks, priv->clks);
 
 	return 0;
 }
@@ -234,6 +230,7 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
 	struct phy *phy;
 	struct phy_provider *phy_provider;
 	void __iomem *base;
+	int i, ret;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -252,13 +249,18 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->regmap))
 		return PTR_ERR(priv->regmap);
 
-	priv->clk_usb_general = devm_clk_get(&pdev->dev, "usb_general");
-	if (IS_ERR(priv->clk_usb_general))
-		return PTR_ERR(priv->clk_usb_general);
+	priv->num_clks = ARRAY_SIZE(meson_phy_clks);
+	priv->clks = devm_kcalloc(&pdev->dev, priv->num_clks,
+				  sizeof(*priv->clks), GFP_KERNEL);
+	if (!priv->clks)
+		return -ENOMEM;
+
+	for (i = 0; i < priv->num_clks; i++)
+		priv->clks[i].id = meson_phy_clks[i];
 
-	priv->clk_usb = devm_clk_get(&pdev->dev, "usb");
-	if (IS_ERR(priv->clk_usb))
-		return PTR_ERR(priv->clk_usb);
+	ret = devm_clk_bulk_get(&pdev->dev, priv->num_clks, priv->clks);
+	if (ret)
+		return ret;
 
 	priv->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
 	if (PTR_ERR(priv->reset) == -EPROBE_DEFER)
-- 
2.31.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2021-06-17 19:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 19:41 [RFCv1 0/8] Meson-8b and Meson-gxbb USB phy code re-structure Anand Moon
2021-06-17 19:41 ` Anand Moon [this message]
2021-06-17 22:33   ` [RFCv1 1/8] phy: amlogic: meson8b-usb2: Use clock bulk to get clocks for phy Martin Blumenstingl
2021-06-18 15:32     ` Anand Moon
2021-06-17 19:41 ` [RFCv1 2/8] phy: amlogic: meson8b-usb2: Use phy init callback function Anand Moon
2021-06-18 12:26   ` Martin Blumenstingl
2021-06-18 13:17     ` Anand Moon
2021-06-17 19:41 ` [RFCv1 3/8] phy: amlogic: meson8b-usb2: Use phy exit " Anand Moon
2021-06-17 19:41 ` [RFCv1 4/8] phy: amlogic: meson8b-usb2: Use phy set_mode " Anand Moon
2021-06-17 22:16   ` Martin Blumenstingl
2021-06-18 13:19     ` Anand Moon
2021-06-18 20:01       ` Martin Blumenstingl
2021-06-21  7:20         ` Anand Moon
2021-06-22 20:27           ` Martin Blumenstingl
2021-06-17 19:41 ` [RFCv1 5/8] phy: amlogic: meson8b-usb2: Reorder phy poweroff " Anand Moon
2021-06-17 22:16   ` Martin Blumenstingl
2021-06-18 15:33     ` Anand Moon
2021-06-17 19:41 ` [RFCv1 6/8] phy: amlogic: meson8b-usb2: Use phy reset " Anand Moon
2021-06-17 22:24   ` Martin Blumenstingl
2021-06-18 15:33     ` Anand Moon
2021-06-18 20:06       ` Martin Blumenstingl
2021-06-21  7:15         ` Anand Moon
2021-06-22 20:11           ` Martin Blumenstingl
2021-06-24 14:54             ` Anand Moon
2021-06-27 20:07               ` Anand Moon
2021-06-27 20:25                 ` Martin Blumenstingl
2021-07-02 19:13                   ` Anand Moon
2021-06-17 19:41 ` [RFCv1 7/8] phy: amlogic: meson8b-usb2: Power off the PHY by putting it into reset mode Anand Moon
2021-06-17 22:37   ` Martin Blumenstingl
2021-06-21  7:15     ` Anand Moon
2021-06-22 20:00       ` Martin Blumenstingl
2021-06-17 19:41 ` [RFCv1 8/8] phy: amlogic: meson8b-usb2: don't log an error on -EPROBE_DEFER Anand Moon
2021-06-17 22:26   ` Martin Blumenstingl
2021-06-17 22:11 ` [RFCv1 0/8] Meson-8b and Meson-gxbb USB phy code re-structure Martin Blumenstingl
2021-06-18 13:20   ` Anand Moon
2021-06-18 20:16     ` Martin Blumenstingl
2021-06-21  7:21       ` Anand Moon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210617194154.2397-2-linux.amoon@gmail.com \
    --to=linux.amoon@gmail.com \
    --cc=--to=linux-amlogic@lists.infradead.org \
    --cc=--to=linux-arm-kernel@lists.infradead.org \
    --cc=--to=linux-kernel@vger.kernel.org \
    --cc=--to=linux-phy@lists.infradead.org \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=kishon@ti.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).