All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] atmel-mci device tree support
@ 2012-05-22 10:09 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre, plagnioj, devicetree-discuss

Hi,

This patch-set adds device tree support for atmel-mci.

Regards

Ludovic

v3:
- use cd-inverted instead of cd-invert to follow mmc common binding.
- don't assign a pointer to pdev->dev.platform.
- add mci controller nodes to other chips and boards.
- put all dts file changes together.

v2:
- squash patch v1 2/4 and 3/4.
- change atmci_get_of_slots to atmci_of_init and manage pdata allocation into
it.
- correct potential issue (e.g. having only one slot which is not slot0 into
the dt) about slots by adding a reg property corresponding to the slot id.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 0/3] atmel-mci device tree support
@ 2012-05-22 10:09 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

This patch-set adds device tree support for atmel-mci.

Regards

Ludovic

v3:
- use cd-inverted instead of cd-invert to follow mmc common binding.
- don't assign a pointer to pdev->dev.platform.
- add mci controller nodes to other chips and boards.
- put all dts file changes together.

v2:
- squash patch v1 2/4 and 3/4.
- change atmci_get_of_slots to atmci_of_init and manage pdata allocation into
it.
- correct potential issue (e.g. having only one slot which is not slot0 into
the dt) about slots by adding a reg property corresponding to the slot id.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 10:09 ` ludovic.desroches at atmel.com
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
 drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
 2 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt

diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
new file mode 100644
index 0000000..81c20cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
@@ -0,0 +1,67 @@
+* Atmel High Speed MultiMedia Card Interface
+
+This controller on atmel products provides an interface for MMC, SD and SDIO
+types of memory cards.
+
+1) MCI node
+
+Required properties:
+- compatible: no blank "atmel,hsmci"
+- reg: should contain HSMCI registers location and length
+- interrupts: should contain HSMCI interrupt number
+- #address-cells: should be one. The cell is the slot id.
+- #size-cells: should be zero.
+- at least one slot node
+
+The node contains child nodes for each slot that the platform uses
+
+Example MCI node:
+
+mmc0: mmc@f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	[ child node definitions...]
+};
+
+2) slot nodes
+
+Required properties:
+- reg: should contain the slot id.
+- bus-width: number of data lines connected to the controller
+
+Optional properties:
+- cd-gpios: specify GPIOs for card detection
+- cd-inverted: invert the value of external card detect gpio line
+- wp-gpios: specify GPIOs for write protection
+
+Example slot node:
+
+slot@0 {
+	reg = <0>;
+	bus-width = <4>;
+	cd-gpios = <&pioD 15 0>
+	cd-inverted;
+};
+
+Example full MCI node:
+mmc0: mmc@f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	slot@0 {
+		reg = <0>;
+		bus-width = <4>;
+		cd-gpios = <&pioD 15 0>
+		cd-inverted;
+	};
+	slot@1 {
+		reg = <1>;
+		bus-width = <4>;
+	};
+};
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 556d384..43f98fc 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -19,6 +19,9 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -493,6 +496,74 @@ err:
 	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
 }
 
+#if defined(CONFIG_OF)
+static const struct of_device_id atmci_dt_ids[] = {
+	{ .compatible = "atmel,hsmci" },
+	{ /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
+
+static struct mci_platform_data __devinit*
+atmci_of_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *cnp;
+	struct mci_platform_data *pdata;
+	unsigned int slot_id;
+	const __be32 *reg;
+
+	if (!np) {
+		dev_err(&pdev->dev, "device node not found\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	for_each_child_of_node(np, cnp) {
+		reg = of_get_property(cnp, "reg", NULL);
+		if (!reg) {
+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
+				 cnp->full_name);
+			continue;
+		}
+
+		slot_id = be32_to_cpu(reg[0]);
+
+		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
+			         ATMCI_MAX_NR_SLOTS);
+			break;
+		}
+
+		if (of_property_read_u32(cnp, "bus-width",
+		                         &pdata->slot[slot_id].bus_width))
+			pdata->slot[slot_id].bus_width = 1;
+
+		pdata->slot[slot_id].detect_pin =
+			of_get_named_gpio(cnp, "cd-gpios", 0);
+
+		if (of_find_property(cnp, "cd-inverted", NULL))
+			pdata->slot[slot_id].detect_is_active_high = true;
+
+		pdata->slot[slot_id].wp_pin =
+			of_get_named_gpio(cnp, "wp-gpios", 0);
+	}
+
+	return pdata;
+}
+#else /* CONFIG_OF */
+static inline struct mci_platform_data*
+atmci_of_init(struct platform_device *dev)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif
+
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
 {
 	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
@@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->sdc_reg = sdc_reg;
 	slot->sdio_irq = sdio_irq;
 
+	dev_dbg(&mmc->class_dev,
+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
+		"detect_is_active_high=%s, wp_pin=%d\n",
+		id, slot_data->bus_width, slot_data->detect_pin,
+		slot_data->detect_is_active_high ? "true" : "false",
+		slot_data->wp_pin);
+
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
 	mmc->f_max = host->bus_hz / 2;
@@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 	pdata = pdev->dev.platform_data;
-	if (!pdata)
-		return -ENXIO;
+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return -EINVAL;
+		}
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -2477,6 +2561,7 @@ static struct platform_driver atmci_driver = {
 	.driver		= {
 		.name		= "atmel_mci",
 		.pm		= ATMCI_PM_OPS,
+		.of_match_table	= of_match_ptr(atmci_dt_ids),
 	},
 };
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
 drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
 2 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt

diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
new file mode 100644
index 0000000..81c20cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
@@ -0,0 +1,67 @@
+* Atmel High Speed MultiMedia Card Interface
+
+This controller on atmel products provides an interface for MMC, SD and SDIO
+types of memory cards.
+
+1) MCI node
+
+Required properties:
+- compatible: no blank "atmel,hsmci"
+- reg: should contain HSMCI registers location and length
+- interrupts: should contain HSMCI interrupt number
+- #address-cells: should be one. The cell is the slot id.
+- #size-cells: should be zero.
+- at least one slot node
+
+The node contains child nodes for each slot that the platform uses
+
+Example MCI node:
+
+mmc0: mmc at f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	[ child node definitions...]
+};
+
+2) slot nodes
+
+Required properties:
+- reg: should contain the slot id.
+- bus-width: number of data lines connected to the controller
+
+Optional properties:
+- cd-gpios: specify GPIOs for card detection
+- cd-inverted: invert the value of external card detect gpio line
+- wp-gpios: specify GPIOs for write protection
+
+Example slot node:
+
+slot at 0 {
+	reg = <0>;
+	bus-width = <4>;
+	cd-gpios = <&pioD 15 0>
+	cd-inverted;
+};
+
+Example full MCI node:
+mmc0: mmc at f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	slot at 0 {
+		reg = <0>;
+		bus-width = <4>;
+		cd-gpios = <&pioD 15 0>
+		cd-inverted;
+	};
+	slot at 1 {
+		reg = <1>;
+		bus-width = <4>;
+	};
+};
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 556d384..43f98fc 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -19,6 +19,9 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -493,6 +496,74 @@ err:
 	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
 }
 
+#if defined(CONFIG_OF)
+static const struct of_device_id atmci_dt_ids[] = {
+	{ .compatible = "atmel,hsmci" },
+	{ /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
+
+static struct mci_platform_data __devinit*
+atmci_of_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *cnp;
+	struct mci_platform_data *pdata;
+	unsigned int slot_id;
+	const __be32 *reg;
+
+	if (!np) {
+		dev_err(&pdev->dev, "device node not found\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	for_each_child_of_node(np, cnp) {
+		reg = of_get_property(cnp, "reg", NULL);
+		if (!reg) {
+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
+				 cnp->full_name);
+			continue;
+		}
+
+		slot_id = be32_to_cpu(reg[0]);
+
+		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
+			         ATMCI_MAX_NR_SLOTS);
+			break;
+		}
+
+		if (of_property_read_u32(cnp, "bus-width",
+		                         &pdata->slot[slot_id].bus_width))
+			pdata->slot[slot_id].bus_width = 1;
+
+		pdata->slot[slot_id].detect_pin =
+			of_get_named_gpio(cnp, "cd-gpios", 0);
+
+		if (of_find_property(cnp, "cd-inverted", NULL))
+			pdata->slot[slot_id].detect_is_active_high = true;
+
+		pdata->slot[slot_id].wp_pin =
+			of_get_named_gpio(cnp, "wp-gpios", 0);
+	}
+
+	return pdata;
+}
+#else /* CONFIG_OF */
+static inline struct mci_platform_data*
+atmci_of_init(struct platform_device *dev)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif
+
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
 {
 	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
@@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->sdc_reg = sdc_reg;
 	slot->sdio_irq = sdio_irq;
 
+	dev_dbg(&mmc->class_dev,
+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
+		"detect_is_active_high=%s, wp_pin=%d\n",
+		id, slot_data->bus_width, slot_data->detect_pin,
+		slot_data->detect_is_active_high ? "true" : "false",
+		slot_data->wp_pin);
+
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
 	mmc->f_max = host->bus_hz / 2;
@@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 	pdata = pdev->dev.platform_data;
-	if (!pdata)
-		return -ENXIO;
+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return -EINVAL;
+		}
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -2477,6 +2561,7 @@ static struct platform_driver atmci_driver = {
 	.driver		= {
 		.name		= "atmel_mci",
 		.pm		= ATMCI_PM_OPS,
+		.of_match_table	= of_match_ptr(atmci_dt_ids),
 	},
 };
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 2/3] ARM: at91: add clocks for DT entries
  2012-05-22 10:09 ` ludovic.desroches at atmel.com
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add clocks to clock lookup table for DT entries.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/mach-at91/at91sam9260.c |    1 +
 arch/arm/mach-at91/at91sam9g45.c |    2 ++
 arch/arm/mach-at91/at91sam9x5.c  |    2 ++
 3 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 46f7742..c356471 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -218,6 +218,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index d222f83..0a2c662 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -235,6 +235,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 13c8cae..39cbef3 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 2/3] ARM: at91: add clocks for DT entries
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add clocks to clock lookup table for DT entries.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/mach-at91/at91sam9260.c |    1 +
 arch/arm/mach-at91/at91sam9g45.c |    2 ++
 arch/arm/mach-at91/at91sam9x5.c  |    2 ++
 3 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 46f7742..c356471 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -218,6 +218,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index d222f83..0a2c662 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -235,6 +235,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 13c8cae..39cbef3 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
  2012-05-22 10:09 ` ludovic.desroches at atmel.com
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add nodes for mci controllers.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
 arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
 5 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index 773ef48..6a28bfe 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -197,6 +197,18 @@
 				interrupts = <10 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc@fffa800 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffa800 0x600>;
+				interrupts = <9 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot@0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..dd94f4b 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,22 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc@f0008000 {
+				status = "okay";
+				slot@0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 15 0>;
+				};
+			};
+
+			mmc1: mmc@f000c000 {
+				status = "okay";
+				slot@0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 14 0>;
+				};
+			};
 		};
 
 		usb0: ohci@00600000 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index c804214..2922648 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -199,6 +199,30 @@
 				interrupts = <25 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc@fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot@0 {
+					reg = <0>;
+				};
+			};
+
+			mmc1: mmc@fffd0000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffd0000 0x600>;
+				interrupts = <29 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot@0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..bc4cb3c 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,23 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc@fff80000 {
+				status = "okay";
+				slot@0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 10 0>;
+				};
+			};
+
+			mmc1: mmc@fffd0000 {
+				status = "okay";
+				slot@0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 11 0>;
+					wp-gpios = <&pioD 29 0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index dd4ed74..d5999b2 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -190,6 +190,30 @@
 				interrupts = <27 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc@f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot@0 {
+					reg = <0>;
+				};
+			};
+
+			mmc1: mmc@f000c000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf000c000 0x600>;
+				interrupts = <26 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot@0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
@ 2012-05-22 10:09   ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-22 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add nodes for mci controllers.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
 arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
 5 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index 773ef48..6a28bfe 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -197,6 +197,18 @@
 				interrupts = <10 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc at fffa800 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffa800 0x600>;
+				interrupts = <9 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot at 0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..dd94f4b 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,22 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc at f0008000 {
+				status = "okay";
+				slot at 0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 15 0>;
+				};
+			};
+
+			mmc1: mmc at f000c000 {
+				status = "okay";
+				slot at 0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 14 0>;
+				};
+			};
 		};
 
 		usb0: ohci at 00600000 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index c804214..2922648 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -199,6 +199,30 @@
 				interrupts = <25 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc at fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot at 0 {
+					reg = <0>;
+				};
+			};
+
+			mmc1: mmc at fffd0000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffd0000 0x600>;
+				interrupts = <29 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot at 0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..bc4cb3c 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,23 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc at fff80000 {
+				status = "okay";
+				slot at 0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 10 0>;
+				};
+			};
+
+			mmc1: mmc at fffd0000 {
+				status = "okay";
+				slot at 0 {
+					bus-width = <4>;
+					cd-gpios = <&pioD 11 0>;
+					wp-gpios = <&pioD 29 0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index dd4ed74..d5999b2 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -190,6 +190,30 @@
 				interrupts = <27 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc at f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot at 0 {
+					reg = <0>;
+				};
+			};
+
+			mmc1: mmc at f000c000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf000c000 0x600>;
+				interrupts = <26 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				slot at 0 {
+					reg = <0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 12:55     ` Nicolas Ferre
  -1 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 12:55 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: linux-mmc, linux-arm-kernel, plagnioj, devicetree-discuss

