* [PATCH v2 1/2] mmc: sdhci: add init_card callback
@ 2014-06-13 10:25 Steffen Trumtrar
2014-06-13 10:25 ` [PATCH v2 2/2] mmc: sdhci-esdhc-imx: add callback for card_type inits Steffen Trumtrar
2014-06-13 11:01 ` [PATCH v2 1/2] mmc: sdhci: add init_card callback Ulf Hansson
0 siblings, 2 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2014-06-13 10:25 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Dong Aisheng, Steffen Trumtrar
Currently host drivers using the sdhci-pltfm code can not configure the
host based on the type of card inserted.
The sdio driver e.g. calls the card_init callback, so the host can now
know what card is used and configure itself accordingly.
Provide a callback for users of the sdhci-pltfm code to use this callback
function.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
- rebased onto mmc-updates-for-3.16-rc1
drivers/mmc/host/sdhci.c | 9 +++++++++
drivers/mmc/host/sdhci.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 47055f3..0fa9004 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2071,6 +2071,14 @@ static void sdhci_card_event(struct mmc_host *mmc)
spin_unlock_irqrestore(&host->lock, flags);
}
+static void sdhci_init_card(struct mmc_host *mmc, struct mmc_card *card)
+{
+ struct sdhci_host *host = mmc_priv(mmc);
+
+ if (host->ops->card_type_init)
+ host->ops->card_type_init(host, card);
+}
+
static const struct mmc_host_ops sdhci_ops = {
.request = sdhci_request,
.set_ios = sdhci_set_ios,
@@ -2082,6 +2090,7 @@ static const struct mmc_host_ops sdhci_ops = {
.execute_tuning = sdhci_execute_tuning,
.card_event = sdhci_card_event,
.card_busy = sdhci_card_busy,
+ .init_card = sdhci_init_card,
};
/*****************************************************************************\
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 4a5cd5e..def4adf 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -292,6 +292,7 @@ struct sdhci_ops {
void (*adma_workaround)(struct sdhci_host *host, u32 intmask);
void (*platform_init)(struct sdhci_host *host);
void (*card_event)(struct sdhci_host *host);
+ void (*card_type_init)(struct sdhci_host *host, struct mmc_card *card);
};
#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] mmc: sdhci-esdhc-imx: add callback for card_type inits
2014-06-13 10:25 [PATCH v2 1/2] mmc: sdhci: add init_card callback Steffen Trumtrar
@ 2014-06-13 10:25 ` Steffen Trumtrar
2014-06-13 11:01 ` [PATCH v2 1/2] mmc: sdhci: add init_card callback Ulf Hansson
1 sibling, 0 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2014-06-13 10:25 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Dong Aisheng, Steffen Trumtrar
At least the i.MX35 (there may be others) currently implements a quirk
to turn of multiblock transfers for the esdhc host.
According to the errata this is only true for SD cards and NOT for
sdio cards.
When the sdio driver initializes the card, it knows the type of card
we actually have. So now the sdhci-esdhc-imx could decide based on
card type if multiblock transfers should be used or not
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
- rebased onto mmc-updates-for-3.16-rc1
drivers/mmc/host/sdhci-esdhc-imx.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index ccec0e3..2bf9223 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -18,6 +18,7 @@
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
@@ -880,6 +881,20 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask)
sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
}
+static void esdhc_init_card_type(struct sdhci_host *host, struct mmc_card *card)
+{
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+ struct pltfm_imx_data *imx_data = pltfm_host->priv;
+ struct mmc_host *mmc = host->mmc;
+
+ if (imx_data->socdata->flags & ESDHC_FLAG_ENGCM07207) {
+ if (card->type == MMC_TYPE_SDIO)
+ mmc->max_blk_count = 65535;
+ else
+ mmc->max_blk_count = 1;
+ }
+}
+
static struct sdhci_ops sdhci_esdhc_ops = {
.read_l = esdhc_readl_le,
.read_w = esdhc_readw_le,
@@ -893,6 +908,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
.set_bus_width = esdhc_pltfm_set_bus_width,
.set_uhs_signaling = esdhc_set_uhs_signaling,
.reset = esdhc_reset,
+ .card_type_init = esdhc_init_card_type,
};
static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 1/2] mmc: sdhci: add init_card callback
2014-06-13 10:25 [PATCH v2 1/2] mmc: sdhci: add init_card callback Steffen Trumtrar
2014-06-13 10:25 ` [PATCH v2 2/2] mmc: sdhci-esdhc-imx: add callback for card_type inits Steffen Trumtrar
@ 2014-06-13 11:01 ` Ulf Hansson
2014-06-13 12:09 ` Steffen Trumtrar
1 sibling, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2014-06-13 11:01 UTC (permalink / raw)
To: Steffen Trumtrar; +Cc: linux-mmc, Chris Ball, Dong Aisheng
On 13 June 2014 12:25, Steffen Trumtrar <s.trumtrar@pengutronix.de> wrote:
> Currently host drivers using the sdhci-pltfm code can not configure the
> host based on the type of card inserted.
>
> The sdio driver e.g. calls the card_init callback, so the host can now
> know what card is used and configure itself accordingly.
>
> Provide a callback for users of the sdhci-pltfm code to use this callback
> function.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
At the first glance, this seems like a reasonable approach to your problem.
Though I wonder if the mmc core really behaves as what a host expect
in this context. More precisely, the mmc core _only_ invokes
host_ops->init_card() from the sdio initialization path. Don't your
host need to be invoked for the SD/eMMC case as well?
Do note that the ->init_card() function is also used to handle
non-standard SDIO devices.
Hmm. :-)
Kind regards
Uffe
> ---
> Changes since v1:
> - rebased onto mmc-updates-for-3.16-rc1
>
> drivers/mmc/host/sdhci.c | 9 +++++++++
> drivers/mmc/host/sdhci.h | 1 +
> 2 files changed, 10 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 47055f3..0fa9004 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2071,6 +2071,14 @@ static void sdhci_card_event(struct mmc_host *mmc)
> spin_unlock_irqrestore(&host->lock, flags);
> }
>
> +static void sdhci_init_card(struct mmc_host *mmc, struct mmc_card *card)
> +{
> + struct sdhci_host *host = mmc_priv(mmc);
> +
> + if (host->ops->card_type_init)
> + host->ops->card_type_init(host, card);
> +}
> +
> static const struct mmc_host_ops sdhci_ops = {
> .request = sdhci_request,
> .set_ios = sdhci_set_ios,
> @@ -2082,6 +2090,7 @@ static const struct mmc_host_ops sdhci_ops = {
> .execute_tuning = sdhci_execute_tuning,
> .card_event = sdhci_card_event,
> .card_busy = sdhci_card_busy,
> + .init_card = sdhci_init_card,
> };
>
> /*****************************************************************************\
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 4a5cd5e..def4adf 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -292,6 +292,7 @@ struct sdhci_ops {
> void (*adma_workaround)(struct sdhci_host *host, u32 intmask);
> void (*platform_init)(struct sdhci_host *host);
> void (*card_event)(struct sdhci_host *host);
> + void (*card_type_init)(struct sdhci_host *host, struct mmc_card *card);
> };
>
> #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
> --
> 2.0.0.rc2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2 1/2] mmc: sdhci: add init_card callback
2014-06-13 11:01 ` [PATCH v2 1/2] mmc: sdhci: add init_card callback Ulf Hansson
@ 2014-06-13 12:09 ` Steffen Trumtrar
0 siblings, 0 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2014-06-13 12:09 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, Chris Ball, Dong Aisheng
On Fri, Jun 13, 2014 at 01:01:25PM +0200, Ulf Hansson wrote:
> On 13 June 2014 12:25, Steffen Trumtrar <s.trumtrar@pengutronix.de> wrote:
> > Currently host drivers using the sdhci-pltfm code can not configure the
> > host based on the type of card inserted.
> >
> > The sdio driver e.g. calls the card_init callback, so the host can now
> > know what card is used and configure itself accordingly.
> >
> > Provide a callback for users of the sdhci-pltfm code to use this callback
> > function.
> >
> > Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>
> At the first glance, this seems like a reasonable approach to your problem.
>
> Though I wonder if the mmc core really behaves as what a host expect
> in this context. More precisely, the mmc core _only_ invokes
> host_ops->init_card() from the sdio initialization path. Don't your
> host need to be invoked for the SD/eMMC case as well?
>
For my use-case this is okay. Though it sounds like this is not generic
enough. I'm open for suggestions.
> Do note that the ->init_card() function is also used to handle
> non-standard SDIO devices.
>
Hm, the problem occured with a card that can't handle single transfers.
So, sounds non-standard to me.
Thanks,
Steffen
--
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 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-13 12:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13 10:25 [PATCH v2 1/2] mmc: sdhci: add init_card callback Steffen Trumtrar
2014-06-13 10:25 ` [PATCH v2 2/2] mmc: sdhci-esdhc-imx: add callback for card_type inits Steffen Trumtrar
2014-06-13 11:01 ` [PATCH v2 1/2] mmc: sdhci: add init_card callback Ulf Hansson
2014-06-13 12:09 ` Steffen Trumtrar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox