Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Magnus Damm and committed by
Paul Mundt
ad2a8e7e cf8e56bf

+38
+27
drivers/sh/pfc.c
··· 577 577 sh_gpio_set_value(chip_to_pinmux(chip), offset, value); 578 578 } 579 579 580 + static 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 + 580 606 int register_pinmux(struct pinmux_info *pip) 581 607 { 582 608 struct gpio_chip *chip = &pip->chip; ··· 618 592 chip->get = sh_gpio_get; 619 593 chip->direction_output = sh_gpio_direction_output; 620 594 chip->set = sh_gpio_set; 595 + chip->to_irq = sh_gpio_to_irq; 621 596 622 597 WARN_ON(pip->first_gpio != 0); /* needs testing */ 623 598
+11
include/linux/sh_pfc.h
··· 61 61 .reg = r, .reg_width = r_width, \ 62 62 .enum_ids = (pinmux_enum_t [r_width]) \ 63 63 64 + struct 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 + 64 72 struct pinmux_range { 65 73 pinmux_enum_t begin; 66 74 pinmux_enum_t end; ··· 94 86 95 87 pinmux_enum_t *gpio_data; 96 88 unsigned int gpio_data_size; 89 + 90 + struct pinmux_irq *gpio_irq; 91 + unsigned int gpio_irq_size; 97 92 98 93 struct gpio_chip chip; 99 94 };