On 05/22/2012 12:09 PM, ludovic.desroches@atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Looks neat!

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>  2 files changed, 154 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot@0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot@0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot@1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..43f98fc 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,74 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	unsigned int slot_id;
> +	const __be32 *reg;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		reg = of_get_property(cnp, "reg", NULL);
> +		if (!reg) {
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		slot_id = be32_to_cpu(reg[0]);
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		if (of_find_property(cnp, "cd-inverted", NULL))
> +			pdata->slot[slot_id].detect_is_active_high = true;
> +
> +		pdata->slot[slot_id].wp_pin =
> +			of_get_named_gpio(cnp, "wp-gpios", 0);
> +	}
> +
> +	return pdata;
> +}
> +#else /* CONFIG_OF */
> +static inline struct mci_platform_data*
> +atmci_of_init(struct platform_device *dev)
> +{
> +	return ERR_PTR(-EINVAL);
> +}
> +#endif
> +
>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>  {
>  	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	slot->sdc_reg = sdc_reg;
>  	slot->sdio_irq = sdio_irq;
>  
> +	dev_dbg(&mmc->class_dev,
> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> +		"detect_is_active_high=%s, wp_pin=%d\n",
> +		id, slot_data->bus_width, slot_data->detect_pin,
> +		slot_data->detect_is_active_high ? "true" : "false",
> +		slot_data->wp_pin);
> +
>  	mmc->ops = &atmci_ops;
>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>  	mmc->f_max = host->bus_hz / 2;
> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	if (!regs)
>  		return -ENXIO;
>  	pdata = pdev->dev.platform_data;
> -	if (!pdata)
> -		return -ENXIO;
> +	if (!pdata) {
> +		pdata = atmci_of_init(pdev);
> +		if (IS_ERR(pdata)) {
> +			dev_err(&pdev->dev, "platform data not available\n");
> +			return -EINVAL;
> +		}
> +	}
> +
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return irq;
> @@ -2477,6 +2561,7 @@ static struct platform_driver atmci_driver = {
>  	.driver		= {
>  		.name		= "atmel_mci",
>  		.pm		= ATMCI_PM_OPS,
> +		.of_match_table	= of_match_ptr(atmci_dt_ids),
>  	},
>  };
>  


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 12:55     ` Nicolas Ferre
  0 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 12:55 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/22/2012 12:09 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Looks neat!

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>  2 files changed, 154 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot at 0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot at 0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot at 1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..43f98fc 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,74 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	unsigned int slot_id;
> +	const __be32 *reg;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		reg = of_get_property(cnp, "reg", NULL);
> +		if (!reg) {
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		slot_id = be32_to_cpu(reg[0]);
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		if (of_find_property(cnp, "cd-inverted", NULL))
> +			pdata->slot[slot_id].detect_is_active_high = true;
> +
> +		pdata->slot[slot_id].wp_pin =
> +			of_get_named_gpio(cnp, "wp-gpios", 0);
> +	}
> +
> +	return pdata;
> +}
> +#else /* CONFIG_OF */
> +static inline struct mci_platform_data*
> +atmci_of_init(struct platform_device *dev)
> +{
> +	return ERR_PTR(-EINVAL);
> +}
> +#endif
> +
>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>  {
>  	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	slot->sdc_reg = sdc_reg;
>  	slot->sdio_irq = sdio_irq;
>  
> +	dev_dbg(&mmc->class_dev,
> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> +		"detect_is_active_high=%s, wp_pin=%d\n",
> +		id, slot_data->bus_width, slot_data->detect_pin,
> +		slot_data->detect_is_active_high ? "true" : "false",
> +		slot_data->wp_pin);
> +
>  	mmc->ops = &atmci_ops;
>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>  	mmc->f_max = host->bus_hz / 2;
> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	if (!regs)
>  		return -ENXIO;
>  	pdata = pdev->dev.platform_data;
> -	if (!pdata)
> -		return -ENXIO;
> +	if (!pdata) {
> +		pdata = atmci_of_init(pdev);
> +		if (IS_ERR(pdata)) {
> +			dev_err(&pdev->dev, "platform data not available\n");
> +			return -EINVAL;
> +		}
> +	}
> +
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return irq;
> @@ -2477,6 +2561,7 @@ static struct platform_driver atmci_driver = {
>  	.driver		= {
>  		.name		= "atmel_mci",
>  		.pm		= ATMCI_PM_OPS,
> +		.of_match_table	= of_match_ptr(atmci_dt_ids),
>  	},
>  };
>  


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 2/3] ARM: at91: add clocks for DT entries
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 12:56     ` Nicolas Ferre
  -1 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 12:56 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: linux-mmc, linux-arm-kernel, plagnioj, devicetree-discuss

On 05/22/2012 12:09 PM, ludovic.desroches@atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

This one will probably go through arm-soc git tree...

> ---
>  arch/arm/mach-at91/at91sam9260.c |    1 +
>  arch/arm/mach-at91/at91sam9g45.c |    2 ++
>  arch/arm/mach-at91/at91sam9x5.c  |    2 ++
>  3 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
> index 46f7742..c356471 100644
> --- a/arch/arm/mach-at91/at91sam9260.c
> +++ b/arch/arm/mach-at91/at91sam9260.c
> @@ -218,6 +218,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
>  	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
> index d222f83..0a2c662 100644
> --- a/arch/arm/mach-at91/at91sam9g45.c
> +++ b/arch/arm/mach-at91/at91sam9g45.c
> @@ -235,6 +235,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
>  	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
> index 13c8cae..39cbef3 100644
> --- a/arch/arm/mach-at91/at91sam9x5.c
> +++ b/arch/arm/mach-at91/at91sam9x5.c
> @@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 2/3] ARM: at91: add clocks for DT entries
@ 2012-05-22 12:56     ` Nicolas Ferre
  0 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 12:56 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/22/2012 12:09 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

This one will probably go through arm-soc git tree...

> ---
>  arch/arm/mach-at91/at91sam9260.c |    1 +
>  arch/arm/mach-at91/at91sam9g45.c |    2 ++
>  arch/arm/mach-at91/at91sam9x5.c  |    2 ++
>  3 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
> index 46f7742..c356471 100644
> --- a/arch/arm/mach-at91/at91sam9260.c
> +++ b/arch/arm/mach-at91/at91sam9260.c
> @@ -218,6 +218,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
>  	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
> index d222f83..0a2c662 100644
> --- a/arch/arm/mach-at91/at91sam9g45.c
> +++ b/arch/arm/mach-at91/at91sam9g45.c
> @@ -235,6 +235,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
>  	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
> index 13c8cae..39cbef3 100644
> --- a/arch/arm/mach-at91/at91sam9x5.c
> +++ b/arch/arm/mach-at91/at91sam9x5.c
> @@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
> +	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 13:11     ` Nicolas Ferre
  -1 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 13:11 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: linux-mmc, linux-arm-kernel, plagnioj, devicetree-discuss

On 05/22/2012 12:09 PM, ludovic.desroches@atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add nodes for mci controllers.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++

Maybe this one will have to be reworked on top of new ADC declarations.
Maybe also take into account the device tree support for sam9260: it is
linked with 9g20 support...

otherwise, once rebased you can add my:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

(and I think that this one also should go through arm-soc)

>  arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>  arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>  arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>  5 files changed, 93 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
> index 773ef48..6a28bfe 100644
> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
> @@ -197,6 +197,18 @@
>  				interrupts = <10 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc@fffa800 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffa800 0x600>;
> +				interrupts = <9 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
> index 7829a4d..dd94f4b 100644
> --- a/arch/arm/boot/dts/at91sam9g25ek.dts
> +++ b/arch/arm/boot/dts/at91sam9g25ek.dts
> @@ -32,6 +32,22 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			mmc0: mmc@f0008000 {
> +				status = "okay";
> +				slot@0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 15 0>;
> +				};
> +			};
> +
> +			mmc1: mmc@f000c000 {
> +				status = "okay";
> +				slot@0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 14 0>;
> +				};
> +			};
>  		};
>  
>  		usb0: ohci@00600000 {
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
> index c804214..2922648 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -199,6 +199,30 @@
>  				interrupts = <25 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc@fff80000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfff80000 0x600>;
> +				interrupts = <11 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
> +
> +			mmc1: mmc@fffd0000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffd0000 0x600>;
> +				interrupts = <29 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> index a3633bd..bc4cb3c 100644
> --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
> +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> @@ -46,6 +46,23 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			mmc0: mmc@fff80000 {
> +				status = "okay";
> +				slot@0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 10 0>;
> +				};
> +			};
> +
> +			mmc1: mmc@fffd0000 {
> +				status = "okay";
> +				slot@0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 11 0>;
> +					wp-gpios = <&pioD 29 0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
> index dd4ed74..d5999b2 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -190,6 +190,30 @@
>  				interrupts = <27 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc@f0008000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xf0008000 0x600>;
> +				interrupts = <12 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
> +
> +			mmc1: mmc@f000c000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xf000c000 0x600>;
> +				interrupts = <26 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
@ 2012-05-22 13:11     ` Nicolas Ferre
  0 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/22/2012 12:09 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add nodes for mci controllers.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++

Maybe this one will have to be reworked on top of new ADC declarations.
Maybe also take into account the device tree support for sam9260: it is
linked with 9g20 support...

otherwise, once rebased you can add my:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

(and I think that this one also should go through arm-soc)

>  arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>  arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>  arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>  5 files changed, 93 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
> index 773ef48..6a28bfe 100644
> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
> @@ -197,6 +197,18 @@
>  				interrupts = <10 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc at fffa800 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffa800 0x600>;
> +				interrupts = <9 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
> index 7829a4d..dd94f4b 100644
> --- a/arch/arm/boot/dts/at91sam9g25ek.dts
> +++ b/arch/arm/boot/dts/at91sam9g25ek.dts
> @@ -32,6 +32,22 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			mmc0: mmc at f0008000 {
> +				status = "okay";
> +				slot at 0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 15 0>;
> +				};
> +			};
> +
> +			mmc1: mmc at f000c000 {
> +				status = "okay";
> +				slot at 0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 14 0>;
> +				};
> +			};
>  		};
>  
>  		usb0: ohci at 00600000 {
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
> index c804214..2922648 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -199,6 +199,30 @@
>  				interrupts = <25 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc at fff80000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfff80000 0x600>;
> +				interrupts = <11 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
> +
> +			mmc1: mmc at fffd0000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffd0000 0x600>;
> +				interrupts = <29 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> index a3633bd..bc4cb3c 100644
> --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
> +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> @@ -46,6 +46,23 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			mmc0: mmc at fff80000 {
> +				status = "okay";
> +				slot at 0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 10 0>;
> +				};
> +			};
> +
> +			mmc1: mmc at fffd0000 {
> +				status = "okay";
> +				slot at 0 {
> +					bus-width = <4>;
> +					cd-gpios = <&pioD 11 0>;
> +					wp-gpios = <&pioD 29 0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
> index dd4ed74..d5999b2 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -190,6 +190,30 @@
>  				interrupts = <27 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc at f0008000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xf0008000 0x600>;
> +				interrupts = <12 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
> +
> +			mmc1: mmc at f000c000 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xf000c000 0x600>;
> +				interrupts = <26 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 14:08     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:08 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: nicolas.ferre, devicetree-discuss, linux-mmc, linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>  2 files changed, 154 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
why this

no need you can use the third field and OF_GPIO_ACTIVE_LOW
as done on ohci-at91.c

> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot@0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot@0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot@1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..43f98fc 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,74 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	unsigned int slot_id;
> +	const __be32 *reg;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		reg = of_get_property(cnp, "reg", NULL);
> +		if (!reg) {
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		slot_id = be32_to_cpu(reg[0]);
read_u32
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		if (of_find_property(cnp, "cd-inverted", NULL))
> +			pdata->slot[slot_id].detect_is_active_high = true;
> +
> +		pdata->slot[slot_id].wp_pin =
> +			of_get_named_gpio(cnp, "wp-gpios", 0);
> +	}
> +
> +	return pdata;
> +}
> +#else /* CONFIG_OF */
> +static inline struct mci_platform_data*
> +atmci_of_init(struct platform_device *dev)
> +{
> +	return ERR_PTR(-EINVAL);
> +}
> +#endif
> +
>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>  {
>  	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	slot->sdc_reg = sdc_reg;
>  	slot->sdio_irq = sdio_irq;
>  
> +	dev_dbg(&mmc->class_dev,
> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> +		"detect_is_active_high=%s, wp_pin=%d\n",
> +		id, slot_data->bus_width, slot_data->detect_pin,
> +		slot_data->detect_is_active_high ? "true" : "false",
> +		slot_data->wp_pin);
> +
>  	mmc->ops = &atmci_ops;
>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>  	mmc->f_max = host->bus_hz / 2;
> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	if (!regs)
>  		return -ENXIO;
>  	pdata = pdev->dev.platform_data;
> -	if (!pdata)
> -		return -ENXIO;
check the node and then check the return

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 14:08     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:08 UTC (permalink / raw)
  To: linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>  2 files changed, 154 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
why this

no need you can use the third field and OF_GPIO_ACTIVE_LOW
as done on ohci-at91.c

> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot at 0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot at 0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot at 1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..43f98fc 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,74 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	unsigned int slot_id;
> +	const __be32 *reg;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		reg = of_get_property(cnp, "reg", NULL);
> +		if (!reg) {
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		slot_id = be32_to_cpu(reg[0]);
read_u32
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		if (of_find_property(cnp, "cd-inverted", NULL))
> +			pdata->slot[slot_id].detect_is_active_high = true;
> +
> +		pdata->slot[slot_id].wp_pin =
> +			of_get_named_gpio(cnp, "wp-gpios", 0);
> +	}
> +
> +	return pdata;
> +}
> +#else /* CONFIG_OF */
> +static inline struct mci_platform_data*
> +atmci_of_init(struct platform_device *dev)
> +{
> +	return ERR_PTR(-EINVAL);
> +}
> +#endif
> +
>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>  {
>  	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	slot->sdc_reg = sdc_reg;
>  	slot->sdio_irq = sdio_irq;
>  
> +	dev_dbg(&mmc->class_dev,
> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> +		"detect_is_active_high=%s, wp_pin=%d\n",
> +		id, slot_data->bus_width, slot_data->detect_pin,
> +		slot_data->detect_is_active_high ? "true" : "false",
> +		slot_data->wp_pin);
> +
>  	mmc->ops = &atmci_ops;
>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>  	mmc->f_max = host->bus_hz / 2;
> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	if (!regs)
>  		return -ENXIO;
>  	pdata = pdev->dev.platform_data;
> -	if (!pdata)
> -		return -ENXIO;
check the node and then check the return

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 2/3] ARM: at91: add clocks for DT entries
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 14:11     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:11 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: nicolas.ferre, devicetree-discuss, linux-mmc, linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 2/3] ARM: at91: add clocks for DT entries
@ 2012-05-22 14:11     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:11 UTC (permalink / raw)
  To: linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-22 14:13     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:13 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: nicolas.ferre, devicetree-discuss, linux-mmc, linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add nodes for mci controllers.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
>  arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>  arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>  arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>  5 files changed, 93 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
> index 773ef48..6a28bfe 100644
> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
> @@ -197,6 +197,18 @@
>  				interrupts = <10 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc@fffa800 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffa800 0x600>;
> +				interrupts = <9 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot@0 {
> +					reg = <0>;
> +				};
> +			};
this need to be in 9260.dtsi

if you add the board too plese add all of them
or seperate the commits

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
@ 2012-05-22 14:13     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 14:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add nodes for mci controllers.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
>  arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>  arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>  arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>  5 files changed, 93 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
> index 773ef48..6a28bfe 100644
> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
> @@ -197,6 +197,18 @@
>  				interrupts = <10 4>;
>  				status = "disabled";
>  			};
> +
> +			mmc0: mmc at fffa800 {
> +				compatible = "atmel,hsmci";
> +				reg = <0xfffa800 0x600>;
> +				interrupts = <9 4>;
> +				status = "disabled";
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				slot at 0 {
> +					reg = <0>;
> +				};
> +			};
this need to be in 9260.dtsi

if you add the board too plese add all of them
or seperate the commits

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
  2012-05-22 14:13     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-05-22 14:41         ` ludovic.desroches
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 14:41 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Le 05/22/2012 04:13 PM, Jean-Christophe PLAGNIOL-VILLARD a écrit :
> On 12:09 Tue 22 May     , ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org wrote:
>> From: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>>
>> Add nodes for mci controllers.
>>
>> Signed-off-by: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>> ---
>>   arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
>>   arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>>   arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>>   arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>>   arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>>   5 files changed, 93 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
>> index 773ef48..6a28bfe 100644
>> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
>> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
>> @@ -197,6 +197,18 @@
>>   				interrupts =<10 4>;
>>   				status = "disabled";
>>   			};
>> +
>> +			mmc0: mmc@fffa800 {
>> +				compatible = "atmel,hsmci";
>> +				reg =<0xfffa800 0x600>;
>> +				interrupts =<9 4>;
>> +				status = "disabled";
>> +				#address-cells =<1>;
>> +				#size-cells =<0>;
>> +				slot@0 {
>> +					reg =<0>;
>> +				};
>> +			};
> this need to be in 9260.dtsi
>
> if you add the board too plese add all of them
> or seperate the commits
>

I based it on 3.4 so 9260.dtsi was not present. Nicolas gave me a new 
branch with it so I will add mmc node to 9260.

Regards

Ludovic

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
@ 2012-05-22 14:41         ` ludovic.desroches
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 14:41 UTC (permalink / raw)
  To: linux-arm-kernel

Le 05/22/2012 04:13 PM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
> On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
>> From: Ludovic Desroches<ludovic.desroches@atmel.com>
>>
>> Add nodes for mci controllers.
>>
>> Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com>
>> ---
>>   arch/arm/boot/dts/at91sam9g20.dtsi     |   12 ++++++++++++
>>   arch/arm/boot/dts/at91sam9g25ek.dts    |   16 ++++++++++++++++
>>   arch/arm/boot/dts/at91sam9g45.dtsi     |   24 ++++++++++++++++++++++++
>>   arch/arm/boot/dts/at91sam9m10g45ek.dts |   17 +++++++++++++++++
>>   arch/arm/boot/dts/at91sam9x5.dtsi      |   24 ++++++++++++++++++++++++
>>   5 files changed, 93 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
>> index 773ef48..6a28bfe 100644
>> --- a/arch/arm/boot/dts/at91sam9g20.dtsi
>> +++ b/arch/arm/boot/dts/at91sam9g20.dtsi
>> @@ -197,6 +197,18 @@
>>   				interrupts =<10 4>;
>>   				status = "disabled";
>>   			};
>> +
>> +			mmc0: mmc at fffa800 {
>> +				compatible = "atmel,hsmci";
>> +				reg =<0xfffa800 0x600>;
>> +				interrupts =<9 4>;
>> +				status = "disabled";
>> +				#address-cells =<1>;
>> +				#size-cells =<0>;
>> +				slot at 0 {
>> +					reg =<0>;
>> +				};
>> +			};
> this need to be in 9260.dtsi
>
> if you add the board too plese add all of them
> or seperate the commits
>

I based it on 3.4 so 9260.dtsi was not present. Nicolas gave me a new 
branch with it so I will add mmc node to 9260.

Regards

Ludovic

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 14:08     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-05-22 14:48         ` ludovic.desroches
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 14:48 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a écrit :
> On 12:09 Tue 22 May     , ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org wrote:
>> From: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>>
>> Signed-off-by: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>> ---
>>   .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>>   drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>>   2 files changed, 154 insertions(+), 2 deletions(-)
>>   create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>> new file mode 100644
>> index 0000000..81c20cc
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>> @@ -0,0 +1,67 @@
>> +* Atmel High Speed MultiMedia Card Interface
>> +
>> +This controller on atmel products provides an interface for MMC, SD and SDIO
>> +types of memory cards.
>> +
>> +1) MCI node
>> +
>> +Required properties:
>> +- compatible: no blank "atmel,hsmci"
>> +- reg: should contain HSMCI registers location and length
>> +- interrupts: should contain HSMCI interrupt number
>> +- #address-cells: should be one. The cell is the slot id.
>> +- #size-cells: should be zero.
>> +- at least one slot node
>> +
>> +The node contains child nodes for each slot that the platform uses
>> +
>> +Example MCI node:
>> +
>> +mmc0: mmc@f0008000 {
>> +	compatible = "atmel,hsmci";
>> +	reg =<0xf0008000 0x600>;
>> +	interrupts =<12 4>;
>> +	#address-cells =<1>;
>> +	#size-cells =<0>;
>> +
>> +	[ child node definitions...]
>> +};
>> +
>> +2) slot nodes
>> +
>> +Required properties:
>> +- reg: should contain the slot id.
>> +- bus-width: number of data lines connected to the controller
>> +
>> +Optional properties:
>> +- cd-gpios: specify GPIOs for card detection
>> +- cd-inverted: invert the value of external card detect gpio line
> why this
>
> no need you can use the third field and OF_GPIO_ACTIVE_LOW
> as done on ohci-at91.c
>

It's a property from the common mmc binding so why not using it?

>> +- wp-gpios: specify GPIOs for write protection
>> +
>> +Example slot node:
>> +
>> +slot@0 {
>> +	reg =<0>;
>> +	bus-width =<4>;
>> +	cd-gpios =<&pioD 15 0>
>> +	cd-inverted;
>> +};
>> +
>> +Example full MCI node:
>> +mmc0: mmc@f0008000 {
>> +	compatible = "atmel,hsmci";
>> +	reg =<0xf0008000 0x600>;
>> +	interrupts =<12 4>;
>> +	#address-cells =<1>;
>> +	#size-cells =<0>;
>> +	slot@0 {
>> +		reg =<0>;
>> +		bus-width =<4>;
>> +		cd-gpios =<&pioD 15 0>
>> +		cd-inverted;
>> +	};
>> +	slot@1 {
>> +		reg =<1>;
>> +		bus-width =<4>;
>> +	};
>> +};
>> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
>> index 556d384..43f98fc 100644
>> --- a/drivers/mmc/host/atmel-mci.c
>> +++ b/drivers/mmc/host/atmel-mci.c
>> @@ -19,6 +19,9 @@
>>   #include<linux/interrupt.h>
>>   #include<linux/ioport.h>
>>   #include<linux/module.h>
>> +#include<linux/of.h>
>> +#include<linux/of_device.h>
>> +#include<linux/of_gpio.h>
>>   #include<linux/platform_device.h>
>>   #include<linux/scatterlist.h>
>>   #include<linux/seq_file.h>
>> @@ -493,6 +496,74 @@ err:
>>   	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>>   }
>>
>> +#if defined(CONFIG_OF)
>> +static const struct of_device_id atmci_dt_ids[] = {
>> +	{ .compatible = "atmel,hsmci" },
>> +	{ /* sentinel */ }
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
>> +
>> +static struct mci_platform_data __devinit*
>> +atmci_of_init(struct platform_device *pdev)
>> +{
>> +	struct device_node *np = pdev->dev.of_node;
>> +	struct device_node *cnp;
>> +	struct mci_platform_data *pdata;
>> +	unsigned int slot_id;
>> +	const __be32 *reg;
>> +
>> +	if (!np) {
>> +		dev_err(&pdev->dev, "device node not found\n");
>> +		return ERR_PTR(-EINVAL);
>> +	}
>> +
>> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>> +	if (!pdata) {
>> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
>> +		return ERR_PTR(-ENOMEM);
>> +	}
>> +
>> +	for_each_child_of_node(np, cnp) {
>> +		reg = of_get_property(cnp, "reg", NULL);
>> +		if (!reg) {
>> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
>> +				 cnp->full_name);
>> +			continue;
>> +		}
>> +
>> +		slot_id = be32_to_cpu(reg[0]);
> read_u32

ok

>> +
>> +		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
>> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
>> +			         ATMCI_MAX_NR_SLOTS);
>> +			break;
>> +		}
>> +
>> +		if (of_property_read_u32(cnp, "bus-width",
>> +		&pdata->slot[slot_id].bus_width))
>> +			pdata->slot[slot_id].bus_width = 1;
>> +
>> +		pdata->slot[slot_id].detect_pin =
>> +			of_get_named_gpio(cnp, "cd-gpios", 0);
>> +
>> +		if (of_find_property(cnp, "cd-inverted", NULL))
>> +			pdata->slot[slot_id].detect_is_active_high = true;
>> +
>> +		pdata->slot[slot_id].wp_pin =
>> +			of_get_named_gpio(cnp, "wp-gpios", 0);
>> +	}
>> +
>> +	return pdata;
>> +}
>> +#else /* CONFIG_OF */
>> +static inline struct mci_platform_data*
>> +atmci_of_init(struct platform_device *dev)
>> +{
>> +	return ERR_PTR(-EINVAL);
>> +}
>> +#endif
>> +
>>   static inline unsigned int atmci_get_version(struct atmel_mci *host)
>>   {
>>   	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
>> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>>   	slot->sdc_reg = sdc_reg;
>>   	slot->sdio_irq = sdio_irq;
>>
>> +	dev_dbg(&mmc->class_dev,
>> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
>> +		"detect_is_active_high=%s, wp_pin=%d\n",
>> +		id, slot_data->bus_width, slot_data->detect_pin,
>> +		slot_data->detect_is_active_high ? "true" : "false",
>> +		slot_data->wp_pin);
>> +
>>   	mmc->ops =&atmci_ops;
>>   	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>>   	mmc->f_max = host->bus_hz / 2;
>> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>>   	if (!regs)
>>   		return -ENXIO;
>>   	pdata = pdev->dev.platform_data;
>> -	if (!pdata)
>> -		return -ENXIO;
> check the node and then check the return
>

Sorry but what do you mean? The node is checked into atmci_of_init and 
the return is checked:

+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return -EINVAL;
+		}
+	}


Regards

