From: Manish Narani <manish.narani@xilinx.com>
To: ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,
heiko@sntech.de, michal.simek@xilinx.com,
adrian.hunter@intel.com,
christoph.muellner@theobroma-systems.com,
philipp.tomsich@theobroma-systems.com, viresh.kumar@linaro.org,
scott.branden@broadcom.com, ayaka@soulik.info, kernel@esmil.dk,
tony.xie@rock-chips.com, rajan.vaja@xilinx.com,
jolly.shah@xilinx.com, nava.manne@xilinx.com, mdf@kernel.org,
manish.narani@xilinx.com, olof@lixom.net
Cc: devicetree@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org
Subject: [PATCH v2 06/11] mmc: sdhci-of-arasan: Add sampling clock for a phy to use
Date: Mon, 1 Jul 2019 10:59:46 +0530 [thread overview]
Message-ID: <1561958991-21935-7-git-send-email-manish.narani@xilinx.com> (raw)
In-Reply-To: <1561958991-21935-1-git-send-email-manish.narani@xilinx.com>
There are some operations like setting the clock delays may need to have
two clocks, one for output path and one for input path. Adding input
path clock for some phys to use.
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
drivers/mmc/host/sdhci-of-arasan.c | 118 ++++++++++++++++++++++++++++++++++---
1 file changed, 110 insertions(+), 8 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index c7586f5..9513813 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -75,10 +75,14 @@ struct sdhci_arasan_soc_ctl_map {
* struct sdhci_arasan_clk_data
* @sdcardclk_hw: Struct for the clock we might provide to a PHY.
* @sdcardclk: Pointer to normal 'struct clock' for sdcardclk_hw.
+ * @sampleclk_hw: Struct for the clock we might provide to a PHY.
+ * @sampleclk: Pointer to normal 'struct clock' for sampleclk_hw.
*/
struct sdhci_arasan_clk_data {
struct clk_hw sdcardclk_hw;
struct clk *sdcardclk;
+ struct clk_hw sampleclk_hw;
+ struct clk *sampleclk;
};
/**
@@ -527,6 +531,33 @@ static const struct clk_ops arasan_sdcardclk_ops = {
};
/**
+ * sdhci_arasan_sampleclk_recalc_rate - Return the sampling clock rate
+ *
+ * Return the current actual rate of the sampling clock. This can be used
+ * to communicate with out PHY.
+ *
+ * @hw: Pointer to the hardware clock structure.
+ * @parent_rate The parent rate (should be rate of clk_xin).
+ * Returns the sample clock rate.
+ */
+static unsigned long sdhci_arasan_sampleclk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+
+{
+ struct sdhci_arasan_clk_data *clk_data =
+ container_of(hw, struct sdhci_arasan_clk_data, sampleclk_hw);
+ struct sdhci_arasan_data *sdhci_arasan =
+ container_of(clk_data, struct sdhci_arasan_data, clk_data);
+ struct sdhci_host *host = sdhci_arasan->host;
+
+ return host->mmc->actual_clock;
+}
+
+static const struct clk_ops arasan_sampleclk_ops = {
+ .recalc_rate = sdhci_arasan_sampleclk_recalc_rate,
+};
+
+/**
* sdhci_arasan_update_clockmultiplier - Set corecfg_clockmultiplier
*
* The corecfg_clockmultiplier is supposed to contain clock multiplier
@@ -605,7 +636,7 @@ static void sdhci_arasan_update_baseclkfreq(struct sdhci_host *host)
}
/**
- * sdhci_arasan_register_sdclk - Register the sdclk for a PHY to use
+ * sdhci_arasan_register_sdcardclk - Register the sdcardclk for a PHY to use
*
* Some PHY devices need to know what the actual card clock is. In order for
* them to find out, we'll provide a clock through the common clock framework
@@ -624,9 +655,10 @@ static void sdhci_arasan_update_baseclkfreq(struct sdhci_host *host)
* @dev: Pointer to our struct device.
* Returns 0 on success and error value on error
*/
-static int sdhci_arasan_register_sdclk(struct sdhci_arasan_data *sdhci_arasan,
- struct clk *clk_xin,
- struct device *dev)
+static int
+sdhci_arasan_register_sdcardclk(struct sdhci_arasan_data *sdhci_arasan,
+ struct clk *clk_xin,
+ struct device *dev)
{
struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data;
struct device_node *np = dev->of_node;
@@ -662,7 +694,7 @@ static int sdhci_arasan_register_sdclk(struct sdhci_arasan_data *sdhci_arasan,
ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get,
&clk_data->sdcardclk_hw);
if (ret) {
- dev_err(dev, "Failed to add clock provider\n");
+ dev_err(dev, "Failed to add sdcard clock provider\n");
return ret;
}
@@ -676,10 +708,74 @@ static int sdhci_arasan_register_sdclk(struct sdhci_arasan_data *sdhci_arasan,
}
/**
+ * sdhci_arasan_register_sampleclk - Register the sampleclk for a PHY to use
+ *
+ * Some PHY devices need to know what the actual card clock is. In order for
+ * them to find out, we'll provide a clock through the common clock framework
+ * for them to query.
+ *
+ * @sdhci_arasan: Our private data structure.
+ * @clk_xin: Pointer to the functional clock
+ * @dev: Pointer to our struct device.
+ * Returns 0 on success and error value on error
+ */
+static int
+sdhci_arasan_register_sampleclk(struct sdhci_arasan_data *sdhci_arasan,
+ struct clk *clk_xin,
+ struct device *dev)
+{
+ struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data;
+ struct device_node *np = dev->of_node;
+ struct clk_init_data sampleclk_init;
+ const char *parent_clk_name;
+ int ret;
+
+ /* Providing a clock to the PHY is optional; no error if missing */
+ if (!of_find_property(np, "#clock-cells", NULL))
+ return 0;
+
+ ret = of_property_read_string_index(np, "clock-output-names", 1,
+ &sampleclk_init.name);
+ if (ret) {
+ dev_err(dev, "DT has #clock-cells but no clock-output-names\n");
+ return ret;
+ }
+
+ parent_clk_name = __clk_get_name(clk_xin);
+ sampleclk_init.parent_names = &parent_clk_name;
+ sampleclk_init.num_parents = 1;
+ sampleclk_init.flags = CLK_GET_RATE_NOCACHE;
+ sampleclk_init.ops = &arasan_sampleclk_ops;
+
+ clk_data->sampleclk_hw.init = &sampleclk_init;
+ ret = devm_clk_hw_register(dev, &clk_data->sampleclk_hw);
+ if (ret) {
+ dev_err(dev, "Failed to register SD clk_hw\n");
+ return ret;
+ }
+ clk_data->sampleclk_hw.init = NULL;
+
+ ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get,
+ &clk_data->sampleclk_hw);
+ if (ret) {
+ dev_err(dev, "Failed to add sample clock provider\n");
+ return ret;
+ }
+
+ clk_data->sampleclk = devm_clk_get(dev, "clk_sample");
+ if (IS_ERR(clk_data->sampleclk)) {
+ dev_err(dev, "sampleclk clock not found.\n");
+ ret = PTR_ERR(clk_data->sampleclk);
+ }
+
+ return ret;
+}
+
+/**
* sdhci_arasan_unregister_sdclk - Undoes sdhci_arasan_register_sdclk()
*
- * Should be called any time we're exiting and sdhci_arasan_register_sdclk()
- * returned success.
+ * Should be called any time we're exiting and sdhci_arasan_register_sdcardclk()
+ * /sampleclk() returned success.
*
* @dev: Pointer to our struct device.
*/
@@ -817,10 +913,16 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
sdhci_arasan_update_baseclkfreq(host);
- ret = sdhci_arasan_register_sdclk(sdhci_arasan, clk_xin, &pdev->dev);
+ ret = sdhci_arasan_register_sdcardclk(sdhci_arasan, clk_xin,
+ &pdev->dev);
if (ret)
goto clk_disable_all;
+ ret = sdhci_arasan_register_sampleclk(sdhci_arasan, clk_xin,
+ &pdev->dev);
+ if (ret)
+ goto unreg_clk;
+
ret = mmc_of_parse(host->mmc);
if (ret) {
if (ret != -EPROBE_DEFER)
--
2.1.1
next prev parent reply other threads:[~2019-07-01 5:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 5:29 [PATCH v2 00/11] Arasan SDHCI enhancements and ZynqMP Tap Delays Handling Manish Narani
2019-07-01 5:29 ` [PATCH v2 01/11] dt-bindings: mmc: arasan: Update documentation for SD Card Clock Manish Narani
2019-07-22 21:54 ` Rob Herring
2019-07-23 8:23 ` Manish Narani
2019-07-25 13:00 ` Ulf Hansson
2019-08-19 9:21 ` Manish Narani
2019-08-22 13:38 ` Ulf Hansson
2019-08-22 18:23 ` Heiko Stuebner
2019-08-23 10:01 ` Manish Narani
2019-07-01 5:29 ` [PATCH v2 02/11] arm64: dts: rockchip: Add optional clock property indicating sdcard clock Manish Narani
2019-07-01 5:29 ` [PATCH v2 03/11] mmc: sdhci-of-arasan: Replace deprecated clk API calls Manish Narani
2019-07-01 5:29 ` [PATCH v2 04/11] mmc: sdhci-of-arasan: Separate out clk related data to another structure Manish Narani
2019-07-01 5:29 ` [PATCH v2 05/11] dt-bindings: mmc: arasan: Update Documentation for the input clock Manish Narani
2019-07-22 21:56 ` Rob Herring
2019-07-01 5:29 ` Manish Narani [this message]
2019-07-01 5:29 ` [PATCH v2 07/11] dt-bindings: mmc: arasan: Add optional properties for Arasan SDHCI Manish Narani
2019-07-22 22:01 ` Rob Herring
2019-07-01 5:29 ` [PATCH v2 08/11] mmc: sdhci-of-arasan: Add support to set clock phase delays for SD Manish Narani
2019-07-01 5:29 ` [PATCH v2 09/11] firmware: xilinx: Add SDIO Tap Delay APIs Manish Narani
2019-07-01 18:06 ` Jolly Shah
2019-07-02 5:03 ` Manish Narani
2019-07-01 5:29 ` [PATCH v2 10/11] dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller Manish Narani
2019-07-22 22:06 ` Rob Herring
2019-07-01 5:29 ` [PATCH v2 11/11] mmc: sdhci-of-arasan: Add support for ZynqMP Platform Tap Delays Setup Manish Narani
2019-07-10 11:33 ` [PATCH v2 00/11] Arasan SDHCI enhancements and ZynqMP Tap Delays Handling Adrian Hunter
2019-07-15 7:15 ` Manish Narani
2019-07-22 4:56 ` Manish Narani
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=1561958991-21935-7-git-send-email-manish.narani@xilinx.com \
--to=manish.narani@xilinx.com \
--cc=adrian.hunter@intel.com \
--cc=ayaka@soulik.info \
--cc=christoph.muellner@theobroma-systems.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=jolly.shah@xilinx.com \
--cc=kernel@esmil.dk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mdf@kernel.org \
--cc=michal.simek@xilinx.com \
--cc=nava.manne@xilinx.com \
--cc=olof@lixom.net \
--cc=philipp.tomsich@theobroma-systems.com \
--cc=rajan.vaja@xilinx.com \
--cc=robh+dt@kernel.org \
--cc=scott.branden@broadcom.com \
--cc=tony.xie@rock-chips.com \
--cc=ulf.hansson@linaro.org \
--cc=viresh.kumar@linaro.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).