Skip to contentSkip to conversation

Add tuning algorithm for delay chain

PATCH Superseded Judith Mendez 4 participants 26 messages Feb 7, 2024 – Feb 28, 2024

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Judith Mendez

author maintainer
#0 lore raw

v2 cover Add tuning algorithm for delay chain

This patch series introduces a new tuning algorithm for mmc. The new algorithm should be used when delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer. The new tuning algorithm is implemented as per the paper published here [0] and has been tested on the following
platforms: AM62x SK, AM62A SK, AM62p SK, AM64x SK, and AM64x EVM.

The series also includes a few fixes in the sdhci_am654 driver on OTAPDLYEN/ITAPDLYEN and ITAPDELSEL.

Changelog:
v1->v2:
- Remove unnecessary indentations and if/else in sdhci_am654_calculate_itap
- Optimize sdhci_am654_calculate_itap()
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()
- Change otap_del_sel[], itap_del_sel[], and itap_del_ena[] to type u32
- Revert unnecessary reformating in sdhci_am654_set_clock() and sdhci_j721e_4bit_set_clock()

Judith Mendez (7):
mmc: sdhci_am654: Add tuning algorithm for delay chain
mmc: sdhci_am654: Write ITAPDLY for DDR52 timing
mmc: sdhci_am654: Add missing OTAP/ITAP enable
mmc: sdhci_am654: Fix itapdly/otapdly array type
mmc: sdhci_am654: Update comments in sdhci_am654_set_clock
mmc: sdhci_am654: Add ITAPDLYSEL in sdhci_j721e_4bit_set_clock
mmc: sdhci_am654: Fix ITAPDLY for HS400 timing

 drivers/mmc/host/sdhci_am654.c | 176 ++++++++++++++++++++++++++-------
 1 file changed, 138 insertions(+), 38 deletions(-)

base-commit: 40d83f40c44ba8aa79cba409ace619db3a7f86f2

Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/7 mmc: sdhci_am654: Add tuning algorithm for delay chain

Currently the sdhci_am654 driver only supports one tuning algorithm which should be used only when DLL is enabled. The ITAPDLY is selected from the largest passing window and the buffer is viewed as a circular buffer.

The new algorithm should be used when the delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer.

This implementation is based off of the following paper: [1].

Also add support for multiple failing windows.

[1] https://www.ti.com/lit/an/spract9/spract9.pdf

Fixes 13ebeae68ac9 ("mmc: sdhci_am654: Add support for software tuning")

---
Changelog:
v1->v2:
- Remove unnecessary indentations and if/else in
sdhci_am654_calculate_itap()
- Optimize sdhci_am654_calculate_itap()

---
 drivers/mmc/host/sdhci_am654.c | 111 +++++++++++++++++++++++++++------
 1 file changed, 91 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci_am654.c +91 -20
index d659c59422e1..2c66a965c225 100644
@@ -149,10 +149,17 @@ struct sdhci_am654_data {
 	int strb_sel;
 	u32 flags;
 	u32 quirks;
+	bool dll_enable;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
 };
 
+struct window {
+	u8 start;
+	u8 end;
+	u8 length;
+};
+
 struct sdhci_am654_driver_data {
 	const struct sdhci_pltfm_data *pdata;
 	u32 flags;
@@ -290,10 +297,13 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, mask, val);
 
-	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ)
+	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
 		sdhci_am654_setup_dll(host, clock);
-	else
+		sdhci_am654->dll_enable = true;
+	} else {
 		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
+		sdhci_am654->dll_enable = false;
+	}
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
 			   sdhci_am654->clkbuf_sel);
@@ -408,39 +418,100 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
 	return 0;
 }
 
-#define ITAP_MAX	32
+#define ITAPDLY_LENGTH 32
+#define ITAPDLY_LAST_INDEX 31
+static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
+			  *fail_window, u8 num_fails, bool circular_buffer)
+{
+	struct device *dev = mmc_dev(host->mmc);
+	struct window pass_window = {0, 0, 0};
+	u8 first_fail_start = 0, last_fail_end = 0;
+	int prev_fail_end = -1;
+	u8 itap = 0, start_fail = 0, end_fail = 0, pass_length = 0;
+	u8 i;
+
+	if (!num_fails)
+		return ITAPDLY_LAST_INDEX >> 1;
+
+	if (fail_window->length == ITAPDLY_LENGTH) {
+		dev_err(dev, "No passing ITAPDLY, return 0\n");
+		return 0;
+	}
+
+	first_fail_start = fail_window->start;
+	last_fail_end = fail_window[num_fails - 1].end;
+
+	for (i = 0; i < num_fails; i++) {
+		start_fail = fail_window[i].start;
+		end_fail = fail_window[i].end;
+		pass_length = start_fail - (prev_fail_end + 1);
+
+		if (pass_length > pass_window.length) {
+			pass_window.start = prev_fail_end + 1;
+			pass_window.length = pass_length;
+		}
+		prev_fail_end = end_fail;
+	}
+
+	if (!circular_buffer)
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
+	else
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
+
+	if (pass_length > pass_window.length) {
+		pass_window.start = last_fail_end + 1;
+		pass_window.length = pass_length;
+	}
+
+	if (!circular_buffer)
+		itap = pass_window.start + (pass_window.length >> 1);
+	else
+		itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
+
+	return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);
+}
+
 static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 					       u32 opcode)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
-	int cur_val, prev_val = 1, fail_len = 0, pass_window = 0, pass_len;
-	u32 itap;
+	struct window fail_window[ITAPDLY_LENGTH];
+	u8 prev_pass = 1;
+	u8 fail_index = 0;
+	u8 curr_pass, itap;
+
+	memset(fail_window, 0, sizeof(fail_window[0]) * ITAPDLY_LENGTH);
 
 	/* Enable ITAPDLY */
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYENA_MASK,
 			   1 << ITAPDLYENA_SHIFT);
 
-	for (itap = 0; itap < ITAP_MAX; itap++) {
+	for (itap = 0; itap < ITAPDLY_LENGTH; itap++) {
 		sdhci_am654_write_itapdly(sdhci_am654, itap);
 
-		cur_val = !mmc_send_tuning(host->mmc, opcode, NULL);
-		if (cur_val && !prev_val)
-			pass_window = itap;
+		curr_pass = !mmc_send_tuning(host->mmc, opcode, NULL);
 
-		if (!cur_val)
-			fail_len++;
+		if (!curr_pass && prev_pass)
+			fail_window[fail_index].start = itap;
 
-		prev_val = cur_val;
+		if (!curr_pass) {
+			fail_window[fail_index].end = itap;
+			fail_window[fail_index].length++;
+		}
+
+		if (curr_pass && !prev_pass)
+			fail_index++;
+
+		prev_pass = curr_pass;
 	}
-	/*
-	 * Having determined the length of the failing window and start of
-	 * the passing window calculate the length of the passing window and
-	 * set the final value halfway through it considering the range as a
-	 * circular buffer
-	 */
-	pass_len = ITAP_MAX - fail_len;
-	itap = (pass_window + (pass_len >> 1)) % ITAP_MAX;
+
+	if (fail_window[fail_index].length != 0)
+		fail_index++;
+
+	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
+					  (sdhci_am654->dll_enable));
+
 	sdhci_am654_write_itapdly(sdhci_am654, itap);
 
 	return 0;
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay chain

