Skip to contentSkip to conversation

sdhci-of-arasan driver updates for ZynqMP platform

PATCH Applied Manish Narani 3 participants 10 messages Jun 15, 2021 – Jun 29, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover sdhci-of-arasan driver updates for ZynqMP platform

This patch series has some bug fixes for sdhci-of-arasan driver with respect to ZynqMP platform. This series also has some code style changes in the driver.

Manish Narani (6):
mmc: sdhci-of-arasan: Modified SD default speed to 19MHz for ZynqMP
mmc: sdhci-of-arasan: Add "SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12" quirk.
mmc: sdhci-of-arasan: Skip Auto tuning for DDR50 mode in ZynqMP
platform
mmc: host: sdhci-of-arasan: Check return value of non-void funtions
mmc: host: sdhci-of-arasan: Use appropriate type of division macro
mmc: host: sdhci-of-arasan: Modify data type of the clk_phase array

Sai Krishna Potthuri (1):
mmc: arasan: Fix the issue in reading tap values from DT

 drivers/mmc/host/sdhci-of-arasan.c | 51 ++++++++++++++++++++++++++++++++------
 1 file changed, 44 insertions(+), 7 deletions(-)
Signature · 1 line
2.1.1
#1 lore raw

PATCH 1/7 mmc: sdhci-of-arasan: Modified SD default speed to 19MHz for ZynqMP

SD standard speed timing was met only at 19MHz and not 25 MHz, that's why changing driver to 19MHz. The reason for this is when a level shifter is used on the board, timing was met for standard speed only at 19MHz. Since this level shifter is commonly required for high speed modes, the driver is modified to use standard speed of 19Mhz.

---
 drivers/mmc/host/sdhci-of-arasan.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +18 -0
index 839965f..fc3e41c 100644
@@ -159,6 +159,12 @@ struct sdhci_arasan_data {
 /* Controller immediately reports SDHCI_CLOCK_INT_STABLE after enabling the
  * internal clock even when the clock isn't stable */
 #define SDHCI_ARASAN_QUIRK_CLOCK_UNSTABLE BIT(1)
+/*
+ * Some of the Arasan variations might not have timing requirements
+ * met at 25MHz for Default Speed mode, those controllers work at
+ * 19MHz instead
+ */
+#define SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN BIT(2)
 };
 
 struct sdhci_arasan_of_data {
@@ -290,6 +296,16 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 		sdhci_arasan->is_phy_on = false;
 	}
 
+	if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN) {
+		/*
+		 * Some of the Arasan variations might not have timing
+		 * requirements met at 25MHz for Default Speed mode,
+		 * those controllers work at 19MHz instead.
+		 */
+		if (clock == DEFAULT_SPEED_MAX_DTR)
+			clock = (DEFAULT_SPEED_MAX_DTR * 19) / 25;
+	}
+
 	/* Set the Input and Output Clock Phase Delays */
 	if (clk_data->set_clk_delays)
 		clk_data->set_clk_delays(host);
@@ -1598,6 +1614,8 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 	if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) {
 		host->mmc_host_ops.execute_tuning =
 			arasan_zynqmp_execute_tuning;
+
+		sdhci_arasan->quirks |= SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN;
 	}
 
 	arasan_dt_parse_clk_phases(dev, &sdhci_arasan->clk_data);
Signature · 1 line
2.1.1
#2 lore raw

PATCH 2/7 mmc: sdhci-of-arasan: Add "SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12" quirk.

In reply to Manish Narani

Arasan controller supports AUTO CMD12, this patch adds "SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12" quirk to enable auto cmd12 feature.
By using auto cmd12 we can also avoid following error message "Got data interrupt even though no data operation in progress"

---
 drivers/mmc/host/sdhci-of-arasan.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-of-arasan.c +1 -0
index fc3e41c..b13e719 100644
@@ -1616,6 +1616,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 			arasan_zynqmp_execute_tuning;
 
 		sdhci_arasan->quirks |= SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN;
+		host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
 	}
 
 	arasan_dt_parse_clk_phases(dev, &sdhci_arasan->clk_data);
Signature · 1 line
2.1.1
#3 lore raw

