linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller
@ 2018-09-18 13:45 Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 1/4] firmware: xilinx: Add SD Node and DLL Reset Data APIs Manish Narani
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Manish Narani @ 2018-09-18 13:45 UTC (permalink / raw)
  To: ulf.hansson, robh+dt, mark.rutland, michal.simek, adrian.hunter,
	manish.narani, leoyang.li, sudeep.holla, olof, amit.kucheria,
	rajanv, jollys
  Cc: linux-mmc, devicetree, linux-kernel, linux-arm-kernel

This series of patches are created On top of the
below series of patches.
https://lkml.org/lkml/2018/8/3/687 

Manish Narani (4):
  firmware: xilinx: Add SD Node and DLL Reset Data APIs
  dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller
  mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform
  arm64: zynqmp: Add new SDHCI compatible string

 .../devicetree/bindings/mmc/arasan,sdhci.txt       | 14 ++++
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi             |  6 +-
 drivers/mmc/host/sdhci-of-arasan.c                 | 83 ++++++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h               | 12 ++++
 4 files changed, 113 insertions(+), 2 deletions(-)

-- 
2.1.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH 1/4] firmware: xilinx: Add SD Node and DLL Reset Data APIs
  2018-09-18 13:45 [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller Manish Narani
@ 2018-09-18 13:45 ` Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 2/4] dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller Manish Narani
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Manish Narani @ 2018-09-18 13:45 UTC (permalink / raw)
  To: ulf.hansson, robh+dt, mark.rutland, michal.simek, adrian.hunter,
	manish.narani, leoyang.li, sudeep.holla, olof, amit.kucheria,
	rajanv, jollys
  Cc: linux-mmc, devicetree, linux-kernel, linux-arm-kernel

Add ZynqMP firmware SD Node data API to be used in call from SDHCI
driver. Also add DLL Reset data API to used for DLL reset calls from any
drivers.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
 include/linux/firmware/xlnx-zynqmp.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 58a7478..743687b 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -58,13 +58,25 @@ enum pm_ret_status {
 	XST_PM_ABORT_SUSPEND,
 };
 
+enum pm_node_id {
+	NODE_SD_0 = 39,
+	NODE_SD_1,
+};
+
 enum pm_ioctl_id {
+	IOCTL_SD_DLL_RESET = 6,
 	IOCTL_SET_PLL_FRAC_MODE = 8,
 	IOCTL_GET_PLL_FRAC_MODE,
 	IOCTL_SET_PLL_FRAC_DATA,
 	IOCTL_GET_PLL_FRAC_DATA,
 };
 
+enum dll_reset_type {
+	PM_DLL_RESET_ASSERT,
+	PM_DLL_RESET_RELEASE,
+	PM_DLL_RESET_PULSE,
+};
+
 enum pm_query_id {
 	PM_QID_INVALID,
 	PM_QID_CLOCK_GET_NAME,
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 2/4] dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller
  2018-09-18 13:45 [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 1/4] firmware: xilinx: Add SD Node and DLL Reset Data APIs Manish Narani
@ 2018-09-18 13:45 ` Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 3/4] mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 4/4] arm64: zynqmp: Add new SDHCI compatible string Manish Narani
  3 siblings, 0 replies; 5+ messages in thread
From: Manish Narani @ 2018-09-18 13:45 UTC (permalink / raw)
  To: ulf.hansson, robh+dt, mark.rutland, michal.simek, adrian.hunter,
	manish.narani, leoyang.li, sudeep.holla, olof, amit.kucheria,
	rajanv, jollys
  Cc: linux-mmc, devicetree, linux-kernel, linux-arm-kernel

Add documentation for 'xlnx,zynqmp-8.9a' SDHCI controller and required
properties followed by example.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
 Documentation/devicetree/bindings/mmc/arasan,sdhci.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/arasan,sdhci.txt b/Documentation/devicetree/bindings/mmc/arasan,sdhci.txt
index f6ddba3..72769e0 100644
--- a/Documentation/devicetree/bindings/mmc/arasan,sdhci.txt
+++ b/Documentation/devicetree/bindings/mmc/arasan,sdhci.txt
@@ -15,6 +15,7 @@ Required Properties:
     - "arasan,sdhci-5.1": generic Arasan SDHCI 5.1 PHY
     - "rockchip,rk3399-sdhci-5.1", "arasan,sdhci-5.1": rk3399 eMMC PHY
       For this device it is strongly suggested to include arasan,soc-ctl-syscon.
+    - "xlnx,zynqmp-8.9a", "arasan,sdhci-8.9a": Xilinx ZynqMP Arasan SDHCI 8.9a PHY
   - reg: From mmc bindings: Register location and length.
   - clocks: From clock bindings: Handles to clock inputs.
   - clock-names: From clock bindings: Tuple including "clk_xin" and "clk_ahb"
@@ -24,6 +25,9 @@ Required Properties for "arasan,sdhci-5.1":
   - phys: From PHY bindings: Phandle for the Generic PHY for arasan.
   - phy-names:  MUST be "phy_arasan".
 
+Required Properties for "xlnx,zynqmp-8.9a":
+  - xlnx,device_id: SD controller device ID. Must be either <0> or <1>.
+
 Optional Properties:
   - arasan,soc-ctl-syscon: A phandle to a syscon device (see ../mfd/syscon.txt)
     used to access core corecfg registers.  Offsets of registers in this
@@ -75,3 +79,13 @@ Example:
 		phy-names = "phy_arasan";
 		#clock-cells = <0>;
 	};
+
+	sdhci: sdhci@ff160000 {
+		compatible = "xlnx,zynqmp-8.9a", "arasan,sdhci-8.9a";
+		reg = <0x0 0xff160000 0x0 0x1000>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 48 4>;
+		clock-names = "clk_xin", "clk_ahb";
+		clocks = <&clk 54>, <&clk 31>;
+		xlnx,device_id = <0>;
+	};
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 3/4] mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform
  2018-09-18 13:45 [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 1/4] firmware: xilinx: Add SD Node and DLL Reset Data APIs Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 2/4] dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller Manish Narani
@ 2018-09-18 13:45 ` Manish Narani
  2018-09-18 13:45 ` [RFC PATCH 4/4] arm64: zynqmp: Add new SDHCI compatible string Manish Narani
  3 siblings, 0 replies; 5+ messages in thread
From: Manish Narani @ 2018-09-18 13:45 UTC (permalink / raw)
  To: ulf.hansson, robh+dt, mark.rutland, michal.simek, adrian.hunter,
	manish.narani, leoyang.li, sudeep.holla, olof, amit.kucheria,
	rajanv, jollys
  Cc: linux-mmc, devicetree, linux-kernel, linux-arm-kernel

Add support of SD auto tuning for ZynqMP platform. Before tuning
execution, reset the DLL and after the auto tuning process gets
completed, reset the DLL to load the newly obtained SDHC tuned tap
value.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
 drivers/mmc/host/sdhci-of-arasan.c | 83 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index a40bcc2..1a8bbd2 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -26,6 +26,7 @@
 #include <linux/phy/phy.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
+#include <linux/firmware/xlnx-zynqmp.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -98,6 +99,7 @@ struct sdhci_arasan_data {
 
 	struct regmap	*soc_ctl_base;
 	const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+	unsigned int	device_id;
 	unsigned int	quirks; /* Arasan deviations from spec */
 
 /* Controller does not have CD wired and will not function normally without */
@@ -163,6 +165,72 @@ static int sdhci_arasan_syscon_write(struct sdhci_host *host,
 	return ret;
 }
 
+static void zynqmp_dll_reset(u8 deviceid)
+{
+	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();
+
+	if (!eemi_ops || !eemi_ops->ioctl)
+		return;
+
+	/* Issue DLL Reset */
+	if (deviceid == 0)
+		eemi_ops->ioctl(NODE_SD_0, IOCTL_SD_DLL_RESET,
+				PM_DLL_RESET_PULSE, 0, NULL);
+	else
+		eemi_ops->ioctl(NODE_SD_1, IOCTL_SD_DLL_RESET,
+				PM_DLL_RESET_PULSE, 0, NULL);
+}
+
+static void arasan_zynqmp_dll_reset(struct sdhci_host *host, u8 deviceid)
+{
+	u16 clk;
+	unsigned long timeout;
+
+	clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
+	clk &= ~(SDHCI_CLOCK_CARD_EN | SDHCI_CLOCK_INT_EN);
+	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
+
+	/* Issue DLL Reset */
+	zynqmp_dll_reset(deviceid);
+
+	clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
+	clk |= SDHCI_CLOCK_INT_EN;
+	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
+
+	/* Wait max 20 ms */
+	timeout = 20;
+	while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
+				& SDHCI_CLOCK_INT_STABLE)) {
+		if (timeout == 0) {
+			dev_err(mmc_dev(host->mmc),
+				": Internal clock never stabilised.\n");
+			return;
+		}
+		timeout--;
+		mdelay(1);
+	}
+
+	clk |= SDHCI_CLOCK_CARD_EN;
+	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
+}
+
+static int arasan_zynqmp_execute_tuning(struct mmc_host *mmc, u32 opcode) {
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+	int err;
+
+	arasan_zynqmp_dll_reset(host, sdhci_arasan->device_id);
+
+	err = sdhci_execute_tuning(mmc, opcode);
+	if (err)
+		return err;
+
+	arasan_zynqmp_dll_reset(host, sdhci_arasan->device_id);
+
+	return 0;
+}
+
 static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -469,6 +537,7 @@ static const struct of_device_id sdhci_arasan_of_match[] = {
 	{ .compatible = "arasan,sdhci-8.9a" },
 	{ .compatible = "arasan,sdhci-5.1" },
 	{ .compatible = "arasan,sdhci-4.9a" },
+	{ .compatible = "xlnx,zynqmp-8.9a" },
 
 	{ /* sentinel */ }
 };
@@ -792,6 +861,20 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 		goto unreg_clk;
 	}
 
+	if (of_device_is_compatible(pdev->dev.of_node, "xlnx,zynqmp-8.9a")) {
+		ret = of_property_read_u32(pdev->dev.of_node,
+					   "xlnx,device_id",
+					   &sdhci_arasan->device_id);
+		if (ret < 0) {
+			dev_err(&pdev->dev,
+				"\"xlnx,device_id \" property is missing.\n");
+			goto unreg_clk;
+		}
+
+		host->mmc_host_ops.execute_tuning =
+			arasan_zynqmp_execute_tuning;
+	}
+
 	sdhci_arasan->phy = ERR_PTR(-ENODEV);
 	if (of_device_is_compatible(pdev->dev.of_node,
 				    "arasan,sdhci-5.1")) {
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 4/4] arm64: zynqmp: Add new SDHCI compatible string
  2018-09-18 13:45 [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller Manish Narani
                   ` (2 preceding siblings ...)
  2018-09-18 13:45 ` [RFC PATCH 3/4] mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform Manish Narani
@ 2018-09-18 13:45 ` Manish Narani
  3 siblings, 0 replies; 5+ messages in thread
From: Manish Narani @ 2018-09-18 13:45 UTC (permalink / raw)
  To: ulf.hansson, robh+dt, mark.rutland, michal.simek, adrian.hunter,
	manish.narani, leoyang.li, sudeep.holla, olof, amit.kucheria,
	rajanv, jollys
  Cc: linux-mmc, devicetree, linux-kernel, linux-arm-kernel

Mainline kernel has arasan compatible string now. Append this new
compatible string for ZynqMP SDHCI controller. Also add a required
property indicating ZynqMP SDHCI controller device ID.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
index 29ce234..1def7e1 100644
--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
+++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
@@ -485,21 +485,23 @@
 		};
 
 		sdhci0: sdhci@ff160000 {
-			compatible = "arasan,sdhci-8.9a";
+			compatible = "xlnx,zynqmp-8.9a", "arasan,sdhci-8.9a";
 			status = "disabled";
 			interrupt-parent = <&gic>;
 			interrupts = <0 48 4>;
 			reg = <0x0 0xff160000 0x0 0x1000>;
 			clock-names = "clk_xin", "clk_ahb";
+			xlnx,device_id = <0>;
 		};
 
 		sdhci1: sdhci@ff170000 {
-			compatible = "arasan,sdhci-8.9a";
+			compatible = "xlnx,zynqmp-8.9a", "arasan,sdhci-8.9a";
 			status = "disabled";
 			interrupt-parent = <&gic>;
 			interrupts = <0 49 4>;
 			reg = <0x0 0xff170000 0x0 0x1000>;
 			clock-names = "clk_xin", "clk_ahb";
+			xlnx,device_id = <1>;
 		};
 
 		smmu: smmu@fd800000 {
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-18 13:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 13:45 [RFC PATCH 0/4] Add auto tuning support for ZynqMP SDHCI controller Manish Narani
2018-09-18 13:45 ` [RFC PATCH 1/4] firmware: xilinx: Add SD Node and DLL Reset Data APIs Manish Narani
2018-09-18 13:45 ` [RFC PATCH 2/4] dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller Manish Narani
2018-09-18 13:45 ` [RFC PATCH 3/4] mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform Manish Narani
2018-09-18 13:45 ` [RFC PATCH 4/4] arm64: zynqmp: Add new SDHCI compatible string Manish Narani

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).