All of lore.kernel.org
 help / color / mirror / Atom feed
From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/7] gpio: mxc: Support initialization as subdevice
Date: Fri,  2 Aug 2013 12:38:21 +0200	[thread overview]
Message-ID: <1375439907-10462-2-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1375439907-10462-1-git-send-email-mpa@pengutronix.de>

On imx27 and imx21, there is no clear seperation between iomux control
registers and GPIO data registers. For easier pingroup definitions, the
gpio drivers will be initialized as subnodes of the iomux controller. It
is necessary to share the registers between iomux and gpio.

This patch adds support to pass a register memory region via platform
data.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/gpio/gpio-mxc.c                | 18 ++++++++++++++----
 include/linux/platform_data/gpio-mxc.h | 17 +++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/platform_data/gpio-mxc.h

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 875a7c5..41922e8 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -27,6 +27,7 @@
 #include <linux/irqdomain.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/gpio.h>
+#include <linux/platform_data/gpio-mxc.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/basic_mmio_gpio.h>
@@ -401,6 +402,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct mxc_gpio_port *port;
 	struct resource *iores;
+	struct mxc_gpio_platform_data *pdata = pdev->dev.platform_data;
 	int irq_base;
 	int err;
 
@@ -410,10 +412,18 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	if (!port)
 		return -ENOMEM;
 
-	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	port->base = devm_ioremap_resource(&pdev->dev, iores);
-	if (IS_ERR(port->base))
-		return PTR_ERR(port->base);
+	if (pdata) {
+		port->base = pdata->base;
+		if (!pdata->base) {
+			dev_err(&pdev->dev, "No mapped memory in platform_data\n");
+			return -EINVAL;
+		}
+	} else {
+		iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		port->base = devm_ioremap_resource(&pdev->dev, iores);
+		if (IS_ERR(port->base))
+			return PTR_ERR(port->base);
+	}
 
 	port->irq_high = platform_get_irq(pdev, 1);
 	port->irq = platform_get_irq(pdev, 0);
diff --git a/include/linux/platform_data/gpio-mxc.h b/include/linux/platform_data/gpio-mxc.h
new file mode 100644
index 0000000..fb3e06b
--- /dev/null
+++ b/include/linux/platform_data/gpio-mxc.h
@@ -0,0 +1,17 @@
+#ifndef _LINUX_GPIO_MXC_H
+#define _LINUX_GPIO_MXC_H
+
+#include <linux/types.h>
+
+/*
+ * MXC GPIO driver platform data. If this platform data is passed to the
+ * driver, it will use the memory base defined in the struct. This is used for
+ * iomuxc drivers on imx1/imx21/imx27, where the GPIO data register is embedded
+ * between iomuxc registers.
+ */
+
+struct mxc_gpio_platform_data {
+	void __iomem *base;
+};
+
+#endif /* _LINUX_GPIO_MXC_H */
-- 
1.8.3.2

  reply	other threads:[~2013-08-02 10:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02 10:38 [PATCH 0/7] ARM: imx27 pinctrl Markus Pargmann
2013-08-02 10:38 ` Markus Pargmann [this message]
2013-08-07 19:03   ` [PATCH 1/7] gpio: mxc: Support initialization as subdevice Linus Walleij
2013-08-09 17:56     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 2/7] pinctrl: imx header, conditional probe functions Markus Pargmann
2013-08-05  5:43   ` Shawn Guo
2013-08-09 13:31     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 3/7] pinctrl: imx1 core driver Markus Pargmann
2013-08-02 10:51   ` Alexander Shiyan
2013-08-02 10:54     ` Markus Pargmann
2013-08-05  9:29   ` Sascha Hauer
2013-08-09 18:16     ` Markus Pargmann
2013-08-07 19:25   ` Linus Walleij
2013-08-09 19:33     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 4/7] pinctrl: imx27: imx27 pincontrol driver Markus Pargmann
2013-08-05  6:12   ` Shawn Guo
2013-08-09 13:46     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 5/7] ARM: dts: imx27 pin functions Markus Pargmann
2013-08-05  6:14   ` Shawn Guo
2013-08-02 10:38 ` [PATCH 6/7] ARM: dts: imx27 pinctrl Markus Pargmann
2013-08-05  6:18   ` Shawn Guo
2013-08-09 13:54     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 7/7] ARM: imx27: enable pinctrl Markus Pargmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375439907-10462-2-git-send-email-mpa@pengutronix.de \
    --to=mpa@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.