PATCH 3/7 mmc: sdhci-of-arasan: Skip Auto tuning for DDR50 mode in ZynqMP platform

In reply to Manish Narani

ZynqMP platform does not perform auto tuning in DDR50 mode. Skip the same while the card is operating in DDR50 mode.

---
 drivers/mmc/host/sdhci-of-arasan.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +4 -0
index b13e719..1980d0b 100644
@@ -894,6 +894,10 @@ static int arasan_zynqmp_execute_tuning(struct mmc_host *mmc, u32 opcode)
 							   NODE_SD_1;
 	int err;
 
+	/* ZynqMP SD controller does not perform auto tuning in DDR50 mode */
+	if (mmc->ios.timing == MMC_TIMING_UHS_DDR50)
+		return 0;
+
 	arasan_zynqmp_dll_reset(host, device_id);
 
 	err = sdhci_execute_tuning(mmc, opcode);
Signature · 1 line
2.1.1
#4 lore raw

PATCH 4/7 mmc: host: sdhci-of-arasan: Check return value of non-void funtions

In reply to Manish Narani

At a couple of places, the return values of the non-void functions were not getting checked. This was reported by the coverity tool. Modify the code to check the return values of the same.

Addresses-Coverity: ("check_return")

---
 drivers/mmc/host/sdhci-of-arasan.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-of-arasan.c +15 -3
index 1980d0b..98671a3 100644
@@ -273,7 +273,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 			 * through low speeds without power cycling.
 			 */
 			sdhci_set_clock(host, host->max_clk);
-			phy_power_on(sdhci_arasan->phy);
+			if (phy_power_on(sdhci_arasan->phy)) {
+				pr_err("%s: Cannot power on phy.\n",
+				       mmc_hostname(host->mmc));
+				return;
+			}
+
 			sdhci_arasan->is_phy_on = true;
 
 			/*
@@ -323,7 +328,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 		msleep(20);
 
 	if (ctrl_phy) {
-		phy_power_on(sdhci_arasan->phy);
+		if (phy_power_on(sdhci_arasan->phy)) {
+			pr_err("%s: Cannot power on phy.\n",
+			       mmc_hostname(host->mmc));
+			return;
+		}
+
 		sdhci_arasan->is_phy_on = true;
 	}
 }
@@ -479,7 +489,9 @@ static int sdhci_arasan_suspend(struct device *dev)
 		ret = phy_power_off(sdhci_arasan->phy);
 		if (ret) {
 			dev_err(dev, "Cannot power off phy.\n");
-			sdhci_resume_host(host);
+			if (sdhci_resume_host(host))
+				dev_err(dev, "Cannot resume host.\n");
+
 			return ret;
 		}
 		sdhci_arasan->is_phy_on = false;
Signature · 1 line
2.1.1
#5 lore raw

PATCH 5/7 mmc: host: sdhci-of-arasan: Use appropriate type of division macro

In reply to Manish Narani

The division macro DIV_ROUND_CLOSEST takes int values as the argument. However the code here uses unsigned int values for this, which is causing the values comparison with 0 as always true. We can use DIV_ROUND_CLOSEST_ULL instead for the same.

Addresses-coverity: ("result_independent_of_operands")

---
 drivers/mmc/host/sdhci-of-arasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-arasan.c +1 -1
index 98671a3..510d8fc 100644
@@ -984,7 +984,7 @@ static void sdhci_arasan_update_baseclkfreq(struct sdhci_host *host)
 	struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
 	const struct sdhci_arasan_soc_ctl_map *soc_ctl_map =
 		sdhci_arasan->soc_ctl_map;
-	u32 mhz = DIV_ROUND_CLOSEST(clk_get_rate(pltfm_host->clk), 1000000);
+	u32 mhz = DIV_ROUND_CLOSEST_ULL(clk_get_rate(pltfm_host->clk), 1000000);
 
 	/* Having a map is optional */
 	if (!soc_ctl_map)
Signature · 1 line
2.1.1
#6 lore raw

PATCH 6/7 mmc: host: sdhci-of-arasan: Modify data type of the clk_phase array

In reply to Manish Narani

Modify the data type of the clk_phase array to u32 to make it compatible with the argument requirement of "of_property_read_variable_u32_array".

