* [PATCH] sh: pfc: Add GPIO IRQ support
@ 2011-09-28 7:50 Magnus Damm
0 siblings, 0 replies; only message in thread
From: Magnus Damm @ 2011-09-28 7:50 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@opensource.se>
Add GPIO IRQ support to the shared PFC code in drivers/sh/pfc.c
The enums pointed out by a certain GPIO will be matched against
a table for IRQ to enum mappings.
Only the shared PFC code is updated by this patch. SoC specific
changes are also needed to allow platforms to make use of this
feature.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Applies on top of "sh: pfc: Remove unused gpio_in_use member"
drivers/sh/pfc.c | 27 +++++++++++++++++++++++++++
include/linux/sh_pfc.h | 11 +++++++++++
2 files changed, 38 insertions(+)
--- 0001/drivers/sh/pfc.c
+++ work/drivers/sh/pfc.c 2011-09-28 15:02:21.000000000 +0900
@@ -577,6 +577,32 @@ static void sh_gpio_set(struct gpio_chip
sh_gpio_set_value(chip_to_pinmux(chip), offset, value);
}
+static int sh_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+{
+ struct pinmux_info *gpioc = chip_to_pinmux(chip);
+ pinmux_enum_t enum_id;
+ pinmux_enum_t *enum_ids;
+ int i, k, pos;
+
+ pos = 0;
+ enum_id = 0;
+ while (1) {
+ pos = get_gpio_enum_id(gpioc, offset, pos, &enum_id);
+ if (pos <= 0 || !enum_id)
+ break;
+
+ for (i = 0; i < gpioc->gpio_irq_size; i++) {
+ enum_ids = gpioc->gpio_irq[i].enum_ids;
+ for (k = 0; enum_ids[k]; k++) {
+ if (enum_ids[k] = enum_id)
+ return gpioc->gpio_irq[i].irq;
+ }
+ }
+ }
+
+ return -ENOSYS;
+}
+
int register_pinmux(struct pinmux_info *pip)
{
struct gpio_chip *chip = &pip->chip;
@@ -592,6 +618,7 @@ int register_pinmux(struct pinmux_info *
chip->get = sh_gpio_get;
chip->direction_output = sh_gpio_direction_output;
chip->set = sh_gpio_set;
+ chip->to_irq = sh_gpio_to_irq;
WARN_ON(pip->first_gpio != 0); /* needs testing */
--- 0004/include/linux/sh_pfc.h
+++ work/include/linux/sh_pfc.h 2011-09-28 15:01:46.000000000 +0900
@@ -61,6 +61,14 @@ struct pinmux_data_reg {
.reg = r, .reg_width = r_width, \
.enum_ids = (pinmux_enum_t [r_width]) \
+struct pinmux_irq {
+ int irq;
+ pinmux_enum_t *enum_ids;
+};
+
+#define PINMUX_IRQ(irq_nr, ids...) \
+ { .irq = irq_nr, .enum_ids = (pinmux_enum_t []) { ids, 0 } } \
+
struct pinmux_range {
pinmux_enum_t begin;
pinmux_enum_t end;
@@ -87,6 +95,9 @@ struct pinmux_info {
pinmux_enum_t *gpio_data;
unsigned int gpio_data_size;
+ struct pinmux_irq *gpio_irq;
+ unsigned int gpio_irq_size;
+
struct gpio_chip chip;
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-28 7:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-28 7:50 [PATCH] sh: pfc: Add GPIO IRQ support Magnus Damm
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).