aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2011-09-28 03:50:58 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-10-28 02:03:52 -0400
commitad2a8e7ea4128af984a98537b1b9484722b6b4bb (patch)
treecf5030dda233a9182e78574356d1853652753aad
parentcf8e56bf5b60dba5ba11db83ca7f1df884e568e5 (diff)
sh: pfc: Add GPIO IRQ support
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> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/sh/pfc.c27
-rw-r--r--include/linux/sh_pfc.h11
2 files changed, 38 insertions, 0 deletions
diff --git a/drivers/sh/pfc.c b/drivers/sh/pfc.c
index de5e3d65a6fa..e67fe170d8d5 100644
--- a/drivers/sh/pfc.c
+++ b/drivers/sh/pfc.c
@@ -577,6 +577,32 @@ static void sh_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
577 sh_gpio_set_value(chip_to_pinmux(chip), offset, value); 577 sh_gpio_set_value(chip_to_pinmux(chip), offset, value);
578} 578}
579 579
580static int sh_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
581{
582 struct pinmux_info *gpioc = chip_to_pinmux(chip);
583 pinmux_enum_t enum_id;
584 pinmux_enum_t *enum_ids;
585 int i, k, pos;
586
587 pos = 0;
588 enum_id = 0;
589 while (1) {
590 pos = get_gpio_enum_id(gpioc, offset, pos, &enum_id);
591 if (pos <= 0 || !enum_id)
592 break;
593
594 for (i = 0; i < gpioc->gpio_irq_size; i++) {
595 enum_ids = gpioc->gpio_irq[i].enum_ids;
596 for (k = 0; enum_ids[k]; k++) {
597 if (enum_ids[k] == enum_id)
598 return gpioc->gpio_irq[i].irq;
599 }
600 }
601 }
602
603 return -ENOSYS;
604}
605
580int register_pinmux(struct pinmux_info *pip) 606int register_pinmux(struct pinmux_info *pip)
581{ 607{
582 struct gpio_chip *chip = &pip->chip; 608 struct gpio_chip *chip = &pip->chip;
@@ -592,6 +618,7 @@ int register_pinmux(struct pinmux_info *pip)
592 chip->get = sh_gpio_get; 618 chip->get = sh_gpio_get;
593 chip->direction_output = sh_gpio_direction_output; 619 chip->direction_output = sh_gpio_direction_output;
594 chip->set = sh_gpio_set; 620 chip->set = sh_gpio_set;
621 chip->to_irq = sh_gpio_to_irq;
595 622
596 WARN_ON(pip->first_gpio != 0); /* needs testing */ 623 WARN_ON(pip->first_gpio != 0); /* needs testing */
597 624
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
index 12f351991701..bc8c9208f7e2 100644
--- a/include/linux/sh_pfc.h
+++ b/include/linux/sh_pfc.h
@@ -61,6 +61,14 @@ struct pinmux_data_reg {
61 .reg = r, .reg_width = r_width, \ 61 .reg = r, .reg_width = r_width, \
62 .enum_ids = (pinmux_enum_t [r_width]) \ 62 .enum_ids = (pinmux_enum_t [r_width]) \
63 63
64struct pinmux_irq {
65 int irq;
66 pinmux_enum_t *enum_ids;
67};
68
69#define PINMUX_IRQ(irq_nr, ids...) \
70 { .irq = irq_nr, .enum_ids = (pinmux_enum_t []) { ids, 0 } } \
71
64struct pinmux_range { 72struct pinmux_range {
65 pinmux_enum_t begin; 73 pinmux_enum_t begin;
66 pinmux_enum_t end; 74 pinmux_enum_t end;
@@ -87,6 +95,9 @@ struct pinmux_info {
87 pinmux_enum_t *gpio_data; 95 pinmux_enum_t *gpio_data;
88 unsigned int gpio_data_size; 96 unsigned int gpio_data_size;
89 97
98 struct pinmux_irq *gpio_irq;
99 unsigned int gpio_irq_size;
100
90 struct gpio_chip chip; 101 struct gpio_chip chip;
91}; 102};
92 103