mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Subsystems (3)
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
In case of a DT-based probe of the stmpe MFD driver, the irq_gpio was zero, which resulted in the driver failing to probe.
Implement DT properties "irq-over-gpio" and "irq-gpios" which are already used in "arch/arm/boot/dts/spear320-hmi.dts" to circumvent these problems. The new behaviour is the expected one and copies the behavior of platform_data-based probe.
--- drivers/mfd/stmpe.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mfd/stmpe.c +5 -0
@@ -1018,6 +1018,11 @@ void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) pdata->id =-1 ; pdata->irq_trigger =IRQF_TRIGGER_NONE ; + pdata->irq_over_gpio =of_get_property (np,"irq-over-gpio" ,NULL ); + pdata->irq_gpio =of_get_named_gpio (np,"irq-gpios" ,0 ); +if (!gpio_is_valid (pdata->irq_gpio)) + pdata->irq_gpio =-1 ; +of_property_read_u32 (np,"st,autosleep-timeout" , &pdata->autosleep_timeout);
Signature · 1 line
1.7.10.4
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 5 lines · Marek Vasut
In case of a DT-based probe of the stmpe MFD driver, the
irq_gpiowas zero, which resulted in the driver failing to probe.Implement DT properties "irq-over-gpio" and "irq-gpios" which are already used in "
arch/arm/boot/dts/spear320-hmi.dts" to circumvent these problems.
This must have slipped through the gaps. It should be removed.
Quoted 3 lines
The new
behaviour is the expected one and copies the behavior of platform_data-based probe.
Blindly copying platform data behaviour to DT bindings is seldom a good idea.
Quoted 15 lines
Signed-off-by Marek Vasut <[email protected]>Cc Lee Jones <[email protected]>Cc Linus Walleij <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Vipul Kumar Samar <[email protected]>Cc Viresh Kumar <[email protected]>--- drivers/mfd/stmpe.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/mfd/stmpe.c +0
-0
drivers/mfd/stmpe.c void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) · line 1021
Quoted 4 lines
drivers/mfd/stmpe.c +1
-0@@ -1018,6 +1018,11 @@ void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) pdata->id =-1 ; pdata->irq_trigger =IRQF_TRIGGER_NONE ; + pdata->irq_over_gpio =of_get_property (np,"irq-over-gpio" ,NULL );
This is a new DT binding and you haven't provided any documentation for it.
Also, there is no reason for the binding to exist.
Lots of drivers use GPIO pins as IRQs.
Quoted 10 lines
drivers/mfd/stmpe.c +4
-0+ pdata->irq_gpio =of_get_named_gpio (np,"irq-gpios" ,0 ); +if (!gpio_is_valid (pdata->irq_gpio)) + pdata->irq_gpio =-1 ; +of_property_read_u32 (np,"st,autosleep-timeout" , &pdata->autosleep_timeout);Signature · 1 line
1.7.10.4
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Dear Lee Jones,
Quoted 9 lines · Marek Vasut
Quoted 6 lines
In case of a DT-based probe of the stmpe MFD driver, the
irq_gpiowas zero, which resulted in the driver failing to probe.Implement DT properties "irq-over-gpio" and "irq-gpios" which are already used in "
arch/arm/boot/dts/spear320-hmi.dts" to circumvent these problems.This must have slipped through the gaps. It should be removed.
True
Quoted 6 lines
Quoted 3 lines
The new
behaviour is the expected one and copies the behavior of platform_data-based probe.Blindly copying platform data behaviour to DT bindings is seldom a good idea.
Do you have suggestions how to pass these information? I suspect the irq-over- gpio property can be killed, since if irq-gpios prop is there, it implies irq- over-gpio anyway.
Quoted 21 lines
Quoted 21 lines
Signed-off-by Marek Vasut <[email protected]>Cc Lee Jones <[email protected]>Cc Linus Walleij <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Vipul Kumar Samar <[email protected]>Cc Viresh Kumar <[email protected]>---
drivers/mfd/stmpe.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/mfd/stmpe.c +0
-0@@ -1018,6 +1018,11 @@ void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) pdata->id =-1 ; pdata->irq_trigger =IRQF_TRIGGER_NONE ;
Quoted 7 lines
drivers/mfd/stmpe.c void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) · line 1021
Quoted 1 line
drivers/mfd/stmpe.c +1
-0+ pdata->irq_over_gpio =of_get_property (np,"irq-over-gpio" ,NULL );This is a new DT binding and you haven't provided any documentation for it.
Also, there is no reason for the binding to exist.
Lots of drivers use GPIO pins as IRQs.
Right, this can be removed and only the 'irq-gpios' can be kept around. What do you say?
Quoted 8 lines
drivers/mfd/stmpe.c void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np)
Quoted 8 lines
drivers/mfd/stmpe.c +4
-0+ pdata->irq_gpio =of_get_named_gpio (np,"irq-gpios" ,0 ); +if (!gpio_is_valid (pdata->irq_gpio)) + pdata->irq_gpio =-1 ; +drivers/mfd/stmpe.c +0
-0of_property_read_u32 (np,"st,autosleep-timeout" , &pdata->autosleep_timeout);
Best regards,
Marek Vasut
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 10 lines
Quoted 7 lines
drivers/mfd/stmpe.c void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) · line 1021
Quoted 1 line
drivers/mfd/stmpe.c +1
-0+ pdata->irq_over_gpio =of_get_property (np,"irq-over-gpio" ,NULL );This is a new DT binding and you haven't provided any documentation for it.
Also, there is no reason for the binding to exist.
Lots of drivers use GPIO pins as IRQs.
Right, this can be removed and only the 'irq-gpios' can be kept around. What do you say?
I don't like it to be honest.
How many GPIOs does the STMPE driver need?
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
In reply to Marek VasutQuoted 10 lines · Marek Vasut
Quoted 6 lines
Quoted 3 lines
The new
behaviour is the expected one and copies the behavior of platform_data-based probe.Blindly copying platform data behaviour to DT bindings is seldom a good idea.
Do you have suggestions how to pass these information? I suspect the irq-over- gpio property can be killed, since if irq-gpios prop is there, it implies irq- over-gpio anyway.
Both can be killed. gpios as interrupt lines can be requested as:
interrupt-parent = <&gpio-controller>;
interrupts = <25 0x1>;
and probably the stmpe driver doesn't have to bother at all if interrupt was over gpio
or not.
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 14 lines · Viresh Kumar
Quoted 10 lines · Marek Vasut
Quoted 6 lines
Quoted 3 lines
The new
behaviour is the expected one and copies the behavior of platform_data-based probe.Blindly copying platform data behaviour to DT bindings is seldom a good idea.
Do you have suggestions how to pass these information? I suspect the irq-over- gpio property can be killed, since if irq-gpios prop is there, it implies irq- over-gpio anyway.
Both can be killed. gpios as interrupt lines can be requested as:
Quoted 8 lines
interrupt-parent =<&gpio-controller>; interrupts =<25 0x1>;and probably the stmpe driver doesn't have to bother at all if interrupt was over gpio
or not.
.
Yes, both can be killed and similarly we did for spear1340 machine but some how we missed it on spear320-hmi.
Regards
Vipul Samar
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 10 lines
Quoted 7 lines
Both can be killed. gpios as interrupt lines can be requested as:
interrupt-parent =<&gpio-controller>;
interrupts =<250x1>;and probably the stmpe driver doesn't have to bother at all if interrupt was over gpio or not.
Yes, both can be killed and similarly we did for spear1340 machine but some how we missed it on spear320-hmi.
Bingo!
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Dear Lee Jones,
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Both can be killed. gpios as interrupt lines can be requested as:
interrupt-parent =<&gpio-controller>;
interrupts =<250x1>;and probably the stmpe driver doesn't have to bother at all if interrupt was over gpio or not.
Yes, both can be killed and similarly we did for spear1340 machine but some how we missed it on spear320-hmi.
Bingo!
All right, all right ... got it ;-)
I'll rework it and repost then.
Best regards,
Marek Vasut
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Dear Lee Jones,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Both can be killed. gpios as interrupt lines can be requested as:
interrupt-parent =<&gpio-controller>;
interrupts =<250x1>;and probably the stmpe driver doesn't have to bother at all if interrupt was over gpio or not.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Yes, both can be killed and similarly we did for spear1340 machine but some how we missed it on spear320-hmi.
Bingo!
All right, all right ... got it ;-)
I'll rework it and repost then.
Maybe I was too quick about understanding the issue at hand. So allow me a stupid question -- who's gonna configure the GPIO as input for it to work as IRQ GPIO?
Best regards,
Marek Vasut
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 3 lines · Marek Vasut
Maybe I was too quick about understanding the issue at hand. So allow me a stupid question -- who's gonna configure the GPIO as input for it to work as IRQ GPIO?
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.
Much of gpio controllers configure gpio pins in input mode in their probe().
Maybe, there is something else :)
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 11 lines · Viresh Kumar
Quoted 3 lines · Marek Vasut
Maybe I was too quick about understanding the issue at hand. So allow me a stupid question -- who's gonna configure the GPIO as input for it to work as IRQ GPIO?
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.
Quoted 3 lines
Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Pinctrl?
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 11 lines · Lee Jones
Quoted 9 lines
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Pinctrl?
I don't think pinctrl is playing with it. I searched for "direction_input" string and
pinctrl routine also had similar name. I couldn't fine use of direction_input anywhere
in kernel, for setting them as irqs for OF cases.
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 9 lines · Viresh Kumar
Quoted 8 lines · Lee Jones
Quoted 8 lines
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Maybe, there is something else :)
Pinctrl?
I don't think pinctrl is playing with it. I searched for "
direction_input" string and
pinctrl routine also had similar name. I couldn't fine use ofdirection_inputanywhere
in kernel, for setting them as irqs for OF cases.
I think we can do it in the gpio chip driver inthe function xxx_gpio_irq_set_type().
When you register any irq and if this callback is available from gpio chip driver then this will get called. and so the setting the pi to input mode as well as putting the pin in GPIO mode can be done here. This is what we are doing it in gpio-tegra driver.
Thanks,
Laxman
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 6 lines · Laxman Dewangan
I think we can do it in the gpio chip driver inthe function
xxx_gpio_irq_set_type().
When you register any irq and if this callback is available from gpio chip driver then this will get called. and so the setting the pi to input mode as well as putting the pin in GPIO mode can be done here. This is what we are doing it in gpio-tegra driver.
Hmm... So, the initial question was, is somebody setting gpio in input mode? There were no bugs reported, it was just a query. As most of the stuff would work as per my earlier explanation.
But yes, your suggestion makes sense too.. I would rather do it in the gpiolib routine instead of adding this in every driver.
@Linus/Grant: What do you say?
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
In reply to Viresh KumarQuoted 11 lines · Viresh Kumar
Quoted 10 lines · Lee Jones
Quoted 9 lines
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Quoted 7 lines
Quoted 1 line
Pinctrl?
I don't think pinctrl is playing with it. I searched for "
direction_input" string and
pinctrl routine also had similar name. I couldn't fine use ofdirection_inputanywhere
in kernel, for setting them as irqs for OF cases.
pinctrl has pinctrl_gpio_direction_input() and pinctrl_gpio_direction_output() which are supposed to be called *only* by GPIOlib frontends using pinctrl as backend to control the pins.
But if it's a pinctrl driver using standard pinconfig from include/linux/pinctrl/pinconf-generic.h
I'm all for adding a PIN_CONFIG_INPUT_ENABLE
to these definintions so it can be set up as input at boot from the device tree using hogs or something, that make things easy when using GPIOs as IRQ providers only.
So the alternative is to just set up the IRQ using the gpiolib functions for this: of_get_gpio() if you need the number from DT, then gpio_request() and gpio_direction_input() as on any GPIO. This can be done in the device driver or board code depending on use case.
In the Nomadik I did this (maybe ugly) hack for a
similar case:
+/*
+ * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects
+ * to simply request an IRQ passed as a resource. So the GPIO pin needs
+ * to be requested by this hog and set as input.
+ */
+static int __init cpu8815_eth_init(void)
+{
+ struct device_node *eth;
+ int gpio, irq, err;
+
+ eth = of_find_node_by_path("/external-bus at 34000000/ethernet at 300");
+ if (!eth) {
+ pr_info("could not find any ethernet controller\n");
+ return 0;
+ }
+ gpio = of_get_gpio(eth, 0);
+ err = gpio_request(gpio, "eth_irq");
+ if (err) {
+ pr_info("failed to request ethernet GPIO\n");
+ return -ENODEV;
+ }
+ err = gpio_direction_input(gpio);
+ if (err) {
+ pr_info("failed to set ehernet GPIO as input\n");
+ return -ENODEV;
+ }
+ irq = gpio_to_irq(gpio);
+ pr_info("enabled ethernet GPIO %d, IRQ %d\n", gpio, irq);
+ return 0;+}
+device_initcall(cpu8815_eth_init);
I haven't read review comments on that patch.
Maybe it's not such a good idea to add the GPIO to the device itself when it's being hogged by board code like this. It's a bit of a grey area so I'm a bit confused here.
Maybe the GPIO lib actually needs a "hog" mechanism that can request and set GPIO pins as input/output on boot and then forget about them.
Yours,
Linus Walleij
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Quoted 64 lines · Linus Walleij
Quoted 11 lines · Viresh Kumar
Quoted 10 lines · Lee Jones
Quoted 9 lines
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Quoted 7 lines
Quoted 1 line
Pinctrl?
I don't think pinctrl is playing with it. I searched for "
direction_input" string and
pinctrl routine also had similar name. I couldn't fine use ofdirection_inputanywhere
in kernel, for setting them as irqs for OF cases.pinctrl has
pinctrl_gpio_direction_input()andpinctrl_gpio_direction_output()which are supposed to be called *only* by GPIOlib frontends using pinctrl as backend to control the pins.But if it's a pinctrl driver using standard pinconfig from
include/linux/pinctrl/pinconf-generic.h
I'm all for adding aPIN_CONFIG_INPUT_ENABLE
to these definintions so it can be set up as input at boot from the device tree using hogs or something, that make things easy when using GPIOs as IRQ providers only.So the alternative is to just set up the IRQ using the gpiolib functions for this:
of_get_gpio()if you need the number from DT, thengpio_request()andgpio_direction_input()as on any GPIO. This can be done in the device driver or board code depending on use case.In the Nomadik I did this (maybe ugly) hack for a
similar case:(quoted diff) +21
-0+/* + * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects + * to simply request an IRQ passed as a resource. So the GPIO pin needs + * to be requested by this hog and set as input. + */ +static int __init cpu8815_eth_init(void) +{ + struct device_node *eth; + int gpio, irq, err; + + eth = of_find_node_by_path("/external-bus at 34000000/ethernet at 300"); + if (!eth) { + pr_info("could not find any ethernet controller\n"); + return 0; + } + gpio = of_get_gpio(eth, 0); + err = gpio_request(gpio, "eth_irq"); + if (err) { + pr_info("failed to request ethernet GPIO\n"); + return -ENODEV; + }
Review
Quoted 10 lines
(quoted diff) +10
-0+ err = gpio_direction_input(gpio); + if (err) { + pr_info("failed to set ehernet GPIO as input\n"); + return -ENODEV; + } + irq = gpio_to_irq(gpio); + pr_info("enabled ethernet GPIO %d, IRQ %d\n", gpio, irq); + return 0; +} +device_initcall(cpu8815_eth_init);
Yep, that looks pretty gross!
Quoted 12 lines
I haven't read review comments on that patch.
Maybe it's not such a good idea to add the GPIO to the device itself when it's being hogged by board code like this. It's a bit of a grey area so I'm a bit confused here.
Maybe the GPIO lib actually needs a "hog" mechanism that can request and set GPIO pins as input/output on boot and then forget about them.
Yours,
Linus Walleij
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
In reply to Linus WalleijQuoted 77 lines · Linus Walleij
Quoted 11 lines · Viresh Kumar
Quoted 10 lines · Lee Jones
Quoted 9 lines
Hmm.. I tried a bit, but couldn't find any such call :(
Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Quoted 7 lines
Quoted 1 line
Pinctrl?
I don't think pinctrl is playing with it. I searched for "
direction_input" string and
pinctrl routine also had similar name. I couldn't fine use ofdirection_inputanywhere
in kernel, for setting them as irqs for OF cases.pinctrl has
pinctrl_gpio_direction_input()andpinctrl_gpio_direction_output()which are supposed to be called *only* by GPIOlib frontends using pinctrl as backend to control the pins.But if it's a pinctrl driver using standard pinconfig from
include/linux/pinctrl/pinconf-generic.h
I'm all for adding aPIN_CONFIG_INPUT_ENABLE
to these definintions so it can be set up as input at boot from the device tree using hogs or something, that make things easy when using GPIOs as IRQ providers only.So the alternative is to just set up the IRQ using the gpiolib functions for this:
of_get_gpio()if you need the number from DT, thengpio_request()andgpio_direction_input()as on any GPIO. This can be done in the device driver or board code depending on use case.In the Nomadik I did this (maybe ugly) hack for a
similar case:(quoted diff) +31
-0+/* + * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects + * to simply request an IRQ passed as a resource. So the GPIO pin needs + * to be requested by this hog and set as input. + */ +static int __init cpu8815_eth_init(void) +{ + struct device_node *eth; + int gpio, irq, err; + + eth = of_find_node_by_path("/external-bus at 34000000/ethernet at 300"); + if (!eth) { + pr_info("could not find any ethernet controller\n"); + return 0; + } + gpio = of_get_gpio(eth, 0); + err = gpio_request(gpio, "eth_irq"); + if (err) { + pr_info("failed to request ethernet GPIO\n"); + return -ENODEV; + } + err = gpio_direction_input(gpio); + if (err) { + pr_info("failed to set ehernet GPIO as input\n"); + return -ENODEV; + } + irq = gpio_to_irq(gpio); + pr_info("enabled ethernet GPIO %d, IRQ %d\n", gpio, irq); + return 0; +} +device_initcall(cpu8815_eth_init);I haven't read review comments on that patch.
Quoted 7 lines
Maybe it's not such a good idea to add the GPIO to the device itself when it's being hogged by board code like this. It's a bit of a grey area so I'm a bit confused here.
Maybe the GPIO lib actually needs a "hog" mechanism that can request and set GPIO pins as input/output on boot and then forget about them.
That would be reasonable. Probably as properties in the gpio controller node that specify how to set the inital state.
g.
PATCH 1/1 mfd: stmpe: Pull IRQ GPIO number from DT during DT-based probe
Dear Grant Likely,
Quoted 1 line
On Thu, 10 Jan 2013 12:42:53 +0100, Linus Walleij <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
On Tue, Jan 8, 2013 at 12:14 PM, Viresh Kumar <[email protected]>
Quoted 82 lines · wrote:
Quoted 82 lines
Quoted 12 lines · Lee Jones
Quoted 11 lines
Quoted 10 lines
Hmm.. I tried a bit, but couldn't find any such call :( Probably an assumption is taken here. GPIO pins which are going to be used as interrupt lines, wouldn't be getting set in output mode at all. So, once they are put
in input mode in beginning, nobody would change it ever.Much of gpio controllers configure gpio pins in input mode in their
probe().Maybe, there is something else :)
Quoted 7 lines
Quoted 1 line
Pinctrl?
I don't think pinctrl is playing with it. I searched for "
direction_input" string and
pinctrl routine also had similar name. I couldn't fine use ofdirection_inputanywhere
in kernel, for setting them as irqs for OF cases.pinctrl has
pinctrl_gpio_direction_input()andpinctrl_gpio_direction_output()which are supposed to be called *only* by GPIOlib frontends using pinctrl as backend to control the pins.But if it's a pinctrl driver using standard pinconfig from
include/linux/pinctrl/pinconf-generic.h
I'm all for adding aPIN_CONFIG_INPUT_ENABLE
to these definintions so it can be set up as input at boot from the device tree using hogs or something, that make things easy when using GPIOs as IRQ providers only.So the alternative is to just set up the IRQ using the gpiolib functions for this:
of_get_gpio()if you need the number from DT, thengpio_request()andgpio_direction_input()as on any GPIO. This can be done in the device driver or board code depending on use case.In the Nomadik I did this (maybe ugly) hack for a
similar case:(quoted diff) +11
-0+/* + * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects + * to simply request an IRQ passed as a resource. So the GPIO pin needs + * to be requested by this hog and set as input. + */ +static int __init cpu8815_eth_init(void) +{ + struct device_node *eth; + int gpio, irq, err; + + eth =
of_find_node_by_path("/external-bus at 34000000/ethernet at 300"); + if
(!eth) {(quoted diff) +19
-0+ pr_info("could not find any ethernet controller\n"); + return 0; + } + gpio = of_get_gpio(eth, 0); + err = gpio_request(gpio, "eth_irq"); + if (err) { + pr_info("failed to request ethernet GPIO\n"); + return -ENODEV; + } + err = gpio_direction_input(gpio); + if (err) { + pr_info("failed to set ehernet GPIO as input\n"); + return -ENODEV; + } + irq = gpio_to_irq(gpio); + pr_info("enabled ethernet GPIO %d, IRQ %d\n", gpio, irq); + return 0; +} +device_initcall(cpu8815_eth_init);I haven't read review comments on that patch.
Maybe it's not such a good idea to add the GPIO to the device itself when it's being hogged by board code like this. It's a bit of a grey area so I'm a bit confused here.
Quoted 6 lines
Quoted 3 lines
Maybe the GPIO lib actually needs a "hog" mechanism that can request and set GPIO pins as input/output on boot and then forget about them.
That would be reasonable. Probably as properties in the gpio controller node that specify how to set the inital state.
Looks good.
btw. I have a feeling this stmpe touchscreen driver has a few more issues, but I'll need to investigate before I jump to any conclusion.
Best regards,
Marek Vasut