Ludovic

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 14:48         ` ludovic.desroches
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-22 14:48 UTC (permalink / raw)
  To: linux-arm-kernel

Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
> On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
>> From: Ludovic Desroches<ludovic.desroches@atmel.com>
>>
>> Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com>
>> ---
>>   .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>>   drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>>   2 files changed, 154 insertions(+), 2 deletions(-)
>>   create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>> new file mode 100644
>> index 0000000..81c20cc
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>> @@ -0,0 +1,67 @@
>> +* Atmel High Speed MultiMedia Card Interface
>> +
>> +This controller on atmel products provides an interface for MMC, SD and SDIO
>> +types of memory cards.
>> +
>> +1) MCI node
>> +
>> +Required properties:
>> +- compatible: no blank "atmel,hsmci"
>> +- reg: should contain HSMCI registers location and length
>> +- interrupts: should contain HSMCI interrupt number
>> +- #address-cells: should be one. The cell is the slot id.
>> +- #size-cells: should be zero.
>> +- at least one slot node
>> +
>> +The node contains child nodes for each slot that the platform uses
>> +
>> +Example MCI node:
>> +
>> +mmc0: mmc at f0008000 {
>> +	compatible = "atmel,hsmci";
>> +	reg =<0xf0008000 0x600>;
>> +	interrupts =<12 4>;
>> +	#address-cells =<1>;
>> +	#size-cells =<0>;
>> +
>> +	[ child node definitions...]
>> +};
>> +
>> +2) slot nodes
>> +
>> +Required properties:
>> +- reg: should contain the slot id.
>> +- bus-width: number of data lines connected to the controller
>> +
>> +Optional properties:
>> +- cd-gpios: specify GPIOs for card detection
>> +- cd-inverted: invert the value of external card detect gpio line
> why this
>
> no need you can use the third field and OF_GPIO_ACTIVE_LOW
> as done on ohci-at91.c
>

It's a property from the common mmc binding so why not using it?

>> +- wp-gpios: specify GPIOs for write protection
>> +
>> +Example slot node:
>> +
>> +slot at 0 {
>> +	reg =<0>;
>> +	bus-width =<4>;
>> +	cd-gpios =<&pioD 15 0>
>> +	cd-inverted;
>> +};
>> +
>> +Example full MCI node:
>> +mmc0: mmc at f0008000 {
>> +	compatible = "atmel,hsmci";
>> +	reg =<0xf0008000 0x600>;
>> +	interrupts =<12 4>;
>> +	#address-cells =<1>;
>> +	#size-cells =<0>;
>> +	slot at 0 {
>> +		reg =<0>;
>> +		bus-width =<4>;
>> +		cd-gpios =<&pioD 15 0>
>> +		cd-inverted;
>> +	};
>> +	slot at 1 {
>> +		reg =<1>;
>> +		bus-width =<4>;
>> +	};
>> +};
>> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
>> index 556d384..43f98fc 100644
>> --- a/drivers/mmc/host/atmel-mci.c
>> +++ b/drivers/mmc/host/atmel-mci.c
>> @@ -19,6 +19,9 @@
>>   #include<linux/interrupt.h>
>>   #include<linux/ioport.h>
>>   #include<linux/module.h>
>> +#include<linux/of.h>
>> +#include<linux/of_device.h>
>> +#include<linux/of_gpio.h>
>>   #include<linux/platform_device.h>
>>   #include<linux/scatterlist.h>
>>   #include<linux/seq_file.h>
>> @@ -493,6 +496,74 @@ err:
>>   	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>>   }
>>
>> +#if defined(CONFIG_OF)
>> +static const struct of_device_id atmci_dt_ids[] = {
>> +	{ .compatible = "atmel,hsmci" },
>> +	{ /* sentinel */ }
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
>> +
>> +static struct mci_platform_data __devinit*
>> +atmci_of_init(struct platform_device *pdev)
>> +{
>> +	struct device_node *np = pdev->dev.of_node;
>> +	struct device_node *cnp;
>> +	struct mci_platform_data *pdata;
>> +	unsigned int slot_id;
>> +	const __be32 *reg;
>> +
>> +	if (!np) {
>> +		dev_err(&pdev->dev, "device node not found\n");
>> +		return ERR_PTR(-EINVAL);
>> +	}
>> +
>> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>> +	if (!pdata) {
>> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
>> +		return ERR_PTR(-ENOMEM);
>> +	}
>> +
>> +	for_each_child_of_node(np, cnp) {
>> +		reg = of_get_property(cnp, "reg", NULL);
>> +		if (!reg) {
>> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
>> +				 cnp->full_name);
>> +			continue;
>> +		}
>> +
>> +		slot_id = be32_to_cpu(reg[0]);
> read_u32

ok

>> +
>> +		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
>> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
>> +			         ATMCI_MAX_NR_SLOTS);
>> +			break;
>> +		}
>> +
>> +		if (of_property_read_u32(cnp, "bus-width",
>> +		&pdata->slot[slot_id].bus_width))
>> +			pdata->slot[slot_id].bus_width = 1;
>> +
>> +		pdata->slot[slot_id].detect_pin =
>> +			of_get_named_gpio(cnp, "cd-gpios", 0);
>> +
>> +		if (of_find_property(cnp, "cd-inverted", NULL))
>> +			pdata->slot[slot_id].detect_is_active_high = true;
>> +
>> +		pdata->slot[slot_id].wp_pin =
>> +			of_get_named_gpio(cnp, "wp-gpios", 0);
>> +	}
>> +
>> +	return pdata;
>> +}
>> +#else /* CONFIG_OF */
>> +static inline struct mci_platform_data*
>> +atmci_of_init(struct platform_device *dev)
>> +{
>> +	return ERR_PTR(-EINVAL);
>> +}
>> +#endif
>> +
>>   static inline unsigned int atmci_get_version(struct atmel_mci *host)
>>   {
>>   	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
>> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>>   	slot->sdc_reg = sdc_reg;
>>   	slot->sdio_irq = sdio_irq;
>>
>> +	dev_dbg(&mmc->class_dev,
>> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
>> +		"detect_is_active_high=%s, wp_pin=%d\n",
>> +		id, slot_data->bus_width, slot_data->detect_pin,
>> +		slot_data->detect_is_active_high ? "true" : "false",
>> +		slot_data->wp_pin);
>> +
>>   	mmc->ops =&atmci_ops;
>>   	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>>   	mmc->f_max = host->bus_hz / 2;
>> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>>   	if (!regs)
>>   		return -ENXIO;
>>   	pdata = pdev->dev.platform_data;
>> -	if (!pdata)
>> -		return -ENXIO;
> check the node and then check the return
>

Sorry but what do you mean? The node is checked into atmci_of_init and 
the return is checked:

+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return -EINVAL;
+		}
+	}


Regards

Ludovic

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 14:48         ` ludovic.desroches
@ 2012-05-22 15:10             ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 15:10 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 16:48 Tue 22 May     , ludovic.desroches wrote:
> Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a écrit :
> >On 12:09 Tue 22 May     , ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org wrote:
> >>From: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> >>
> >>Signed-off-by: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> >>---
> >>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
> >>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
> >>  2 files changed, 154 insertions(+), 2 deletions(-)
> >>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>
> >>diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>new file mode 100644
> >>index 0000000..81c20cc
> >>--- /dev/null
> >>+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>@@ -0,0 +1,67 @@
> >>+* Atmel High Speed MultiMedia Card Interface
> >>+
> >>+This controller on atmel products provides an interface for MMC, SD and SDIO
> >>+types of memory cards.
> >>+
> >>+1) MCI node
> >>+
> >>+Required properties:
> >>+- compatible: no blank "atmel,hsmci"
> >>+- reg: should contain HSMCI registers location and length
> >>+- interrupts: should contain HSMCI interrupt number
> >>+- #address-cells: should be one. The cell is the slot id.
> >>+- #size-cells: should be zero.
> >>+- at least one slot node
> >>+
> >>+The node contains child nodes for each slot that the platform uses
> >>+
> >>+Example MCI node:
> >>+
> >>+mmc0: mmc@f0008000 {
> >>+	compatible = "atmel,hsmci";
> >>+	reg =<0xf0008000 0x600>;
> >>+	interrupts =<12 4>;
> >>+	#address-cells =<1>;
> >>+	#size-cells =<0>;
> >>+
> >>+	[ child node definitions...]
> >>+};
> >>+
> >>+2) slot nodes
> >>+
> >>+Required properties:
> >>+- reg: should contain the slot id.
> >>+- bus-width: number of data lines connected to the controller
> >>+
> >>+Optional properties:
> >>+- cd-gpios: specify GPIOs for card detection
> >>+- cd-inverted: invert the value of external card detect gpio line
> >why this
> >
> >no need you can use the third field and OF_GPIO_ACTIVE_LOW
> >as done on ohci-at91.c
> >
> 
> It's a property from the common mmc binding so why not using it?
gpio alread carry this information mmc common bindingd need to use is

btw for bool property you need to use of_property_read_bool
> 
> >>+- wp-gpios: specify GPIOs for write protection
> >>+
> >>+Example slot node:
> >>+
> >>+slot@0 {
> >>+	reg =<0>;
> >>+	bus-width =<4>;
> >>+	cd-gpios =<&pioD 15 0>
> >>+	cd-inverted;
> >>+};
> >>+
> >>+Example full MCI node:
> >>+mmc0: mmc@f0008000 {
> >>+	compatible = "atmel,hsmci";
> >>+	reg =<0xf0008000 0x600>;
> >>+	interrupts =<12 4>;
> >>+	#address-cells =<1>;
> >>+	#size-cells =<0>;
> >>+	slot@0 {
> >>+		reg =<0>;
> >>+		bus-width =<4>;
> >>+		cd-gpios =<&pioD 15 0>
> >>+		cd-inverted;
> >>+	};
> >>+	slot@1 {
> >>+		reg =<1>;
> >>+		bus-width =<4>;
> >>+	};
> >>+};
> >>diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> >>index 556d384..43f98fc 100644
> >>--- a/drivers/mmc/host/atmel-mci.c
> >>+++ b/drivers/mmc/host/atmel-mci.c
> >>@@ -19,6 +19,9 @@
> >>  #include<linux/interrupt.h>
> >>  #include<linux/ioport.h>
> >>  #include<linux/module.h>
> >>+#include<linux/of.h>
> >>+#include<linux/of_device.h>
> >>+#include<linux/of_gpio.h>
> >>  #include<linux/platform_device.h>
> >>  #include<linux/scatterlist.h>
> >>  #include<linux/seq_file.h>
> >>@@ -493,6 +496,74 @@ err:
> >>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
> >>  }
> >>
> >>+#if defined(CONFIG_OF)
> >>+static const struct of_device_id atmci_dt_ids[] = {
> >>+	{ .compatible = "atmel,hsmci" },
> >>+	{ /* sentinel */ }
> >>+};
> >>+
> >>+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> >>+
> >>+static struct mci_platform_data __devinit*
> >>+atmci_of_init(struct platform_device *pdev)
> >>+{
> >>+	struct device_node *np = pdev->dev.of_node;
> >>+	struct device_node *cnp;
> >>+	struct mci_platform_data *pdata;
> >>+	unsigned int slot_id;
> >>+	const __be32 *reg;
> >>+
> >>+	if (!np) {
> >>+		dev_err(&pdev->dev, "device node not found\n");
> >>+		return ERR_PTR(-EINVAL);
> >>+	}
> >>+
> >>+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> >>+	if (!pdata) {
> >>+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> >>+		return ERR_PTR(-ENOMEM);
> >>+	}
> >>+
> >>+	for_each_child_of_node(np, cnp) {
> >>+		reg = of_get_property(cnp, "reg", NULL);
> >>+		if (!reg) {
> >>+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> >>+				 cnp->full_name);
> >>+			continue;
> >>+		}
> >>+
> >>+		slot_id = be32_to_cpu(reg[0]);
> >read_u32
> 
> ok
> 
> >>+
> >>+		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
> >>+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> >>+			         ATMCI_MAX_NR_SLOTS);
> >>+			break;
> >>+		}
> >>+
> >>+		if (of_property_read_u32(cnp, "bus-width",
> >>+		&pdata->slot[slot_id].bus_width))
> >>+			pdata->slot[slot_id].bus_width = 1;
> >>+
> >>+		pdata->slot[slot_id].detect_pin =
> >>+			of_get_named_gpio(cnp, "cd-gpios", 0);
> >>+
> >>+		if (of_find_property(cnp, "cd-inverted", NULL))
> >>+			pdata->slot[slot_id].detect_is_active_high = true;
> >>+
> >>+		pdata->slot[slot_id].wp_pin =
> >>+			of_get_named_gpio(cnp, "wp-gpios", 0);
> >>+	}
> >>+
> >>+	return pdata;
> >>+}
> >>+#else /* CONFIG_OF */
> >>+static inline struct mci_platform_data*
> >>+atmci_of_init(struct platform_device *dev)
> >>+{
> >>+	return ERR_PTR(-EINVAL);
> >>+}
> >>+#endif
> >>+
> >>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
> >>  {
> >>  	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
> >>@@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
> >>  	slot->sdc_reg = sdc_reg;
> >>  	slot->sdio_irq = sdio_irq;
> >>
> >>+	dev_dbg(&mmc->class_dev,
> >>+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> >>+		"detect_is_active_high=%s, wp_pin=%d\n",
> >>+		id, slot_data->bus_width, slot_data->detect_pin,
> >>+		slot_data->detect_is_active_high ? "true" : "false",
> >>+		slot_data->wp_pin);
> >>+
> >>  	mmc->ops =&atmci_ops;
> >>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
> >>  	mmc->f_max = host->bus_hz / 2;
> >>@@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
> >>  	if (!regs)
> >>  		return -ENXIO;
> >>  	pdata = pdev->dev.platform_data;
> >>-	if (!pdata)
> >>-		return -ENXIO;
> >check the node and then check the return
> >
> 
> Sorry but what do you mean? The node is checked into atmci_of_init
> and the return is checked:
> 
> +	if (!pdata) {
> +		pdata = atmci_of_init(pdev);
> +		if (IS_ERR(pdata)) {
> +			dev_err(&pdev->dev, "platform data not available\n");
> +			return -EINVAL;
and here return the reall error btw
> +		}
> +	}
you just call the of_init if you have a node

Best Regards,
J.
> 
> 
> Regards
> 
> Ludovic
> 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 15:10             ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-22 15:10 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:48 Tue 22 May     , ludovic.desroches wrote:
> Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
> >On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
> >>From: Ludovic Desroches<ludovic.desroches@atmel.com>
> >>
> >>Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com>
> >>---
> >>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
> >>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
> >>  2 files changed, 154 insertions(+), 2 deletions(-)
> >>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>
> >>diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>new file mode 100644
> >>index 0000000..81c20cc
> >>--- /dev/null
> >>+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> >>@@ -0,0 +1,67 @@
> >>+* Atmel High Speed MultiMedia Card Interface
> >>+
> >>+This controller on atmel products provides an interface for MMC, SD and SDIO
> >>+types of memory cards.
> >>+
> >>+1) MCI node
> >>+
> >>+Required properties:
> >>+- compatible: no blank "atmel,hsmci"
> >>+- reg: should contain HSMCI registers location and length
> >>+- interrupts: should contain HSMCI interrupt number
> >>+- #address-cells: should be one. The cell is the slot id.
> >>+- #size-cells: should be zero.
> >>+- at least one slot node
> >>+
> >>+The node contains child nodes for each slot that the platform uses
> >>+
> >>+Example MCI node:
> >>+
> >>+mmc0: mmc at f0008000 {
> >>+	compatible = "atmel,hsmci";
> >>+	reg =<0xf0008000 0x600>;
> >>+	interrupts =<12 4>;
> >>+	#address-cells =<1>;
> >>+	#size-cells =<0>;
> >>+
> >>+	[ child node definitions...]
> >>+};
> >>+
> >>+2) slot nodes
> >>+
> >>+Required properties:
> >>+- reg: should contain the slot id.
> >>+- bus-width: number of data lines connected to the controller
> >>+
> >>+Optional properties:
> >>+- cd-gpios: specify GPIOs for card detection
> >>+- cd-inverted: invert the value of external card detect gpio line
> >why this
> >
> >no need you can use the third field and OF_GPIO_ACTIVE_LOW
> >as done on ohci-at91.c
> >
> 
> It's a property from the common mmc binding so why not using it?
gpio alread carry this information mmc common bindingd need to use is

btw for bool property you need to use of_property_read_bool
> 
> >>+- wp-gpios: specify GPIOs for write protection
> >>+
> >>+Example slot node:
> >>+
> >>+slot at 0 {
> >>+	reg =<0>;
> >>+	bus-width =<4>;
> >>+	cd-gpios =<&pioD 15 0>
> >>+	cd-inverted;
> >>+};
> >>+
> >>+Example full MCI node:
> >>+mmc0: mmc at f0008000 {
> >>+	compatible = "atmel,hsmci";
> >>+	reg =<0xf0008000 0x600>;
> >>+	interrupts =<12 4>;
> >>+	#address-cells =<1>;
> >>+	#size-cells =<0>;
> >>+	slot at 0 {
> >>+		reg =<0>;
> >>+		bus-width =<4>;
> >>+		cd-gpios =<&pioD 15 0>
> >>+		cd-inverted;
> >>+	};
> >>+	slot at 1 {
> >>+		reg =<1>;
> >>+		bus-width =<4>;
> >>+	};
> >>+};
> >>diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> >>index 556d384..43f98fc 100644
> >>--- a/drivers/mmc/host/atmel-mci.c
> >>+++ b/drivers/mmc/host/atmel-mci.c
> >>@@ -19,6 +19,9 @@
> >>  #include<linux/interrupt.h>
> >>  #include<linux/ioport.h>
> >>  #include<linux/module.h>
> >>+#include<linux/of.h>
> >>+#include<linux/of_device.h>
> >>+#include<linux/of_gpio.h>
> >>  #include<linux/platform_device.h>
> >>  #include<linux/scatterlist.h>
> >>  #include<linux/seq_file.h>
> >>@@ -493,6 +496,74 @@ err:
> >>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
> >>  }
> >>
> >>+#if defined(CONFIG_OF)
> >>+static const struct of_device_id atmci_dt_ids[] = {
> >>+	{ .compatible = "atmel,hsmci" },
> >>+	{ /* sentinel */ }
> >>+};
> >>+
> >>+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> >>+
> >>+static struct mci_platform_data __devinit*
> >>+atmci_of_init(struct platform_device *pdev)
> >>+{
> >>+	struct device_node *np = pdev->dev.of_node;
> >>+	struct device_node *cnp;
> >>+	struct mci_platform_data *pdata;
> >>+	unsigned int slot_id;
> >>+	const __be32 *reg;
> >>+
> >>+	if (!np) {
> >>+		dev_err(&pdev->dev, "device node not found\n");
> >>+		return ERR_PTR(-EINVAL);
> >>+	}
> >>+
> >>+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> >>+	if (!pdata) {
> >>+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> >>+		return ERR_PTR(-ENOMEM);
> >>+	}
> >>+
> >>+	for_each_child_of_node(np, cnp) {
> >>+		reg = of_get_property(cnp, "reg", NULL);
> >>+		if (!reg) {
> >>+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> >>+				 cnp->full_name);
> >>+			continue;
> >>+		}
> >>+
> >>+		slot_id = be32_to_cpu(reg[0]);
> >read_u32
> 
> ok
> 
> >>+
> >>+		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
> >>+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> >>+			         ATMCI_MAX_NR_SLOTS);
> >>+			break;
> >>+		}
> >>+
> >>+		if (of_property_read_u32(cnp, "bus-width",
> >>+		&pdata->slot[slot_id].bus_width))
> >>+			pdata->slot[slot_id].bus_width = 1;
> >>+
> >>+		pdata->slot[slot_id].detect_pin =
> >>+			of_get_named_gpio(cnp, "cd-gpios", 0);
> >>+
> >>+		if (of_find_property(cnp, "cd-inverted", NULL))
> >>+			pdata->slot[slot_id].detect_is_active_high = true;
> >>+
> >>+		pdata->slot[slot_id].wp_pin =
> >>+			of_get_named_gpio(cnp, "wp-gpios", 0);
> >>+	}
> >>+
> >>+	return pdata;
> >>+}
> >>+#else /* CONFIG_OF */
> >>+static inline struct mci_platform_data*
> >>+atmci_of_init(struct platform_device *dev)
> >>+{
> >>+	return ERR_PTR(-EINVAL);
> >>+}
> >>+#endif
> >>+
> >>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
> >>  {
> >>  	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
> >>@@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
> >>  	slot->sdc_reg = sdc_reg;
> >>  	slot->sdio_irq = sdio_irq;
> >>
> >>+	dev_dbg(&mmc->class_dev,
> >>+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
> >>+		"detect_is_active_high=%s, wp_pin=%d\n",
> >>+		id, slot_data->bus_width, slot_data->detect_pin,
> >>+		slot_data->detect_is_active_high ? "true" : "false",
> >>+		slot_data->wp_pin);
> >>+
> >>  	mmc->ops =&atmci_ops;
> >>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
> >>  	mmc->f_max = host->bus_hz / 2;
> >>@@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
> >>  	if (!regs)
> >>  		return -ENXIO;
> >>  	pdata = pdev->dev.platform_data;
> >>-	if (!pdata)
> >>-		return -ENXIO;
> >check the node and then check the return
> >
> 
> Sorry but what do you mean? The node is checked into atmci_of_init
> and the return is checked:
> 
> +	if (!pdata) {
> +		pdata = atmci_of_init(pdev);
> +		if (IS_ERR(pdata)) {
> +			dev_err(&pdev->dev, "platform data not available\n");
> +			return -EINVAL;
and here return the reall error btw
> +		}
> +	}
you just call the of_init if you have a node

Best Regards,
J.
> 
> 
> Regards
> 
> Ludovic
> 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 15:10             ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-05-22 15:18                 ` Nicolas Ferre
  -1 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 15:18 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 05/22/2012 05:10 PM, Jean-Christophe PLAGNIOL-VILLARD :
> On 16:48 Tue 22 May     , ludovic.desroches wrote:
>> Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a écrit :
>>> On 12:09 Tue 22 May     , ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org wrote:
>>>> From: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>>>>
>>>> Signed-off-by: Ludovic Desroches<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>>>> ---
>>>>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>>>>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>>>>  2 files changed, 154 insertions(+), 2 deletions(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>> new file mode 100644
>>>> index 0000000..81c20cc
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>> @@ -0,0 +1,67 @@
>>>> +* Atmel High Speed MultiMedia Card Interface
>>>> +
>>>> +This controller on atmel products provides an interface for MMC, SD and SDIO
>>>> +types of memory cards.
>>>> +
>>>> +1) MCI node
>>>> +
>>>> +Required properties:
>>>> +- compatible: no blank "atmel,hsmci"
>>>> +- reg: should contain HSMCI registers location and length
>>>> +- interrupts: should contain HSMCI interrupt number
>>>> +- #address-cells: should be one. The cell is the slot id.
>>>> +- #size-cells: should be zero.
>>>> +- at least one slot node
>>>> +
>>>> +The node contains child nodes for each slot that the platform uses
>>>> +
>>>> +Example MCI node:
>>>> +
>>>> +mmc0: mmc@f0008000 {
>>>> +	compatible = "atmel,hsmci";
>>>> +	reg =<0xf0008000 0x600>;
>>>> +	interrupts =<12 4>;
>>>> +	#address-cells =<1>;
>>>> +	#size-cells =<0>;
>>>> +
>>>> +	[ child node definitions...]
>>>> +};
>>>> +
>>>> +2) slot nodes
>>>> +
>>>> +Required properties:
>>>> +- reg: should contain the slot id.
>>>> +- bus-width: number of data lines connected to the controller
>>>> +
>>>> +Optional properties:
>>>> +- cd-gpios: specify GPIOs for card detection
>>>> +- cd-inverted: invert the value of external card detect gpio line
>>> why this
>>>
>>> no need you can use the third field and OF_GPIO_ACTIVE_LOW
>>> as done on ohci-at91.c
>>>
>>
>> It's a property from the common mmc binding so why not using it?
> gpio alread carry this information mmc common bindingd need to use is

Discussion seem ongoing about common mmc binding. What you describe
above has been proposed but not adopted. So, until it reaches a
consensus, we keep what is described in current binding.


> btw for bool property you need to use of_property_read_bool
>>
>>>> +- wp-gpios: specify GPIOs for write protection
>>>> +
>>>> +Example slot node:
>>>> +
>>>> +slot@0 {
>>>> +	reg =<0>;
>>>> +	bus-width =<4>;
>>>> +	cd-gpios =<&pioD 15 0>
>>>> +	cd-inverted;
>>>> +};
>>>> +
>>>> +Example full MCI node:
>>>> +mmc0: mmc@f0008000 {
>>>> +	compatible = "atmel,hsmci";
>>>> +	reg =<0xf0008000 0x600>;
>>>> +	interrupts =<12 4>;
>>>> +	#address-cells =<1>;
>>>> +	#size-cells =<0>;
>>>> +	slot@0 {
>>>> +		reg =<0>;
>>>> +		bus-width =<4>;
>>>> +		cd-gpios =<&pioD 15 0>
>>>> +		cd-inverted;
>>>> +	};
>>>> +	slot@1 {
>>>> +		reg =<1>;
>>>> +		bus-width =<4>;
>>>> +	};
>>>> +};
>>>> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
>>>> index 556d384..43f98fc 100644
>>>> --- a/drivers/mmc/host/atmel-mci.c
>>>> +++ b/drivers/mmc/host/atmel-mci.c
>>>> @@ -19,6 +19,9 @@
>>>>  #include<linux/interrupt.h>
>>>>  #include<linux/ioport.h>
>>>>  #include<linux/module.h>
>>>> +#include<linux/of.h>
>>>> +#include<linux/of_device.h>
>>>> +#include<linux/of_gpio.h>
>>>>  #include<linux/platform_device.h>
>>>>  #include<linux/scatterlist.h>
>>>>  #include<linux/seq_file.h>
>>>> @@ -493,6 +496,74 @@ err:
>>>>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>>>>  }
>>>>
>>>> +#if defined(CONFIG_OF)
>>>> +static const struct of_device_id atmci_dt_ids[] = {
>>>> +	{ .compatible = "atmel,hsmci" },
>>>> +	{ /* sentinel */ }
>>>> +};
>>>> +
>>>> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
>>>> +
>>>> +static struct mci_platform_data __devinit*
>>>> +atmci_of_init(struct platform_device *pdev)
>>>> +{
>>>> +	struct device_node *np = pdev->dev.of_node;
>>>> +	struct device_node *cnp;
>>>> +	struct mci_platform_data *pdata;
>>>> +	unsigned int slot_id;
>>>> +	const __be32 *reg;
>>>> +
>>>> +	if (!np) {
>>>> +		dev_err(&pdev->dev, "device node not found\n");
>>>> +		return ERR_PTR(-EINVAL);
>>>> +	}
>>>> +
>>>> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>>>> +	if (!pdata) {
>>>> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
>>>> +		return ERR_PTR(-ENOMEM);
>>>> +	}
>>>> +
>>>> +	for_each_child_of_node(np, cnp) {
>>>> +		reg = of_get_property(cnp, "reg", NULL);
>>>> +		if (!reg) {
>>>> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
>>>> +				 cnp->full_name);
>>>> +			continue;
>>>> +		}
>>>> +
>>>> +		slot_id = be32_to_cpu(reg[0]);
>>> read_u32
>>
>> ok
>>
>>>> +
>>>> +		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
>>>> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
>>>> +			         ATMCI_MAX_NR_SLOTS);
>>>> +			break;
>>>> +		}
>>>> +
>>>> +		if (of_property_read_u32(cnp, "bus-width",
>>>> +		&pdata->slot[slot_id].bus_width))
>>>> +			pdata->slot[slot_id].bus_width = 1;
>>>> +
>>>> +		pdata->slot[slot_id].detect_pin =
>>>> +			of_get_named_gpio(cnp, "cd-gpios", 0);
>>>> +
>>>> +		if (of_find_property(cnp, "cd-inverted", NULL))
>>>> +			pdata->slot[slot_id].detect_is_active_high = true;
>>>> +
>>>> +		pdata->slot[slot_id].wp_pin =
>>>> +			of_get_named_gpio(cnp, "wp-gpios", 0);
>>>> +	}
>>>> +
>>>> +	return pdata;
>>>> +}
>>>> +#else /* CONFIG_OF */
>>>> +static inline struct mci_platform_data*
>>>> +atmci_of_init(struct platform_device *dev)
>>>> +{
>>>> +	return ERR_PTR(-EINVAL);
>>>> +}
>>>> +#endif
>>>> +
>>>>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>>>>  {
>>>>  	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
>>>> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>>>>  	slot->sdc_reg = sdc_reg;
>>>>  	slot->sdio_irq = sdio_irq;
>>>>
>>>> +	dev_dbg(&mmc->class_dev,
>>>> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
>>>> +		"detect_is_active_high=%s, wp_pin=%d\n",
>>>> +		id, slot_data->bus_width, slot_data->detect_pin,
>>>> +		slot_data->detect_is_active_high ? "true" : "false",
>>>> +		slot_data->wp_pin);
>>>> +
>>>>  	mmc->ops =&atmci_ops;
>>>>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>>>>  	mmc->f_max = host->bus_hz / 2;
>>>> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>>>>  	if (!regs)
>>>>  		return -ENXIO;
>>>>  	pdata = pdev->dev.platform_data;
>>>> -	if (!pdata)
>>>> -		return -ENXIO;
>>> check the node and then check the return
>>>
>>
>> Sorry but what do you mean? The node is checked into atmci_of_init
>> and the return is checked:
>>
>> +	if (!pdata) {
>> +		pdata = atmci_of_init(pdev);
>> +		if (IS_ERR(pdata)) {
>> +			dev_err(&pdev->dev, "platform data not available\n");
>> +			return -EINVAL;
> and here return the reall error btw
>> +		}
>> +	}
> you just call the of_init if you have a node

Well, this seems simple and elegant to me.

Bye,
-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-22 15:18                 ` Nicolas Ferre
  0 siblings, 0 replies; 40+ messages in thread
From: Nicolas Ferre @ 2012-05-22 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/22/2012 05:10 PM, Jean-Christophe PLAGNIOL-VILLARD :
> On 16:48 Tue 22 May     , ludovic.desroches wrote:
>> Le 05/22/2012 04:08 PM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
>>> On 12:09 Tue 22 May     , ludovic.desroches at atmel.com wrote:
>>>> From: Ludovic Desroches<ludovic.desroches@atmel.com>
>>>>
>>>> Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com>
>>>> ---
>>>>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>>>>  drivers/mmc/host/atmel-mci.c                       |   89 +++++++++++++++++++-
>>>>  2 files changed, 154 insertions(+), 2 deletions(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>> new file mode 100644
>>>> index 0000000..81c20cc
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
>>>> @@ -0,0 +1,67 @@
>>>> +* Atmel High Speed MultiMedia Card Interface
>>>> +
>>>> +This controller on atmel products provides an interface for MMC, SD and SDIO
>>>> +types of memory cards.
>>>> +
>>>> +1) MCI node
>>>> +
>>>> +Required properties:
>>>> +- compatible: no blank "atmel,hsmci"
>>>> +- reg: should contain HSMCI registers location and length
>>>> +- interrupts: should contain HSMCI interrupt number
>>>> +- #address-cells: should be one. The cell is the slot id.
>>>> +- #size-cells: should be zero.
>>>> +- at least one slot node
>>>> +
>>>> +The node contains child nodes for each slot that the platform uses
>>>> +
>>>> +Example MCI node:
>>>> +
>>>> +mmc0: mmc at f0008000 {
>>>> +	compatible = "atmel,hsmci";
>>>> +	reg =<0xf0008000 0x600>;
>>>> +	interrupts =<12 4>;
>>>> +	#address-cells =<1>;
>>>> +	#size-cells =<0>;
>>>> +
>>>> +	[ child node definitions...]
>>>> +};
>>>> +
>>>> +2) slot nodes
>>>> +
>>>> +Required properties:
>>>> +- reg: should contain the slot id.
>>>> +- bus-width: number of data lines connected to the controller
>>>> +
>>>> +Optional properties:
>>>> +- cd-gpios: specify GPIOs for card detection
>>>> +- cd-inverted: invert the value of external card detect gpio line
>>> why this
>>>
>>> no need you can use the third field and OF_GPIO_ACTIVE_LOW
>>> as done on ohci-at91.c
>>>
>>
>> It's a property from the common mmc binding so why not using it?
> gpio alread carry this information mmc common bindingd need to use is

