Message ID | 1493295756-17812-1-git-send-email-martin.kepplinger@ginzinger.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Thu, Apr 27, 2017 at 02:22:35PM +0200, Martin Kepplinger wrote: > The device could as well be in command mode, in which this driver cannot > handle the device. When opening the device, let's make sure the device > will be in the mode we expect it to be for this driver. > > Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com> > --- > drivers/input/touchscreen/ar1021_i2c.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c > index 1a94d8b..2a76231 100644 > --- a/drivers/input/touchscreen/ar1021_i2c.c > +++ b/drivers/input/touchscreen/ar1021_i2c.c > @@ -18,6 +18,12 @@ > #define AR1021_MAX_X 4095 > #define AR1021_MAX_Y 4095 > > +#define AR1021_CMD 0x55 > +#define AR1021_TOUCH 0x80 > + > +#define AR1021_CMD_ENABLE_TOUCH 0x12 > +#define AR1021_CMD_DISABLE_TOUCH 0x13 > + > struct ar1021_i2c { > struct i2c_client *client; > struct input_dev *input; > @@ -58,6 +64,15 @@ static int ar1021_i2c_open(struct input_dev *dev) > { > struct ar1021_i2c *ar1021 = input_get_drvdata(dev); > struct i2c_client *client = ar1021->client; > + int error; > + u8 cmd_enable_touch[3] = {AR1021_CMD, > + 0x01, /* number of bytes after this */ > + AR1021_CMD_ENABLE_TOUCH }; Changed to static const and applied, thank you. > + > + error = i2c_master_send(ar1021->client, cmd_enable_touch, > + sizeof(cmd_enable_touch)); > + if (error < 0) > + return error; > > enable_irq(client->irq); > > -- > 2.1.4 >
Hi all. 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: > The device could as well be in command mode, in which this driver cannot > handle the device. When opening the device, let's make sure the device > will be in the mode we expect it to be for this driver. > I run into issues caused by this change. It turns out that the device is non-functional after some warm-reboots and as a result I am not able to use xorg's evdev driver. So I have some questions about this change: * Should we enable irq before calling i2c_master_send(..) as the chip raises an irq if the command was processed? * Would it be enough to send this command only once during driver lifetime? I can see that on my system open gets called 3 times during boot-up. * What are the circumstances the touch device would be in an other state? In the official kernel driver the userspace can send commands via sysfs. Also the driver does set the touch enable mode as this patch does. > Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com> > --- > drivers/input/touchscreen/ar1021_i2c.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c > index 1a94d8b..2a76231 100644 > --- a/drivers/input/touchscreen/ar1021_i2c.c > +++ b/drivers/input/touchscreen/ar1021_i2c.c > @@ -18,6 +18,12 @@ > #define AR1021_MAX_X 4095 > #define AR1021_MAX_Y 4095 > > +#define AR1021_CMD 0x55 > +#define AR1021_TOUCH 0x80 > + > +#define AR1021_CMD_ENABLE_TOUCH 0x12 > +#define AR1021_CMD_DISABLE_TOUCH 0x13 > + > struct ar1021_i2c { > struct i2c_client *client; > struct input_dev *input; > @@ -58,6 +64,15 @@ static int ar1021_i2c_open(struct input_dev *dev) > { > struct ar1021_i2c *ar1021 = input_get_drvdata(dev); > struct i2c_client *client = ar1021->client; > + int error; > + u8 cmd_enable_touch[3] = {AR1021_CMD, > + 0x01, /* number of bytes after this */ > + AR1021_CMD_ENABLE_TOUCH }; > + > + error = i2c_master_send(ar1021->client, cmd_enable_touch, > + sizeof(cmd_enable_touch)); > + if (error < 0) > + return error; > > enable_irq(client->irq); > > -- > 2.1.4 >
Martin Kepplinger | Entwicklung Software GINZINGER ELECTRONIC SYSTEMS GMBH Tel.: +43 7723 5422 157 Mail: martin.kepplinger@ginzinger.com Web: www.ginzinger.com On 2018-02-05 11:07, Christian Gmeiner wrote: > Hi all. > > 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: >> The device could as well be in command mode, in which this driver cannot >> handle the device. When opening the device, let's make sure the device >> will be in the mode we expect it to be for this driver. >> > > I run into issues caused by this change. It turns out that the device > is non-functional > after some warm-reboots and as a result I am not able to use xorg's > evdev driver. > So I have some questions about this change: > > * Should we enable irq before calling i2c_master_send(..) as the chip raises an > irq if the command was processed? > > * Would it be enough to send this command only once during driver > lifetime? I can > see that on my system open gets called 3 times during boot-up. It would. See below for my thought on this change. > > * What are the circumstances the touch device would be in an other state? In the > official kernel driver the userspace can send commands via sysfs. > Also the driver > does set the touch enable mode as this patch does. I did this change as the device was once non-functional unexpectedly because it wasn't in touch mode. We can set touch mode during open() or probe() but I figured during open() would keep the driver working even when others would use the device in command mode. Does your problem go away when you revert this change or put it into probe()? martin
On Mon, Feb 05, 2018 at 11:07:08AM +0100, Christian Gmeiner wrote: > Hi all. > > 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: > > The device could as well be in command mode, in which this driver cannot > > handle the device. When opening the device, let's make sure the device > > will be in the mode we expect it to be for this driver. > > > > I run into issues caused by this change. It turns out that the device > is non-functional > after some warm-reboots and as a result I am not able to use xorg's > evdev driver. > So I have some questions about this change: > > * Should we enable irq before calling i2c_master_send(..) as the chip raises an > irq if the command was processed? Well, we do not care about the response... However, what is your interrupt trigger settings? Are you using edge by chance? If so, please try switching to level. > > * Would it be enough to send this command only once during driver > lifetime? I can > see that on my system open gets called 3 times during boot-up. > > * What are the circumstances the touch device would be in an other state? In the > official kernel driver the userspace can send commands via sysfs. > Also the driver > does set the touch enable mode as this patch does. What is "the official kernel driver"? Thanks.
2018-02-05 11:40 GMT+01:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: > > > > > Martin Kepplinger | Entwicklung Software > > GINZINGER ELECTRONIC SYSTEMS GMBH > > Tel.: +43 7723 5422 157 > Mail: martin.kepplinger@ginzinger.com > Web: www.ginzinger.com > > > > > On 2018-02-05 11:07, Christian Gmeiner wrote: >> Hi all. >> >> 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: >>> The device could as well be in command mode, in which this driver cannot >>> handle the device. When opening the device, let's make sure the device >>> will be in the mode we expect it to be for this driver. >>> >> >> I run into issues caused by this change. It turns out that the device >> is non-functional >> after some warm-reboots and as a result I am not able to use xorg's >> evdev driver. >> So I have some questions about this change: >> >> * Should we enable irq before calling i2c_master_send(..) as the chip raises an >> irq if the command was processed? >> >> * Would it be enough to send this command only once during driver >> lifetime? I can >> see that on my system open gets called 3 times during boot-up. > > It would. See below for my thought on this change. > >> >> * What are the circumstances the touch device would be in an other state? In the >> official kernel driver the userspace can send commands via sysfs. >> Also the driver >> does set the touch enable mode as this patch does. > > I did this change as the device was once non-functional unexpectedly > because it wasn't in touch mode. We can set touch mode during open() or > probe() but I figured during open() would keep the driver working even > when others would use the device in command mode. > > Does your problem go away when you revert this change or put it into > probe()? I needed to postprone further research and reverted this commit locally as a new software release gets releases soon. The good this that I have an automated way to run a test to trigger this issue quite easily. Will have a deeper look after release time.
2018-02-06 2:20 GMT+01:00 Dmitry Torokhov <dmitry.torokhov@gmail.com>: > On Mon, Feb 05, 2018 at 11:07:08AM +0100, Christian Gmeiner wrote: >> Hi all. >> >> 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>: >> > The device could as well be in command mode, in which this driver cannot >> > handle the device. When opening the device, let's make sure the device >> > will be in the mode we expect it to be for this driver. >> > >> >> I run into issues caused by this change. It turns out that the device >> is non-functional >> after some warm-reboots and as a result I am not able to use xorg's >> evdev driver. >> So I have some questions about this change: >> >> * Should we enable irq before calling i2c_master_send(..) as the chip raises an >> irq if the command was processed? > > Well, we do not care about the response... However, what is your > interrupt trigger settings? Are you using edge by chance? If so, please > try switching to level. > We may should take care of the response. I have seen strange responses after the third open of the device. &i2c2 { ar1021@4d { compatible = "microchip,ar1021-i2c"; reg = <0x4d>; interrupt-parent = <&gpio3>; interrupts = <26 IRQ_TYPE_EDGE_RISING>; }; }; I am not sure if this is really the cause of the problem! As without this commit my device survives one week of a automated touch-press-test done with some mechanical gear and with the help of an SPS. >> >> * Would it be enough to send this command only once during driver >> lifetime? I can >> see that on my system open gets called 3 times during boot-up. >> >> * What are the circumstances the touch device would be in an other state? In the >> official kernel driver the userspace can send commands via sysfs. >> Also the driver >> does set the touch enable mode as this patch does. > > What is "the official kernel driver"? > http://ww1.microchip.com/downloads/en/DeviceDoc/AR1020-AR1021-LINUX-SPI-I2C-V102.tar.gz As it is release time at my company I had to stop finding the root cause but will look into the issue again in 2-3 weeks.
diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c index 1a94d8b..2a76231 100644 --- a/drivers/input/touchscreen/ar1021_i2c.c +++ b/drivers/input/touchscreen/ar1021_i2c.c @@ -18,6 +18,12 @@ #define AR1021_MAX_X 4095 #define AR1021_MAX_Y 4095 +#define AR1021_CMD 0x55 +#define AR1021_TOUCH 0x80 + +#define AR1021_CMD_ENABLE_TOUCH 0x12 +#define AR1021_CMD_DISABLE_TOUCH 0x13 + struct ar1021_i2c { struct i2c_client *client; struct input_dev *input; @@ -58,6 +64,15 @@ static int ar1021_i2c_open(struct input_dev *dev) { struct ar1021_i2c *ar1021 = input_get_drvdata(dev); struct i2c_client *client = ar1021->client; + int error; + u8 cmd_enable_touch[3] = {AR1021_CMD, + 0x01, /* number of bytes after this */ + AR1021_CMD_ENABLE_TOUCH }; + + error = i2c_master_send(ar1021->client, cmd_enable_touch, + sizeof(cmd_enable_touch)); + if (error < 0) + return error; enable_irq(client->irq);
The device could as well be in command mode, in which this driver cannot handle the device. When opening the device, let's make sure the device will be in the mode we expect it to be for this driver. Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com> --- drivers/input/touchscreen/ar1021_i2c.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)