* How to define gpio irq with device tree
@ 2012-08-10 12:30 Knut Wohlrab
2012-08-14 4:18 ` Shawn Guo
0 siblings, 1 reply; 5+ messages in thread
From: Knut Wohlrab @ 2012-08-10 12:30 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
I try the touch screen of a iMX6 SabreLite evaluation board. The used
eGalax touch controller worked fine with a 3.2.x kernel [1]. As
mentioned there [2] I merge the basic device tree support to the actual
driver (see patch [4]) and add the touch definition to
arch/arm/boot/dts/imx6q-sabrelite.dts [3].
The driver seems to start but the interrupt never occurs.
The pinmux and I2C configuration seems correct. I did a simple test with
polling the interrupt gpio (see "POLLTEST" in patch [4]) and got
coordinates matching to the movements on the screen.
How to configure the gpio irq correctly?
Anybody solved to work with the eGalax touch and iMX6 SabreLite with
kernel > 3.2?
Thanks a lot for any information.
[1]
http://git.linaro.org/gitweb?p=landing-teams/working/freescale/kernel.git;a=shortlog;h=refs/heads/lt-3.2-imx6
[2]
http://git.linaro.org/gitweb?p=landing-teams/working/freescale/kernel.git;a=blob;f=drivers/input/touchscreen/egalax_ts.c;h=58184dad7a2e1b6a42711acddb184d68ffceeb4c;hb=refs/heads/lt-3.2-imx6
[3]
...
i2c at 021a8000 { /* I2C3 */
status = "okay";
clock-frequency = <400000>;
egalax at 04 {
compatible = "eeti,egalax";
reg = <0x04>;
interrupt-parent = <&gpio1>;
interrupts = <9 0x08>;
interrupt-gpio = <&gpio1 9 0>;
};
...
[4]
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 70524dd..653a97a 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -28,6 +28,9 @@
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/input/mt.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
/*
* Mouse Mode: some panel may configure the controller to mouse mode,
@@ -62,6 +65,7 @@
struct egalax_ts {
struct i2c_client *client;
struct input_dev *input_dev;
+ int gpio_irq;
};
static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
@@ -122,7 +126,8 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
- int gpio = irq_to_gpio(client->irq);
+ struct egalax_ts *ts = i2c_get_clientdata(client);
+ int gpio = ts->gpio_irq;
int ret;
ret = gpio_request(gpio, "egalax_irq");
@@ -159,6 +164,7 @@ static int __devinit egalax_firmware_version(struct i2c_client *client)
static int __devinit egalax_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device_node *n = client->dev.of_node;
struct egalax_ts *ts;
struct input_dev *input_dev;
int ret;
@@ -179,6 +185,13 @@ static int __devinit egalax_ts_probe(struct i2c_client *client,
ts->client = client;
ts->input_dev = input_dev;
+ ts->gpio_irq = of_get_named_gpio(n, "interrupt-gpio", 0);
+ if (!gpio_is_valid(ts->gpio_irq))
+ dev_warn(&client->dev, "invalid interrupt GPIO\n");
+ else
+ dev_info(&client->dev, "valid interrupt GPIO:%d\n", ts->gpio_irq);
+
+ i2c_set_clientdata(client, ts);
/* controller may be in sleep, wake it up. */
egalax_wake_up_device(client);
@@ -214,13 +227,31 @@ static int __devinit egalax_ts_probe(struct i2c_client *client,
if (error < 0) {
dev_err(&client->dev, "Failed to register interrupt\n");
goto err_free_dev;
+ }else{
+ dev_info(&client->dev, "register interrupt: %d\n", client->irq);
}
error = input_register_device(ts->input_dev);
if (error)
goto err_free_irq;
- i2c_set_clientdata(client, ts);
+//#define POLLTEST
+#ifdef POLLTEST
+ while(1){
+ if(!gpio_get_value(ts->gpio_irq)){
+ u8 buf[MAX_I2C_DATA_LEN];
+ int i, ret, tries = 0;
+ do {
+ ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
+
+ for(i=0; i<ret; ++i)
+ printk("0x%02X ", buf[i]);
+
+ printk("\n");
+ } while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
+ }
+ }
+#endif
return 0;
err_free_irq:
@@ -251,6 +282,12 @@ static const struct i2c_device_id egalax_ts_id[] = {
};
MODULE_DEVICE_TABLE(i2c, egalax_ts_id);
+static struct of_device_id egalax_dt_ids[] = {
+ { .compatible = "eeti,egalax" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx_uart_dt_ids);
+
#ifdef CONFIG_PM_SLEEP
static int egalax_ts_suspend(struct device *dev)
{
@@ -279,6 +316,7 @@ static struct i2c_driver egalax_ts_driver = {
.name = "egalax_ts",
.owner = THIS_MODULE,
.pm = &egalax_ts_pm_ops,
+ .of_match_table = egalax_dt_ids,
},
.id_table = egalax_ts_id,
.probe = egalax_ts_probe,
^ permalink raw reply related [flat|nested] 5+ messages in thread
* How to define gpio irq with device tree
2012-08-10 12:30 How to define gpio irq with device tree Knut Wohlrab
@ 2012-08-14 4:18 ` Shawn Guo
2012-08-14 5:46 ` Hui Wang
0 siblings, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2012-08-14 4:18 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Aug 10, 2012 at 02:30:59PM +0200, Knut Wohlrab wrote:
> Hello,
>
> I try the touch screen of a iMX6 SabreLite evaluation board. The
> used eGalax touch controller worked fine with a 3.2.x kernel [1]. As
> mentioned there [2] I merge the basic device tree support to the
> actual driver (see patch [4]) and add the touch definition to
> arch/arm/boot/dts/imx6q-sabrelite.dts [3].
>
> The driver seems to start but the interrupt never occurs.
>
> The pinmux and I2C configuration seems correct. I did a simple test
> with polling the interrupt gpio (see "POLLTEST" in patch [4]) and
> got coordinates matching to the movements on the screen.
>
> How to configure the gpio irq correctly?
>
> Anybody solved to work with the eGalax touch and iMX6 SabreLite with
> kernel > 3.2?
>
I'm not interested in reviewing those out-of-tree codes to see what
goes wrong there. But I just quickly enabled the driver for
imx6q-sabrelite board with the following changes against latest
mainline. And the interrupt seems working for me.
Regards,
Shawn
--8<---
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 72f30f3..c8511c1 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -115,6 +115,21 @@
VDDIO-supply = <®_3p3v>;
};
};
+
+ i2c at 021a8000 { /* I2C3 */
+ status = "okay";
+ clock-frequency = <400000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c3_1>;
+
+ egalax at 04 {
+ compatible = "eeti,egalax";
+ reg = <0x04>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <9 0x8>;
+ wakeup-gpios = <&gpio1 9 0>;
+ };
+ };
};
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 3d3c64b..bbf5196 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -545,6 +545,13 @@
};
};
+ i2c3 {
+ pinctrl_i2c3_1: i2c3grp-1 {
+ fsl,pins = <1013 0x4001b8b1 /* MX6Q_PAD_GPIO_5__I2C3_SCL */
+ 1037 0x4001b8b1>; /* MX6Q_PAD_GPIO_16__I2C3_SDA */
+ };
+ };
+
serial2 {
pinctrl_serial2_1: serial2grp-1 {
fsl,pins = <183 0x1b0b1 /* MX6Q_PAD_EIM_D26__UART2_TXD */
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 70524dd..013011d 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -28,6 +28,8 @@
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/input/mt.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
/*
* Mouse Mode: some panel may configure the controller to mouse mode,
@@ -122,7 +124,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
- int gpio = irq_to_gpio(client->irq);
+ int gpio = of_get_named_gpio(client->dev.of_node, "wakeup-gpios", 0);
int ret;
ret = gpio_request(gpio, "egalax_irq");
@@ -251,6 +253,12 @@ static const struct i2c_device_id egalax_ts_id[] = {
};
MODULE_DEVICE_TABLE(i2c, egalax_ts_id);
+static struct of_device_id egalax_ts_dt_ids[] = {
+ { .compatible = "eeti,egalax" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, egalax_ts_dt_ids);
+
#ifdef CONFIG_PM_SLEEP
static int egalax_ts_suspend(struct device *dev)
{
@@ -279,6 +287,7 @@ static struct i2c_driver egalax_ts_driver = {
.name = "egalax_ts",
.owner = THIS_MODULE,
.pm = &egalax_ts_pm_ops,
+ .of_match_table = egalax_ts_dt_ids,
},
.id_table = egalax_ts_id,
.probe = egalax_ts_probe,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* How to define gpio irq with device tree
2012-08-14 4:18 ` Shawn Guo
@ 2012-08-14 5:46 ` Hui Wang
2012-08-14 6:46 ` Shawn Guo
0 siblings, 1 reply; 5+ messages in thread
From: Hui Wang @ 2012-08-14 5:46 UTC (permalink / raw)
To: linux-arm-kernel
Shawn Guo wrote:
> On Fri, Aug 10, 2012 at 02:30:59PM +0200, Knut Wohlrab wrote:
>
>> Hello,
>>
>> I try the touch screen of a iMX6 SabreLite evaluation board. The
>> used eGalax touch controller worked fine with a 3.2.x kernel [1]. As
>> mentioned there [2] I merge the basic device tree support to the
>> actual driver (see patch [4]) and add the touch definition to
>> arch/arm/boot/dts/imx6q-sabrelite.dts [3].
>>
>> The driver seems to start but the interrupt never occurs.
>>
>> The pinmux and I2C configuration seems correct. I did a simple test
>> with polling the interrupt gpio (see "POLLTEST" in patch [4]) and
>> got coordinates matching to the movements on the screen.
>>
>> How to configure the gpio irq correctly?
>>
>> Anybody solved to work with the eGalax touch and iMX6 SabreLite with
>> kernel > 3.2?
>>
>>
> I'm not interested in reviewing those out-of-tree codes to see what
> goes wrong there. But I just quickly enabled the driver for
> imx6q-sabrelite board with the following changes against latest
> mainline. And the interrupt seems working for me.
>
>
I generated a similar patch on the last week, only the linux-input part.
please refer to https://patchwork.kernel.org/patch/1293451/
For mach dts part:
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index d42e851..71fcd12 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -53,6 +53,7 @@
fsl,pins = <
144 0x80000000 /* MX6Q_PAD_EIM_D22__GPIO_3_22 */
121 0x80000000 /* MX6Q_PAD_EIM_D19__GPIO_3_19 */
+ 972 0x10 /* MX6Q_PAD_GPIO_9__GPIO_1_9 */
>;
};
};
@@ -114,6 +115,21 @@
VDDIO-supply = <®_3p3v>;
};
};
+
+ i2c at 021a8000 { /* I2C3 */
+ status = "okay";
+ clock-frequency = <100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c3_1>;
+
+ egalax_ts at 04 {
+ compatible = "eeti,egalax_ts";
+ reg = <0x04>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <9 2>;
+ irq-gpio = <&gpio1 9 0>;
+ };
+ };
};
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 3d3c64b..ebbd624 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -545,6 +545,14 @@
};
};
+
+ i2c3 {
+ pinctrl_i2c3_1: i2c3grp-1 {
+ fsl,pins = <1013 0x4001b8b1 /* MX6Q_PAD_GPIO_5__I2C3_SCL */
+ 1037 0x4001b8b1>; /* MX6Q_PAD_GPIO_16__I2C3_SDA */
+ };
+ };
+
serial2 {
pinctrl_serial2_1: serial2grp-1 {
fsl,pins = <183 0x1b0b1 /* MX6Q_PAD_EIM_D26__UART2_TXD */
> Regards,
> Shawn
>
> --8<---
>
> diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
> index 72f30f3..c8511c1 100644
> --- a/arch/arm/boot/dts/imx6q-sabrelite.dts
> +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
> @@ -115,6 +115,21 @@
> VDDIO-supply = <®_3p3v>;
> };
> };
> +
> + i2c at 021a8000 { /* I2C3 */
> + status = "okay";
> + clock-frequency = <400000>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_i2c3_1>;
> +
> + egalax at 04 {
> + compatible = "eeti,egalax";
> + reg = <0x04>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <9 0x8>;
> + wakeup-gpios = <&gpio1 9 0>;
> + };
> + };
> };
> };
>
> diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
> index 3d3c64b..bbf5196 100644
> --- a/arch/arm/boot/dts/imx6q.dtsi
> +++ b/arch/arm/boot/dts/imx6q.dtsi
> @@ -545,6 +545,13 @@
> };
> };
>
> + i2c3 {
> + pinctrl_i2c3_1: i2c3grp-1 {
> + fsl,pins = <1013 0x4001b8b1 /* MX6Q_PAD_GPIO_5__I2C3_SCL */
> + 1037 0x4001b8b1>; /* MX6Q_PAD_GPIO_16__I2C3_SDA */
> + };
> + };
> +
> serial2 {
> pinctrl_serial2_1: serial2grp-1 {
> fsl,pins = <183 0x1b0b1 /* MX6Q_PAD_EIM_D26__UART2_TXD */
> diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
> index 70524dd..013011d 100644
> --- a/drivers/input/touchscreen/egalax_ts.c
> +++ b/drivers/input/touchscreen/egalax_ts.c
> @@ -28,6 +28,8 @@
> #include <linux/slab.h>
> #include <linux/bitops.h>
> #include <linux/input/mt.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>
> /*
> * Mouse Mode: some panel may configure the controller to mouse mode,
> @@ -122,7 +124,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
> /* wake up controller by an falling edge of interrupt gpio. */
> static int egalax_wake_up_device(struct i2c_client *client)
> {
> - int gpio = irq_to_gpio(client->irq);
> + int gpio = of_get_named_gpio(client->dev.of_node, "wakeup-gpios", 0);
> int ret;
>
> ret = gpio_request(gpio, "egalax_irq");
> @@ -251,6 +253,12 @@ static const struct i2c_device_id egalax_ts_id[] = {
> };
> MODULE_DEVICE_TABLE(i2c, egalax_ts_id);
>
> +static struct of_device_id egalax_ts_dt_ids[] = {
> + { .compatible = "eeti,egalax" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, egalax_ts_dt_ids);
> +
> #ifdef CONFIG_PM_SLEEP
> static int egalax_ts_suspend(struct device *dev)
> {
> @@ -279,6 +287,7 @@ static struct i2c_driver egalax_ts_driver = {
> .name = "egalax_ts",
> .owner = THIS_MODULE,
> .pm = &egalax_ts_pm_ops,
> + .of_match_table = egalax_ts_dt_ids,
> },
> .id_table = egalax_ts_id,
> .probe = egalax_ts_probe,
>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* How to define gpio irq with device tree
2012-08-14 5:46 ` Hui Wang
@ 2012-08-14 6:46 ` Shawn Guo
2012-08-14 6:54 ` Hui Wang
0 siblings, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2012-08-14 6:46 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Aug 14, 2012 at 01:46:46PM +0800, Hui Wang wrote:
> I generated a similar patch on the last week, only the linux-input
> part. please refer to https://patchwork.kernel.org/patch/1293451/
>
Ok. But can you rename property "irq-gpio" to "wakeup-gpios"?
Firstly, the idiom of gpio naming in DT is *-gpios, even though
most of time, it could be just one gpio. Secondly, as the pin is
accessed as a gpio only in egalax_wake_up_device for waking up the
device, "wakeup-gpios" sounds better?
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 5+ messages in thread
* How to define gpio irq with device tree
2012-08-14 6:46 ` Shawn Guo
@ 2012-08-14 6:54 ` Hui Wang
0 siblings, 0 replies; 5+ messages in thread
From: Hui Wang @ 2012-08-14 6:54 UTC (permalink / raw)
To: linux-arm-kernel
Shawn Guo wrote:
> On Tue, Aug 14, 2012 at 01:46:46PM +0800, Hui Wang wrote:
>
>> I generated a similar patch on the last week, only the linux-input
>> part. please refer to https://patchwork.kernel.org/patch/1293451/
>>
>>
> Ok. But can you rename property "irq-gpio" to "wakeup-gpios"?
> Firstly, the idiom of gpio naming in DT is *-gpios, even though
> most of time, it could be just one gpio. Secondly, as the pin is
> accessed as a gpio only in egalax_wake_up_device for waking up the
> device, "wakeup-gpios" sounds better?
>
>
Both accepted.
Thanks,
Hui.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-14 6:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-10 12:30 How to define gpio irq with device tree Knut Wohlrab
2012-08-14 4:18 ` Shawn Guo
2012-08-14 5:46 ` Hui Wang
2012-08-14 6:46 ` Shawn Guo
2012-08-14 6:54 ` Hui Wang
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).