* [PATCH 1/6] MXS/MCI: add forgotten header file
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 9:31 ` [PATCH 2/6] MXS/MCI: don't touch variables in the host structure Juergen Beisert
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
Commit b36f68d74b5379c216429a0f15aeedbd7917e10d now uses the generic
mxs_reset_block() routine, but this requires the mxs.h header file for the
prototype.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mxs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 93f5a41..e2ffa43 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -37,6 +37,7 @@
#include <clock.h>
#include <io.h>
#include <asm/bitops.h>
+#include <mach/mxs.h>
#include <mach/imx-regs.h>
#include <mach/mci.h>
#include <mach/clock.h>
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/6] MXS/MCI: don't touch variables in the host structure
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
2013-04-26 9:31 ` [PATCH 1/6] MXS/MCI: add forgotten header file Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 9:31 ` [PATCH 3/6] MCI/Core: increase the transmission frequency while card detection Juergen Beisert
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
MMC_BUS_WIDTH_* macros do not correspond with the real bus width.
After setting a bus width larger than 1 bit the next call to change the
frequency ends in the default handler and the host interface stays silently
at the previous frequency.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mxs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index e2ffa43..3045e6a 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -515,23 +515,23 @@ static void mxs_mci_set_ios(struct mci_host *host, struct mci_ios *ios)
switch (ios->bus_width) {
case MMC_BUS_WIDTH_8:
mxs_mci->bus_width = 2;
- host->bus_width = 8; /* 8 bit is possible */
+ pr_debug("IO settings: changing bus width to 8 bits\n");
break;
case MMC_BUS_WIDTH_4:
mxs_mci->bus_width = 1;
- host->bus_width = 4; /* 4 bit is possible */
+ pr_debug("IO settings: changing bus width to 4 bits\n");
break;
case MMC_BUS_WIDTH_1:
mxs_mci->bus_width = 0;
- host->bus_width = 1; /* 1 bit is possible */
+ pr_debug("IO settings: changing bus width to 1 bit\n");
break;
default:
+ pr_debug("IO settings: unsupported bus width!\n");
return;
}
mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, ios->clock);
- pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width,
- mxs_mci->clock);
+ pr_debug("IO settings: frequency=%u Hz\n", mxs_mci->clock);
}
/* ----------------------------------------------------------------------- */
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/6] MCI/Core: increase the transmission frequency while card detection
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
2013-04-26 9:31 ` [PATCH 1/6] MXS/MCI: add forgotten header file Juergen Beisert
2013-04-26 9:31 ` [PATCH 2/6] MXS/MCI: don't touch variables in the host structure Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 9:31 ` [PATCH 4/6] MCI/Core: honor transmission limits at the card's side Juergen Beisert
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
According to the SD card spec the detection can happen at 400 kHz
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mci-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index a269aee..9aeaa4d 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1371,7 +1371,8 @@ static int mci_card_probe(struct mci *mci)
}
mci_set_bus_width(mci, MMC_BUS_WIDTH_1);
- mci_set_clock(mci, 1); /* set the lowest available clock */
+ /* according to the SD card spec the detection can happen at 400 kHz */
+ mci_set_clock(mci, 400000);
/* reset the card */
rc = mci_go_idle(mci);
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/6] MCI/Core: honor transmission limits at the card's side
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
` (2 preceding siblings ...)
2013-04-26 9:31 ` [PATCH 3/6] MCI/Core: increase the transmission frequency while card detection Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 9:31 ` [PATCH 5/6] MCI/MXS: report a better matching error code when the transfer fails Juergen Beisert
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
The host limits are only one limit we must honor when changing the transmission frequency.
The SD cards have their own limits, so take them also into account.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mci-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 9aeaa4d..42e3d4b 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -605,13 +605,17 @@ static void mci_set_clock(struct mci *mci, unsigned clock)
{
struct mci_host *host = mci->host;
- /* check against any given limits */
+ /* check against any given limits at the host's side */
if (clock > host->f_max)
clock = host->f_max;
if (clock < host->f_min)
clock = host->f_min;
+ /* check against the limit at the card's side */
+ if (mci->tran_speed != 0 && clock > mci->tran_speed)
+ clock = mci->tran_speed;
+
host->clock = clock; /* the new target frequency */
mci_set_ios(mci);
}
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/6] MCI/MXS: report a better matching error code when the transfer fails
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
` (3 preceding siblings ...)
2013-04-26 9:31 ` [PATCH 4/6] MCI/Core: honor transmission limits at the card's side Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 9:31 ` [PATCH 6/6] MCI/Core: move an ugly ifdef to the header file Juergen Beisert
2013-04-26 22:08 ` Some fixes and improvements while working with the Chumby Sascha Hauer
6 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
EIO is a better error message to describe the data transfer to or from the SD cards has failed.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mxs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 3045e6a..c15461c 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -186,7 +186,7 @@ static int mxs_mci_read_data(struct mxs_mci_host *mxs_mci, void *buffer, unsigne
if (length == 0)
return 0;
- return -EINVAL;
+ return -EIO;
}
@@ -223,7 +223,7 @@ static int mxs_mci_write_data(struct mxs_mci_host *mxs_mci, const void *buffer,
if (length == 0)
return 0;
- return -EINVAL;
+ return -EIO;
}
/**
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/6] MCI/Core: move an ugly ifdef to the header file
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
` (4 preceding siblings ...)
2013-04-26 9:31 ` [PATCH 5/6] MCI/MXS: report a better matching error code when the transfer fails Juergen Beisert
@ 2013-04-26 9:31 ` Juergen Beisert
2013-04-26 22:04 ` Sascha Hauer
2013-04-26 22:08 ` Some fixes and improvements while working with the Chumby Sascha Hauer
6 siblings, 1 reply; 9+ messages in thread
From: Juergen Beisert @ 2013-04-26 9:31 UTC (permalink / raw)
To: barebox
To avoid the compiler complains about an unused variable when no SPI host is
enabled, use an inline function instead of a macro.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
drivers/mci/mci-core.c | 3 +--
include/mci.h | 15 +++++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 42e3d4b..ba7ef55 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -482,9 +482,8 @@ static int sd_change_freq(struct mci *mci)
{
struct mci_cmd cmd;
struct mci_data data;
-#ifdef CONFIG_MCI_SPI
struct mci_host *host = mci->host;
-#endif
+
uint32_t *switch_status = sector_buf;
uint32_t *scr = sector_buf;
int timeout;
diff --git a/include/mci.h b/include/mci.h
index cf9582d..7f514be 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -54,12 +54,6 @@
#define IS_SD(x) (x->version & SD_VERSION_SD)
-#ifdef CONFIG_MCI_SPI
-#define mmc_host_is_spi(host) ((host)->host_caps & MMC_CAP_SPI)
-#else
-#define mmc_host_is_spi(host) 0
-#endif
-
#define MMC_DATA_READ 1
#define MMC_DATA_WRITE 2
@@ -330,6 +324,15 @@ struct mci {
char *ext_csd;
};
+static inline bool mmc_host_is_spi(const struct mci_host *host)
+{
+#ifdef CONFIG_MCI_SPI
+ return !!host->host_caps & MMC_CAP_SPI;
+#else
+ return false;
+#endif
+}
+
int mci_register(struct mci_host*);
#endif /* _MCI_H_ */
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/6] MCI/Core: move an ugly ifdef to the header file
2013-04-26 9:31 ` [PATCH 6/6] MCI/Core: move an ugly ifdef to the header file Juergen Beisert
@ 2013-04-26 22:04 ` Sascha Hauer
0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-04-26 22:04 UTC (permalink / raw)
To: Juergen Beisert; +Cc: barebox
On Fri, Apr 26, 2013 at 11:31:52AM +0200, Juergen Beisert wrote:
> To avoid the compiler complains about an unused variable when no SPI host is
> enabled, use an inline function instead of a macro.
>
> Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
> ---
> drivers/mci/mci-core.c | 3 +--
> include/mci.h | 15 +++++++++------
> 2 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 42e3d4b..ba7ef55 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -482,9 +482,8 @@ static int sd_change_freq(struct mci *mci)
> {
> struct mci_cmd cmd;
> struct mci_data data;
> -#ifdef CONFIG_MCI_SPI
> struct mci_host *host = mci->host;
> -#endif
> +
> uint32_t *switch_status = sector_buf;
> uint32_t *scr = sector_buf;
> int timeout;
> diff --git a/include/mci.h b/include/mci.h
> index cf9582d..7f514be 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -54,12 +54,6 @@
>
> #define IS_SD(x) (x->version & SD_VERSION_SD)
>
> -#ifdef CONFIG_MCI_SPI
> -#define mmc_host_is_spi(host) ((host)->host_caps & MMC_CAP_SPI)
> -#else
> -#define mmc_host_is_spi(host) 0
> -#endif
> -
> #define MMC_DATA_READ 1
> #define MMC_DATA_WRITE 2
>
> @@ -330,6 +324,15 @@ struct mci {
> char *ext_csd;
> };
>
> +static inline bool mmc_host_is_spi(const struct mci_host *host)
> +{
> +#ifdef CONFIG_MCI_SPI
> + return !!host->host_caps & MMC_CAP_SPI;
negation comes before bitwise and. This always returns 0.
Also you could use IS_ENABLED().
Sascha
> +#else
> + return false;
> +#endif
> +}
> +
> int mci_register(struct mci_host*);
>
> #endif /* _MCI_H_ */
> --
> 1.8.2.rc2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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] 9+ messages in thread
* Re: Some fixes and improvements while working with the Chumby
2013-04-26 9:31 Some fixes and improvements while working with the Chumby Juergen Beisert
` (5 preceding siblings ...)
2013-04-26 9:31 ` [PATCH 6/6] MCI/Core: move an ugly ifdef to the header file Juergen Beisert
@ 2013-04-26 22:08 ` Sascha Hauer
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-04-26 22:08 UTC (permalink / raw)
To: Juergen Beisert; +Cc: barebox
On Fri, Apr 26, 2013 at 11:31:46AM +0200, Juergen Beisert wrote:
> Below a list of some small patches for the MXS MCI driver and the MCI core.
> Comments are welcome.
Squashed 1/6 into the commit breaking it, applied 2/6 to master,
3-5/6 to next.
Sascha
--
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] 9+ messages in thread