提交 c7977ec4 编写于 作者: G Geert Uytterhoeven 提交者: Linus Walleij

pinctrl: sh-pfc: Convert to platform_get_*()

If the pin function controller (which can be a GPIO controller) is
instantiated before the interrupt controllers, due to the ordering in
the DTS, the irq domains for the interrupt controllers referenced by its
"interrupts-extended" property cannot be found yet:

    irq: no irq domain found for /interrupt-controller@e61c0000 !

As the sh-pfc driver accesses the platform device's resources directly,
it cannot find the (optional) IRQ resources, and thinks no interrupts
are available. This may lead to failures later, when GPIOs are used as
interupts:

    gpio-keys keyboard: Unable to claim irq 0; error -22
    gpio-keys: probe of keyboard failed with error -22

To fix this, add support for deferred probing to sh-pfc, by converting
the driver from direct platform device resource access to using the
platform_get_resource() and platform_get_irq() helpers.

Note that while this fixes the root cause worked around by commit
e4ba0a9b ("ARM: shmobile: r8a73a4: Move pfc node to work around
probe ordering bug"), I strongly recommend against reverting the
workaround now, as this would lead to lots of probe deferrals in drivers
relying on pinctrl. This may be reconsidered once the DT code starts
taking into account phandle dependencies during device instantation.
Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 16ccaf5b
...@@ -29,24 +29,25 @@ ...@@ -29,24 +29,25 @@
static int sh_pfc_map_resources(struct sh_pfc *pfc, static int sh_pfc_map_resources(struct sh_pfc *pfc,
struct platform_device *pdev) struct platform_device *pdev)
{ {
unsigned int num_windows = 0; unsigned int num_windows, num_irqs;
unsigned int num_irqs = 0;
struct sh_pfc_window *windows; struct sh_pfc_window *windows;
unsigned int *irqs = NULL; unsigned int *irqs = NULL;
struct resource *res; struct resource *res;
unsigned int i; unsigned int i;
int irq;
/* Count the MEM and IRQ resources. */ /* Count the MEM and IRQ resources. */
for (i = 0; i < pdev->num_resources; ++i) { for (num_windows = 0;; num_windows++) {
switch (resource_type(&pdev->resource[i])) { res = platform_get_resource(pdev, IORESOURCE_MEM, num_windows);
case IORESOURCE_MEM: if (!res)
num_windows++;
break; break;
}
case IORESOURCE_IRQ: for (num_irqs = 0;; num_irqs++) {
num_irqs++; irq = platform_get_irq(pdev, num_irqs);
if (irq == -EPROBE_DEFER)
return irq;
if (irq < 0)
break; break;
}
} }
if (num_windows == 0) if (num_windows == 0)
...@@ -72,22 +73,17 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, ...@@ -72,22 +73,17 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc,
} }
/* Fill them. */ /* Fill them. */
for (i = 0, res = pdev->resource; i < pdev->num_resources; i++, res++) { for (i = 0; i < num_windows; i++) {
switch (resource_type(res)) { res = platform_get_resource(pdev, IORESOURCE_MEM, i);
case IORESOURCE_MEM: windows->phys = res->start;
windows->phys = res->start; windows->size = resource_size(res);
windows->size = resource_size(res); windows->virt = devm_ioremap_resource(pfc->dev, res);
windows->virt = devm_ioremap_resource(pfc->dev, res); if (IS_ERR(windows->virt))
if (IS_ERR(windows->virt)) return -ENOMEM;
return -ENOMEM; windows++;
windows++;
break;
case IORESOURCE_IRQ:
*irqs++ = res->start;
break;
}
} }
for (i = 0; i < num_irqs; i++)
*irqs++ = platform_get_irq(pdev, i);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册