From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: martin.petersen@oracle.com, jejb@linux.ibm.com
Cc: andersson@kernel.org, konrad.dybcio@linaro.org,
linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, quic_cang@quicinc.com,
ahalaney@redhat.com, quic_nitirawa@quicinc.com,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Subject: [PATCH v2 01/17] scsi: ufs: qcom: Use clk_bulk APIs for managing lane clocks
Date: Fri, 8 Dec 2023 12:28:46 +0530 [thread overview]
Message-ID: <20231208065902.11006-2-manivannan.sadhasivam@linaro.org> (raw)
In-Reply-To: <20231208065902.11006-1-manivannan.sadhasivam@linaro.org>
Lane clock handling can be simplified by using the clk_bulk APIs. So let's
make use of them. This also get's rid of the clock validation in the driver
as kernel should just rely on the firmware (DT/ACPI) to provide the clocks
required for proper functioning.
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/ufs/host/ufs-qcom.c | 94 ++-----------------------------------
drivers/ufs/host/ufs-qcom.h | 6 +--
2 files changed, 7 insertions(+), 93 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 96cb8b5b4e66..cbb6a696cd97 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -194,52 +194,12 @@ static inline int ufs_qcom_ice_suspend(struct ufs_qcom_host *host)
}
#endif
-static int ufs_qcom_host_clk_get(struct device *dev,
- const char *name, struct clk **clk_out, bool optional)
-{
- struct clk *clk;
- int err = 0;
-
- clk = devm_clk_get(dev, name);
- if (!IS_ERR(clk)) {
- *clk_out = clk;
- return 0;
- }
-
- err = PTR_ERR(clk);
-
- if (optional && err == -ENOENT) {
- *clk_out = NULL;
- return 0;
- }
-
- if (err != -EPROBE_DEFER)
- dev_err(dev, "failed to get %s err %d\n", name, err);
-
- return err;
-}
-
-static int ufs_qcom_host_clk_enable(struct device *dev,
- const char *name, struct clk *clk)
-{
- int err = 0;
-
- err = clk_prepare_enable(clk);
- if (err)
- dev_err(dev, "%s: %s enable failed %d\n", __func__, name, err);
-
- return err;
-}
-
static void ufs_qcom_disable_lane_clks(struct ufs_qcom_host *host)
{
if (!host->is_lane_clks_enabled)
return;
- clk_disable_unprepare(host->tx_l1_sync_clk);
- clk_disable_unprepare(host->tx_l0_sync_clk);
- clk_disable_unprepare(host->rx_l1_sync_clk);
- clk_disable_unprepare(host->rx_l0_sync_clk);
+ clk_bulk_disable_unprepare(host->num_clks, host->clks);
host->is_lane_clks_enabled = false;
}
@@ -247,43 +207,14 @@ static void ufs_qcom_disable_lane_clks(struct ufs_qcom_host *host)
static int ufs_qcom_enable_lane_clks(struct ufs_qcom_host *host)
{
int err;
- struct device *dev = host->hba->dev;
-
- if (host->is_lane_clks_enabled)
- return 0;
- err = ufs_qcom_host_clk_enable(dev, "rx_lane0_sync_clk",
- host->rx_l0_sync_clk);
+ err = clk_bulk_prepare_enable(host->num_clks, host->clks);
if (err)
return err;
- err = ufs_qcom_host_clk_enable(dev, "tx_lane0_sync_clk",
- host->tx_l0_sync_clk);
- if (err)
- goto disable_rx_l0;
-
- err = ufs_qcom_host_clk_enable(dev, "rx_lane1_sync_clk",
- host->rx_l1_sync_clk);
- if (err)
- goto disable_tx_l0;
-
- err = ufs_qcom_host_clk_enable(dev, "tx_lane1_sync_clk",
- host->tx_l1_sync_clk);
- if (err)
- goto disable_rx_l1;
-
host->is_lane_clks_enabled = true;
return 0;
-
-disable_rx_l1:
- clk_disable_unprepare(host->rx_l1_sync_clk);
-disable_tx_l0:
- clk_disable_unprepare(host->tx_l0_sync_clk);
-disable_rx_l0:
- clk_disable_unprepare(host->rx_l0_sync_clk);
-
- return err;
}
static int ufs_qcom_init_lane_clks(struct ufs_qcom_host *host)
@@ -294,26 +225,11 @@ static int ufs_qcom_init_lane_clks(struct ufs_qcom_host *host)
if (has_acpi_companion(dev))
return 0;
- err = ufs_qcom_host_clk_get(dev, "rx_lane0_sync_clk",
- &host->rx_l0_sync_clk, false);
- if (err)
- return err;
-
- err = ufs_qcom_host_clk_get(dev, "tx_lane0_sync_clk",
- &host->tx_l0_sync_clk, false);
- if (err)
+ err = devm_clk_bulk_get_all(dev, &host->clks);
+ if (err <= 0)
return err;
- /* In case of single lane per direction, don't read lane1 clocks */
- if (host->hba->lanes_per_direction > 1) {
- err = ufs_qcom_host_clk_get(dev, "rx_lane1_sync_clk",
- &host->rx_l1_sync_clk, false);
- if (err)
- return err;
-
- err = ufs_qcom_host_clk_get(dev, "tx_lane1_sync_clk",
- &host->tx_l1_sync_clk, true);
- }
+ host->num_clks = err;
return 0;
}
diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
index 9950a0089475..e2df4c528a2a 100644
--- a/drivers/ufs/host/ufs-qcom.h
+++ b/drivers/ufs/host/ufs-qcom.h
@@ -213,10 +213,8 @@ struct ufs_qcom_host {
struct phy *generic_phy;
struct ufs_hba *hba;
struct ufs_pa_layer_attr dev_req_params;
- struct clk *rx_l0_sync_clk;
- struct clk *tx_l0_sync_clk;
- struct clk *rx_l1_sync_clk;
- struct clk *tx_l1_sync_clk;
+ struct clk_bulk_data *clks;
+ u32 num_clks;
bool is_lane_clks_enabled;
struct icc_path *icc_ddr;
--
2.25.1
next prev parent reply other threads:[~2023-12-08 6:59 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 6:58 [PATCH v2 00/17] scsi: ufs: qcom: Code cleanups Manivannan Sadhasivam
2023-12-08 6:58 ` Manivannan Sadhasivam [this message]
2023-12-08 6:58 ` [PATCH v2 02/17] scsi: ufs: qcom: Fix the return value of ufs_qcom_ice_program_key() Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 03/17] scsi: ufs: qcom: Fix the return value when platform_get_resource_byname() fails Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 04/17] scsi: ufs: qcom: Remove superfluous variable assignments Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 05/17] scsi: ufs: qcom: Remove the warning message when core_reset is not available Manivannan Sadhasivam
2023-12-08 9:25 ` Nitin Rawat
2023-12-08 10:28 ` Manivannan Sadhasivam
2023-12-08 13:29 ` Nitin Rawat
2023-12-14 7:13 ` Nitin Rawat
2023-12-14 7:33 ` Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 06/17] scsi: ufs: qcom: Export ufshcd_{enable/disable}_irq helpers and make use of them Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 07/17] scsi: ufs: qcom: Fail ufs_qcom_power_up_sequence() when core_reset fails Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 08/17] scsi: ufs: qcom: Check the return value of ufs_qcom_power_up_sequence() Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 09/17] scsi: ufs: qcom: Remove redundant error print for devm_kzalloc() failure Manivannan Sadhasivam
2023-12-08 9:39 ` Nitin Rawat
2023-12-08 6:58 ` [PATCH v2 10/17] scsi: ufs: qcom: Use dev_err_probe() to simplify error handling of devm_gpiod_get_optional() Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 11/17] scsi: ufs: qcom: Remove unused ufs_qcom_hosts struct array Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 12/17] scsi: ufs: qcom: Sort includes alphabetically Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 13/17] scsi: ufs: qcom: Initialize cycles_in_1us variable in ufs_qcom_set_core_clk_ctrl() Manivannan Sadhasivam
2023-12-08 6:58 ` [PATCH v2 14/17] scsi: ufs: qcom: Simplify ufs_qcom_{assert/deassert}_reset Manivannan Sadhasivam
2023-12-08 17:46 ` Andrew Halaney
2023-12-08 6:59 ` [PATCH v2 15/17] scsi: ufs: qcom: Remove support for host controllers older than v2.0 Manivannan Sadhasivam
2023-12-08 6:59 ` [PATCH v2 16/17] scsi: ufs: qcom: Use ufshcd_rmwl() where applicable Manivannan Sadhasivam
2023-12-08 18:02 ` Andrew Halaney
2023-12-14 4:56 ` Manivannan Sadhasivam
2023-12-08 6:59 ` [PATCH v2 17/17] scsi: ufs: qcom: Remove unused definitions Manivannan Sadhasivam
2023-12-08 18:03 ` Andrew Halaney
2023-12-08 20:39 ` [PATCH v2 00/17] scsi: ufs: qcom: Code cleanups Andrew Halaney
2023-12-09 17:42 ` Konrad Dybcio
2023-12-14 5:09 ` Manivannan Sadhasivam
2023-12-14 4:10 ` Martin K. Petersen
2023-12-14 4:58 ` Manivannan Sadhasivam
2023-12-19 2:18 ` Martin K. Petersen
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=20231208065902.11006-2-manivannan.sadhasivam@linaro.org \
--to=manivannan.sadhasivam@linaro.org \
--cc=ahalaney@redhat.com \
--cc=andersson@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
/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).