Addresses-coverity: ("incompatible_param")

---
 drivers/mmc/host/sdhci-of-arasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-arasan.c +1 -1
index 510d8fc..61fe13c 100644
@@ -1018,7 +1018,7 @@ static void arasan_dt_read_clk_phase(struct device *dev,
 {
 	struct device_node *np = dev->of_node;
 
-	int clk_phase[2] = {0};
+	u32 clk_phase[2] = {0};
 
 	/*
 	 * Read Tap Delay values from DT, if the DT does not contain the
Signature · 1 line
2.1.1
#7 lore raw

PATCH 7/7 mmc: arasan: Fix the issue in reading tap values from DT

In reply to Manish Narani

From: Sai Krishna Potthuri <[email protected]>

'of_property_read_variable_u32_array' function returns number of elements read on success. This patch updates the condition check in the driver to overwrite the tap values from DT if exist.

---
 drivers/mmc/host/sdhci-of-arasan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-arasan.c +4 -2
index 61fe13c..3f50095 100644
@@ -1019,13 +1019,15 @@ static void arasan_dt_read_clk_phase(struct device *dev,
 	struct device_node *np = dev->of_node;
 
 	u32 clk_phase[2] = {0};
+	int ret;
 
 	/*
 	 * Read Tap Delay values from DT, if the DT does not contain the
 	 * Tap Values then use the pre-defined values.
 	 */
-	if (of_property_read_variable_u32_array(np, prop, &clk_phase[0],
-						2, 0)) {
+	ret = of_property_read_variable_u32_array(np, prop, &clk_phase[0],
+						  2, 0);
+	if (ret < 0) {
 		dev_dbg(dev, "Using predefined clock phase for %s = %d %d\n",
 			prop, clk_data->clk_phase_in[timing],
 			clk_data->clk_phase_out[timing]);
Signature · 1 line
2.1.1
maintainer Acked-by on the v1 series
#8 lore raw
In reply to Manish Narani
Quoted 13 lines · Manish Narani

This patch series has some bug fixes for sdhci-of-arasan driver with respect to ZynqMP platform. This series also has some code style changes in the driver.

Manish Narani (6):
mmc: sdhci-of-arasan: Modified SD default speed to 19MHz for ZynqMP
mmc: sdhci-of-arasan: Add "SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12" quirk.
mmc: sdhci-of-arasan: Skip Auto tuning for DDR50 mode in ZynqMP
platform
mmc: host: sdhci-of-arasan: Check return value of non-void funtions
mmc: host: sdhci-of-arasan: Use appropriate type of division macro
mmc: host: sdhci-of-arasan: Modify data type of the clk_phase array

Quoted 6 lines

Sai Krishna Potthuri (1):
mmc: arasan: Fix the issue in reading tap values from DT

 drivers/mmc/host/sdhci-of-arasan.c | 51 ++++++++++++++++++++++++++++++++------
 1 file changed, 44 insertions(+), 7 deletions(-)

The subject prefixes look inconsistent, nevertheless, for all 7:

Applied
#9 lore raw
In reply to Manish Narani
Quoted 14 lines · Manish Narani

This patch series has some bug fixes for sdhci-of-arasan driver with respect to ZynqMP platform. This series also has some code style changes in the driver.

Manish Narani (6):
mmc: sdhci-of-arasan: Modified SD default speed to 19MHz for ZynqMP
mmc: sdhci-of-arasan: Add "SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12" quirk.
mmc: sdhci-of-arasan: Skip Auto tuning for DDR50 mode in ZynqMP
platform
mmc: host: sdhci-of-arasan: Check return value of non-void funtions
mmc: host: sdhci-of-arasan: Use appropriate type of division macro
mmc: host: sdhci-of-arasan: Modify data type of the clk_phase array

Quoted 9 lines

Sai Krishna Potthuri (1):
mmc: arasan: Fix the issue in reading tap values from DT

 drivers/mmc/host/sdhci-of-arasan.c | 51 ++++++++++++++++++++++++++++++++------
 1 file changed, 44 insertions(+), 7 deletions(-)

--
2.1.1

Queued up for v5.15 (temporary on the devel branch) and by amending the prefixes, thanks!

Kind regards
Uffe