linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: patrice.chotard@st.com
Cc: gnurou@gmail.com, amelie.delaunay@st.com, vireshk@kernel.org,
	linus.walleij@linaro.org, linux-gpio@vger.kernel.org,
	thierry.reding@gmail.com, kernel@pengutronix.de,
	dinguyen@opensource.altera.com, shawnguo@kernel.org,
	shiraz.linux.kernel@gmail.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RESEND v2 03/10] gpio: stmpe: fix edge and rising/falling edge detection
Date: Wed, 10 Aug 2016 09:29:10 +0100	[thread overview]
Message-ID: <20160810082910.GI1581@dell> (raw)
In-Reply-To: <1470814755-19447-4-git-send-email-patrice.chotard@st.com>

On Wed, 10 Aug 2016, patrice.chotard@st.com wrote:

> From: Patrice Chotard <patrice.chotard@st.com>
> 
> By cross-checking STMPE 610/801/811/1601/2401/2403 datasheets,
> it appears that edge detection and rising/falling edge detection
> is not supported by all STMPE variant:
> 
>            GPIO              GPIO
>       Edge detection     rising/falling
>                          edge detection
>  610 |      X        |         X       |
>  801 |               |                 |
>  811 |      X        |         X       |
> 1600 |               |                 |
> 1601 |      X        |         X       |
> 1801 |               |         X       |
> 2401 |      X        |         X       |
> 2403 |      X        |         X       |
> 
> Rework stmpe_dbg_show_one() and stmpe_gpio_irq to correctly
> take these cases into account.
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-stmpe.c | 85 +++++++++++++++++++++++++++++++++--------------
>  1 file changed, 60 insertions(+), 25 deletions(-)

Applied, thanks.

> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 5197edf..bfc918c 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -231,39 +231,74 @@ static void stmpe_dbg_show_one(struct seq_file *s,
>  			   gpio, label ?: "(none)",
>  			   val ? "hi" : "lo");
>  	} else {
> -		u8 edge_det_reg = stmpe->regs[STMPE_IDX_GPEDR_MSB] + num_banks - 1 - (offset / 8);
> -		u8 rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB] - (offset / 8);
> -		u8 fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB] - (offset / 8);
> -		u8 irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB] - (offset / 8);
> -		bool edge_det;
> -		bool rise;
> -		bool fall;
> +		u8 edge_det_reg;
> +		u8 rise_reg;
> +		u8 fall_reg;
> +		u8 irqen_reg;
> +
> +		char *edge_det_values[] = {"edge-inactive",
> +					   "edge-asserted",
> +					   "not-supported"};
> +		char *rise_values[] = {"no-rising-edge-detection",
> +				       "rising-edge-detection",
> +				       "not-supported"};
> +		char *fall_values[] = {"no-falling-edge-detection",
> +				       "falling-edge-detection",
> +				       "not-supported"};
> +		#define NOT_SUPPORTED_IDX 2
> +		u8 edge_det = NOT_SUPPORTED_IDX;
> +		u8 rise = NOT_SUPPORTED_IDX;
> +		u8 fall = NOT_SUPPORTED_IDX;
>  		bool irqen;
>  
> -		ret = stmpe_reg_read(stmpe, edge_det_reg);
> -		if (ret < 0)
> -			return;
> -		edge_det = !!(ret & mask);
> -		ret = stmpe_reg_read(stmpe, rise_reg);
> -		if (ret < 0)
> +		switch (stmpe->partnum) {
> +		case STMPE610:
> +		case STMPE811:
> +		case STMPE1601:
> +		case STMPE2401:
> +		case STMPE2403:
> +			edge_det_reg = stmpe->regs[STMPE_IDX_GPEDR_MSB] +
> +				       num_banks - 1 - (offset / 8);
> +			ret = stmpe_reg_read(stmpe, edge_det_reg);
> +			if (ret < 0)
> +				return;
> +			edge_det = !!(ret & mask);
> +
> +		case STMPE1801:
> +			rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB] -
> +				   (offset / 8);
> +			fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB] -
> +				   (offset / 8);
> +			ret = stmpe_reg_read(stmpe, rise_reg);
> +			if (ret < 0)
> +				return;
> +			rise = !!(ret & mask);
> +			ret = stmpe_reg_read(stmpe, fall_reg);
> +			if (ret < 0)
> +				return;
> +			fall = !!(ret & mask);
> +
> +		case STMPE801:
> +			irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB] -
> +				    (offset / 8);
> +			break;
> +
> +		default:
>  			return;
> -		rise = !!(ret & mask);
> -		ret = stmpe_reg_read(stmpe, fall_reg);
> -		if (ret < 0)
> -			return;
> -		fall = !!(ret & mask);
> +		}
> +
>  		ret = stmpe_reg_read(stmpe, irqen_reg);
>  		if (ret < 0)
>  			return;
>  		irqen = !!(ret & mask);
>  
> -		seq_printf(s, " gpio-%-3d (%-20.20s) in  %s %s %s%s%s",
> +		seq_printf(s, " gpio-%-3d (%-20.20s) in  %s %13s %13s %25s %25s",
>  			   gpio, label ?: "(none)",
>  			   val ? "hi" : "lo",
> -			   edge_det ? "edge-asserted" : "edge-inactive",
> -			   irqen ? "IRQ-enabled" : "",
> -			   rise ? " rising-edge-detection" : "",
> -			   fall ? " falling-edge-detection" : "");
> +			   edge_det_values[edge_det],
> +			   irqen ? "IRQ-enabled" : "IRQ-disabled",
> +			   rise_values[rise],
> +			   fall_values[fall]);
>  	}
>  }
>  
> @@ -322,8 +357,8 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev)
>  
>  		stmpe_reg_write(stmpe, statmsbreg + i, status[i]);
>  
> -		/* Edge detect register is not present on 801 */
> -		if (stmpe->partnum != STMPE801)
> +		/* Edge detect register is not present on 801 and 1801 */
> +		if (stmpe->partnum != STMPE801 || stmpe->partnum != STMPE1801)
>  			stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB]
>  					+ i, status[i]);
>  	}

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2016-08-10  8:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10  7:39 [RESEND v2 00/10] STMPE fixes/rework and add STMPE1600 support patrice.chotard
2016-08-10  7:39 ` [RESEND v2 01/10] mfd: stmpe: Add STMPE_IDX_SYS_CTRL/2 enum patrice.chotard
2016-08-10  8:28   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 02/10] mfd: stmpe: Add reset support for all STMPE variant patrice.chotard
2016-08-10  8:28   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 03/10] gpio: stmpe: fix edge and rising/falling edge detection patrice.chotard
2016-08-10  8:29   ` Lee Jones [this message]
2016-08-10  7:39 ` [RESEND v2 04/10] gpio: stmpe: write int status register only when needed patrice.chotard
2016-08-10  8:29   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 05/10] mfd: stmpe: use generic bit mask name patrice.chotard
2016-08-10  8:29   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 06/10] mfd: stmpe: rework registers access patrice.chotard
2016-08-10  8:29   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 07/10] gpio: " patrice.chotard
2016-08-10  8:29   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 08/10] Documentation: dt: add stmpe1600 compatible string to stmpe mfd patrice.chotard
2016-08-10  8:30   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 09/10] mfd: Add STMPE1600 support patrice.chotard
2016-08-10  8:30   ` Lee Jones
2016-08-10  7:39 ` [RESEND v2 10/10] gpio: stmpe: " patrice.chotard
2016-08-10  8:30   ` Lee Jones
2016-08-10  8:42 ` [GIT PULL] Immutable branch between MFD and GPIO due for v4.9 Lee Jones
2016-08-11 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=20160810082910.GI1581@dell \
    --to=lee.jones@linaro.org \
    --cc=amelie.delaunay@st.com \
    --cc=dinguyen@opensource.altera.com \
    --cc=gnurou@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=patrice.chotard@st.com \
    --cc=shawnguo@kernel.org \
    --cc=shiraz.linux.kernel@gmail.com \
    --cc=thierry.reding@gmail.com \
    --cc=vireshk@kernel.org \
    /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 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).