Discussion seem ongoing about common mmc binding. What you describe
above has been proposed but not adopted. So, until it reaches a
consensus, we keep what is described in current binding.


> btw for bool property you need to use of_property_read_bool
>>
>>>> +- wp-gpios: specify GPIOs for write protection
>>>> +
>>>> +Example slot node:
>>>> +
>>>> +slot at 0 {
>>>> +	reg =<0>;
>>>> +	bus-width =<4>;
>>>> +	cd-gpios =<&pioD 15 0>
>>>> +	cd-inverted;
>>>> +};
>>>> +
>>>> +Example full MCI node:
>>>> +mmc0: mmc at f0008000 {
>>>> +	compatible = "atmel,hsmci";
>>>> +	reg =<0xf0008000 0x600>;
>>>> +	interrupts =<12 4>;
>>>> +	#address-cells =<1>;
>>>> +	#size-cells =<0>;
>>>> +	slot at 0 {
>>>> +		reg =<0>;
>>>> +		bus-width =<4>;
>>>> +		cd-gpios =<&pioD 15 0>
>>>> +		cd-inverted;
>>>> +	};
>>>> +	slot at 1 {
>>>> +		reg =<1>;
>>>> +		bus-width =<4>;
>>>> +	};
>>>> +};
>>>> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
>>>> index 556d384..43f98fc 100644
>>>> --- a/drivers/mmc/host/atmel-mci.c
>>>> +++ b/drivers/mmc/host/atmel-mci.c
>>>> @@ -19,6 +19,9 @@
>>>>  #include<linux/interrupt.h>
>>>>  #include<linux/ioport.h>
>>>>  #include<linux/module.h>
>>>> +#include<linux/of.h>
>>>> +#include<linux/of_device.h>
>>>> +#include<linux/of_gpio.h>
>>>>  #include<linux/platform_device.h>
>>>>  #include<linux/scatterlist.h>
>>>>  #include<linux/seq_file.h>
>>>> @@ -493,6 +496,74 @@ err:
>>>>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>>>>  }
>>>>
>>>> +#if defined(CONFIG_OF)
>>>> +static const struct of_device_id atmci_dt_ids[] = {
>>>> +	{ .compatible = "atmel,hsmci" },
>>>> +	{ /* sentinel */ }
>>>> +};
>>>> +
>>>> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
>>>> +
>>>> +static struct mci_platform_data __devinit*
>>>> +atmci_of_init(struct platform_device *pdev)
>>>> +{
>>>> +	struct device_node *np = pdev->dev.of_node;
>>>> +	struct device_node *cnp;
>>>> +	struct mci_platform_data *pdata;
>>>> +	unsigned int slot_id;
>>>> +	const __be32 *reg;
>>>> +
>>>> +	if (!np) {
>>>> +		dev_err(&pdev->dev, "device node not found\n");
>>>> +		return ERR_PTR(-EINVAL);
>>>> +	}
>>>> +
>>>> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>>>> +	if (!pdata) {
>>>> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
>>>> +		return ERR_PTR(-ENOMEM);
>>>> +	}
>>>> +
>>>> +	for_each_child_of_node(np, cnp) {
>>>> +		reg = of_get_property(cnp, "reg", NULL);
>>>> +		if (!reg) {
>>>> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
>>>> +				 cnp->full_name);
>>>> +			continue;
>>>> +		}
>>>> +
>>>> +		slot_id = be32_to_cpu(reg[0]);
>>> read_u32
>>
>> ok
>>
>>>> +
>>>> +		if (slot_id>  (ATMCI_MAX_NR_SLOTS-1)) {
>>>> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
>>>> +			         ATMCI_MAX_NR_SLOTS);
>>>> +			break;
>>>> +		}
>>>> +
>>>> +		if (of_property_read_u32(cnp, "bus-width",
>>>> +		&pdata->slot[slot_id].bus_width))
>>>> +			pdata->slot[slot_id].bus_width = 1;
>>>> +
>>>> +		pdata->slot[slot_id].detect_pin =
>>>> +			of_get_named_gpio(cnp, "cd-gpios", 0);
>>>> +
>>>> +		if (of_find_property(cnp, "cd-inverted", NULL))
>>>> +			pdata->slot[slot_id].detect_is_active_high = true;
>>>> +
>>>> +		pdata->slot[slot_id].wp_pin =
>>>> +			of_get_named_gpio(cnp, "wp-gpios", 0);
>>>> +	}
>>>> +
>>>> +	return pdata;
>>>> +}
>>>> +#else /* CONFIG_OF */
>>>> +static inline struct mci_platform_data*
>>>> +atmci_of_init(struct platform_device *dev)
>>>> +{
>>>> +	return ERR_PTR(-EINVAL);
>>>> +}
>>>> +#endif
>>>> +
>>>>  static inline unsigned int atmci_get_version(struct atmel_mci *host)
>>>>  {
>>>>  	return atmci_readl(host, ATMCI_VERSION)&  0x00000fff;
>>>> @@ -2038,6 +2109,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>>>>  	slot->sdc_reg = sdc_reg;
>>>>  	slot->sdio_irq = sdio_irq;
>>>>
>>>> +	dev_dbg(&mmc->class_dev,
>>>> +	        "slot[%u]: bus_width=%u, detect_pin=%d, "
>>>> +		"detect_is_active_high=%s, wp_pin=%d\n",
>>>> +		id, slot_data->bus_width, slot_data->detect_pin,
>>>> +		slot_data->detect_is_active_high ? "true" : "false",
>>>> +		slot_data->wp_pin);
>>>> +
>>>>  	mmc->ops =&atmci_ops;
>>>>  	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
>>>>  	mmc->f_max = host->bus_hz / 2;
>>>> @@ -2258,8 +2336,14 @@ static int __init atmci_probe(struct platform_device *pdev)
>>>>  	if (!regs)
>>>>  		return -ENXIO;
>>>>  	pdata = pdev->dev.platform_data;
>>>> -	if (!pdata)
>>>> -		return -ENXIO;
>>> check the node and then check the return
>>>
>>
>> Sorry but what do you mean? The node is checked into atmci_of_init
>> and the return is checked:
>>
>> +	if (!pdata) {
>> +		pdata = atmci_of_init(pdev);
>> +		if (IS_ERR(pdata)) {
>> +			dev_err(&pdev->dev, "platform data not available\n");
>> +			return -EINVAL;
> and here return the reall error btw
>> +		}
>> +	}
> you just call the of_init if you have a node

Well, this seems simple and elegant to me.

Bye,
-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 1/3] mmc: atmel-mci: add device tree support
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-23  7:23     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-23  7:23 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
 drivers/mmc/host/atmel-mci.c                       |   87 +++++++++++++++++++-
 2 files changed, 152 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt

diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
new file mode 100644
index 0000000..81c20cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
@@ -0,0 +1,67 @@
+* Atmel High Speed MultiMedia Card Interface
+
+This controller on atmel products provides an interface for MMC, SD and SDIO
+types of memory cards.
+
+1) MCI node
+
+Required properties:
+- compatible: no blank "atmel,hsmci"
+- reg: should contain HSMCI registers location and length
+- interrupts: should contain HSMCI interrupt number
+- #address-cells: should be one. The cell is the slot id.
+- #size-cells: should be zero.
+- at least one slot node
+
+The node contains child nodes for each slot that the platform uses
+
+Example MCI node:
+
+mmc0: mmc@f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	[ child node definitions...]
+};
+
+2) slot nodes
+
+Required properties:
+- reg: should contain the slot id.
+- bus-width: number of data lines connected to the controller
+
+Optional properties:
+- cd-gpios: specify GPIOs for card detection
+- cd-inverted: invert the value of external card detect gpio line
+- wp-gpios: specify GPIOs for write protection
+
+Example slot node:
+
+slot@0 {
+	reg = <0>;
+	bus-width = <4>;
+	cd-gpios = <&pioD 15 0>
+	cd-inverted;
+};
+
+Example full MCI node:
+mmc0: mmc@f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	slot@0 {
+		reg = <0>;
+		bus-width = <4>;
+		cd-gpios = <&pioD 15 0>
+		cd-inverted;
+	};
+	slot@1 {
+		reg = <1>;
+		bus-width = <4>;
+	};
+};
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 556d384..1842dc7 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -19,6 +19,9 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -493,6 +496,72 @@ err:
 	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
 }
 
+#if defined(CONFIG_OF)
+static const struct of_device_id atmci_dt_ids[] = {
+	{ .compatible = "atmel,hsmci" },
+	{ /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
+
+static struct mci_platform_data __devinit*
+atmci_of_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *cnp;
+	struct mci_platform_data *pdata;
+	u32 slot_id;
+	int ret;
+
+	if (!np) {
+		dev_err(&pdev->dev, "device node not found\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	for_each_child_of_node(np, cnp) {
+		ret = of_property_read_u32(cnp, "reg", &slot_id);
+		if (ret) {
+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
+				 cnp->full_name);
+			continue;
+		}
+
+		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
+			         ATMCI_MAX_NR_SLOTS);
+			break;
+		}
+
+		if (of_property_read_u32(cnp, "bus-width",
+		                         &pdata->slot[slot_id].bus_width))
+			pdata->slot[slot_id].bus_width = 1;
+
+		pdata->slot[slot_id].detect_pin =
+			of_get_named_gpio(cnp, "cd-gpios", 0);
+
+		pdata->slot[slot_id].detect_is_active_high =
+			of_property_read_bool(cnp, "cd-inverted");
+
+		pdata->slot[slot_id].wp_pin =
+			of_get_named_gpio(cnp, "wp-gpios", 0);
+	}
+
+	return pdata;
+}
+#else /* CONFIG_OF */
+static inline struct mci_platform_data*
+atmci_of_init(struct platform_device *dev)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif
+
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
 {
 	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
@@ -2038,6 +2107,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->sdc_reg = sdc_reg;
 	slot->sdio_irq = sdio_irq;
 
+	dev_dbg(&mmc->class_dev,
+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
+		"detect_is_active_high=%s, wp_pin=%d\n",
+		id, slot_data->bus_width, slot_data->detect_pin,
+		slot_data->detect_is_active_high ? "true" : "false",
+		slot_data->wp_pin);
+
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
 	mmc->f_max = host->bus_hz / 2;
@@ -2258,8 +2334,14 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 	pdata = pdev->dev.platform_data;
-	if (!pdata)
-		return -ENXIO;
+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return PTR_ERR(pdata);
+		}
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -2477,6 +2559,7 @@ static struct platform_driver atmci_driver = {
 	.driver		= {
 		.name		= "atmel_mci",
 		.pm		= ATMCI_PM_OPS,
+		.of_match_table	= of_match_ptr(atmci_dt_ids),
 	},
 };
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-23  7:23     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-23  7:23 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
 drivers/mmc/host/atmel-mci.c                       |   87 +++++++++++++++++++-
 2 files changed, 152 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt

diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
new file mode 100644
index 0000000..81c20cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
@@ -0,0 +1,67 @@
+* Atmel High Speed MultiMedia Card Interface
+
+This controller on atmel products provides an interface for MMC, SD and SDIO
+types of memory cards.
+
+1) MCI node
+
+Required properties:
+- compatible: no blank "atmel,hsmci"
+- reg: should contain HSMCI registers location and length
+- interrupts: should contain HSMCI interrupt number
+- #address-cells: should be one. The cell is the slot id.
+- #size-cells: should be zero.
+- at least one slot node
+
+The node contains child nodes for each slot that the platform uses
+
+Example MCI node:
+
+mmc0: mmc at f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	[ child node definitions...]
+};
+
+2) slot nodes
+
+Required properties:
+- reg: should contain the slot id.
+- bus-width: number of data lines connected to the controller
+
+Optional properties:
+- cd-gpios: specify GPIOs for card detection
+- cd-inverted: invert the value of external card detect gpio line
+- wp-gpios: specify GPIOs for write protection
+
+Example slot node:
+
+slot at 0 {
+	reg = <0>;
+	bus-width = <4>;
+	cd-gpios = <&pioD 15 0>
+	cd-inverted;
+};
+
+Example full MCI node:
+mmc0: mmc at f0008000 {
+	compatible = "atmel,hsmci";
+	reg = <0xf0008000 0x600>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	slot at 0 {
+		reg = <0>;
+		bus-width = <4>;
+		cd-gpios = <&pioD 15 0>
+		cd-inverted;
+	};
+	slot at 1 {
+		reg = <1>;
+		bus-width = <4>;
+	};
+};
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 556d384..1842dc7 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -19,6 +19,9 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -493,6 +496,72 @@ err:
 	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
 }
 
+#if defined(CONFIG_OF)
+static const struct of_device_id atmci_dt_ids[] = {
+	{ .compatible = "atmel,hsmci" },
+	{ /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmci_dt_ids);
+
+static struct mci_platform_data __devinit*
+atmci_of_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *cnp;
+	struct mci_platform_data *pdata;
+	u32 slot_id;
+	int ret;
+
+	if (!np) {
+		dev_err(&pdev->dev, "device node not found\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	for_each_child_of_node(np, cnp) {
+		ret = of_property_read_u32(cnp, "reg", &slot_id);
+		if (ret) {
+			dev_warn(&pdev->dev, "reg property is missing for %s\n",
+				 cnp->full_name);
+			continue;
+		}
+
+		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
+			dev_warn(&pdev->dev, "can't have more than %d slots\n",
+			         ATMCI_MAX_NR_SLOTS);
+			break;
+		}
+
+		if (of_property_read_u32(cnp, "bus-width",
+		                         &pdata->slot[slot_id].bus_width))
+			pdata->slot[slot_id].bus_width = 1;
+
+		pdata->slot[slot_id].detect_pin =
+			of_get_named_gpio(cnp, "cd-gpios", 0);
+
+		pdata->slot[slot_id].detect_is_active_high =
+			of_property_read_bool(cnp, "cd-inverted");
+
+		pdata->slot[slot_id].wp_pin =
+			of_get_named_gpio(cnp, "wp-gpios", 0);
+	}
+
+	return pdata;
+}
+#else /* CONFIG_OF */
+static inline struct mci_platform_data*
+atmci_of_init(struct platform_device *dev)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif
+
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
 {
 	return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
@@ -2038,6 +2107,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->sdc_reg = sdc_reg;
 	slot->sdio_irq = sdio_irq;
 
+	dev_dbg(&mmc->class_dev,
+	        "slot[%u]: bus_width=%u, detect_pin=%d, "
+		"detect_is_active_high=%s, wp_pin=%d\n",
+		id, slot_data->bus_width, slot_data->detect_pin,
+		slot_data->detect_is_active_high ? "true" : "false",
+		slot_data->wp_pin);
+
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
 	mmc->f_max = host->bus_hz / 2;
@@ -2258,8 +2334,14 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 	pdata = pdev->dev.platform_data;
-	if (!pdata)
-		return -ENXIO;
+	if (!pdata) {
+		pdata = atmci_of_init(pdev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "platform data not available\n");
+			return PTR_ERR(pdata);
+		}
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -2477,6 +2559,7 @@ static struct platform_driver atmci_driver = {
 	.driver		= {
 		.name		= "atmel_mci",
 		.pm		= ATMCI_PM_OPS,
+		.of_match_table	= of_match_ptr(atmci_dt_ids),
 	},
 };
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 2/3] ARM: at91: add clocks for DT entries
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-23 19:38     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-23 19:38 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add clocks to clock lookup table for DT entries.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
v4: add new chips

 arch/arm/mach-at91/at91sam9260.c |    1 +
 arch/arm/mach-at91/at91sam9263.c |    2 ++
 arch/arm/mach-at91/at91sam9g45.c |    2 ++
 arch/arm/mach-at91/at91sam9n12.c |    1 +
 arch/arm/mach-at91/at91sam9x5.c  |    2 ++
 5 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 2b1e438..ddba004 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -226,6 +226,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 0eb20f9..f165b25 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -211,6 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff84000.mmc", &mmc1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 4792682..aa24e82 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -242,6 +242,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 0849466..cce4e0f 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -168,6 +168,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 1b144b4..de86e37 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,6 +231,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 2/3] ARM: at91: add clocks for DT entries
