aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sh')
-rw-r--r--drivers/sh/intc/chip.c11
-rw-r--r--drivers/sh/intc/userimask.c1
-rw-r--r--drivers/sh/pfc.c29
3 files changed, 37 insertions, 4 deletions
diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
index 33b2ed451e09..7b246efa94ea 100644
--- a/drivers/sh/intc/chip.c
+++ b/drivers/sh/intc/chip.c
@@ -186,7 +186,7 @@ static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
186 !defined(CONFIG_CPU_SUBTYPE_SH7709) 186 !defined(CONFIG_CPU_SUBTYPE_SH7709)
187 [IRQ_TYPE_LEVEL_HIGH] = VALID(3), 187 [IRQ_TYPE_LEVEL_HIGH] = VALID(3),
188#endif 188#endif
189#if defined(CONFIG_ARCH_SH7372) 189#if defined(CONFIG_ARM) /* all recent SH-Mobile / R-Mobile ARM support this */
190 [IRQ_TYPE_EDGE_BOTH] = VALID(4), 190 [IRQ_TYPE_EDGE_BOTH] = VALID(4),
191#endif 191#endif
192}; 192};
@@ -202,11 +202,16 @@ static int intc_set_type(struct irq_data *data, unsigned int type)
202 if (!value) 202 if (!value)
203 return -EINVAL; 203 return -EINVAL;
204 204
205 value &= ~SENSE_VALID_FLAG;
206
205 ihp = intc_find_irq(d->sense, d->nr_sense, irq); 207 ihp = intc_find_irq(d->sense, d->nr_sense, irq);
206 if (ihp) { 208 if (ihp) {
209 /* PINT has 2-bit sense registers, should fail on EDGE_BOTH */
210 if (value >= (1 << _INTC_WIDTH(ihp->handle)))
211 return -EINVAL;
212
207 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0); 213 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0);
208 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle, 214 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle, value);
209 value & ~SENSE_VALID_FLAG);
210 } 215 }
211 216
212 return 0; 217 return 0;
diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
index e32304b66cf1..56bf9336b92b 100644
--- a/drivers/sh/intc/userimask.c
+++ b/drivers/sh/intc/userimask.c
@@ -13,6 +13,7 @@
13#include <linux/sysdev.h> 13#include <linux/sysdev.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/stat.h>
16#include <asm/sizes.h> 17#include <asm/sizes.h>
17#include "internals.h" 18#include "internals.h"
18 19
diff --git a/drivers/sh/pfc.c b/drivers/sh/pfc.c
index 75934e3ea34e..e67fe170d8d5 100644
--- a/drivers/sh/pfc.c
+++ b/drivers/sh/pfc.c
@@ -217,7 +217,7 @@ static int get_config_reg(struct pinmux_info *gpioc, pinmux_enum_t enum_id,
217 217
218 if (!r_width) 218 if (!r_width)
219 break; 219 break;
220 for (n = 0; n < (r_width / f_width) * 1 << f_width; n++) { 220 for (n = 0; n < (r_width / f_width) * (1 << f_width); n++) {
221 if (config_reg->enum_ids[n] == enum_id) { 221 if (config_reg->enum_ids[n] == enum_id) {
222 *crp = config_reg; 222 *crp = config_reg;
223 *indexp = n; 223 *indexp = n;
@@ -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