Quoted 66 lines · Judith Mendez

Currently the sdhci_am654 driver only supports one tuning algorithm which should be used only when DLL is enabled. The ITAPDLY is selected from the largest passing window and the buffer is viewed as a circular buffer.

The new algorithm should be used when the delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer.

This implementation is based off of the following paper: [1].

Also add support for multiple failing windows.

[1] https://www.ti.com/lit/an/spract9/spract9.pdf

Fixes 13ebeae68ac9 ("mmc: sdhci_am654: Add support for software tuning")

---
Changelog:
v1->v2:
- Remove unnecessary indentations and if/else in
sdhci_am654_calculate_itap()
- Optimize sdhci_am654_calculate_itap()

---
 drivers/mmc/host/sdhci_am654.c | 111 +++++++++++++++++++++++++++------
 1 file changed, 91 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci_am654.c +12 -2
index d659c59422e1..2c66a965c225 100644
@@ -149,10 +149,17 @@ struct sdhci_am654_data {
 	int strb_sel;
 	u32 flags;
 	u32 quirks;
+	bool dll_enable;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
 };
 
+struct window {
+	u8 start;
+	u8 end;
+	u8 length;
+};
+
 struct sdhci_am654_driver_data {
 	const struct sdhci_pltfm_data *pdata;
 	u32 flags;
@@ -290,10 +297,13 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, mask, val);
 
-	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ)
+	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
 		sdhci_am654_setup_dll(host, clock);
-	else
+		sdhci_am654->dll_enable = true;
+	} else {
 		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
+		sdhci_am654->dll_enable = false;
+	}
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
 			   sdhci_am654->clkbuf_sel);

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 422

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +2 -1
@@ -408,39 +418,100 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
 	return 0;
 }
 
-#define ITAP_MAX	32
+#define ITAPDLY_LENGTH 32
+#define ITAPDLY_LAST_INDEX 31

Presumably ITAPDLY_LAST_INDEX == ITAPDLY_LENGTH - 1, so perhaps:

#define ITAPDLY_LAST_INDEX (ITAPDLY_LENGTH - 1)

Blank line here perhaps.

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 431

Quoted 9 lines
drivers/mmc/host/sdhci_am654.c +9 -0
+static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
+			  *fail_window, u8 num_fails, bool circular_buffer)
+{
+	struct device *dev = mmc_dev(host->mmc);
+	struct window pass_window = {0, 0, 0};
+	u8 first_fail_start = 0, last_fail_end = 0;
+	int prev_fail_end = -1;
+	u8 itap = 0, start_fail = 0, end_fail = 0, pass_length = 0;
+	u8 i;

Some prefer ordering of variable declarations at the beginning of a function to be "reverse fir tree" order, in other words, longer lines first, e.g.

	u8 itap = 0, start_fail = 0, end_fail = 0, pass_length = 0;
	u8 first_fail_start = 0, last_fail_end = 0;
	struct device *dev = mmc_dev(host->mmc);
	struct window pass_window = {0, 0, 0};
	int prev_fail_end = -1;
	u8 i;
Quoted 30 lines
drivers/mmc/host/sdhci_am654.c +30 -0
+
+	if (!num_fails)
+		return ITAPDLY_LAST_INDEX >> 1;
+
+	if (fail_window->length == ITAPDLY_LENGTH) {
+		dev_err(dev, "No passing ITAPDLY, return 0\n");
+		return 0;
+	}
+
+	first_fail_start = fail_window->start;
+	last_fail_end = fail_window[num_fails - 1].end;
+
+	for (i = 0; i < num_fails; i++) {
+		start_fail = fail_window[i].start;
+		end_fail = fail_window[i].end;
+		pass_length = start_fail - (prev_fail_end + 1);
+
+		if (pass_length > pass_window.length) {
+			pass_window.start = prev_fail_end + 1;
+			pass_window.length = pass_length;
+		}
+		prev_fail_end = end_fail;
+	}
+
+	if (!circular_buffer)
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
+	else
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
+
+	if (pass_length > pass_window.length) {

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 471

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +10 -0
+		pass_window.start = last_fail_end + 1;
+		pass_window.length = pass_length;
+	}
+
+	if (!circular_buffer)
+		itap = pass_window.start + (pass_window.length >> 1);
+	else
+		itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
+
+	return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);

Parentheses are not needed where they are but putting them around the condition would make it more readable e.g.

	return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;

However (itap < 0) is not possible because itap is an unsigned type and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better to return ITAPDLY_LAST_INDEX

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 482

Quoted 13 lines
drivers/mmc/host/sdhci_am654.c +6 -2
+}
+
 static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 					       u32 opcode)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
-	int cur_val, prev_val = 1, fail_len = 0, pass_window = 0, pass_len;
-	u32 itap;
+	struct window fail_window[ITAPDLY_LENGTH];
+	u8 prev_pass = 1;
+	u8 fail_index = 0;
+	u8 curr_pass, itap;

Perhaps reverse fir tree

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 484

Quoted 2 lines
drivers/mmc/host/sdhci_am654.c +2 -0
+
+	memset(fail_window, 0, sizeof(fail_window[0]) * ITAPDLY_LENGTH);

This can be:

	memset(fail_window, 0, sizeof(fail_window));
Quoted 34 lines
drivers/mmc/host/sdhci_am654.c +13 -11
 	/* Enable ITAPDLY */
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYENA_MASK,
 			   1 << ITAPDLYENA_SHIFT);
 
-	for (itap = 0; itap < ITAP_MAX; itap++) {
+	for (itap = 0; itap < ITAPDLY_LENGTH; itap++) {
 		sdhci_am654_write_itapdly(sdhci_am654, itap);
 
-		cur_val = !mmc_send_tuning(host->mmc, opcode, NULL);
-		if (cur_val && !prev_val)
-			pass_window = itap;
+		curr_pass = !mmc_send_tuning(host->mmc, opcode, NULL);
 
-		if (!cur_val)
-			fail_len++;
+		if (!curr_pass && prev_pass)
+			fail_window[fail_index].start = itap;
 
-		prev_val = cur_val;
+		if (!curr_pass) {
+			fail_window[fail_index].end = itap;
+			fail_window[fail_index].length++;
+		}
+
+		if (curr_pass && !prev_pass)
+			fail_index++;
+
+		prev_pass = curr_pass;
 	}
-	/*
-	 * Having determined the length of the failing window and start of
-	 * the passing window calculate the length of the passing window and
-	 * set the final value halfway through it considering the range as a

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 513

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +6 -4
-	 * circular buffer
-	 */
-	pass_len = ITAP_MAX - fail_len;
-	itap = (pass_window + (pass_len >> 1)) % ITAP_MAX;
+
+	if (fail_window[fail_index].length != 0)
+		fail_index++;
+
+	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
+					  (sdhci_am654->dll_enable));

