Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273359
b: refs/heads/master
c: ad2a8e7
h: refs/heads/master
i:
  273357: 9cf98bb
  273355: 1e673fb
  273351: 694a807
  273343: 8d6e397
v: v3
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Oct 28, 2011
1 parent 446c12d commit cfad3d1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cf8e56bf5b60dba5ba11db83ca7f1df884e568e5
refs/heads/master: ad2a8e7ea4128af984a98537b1b9484722b6b4bb
27 changes: 27 additions & 0 deletions trunk/drivers/sh/pfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,32 @@ static void sh_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
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;
Expand All @@ -592,6 +618,7 @@ int register_pinmux(struct pinmux_info *pip)
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 */

Expand Down
11 changes: 11 additions & 0 deletions trunk/include/linux/sh_pfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down

0 comments on commit cfad3d1

Please sign in to comment.