* [PATCH] mmc: sdhci-esdhc-imx: Allow the usage of mmc aliases
@ 2013-09-23 2:38 Fabio Estevam
[not found] ` <1379903897-16019-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2013-09-23 2:38 UTC (permalink / raw)
To: cjb
Cc: dirk.behme, kernel, shawn.guo, linux-mmc, swarren, arnd,
devicetree-discuss, Fabio Estevam, Dirk Behme
From: Fabio Estevam <fabio.estevam@freescale.com>
On embedded devices, there is often a combination of removable mmc
devices (e.g. MMC/SD cards) and hard wired ones (e.g. eMMC).
Depending on the hardware configuration, the 'mmcblkN' node might
change if the removable device is available or not at boot time.
E.g. if the removable device is attached at boot time, it might
become mmxblk0. And the hard wired one mmcblk1. But if the removable
device isn't there at boot time, the hard wired one will become
mmcblk0. This makes it somehow difficult to hard code the root device
to the non-removable device and boot fast.
Allow the sdhci-esdhc-imx driver to retrieve the mmc aliases, so that we can
map via the device tree which mmcblk corresponds to the rootfs.
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/mmc/card/block.c | 5 +++--
drivers/mmc/host/sdhci-esdhc-imx.c | 10 +++++++++-
include/linux/mmc/host.h | 2 ++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1a3163f..94f842b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2026,7 +2026,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
struct mmc_blk_data *md;
int devidx, ret;
- devidx = find_first_zero_bit(dev_use, max_devices);
+ devidx = find_next_zero_bit(dev_use, max_devices, card->host->devidx);
if (devidx >= max_devices)
return ERR_PTR(-ENOSPC);
__set_bit(devidx, dev_use);
@@ -2044,7 +2044,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
* index anymore so we keep track of a name index.
*/
if (!subname) {
- md->name_idx = find_first_zero_bit(name_use, max_devices);
+ md->name_idx = find_next_zero_bit(name_use, max_devices,
+ card->host->devidx);
__set_bit(md->name_idx, name_use);
} else
md->name_idx = ((struct mmc_blk_data *)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index abc8cf0..e11a6af 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -524,8 +524,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host;
struct sdhci_host *host;
struct esdhc_platform_data *boarddata;
- int err;
+ int err, ret;
struct pltfm_imx_data *imx_data;
+ struct device_node *np = pdev->dev.of_node;
host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0);
if (IS_ERR(host))
@@ -602,6 +603,13 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
host->mmc->parent->platform_data);
}
+
+ if (np) {
+ ret = of_alias_get_id(np, "mmcblk");
+ if (ret >= 0)
+ host->mmc->devidx = ret;
+ }
+
/* write_protect */
if (boarddata->wp_type == ESDHC_WP_GPIO) {
err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 3b0c33a..8209f72 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -362,6 +362,8 @@ struct mmc_host {
unsigned int slotno; /* used for sdio acpi binding */
+ /* preferred mmc block device index (mmcblkX) */
+ unsigned int devidx;
unsigned long private[0] ____cacheline_aligned;
};
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Allow the usage of mmc aliases
[not found] ` <1379903897-16019-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-09-23 21:27 ` Stephen Warren
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Warren @ 2013-09-23 21:27 UTC (permalink / raw)
To: Fabio Estevam
Cc: cjb-2X9k7bc8m7Mdnm+yROfE0A, dirk.behme-Re5JQEeQqe8AvxtiuMwx3w,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
linux-mmc-u79uwXL29TY76Z2rM5mHXA, arnd-r2nGTMty4D4,
devicetree-u79uwXL29TY76Z2rM5mHXA, Fabio Estevam, Dirk Behme
On 09/22/2013 08:38 PM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>
> On embedded devices, there is often a combination of removable mmc
> devices (e.g. MMC/SD cards) and hard wired ones (e.g. eMMC).
> Depending on the hardware configuration, the 'mmcblkN' node might
> change if the removable device is available or not at boot time.
>
> E.g. if the removable device is attached at boot time, it might
> become mmxblk0. And the hard wired one mmcblk1. But if the removable
> device isn't there at boot time, the hard wired one will become
> mmcblk0. This makes it somehow difficult to hard code the root device
> to the non-removable device and boot fast.
>
> Allow the sdhci-esdhc-imx driver to retrieve the mmc aliases, so that we can
> map via the device tree which mmcblk corresponds to the rootfs.
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> - devidx = find_first_zero_bit(dev_use, max_devices);
> + devidx = find_next_zero_bit(dev_use, max_devices, card->host->devidx);
I'm not sure if this works; what if the SD card gets detected/removed
without recycling the device name/ID a few times before the fixed eMMC
is detected?
So, in the perfect case this will achieve what you want, but not in some
unusual cases. So I don't think it's a good idea to rely on this.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-23 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23 2:38 [PATCH] mmc: sdhci-esdhc-imx: Allow the usage of mmc aliases Fabio Estevam
[not found] ` <1379903897-16019-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-23 21:27 ` Stephen Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox