MMC: Make the configuration memory resource optional

From: Guennadi Liakhovetski
Date: Fri Jul 17 2009 - 07:10:33 EST


Add support for tmio_mmc hardware configurations, that lack the cnf io
area, like SuperH SoCs. With this patch such hardware can pass a single
ctl io area with the platform data.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@xxxxxx>
CC: Magnus Damm <damm@xxxxxxxxxxxxx>
---
Pierre, I know you wanted to step down as a MMC maintainer (thanks for
your great work btw!), but since we don't have a new one yet, I'm CC-ing
you.

A version of this patch has previously been submitted by Magnus Damm
(CCed), but it hasn't been accepted back at 2.6.29 times (about 4 months
ago). Now this driver extension has become much simpler, so, I think,
there should be no problem accepting this patch now.

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 91991b4..c246191 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -519,12 +519,12 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
struct mmc_host *mmc;
int ret = -EINVAL;

- if (dev->num_resources != 3)
+ if (dev->num_resources < 2 || dev->num_resources > 3)
goto out;

res_ctl = platform_get_resource(dev, IORESOURCE_MEM, 0);
res_cnf = platform_get_resource(dev, IORESOURCE_MEM, 1);
- if (!res_ctl || !res_cnf)
+ if (!res_ctl)
goto out;

pdata = cell->driver_data;
@@ -548,9 +548,11 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
if (!host->ctl)
goto host_free;

- host->cnf = ioremap(res_cnf->start, resource_size(res_cnf));
- if (!host->cnf)
- goto unmap_ctl;
+ if (res_cnf) {
+ host->cnf = ioremap(res_cnf->start, resource_size(res_cnf));
+ if (!host->cnf)
+ goto unmap_ctl;
+ }

mmc->ops = &tmio_mmc_ops;
mmc->caps = MMC_CAP_4_BIT_DATA;
@@ -606,7 +608,8 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
return 0;

unmap_cnf:
- iounmap(host->cnf);
+ if (host->cnf)
+ iounmap(host->cnf);
unmap_ctl:
iounmap(host->ctl);
host_free:
@@ -626,7 +629,8 @@ static int __devexit tmio_mmc_remove(struct platform_device *dev)
mmc_remove_host(mmc);
free_irq(host->irq, host);
iounmap(host->ctl);
- iounmap(host->cnf);
+ if (host->cnf)
+ iounmap(host->cnf);
mmc_free_host(mmc);
}

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 9fa9985..45f06aa 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -166,18 +166,24 @@ static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr,
static inline void sd_config_write8(struct tmio_mmc_host *host, int addr,
u8 val)
{
+ if (!host->cnf)
+ return;
writeb(val, host->cnf + (addr << host->bus_shift));
}

static inline void sd_config_write16(struct tmio_mmc_host *host, int addr,
u16 val)
{
+ if (!host->cnf)
+ return;
writew(val, host->cnf + (addr << host->bus_shift));
}

static inline void sd_config_write32(struct tmio_mmc_host *host, int addr,
u32 val)
{
+ if (!host->cnf)
+ return;
writew(val, host->cnf + (addr << host->bus_shift));
writew(val >> 16, host->cnf + ((addr + 2) << host->bus_shift));
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/