Skip to content

Commit 5558f27

Browse files
wenslinusw
authored andcommitted
pinctrl: sunxi: dt: Consider pin base when calculating bank number from pin
In prepare_function_table() when the pinctrl function table IRQ entries are generated, the pin bank is calculated from the absolute pin number; however the IRQ bank mux array is indexed from the first pin bank of the controller. For R_PIO controllers, this means the absolute pin bank is way off from the relative pin bank used for array indexing. Correct this by taking into account the pin base of the controller. Fixes: f5e2cd3 ("pinctrl: sunxi: allow reading mux values from DT") Signed-off-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 24b0277 commit 5558f27

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
143143
*/
144144
static int prepare_function_table(struct device *dev, struct device_node *pnode,
145145
struct sunxi_desc_pin *pins, int npins,
146-
const u8 *irq_bank_muxes)
146+
unsigned pin_base, const u8 *irq_bank_muxes)
147147
{
148148
struct device_node *node;
149149
struct property *prop;
@@ -166,7 +166,7 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
166166
*/
167167
for (i = 0; i < npins; i++) {
168168
struct sunxi_desc_pin *pin = &pins[i];
169-
int bank = pin->pin.number / PINS_PER_BANK;
169+
int bank = (pin->pin.number - pin_base) / PINS_PER_BANK;
170170

171171
if (irq_bank_muxes[bank]) {
172172
pin->variant++;
@@ -211,7 +211,7 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
211211
last_bank = 0;
212212
for (i = 0; i < npins; i++) {
213213
struct sunxi_desc_pin *pin = &pins[i];
214-
int bank = pin->pin.number / PINS_PER_BANK;
214+
int bank = (pin->pin.number - pin_base) / PINS_PER_BANK;
215215
int lastfunc = pin->variant + 1;
216216
int irq_mux = irq_bank_muxes[bank];
217217

@@ -353,7 +353,7 @@ int sunxi_pinctrl_dt_table_init(struct platform_device *pdev,
353353
return PTR_ERR(pins);
354354

355355
ret = prepare_function_table(&pdev->dev, pnode, pins, desc->npins,
356-
irq_bank_muxes);
356+
desc->pin_base, irq_bank_muxes);
357357
if (ret)
358358
return ret;
359359

0 commit comments

Comments
 (0)