Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
On Sun, Apr 10, 2016 at 5:02 AM, Li, Yong Bwrote: > Thanks Linus. I think the below patch(in fixes branch) should be merged into > devel branch too, since the below patch is depended by this one in devel > branch. > > commit 9b8e3ec34318663affced3c14d960e78d760dd9a > Author: Yong Li > Date: Wed Mar 30 14:49:14 2016 +0800 > > gpio: pca953x: Use correct u16 value for register word write This patch is already upstream so no need to worry about that. Yours, Linus Walleij
Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
On Sun, Apr 10, 2016 at 5:02 AM, Li, Yong B wrote: > Thanks Linus. I think the below patch(in fixes branch) should be merged into > devel branch too, since the below patch is depended by this one in devel > branch. > > commit 9b8e3ec34318663affced3c14d960e78d760dd9a > Author: Yong Li > Date: Wed Mar 30 14:49:14 2016 +0800 > > gpio: pca953x: Use correct u16 value for register word write This patch is already upstream so no need to worry about that. Yours, Linus Walleij
RE: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
Thanks Linus. I think the below patch(in fixes branch) should be merged into devel branch too, since the below patch is depended by this one in devel branch. commit 9b8e3ec34318663affced3c14d960e78d760dd9a Author: Yong Li <sdliy...@gmail.com> Date: Wed Mar 30 14:49:14 2016 +0800 gpio: pca953x: Use correct u16 value for register word write The current implementation only uses the first byte in val, the second byte is always 0. Change it to use cpu_to_le16 to write the two bytes into the register Cc: sta...@vger.kernel.org Signed-off-by: Yong Li <sdliy...@gmail.com> Reviewed-by: Phil Reid <pr...@electromag.com.au> Signed-off-by: Linus Walleij <linus.wall...@linaro.org> Yong > -Original Message- > From: Linus Walleij [mailto:linus.wall...@linaro.org] > Sent: Friday, April 08, 2016 21:21 > To: Li, Yong B <yong.b...@intel.com> > Cc: linux-g...@vger.kernel.org; linux-kernel@vger.kernel.org; Alexandre > Courbot <gnu...@gmail.com>; Andy Shevchenko > <andriy.shevche...@linux.intel.com>; Puustinen, Ismo > <ismo.puusti...@intel.com>; Phil Reid <pr...@electromag.com.au> > Subject: Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for > Galileo Gen2 > > n Thu, Apr 7, 2016 at 6:56 AM, Yong Li <yong.b...@intel.com> wrote: > > > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, it is > > different from PCA9535 and includes interrupt mask/status registers, > > The current driver does not support the interrupt registers > > configuration, it causes some gpio pins cannot trigger interrupt > > events, this patch fix this issue. The original patch was submitted by > > Josef Ahmad <josef.ah...@linux.intel.com> > > http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipe > > s-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > > > > Signed-off-by: Yong Li <yong.b...@intel.com> > > Patch applied with Andy's review tag. > > Yours, > Linus Walleij
RE: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
Thanks Linus. I think the below patch(in fixes branch) should be merged into devel branch too, since the below patch is depended by this one in devel branch. commit 9b8e3ec34318663affced3c14d960e78d760dd9a Author: Yong Li Date: Wed Mar 30 14:49:14 2016 +0800 gpio: pca953x: Use correct u16 value for register word write The current implementation only uses the first byte in val, the second byte is always 0. Change it to use cpu_to_le16 to write the two bytes into the register Cc: sta...@vger.kernel.org Signed-off-by: Yong Li Reviewed-by: Phil Reid Signed-off-by: Linus Walleij Yong > -Original Message- > From: Linus Walleij [mailto:linus.wall...@linaro.org] > Sent: Friday, April 08, 2016 21:21 > To: Li, Yong B > Cc: linux-g...@vger.kernel.org; linux-kernel@vger.kernel.org; Alexandre > Courbot ; Andy Shevchenko > ; Puustinen, Ismo > ; Phil Reid > Subject: Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for > Galileo Gen2 > > n Thu, Apr 7, 2016 at 6:56 AM, Yong Li wrote: > > > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, it is > > different from PCA9535 and includes interrupt mask/status registers, > > The current driver does not support the interrupt registers > > configuration, it causes some gpio pins cannot trigger interrupt > > events, this patch fix this issue. The original patch was submitted by > > Josef Ahmad > > http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipe > > s-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > > > > Signed-off-by: Yong Li > > Patch applied with Andy's review tag. > > Yours, > Linus Walleij
Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
n Thu, Apr 7, 2016 at 6:56 AM, Yong Liwrote: > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, > it is different from PCA9535 and includes interrupt mask/status registers, > The current driver does not support the interrupt registers configuration, > it causes some gpio pins cannot trigger interrupt events, > this patch fix this issue. The original patch was submitted by > Josef Ahmad > http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipes-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > > Signed-off-by: Yong Li Patch applied with Andy's review tag. Yours, Linus Walleij
Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
n Thu, Apr 7, 2016 at 6:56 AM, Yong Li wrote: > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, > it is different from PCA9535 and includes interrupt mask/status registers, > The current driver does not support the interrupt registers configuration, > it causes some gpio pins cannot trigger interrupt events, > this patch fix this issue. The original patch was submitted by > Josef Ahmad > http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipes-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > > Signed-off-by: Yong Li Patch applied with Andy's review tag. Yours, Linus Walleij
Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
On Thu, 2016-04-07 at 12:56 +0800, Yong Li wrote: > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, > it is different from PCA9535 and includes interrupt mask/status > registers, > The current driver does not support the interrupt registers > configuration, > it causes some gpio pins cannot trigger interrupt events, > this patch fix this issue. The original patch was submitted by > Josef Ahmad> http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipe > s-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > FWIW: Reviewed-by: Andy Shevchenko > Signed-off-by: Yong Li > --- > drivers/gpio/gpio-pca953x.c | 42 > +- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c > index e66084c..5e3be32 100644 > --- a/drivers/gpio/gpio-pca953x.c > +++ b/drivers/gpio/gpio-pca953x.c > @@ -38,8 +38,13 @@ > #define PCA957X_MSK 6 > #define PCA957X_INTS 7 > > +#define PCAL953X_IN_LATCH34 > +#define PCAL953X_INT_MASK37 > +#define PCAL953X_INT_STAT38 > + > #define PCA_GPIO_MASK0x00FF > #define PCA_INT 0x0100 > +#define PCA_PCAL 0x0200 > #define PCA953X_TYPE 0x1000 > #define PCA957X_TYPE 0x2000 > #define PCA_TYPE_MASK0xF000 > @@ -77,7 +82,7 @@ static const struct i2c_device_id pca953x_id[] = { > MODULE_DEVICE_TABLE(i2c, pca953x_id); > > static const struct acpi_device_id pca953x_acpi_ids[] = { > - { "INT3491", 16 | PCA953X_TYPE | PCA_INT, }, > + { "INT3491", 16 | PCA953X_TYPE | PCA_INT | PCA_PCAL, }, > { } > }; > MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids); > @@ -437,6 +442,18 @@ static void pca953x_irq_bus_sync_unlock(struct > irq_data *d) > struct pca953x_chip *chip = gpiochip_get_data(gc); > u8 new_irqs; > int level, i; > + u8 invert_irq_mask[MAX_BANK]; > + > + if (chip->driver_data & PCA_PCAL) { > + /* Enable latch on interrupt-enabled inputs */ > + pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip- > >irq_mask); > + > + for (i = 0; i < NBANK(chip); i++) > + invert_irq_mask[i] = ~chip->irq_mask[i]; > + > + /* Unmask enabled interrupts */ > + pca953x_write_regs(chip, PCAL953X_INT_MASK, > invert_irq_mask); > + } > > /* Look for any newly setup interrupt */ > for (i = 0; i < NBANK(chip); i++) { > @@ -498,6 +515,29 @@ static bool pca953x_irq_pending(struct > pca953x_chip *chip, u8 *pending) > u8 trigger[MAX_BANK]; > int ret, i, offset = 0; > > + if (chip->driver_data & PCA_PCAL) { > + /* Read the current interrupt status from the device > */ > + ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, > trigger); > + if (ret) > + return false; > + > + /* Check latched inputs and clear interrupt status */ > + ret = pca953x_read_regs(chip, PCA953X_INPUT, > cur_stat); > + if (ret) > + return false; > + > + for (i = 0; i < NBANK(chip); i++) { > + /* Apply filter for rising/falling edge > selection */ > + pending[i] = (~cur_stat[i] & chip- > >irq_trig_fall[i]) | > + (cur_stat[i] & chip- > >irq_trig_raise[i]); > + pending[i] &= trigger[i]; > + if (pending[i]) > + pending_seen = true; > + } > + > + return pending_seen; > + } > + > switch (chip->chip_type) { > case PCA953X_TYPE: > offset = PCA953X_INPUT; -- Andy Shevchenko Intel Finland Oy
Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
On Thu, 2016-04-07 at 12:56 +0800, Yong Li wrote: > Galileo Gen2 board uses the PCAL9535 as the GPIO expansion, > it is different from PCA9535 and includes interrupt mask/status > registers, > The current driver does not support the interrupt registers > configuration, > it causes some gpio pins cannot trigger interrupt events, > this patch fix this issue. The original patch was submitted by > Josef Ahmad > http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipe > s-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch > FWIW: Reviewed-by: Andy Shevchenko > Signed-off-by: Yong Li > --- > drivers/gpio/gpio-pca953x.c | 42 > +- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c > index e66084c..5e3be32 100644 > --- a/drivers/gpio/gpio-pca953x.c > +++ b/drivers/gpio/gpio-pca953x.c > @@ -38,8 +38,13 @@ > #define PCA957X_MSK 6 > #define PCA957X_INTS 7 > > +#define PCAL953X_IN_LATCH34 > +#define PCAL953X_INT_MASK37 > +#define PCAL953X_INT_STAT38 > + > #define PCA_GPIO_MASK0x00FF > #define PCA_INT 0x0100 > +#define PCA_PCAL 0x0200 > #define PCA953X_TYPE 0x1000 > #define PCA957X_TYPE 0x2000 > #define PCA_TYPE_MASK0xF000 > @@ -77,7 +82,7 @@ static const struct i2c_device_id pca953x_id[] = { > MODULE_DEVICE_TABLE(i2c, pca953x_id); > > static const struct acpi_device_id pca953x_acpi_ids[] = { > - { "INT3491", 16 | PCA953X_TYPE | PCA_INT, }, > + { "INT3491", 16 | PCA953X_TYPE | PCA_INT | PCA_PCAL, }, > { } > }; > MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids); > @@ -437,6 +442,18 @@ static void pca953x_irq_bus_sync_unlock(struct > irq_data *d) > struct pca953x_chip *chip = gpiochip_get_data(gc); > u8 new_irqs; > int level, i; > + u8 invert_irq_mask[MAX_BANK]; > + > + if (chip->driver_data & PCA_PCAL) { > + /* Enable latch on interrupt-enabled inputs */ > + pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip- > >irq_mask); > + > + for (i = 0; i < NBANK(chip); i++) > + invert_irq_mask[i] = ~chip->irq_mask[i]; > + > + /* Unmask enabled interrupts */ > + pca953x_write_regs(chip, PCAL953X_INT_MASK, > invert_irq_mask); > + } > > /* Look for any newly setup interrupt */ > for (i = 0; i < NBANK(chip); i++) { > @@ -498,6 +515,29 @@ static bool pca953x_irq_pending(struct > pca953x_chip *chip, u8 *pending) > u8 trigger[MAX_BANK]; > int ret, i, offset = 0; > > + if (chip->driver_data & PCA_PCAL) { > + /* Read the current interrupt status from the device > */ > + ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, > trigger); > + if (ret) > + return false; > + > + /* Check latched inputs and clear interrupt status */ > + ret = pca953x_read_regs(chip, PCA953X_INPUT, > cur_stat); > + if (ret) > + return false; > + > + for (i = 0; i < NBANK(chip); i++) { > + /* Apply filter for rising/falling edge > selection */ > + pending[i] = (~cur_stat[i] & chip- > >irq_trig_fall[i]) | > + (cur_stat[i] & chip- > >irq_trig_raise[i]); > + pending[i] &= trigger[i]; > + if (pending[i]) > + pending_seen = true; > + } > + > + return pending_seen; > + } > + > switch (chip->chip_type) { > case PCA953X_TYPE: > offset = PCA953X_INPUT; -- Andy Shevchenko Intel Finland Oy