* [PATCH RESEND] gpio: rcar: Support both edge trigger with DT
@ 2013-11-29 13:48 Laurent Pinchart
2013-11-29 20:06 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2013-11-29 13:48 UTC (permalink / raw)
To: linux-sh; +Cc: linux-gpio, Linus Walleij, Magnus Damm
Some versions of the R-Car GPIO controller support triggering on both
edges of the input signal. Whether this capability is supported is
currently specified in platform data. R-Car GPIO devices instantiated
from the device tree have the capability turned off even when the
hardware supports it.
To fix this, add DT match data support to the driver, initialize both
edge trigger support from match data and enable both edge trigger in
r8a7790 and r8a7791 match data.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Magnus Damm <damm@opensource.se>
---
drivers/gpio/gpio-rcar.c | 56 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 43 insertions(+), 13 deletions(-)
(With the correct linux-sh address this time, sorry about the noise)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 5c25fa1..2fdd019 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -284,7 +284,34 @@ static struct irq_domain_ops gpio_rcar_irq_domain_ops = {
.map = gpio_rcar_irq_domain_map,
};
-static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
+struct gpio_rcar_info {
+ bool has_both_edge_trigger;
+};
+
+static const struct of_device_id gpio_rcar_of_table[] = {
+ {
+ .compatible = "renesas,gpio-r8a7790",
+ .data = (void *)&(const struct gpio_rcar_info) {
+ .has_both_edge_trigger = true,
+ },
+ }, {
+ .compatible = "renesas,gpio-r8a7791",
+ .data = (void *)&(const struct gpio_rcar_info) {
+ .has_both_edge_trigger = true,
+ },
+ }, {
+ .compatible = "renesas,gpio-rcar",
+ .data = (void *)&(const struct gpio_rcar_info) {
+ .has_both_edge_trigger = false,
+ },
+ }, {
+ /* Terminator */
+ },
+};
+
+MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);
+
+static int gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
{
struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev);
struct device_node *np = p->pdev->dev.of_node;
@@ -294,11 +321,21 @@ static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
if (pdata) {
p->config = *pdata;
} else if (IS_ENABLED(CONFIG_OF) && np) {
+ const struct of_device_id *match;
+ const struct gpio_rcar_info *info;
+
+ match = of_match_node(gpio_rcar_of_table, np);
+ if (!match)
+ return -EINVAL;
+
+ info = match->data;
+
ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0,
&args);
p->config.number_of_pins = ret = 0 ? args.args[2]
: RCAR_MAX_GPIO_PER_BANK;
p->config.gpio_base = -1;
+ p->config.has_both_edge_trigger = info->has_both_edge_trigger;
}
if (p->config.number_of_pins = 0 ||
@@ -308,6 +345,8 @@ static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK);
p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK;
}
+
+ return 0;
}
static int gpio_rcar_probe(struct platform_device *pdev)
@@ -330,7 +369,9 @@ static int gpio_rcar_probe(struct platform_device *pdev)
spin_lock_init(&p->lock);
/* Get device configuration from DT node or platform data. */
- gpio_rcar_parse_pdata(p);
+ ret = gpio_rcar_parse_pdata(p);
+ if (ret < 0)
+ return ret;
platform_set_drvdata(pdev, p);
@@ -434,17 +475,6 @@ static int gpio_rcar_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_OF
-static const struct of_device_id gpio_rcar_of_table[] = {
- {
- .compatible = "renesas,gpio-rcar",
- },
- { },
-};
-
-MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);
-#endif
-
static struct platform_driver gpio_rcar_device_driver = {
.probe = gpio_rcar_probe,
.remove = gpio_rcar_remove,
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] gpio: rcar: Support both edge trigger with DT
2013-11-29 13:48 [PATCH RESEND] gpio: rcar: Support both edge trigger with DT Laurent Pinchart
@ 2013-11-29 20:06 ` Linus Walleij
2013-11-29 20:15 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2013-11-29 20:06 UTC (permalink / raw)
To: Laurent Pinchart
Cc: linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org, Magnus Damm
On Fri, Nov 29, 2013 at 2:48 PM, Laurent Pinchart
<laurent.pinchart+renesas@ideasonboard.com> wrote:
> Some versions of the R-Car GPIO controller support triggering on both
> edges of the input signal. Whether this capability is supported is
> currently specified in platform data. R-Car GPIO devices instantiated
> from the device tree have the capability turned off even when the
> hardware supports it.
>
> To fix this, add DT match data support to the driver, initialize both
> edge trigger support from match data and enable both edge trigger in
> r8a7790 and r8a7791 match data.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Acked-by: Magnus Damm <damm@opensource.se>
Patch applied, but shouldn't there be some change to add these
new compatible strings to Documentation/devicetree/bindings/*
somewhere?
Accepted as follow-on patch or something to be squashed into
this later if I'm right.
Thanks!
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] gpio: rcar: Support both edge trigger with DT
2013-11-29 20:06 ` Linus Walleij
@ 2013-11-29 20:15 ` Laurent Pinchart
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2013-11-29 20:15 UTC (permalink / raw)
To: Linus Walleij
Cc: Laurent Pinchart, linux-sh@vger.kernel.org,
linux-gpio@vger.kernel.org, Magnus Damm
Hi Linus,
On Friday 29 November 2013 21:06:17 Linus Walleij wrote:
> On Fri, Nov 29, 2013 at 2:48 PM, Laurent Pinchart wrote:
> > Some versions of the R-Car GPIO controller support triggering on both
> > edges of the input signal. Whether this capability is supported is
> > currently specified in platform data. R-Car GPIO devices instantiated
> > from the device tree have the capability turned off even when the
> > hardware supports it.
> >
> > To fix this, add DT match data support to the driver, initialize both
> > edge trigger support from match data and enable both edge trigger in
> > r8a7790 and r8a7791 match data.
> >
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > Acked-by: Magnus Damm <damm@opensource.se>
>
> Patch applied, but shouldn't there be some change to add these
> new compatible strings to Documentation/devicetree/bindings/*
> somewhere?
You're right.
> Accepted as follow-on patch or something to be squashed into
> this later if I'm right.
Sent.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-29 20:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-29 13:48 [PATCH RESEND] gpio: rcar: Support both edge trigger with DT Laurent Pinchart
2013-11-29 20:06 ` Linus Walleij
2013-11-29 20:15 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).