Parentheses around sdhci_am654->dll_enable are not needed.

Quoted 4 lines
drivers/mmc/host/sdhci_am654.c +1 -0
+
 	sdhci_am654_write_itapdly(sdhci_am654, itap);
 
 	return 0;
author maintainer
#3 lore raw

Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay chain

Hi Adrian,

Quoted 76 lines · Adrian Hunter
Quoted 66 lines · Judith Mendez

Currently the sdhci_am654 driver only supports one tuning algorithm which should be used only when DLL is enabled. The ITAPDLY is selected from the largest passing window and the buffer is viewed as a circular buffer.

The new algorithm should be used when the delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer.

This implementation is based off of the following paper: [1].

Also add support for multiple failing windows.

[1] https://www.ti.com/lit/an/spract9/spract9.pdf

Fixes 13ebeae68ac9 ("mmc: sdhci_am654: Add support for software tuning")

---
Changelog:
v1->v2:
- Remove unnecessary indentations and if/else in
sdhci_am654_calculate_itap()
- Optimize sdhci_am654_calculate_itap()

---
  drivers/mmc/host/sdhci_am654.c | 111 +++++++++++++++++++++++++++------
  1 file changed, 91 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci_am654.c +12 -2
index d659c59422e1..2c66a965c225 100644
@@ -149,10 +149,17 @@ struct sdhci_am654_data {
  	int strb_sel;
  	u32 flags;
  	u32 quirks;
+	bool dll_enable;
 
  #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
  };
 
+struct window {
+	u8 start;
+	u8 end;
+	u8 length;
+};
+
  struct sdhci_am654_driver_data {
  	const struct sdhci_pltfm_data *pdata;
  	u32 flags;
@@ -290,10 +297,13 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
  	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, mask, val);
 
-	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ)
+	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
  		sdhci_am654_setup_dll(host, clock);
-	else
+		sdhci_am654->dll_enable = true;
+	} else {
  		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
+		sdhci_am654->dll_enable = false;
+	}
 
  	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
  			   sdhci_am654->clkbuf_sel);

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 422

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +2 -1
@@ -408,39 +418,100 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
  	return 0;
  }
 
-#define ITAP_MAX	32
+#define ITAPDLY_LENGTH 32
+#define ITAPDLY_LAST_INDEX 31

Presumably ITAPDLY_LAST_INDEX == ITAPDLY_LENGTH - 1, so perhaps:

Quoted 3 lines

#define ITAPDLY_LAST_INDEX (ITAPDLY_LENGTH - 1)

Blank line here perhaps.

This does seem easier to read, will add for v3.

Quoted 15 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 431

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +9 -0
+static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
+			  *fail_window, u8 num_fails, bool circular_buffer)
+{
+	struct device *dev = mmc_dev(host->mmc);
+	struct window pass_window = {0, 0, 0};
+	u8 first_fail_start = 0, last_fail_end = 0;
+	int prev_fail_end = -1;
+	u8 itap = 0, start_fail = 0, end_fail = 0, pass_length = 0;
+	u8 i;

Some prefer ordering of variable declarations at the beginning of a function to be "reverse fir tree" order, in other words, longer lines first, e.g.

Quoted 6 lines
	u8 itap = 0, start_fail = 0, end_fail = 0, pass_length = 0;
	u8 first_fail_start = 0, last_fail_end = 0;
	struct device *dev = mmc_dev(host->mmc);
	struct window pass_window = {0, 0, 0};
	int prev_fail_end = -1;
	u8 i;

Understood, will add for v3.

Quoted 45 lines
Quoted 31 lines
drivers/mmc/host/sdhci_am654.c +30 -0
+
+	if (!num_fails)
+		return ITAPDLY_LAST_INDEX >> 1;
+
+	if (fail_window->length == ITAPDLY_LENGTH) {
+		dev_err(dev, "No passing ITAPDLY, return 0\n");
+		return 0;
+	}
+
+	first_fail_start = fail_window->start;
+	last_fail_end = fail_window[num_fails - 1].end;
+
+	for (i = 0; i < num_fails; i++) {
+		start_fail = fail_window[i].start;
+		end_fail = fail_window[i].end;
+		pass_length = start_fail - (prev_fail_end + 1);
+
+		if (pass_length > pass_window.length) {
+			pass_window.start = prev_fail_end + 1;
+			pass_window.length = pass_length;
+		}
+		prev_fail_end = end_fail;
+	}
+
+	if (!circular_buffer)
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
+	else
+		pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
+
+	if (pass_length > pass_window.length) {

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 471

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +10 -0
+		pass_window.start = last_fail_end + 1;
+		pass_window.length = pass_length;
+	}
+
+	if (!circular_buffer)
+		itap = pass_window.start + (pass_window.length >> 1);
+	else
+		itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
+
+	return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);

Parentheses are not needed where they are but putting them around the condition would make it more readable e.g.

Quoted 5 lines
	return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;

However (itap < 0) is not possible because itap is an unsigned type and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better to return ITAPDLY_LAST_INDEX

You are right about itap < 0, thanks will fix.

About itap > ITAPDLY_LAST_INDEX, this is an error. Why return ITAPDLY_LAST_INDEX instead of 0?

Quoted 16 lines
Quoted 4 lines
drivers/mmc/host/sdhci_am654.c +2 -0
+}
+
  static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 482

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +4 -2
  					       u32 opcode)
  {
  	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
-	int cur_val, prev_val = 1, fail_len = 0, pass_window = 0, pass_len;
-	u32 itap;
+	struct window fail_window[ITAPDLY_LENGTH];
+	u8 prev_pass = 1;
+	u8 fail_index = 0;
+	u8 curr_pass, itap;

Perhaps reverse fir tree

Will add fix here as well.

Quoted 7 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 484

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +2 -0
+
+	memset(fail_window, 0, sizeof(fail_window[0]) * ITAPDLY_LENGTH);

This can be:

	memset(fail_window, 0, sizeof(fail_window));

This does look simpler, will add for v3.

Quoted 39 lines
Quoted 39 lines
drivers/mmc/host/sdhci_am654.c +13 -15
  	/* Enable ITAPDLY */
  	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYENA_MASK,
  			   1 << ITAPDLYENA_SHIFT);
 
