Skip to content

Commit

Permalink
mmc: pxa-mci: add DT bindings
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
  • Loading branch information
Daniel Mack authored and Chris Ball committed Sep 4, 2012
1 parent 75b53ae commit e6027b4
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Documentation/devicetree/bindings/mmc/pxa-mmc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
* PXA MMC drivers

Driver bindings for the PXA MCI (MMC/SDIO) interfaces

Required properties:
- compatible: Should be "marvell,pxa-mmc".
- vmmc-supply: A regulator for VMMC

Optional properties:
- marvell,detect-delay-ms: sets the detection delay timeout in ms.
- marvell,gpio-power: GPIO spec for the card power enable pin

This file documents differences between the core properties in mmc.txt
and the properties used by the pxa-mmc driver.

Examples:

mmc0: mmc@41100000 {
compatible = "marvell,pxa-mmc";
reg = <0x41100000 0x1000>;
interrupts = <23>;
cd-gpios = <&gpio 23 0>;
wp-gpios = <&gpio 24 0>;
};

52 changes: 52 additions & 0 deletions drivers/mmc/host/pxamci.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <linux/regulator/consumer.h>
#include <linux/gpio.h>
#include <linux/gfp.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>

#include <asm/sizes.h>

Expand Down Expand Up @@ -573,13 +576,61 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid)
return IRQ_HANDLED;
}

#ifdef CONFIG_OF
static const struct of_device_id pxa_mmc_dt_ids[] = {
{ .compatible = "marvell,pxa-mmc" },
{ }
};

MODULE_DEVICE_TABLE(of, pxa_mmc_dt_ids);

static int __devinit pxamci_of_init(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct pxamci_platform_data *pdata;
u32 tmp;

if (!np)
return 0;

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;

pdata->gpio_card_detect =
of_get_named_gpio(np, "cd-gpios", 0);
pdata->gpio_card_ro =
of_get_named_gpio(np, "wp-gpios", 0);

/* pxa-mmc specific */
pdata->gpio_power =
of_get_named_gpio(np, "pxa-mmc,gpio-power", 0);

if (of_property_read_u32(np, "pxa-mmc,detect-delay-ms", &tmp) == 0)
pdata->detect_delay_ms = tmp;

pdev->dev.platform_data = pdata;

return 0;
}
#else
static int __devinit pxamci_of_init(struct platform_device *pdev)
{
return 0;
}
#endif

static int pxamci_probe(struct platform_device *pdev)
{
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
struct resource *r, *dmarx, *dmatx;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;

ret = pxamci_of_init(pdev);
if (ret)
return ret;

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!r || irq < 0)
Expand Down Expand Up @@ -866,6 +917,7 @@ static struct platform_driver pxamci_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(pxa_mmc_dt_ids),
#ifdef CONFIG_PM
.pm = &pxamci_pm_ops,
#endif
Expand Down

0 comments on commit e6027b4

Please sign in to comment.