Add auto tuning support for ZynqMP SDHCI controller
Subsystems (4)
cover Add auto tuning support for ZynqMP SDHCI controller
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(-)
Signature · 1 line
2.1.1
RFC PATCH 1/4 firmware: xilinx: Add SD Node and DLL Reset Data APIs
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.
--- include/linux/firmware/xlnx-zynqmp.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/firmware/xlnx-zynqmp.h +12 -0
@@ -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 ,
Signature · 1 line
2.1.1
RFC PATCH 2/4 dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller
In reply to Manish NaraniAdd documentation for 'xlnx,zynqmp-8.9a' SDHCI controller and required properties followed by example.
--- Documentation/devicetree/bindings/mmc/arasan,sdhci.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +14 -0
@@ -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 at 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>; + };
Signature · 1 line
2.1.1
Rob Herring
maintainerRFC PATCH 2/4 dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller
Quoted 13 lines · Manish Narani
Add documentation for 'xlnx,zynqmp-8.9a' SDHCI controller and required properties followed by example.
Signed-off-by Manish Narani <[email protected]>--- Documentation/devicetree/bindings/mmc/arasan,sdhci.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +0
-0
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt Required Properties: · line 18
Quoted 4 lines
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +1
-0@@ -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
xlnx,zynqmp-sdhci. The version number is for Arasan.
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt Required Properties for "arasan,sdhci-5.1": · line 30
Quoted 10 lines
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +3
-0- 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>. +
What's this for?
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt Example: · line 83
Quoted 9 lines
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +2
-0Optional 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 at ff160000 {
mmc at ...
Quoted 11 lines
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt +8
-0+ 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>; + };Signature · 1 line
2.1.1
RFC PATCH 3/4 mmc: sdhci-of-arasan: Add auto tuning support for ZynqMP platform
In reply to Manish NaraniAdd 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.
--- drivers/mmc/host/sdhci-of-arasan.c | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +83 -0
@@ -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" )) {
Signature · 1 line
2.1.1
RFC PATCH 4/4 arm64: zynqmp: Add new SDHCI compatible string
In reply to Manish NaraniMainline 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.
--- arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +4 -2
@@ -485,21 +485,23 @@ }; sdhci0: sdhci at 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 at 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 at fd800000 {
Signature · 1 line
2.1.1