* [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support
@ 2020-02-12 14:14 Ahmad Fatoum
2020-02-12 14:14 ` [PATCH 2/2] mci: core: populate mci_ios.timing member Ahmad Fatoum
2020-02-14 7:47 ` [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-02-12 14:14 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The SDMMC2 doesn't need any special setup for High-Speed modes, except
for the clock changes. Thus set the cap flags if the max clock would
allow for the higher speed mode.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mci/stm32_sdmmc2.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mci/stm32_sdmmc2.c b/drivers/mci/stm32_sdmmc2.c
index 695e61d1ccd7..0c26869b0378 100644
--- a/drivers/mci/stm32_sdmmc2.c
+++ b/drivers/mci/stm32_sdmmc2.c
@@ -631,6 +631,11 @@ static int stm32_sdmmc2_probe(struct amba_device *adev,
mci_of_parse(&priv->mci);
+ if (mci->f_max >= 26000000)
+ mci->host_caps |= MMC_CAP_MMC_HIGHSPEED;
+ if (mci->f_max >= 52000000)
+ mci->host_caps |= MMC_CAP_MMC_HIGHSPEED_52MHZ;
+
return mci_register(&priv->mci);
priv_free:
--
2.25.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] mci: core: populate mci_ios.timing member
2020-02-12 14:14 [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Ahmad Fatoum
@ 2020-02-12 14:14 ` Ahmad Fatoum
2020-02-14 7:47 ` [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-02-12 14:14 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
So far we passed an uninitialized timing member in the ios to the
->set_ios of the host controller drivers.
To allow extension for new modes that need MCI host support beyond
the usual clock rate change, make the member useful:
- populate is with the correct value
- add some type safety by using an enum
- print it in the devinfo output
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mci/mci-core.c | 29 +++++++++++++++++++++++++----
include/mci.h | 25 ++++++++++++++-----------
2 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index dd163c3d1652..e5b5e8a27539 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -668,10 +668,11 @@ retry_scr:
static void mci_set_ios(struct mci *mci)
{
struct mci_host *host = mci->host;
- struct mci_ios ios;
-
- ios.bus_width = host->bus_width;
- ios.clock = host->clock;
+ struct mci_ios ios = {
+ .bus_width = host->bus_width,
+ .clock = host->clock,
+ .timing = host->timing,
+ };
host->set_ios(host, &ios);
}
@@ -996,6 +997,9 @@ static int mci_startup_sd(struct mci *mci)
mci_set_bus_width(mci, MMC_BUS_WIDTH_4);
}
+ if (mci->tran_speed > 25000000)
+ mci->host->timing = MMC_TIMING_SD_HS;
+
mci_set_clock(mci, mci->tran_speed);
return 0;
@@ -1021,6 +1025,8 @@ static int mci_startup_mmc(struct mci *mci)
mci->tran_speed = 52000000;
else
mci->tran_speed = 26000000;
+
+ host->timing = MMC_TIMING_MMC_HS;
}
mci_set_clock(mci, mci->tran_speed);
@@ -1473,6 +1479,20 @@ static unsigned extract_mtd_year(struct mci *mci)
return year;
}
+static const char *mci_timing_tostr(unsigned timing)
+{
+ switch (timing) {
+ case MMC_TIMING_LEGACY:
+ return "legacy";
+ case MMC_TIMING_MMC_HS:
+ return "MMC HS";
+ case MMC_TIMING_SD_HS:
+ return "SD HS";
+ default:
+ return "unknown"; /* shouldn't happen */
+ }
+}
+
static void mci_print_caps(unsigned caps)
{
printf(" capabilities: %s%s%s%s%s\n",
@@ -1509,6 +1529,7 @@ static void mci_info(struct device_d *dev)
bw = 1;
printf(" current buswidth: %d\n", bw);
+ printf(" current timing: %s\n", mci_timing_tostr(host->timing));
mci_print_caps(host->host_caps);
printf("Card information:\n");
diff --git a/include/mci.h b/include/mci.h
index a45d744761a2..57a4629d1293 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -367,6 +367,18 @@ struct mci_data {
unsigned blocksize; /**< block size in bytes (mostly 512) */
};
+enum mci_timing {
+ MMC_TIMING_LEGACY = 0,
+ MMC_TIMING_MMC_HS = 1,
+ MMC_TIMING_SD_HS = 2,
+ MMC_TIMING_UHS_SDR12 = MMC_TIMING_LEGACY,
+ MMC_TIMING_UHS_SDR25 = MMC_TIMING_SD_HS,
+ MMC_TIMING_UHS_SDR50 = 3,
+ MMC_TIMING_UHS_SDR104 = 4,
+ MMC_TIMING_UHS_DDR50 = 5,
+ MMC_TIMING_MMC_HS200 = 6,
+};
+
struct mci_ios {
unsigned int clock; /* clock rate */
@@ -376,17 +388,7 @@ struct mci_ios {
#define MMC_BUS_WIDTH_4 2
#define MMC_BUS_WIDTH_8 3
- unsigned char timing; /* timing specification used */
-
-#define MMC_TIMING_LEGACY 0
-#define MMC_TIMING_MMC_HS 1
-#define MMC_TIMING_SD_HS 2
-#define MMC_TIMING_UHS_SDR12 MMC_TIMING_LEGACY
-#define MMC_TIMING_UHS_SDR25 MMC_TIMING_SD_HS
-#define MMC_TIMING_UHS_SDR50 3
-#define MMC_TIMING_UHS_SDR104 4
-#define MMC_TIMING_UHS_DDR50 5
-#define MMC_TIMING_MMC_HS200 6
+ enum mci_timing timing; /* timing specification used */
#define MMC_SDR_MODE 0
#define MMC_1_2V_DDR_MODE 1
@@ -408,6 +410,7 @@ struct mci_host {
unsigned f_max; /**< host interface upper limit */
unsigned clock; /**< Current clock used to talk to the card */
unsigned bus_width; /**< used data bus width to the card */
+ enum mci_timing timing; /**< used timing specification to the card */
unsigned max_req_size;
unsigned dsr_val; /**< optional dsr value */
int use_dsr; /**< optional dsr usage flag */
--
2.25.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support
2020-02-12 14:14 [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Ahmad Fatoum
2020-02-12 14:14 ` [PATCH 2/2] mci: core: populate mci_ios.timing member Ahmad Fatoum
@ 2020-02-14 7:47 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-02-14 7:47 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Feb 12, 2020 at 03:14:29PM +0100, Ahmad Fatoum wrote:
> The SDMMC2 doesn't need any special setup for High-Speed modes, except
> for the clock changes. Thus set the cap flags if the max clock would
> allow for the higher speed mode.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/mci/stm32_sdmmc2.c | 5 +++++
> 1 file changed, 5 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/drivers/mci/stm32_sdmmc2.c b/drivers/mci/stm32_sdmmc2.c
> index 695e61d1ccd7..0c26869b0378 100644
> --- a/drivers/mci/stm32_sdmmc2.c
> +++ b/drivers/mci/stm32_sdmmc2.c
> @@ -631,6 +631,11 @@ static int stm32_sdmmc2_probe(struct amba_device *adev,
>
> mci_of_parse(&priv->mci);
>
> + if (mci->f_max >= 26000000)
> + mci->host_caps |= MMC_CAP_MMC_HIGHSPEED;
> + if (mci->f_max >= 52000000)
> + mci->host_caps |= MMC_CAP_MMC_HIGHSPEED_52MHZ;
> +
> return mci_register(&priv->mci);
>
> priv_free:
> --
> 2.25.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-14 7:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12 14:14 [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Ahmad Fatoum
2020-02-12 14:14 ` [PATCH 2/2] mci: core: populate mci_ios.timing member Ahmad Fatoum
2020-02-14 7:47 ` [PATCH 1/2] mci: stm32_sdmmc2: add High-Speed (26 & 52 MHz) support Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox