devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support
@ 2013-02-14 17:42 Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 2/5] pcmcia: at91_cf: convert to dev_ print functions Joachim Eastwood
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux-X3ehHDuj6sIIGcDfoQAp7OTW4wlIGRCZ
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-pcmcia-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Joachim Eastwood

Hi

This series clean up at91_cf a bit and add DT bindings.

Patch series tested on custom RM9200 board in both with DT and
with old platform data.


Joachim Eastwood (5):
  pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status
  pcmcia: at91_cf: convert to dev_ print functions
  pcmcia: at91_cf: use devm_ functions for allocations
  pcmcia: at91_cf: clean up header includes
  pcmcia: at91_cf: add support for DT

 .../devicetree/bindings/ata/atmel-at91_cf.txt      |  19 +++
 drivers/pcmcia/Kconfig                             |   2 +-
 drivers/pcmcia/at91_cf.c                           | 148 +++++++++++----------
 3 files changed, 99 insertions(+), 70 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/atmel-at91_cf.txt

-- 
1.8.0

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

* [PATCH 1/5] pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status
       [not found] ` <1360863766-22511-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-02-14 17:42   ` Joachim Eastwood
  2013-03-08  9:21   ` [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Nicolas Ferre
  1 sibling, 0 replies; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux-X3ehHDuj6sIIGcDfoQAp7OTW4wlIGRCZ
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-pcmcia-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Joachim Eastwood

Commit 80af9e6d (pcmcia at91_cf: fix raw gpio number usage) forgot
to change the parameter in gpio_get_value after adding gpio
validation.

Signed-off-by: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/pcmcia/at91_cf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 01463c7..1b2c631 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -100,9 +100,9 @@ static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp)
 		int vcc	= gpio_is_valid(cf->board->vcc_pin);
 
 		*sp = SS_DETECT | SS_3VCARD;
-		if (!rdy || gpio_get_value(rdy))
+		if (!rdy || gpio_get_value(cf->board->irq_pin))
 			*sp |= SS_READY;
-		if (!vcc || gpio_get_value(vcc))
+		if (!vcc || gpio_get_value(cf->board->vcc_pin))
 			*sp |= SS_POWERON;
 	} else
 		*sp = 0;
-- 
1.8.0

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

* [PATCH 2/5] pcmcia: at91_cf: convert to dev_ print functions
  2013-02-14 17:42 [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Joachim Eastwood
@ 2013-02-14 17:42 ` Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 3/5] pcmcia: at91_cf: use devm_ functions for allocations Joachim Eastwood
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux
  Cc: plagnioj, devicetree-discuss, linux-pcmcia, nicolas.ferre,
	Joachim Eastwood

Convert all pr_* functions to equivalent dev_* functions and
drop the driver_name variable.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/pcmcia/at91_cf.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 1b2c631..4eec14b 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -41,8 +41,6 @@
 
 /*--------------------------------------------------------------------------*/
 
-static const char driver_name[] = "at91_cf";
-
 struct at91_cf_socket {
 	struct pcmcia_socket	socket;
 
@@ -76,7 +74,7 @@ static irqreturn_t at91_cf_irq(int irq, void *_cf)
 		/* kick pccard as needed */
 		if (present != cf->present) {
 			cf->present = present;
-			pr_debug("%s: card %s\n", driver_name,
+			dev_dbg(&cf->pdev->dev, "card %s\n",
 					present ? "present" : "gone");
 			pcmcia_parse_events(&cf->socket, SS_DETECT);
 		}
@@ -134,8 +132,8 @@ at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
 	/* toggle reset if needed */
 	gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET);
 
-	pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n",
-		driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
+	dev_dbg(&cf->pdev->dev, "Vcc %d, io_irq %d, flags %04x csc %04x\n",
+				s->Vcc, s->io_irq, s->flags, s->csc_mask);
 
 	return 0;
 }
@@ -171,10 +169,10 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
 	 */
 	if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) {
 		csr |= AT91_SMC_DBW_8;
-		pr_debug("%s: 8bit i/o bus\n", driver_name);
+		dev_dbg(&cf->pdev->dev, "8bit i/o bus\n");
 	} else {
 		csr |= AT91_SMC_DBW_16;
-		pr_debug("%s: 16bit i/o bus\n", driver_name);
+		dev_dbg(&cf->pdev->dev, "16bit i/o bus\n");
 	}
 	at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr);
 
@@ -242,7 +240,7 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	status = gpio_request(board->det_pin, "cf_det");
 	if (status < 0)
 		goto fail0;
-	status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, driver_name, cf);
+	status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, "at91_cf detect", cf);
 	if (status < 0)
 		goto fail00;
 	device_init_wakeup(&pdev->dev, 1);
@@ -268,7 +266,7 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 		if (status < 0)
 			goto fail0c;
 		status = request_irq(gpio_to_irq(board->irq_pin), at91_cf_irq,
-				IRQF_SHARED, driver_name, cf);
+				IRQF_SHARED, "at91_cf", cf);
 		if (status < 0)
 			goto fail0d;
 		cf->socket.pci_irq = gpio_to_irq(board->irq_pin);
@@ -284,12 +282,12 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	}
 
 	/* reserve chip-select regions */