@ 2012-05-23 19:38     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-23 19:38 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add clocks to clock lookup table for DT entries.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
v4: add new chips

 arch/arm/mach-at91/at91sam9260.c |    1 +
 arch/arm/mach-at91/at91sam9263.c |    2 ++
 arch/arm/mach-at91/at91sam9g45.c |    2 ++
 arch/arm/mach-at91/at91sam9n12.c |    1 +
 arch/arm/mach-at91/at91sam9x5.c  |    2 ++
 5 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 2b1e438..ddba004 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -226,6 +226,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 0eb20f9..f165b25 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -211,6 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff84000.mmc", &mmc1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 4792682..aa24e82 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -242,6 +242,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 0849466..cce4e0f 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -168,6 +168,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 1b144b4..de86e37 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,6 +231,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
  2012-05-22 10:09   ` ludovic.desroches at atmel.com
@ 2012-05-23 19:42     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches @ 2012-05-23 19:42 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: nicolas.ferre, plagnioj, devicetree-discuss, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add nodes for mci controllers.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
v4: add new chips and boards

 arch/arm/boot/dts/at91sam9260.dtsi          |    9 +++++++++
 arch/arm/boot/dts/at91sam9263.dtsi          |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9263ek.dts         |   10 ++++++++++
 arch/arm/boot/dts/at91sam9g20ek_2mmc.dts    |   12 ++++++++++++
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi |    9 +++++++++
 arch/arm/boot/dts/at91sam9g25ek.dts         |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi          |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts      |   19 +++++++++++++++++++
 arch/arm/boot/dts/at91sam9n12.dtsi          |    9 +++++++++
 arch/arm/boot/dts/at91sam9n12ek.dts         |    9 +++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi           |   18 ++++++++++++++++++
 11 files changed, 149 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..ae54bf3 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -198,6 +198,15 @@
 				status = "disabled";
 			};
 
+			mmc0: mmc@fffa8000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffa800 0x600>;
+				interrupts = <9 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
 			adc0: adc@fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..a327ebe 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -179,6 +179,24 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc@fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <10 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc@fff84000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff84000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index f86ac4b..05028ed 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -50,6 +50,16 @@
 				atmel,vbus-gpio = <&pioA 25 0>;
 				status = "okay";
 			};
+
+			mmc0: mmc@fff80000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioE 18 0>;
+					wp-gpios = <&pioE 19 0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts b/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
index f1b2e14..684b229 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
+++ b/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
@@ -12,6 +12,18 @@
 	model = "Atmel at91sam9g20ek 2 mmc";
 	compatible = "atmel,at91sam9g20ek_2mmc", "atmel,at91sam9g20", "atmel,at91sam9";
 
+	ahb {
+		apb{
+			mmc0: mmc@fffa8000 {
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioC 2 0>;
+				};
+			};
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index b06c0db..7da326a 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,15 @@
 				atmel,vbus-gpio = <&pioC 5 0>;
 				status = "okay";
 			};
+
+			mmc0: mmc@fffa8000 {
+				status = "okay";
+				slot@1 {
+					reg = <1>;
+					bus-width = <4>;
+					cd-gpios = <&pioC 9 0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..422a9fb 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,24 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc@f0008000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 15 0>;
+				};
+			};
+
+			mmc1: mmc@f000c000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 14 0>;
+				};
+			};
 		};
 
 		usb0: ohci@00600000 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..0360bf8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -236,6 +236,24 @@
 					trigger-value = <0x6>;
 				};
 			};
+
+			mmc0: mmc@fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc@fffd0000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffd0000 0x600>;
+				interrupts = <29 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..7a7b571 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,25 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc@fff80000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 10 0>;
+				};
+			};
+
+			mmc1: mmc@fffd0000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 11 0>;
+					wp-gpios = <&pioD 29 0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..f3e03fb 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -82,6 +82,15 @@
 				reg = <0xfffffe10 0x10>;
 			};
 
+			mmc0: mmc@f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
 			tcb0: timer@f8008000 {
 				compatible = "atmel,at91sam9x5-tcb";
 				reg = <0xf8008000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index f4e43e3..44b42d9 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -37,6 +37,15 @@
 			dbgu: serial@fffff200 {
 				status = "okay";
 			};
+
+			mmc0: mmc@f0008000 {
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioA 7 0>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..4e8125b 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -228,6 +228,24 @@
 					trigger-value = <0x6>;
 				};
 			};
+
+			mmc0: mmc@f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc@f000c000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf000c000 0x600>;
+				interrupts = <26 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand@40000000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms
@ 2012-05-23 19:42     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 40+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-05-23 19:42 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add nodes for mci controllers.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
v4: add new chips and boards

 arch/arm/boot/dts/at91sam9260.dtsi          |    9 +++++++++
 arch/arm/boot/dts/at91sam9263.dtsi          |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9263ek.dts         |   10 ++++++++++
 arch/arm/boot/dts/at91sam9g20ek_2mmc.dts    |   12 ++++++++++++
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi |    9 +++++++++
 arch/arm/boot/dts/at91sam9g25ek.dts         |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi          |   18 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts      |   19 +++++++++++++++++++
 arch/arm/boot/dts/at91sam9n12.dtsi          |    9 +++++++++
 arch/arm/boot/dts/at91sam9n12ek.dts         |    9 +++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi           |   18 ++++++++++++++++++
 11 files changed, 149 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..ae54bf3 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -198,6 +198,15 @@
 				status = "disabled";
 			};
 
+			mmc0: mmc at fffa8000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffa800 0x600>;
+				interrupts = <9 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
 			adc0: adc at fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..a327ebe 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -179,6 +179,24 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			mmc0: mmc at fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <10 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc at fff84000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff84000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index f86ac4b..05028ed 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -50,6 +50,16 @@
 				atmel,vbus-gpio = <&pioA 25 0>;
 				status = "okay";
 			};
+
+			mmc0: mmc at fff80000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioE 18 0>;
+					wp-gpios = <&pioE 19 0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts b/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
index f1b2e14..684b229 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
+++ b/arch/arm/boot/dts/at91sam9g20ek_2mmc.dts
@@ -12,6 +12,18 @@
 	model = "Atmel at91sam9g20ek 2 mmc";
 	compatible = "atmel,at91sam9g20ek_2mmc", "atmel,at91sam9g20", "atmel,at91sam9";
 
+	ahb {
+		apb{
+			mmc0: mmc at fffa8000 {
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioC 2 0>;
+				};
+			};
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index b06c0db..7da326a 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,15 @@
 				atmel,vbus-gpio = <&pioC 5 0>;
 				status = "okay";
 			};
+
+			mmc0: mmc at fffa8000 {
+				status = "okay";
+				slot at 1 {
+					reg = <1>;
+					bus-width = <4>;
+					cd-gpios = <&pioC 9 0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..422a9fb 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,24 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc at f0008000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 15 0>;
+				};
+			};
+
+			mmc1: mmc at f000c000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 14 0>;
+				};
+			};
 		};
 
 		usb0: ohci at 00600000 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..0360bf8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -236,6 +236,24 @@
 					trigger-value = <0x6>;
 				};
 			};
+
+			mmc0: mmc at fff80000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfff80000 0x600>;
+				interrupts = <11 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc at fffd0000 {
+				compatible = "atmel,hsmci";
+				reg = <0xfffd0000 0x600>;
+				interrupts = <29 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..7a7b571 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,25 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			mmc0: mmc at fff80000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 10 0>;
+				};
+			};
+
+			mmc1: mmc at fffd0000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioD 11 0>;
+					wp-gpios = <&pioD 29 0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..f3e03fb 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -82,6 +82,15 @@
 				reg = <0xfffffe10 0x10>;
 			};
 
+			mmc0: mmc at f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
 			tcb0: timer at f8008000 {
 				compatible = "atmel,at91sam9x5-tcb";
 				reg = <0xf8008000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index f4e43e3..44b42d9 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -37,6 +37,15 @@
 			dbgu: serial at fffff200 {
 				status = "okay";
 			};
+
+			mmc0: mmc at f0008000 {
+				status = "okay";
+				slot at 0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioA 7 0>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..4e8125b 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -228,6 +228,24 @@
 					trigger-value = <0x6>;
 				};
 			};
+
+			mmc0: mmc at f0008000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf0008000 0x600>;
+				interrupts = <12 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			mmc1: mmc at f000c000 {
+				compatible = "atmel,hsmci";
+				reg = <0xf000c000 0x600>;
+				interrupts = <26 4>;
+				status = "disabled";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		nand0: nand at 40000000 {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 1/3] mmc: atmel-mci: add device tree support
  2012-05-23  7:23     ` ludovic.desroches at atmel.com
@ 2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-24  9:43 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: linux-mmc, linux-arm-kernel, nicolas.ferre, devicetree-discuss

On 09:23 Wed 23 May     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   87 +++++++++++++++++++-
>  2 files changed, 152 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot@0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc@f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot@0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot@1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..1842dc7 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,72 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	u32 slot_id;
> +	int ret;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		ret = of_property_read_u32(cnp, "reg", &slot_id);
> +		if (ret) {
really need ret = ?
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
missing spase arround '-'
if (slot_id >= ATMCI_MAX_NR_SLOTS)
will do the same
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		pdata->slot[slot_id].detect_is_active_high =
> +			of_property_read_bool(cnp, "cd-inverted");
I really this this is redondant with gpio binding

Chris??

BestRegards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-24  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 09:23 Wed 23 May     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  .../devicetree/bindings/mmc/atmel-hsmci.txt        |   67 +++++++++++++++
>  drivers/mmc/host/atmel-mci.c                       |   87 +++++++++++++++++++-
>  2 files changed, 152 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> new file mode 100644
> index 0000000..81c20cc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
> @@ -0,0 +1,67 @@
> +* Atmel High Speed MultiMedia Card Interface
> +
> +This controller on atmel products provides an interface for MMC, SD and SDIO
> +types of memory cards.
> +
> +1) MCI node
> +
> +Required properties:
> +- compatible: no blank "atmel,hsmci"
> +- reg: should contain HSMCI registers location and length
> +- interrupts: should contain HSMCI interrupt number
> +- #address-cells: should be one. The cell is the slot id.
> +- #size-cells: should be zero.
> +- at least one slot node
> +
> +The node contains child nodes for each slot that the platform uses
> +
> +Example MCI node:
> +
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	[ child node definitions...]
> +};
> +
> +2) slot nodes
> +
> +Required properties:
> +- reg: should contain the slot id.
> +- bus-width: number of data lines connected to the controller
> +
> +Optional properties:
> +- cd-gpios: specify GPIOs for card detection
> +- cd-inverted: invert the value of external card detect gpio line
> +- wp-gpios: specify GPIOs for write protection
> +
> +Example slot node:
> +
> +slot at 0 {
> +	reg = <0>;
> +	bus-width = <4>;
> +	cd-gpios = <&pioD 15 0>
> +	cd-inverted;
> +};
> +
> +Example full MCI node:
> +mmc0: mmc at f0008000 {
> +	compatible = "atmel,hsmci";
> +	reg = <0xf0008000 0x600>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	slot at 0 {
> +		reg = <0>;
> +		bus-width = <4>;
> +		cd-gpios = <&pioD 15 0>
> +		cd-inverted;
> +	};
> +	slot at 1 {
> +		reg = <1>;
> +		bus-width = <4>;
> +	};
> +};
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 556d384..1842dc7 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -19,6 +19,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -493,6 +496,72 @@ err:
>  	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
>  }
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id atmci_dt_ids[] = {
> +	{ .compatible = "atmel,hsmci" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, atmci_dt_ids);
> +
> +static struct mci_platform_data __devinit*
> +atmci_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *cnp;
> +	struct mci_platform_data *pdata;
> +	u32 slot_id;
> +	int ret;
> +
> +	if (!np) {
> +		dev_err(&pdev->dev, "device node not found\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "could not allocate memory for pdata\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	for_each_child_of_node(np, cnp) {
> +		ret = of_property_read_u32(cnp, "reg", &slot_id);
> +		if (ret) {
really need ret = ?
> +			dev_warn(&pdev->dev, "reg property is missing for %s\n",
> +				 cnp->full_name);
> +			continue;
> +		}
> +
> +		if (slot_id > (ATMCI_MAX_NR_SLOTS-1)) {
missing spase arround '-'
if (slot_id >= ATMCI_MAX_NR_SLOTS)
will do the same
> +			dev_warn(&pdev->dev, "can't have more than %d slots\n",
> +			         ATMCI_MAX_NR_SLOTS);
> +			break;
> +		}
> +
> +		if (of_property_read_u32(cnp, "bus-width",
> +		                         &pdata->slot[slot_id].bus_width))
> +			pdata->slot[slot_id].bus_width = 1;
> +
> +		pdata->slot[slot_id].detect_pin =
> +			of_get_named_gpio(cnp, "cd-gpios", 0);
> +
> +		pdata->slot[slot_id].detect_is_active_high =
> +			of_property_read_bool(cnp, "cd-inverted");
I really this this is redondant with gpio binding

Chris??

BestRegards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 2/3] ARM: at91: add clocks for DT entries
  2012-05-23 19:38     ` ludovic.desroches at atmel.com
@ 2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-24  9:43 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: nicolas.ferre, devicetree-discuss, linux-mmc, linux-arm-kernel

On 21:38 Wed 23 May     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

please next time send it as a new thread

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 2/3] ARM: at91: add clocks for DT entries
@ 2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 40+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-05-24  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 21:38 Wed 23 May     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add clocks to clock lookup table for DT entries.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

please next time send it as a new thread

Best Regards,
J.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 1/3] mmc: atmel-mci: add device tree support
  2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-05-24 14:40         ` Chris Ball
  -1 siblings, 0 replies; 40+ messages in thread
From: Chris Ball @ 2012-05-24 14:40 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: ludovic.desroches, linux-mmc, linux-arm-kernel, nicolas.ferre,
	devicetree-discuss

Hi,

On Thu, May 24 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:
>> +
>> +		pdata->slot[slot_id].detect_is_active_high =
>> +			of_property_read_bool(cnp, "cd-inverted");
> 
> I really this this is redondant with gpio binding
>
> Chris??

Hm, I think go ahead and add it for now -- I agree it's redundant, but
we should go through and remove the redundancy from all drivers (and the
binding document, which is in 3.5-rc1 now) at once later.  Since it's in
the bindings doc, best to implement it until that changes.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 1/3] mmc: atmel-mci: add device tree support
@ 2012-05-24 14:40         ` Chris Ball
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Ball @ 2012-05-24 14:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thu, May 24 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:
>> +
>> +		pdata->slot[slot_id].detect_is_active_high =
>> +			of_property_read_bool(cnp, "cd-inverted");
> 
> I really this this is redondant with gpio binding
>
> Chris??

Hm, I think go ahead and add it for now -- I agree it's redundant, but
we should go through and remove the redundancy from all drivers (and the
binding document, which is in 3.5-rc1 now) at once later.  Since it's in
the bindings doc, best to implement it until that changes.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2012-05-24 14:40 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-22 10:09 [PATCH v3 0/3] atmel-mci device tree support ludovic.desroches
2012-05-22 10:09 ` ludovic.desroches at atmel.com
2012-05-22 10:09 ` [PATCH v3 1/3] mmc: atmel-mci: add " ludovic.desroches
2012-05-22 10:09   ` ludovic.desroches at atmel.com
2012-05-22 12:55   ` Nicolas Ferre
2012-05-22 12:55     ` Nicolas Ferre
2012-05-22 14:08   ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-22 14:08     ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]     ` <20120522140845.GA3377-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-05-22 14:48       ` ludovic.desroches
2012-05-22 14:48         ` ludovic.desroches
     [not found]         ` <4FBBA756.8030501-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-05-22 15:10           ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-22 15:10             ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]             ` <20120522151048.GD3377-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-05-22 15:18               ` Nicolas Ferre
2012-05-22 15:18                 ` Nicolas Ferre
2012-05-23  7:23   ` [PATCH v4 " ludovic.desroches
2012-05-23  7:23     ` ludovic.desroches at atmel.com
2012-05-24  9:43     ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-24 14:40       ` Chris Ball
2012-05-24 14:40         ` Chris Ball
2012-05-22 10:09 ` [PATCH v3 2/3] ARM: at91: add clocks for DT entries ludovic.desroches
2012-05-22 10:09   ` ludovic.desroches at atmel.com
2012-05-22 12:56   ` Nicolas Ferre
2012-05-22 12:56     ` Nicolas Ferre
2012-05-22 14:11   ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-22 14:11     ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-23 19:38   ` [PATCH v4 " ludovic.desroches
2012-05-23 19:38     ` ludovic.desroches at atmel.com
2012-05-24  9:43     ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-24  9:43       ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-22 10:09 ` [PATCH v3 3/3] ARM: dts: add nodes for atmel hsmci controllers for atmel platforms ludovic.desroches
2012-05-22 10:09   ` ludovic.desroches at atmel.com
2012-05-22 13:11   ` Nicolas Ferre
2012-05-22 13:11     ` Nicolas Ferre
2012-05-22 14:13   ` Jean-Christophe PLAGNIOL-VILLARD
2012-05-22 14:13     ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]     ` <20120522141348.GC3377-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-05-22 14:41       ` ludovic.desroches
2012-05-22 14:41         ` ludovic.desroches
2012-05-23 19:42   ` [PATCH v4 " ludovic.desroches
2012-05-23 19:42     ` ludovic.desroches at atmel.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.