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

[PATCH 3/7] sh: pfc: Allow device tree registration

From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
Date: 2012-11-26 12:54:47
Also in: linux-sh

Hi Simon,

On Monday 26 November 2012 09:16:50 Simon Horman wrote:
This is a crude mechanism to allow the pfc driver to be registered through
device tree. The mofication of this is to provide a way for pfc gpios to be
looked up by device tree for devices which use pfc gpios.
Indeed it's a bit of a hack :-) I'll see how I can rebase that on top of my 
PFC patch series. I'd rather avoid this intermediate step as it would make PFC 
rework more complex.
quoted hunk ↗ jump to hunk
More specifically, the motivation is to allow the registration
of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board.

Cc: Paul Mundt <redacted>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
 drivers/sh/pfc/gpio.c  |   15 +++++++++++++++
 include/linux/sh_pfc.h |    7 +++++++
 2 files changed, 22 insertions(+)
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 038fa07..322b927 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -136,6 +136,19 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip)
gc->ngpio = (pfc->last_gpio - pfc->first_gpio) + 1;
 }

+#ifdef CONFIG_OF_GPIO
+static void
+sh_pfc_register_gpiochip_dt(struct sh_pfc *pfc, struct gpio_chip *chip)
+{
+	chip->of_node = pfc->of_node;
+	chip->of_gpio_n_cells = pfc->of_gpio_n_cells;
+	chip->of_xlate = pfc->of_xlate;
+}
+#else
+static void sh_pfc_register_gpiochip_dt(struct sh_pfc *pfc,
+					struct gpio_chip *chip) {}
+#endif
+
 int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
 {
 	struct sh_pfc_chip *chip;
@@ -153,6 +166,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
 	if (unlikely(ret < 0))
 		kfree(chip);

+	sh_pfc_register_gpiochip_dt(pfc, &chip->gpio_chip);
+
 	pr_info("%s handling gpio %d -> %d\n",
 		pfc->name, pfc->first_gpio, pfc->last_gpio);
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
index c19a092..9963370 100644
--- a/include/linux/sh_pfc.h
+++ b/include/linux/sh_pfc.h
@@ -124,6 +124,13 @@ struct sh_pfc {
 	struct pfc_window *window;

 	unsigned long unlock_reg;
+
+#ifdef CONFIG_OF_GPIO
+	struct device_node *of_node;
+	int of_gpio_n_cells;
+	int (*of_xlate)(struct gpio_chip *gc,
+		        const struct of_phandle_args *gpiospec, u32 *flags);
+#endif
 };

 /* XXX compat for now */
-- 
Regards,

Laurent Pinchart
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help