* [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning()
@ 2026-05-19 14:15 Sascha Hauer
2026-05-19 14:15 ` [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing Sascha Hauer
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sascha Hauer @ 2026-05-19 14:15 UTC (permalink / raw)
To: Barebox List; +Cc: Sascha Hauer
From: Sascha Hauer <sascha@saschahauer.de>
sdhci->tuning_err is set but never used. Drop it and return the tuning
error directly from sdhci_execute_tuning(). With this we can actually
return tuning errors instead of silently ignoring them.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mci/sdhci.c | 2 +-
drivers/mci/sdhci.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index f7172347e1..1b13df8583 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -353,7 +353,7 @@ int sdhci_execute_tuning(struct sdhci *sdhci, u32 opcode)
sdhci_start_tuning(sdhci);
- sdhci->tuning_err = __sdhci_execute_tuning(sdhci, opcode);
+ err = __sdhci_execute_tuning(sdhci, opcode);
sdhci_end_tuning(sdhci);
out:
diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
index 8d21febd7a..4a326f9d84 100644
--- a/drivers/mci/sdhci.h
+++ b/drivers/mci/sdhci.h
@@ -280,7 +280,6 @@ struct sdhci {
unsigned int tuning_count; /* Timer count for re-tuning */
unsigned int tuning_mode; /* Re-tuning mode supported by host */
- unsigned int tuning_err; /* Error code for re-tuning */
#define SDHCI_TUNING_MODE_1 0
#define SDHCI_TUNING_MODE_2 1
#define SDHCI_TUNING_MODE_3 2
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing
2026-05-19 14:15 [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Sascha Hauer
@ 2026-05-19 14:15 ` Sascha Hauer
2026-05-19 14:26 ` Ahmad Fatoum
2026-05-19 14:25 ` [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Ahmad Fatoum
2026-05-19 14:35 ` Sascha Hauer
2 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2026-05-19 14:15 UTC (permalink / raw)
To: Barebox List; +Cc: Sascha Hauer
From: Sascha Hauer <sascha@saschahauer.de>
tuning_count and tuning_mode are populated from the host's
CAPABILITIES_1 register at probe time but never consumed. In Linux
they feed an automatic re-tuning timer that periodically re-runs
tuning every N seconds after the controller's re-tuning timer (mode 1)
expires. barebox is a bootloader - tuning runs once at probe and the
controller is then handed to the OS - so the timer infrastructure
doesn't exist and the fields are dead weight.
Drop:
- tuning_count / tuning_mode struct members
- SDHCI_TUNING_MODE_1/2/3 defines
- SDHCI_RETUNING_TIMER_COUNT_MASK / SDHCI_RETUNING_MODE_MASK
- the dead read into a local tuning_count in sdhci_execute_tuning()
- the populate block in sdhci_setup_host()
No behavioural change.
Assisted-By: Claude Opus 4.7
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mci/sdhci.c | 18 ------------------
drivers/mci/sdhci.h | 7 -------
2 files changed, 25 deletions(-)
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 1b13df8583..861e5c7862 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -311,10 +311,6 @@ int sdhci_execute_tuning(struct sdhci *sdhci, u32 opcode)
{
struct mci_host *host = sdhci->mci;
int err = 0;
- unsigned int tuning_count = 0;
-
- if (sdhci->tuning_mode == SDHCI_TUNING_MODE_1)
- tuning_count = sdhci->tuning_count;
/*
* The Host Controller needs tuning in case of SDR104 and DDR50
@@ -1197,19 +1193,5 @@ int sdhci_setup_host(struct sdhci *host)
host->tuning_delay = -1;
host->tuning_loop_count = MAX_TUNING_LOOP;
- /* Initial value for re-tuning timer count */
- host->tuning_count = FIELD_GET(SDHCI_RETUNING_TIMER_COUNT_MASK,
- host->caps1);
-
- /*
- * In case Re-tuning Timer is not disabled, the actual value of
- * re-tuning timer will be 2 ^ (n - 1).
- */
- if (host->tuning_count)
- host->tuning_count = 1 << (host->tuning_count - 1);
-
- /* Re-tuning mode supported by the Host Controller */
- host->tuning_mode = FIELD_GET(SDHCI_RETUNING_MODE_MASK, host->caps1);
-
return 0;
}
diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
index 4a326f9d84..3c678d7999 100644
--- a/drivers/mci/sdhci.h
+++ b/drivers/mci/sdhci.h
@@ -175,9 +175,7 @@
#define SDHCI_DRIVER_TYPE_A 0x00000010
#define SDHCI_DRIVER_TYPE_C 0x00000020
#define SDHCI_DRIVER_TYPE_D 0x00000040
-#define SDHCI_RETUNING_TIMER_COUNT_MASK GENMASK(11, 8)
#define SDHCI_USE_SDR50_TUNING 0x00002000
-#define SDHCI_RETUNING_MODE_MASK GENMASK(15, 14)
#define SDHCI_CLOCK_MUL_MASK GENMASK(23, 16)
#define SDHCI_CAN_DO_ADMA3 0x08000000
#define SDHCI_SUPPORT_HS400 0x80000000 /* Non-standard */
@@ -278,11 +276,6 @@ struct sdhci {
bool read_caps; /* Capability flags have been read */
u32 sdma_boundary;
- unsigned int tuning_count; /* Timer count for re-tuning */
- unsigned int tuning_mode; /* Re-tuning mode supported by host */
-#define SDHCI_TUNING_MODE_1 0
-#define SDHCI_TUNING_MODE_2 1
-#define SDHCI_TUNING_MODE_3 2
/* Delay (ms) between tuning commands */
int tuning_delay;
int tuning_loop_count;
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning()
2026-05-19 14:15 [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Sascha Hauer
2026-05-19 14:15 ` [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing Sascha Hauer
@ 2026-05-19 14:25 ` Ahmad Fatoum
2026-05-19 14:35 ` Sascha Hauer
2 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2026-05-19 14:25 UTC (permalink / raw)
To: Sascha Hauer, Barebox List; +Cc: Sascha Hauer
On 5/19/26 4:15 PM, Sascha Hauer wrote:
> From: Sascha Hauer <sascha@saschahauer.de>
>
> sdhci->tuning_err is set but never used. Drop it and return the tuning
> error directly from sdhci_execute_tuning(). With this we can actually
> return tuning errors instead of silently ignoring them.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/mci/sdhci.c | 2 +-
> drivers/mci/sdhci.h | 1 -
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
> index f7172347e1..1b13df8583 100644
> --- a/drivers/mci/sdhci.c
> +++ b/drivers/mci/sdhci.c
> @@ -353,7 +353,7 @@ int sdhci_execute_tuning(struct sdhci *sdhci, u32 opcode)
>
> sdhci_start_tuning(sdhci);
>
> - sdhci->tuning_err = __sdhci_execute_tuning(sdhci, opcode);
> + err = __sdhci_execute_tuning(sdhci, opcode);
>
> sdhci_end_tuning(sdhci);
> out:
> diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
> index 8d21febd7a..4a326f9d84 100644
> --- a/drivers/mci/sdhci.h
> +++ b/drivers/mci/sdhci.h
> @@ -280,7 +280,6 @@ struct sdhci {
>
> unsigned int tuning_count; /* Timer count for re-tuning */
> unsigned int tuning_mode; /* Re-tuning mode supported by host */
> - unsigned int tuning_err; /* Error code for re-tuning */
> #define SDHCI_TUNING_MODE_1 0
> #define SDHCI_TUNING_MODE_2 1
> #define SDHCI_TUNING_MODE_3 2
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing
2026-05-19 14:15 ` [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing Sascha Hauer
@ 2026-05-19 14:26 ` Ahmad Fatoum
0 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2026-05-19 14:26 UTC (permalink / raw)
To: Sascha Hauer, Barebox List; +Cc: Sascha Hauer
On 5/19/26 4:15 PM, Sascha Hauer wrote:
> From: Sascha Hauer <sascha@saschahauer.de>
>
> tuning_count and tuning_mode are populated from the host's
> CAPABILITIES_1 register at probe time but never consumed. In Linux
> they feed an automatic re-tuning timer that periodically re-runs
> tuning every N seconds after the controller's re-tuning timer (mode 1)
> expires. barebox is a bootloader - tuning runs once at probe and the
> controller is then handed to the OS - so the timer infrastructure
> doesn't exist and the fields are dead weight.
>
> Drop:
> - tuning_count / tuning_mode struct members
> - SDHCI_TUNING_MODE_1/2/3 defines
> - SDHCI_RETUNING_TIMER_COUNT_MASK / SDHCI_RETUNING_MODE_MASK
> - the dead read into a local tuning_count in sdhci_execute_tuning()
> - the populate block in sdhci_setup_host()
>
> No behavioural change.
>
> Assisted-By: Claude Opus 4.7
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/mci/sdhci.c | 18 ------------------
> drivers/mci/sdhci.h | 7 -------
> 2 files changed, 25 deletions(-)
>
> diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
> index 1b13df8583..861e5c7862 100644
> --- a/drivers/mci/sdhci.c
> +++ b/drivers/mci/sdhci.c
> @@ -311,10 +311,6 @@ int sdhci_execute_tuning(struct sdhci *sdhci, u32 opcode)
> {
> struct mci_host *host = sdhci->mci;
> int err = 0;
> - unsigned int tuning_count = 0;
> -
> - if (sdhci->tuning_mode == SDHCI_TUNING_MODE_1)
> - tuning_count = sdhci->tuning_count;
>
> /*
> * The Host Controller needs tuning in case of SDR104 and DDR50
> @@ -1197,19 +1193,5 @@ int sdhci_setup_host(struct sdhci *host)
> host->tuning_delay = -1;
> host->tuning_loop_count = MAX_TUNING_LOOP;
>
> - /* Initial value for re-tuning timer count */
> - host->tuning_count = FIELD_GET(SDHCI_RETUNING_TIMER_COUNT_MASK,
> - host->caps1);
> -
> - /*
> - * In case Re-tuning Timer is not disabled, the actual value of
> - * re-tuning timer will be 2 ^ (n - 1).
> - */
> - if (host->tuning_count)
> - host->tuning_count = 1 << (host->tuning_count - 1);
> -
> - /* Re-tuning mode supported by the Host Controller */
> - host->tuning_mode = FIELD_GET(SDHCI_RETUNING_MODE_MASK, host->caps1);
> -
> return 0;
> }
> diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
> index 4a326f9d84..3c678d7999 100644
> --- a/drivers/mci/sdhci.h
> +++ b/drivers/mci/sdhci.h
> @@ -175,9 +175,7 @@
> #define SDHCI_DRIVER_TYPE_A 0x00000010
> #define SDHCI_DRIVER_TYPE_C 0x00000020
> #define SDHCI_DRIVER_TYPE_D 0x00000040
> -#define SDHCI_RETUNING_TIMER_COUNT_MASK GENMASK(11, 8)
> #define SDHCI_USE_SDR50_TUNING 0x00002000
> -#define SDHCI_RETUNING_MODE_MASK GENMASK(15, 14)
> #define SDHCI_CLOCK_MUL_MASK GENMASK(23, 16)
> #define SDHCI_CAN_DO_ADMA3 0x08000000
> #define SDHCI_SUPPORT_HS400 0x80000000 /* Non-standard */
> @@ -278,11 +276,6 @@ struct sdhci {
> bool read_caps; /* Capability flags have been read */
> u32 sdma_boundary;
>
> - unsigned int tuning_count; /* Timer count for re-tuning */
> - unsigned int tuning_mode; /* Re-tuning mode supported by host */
> -#define SDHCI_TUNING_MODE_1 0
> -#define SDHCI_TUNING_MODE_2 1
> -#define SDHCI_TUNING_MODE_3 2
> /* Delay (ms) between tuning commands */
> int tuning_delay;
> int tuning_loop_count;
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning()
2026-05-19 14:15 [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Sascha Hauer
2026-05-19 14:15 ` [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing Sascha Hauer
2026-05-19 14:25 ` [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Ahmad Fatoum
@ 2026-05-19 14:35 ` Sascha Hauer
2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2026-05-19 14:35 UTC (permalink / raw)
To: Barebox List, Sascha Hauer; +Cc: Sascha Hauer
On Tue, 19 May 2026 16:15:00 +0200, Sascha Hauer wrote:
> sdhci->tuning_err is set but never used. Drop it and return the tuning
> error directly from sdhci_execute_tuning(). With this we can actually
> return tuning errors instead of silently ignoring them.
>
>
Applied, thanks!
[1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning()
https://git.pengutronix.de/cgit/barebox/commit/?id=85995b4d5475 (link may not be stable)
[2/2] mci: sdhci: drop unused re-tuning timer plumbing
https://git.pengutronix.de/cgit/barebox/commit/?id=e8e06fc1608a (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-19 15:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-19 14:15 [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Sascha Hauer
2026-05-19 14:15 ` [PATCH 2/2] mci: sdhci: drop unused re-tuning timer plumbing Sascha Hauer
2026-05-19 14:26 ` Ahmad Fatoum
2026-05-19 14:25 ` [PATCH 1/2] mci: sdhci: propagate tuning failures from sdhci_execute_tuning() Ahmad Fatoum
2026-05-19 14:35 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox