aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManjunathappa, Prakash <prakash.pm@ti.com>2013-03-28 09:12:00 -0400
committerSekhar Nori <nsekhar@ti.com>2013-04-04 07:25:05 -0400
commit7b43da4cfdd5e88157fe83a07cc49919080d3205 (patch)
tree928a0d17db2efe3da349b4b9ebbfe845ed0388aa
parentc3847a395b7175558f83dfc7b3171775a3d4ecf2 (diff)
mmc: davinci_mmc: add DT support
Adds device tree support for davinci_mmc. Also add binding documentation. As of now tested for non-dma PIO mode and without GPIO card_detect/ write_protect option because of dependencies on EDMA and GPIO module DT support. Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Sekhar Nori <nsekhar@ti.com> Cc: linux-mmc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: davinci-linux-open-source@linux.davincidsp.com Cc: devicetree-discuss@lists.ozlabs.org Cc: cjb@laptop.org Cc: Sekhar Nori <nsekhar@ti.com> Cc: mporter@ti.com Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Chris Ball <cjb@laptop.org> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r--Documentation/devicetree/bindings/mmc/davinci_mmc.txt33
-rw-r--r--drivers/mmc/host/davinci_mmc.c70
2 files changed, 99 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/mmc/davinci_mmc.txt b/Documentation/devicetree/bindings/mmc/davinci_mmc.txt
new file mode 100644
index 000000000000..e5a0140b2381
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/davinci_mmc.txt
@@ -0,0 +1,33 @@
1* TI Highspeed MMC host controller for DaVinci
2
3The Highspeed MMC Host Controller on TI DaVinci family
4provides an interface for MMC, SD and SDIO types of memory cards.
5
6This file documents the properties used by the davinci_mmc driver.
7
8Required properties:
9- compatible:
10 Should be "ti,da830-mmc": for da830, da850, dm365
11 Should be "ti,dm355-mmc": for dm355, dm644x
12
13Optional properties:
14- bus-width: Number of data lines, can be <1>, <4>, or <8>, default <1>
15- max-frequency: Maximum operating clock frequency, default 25MHz.
16- dmas: List of DMA specifiers with the controller specific format
17 as described in the generic DMA client binding. A tx and rx
18 specifier is required.
19- dma-names: RX and TX DMA request names. These strings correspond
20 1:1 with the DMA specifiers listed in dmas.
21
22Example:
23mmc0: mmc@1c40000 {
24 compatible = "ti,da830-mmc",
25 reg = <0x40000 0x1000>;
26 interrupts = <16>;
27 status = "okay";
28 bus-width = <4>;
29 max-frequency = <50000000>;
30 dmas = <&edma 16
31 &edma 17>;
32 dma-names = "rx", "tx";
33};
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index b5f1c019ecad..f8a96d652e9e 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -34,6 +34,8 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/edma.h> 35#include <linux/edma.h>
36#include <linux/mmc/mmc.h> 36#include <linux/mmc/mmc.h>
37#include <linux/of.h>
38#include <linux/of_device.h>
37 39
38#include <linux/platform_data/mmc-davinci.h> 40#include <linux/platform_data/mmc-davinci.h>
39 41
@@ -522,14 +524,16 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
522 dma_cap_set(DMA_SLAVE, mask); 524 dma_cap_set(DMA_SLAVE, mask);
523 525
524 host->dma_tx = 526 host->dma_tx =
525 dma_request_channel(mask, edma_filter_fn, &host->txdma); 527 dma_request_slave_channel_compat(mask, edma_filter_fn,
528 &host->txdma, mmc_dev(host->mmc), "tx");
526 if (!host->dma_tx) { 529 if (!host->dma_tx) {
527 dev_err(mmc_dev(host->mmc), "Can't get dma_tx channel\n"); 530 dev_err(mmc_dev(host->mmc), "Can't get dma_tx channel\n");
528 return -ENODEV; 531 return -ENODEV;
529 } 532 }
530 533
531 host->dma_rx = 534 host->dma_rx =
532 dma_request_channel(mask, edma_filter_fn, &host->rxdma); 535 dma_request_slave_channel_compat(mask, edma_filter_fn,
536 &host->rxdma, mmc_dev(host->mmc), "rx");
533 if (!host->dma_rx) { 537 if (!host->dma_rx) {
534 dev_err(mmc_dev(host->mmc), "Can't get dma_rx channel\n"); 538 dev_err(mmc_dev(host->mmc), "Can't get dma_rx channel\n");
535 r = -ENODEV; 539 r = -ENODEV;
@@ -1169,9 +1173,62 @@ static struct platform_device_id davinci_mmc_devtype[] = {
1169}; 1173};
1170MODULE_DEVICE_TABLE(platform, davinci_mmc_devtype); 1174MODULE_DEVICE_TABLE(platform, davinci_mmc_devtype);
1171 1175
1172static int __init davinci_mmcsd_probe(struct platform_device *pdev) 1176static const struct of_device_id davinci_mmc_dt_ids[] = {
1177 {
1178 .compatible = "ti,dm6441-mmc",
1179 .data = &davinci_mmc_devtype[MMC_CTLR_VERSION_1],
1180 },
1181 {
1182 .compatible = "ti,da830-mmc",
1183 .data = &davinci_mmc_devtype[MMC_CTLR_VERSION_2],
1184 },
1185 {},
1186};
1187MODULE_DEVICE_TABLE(of, davinci_mmc_dt_ids);
1188
1189static struct davinci_mmc_config
1190 *mmc_parse_pdata(struct platform_device *pdev)
1173{ 1191{
1192 struct device_node *np;
1174 struct davinci_mmc_config *pdata = pdev->dev.platform_data; 1193 struct davinci_mmc_config *pdata = pdev->dev.platform_data;
1194 const struct of_device_id *match =
1195 of_match_device(of_match_ptr(davinci_mmc_dt_ids), &pdev->dev);
1196 u32 data;
1197
1198 np = pdev->dev.of_node;
1199 if (!np)
1200 return pdata;
1201
1202 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1203 if (!pdata) {
1204 dev_err(&pdev->dev, "Failed to allocate memory for struct davinci_mmc_config\n");
1205 goto nodata;
1206 }
1207
1208 if (match)
1209 pdev->id_entry = match->data;
1210
1211 if (of_property_read_u32(np, "max-frequency", &pdata->max_freq))
1212 dev_info(&pdev->dev, "'max-frequency' property not specified, defaulting to 25MHz\n");
1213
1214 of_property_read_u32(np, "bus-width", &data);
1215 switch (data) {
1216 case 1:
1217 case 4:
1218 case 8:
1219 pdata->wires = data;
1220 break;
1221 default:
1222 pdata->wires = 1;
1223 dev_info(&pdev->dev, "Unsupported buswidth, defaulting to 1 bit\n");
1224 }
1225nodata:
1226 return pdata;
1227}
1228
1229static int __init davinci_mmcsd_probe(struct platform_device *pdev)
1230{
1231 struct davinci_mmc_config *pdata = NULL;
1175 struct mmc_davinci_host *host = NULL; 1232 struct mmc_davinci_host *host = NULL;
1176 struct mmc_host *mmc = NULL; 1233 struct mmc_host *mmc = NULL;
1177 struct resource *r, *mem = NULL; 1234 struct resource *r, *mem = NULL;
@@ -1179,7 +1236,11 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)
1179 size_t mem_size; 1236 size_t mem_size;
1180 const struct platform_device_id *id_entry; 1237 const struct platform_device_id *id_entry;
1181 1238
1182 /* REVISIT: when we're fully converted, fail if pdata is NULL */ 1239 pdata = mmc_parse_pdata(pdev);
1240 if (pdata == NULL) {
1241 dev_err(&pdev->dev, "Couldn't get platform data\n");
1242 return -ENOENT;
1243 }
1183 1244
1184 ret = -ENODEV; 1245 ret = -ENODEV;
1185 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1246 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1421,6 +1482,7 @@ static struct platform_driver davinci_mmcsd_driver = {
1421 .name = "davinci_mmc", 1482 .name = "davinci_mmc",
1422 .owner = THIS_MODULE, 1483 .owner = THIS_MODULE,
1423 .pm = davinci_mmcsd_pm_ops, 1484 .pm = davinci_mmcsd_pm_ops,
1485 .of_match_table = of_match_ptr(davinci_mmc_dt_ids),
1424 }, 1486 },
1425 .remove = __exit_p(davinci_mmcsd_remove), 1487 .remove = __exit_p(davinci_mmcsd_remove),
1426 .id_table = davinci_mmc_devtype, 1488 .id_table = davinci_mmc_devtype,