Commit 208c80f1 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Bartosz Golaszewski

gpio: rcar: Rework hardware features handling

Reuse gpio_rcar_info inside gpio_rcar_priv instead of duplicating the
individual members, so gpio_rcar_parse_dt() can copy them in one go.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 677d7d61
...@@ -32,6 +32,11 @@ struct gpio_rcar_bank_info { ...@@ -32,6 +32,11 @@ struct gpio_rcar_bank_info {
u32 intmsk; u32 intmsk;
}; };
struct gpio_rcar_info {
bool has_outdtsel;
bool has_both_edge_trigger;
};
struct gpio_rcar_priv { struct gpio_rcar_priv {
void __iomem *base; void __iomem *base;
spinlock_t lock; spinlock_t lock;
...@@ -40,8 +45,7 @@ struct gpio_rcar_priv { ...@@ -40,8 +45,7 @@ struct gpio_rcar_priv {
struct irq_chip irq_chip; struct irq_chip irq_chip;
unsigned int irq_parent; unsigned int irq_parent;
atomic_t wakeup_path; atomic_t wakeup_path;
bool has_outdtsel; struct gpio_rcar_info info;
bool has_both_edge_trigger;
struct gpio_rcar_bank_info bank_info; struct gpio_rcar_bank_info bank_info;
}; };
...@@ -123,7 +127,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, ...@@ -123,7 +127,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger); gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger);
/* Select one edge or both edges in BOTHEDGE */ /* Select one edge or both edges in BOTHEDGE */
if (p->has_both_edge_trigger) if (p->info.has_both_edge_trigger)
gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both); gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);
/* Select "Interrupt Input Mode" in IOINTSEL */ /* Select "Interrupt Input Mode" in IOINTSEL */
...@@ -162,7 +166,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) ...@@ -162,7 +166,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type)
false); false);
break; break;
case IRQ_TYPE_EDGE_BOTH: case IRQ_TYPE_EDGE_BOTH:
if (!p->has_both_edge_trigger) if (!p->info.has_both_edge_trigger)
return -EINVAL; return -EINVAL;
gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false, gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false,
true); true);
...@@ -238,7 +242,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, ...@@ -238,7 +242,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
gpio_rcar_modify_bit(p, INOUTSEL, gpio, output); gpio_rcar_modify_bit(p, INOUTSEL, gpio, output);
/* Select General Output Register to output data in OUTDTSEL */ /* Select General Output Register to output data in OUTDTSEL */
if (p->has_outdtsel && output) if (p->info.has_outdtsel && output)
gpio_rcar_modify_bit(p, OUTDTSEL, gpio, false); gpio_rcar_modify_bit(p, OUTDTSEL, gpio, false);
spin_unlock_irqrestore(&p->lock, flags); spin_unlock_irqrestore(&p->lock, flags);
...@@ -347,11 +351,6 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset, ...@@ -347,11 +351,6 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
return 0; return 0;
} }
struct gpio_rcar_info {
bool has_outdtsel;
bool has_both_edge_trigger;
};
static const struct gpio_rcar_info gpio_rcar_info_gen1 = { static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
.has_outdtsel = false, .has_outdtsel = false,
.has_both_edge_trigger = false, .has_both_edge_trigger = false,
...@@ -418,8 +417,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) ...@@ -418,8 +417,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins)
int ret; int ret;
info = of_device_get_match_data(p->dev); info = of_device_get_match_data(p->dev);
p->has_outdtsel = info->has_outdtsel; p->info = *info;
p->has_both_edge_trigger = info->has_both_edge_trigger;
ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args);
*npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK;
...@@ -553,7 +551,7 @@ static int gpio_rcar_suspend(struct device *dev) ...@@ -553,7 +551,7 @@ static int gpio_rcar_suspend(struct device *dev)
p->bank_info.intmsk = gpio_rcar_read(p, INTMSK); p->bank_info.intmsk = gpio_rcar_read(p, INTMSK);
p->bank_info.posneg = gpio_rcar_read(p, POSNEG); p->bank_info.posneg = gpio_rcar_read(p, POSNEG);
p->bank_info.edglevel = gpio_rcar_read(p, EDGLEVEL); p->bank_info.edglevel = gpio_rcar_read(p, EDGLEVEL);
if (p->has_both_edge_trigger) if (p->info.has_both_edge_trigger)
p->bank_info.bothedge = gpio_rcar_read(p, BOTHEDGE); p->bank_info.bothedge = gpio_rcar_read(p, BOTHEDGE);
if (atomic_read(&p->wakeup_path)) if (atomic_read(&p->wakeup_path))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment