* [PATCH 1/4] mci: add DSR support
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
@ 2014-01-14 8:23 ` Markus Niebel
2014-01-14 8:23 ` [PATCH 2/4] mci: add device tree support for DSR Markus Niebel
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Markus Niebel @ 2014-01-14 8:23 UTC (permalink / raw)
To: barebox; +Cc: Markus Niebel
From: Markus Niebel <Markus.Niebel@tqs.de>
The eMMC and the SD-Card specifications describe the optional SET_DSR command.
During measurements at our lab we found that some cards implementing this feature
having really strong driver strengts per default. This can lead to voltage peaks
above the specification of the host on signal edges for data sent from a card to
the host.
Since availability of a given card type may be shorter than the time a certain
hardware will be produced it is useful to have support for this command (Alternative
would be changing termination resistors and adapting the driver strength of the
host to the used card.)
Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
drivers/mci/mci-core.c | 27 +++++++++++++++++++++++++++
include/mci.h | 3 +++
2 files changed, 30 insertions(+)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index a232679..2c91ff2 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -102,6 +102,20 @@ static void mci_setup_cmd(struct mci_cmd *p, unsigned cmd, unsigned arg, unsigne
}
/**
+ * configure optional DSR value
+ * @param mci_dev MCI instance
+ * @return Transaction status (0 on success)
+ */
+static int mci_set_dsr(struct mci *mci)
+{
+ struct mci_cmd cmd;
+
+ mci_setup_cmd(&cmd, MMC_CMD_SET_DSR,
+ (mci->host->dsr_val >> 16) | 0xffff, MMC_RSP_NONE);
+ return mci_send_cmd(mci, &cmd, NULL);
+}
+
+/**
* Setup SD/MMC card's blocklength to be used for future transmitts
* @param mci_dev MCI instance
* @param len Blocklength in bytes
@@ -836,6 +850,15 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
dev_dbg(&mci->dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
}
+/**
+ * Extract card's DSR implementation state from CSD
+ * @param mci MCI instance
+ */
+static void mci_extract_card_dsr_imp_from_csd(struct mci *mci)
+{
+ mci->dsr_imp = UNSTUFF_BITS(mci->csd, 76, 1);
+}
+
static int mmc_compare_ext_csds(struct mci *mci, unsigned bus_width)
{
u8 *bw_ext_csd;
@@ -1058,6 +1081,7 @@ static int mci_startup(struct mci *mci)
mci_detect_version_from_csd(mci);
mci_extract_max_tran_speed_from_csd(mci);
mci_extract_block_lengths_from_csd(mci);
+ mci_extract_card_dsr_imp_from_csd(mci);
/* sanitiy? */
if (mci->read_bl_len > SECTOR_SIZE) {
@@ -1074,6 +1098,9 @@ static int mci_startup(struct mci *mci)
dev_dbg(&mci->dev, "Read block length: %u, Write block length: %u\n",
mci->read_bl_len, mci->write_bl_len);
+ if (mci->dsr_imp && mci->host->use_dsr)
+ mci_set_dsr(mci);
+
if (!mmc_host_is_spi(host)) { /* cmd not supported in spi */
dev_dbg(&mci->dev, "Select the card, and put it into Transfer Mode\n");
/* Select the card, and put it into Transfer Mode */
diff --git a/include/mci.h b/include/mci.h
index 0f10e8a..d3a553e 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -294,6 +294,8 @@ struct mci_host {
unsigned clock; /**< Current clock used to talk to the card */
unsigned bus_width; /**< used data bus width to the card */
unsigned max_req_size;
+ unsigned dsr_val; /**< optional dsr value */
+ int use_dsr; /**< optional dsr usage flag */
/** init the host interface */
int (*init)(struct mci_host*, struct device_d*);
@@ -344,6 +346,7 @@ struct mci {
unsigned write_bl_len;
uint64_t capacity; /**< Card's data capacity in bytes */
int ready_for_use; /** true if already probed */
+ int dsr_imp; /**< DSR implementation state from CSD */
char *ext_csd;
int probe;
struct param_d *param_probe;
--
1.7.9.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/4] mci: add device tree support for DSR
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
2014-01-14 8:23 ` [PATCH 1/4] mci: add DSR support Markus Niebel
@ 2014-01-14 8:23 ` Markus Niebel
2014-01-14 8:23 ` [PATCH 3/4] mci: imx-esdhc: add DSR support Markus Niebel
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Markus Niebel @ 2014-01-14 8:23 UTC (permalink / raw)
To: barebox; +Cc: Markus Niebel
From: Markus Niebel <Markus.Niebel@tqs.de>
add optional DSR support. This should go into the kernel, too
Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
drivers/mci/mci-core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 2c91ff2..b6d7d73 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1746,6 +1746,7 @@ void mci_of_parse(struct mci_host *host)
{
struct device_node *np;
u32 bus_width;
+ u32 dsr_val;
if (!IS_ENABLED(CONFIG_OFDEVICE))
return;
@@ -1778,4 +1779,11 @@ void mci_of_parse(struct mci_host *host)
/* f_max is obtained from the optional "max-frequency" property */
of_property_read_u32(np, "max-frequency", &host->f_max);
+
+ if (!of_property_read_u32(np, "dsr", &dsr_val)) {
+ if (dsr_val < 0x10000) {
+ host->use_dsr = 1;
+ host->dsr_val = dsr_val;
+ }
+ }
}
--
1.7.9.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] mci: imx-esdhc: add DSR support
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
2014-01-14 8:23 ` [PATCH 1/4] mci: add DSR support Markus Niebel
2014-01-14 8:23 ` [PATCH 2/4] mci: add device tree support for DSR Markus Niebel
@ 2014-01-14 8:23 ` Markus Niebel
2014-01-14 8:49 ` Alexander Aring
2014-01-14 8:23 ` [PATCH 4/4] boards: tqma53: add DSR support for eMMC Markus Niebel
2014-01-15 14:23 ` [PATCH v2 0/4] mmc: add setdsr support Sascha Hauer
4 siblings, 1 reply; 8+ messages in thread
From: Markus Niebel @ 2014-01-14 8:23 UTC (permalink / raw)
To: barebox; +Cc: Markus Niebel
From: Markus Niebel <Markus.Niebel@tqs.de>
having DSR support in mci-core we need a way to
forward the DSR value to the driver. Add it to
platform data for imx-esdhc
TODO: implement the same for other host controller
drivers
Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
arch/arm/mach-imx/include/mach/esdhc.h | 2 ++
drivers/mci/imx-esdhc.c | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/arch/arm/mach-imx/include/mach/esdhc.h b/arch/arm/mach-imx/include/mach/esdhc.h
index add1691..fb7380a 100644
--- a/arch/arm/mach-imx/include/mach/esdhc.h
+++ b/arch/arm/mach-imx/include/mach/esdhc.h
@@ -42,5 +42,7 @@ struct esdhc_platform_data {
enum cd_types cd_type;
unsigned caps;
char *devname;
+ unsigned dsr_val;
+ int use_dsr;
};
#endif /* __ASM_ARCH_IMX_ESDHC_H */
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 7664e7b..4c7a45e 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -582,6 +582,10 @@ static int fsl_esdhc_probe(struct device_d *dev)
if (host->mci.f_min < 200000)
host->mci.f_min = 200000;
host->mci.f_max = rate;
+ if (pdata) {
+ host->mci.use_dsr = pdata->use_dsr;
+ host->mci.dsr_val = pdata->dsr_val;
+ }
mci_of_parse(&host->mci);
--
1.7.9.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/4] mci: imx-esdhc: add DSR support
2014-01-14 8:23 ` [PATCH 3/4] mci: imx-esdhc: add DSR support Markus Niebel
@ 2014-01-14 8:49 ` Alexander Aring
2014-01-14 14:26 ` AW: " Markus Niebel
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Aring @ 2014-01-14 8:49 UTC (permalink / raw)
To: Markus Niebel; +Cc: barebox, Markus Niebel
Hi,
On Tue, Jan 14, 2014 at 09:23:36AM +0100, Markus Niebel wrote:
> From: Markus Niebel <Markus.Niebel@tqs.de>
>
> having DSR support in mci-core we need a way to
> forward the DSR value to the driver. Add it to
> platform data for imx-esdhc
>
> TODO: implement the same for other host controller
> drivers
>
> Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
> ---
> arch/arm/mach-imx/include/mach/esdhc.h | 2 ++
> drivers/mci/imx-esdhc.c | 4 ++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/arch/arm/mach-imx/include/mach/esdhc.h b/arch/arm/mach-imx/include/mach/esdhc.h
> index add1691..fb7380a 100644
> --- a/arch/arm/mach-imx/include/mach/esdhc.h
> +++ b/arch/arm/mach-imx/include/mach/esdhc.h
> @@ -42,5 +42,7 @@ struct esdhc_platform_data {
> enum cd_types cd_type;
> unsigned caps;
> char *devname;
> + unsigned dsr_val;
> + int use_dsr;
> };
> #endif /* __ASM_ARCH_IMX_ESDHC_H */
> diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
> index 7664e7b..4c7a45e 100644
> --- a/drivers/mci/imx-esdhc.c
> +++ b/drivers/mci/imx-esdhc.c
> @@ -582,6 +582,10 @@ static int fsl_esdhc_probe(struct device_d *dev)
> if (host->mci.f_min < 200000)
> host->mci.f_min = 200000;
> host->mci.f_max = rate;
> + if (pdata) {
> + host->mci.use_dsr = pdata->use_dsr;
> + host->mci.dsr_val = pdata->dsr_val;
> + }
>
I don't know what other barebox devs thinking about this. But I would
remove use_dsr attribute, because a dsr_val != 0 indicates that you want
to use dsr. You don't need a extra switch, in my opinion.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* AW: [PATCH 3/4] mci: imx-esdhc: add DSR support
2014-01-14 8:49 ` Alexander Aring
@ 2014-01-14 14:26 ` Markus Niebel
0 siblings, 0 replies; 8+ messages in thread
From: Markus Niebel @ 2014-01-14 14:26 UTC (permalink / raw)
To: Alexander Aring, Markus Niebel; +Cc: barebox
Hello,
> Von: Alexander Aring [mailto:alex.aring@gmail.com]
> Gesendet: Dienstag, 14. Januar 2014 09:49
> An: Markus Niebel
> Cc: barebox@lists.infradead.org; Markus Niebel
> Betreff: Re: [PATCH 3/4] mci: imx-esdhc: add DSR support
>
> Hi,
>
> On Tue, Jan 14, 2014 at 09:23:36AM +0100, Markus Niebel wrote:
> > From: Markus Niebel <Markus.Niebel@tqs.de>
> >
> > having DSR support in mci-core we need a way to
> > forward the DSR value to the driver. Add it to
> > platform data for imx-esdhc
> >
> > TODO: implement the same for other host controller
> > drivers
> >
> > Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
> > ---
> > arch/arm/mach-imx/include/mach/esdhc.h | 2 ++
> > drivers/mci/imx-esdhc.c | 4 ++++
> > 2 files changed, 6 insertions(+)
> >
> > diff --git a/arch/arm/mach-imx/include/mach/esdhc.h b/arch/arm/mach-
> imx/include/mach/esdhc.h
> > index add1691..fb7380a 100644
> > --- a/arch/arm/mach-imx/include/mach/esdhc.h
> > +++ b/arch/arm/mach-imx/include/mach/esdhc.h
> > @@ -42,5 +42,7 @@ struct esdhc_platform_data {
> > enum cd_types cd_type;
> > unsigned caps;
> > char *devname;
> > + unsigned dsr_val;
> > + int use_dsr;
> > };
> > #endif /* __ASM_ARCH_IMX_ESDHC_H */
> > diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
> > index 7664e7b..4c7a45e 100644
> > --- a/drivers/mci/imx-esdhc.c
> > +++ b/drivers/mci/imx-esdhc.c
> > @@ -582,6 +582,10 @@ static int fsl_esdhc_probe(struct device_d *dev)
> > if (host->mci.f_min < 200000)
> > host->mci.f_min = 200000;
> > host->mci.f_max = rate;
> > + if (pdata) {
> > + host->mci.use_dsr = pdata->use_dsr;
> > + host->mci.dsr_val = pdata->dsr_val;
> > + }
> >
> I don't know what other barebox devs thinking about this. But I would
> remove use_dsr attribute, because a dsr_val != 0 indicates that you want
> to use dsr. You don't need a extra switch, in my opinion.
As far as I understand the documentation the assignment between DSR / CMD4 value
and driver strength is left to the card (firmware) implementor - so far a dsr_val = 0
could be a valid setting.
>
> - Alex
Markus
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] boards: tqma53: add DSR support for eMMC
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
` (2 preceding siblings ...)
2014-01-14 8:23 ` [PATCH 3/4] mci: imx-esdhc: add DSR support Markus Niebel
@ 2014-01-14 8:23 ` Markus Niebel
2014-01-15 14:23 ` [PATCH v2 0/4] mmc: add setdsr support Sascha Hauer
4 siblings, 0 replies; 8+ messages in thread
From: Markus Niebel @ 2014-01-14 8:23 UTC (permalink / raw)
To: barebox; +Cc: Markus Niebel
From: Markus Niebel <Markus.Niebel@tqs.de>
all eMMC cards with DSR support used on different
revisions of TQMa53 needs the same DSR value.
just apply it.
Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
arch/arm/boards/tqma53/board.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/boards/tqma53/board.c b/arch/arm/boards/tqma53/board.c
index 9069f7c..cc98de9 100644
--- a/arch/arm/boards/tqma53/board.c
+++ b/arch/arm/boards/tqma53/board.c
@@ -39,6 +39,8 @@
#include <mach/iim.h>
#include <mach/imx5.h>
+#define TQMA53_EMMC_DSR 0x0100u
+
static struct fec_platform_data fec_info = {
.xcv_type = PHY_INTERFACE_MODE_RMII,
};
@@ -221,6 +223,8 @@ static struct esdhc_platform_data tqma53_sd3_data = {
.cd_type = ESDHC_CD_PERMANENT,
.wp_type = ESDHC_WP_NONE,
.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
+ .use_dsr = 1,
+ .dsr_val = TQMA53_EMMC_DSR,
};
static int tqma53_devices_init(void)
--
1.7.9.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/4] mmc: add setdsr support
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
` (3 preceding siblings ...)
2014-01-14 8:23 ` [PATCH 4/4] boards: tqma53: add DSR support for eMMC Markus Niebel
@ 2014-01-15 14:23 ` Sascha Hauer
4 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2014-01-15 14:23 UTC (permalink / raw)
To: Markus Niebel; +Cc: barebox
On Tue, Jan 14, 2014 at 09:23:33AM +0100, Markus Niebel wrote:
> This is an example to add DSR support to barebox. Why this feature is
> considered as useful is described in the first patch. Second and third
> patch show how to pass values via device tree or platform data and
> last patch shows how this can be supported for a board using platform
> data.
>
> Tested with TQMa53 and a 4.41 Micron eMMC with DSR support.
Applied, thanks
Sascha
>
> Changelog v1 (RFC) -> v2
> - add device tree support
> - fix possible null pointer access
>
> [PATCH 1/4] mci: add DSR support
> [PATCH 2/4] mci: add device tree support for DSR
> [PATCH 3/4] mci: imx-esdhc: add DSR support
> [PATCH 4/4] boards: tqma53: add DSR support for eMMC
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 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] 8+ messages in thread