-	for (itap = 0; itap < ITAP_MAX; itap++) {
+	for (itap = 0; itap < ITAPDLY_LENGTH; itap++) {
  		sdhci_am654_write_itapdly(sdhci_am654, itap);
 
-		cur_val = !mmc_send_tuning(host->mmc, opcode, NULL);
-		if (cur_val && !prev_val)
-			pass_window = itap;
+		curr_pass = !mmc_send_tuning(host->mmc, opcode, NULL);
 
-		if (!cur_val)
-			fail_len++;
+		if (!curr_pass && prev_pass)
+			fail_window[fail_index].start = itap;
 
-		prev_val = cur_val;
+		if (!curr_pass) {
+			fail_window[fail_index].end = itap;
+			fail_window[fail_index].length++;
+		}
+
+		if (curr_pass && !prev_pass)
+			fail_index++;
+
+		prev_pass = curr_pass;
  	}
-	/*
-	 * Having determined the length of the failing window and start of
-	 * the passing window calculate the length of the passing window and
-	 * set the final value halfway through it considering the range as a
-	 * circular buffer
-	 */
-	pass_len = ITAP_MAX - fail_len;
-	itap = (pass_window + (pass_len >> 1)) % ITAP_MAX;
Quoted 8 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 513

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +6 -0
+
+	if (fail_window[fail_index].length != 0)
+		fail_index++;
+
+	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
+					  (sdhci_am654->dll_enable));

Parentheses around sdhci_am654->dll_enable are not needed.

Agree, I can remove for v3.

Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 517

Quoted 5 lines
drivers/mmc/host/sdhci_am654.c +1 -0
+
  	sdhci_am654_write_itapdly(sdhci_am654, itap);
 
  	return 0;

My apologies for the late reply and thanks for reviewing.

~ Judith

maintainer
#4 lore raw

Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay chain

Quoted 48 lines · Judith Mendez
Quoted 47 lines · Adrian Hunter
Quoted 30 lines · Judith Mendez
drivers/mmc/host/sdhci_am654.c +30 -0
+
+    if (!num_fails)
+        return ITAPDLY_LAST_INDEX >> 1;
+
+    if (fail_window->length == ITAPDLY_LENGTH) {
+        dev_err(dev, "No passing ITAPDLY, return 0\n");
+        return 0;
+    }
+
+    first_fail_start = fail_window->start;
+    last_fail_end = fail_window[num_fails - 1].end;
+
+    for (i = 0; i < num_fails; i++) {
+        start_fail = fail_window[i].start;
+        end_fail = fail_window[i].end;
+        pass_length = start_fail - (prev_fail_end + 1);
+
+        if (pass_length > pass_window.length) {
+            pass_window.start = prev_fail_end + 1;
+            pass_window.length = pass_length;
+        }
+        prev_fail_end = end_fail;
+    }
+
+    if (!circular_buffer)
+        pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
+    else
+        pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
+
+    if (pass_length > pass_window.length) {

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 471

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +10 -0
+        pass_window.start = last_fail_end + 1;
+        pass_window.length = pass_length;
+    }
+
+    if (!circular_buffer)
+        itap = pass_window.start + (pass_window.length >> 1);
+    else
+        itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
+
+    return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);

Parentheses are not needed where they are but putting them around the condition would make it more readable e.g.

    return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;

Quoted 8 lines
Quoted 3 lines

However (itap < 0) is not possible because itap is an unsigned type and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better to return ITAPDLY_LAST_INDEX

You are right about itap < 0, thanks will fix.

About itap > ITAPDLY_LAST_INDEX, this is an error. Why return ITAPDLY_LAST_INDEX instead of 0?

It doesn't matter. Just if a value has a better chance to work if the calculation fails, like maybe ITAPDLY_LAST_INDEX / 2, but presumably it should not fail.

author maintainer
#5 lore raw

Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay chain

Hello Adrian,

Quoted 53 lines · Adrian Hunter
Quoted 52 lines · Judith Mendez
Quoted 50 lines · Adrian Hunter
Quoted 30 lines · Judith Mendez
drivers/mmc/host/sdhci_am654.c +30 -0
+
+    if (!num_fails)
+        return ITAPDLY_LAST_INDEX >> 1;
+
+    if (fail_window->length == ITAPDLY_LENGTH) {
+        dev_err(dev, "No passing ITAPDLY, return 0\n");
+        return 0;
+    }
+
+    first_fail_start = fail_window->start;
+    last_fail_end = fail_window[num_fails - 1].end;
+
+    for (i = 0; i < num_fails; i++) {
+        start_fail = fail_window[i].start;
+        end_fail = fail_window[i].end;
+        pass_length = start_fail - (prev_fail_end + 1);
+
+        if (pass_length > pass_window.length) {
+            pass_window.start = prev_fail_end + 1;
+            pass_window.length = pass_length;
+        }
+        prev_fail_end = end_fail;
+    }
+
+    if (!circular_buffer)
+        pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
+    else
+        pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
+
+    if (pass_length > pass_window.length) {

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) · line 471

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +10 -0
+        pass_window.start = last_fail_end + 1;
+        pass_window.length = pass_length;
+    }
+
+    if (!circular_buffer)
+        itap = pass_window.start + (pass_window.length >> 1);
+    else
+        itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
+
+    return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);

Parentheses are not needed where they are but putting them around the condition would make it more readable e.g.

    return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;

However (itap < 0) is not possible because itap is an unsigned type and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better to return ITAPDLY_LAST_INDEX

Quoted 8 lines
Quoted 4 lines

You are right about itap < 0, thanks will fix.

About itap > ITAPDLY_LAST_INDEX, this is an error. Why return ITAPDLY_LAST_INDEX instead of 0?

It doesn't matter. Just if a value has a better chance to work if the calculation fails, like maybe ITAPDLY_LAST_INDEX / 2, but presumably it should not fail.

Ok, ITAPDLY_LAST_INDEX / sounds good to me, I will add this instead.

Thanks,
~ Judith

author maintainer
#6 lore raw

PATCH v2 2/7 mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

In reply to Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()

---
 drivers/mmc/host/sdhci_am654.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
 		sdhci_am654_setup_dll(host, clock);
+		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
 		sdhci_am654->dll_enable = true;
 	} else {
 		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
Signature · 1 line
2.43.0
Reviewed-by on v2 2/7
#7 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

Quoted 6 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")
Quoted 8 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()

---
  drivers/mmc/host/sdhci_am654.c | 1 +
  1 file changed, 1 insertion(+)

See how much easier this patch is this way :)

Quoted 13 lines
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
  	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
  		sdhci_am654_setup_dll(host, clock);
+		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
  		sdhci_am654->dll_enable = true;
  	} else {
  		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
author maintainer
#8 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

Hi Andrew,

Quoted 16 lines · Andrew Davis
Quoted 6 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")
Quoted 8 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()
---
  drivers/mmc/host/sdhci_am654.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 1 line

See how much easier this patch is this way :)

Thanks for your review. :D It does look simpler.

Quoted 17 lines
Quoted 14 lines
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct 
 sdhci_host *host, unsigned int clock)
       if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
           sdhci_am654_setup_dll(host, clock);
+        sdhci_am654_write_itapdly(sdhci_am654, 
 sdhci_am654->itap_del_sel[timing]);
           sdhci_am654->dll_enable = true;
       } else {

          sdhci_am654_setup_delay_chain(sdhci_am654, timing);

maintainer
#9 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

In reply to Judith Mendez
Quoted 5 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")

Note that the Fixes tags make a different ordering than the patch order i.e.

Patch Fixes in version
1 13ebeae68ac9 v5.10-rc1
2 a161c45f2979 v5.7-rc1
3 8ee5fc0e0b3b v5.7-rc1
4 8ee5fc0e0b3b v5.7-rc1
4 a0a62497f6aa v5.10-rc1
5 fe52e2fbc6ef v5.9-rc1
6 1accbced1c32 v5.3-rc1
7 a161c45f2979 v5.7-rc1

That might make backporting these patches more challenging.

Quoted 22 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()

---
 drivers/mmc/host/sdhci_am654.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
 		sdhci_am654_setup_dll(host, clock);
+		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
 		sdhci_am654->dll_enable = true;
 	} else {
 		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
author maintainer
#10 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

Hi Adrian,

Quoted 20 lines · Adrian Hunter
Quoted 5 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")

Note that the Fixes tags make a different ordering than the patch order i.e.

Patch Fixes in version
1 13ebeae68ac9 v5.10-rc1
2 a161c45f2979 v5.7-rc1
3 8ee5fc0e0b3b v5.7-rc1
4 8ee5fc0e0b3b v5.7-rc1
4 a0a62497f6aa v5.10-rc1
5 fe52e2fbc6ef v5.9-rc1
6 1accbced1c32 v5.3-rc1
7 a161c45f2979 v5.7-rc1

Quoted 1 line

That might make backporting these patches more challenging.

Are you suggesting to remove the fixes tag here?

Quoted 17 lines
Quoted 17 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()

---
  drivers/mmc/host/sdhci_am654.c | 1 +
  1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
Quoted 7 lines

drivers/mmc/host/sdhci_am654.c static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock) · line 305

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +1 -0
  	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
  		sdhci_am654_setup_dll(host, clock);
+		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
  		sdhci_am654->dll_enable = true;
  	} else {
  		sdhci_am654_setup_delay_chain(sdhci_am654, timing);

~ Judith

maintainer
#11 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

Quoted 23 lines · Judith Mendez

Hi Adrian,

Quoted 20 lines · Adrian Hunter
Quoted 5 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")

Note that the Fixes tags make a different ordering than the patch order i.e.

Patch    Fixes        in version
1     13ebeae68ac9     v5.10-rc1
2     a161c45f2979     v5.7-rc1
3     8ee5fc0e0b3b     v5.7-rc1
4     8ee5fc0e0b3b     v5.7-rc1
4     a0a62497f6aa     v5.10-rc1
5     fe52e2fbc6ef     v5.9-rc1
6     1accbced1c32     v5.3-rc1
7     a161c45f2979     v5.7-rc1

Quoted 3 lines
Quoted 1 line

That might make backporting these patches more challenging.

Are you suggesting to remove the fixes tag here?

No, it is just something to think about if you intend to backport these patches to older kernels.

Quoted 26 lines
Quoted 12 lines
Quoted 12 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()
---
  drivers/mmc/host/sdhci_am654.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 12 lines

drivers/mmc/host/sdhci_am654.c static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock) · line 304

Quoted 11 lines
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
         if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
           sdhci_am654_setup_dll(host, clock);
+        sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
           sdhci_am654->dll_enable = true;
       } else {
           sdhci_am654_setup_delay_chain(sdhci_am654, timing);

~ Judith

author maintainer
#12 lore raw

Re: [PATCH v2 2/7] mmc: sdhci_am654: Write ITAPDLY for DDR52 timing

Hi Adrian,

Quoted 24 lines · Adrian Hunter
Quoted 23 lines · Judith Mendez

Hi Adrian,

Quoted 20 lines · Adrian Hunter
Quoted 5 lines · Judith Mendez

For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")

Note that the Fixes tags make a different ordering than the patch order i.e.

Patch    Fixes        in version
1     13ebeae68ac9     v5.10-rc1
2     a161c45f2979     v5.7-rc1
3     8ee5fc0e0b3b     v5.7-rc1
4     8ee5fc0e0b3b     v5.7-rc1
4     a0a62497f6aa     v5.10-rc1
5     fe52e2fbc6ef     v5.9-rc1
6     1accbced1c32     v5.3-rc1
7     a161c45f2979     v5.7-rc1

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

That might make backporting these patches more challenging.

Are you suggesting to remove the fixes tag here?

No, it is just something to think about if you intend to backport these patches to older kernels.

Thanks, Ill keep this in mind for v3.

Quoted 28 lines
Quoted 27 lines
Quoted 13 lines
Quoted 13 lines

---
Changelog:
v1->v2:
- Call sdhci_am654_write_itapdly() in sdhci_am654_set_clock() instead of sdhci_am654_setup_dll()

---
   drivers/mmc/host/sdhci_am654.c | 1 +
   1 file changed, 1 insertion(+)
Quoted 12 lines

drivers/mmc/host/sdhci_am654.c static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock) · line 304

Quoted 11 lines
drivers/mmc/host/sdhci_am654.c +1 -0
index 2c66a965c225..b50db5d4a452 100644
@@ -299,6 +299,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
         if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
           sdhci_am654_setup_dll(host, clock);
+        sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
           sdhci_am654->dll_enable = true;
       } else {
           sdhci_am654_setup_delay_chain(sdhci_am654, timing);

~ Judith

author maintainer
#13 lore raw

PATCH v2 3/7 mmc: sdhci_am654: Add missing OTAP/ITAP enable

In reply to Judith Mendez

Currently the OTAP/ITAP delay enable functionality is missing in the am654_set_clock function which is used for MMC0 on AM62p and AM64x devices. The OTAP delay is not enabled when timing < SDR25 bus speed mode. The ITAP delay is not enabled for all bus speed modes.

Add this OTAP/ITAP delay functionality according to the datasheet
[1] OTAPDLYENA and ITAPDLYENA for MMC0.

[1] https://www.ti.com/lit/ds/symlink/am62p.pdf

Fixes 8ee5fc0e0b3b ("mmc: sdhci_am654: Update OTAPDLY writes")

---
Changelog:
v1->v2:
- Change itap_del_ena[] to type u32
- Revert unnecessary reformating in sdhci_am654_set_clock() and sdhci_j721e_4bit_set_clock()

---
 drivers/mmc/host/sdhci_am654.c | 40 ++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 16 deletions(-)
drivers/mmc/host/sdhci_am654.c +24 -16
index b50db5d4a452..935f581c05d8 100644
@@ -143,6 +143,7 @@ struct sdhci_am654_data {
 	struct regmap *base;
 	int otap_del_sel[ARRAY_SIZE(td)];
 	int itap_del_sel[ARRAY_SIZE(td)];
+	u32 itap_del_ena[ARRAY_SIZE(td)];
 	int clkbuf_sel;
 	int trm_icp;
 	int drv_strength;
@@ -239,11 +240,13 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock)
 }
 
 static void sdhci_am654_write_itapdly(struct sdhci_am654_data *sdhci_am654,
-				      u32 itapdly)
+				      u32 itapdly, u32 enable)
 {
 	/* Set ITAPCHGWIN before writing to ITAPDLY */
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPCHGWIN_MASK,
 			   1 << ITAPCHGWIN_SHIFT);
+	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYENA_MASK,
+			   enable << ITAPDLYENA_SHIFT);
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYSEL_MASK,
 			   itapdly << ITAPDLYSEL_SHIFT);
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPCHGWIN_MASK, 0);
@@ -260,8 +263,8 @@ static void sdhci_am654_setup_delay_chain(struct sdhci_am654_data *sdhci_am654,
 	mask = SELDLYTXCLK_MASK | SELDLYRXCLK_MASK;
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, mask, val);
 
-	sdhci_am654_write_itapdly(sdhci_am654,
-				  sdhci_am654->itap_del_sel[timing]);
+	sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing],
+				  sdhci_am654->itap_del_ena[timing]);
 }
 
 static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
@@ -270,7 +273,6 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
 	unsigned char timing = host->mmc->ios.timing;
 	u32 otap_del_sel;
-	u32 otap_del_ena;
 	u32 mask, val;
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL1, ENDLL_MASK, 0);
@@ -279,10 +281,9 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	/* Setup DLL Output TAP delay */
 	otap_del_sel = sdhci_am654->otap_del_sel[timing];
-	otap_del_ena = (timing > MMC_TIMING_UHS_SDR25) ? 1 : 0;
 
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
-	val = (otap_del_ena << OTAPDLYENA_SHIFT) |
+	val = (0x1 << OTAPDLYENA_SHIFT) |
 	      (otap_del_sel << OTAPDLYSEL_SHIFT);
 
 	/* Write to STRBSEL for HS400 speed mode */
@@ -299,7 +300,8 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	if (timing > MMC_TIMING_UHS_SDR25 && clock >= CLOCK_TOO_SLOW_HZ) {
 		sdhci_am654_setup_dll(host, clock);
-		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing]);
+		sdhci_am654_write_itapdly(sdhci_am654, sdhci_am654->itap_del_sel[timing],
+					  sdhci_am654->itap_del_ena[timing]);
 		sdhci_am654->dll_enable = true;
 	} else {
 		sdhci_am654_setup_delay_chain(sdhci_am654, timing);
@@ -317,6 +319,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
 	unsigned char timing = host->mmc->ios.timing;
 	u32 otap_del_sel;
+	u32 itap_del_ena;
 	u32 mask, val;
 
 	/* Setup DLL Output TAP delay */
@@ -325,6 +328,12 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
 	val = (0x1 << OTAPDLYENA_SHIFT) |
 	      (otap_del_sel << OTAPDLYSEL_SHIFT);
+
+	itap_del_ena = sdhci_am654->itap_del_ena[timing];
+
+	mask |= ITAPDLYENA_MASK;
+	val |= (itap_del_ena << ITAPDLYENA_SHIFT);
+
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, mask, val);
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
@@ -484,12 +493,8 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
 	memset(fail_window, 0, sizeof(fail_window[0]) * ITAPDLY_LENGTH);
 
-	/* Enable ITAPDLY */
-	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPDLYENA_MASK,
-			   1 << ITAPDLYENA_SHIFT);
-
 	for (itap = 0; itap < ITAPDLY_LENGTH; itap++) {
-		sdhci_am654_write_itapdly(sdhci_am654, itap);
+		sdhci_am654_write_itapdly(sdhci_am654, itap, 1);
 
 		curr_pass = !mmc_send_tuning(host->mmc, opcode, NULL);
 
@@ -513,7 +518,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
 					  (sdhci_am654->dll_enable));
 
-	sdhci_am654_write_itapdly(sdhci_am654, itap);
+	sdhci_am654_write_itapdly(sdhci_am654, itap, 1);
 
 	return 0;
 }
@@ -662,9 +667,12 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host,
 				host->mmc->caps2 &= ~td[i].capability;
 		}
 
-		if (td[i].itap_binding)
-			device_property_read_u32(dev, td[i].itap_binding,
-						 &sdhci_am654->itap_del_sel[i]);
+		if (td[i].itap_binding) {
+			ret = device_property_read_u32(dev, td[i].itap_binding,
+						       &sdhci_am654->itap_del_sel[i]);
+			if (!ret)
+				sdhci_am654->itap_del_ena[i] = 0x1;
+		}
 	}
 
 	return 0;
Signature · 1 line
2.43.0
author maintainer
#14 lore raw

PATCH v2 4/7 mmc: sdhci_am654: Fix itapdly/otapdly array type

In reply to Judith Mendez

While integer type works, the otap_del_sel and itap_del_sel arrays are manipulated as u32, so change array types to u32.

Fixes 8ee5fc0e0b3b ("mmc: sdhci_am654: Update OTAPDLY writes")
Fixes a0a62497f6aa ("mmc: sdhci_am654: Add support for input tap delay")
---
 drivers/mmc/host/sdhci_am654.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +2 -2
index 935f581c05d8..35ba7d921690 100644
@@ -141,8 +141,8 @@ static const struct timing_data td[] = {
 
 struct sdhci_am654_data {
 	struct regmap *base;
-	int otap_del_sel[ARRAY_SIZE(td)];
-	int itap_del_sel[ARRAY_SIZE(td)];
+	u32 otap_del_sel[ARRAY_SIZE(td)];
+	u32 itap_del_sel[ARRAY_SIZE(td)];
 	u32 itap_del_ena[ARRAY_SIZE(td)];
 	int clkbuf_sel;
 	int trm_icp;
Signature · 1 line
2.43.0
maintainer
#15 lore raw

Re: [PATCH v2 4/7] mmc: sdhci_am654: Fix itapdly/otapdly array type

Quoted 2 lines · Judith Mendez

While integer type works, the otap_del_sel and itap_del_sel arrays are manipulated as u32, so change array types to u32.

If it doesn't make any practical difference, then it is not generally considered a "fix", at least according to stable kernel rules, so Fixes tags are probably not warranted here.

Quoted 23 lines
Fixes 8ee5fc0e0b3b ("mmc: sdhci_am654: Update OTAPDLY writes")
Fixes a0a62497f6aa ("mmc: sdhci_am654: Add support for input tap delay")
---
 drivers/mmc/host/sdhci_am654.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +2 -2
index 935f581c05d8..35ba7d921690 100644
@@ -141,8 +141,8 @@ static const struct timing_data td[] = {
 
 struct sdhci_am654_data {
 	struct regmap *base;
-	int otap_del_sel[ARRAY_SIZE(td)];
-	int itap_del_sel[ARRAY_SIZE(td)];
+	u32 otap_del_sel[ARRAY_SIZE(td)];
+	u32 itap_del_sel[ARRAY_SIZE(td)];
 	u32 itap_del_ena[ARRAY_SIZE(td)];
 	int clkbuf_sel;
 	int trm_icp;
author maintainer
#16 lore raw

Re: [PATCH v2 4/7] mmc: sdhci_am654: Fix itapdly/otapdly array type

Hi Adrian,

Quoted 7 lines · Adrian Hunter
Quoted 2 lines · Judith Mendez

While integer type works, the otap_del_sel and itap_del_sel arrays are manipulated as u32, so change array types to u32.

If it doesn't make any practical difference, then it is not generally considered a "fix", at least according to stable kernel rules, so Fixes tags are probably not warranted here.

Understood, will remove fixes tag here then, thanks.

Quoted 15 lines
Quoted 15 lines
Fixes 8ee5fc0e0b3b ("mmc: sdhci_am654: Update OTAPDLY writes")
Fixes a0a62497f6aa ("mmc: sdhci_am654: Add support for input tap delay")
---
  drivers/mmc/host/sdhci_am654.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +0 -0
index 935f581c05d8..35ba7d921690 100644
@@ -141,8 +141,8 @@ static const struct timing_data td[] = {
 
Quoted 10 lines

drivers/mmc/host/sdhci_am654.c static const struct timing_data td[] = { · line 148

Quoted 9 lines
drivers/mmc/host/sdhci_am654.c +2 -2
  struct sdhci_am654_data {
  	struct regmap *base;
-	int otap_del_sel[ARRAY_SIZE(td)];
-	int itap_del_sel[ARRAY_SIZE(td)];
+	u32 otap_del_sel[ARRAY_SIZE(td)];
+	u32 itap_del_sel[ARRAY_SIZE(td)];
  	u32 itap_del_ena[ARRAY_SIZE(td)];
  	int clkbuf_sel;
  	int trm_icp;

~ Judith

author maintainer
#17 lore raw

PATCH v2 5/7 mmc: sdhci_am654: Update comments in sdhci_am654_set_clock

In reply to Judith Mendez

The sdhci_am654_set_clock function is also used to enable delay chain, therefore fix comments to be more generic in case we are not enabling DLL.

Fixes fe52e2fbc6ef ("mmc: sdhci_am654: Fix conditions for enabling dll")
---
 drivers/mmc/host/sdhci_am654.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +2 -2
index 35ba7d921690..3755a015f328 100644
@@ -279,7 +279,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	sdhci_set_clock(host, clock);
 
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
 	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
@@ -322,7 +322,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	u32 itap_del_ena;
 	u32 mask, val;
 
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
 	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
Signature · 1 line
2.43.0
maintainer
#18 lore raw

Re: [PATCH v2 5/7] mmc: sdhci_am654: Update comments in sdhci_am654_set_clock

Quoted 5 lines · Judith Mendez

The sdhci_am654_set_clock function is also used to enable delay chain, therefore fix comments to be more generic in case we are not enabling DLL.

Fixes fe52e2fbc6ef ("mmc: sdhci_am654: Fix conditions for enabling dll")

Similar to patch 4, Fixes tag is probably not warranted.

Quoted 27 lines
---
 drivers/mmc/host/sdhci_am654.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +2 -2
index 35ba7d921690..3755a015f328 100644
@@ -279,7 +279,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	sdhci_set_clock(host, clock);
 
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
 	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
@@ -322,7 +322,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	u32 itap_del_ena;
 	u32 mask, val;
 
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
 	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
 	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
author maintainer
#19 lore raw

Re: [PATCH v2 5/7] mmc: sdhci_am654: Update comments in sdhci_am654_set_clock

Hi Adrian,

Quoted 8 lines · Adrian Hunter
Quoted 5 lines · Judith Mendez

The sdhci_am654_set_clock function is also used to enable delay chain, therefore fix comments to be more generic in case we are not enabling DLL.

Fixes fe52e2fbc6ef ("mmc: sdhci_am654: Fix conditions for enabling dll")

Similar to patch 4, Fixes tag is probably not warranted.

Will fix for V3, thanks.

Quoted 23 lines
Quoted 23 lines
---
  drivers/mmc/host/sdhci_am654.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +1 -1
index 35ba7d921690..3755a015f328 100644
@@ -279,7 +279,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
  	sdhci_set_clock(host, clock);
 
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
  	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
  	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
@@ -322,7 +322,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
  	u32 itap_del_ena;
  	u32 mask, val;
 
Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock) · line 285

Quoted 5 lines
drivers/mmc/host/sdhci_am654.c +1 -1
-	/* Setup DLL Output TAP delay */
+	/* Setup Output TAP delay */
  	otap_del_sel = sdhci_am654->otap_del_sel[timing];
 
  	mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;

~ Judith

author maintainer
#20 lore raw

PATCH v2 6/7 mmc: sdhci_am654: Add ITAPDLYSEL in sdhci_j721e_4bit_set_clock

In reply to Judith Mendez

Add ITAPDLYSEL to sdhci_j721e_4bit_set_clock function. This allows to set the correct ITAPDLY for timings that do not carry out tuning.

Fixes 1accbced1c32 ("mmc: sdhci_am654: Add Support for 4 bit IP on J721E")
---
 drivers/mmc/host/sdhci_am654.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci_am654.c +9 -2
index 3755a015f328..f98cce69a286 100644
@@ -320,6 +320,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	unsigned char timing = host->mmc->ios.timing;
 	u32 otap_del_sel;
 	u32 itap_del_ena;
+	u32 itap_del_sel;
 	u32 mask, val;
 
 	/* Setup Output TAP delay */
@@ -329,12 +330,18 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	val = (0x1 << OTAPDLYENA_SHIFT) |
 	      (otap_del_sel << OTAPDLYSEL_SHIFT);
 
+	/* Setup Input TAP delay */
 	itap_del_ena = sdhci_am654->itap_del_ena[timing];
+	itap_del_sel = sdhci_am654->itap_del_sel[timing];
 
-	mask |= ITAPDLYENA_MASK;
-	val |= (itap_del_ena << ITAPDLYENA_SHIFT);
+	mask |= ITAPDLYENA_MASK | ITAPDLYSEL_MASK;
+	val |= (itap_del_ena << ITAPDLYENA_SHIFT) |
+	       (itap_del_sel << ITAPDLYSEL_SHIFT);
 
+	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPCHGWIN_MASK,
+			   1 << ITAPCHGWIN_SHIFT);
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, mask, val);
+	regmap_update_bits(sdhci_am654->base, PHY_CTRL4, ITAPCHGWIN_MASK, 0);
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
 			   sdhci_am654->clkbuf_sel);
Signature · 1 line
2.43.0
author maintainer
#21 lore raw

PATCH v2 7/7 mmc: sdhci_am654: Fix ITAPDLY for HS400 timing

In reply to Judith Mendez

While STRB is currently used for DATA and CRC responses, the CMD responses from the device to the host still require ITAPDLY for HS400 timing.

Currently what is stored for HS400 is the ITAPDLY from High Speed mode which is incorrect. The ITAPDLY for HS400 speed mode should be the same as ITAPDLY as HS200 timing after tuning is executed. Add the functionality to save ITAPDLY from HS200 tuning and save as HS400 ITAPDLY.

Fixes a161c45f2979 ("mmc: sdhci_am654: Enable DLL only for some speed modes")
---
 drivers/mmc/host/sdhci_am654.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/sdhci_am654.c +13 -0
index f98cce69a286..280fd4c86c95 100644
@@ -151,6 +151,7 @@ struct sdhci_am654_data {
 	u32 flags;
 	u32 quirks;
 	bool dll_enable;
+	bool hs200_tunning;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
 };
@@ -175,6 +176,7 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
+	unsigned char timing = host->mmc->ios.timing;
 	int sel50, sel100, freqsel;
 	u32 mask, val;
 	int ret;
@@ -237,6 +239,10 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock)
 		dev_err(mmc_dev(host->mmc), "DLL failed to relock\n");
 		return;
 	}
+
+	/* HS400 ITAPDLY should be the same as HS200 ITAPDLY*/
+	if (timing == MMC_TIMING_MMC_HS400)
+		sdhci_am654->itap_del_sel[timing] = sdhci_am654->itap_del_sel[timing - 1];
 }
 
 static void sdhci_am654_write_itapdly(struct sdhci_am654_data *sdhci_am654,
@@ -310,6 +316,9 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
 			   sdhci_am654->clkbuf_sel);
