Skip to content

Commit 228f1ce

Browse files
21cnbaolinusw
authored andcommitted
pinctrl: sirf: replace of_gpio_simple_xlate by sirf specific of_xlate
the default of_gpio_simple_xlate() will make us fail while getting gpios bigger than 32 by of_get_named_gpio() or related APIs. this patch adds a specific of_xlate callback for sirf gpio_chip and fix the problem. Signed-off-by: Barry Song <Baohua.Song@csr.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent a1ed267 commit 228f1ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/pinctrl/pinctrl-sirf.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,22 @@ static void __iomem *sirfsoc_rsc_of_iomap(void)
12461246
return of_iomap(np, 0);
12471247
}
12481248

1249+
static int sirfsoc_gpio_of_xlate(struct gpio_chip *gc,
1250+
const struct of_phandle_args *gpiospec,
1251+
u32 *flags)
1252+
{
1253+
if (gpiospec->args[0] > SIRFSOC_GPIO_NO_OF_BANKS * SIRFSOC_GPIO_BANK_SIZE)
1254+
return -EINVAL;
1255+
1256+
if (gc != &sgpio_bank[gpiospec->args[0] / SIRFSOC_GPIO_BANK_SIZE].chip.gc)
1257+
return -EINVAL;
1258+
1259+
if (flags)
1260+
*flags = gpiospec->args[1];
1261+
1262+
return gpiospec->args[0] % SIRFSOC_GPIO_BANK_SIZE;
1263+
}
1264+
12491265
static int sirfsoc_pinmux_probe(struct platform_device *pdev)
12501266
{
12511267
int ret;
@@ -1736,6 +1752,8 @@ static int sirfsoc_gpio_probe(struct device_node *np)
17361752
bank->chip.gc.ngpio = SIRFSOC_GPIO_BANK_SIZE;
17371753
bank->chip.gc.label = kstrdup(np->full_name, GFP_KERNEL);
17381754
bank->chip.gc.of_node = np;
1755+
bank->chip.gc.of_xlate = sirfsoc_gpio_of_xlate;
1756+
bank->chip.gc.of_gpio_n_cells = 2;
17391757
bank->chip.regs = regs;
17401758
bank->id = i;
17411759
bank->is_marco = is_marco;

0 commit comments

Comments
 (0)