-	if (!request_mem_region(io->start, resource_size(io), driver_name)) {
+	if (!request_mem_region(io->start, resource_size(io), "at91_cf")) {
 		status = -ENXIO;
 		goto fail1;
 	}
 
-	pr_info("%s: irqs det #%d, io #%d\n", driver_name,
+	dev_info(&pdev->dev, "irqs det #%d, io #%d\n",
 		gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin));
 
 	cf->socket.owner = THIS_MODULE;
@@ -391,7 +389,7 @@ static int at91_cf_resume(struct platform_device *pdev)
 
 static struct platform_driver at91_cf_driver = {
 	.driver = {
-		.name		= (char *) driver_name,
+		.name		= "at91_cf",
 		.owner		= THIS_MODULE,
 	},
 	.remove		= __exit_p(at91_cf_remove),
-- 
1.8.0

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

* [PATCH 3/5] pcmcia: at91_cf: use devm_ functions for allocations
  2013-02-14 17:42 [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 2/5] pcmcia: at91_cf: convert to dev_ print functions Joachim Eastwood
@ 2013-02-14 17:42 ` Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 4/5] pcmcia: at91_cf: clean up header includes Joachim Eastwood
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux
  Cc: plagnioj, devicetree-discuss, linux-pcmcia, nicolas.ferre,
	Joachim Eastwood

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/pcmcia/at91_cf.c | 77 +++++++++++++++---------------------------------
 1 file changed, 24 insertions(+), 53 deletions(-)

diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 4eec14b..43bc342 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -227,7 +227,7 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	if (!io)
 		return -ENODEV;
 
-	cf = kzalloc(sizeof *cf, GFP_KERNEL);
+	cf = devm_kzalloc(&pdev->dev, sizeof(*cf), GFP_KERNEL);
 	if (!cf)
 		return -ENOMEM;
 
@@ -237,22 +237,25 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, cf);
 
 	/* must be a GPIO; ergo must trigger on both edges */
-	status = gpio_request(board->det_pin, "cf_det");
+	status = devm_gpio_request(&pdev->dev, board->det_pin, "cf_det");
 	if (status < 0)
-		goto fail0;
-	status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, "at91_cf detect", cf);
+		return status;
+
+	status = devm_request_irq(&pdev->dev, gpio_to_irq(board->det_pin),
+					at91_cf_irq, 0, "at91_cf detect", cf);
 	if (status < 0)
-		goto fail00;
+		return status;
+
 	device_init_wakeup(&pdev->dev, 1);
 
-	status = gpio_request(board->rst_pin, "cf_rst");
+	status = devm_gpio_request(&pdev->dev, board->rst_pin, "cf_rst");
 	if (status < 0)
 		goto fail0a;
 
 	if (gpio_is_valid(board->vcc_pin)) {
-		status = gpio_request(board->vcc_pin, "cf_vcc");
+		status = devm_gpio_request(&pdev->dev, board->vcc_pin, "cf_vcc");
 		if (status < 0)
-			goto fail0b;
+			goto fail0a;
 	}
 
 	/*
@@ -262,29 +265,30 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	 * (Note:  DK board doesn't wire the IRQ pin...)
 	 */
 	if (gpio_is_valid(board->irq_pin)) {
-		status = gpio_request(board->irq_pin, "cf_irq");
+		status = devm_gpio_request(&pdev->dev, board->irq_pin, "cf_irq");
 		if (status < 0)
-			goto fail0c;
-		status = request_irq(gpio_to_irq(board->irq_pin), at91_cf_irq,
-				IRQF_SHARED, "at91_cf", cf);
+			goto fail0a;
+
+		status = devm_request_irq(&pdev->dev, gpio_to_irq(board->irq_pin),
+					at91_cf_irq, IRQF_SHARED, "at91_cf", cf);
 		if (status < 0)
-			goto fail0d;
+			goto fail0a;
 		cf->socket.pci_irq = gpio_to_irq(board->irq_pin);
 	} else
 		cf->socket.pci_irq = nr_irqs + 1;
 
 	/* pcmcia layer only remaps "real" memory not iospace */
-	cf->socket.io_offset = (unsigned long)
-			ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
+	cf->socket.io_offset = (unsigned long) devm_ioremap(&pdev->dev,
+					cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
 	if (!cf->socket.io_offset) {
 		status = -ENXIO;
-		goto fail1;
+		goto fail0a;
 	}
 
 	/* reserve chip-select regions */
-	if (!request_mem_region(io->start, resource_size(io), "at91_cf")) {
+	if (!devm_request_mem_region(&pdev->dev, io->start, resource_size(io), "at91_cf")) {
 		status = -ENXIO;
-		goto fail1;
+		goto fail0a;
 	}
 
 	dev_info(&pdev->dev, "irqs det #%d, io #%d\n",
@@ -301,55 +305,22 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 
 	status = pcmcia_register_socket(&cf->socket);
 	if (status < 0)
-		goto fail2;
+		goto fail0a;
 
 	return 0;
 
-fail2:
-	release_mem_region(io->start, resource_size(io));
-fail1:
-	if (cf->socket.io_offset)
-		iounmap((void __iomem *) cf->socket.io_offset);
-	if (gpio_is_valid(board->irq_pin)) {
-		free_irq(gpio_to_irq(board->irq_pin), cf);
-fail0d:
-		gpio_free(board->irq_pin);
-	}
-fail0c:
-	if (gpio_is_valid(board->vcc_pin))
-		gpio_free(board->vcc_pin);
-fail0b:
-	gpio_free(board->rst_pin);
 fail0a:
 	device_init_wakeup(&pdev->dev, 0);
-	free_irq(gpio_to_irq(board->det_pin), cf);
-fail00:
-	gpio_free(board->det_pin);
-fail0:
-	kfree(cf);
 	return status;
 }
 
 static int __exit at91_cf_remove(struct platform_device *pdev)
 {
 	struct at91_cf_socket	*cf = platform_get_drvdata(pdev);
-	struct at91_cf_data	*board = cf->board;
-	struct resource		*io = cf->socket.io[0].res;
 
 	pcmcia_unregister_socket(&cf->socket);
-	release_mem_region(io->start, resource_size(io));
-	iounmap((void __iomem *) cf->socket.io_offset);
-	if (gpio_is_valid(board->irq_pin)) {
-		free_irq(gpio_to_irq(board->irq_pin), cf);
-		gpio_free(board->irq_pin);
-	}
-	if (gpio_is_valid(board->vcc_pin))
-		gpio_free(board->vcc_pin);
-	gpio_free(board->rst_pin);
 	device_init_wakeup(&pdev->dev, 0);
-	free_irq(gpio_to_irq(board->det_pin), cf);
-	gpio_free(board->det_pin);
-	kfree(cf);
+
 	return 0;
 }
 
-- 
1.8.0

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

* [PATCH 4/5] pcmcia: at91_cf: clean up header includes
  2013-02-14 17:42 [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 2/5] pcmcia: at91_cf: convert to dev_ print functions Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 3/5] pcmcia: at91_cf: use devm_ functions for allocations Joachim Eastwood
@ 2013-02-14 17:42 ` Joachim Eastwood
  2013-02-14 17:42 ` [PATCH 5/5] pcmcia: at91_cf: add support for DT Joachim Eastwood
       [not found] ` <1360863766-22511-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  4 siblings, 0 replies; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux
  Cc: plagnioj, devicetree-discuss, linux-pcmcia, nicolas.ferre,
	Joachim Eastwood

Use includes from linux/ instead of asm/ and remove a
unnecessary mach/ include.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/pcmcia/at91_cf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 43bc342..bce8a64 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -18,13 +18,11 @@
 #include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/platform_data/atmel.h>
+#include <linux/io.h>
+#include <linux/sizes.h>
 
 #include <pcmcia/ss.h>
 
-#include <mach/hardware.h>
-#include <asm/io.h>
-#include <asm/sizes.h>
-
 #include <mach/at91rm9200_mc.h>
 #include <mach/at91_ramc.h>
 
-- 
1.8.0

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

* [PATCH 5/5] pcmcia: at91_cf: add support for DT
  2013-02-14 17:42 [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Joachim Eastwood
                   ` (2 preceding siblings ...)
  2013-02-14 17:42 ` [PATCH 4/5] pcmcia: at91_cf: clean up header includes Joachim Eastwood
@ 2013-02-14 17:42 ` Joachim Eastwood
  2013-03-08  9:18   ` Nicolas Ferre
       [not found] ` <1360863766-22511-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  4 siblings, 1 reply; 8+ messages in thread
From: Joachim Eastwood @ 2013-02-14 17:42 UTC (permalink / raw)
  To: linux
  Cc: plagnioj, devicetree-discuss, linux-pcmcia, nicolas.ferre,
	Joachim Eastwood

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 .../devicetree/bindings/ata/atmel-at91_cf.txt      | 19 +++++++++
 drivers/pcmcia/Kconfig                             |  2 +-
 drivers/pcmcia/at91_cf.c                           | 45 +++++++++++++++++++++-
 3 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/atmel-at91_cf.txt

diff --git a/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
new file mode 100644
index 0000000..c1d22b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
@@ -0,0 +1,19 @@
+Atmel AT91RM9200 CompactFlash
+
+Required properties:
+- compatible : "atmel,at91rm9200-cf".
+- reg : should specify localbus address and size used.
+- gpios : specifies the gpio pins to control the CF device. Detect
+  and reset gpio's are mandatory while irq and vcc gpio's are
+  optional and may be set to 0 if not present.
+
+Example:
+compact-flash@50000000 {
+	compatible = "atmel,at91rm9200-cf";
+	reg = <0x50000000 0x30000000>;
+	gpios = <&pioC 13 0	/* irq */
+		 &pioC 15 0 	/* detect */
+		 0		/* vcc */
+		 &pioC  5 0	/* reset */
+		>;
+};
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 8fd255f..2adad5b 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -288,7 +288,7 @@ config BFIN_CFPCMCIA
 
 config AT91_CF
 	tristate "AT91 CompactFlash Controller"
-	depends on PCMCIA && ARCH_AT91RM9200
+	depends on PCMCIA && ARCH_AT91
 	help
 	  Say Y here to support the CompactFlash controller on AT91 chips.
 	  Or choose M to compile the driver as a module named "at91_cf".
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index bce8a64..149b95c 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -20,6 +20,9 @@
 #include <linux/platform_data/atmel.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 
 #include <pcmcia/ss.h>
 
@@ -211,6 +214,37 @@ static struct pccard_operations at91_cf_ops = {
 
 /*--------------------------------------------------------------------------*/
 
+#if defined(CONFIG_OF)
+static const struct of_device_id at91_cf_dt_ids[] = {
+	{ .compatible = "atmel,at91rm9200-cf" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, at91_cf_dt_ids);
+
+static int at91_cf_dt_init(struct platform_device *pdev)
+{
+	struct at91_cf_data *board;
+
+	board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
+	if (!board)
+		return -ENOMEM;
+
+	board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
+	board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
+	board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
+	board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
+
+	pdev->dev.platform_data = board;
+
+	return 0;
+}
+#else
+static int at91_cf_dt_init(struct platform_device *pdev)
+{
+	return -ENODEV;
+}
+#endif
+
 static int __init at91_cf_probe(struct platform_device *pdev)
 {
 	struct at91_cf_socket	*cf;
@@ -218,7 +252,15 @@ static int __init at91_cf_probe(struct platform_device *pdev)
 	struct resource		*io;
 	int			status;
 
-	if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
+	if (!board) {
+		status = at91_cf_dt_init(pdev);
+		if (status)
+			return status;
+
+		board = pdev->dev.platform_data;
+	}
+
+	if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
 		return -ENODEV;
 
 	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -360,6 +402,7 @@ static struct platform_driver at91_cf_driver = {
 	.driver = {
 		.name		= "at91_cf",
 		.owner		= THIS_MODULE,
+		.of_match_table = of_match_ptr(at91_cf_dt_ids),
 	},
 	.remove		= __exit_p(at91_cf_remove),
 	.suspend	= at91_cf_suspend,
-- 
1.8.0

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

* Re: [PATCH 5/5] pcmcia: at91_cf: add support for DT
  2013-02-14 17:42 ` [PATCH 5/5] pcmcia: at91_cf: add support for DT Joachim Eastwood
@ 2013-03-08  9:18   ` Nicolas Ferre
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2013-03-08  9:18 UTC (permalink / raw)
  To: Joachim Eastwood
  Cc: devicetree-discuss, linux-pcmcia, plagnioj, linux-arm-kernel,
	linux

On 02/14/2013 06:42 PM, Joachim Eastwood :
> Signed-off-by: Joachim Eastwood <manabian@gmail.com>

Seems good.

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

> ---
>  .../devicetree/bindings/ata/atmel-at91_cf.txt      | 19 +++++++++
>  drivers/pcmcia/Kconfig                             |  2 +-
>  drivers/pcmcia/at91_cf.c                           | 45 +++++++++++++++++++++-
>  3 files changed, 64 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
> 
> diff --git a/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
> new file mode 100644
> index 0000000..c1d22b3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
> @@ -0,0 +1,19 @@
> +Atmel AT91RM9200 CompactFlash
> +
> +Required properties:
> +- compatible : "atmel,at91rm9200-cf".
> +- reg : should specify localbus address and size used.
> +- gpios : specifies the gpio pins to control the CF device. Detect
> +  and reset gpio's are mandatory while irq and vcc gpio's are
> +  optional and may be set to 0 if not present.
> +
> +Example:
> +compact-flash@50000000 {
> +	compatible = "atmel,at91rm9200-cf";
> +	reg = <0x50000000 0x30000000>;
> +	gpios = <&pioC 13 0	/* irq */
> +		 &pioC 15 0 	/* detect */
> +		 0		/* vcc */
> +		 &pioC  5 0	/* reset */
> +		>;
> +};
> diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
> index 8fd255f..2adad5b 100644
> --- a/drivers/pcmcia/Kconfig
> +++ b/drivers/pcmcia/Kconfig
> @@ -288,7 +288,7 @@ config BFIN_CFPCMCIA
>  
>  config AT91_CF
>  	tristate "AT91 CompactFlash Controller"
> -	depends on PCMCIA && ARCH_AT91RM9200
> +	depends on PCMCIA && ARCH_AT91
>  	help
>  	  Say Y here to support the CompactFlash controller on AT91 chips.
>  	  Or choose M to compile the driver as a module named "at91_cf".
> diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
> index bce8a64..149b95c 100644
> --- a/drivers/pcmcia/at91_cf.c
> +++ b/drivers/pcmcia/at91_cf.c
> @@ -20,6 +20,9 @@
>  #include <linux/platform_data/atmel.h>
>  #include <linux/io.h>
>  #include <linux/sizes.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  
>  #include <pcmcia/ss.h>
>  
> @@ -211,6 +214,37 @@ static struct pccard_operations at91_cf_ops = {
>  
>  /*--------------------------------------------------------------------------*/
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id at91_cf_dt_ids[] = {
> +	{ .compatible = "atmel,at91rm9200-cf" },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, at91_cf_dt_ids);
> +
> +static int at91_cf_dt_init(struct platform_device *pdev)
> +{
> +	struct at91_cf_data *board;
> +
> +	board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
> +	if (!board)
> +		return -ENOMEM;
> +
> +	board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
> +	board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
> +	board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
> +	board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
> +
> +	pdev->dev.platform_data = board;
> +
> +	return 0;
> +}
> +#else
> +static int at91_cf_dt_init(struct platform_device *pdev)
> +{
> +	return -ENODEV;
> +}
> +#endif
> +
>  static int __init at91_cf_probe(struct platform_device *pdev)
>  {
>  	struct at91_cf_socket	*cf;
> @@ -218,7 +252,15 @@ static int __init at91_cf_probe(struct platform_device *pdev)
>  	struct resource		*io;
>  	int			status;
>  
> -	if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
> +	if (!board) {
> +		status = at91_cf_dt_init(pdev);
> +		if (status)
> +			return status;
> +
> +		board = pdev->dev.platform_data;
> +	}
> +
> +	if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
>  		return -ENODEV;
>  
>  	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -360,6 +402,7 @@ static struct platform_driver at91_cf_driver = {
>  	.driver = {
>  		.name		= "at91_cf",
>  		.owner		= THIS_MODULE,
> +		.of_match_table = of_match_ptr(at91_cf_dt_ids),
>  	},
>  	.remove		= __exit_p(at91_cf_remove),
>  	.suspend	= at91_cf_suspend,
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support
       [not found] ` <1360863766-22511-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2013-02-14 17:42   ` [PATCH 1/5] pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status Joachim Eastwood
@ 2013-03-08  9:21   ` Nicolas Ferre
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2013-03-08  9:21 UTC (permalink / raw)
  To: Joachim Eastwood, linux-X3ehHDuj6sIIGcDfoQAp7OTW4wlIGRCZ,
	linux-pcmcia-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-arm-kernel

On 02/14/2013 06:42 PM, Joachim Eastwood :
> Hi
> 
> This series clean up at91_cf a bit and add DT bindings.
> 
> Patch series tested on custom RM9200 board in both with DT and
> with old platform data.
> 
> 
> Joachim Eastwood (5):
>   pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status
>   pcmcia: at91_cf: convert to dev_ print functions
>   pcmcia: at91_cf: use devm_ functions for allocations
>   pcmcia: at91_cf: clean up header includes
>   pcmcia: at91_cf: add support for DT
> 
>  .../devicetree/bindings/ata/atmel-at91_cf.txt      |  19 +++
>  drivers/pcmcia/Kconfig                             |   2 +-
>  drivers/pcmcia/at91_cf.c                           | 148 +++++++++++----------
>  3 files changed, 99 insertions(+), 70 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/ata/atmel-at91_cf.txt

Joachim,

Thanks a lot for these patches. You can add on the whole series:

Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

I hope that it can be taken by linux-pcmcia.

Best regards,

PS: make sure to add linux-arm-kernel mailing-list as well: it always
interests people there to have updates on AT91 peripherals...
-- 
Nicolas Ferre

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

end of thread, other threads:[~2013-03-08  9:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14 17:42 [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Joachim Eastwood
2013-02-14 17:42 ` [PATCH 2/5] pcmcia: at91_cf: convert to dev_ print functions Joachim Eastwood
2013-02-14 17:42 ` [PATCH 3/5] pcmcia: at91_cf: use devm_ functions for allocations Joachim Eastwood
2013-02-14 17:42 ` [PATCH 4/5] pcmcia: at91_cf: clean up header includes Joachim Eastwood
2013-02-14 17:42 ` [PATCH 5/5] pcmcia: at91_cf: add support for DT Joachim Eastwood
2013-03-08  9:18   ` Nicolas Ferre
     [not found] ` <1360863766-22511-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-14 17:42   ` [PATCH 1/5] pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status Joachim Eastwood
2013-03-08  9:21   ` [PATCH 0/5] pcmcia: at91_cf: clean up and add DT support Nicolas Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).