+
+	if (timing == MMC_TIMING_MMC_HS200 && sdhci_am654->dll_enable)
+		sdhci_am654->hs200_tunning = true;
 }
 
 static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
@@ -527,6 +536,10 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
 	sdhci_am654_write_itapdly(sdhci_am654, itap, 1);
 
+	/* Save ITAPDLY for HS200 */
+	if (sdhci_am654->hs200_tunning)
+		sdhci_am654->itap_del_sel[MMC_TIMING_MMC_HS200] = itap;
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
#22 lore raw
In reply to Judith Mendez
Quoted 6 lines · Judith Mendez

This patch series introduces a new tuning algorithm for mmc. The new algorithm should be used when delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer. The new tuning algorithm is implemented as per the paper published here [0] and has been tested on the following

Where is this [0]?

Quoted 2 lines

platforms: AM62x SK, AM62A SK, AM62p SK, AM64x SK, and AM64x EVM.

In the other patches you link some document, but I was not able to find anything related to AM62, can you provide some reference on this specific SOC?

Francesco

author maintainer
#23 lore raw

Hi Francesco,

Quoted 9 lines · Francesco Dolcini
Quoted 6 lines · Judith Mendez

This patch series introduces a new tuning algorithm for mmc. The new algorithm should be used when delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer. The new tuning algorithm is implemented as per the paper published here [0] and has been tested on the following

Where is this [0]?

I must have missed linking the ref doc here, will add in next iteration, thanks.

Quoted 7 lines
Quoted 3 lines

platforms: AM62x SK, AM62A SK, AM62p SK, AM64x SK, and AM64x EVM.

In the other patches you link some document, but I was not able to find anything related to AM62, can you provide some reference on this specific SOC?

This patch series fixes issues that affect all Sitara SoCs, not only AM62x. However, I could use AM62x for reference, no problem.

Quoted 3 lines

Francesco

~ Judith

#24 lore raw

Hi Judith,

Quoted 20 lines · Judith Mendez

Hi Francesco,

Quoted 9 lines · Francesco Dolcini
Quoted 6 lines · Judith Mendez

This patch series introduces a new tuning algorithm for mmc. The new algorithm should be used when delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer. The new tuning algorithm is implemented as per the paper published here [0] and has been tested on the following

Where is this [0]?

I must have missed linking the ref doc here, will add in next iteration, thanks.

Quoted 4 lines
Quoted 3 lines

platforms: AM62x SK, AM62A SK, AM62p SK, AM64x SK, and AM64x EVM.

Quoted 6 lines
Quoted 3 lines

In the other patches you link some document, but I was not able to find anything related to AM62, can you provide some reference on this specific SOC?

This patch series fixes issues that affect all Sitara SoCs, not only AM62x. However, I could use AM62x for reference, no problem.

I am really looking for documentation here that is related to the AM62 because I was not able to find anything and this is a topic of interest for me.

Can you share something?

Francesco

author maintainer
#25 lore raw

Hi Francesco,

Quoted 27 lines · Francesco Dolcini

Hi Judith,

Quoted 24 lines · Judith Mendez

Hi Francesco,

Quoted 9 lines · Francesco Dolcini
Quoted 6 lines · Judith Mendez

This patch series introduces a new tuning algorithm for mmc. The new algorithm should be used when delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer. The new tuning algorithm is implemented as per the paper published here [0] and has been tested on the following

Where is this [0]?

I must have missed linking the ref doc here, will add in next iteration, thanks.

Quoted 7 lines
Quoted 3 lines

platforms: AM62x SK, AM62A SK, AM62p SK, AM64x SK, and AM64x EVM.

In the other patches you link some document, but I was not able to find anything related to AM62, can you provide some reference on this specific SOC?

Quoted 7 lines
Quoted 2 lines

This patch series fixes issues that affect all Sitara SoCs, not only AM62x. However, I could use AM62x for reference, no problem.

I am really looking for documentation here that is related to the AM62 because I was not able to find anything and this is a topic of interest for me.

The AM62x device datasheet: https://www.ti.com/lit/ds/symlink/am625.pdf,
reference Table 7-79 for MMC0 and Table 7-97 for MMC1.

TRM, reference section 12.4.5 for MMCSD and section 12.4.5.5.2.3.2 Tuning Sequence that we currently implement in the sdhci_am654 driver. Section 14.8.4.6 for MMCSD registers, SS_CFG_PHY_CTRL_1, SS_CFG_PHY_CTRL_5, and SS_CFG_PHY_CTRL_5 are usually of higher interest.

Tuning algorithm, reference: https://www.ti.com/lit/an/spract9/spract9.pdf which is applicable for AM62x, DLL is not applicable for AM62x, so the tuning algorithm should not consider the buffer
as a circular buffer.

~ Judith

Quoted 4 lines

Can you share something?

Francesco