All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Yong Li <yong.b.li@intel.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linus.walleij@linaro.org, gnurou@gmail.com
Cc: ismo.puustinen@intel.com, preid@electromag.com.au
Subject: Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
Date: Thu, 07 Apr 2016 14:07:49 +0300	[thread overview]
Message-ID: <1460027269.6620.18.camel@linux.intel.com> (raw)
In-Reply-To: <1460004992-16210-1-git-send-email-yong.b.li@intel.com>

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 <josef.ahmad@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
> 

FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Yong Li <yong.b.li@intel.com>
> ---
>  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_LATCH	34
> +#define PCAL953X_INT_MASK	37
> +#define PCAL953X_INT_STAT	38
> +
>  #define PCA_GPIO_MASK		0x00FF
>  #define PCA_INT			0x0100
> +#define PCA_PCAL			0x0200
>  #define PCA953X_TYPE		0x1000
>  #define PCA957X_TYPE		0x2000
>  #define PCA_TYPE_MASK		0xF000
> @@ -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 <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Yong Li <yong.b.li@intel.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linus.walleij@linaro.org, gnurou@gmail.com
Cc: ismo.puustinen@intel.com, preid@electromag.com.au
Subject: Re: [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2
Date: Thu, 07 Apr 2016 14:07:49 +0300	[thread overview]
Message-ID: <1460027269.6620.18.camel@linux.intel.com> (raw)
In-Reply-To: <1460004992-16210-1-git-send-email-yong.b.li@intel.com>

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 <josef.ahmad@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
> 

FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Yong Li <yong.b.li@intel.com>
> ---
>  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_LATCH	34
> +#define PCAL953X_INT_MASK	37
> +#define PCAL953X_INT_STAT	38
> +
>  #define PCA_GPIO_MASK		0x00FF
>  #define PCA_INT			0x0100
> +#define PCA_PCAL			0x0200
>  #define PCA953X_TYPE		0x1000
>  #define PCA957X_TYPE		0x2000
>  #define PCA_TYPE_MASK		0xF000
> @@ -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 <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2016-04-07 11:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07  4:56 [PATCH v2] gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2 Yong Li
2016-04-07 11:07 ` Andy Shevchenko [this message]
2016-04-07 11:07   ` Andy Shevchenko
2016-04-08 13:20 ` Linus Walleij
2016-04-10  3:02   ` Li, Yong B
2016-04-14 12:07     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460027269.6620.18.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gnurou@gmail.com \
    --cc=ismo.puustinen@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=preid@electromag.com.au \
    --cc=yong.b.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.