Skip to content

Commit 00dfe29

Browse files
prabhakarladgeertu
authored andcommitted
pinctrl: renesas: rzg2l: Fix configuring the GPIO pins as interrupts
On the RZ/G2UL SoC we have less number of pins compared to RZ/G2L and also the pin configs are completely different. This patch makes sure we use the appropriate pin configs for each SoC (which is passed as part of the OF data) while configuring the GPIO pin as interrupts instead of using rzg2l_gpio_configs[] for all the SoCs. Fixes: bfc69bd ("pinctrl: renesas: rzg2l: Add RZ/G2UL support") Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 34cf9a8 commit 00dfe29

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct rzg2l_dedicated_configs {
130130
struct rzg2l_pinctrl_data {
131131
const char * const *port_pins;
132132
const u32 *port_pin_configs;
133+
unsigned int n_ports;
133134
struct rzg2l_dedicated_configs *dedicated_pins;
134135
unsigned int n_port_pins;
135136
unsigned int n_dedicated_pins;
@@ -1124,7 +1125,7 @@ static struct {
11241125
}
11251126
};
11261127

1127-
static int rzg2l_gpio_get_gpioint(unsigned int virq)
1128+
static int rzg2l_gpio_get_gpioint(unsigned int virq, const struct rzg2l_pinctrl_data *data)
11281129
{
11291130
unsigned int gpioint;
11301131
unsigned int i;
@@ -1133,13 +1134,13 @@ static int rzg2l_gpio_get_gpioint(unsigned int virq)
11331134
port = virq / 8;
11341135
bit = virq % 8;
11351136

1136-
if (port >= ARRAY_SIZE(rzg2l_gpio_configs) ||
1137-
bit >= RZG2L_GPIO_PORT_GET_PINCNT(rzg2l_gpio_configs[port]))
1137+
if (port >= data->n_ports ||
1138+
bit >= RZG2L_GPIO_PORT_GET_PINCNT(data->port_pin_configs[port]))
11381139
return -EINVAL;
11391140

11401141
gpioint = bit;
11411142
for (i = 0; i < port; i++)
1142-
gpioint += RZG2L_GPIO_PORT_GET_PINCNT(rzg2l_gpio_configs[i]);
1143+
gpioint += RZG2L_GPIO_PORT_GET_PINCNT(data->port_pin_configs[i]);
11431144

11441145
return gpioint;
11451146
}
@@ -1239,7 +1240,7 @@ static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
12391240
unsigned long flags;
12401241
int gpioint, irq;
12411242

1242-
gpioint = rzg2l_gpio_get_gpioint(child);
1243+
gpioint = rzg2l_gpio_get_gpioint(child, pctrl->data);
12431244
if (gpioint < 0)
12441245
return gpioint;
12451246

@@ -1313,8 +1314,8 @@ static void rzg2l_init_irq_valid_mask(struct gpio_chip *gc,
13131314
port = offset / 8;
13141315
bit = offset % 8;
13151316

1316-
if (port >= ARRAY_SIZE(rzg2l_gpio_configs) ||
1317-
bit >= RZG2L_GPIO_PORT_GET_PINCNT(rzg2l_gpio_configs[port]))
1317+
if (port >= pctrl->data->n_ports ||
1318+
bit >= RZG2L_GPIO_PORT_GET_PINCNT(pctrl->data->port_pin_configs[port]))
13181319
clear_bit(offset, valid_mask);
13191320
}
13201321
}
@@ -1519,6 +1520,7 @@ static int rzg2l_pinctrl_probe(struct platform_device *pdev)
15191520
static struct rzg2l_pinctrl_data r9a07g043_data = {
15201521
.port_pins = rzg2l_gpio_names,
15211522
.port_pin_configs = r9a07g043_gpio_configs,
1523+
.n_ports = ARRAY_SIZE(r9a07g043_gpio_configs),
15221524
.dedicated_pins = rzg2l_dedicated_pins.common,
15231525
.n_port_pins = ARRAY_SIZE(r9a07g043_gpio_configs) * RZG2L_PINS_PER_PORT,
15241526
.n_dedicated_pins = ARRAY_SIZE(rzg2l_dedicated_pins.common),
@@ -1527,6 +1529,7 @@ static struct rzg2l_pinctrl_data r9a07g043_data = {
15271529
static struct rzg2l_pinctrl_data r9a07g044_data = {
15281530
.port_pins = rzg2l_gpio_names,
15291531
.port_pin_configs = rzg2l_gpio_configs,
1532+
.n_ports = ARRAY_SIZE(rzg2l_gpio_configs),
15301533
.dedicated_pins = rzg2l_dedicated_pins.common,
15311534
.n_port_pins = ARRAY_SIZE(rzg2l_gpio_names),
15321535
.n_dedicated_pins = ARRAY_SIZE(rzg2l_dedicated_pins.common) +

0 commit comments

Comments
 (0)