Thread (25 messages) 25 messages, 5 authors, 2012-11-27
STALE4936d
Revisions (4)
  1. v1 current
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v2 [diff vs current]

[PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree

From: horms@verge.net.au (Simon Horman)
Date: 2012-11-26 00:16:51
Also in: linux-sh
Subsystem: arm port, arm/risc-v/renesas architecture, the rest · Maintainers: Russell King, Geert Uytterhoeven, Magnus Damm, Linus Torvalds

Register the pfc with sh73a0_init_gpio_dt() to allow
gpios provided by pfc to be accessed by devices which
are registered using device tree.

The motivation of this is to allow the gpio used for carrier detect
but the Micro SD SDHI port of the KZM-9A-GT board to be accessed
using device tree. Thus, allowing the SDHI device of the KZM-9A-GT
board to be registered using device tree.

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 arch/arm/mach-shmobile/pfc-sh73a0.c |   45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c b/arch/arm/mach-shmobile/pfc-sh73a0.c
index b442f9d..d1a04c0b 100644
--- a/arch/arm/mach-shmobile/pfc-sh73a0.c
+++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
@@ -2797,7 +2797,52 @@ static struct pinmux_info sh73a0_pinmux_info = {
 	.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
 };
 
+#ifdef CONFIG_OF_GPIO
+static int sh73a0_gpio_xlate(struct gpio_chip *gc,
+			     const struct of_phandle_args *gpiospec,
+			     u32 *flags)
+{
+	if (WARN_ON(gc->of_gpio_n_cells < 2))
+		return -EINVAL;
+
+	if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
+		return -EINVAL;
+
+	if (gpiospec->args[0] > gc->ngpio)
+		return -EINVAL;
+
+	if (flags)
+		*flags = gpiospec->args[1];
+
+	return gpiospec->args[0];
+}
+
+static const struct of_device_id sh73a0_gpio_dt_match[] __initdata = {
+	{ .compatible = "renesas,sh_pfc-sh73a0", },
+	{}
+};
+
+static inline void sh73a0_init_gpio_dt(void)
+{
+	struct device_node *of_node;
+
+	if (!of_have_populated_dt())
+		return;
+
+	of_node = of_find_matching_node(NULL, sh73a0_gpio_dt_match);
+	sh73a0_pinmux_info.of_node = of_node;
+	sh73a0_pinmux_info.of_gpio_n_cells = 2;
+	sh73a0_pinmux_info.of_xlate = sh73a0_gpio_xlate;
+}
+
+#else
+
+static inline void sh73a0_init_gpio_dt(void) {}
+
+#endif
+
 void sh73a0_pinmux_init(void)
 {
+	sh73a0_init_gpio_dt();
 	register_pinmux(&sh73a0_pinmux_info);
 }
-- 
1.7.10.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help