All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG
@ 2016-11-28  8:42 Haibo Chen
  2016-11-29 12:36 ` Guy Shapiro
  0 siblings, 1 reply; 3+ messages in thread
From: Haibo Chen @ 2016-11-28  8:42 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input; +Cc: haibo.chen, guy.shapiro, fabio.estevam

Add mask of each function bits of REG_ADC_CFG, and clear these
function bits first, otherwise use '|=' operation may get the
wrong setting which depends on the original value of REG_ADC_CFG.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/input/touchscreen/imx6ul_tsc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index 31724d9..96358fb 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -29,11 +29,16 @@
 #define ADC_CAL			(0x1 << 7)
 #define ADC_CALF		0x2
 #define ADC_12BIT_MODE		(0x2 << 2)
+#define ADC_CONV_MODE_MASK	(0x3 << 2)
 #define ADC_IPG_CLK		0x00
+#define ADC_INPUT_CLK_MASK	0x3
 #define ADC_CLK_DIV_8		(0x03 << 5)
+#define ADC_CLK_DIV_MASK	(0x3 << 5)
 #define ADC_SHORT_SAMPLE_MODE	(0x0 << 4)
+#define ADC_SAMPLE_MODE_MASK	(0x1 << 4)
 #define ADC_HARDWARE_TRIGGER	(0x1 << 13)
 #define ADC_AVGS_SHIFT		14
+#define ADC_AVGS_MASK		(0x3 << 14)
 #define SELECT_CHANNEL_4	0x04
 #define SELECT_CHANNEL_1	0x01
 #define DISABLE_CONVERSION_INT	(0x0 << 7)
@@ -108,10 +113,14 @@ static int imx6ul_adc_init(struct imx6ul_tsc *tsc)
 	reinit_completion(&tsc->completion);
 
 	adc_cfg = readl(tsc->adc_regs + REG_ADC_CFG);
+	adc_cfg &= ~(ADC_CONV_MODE_MASK | ADC_INPUT_CLK_MASK);
 	adc_cfg |= ADC_12BIT_MODE | ADC_IPG_CLK;
+	adc_cfg &= ~(ADC_CLK_DIV_MASK | ADC_SAMPLE_MODE_MASK);
 	adc_cfg |= ADC_CLK_DIV_8 | ADC_SHORT_SAMPLE_MODE;
-	if (tsc->average_samples)
+	if (tsc->average_samples) {
+		adc_cfg &= ~ADC_AVGS_MASK;
 		adc_cfg |= (tsc->average_samples - 1) << ADC_AVGS_SHIFT;
+	}
 	adc_cfg &= ~ADC_HARDWARE_TRIGGER;
 	writel(adc_cfg, tsc->adc_regs + REG_ADC_CFG);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG
  2016-11-28  8:42 [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG Haibo Chen
@ 2016-11-29 12:36 ` Guy Shapiro
  2016-11-30 17:02   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Guy Shapiro @ 2016-11-29 12:36 UTC (permalink / raw)
  To: Haibo Chen, dmitry.torokhov, linux-input; +Cc: fabio.estevam

On 28/11/2016 10:42, Haibo Chen wrote:
> Add mask of each function bits of REG_ADC_CFG, and clear these
> function bits first, otherwise use '|=' operation may get the
> wrong setting which depends on the original value of REG_ADC_CFG.
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>   drivers/input/touchscreen/imx6ul_tsc.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
Reviewed-by: Guy Shapiro <guy.shapiro@mobi-wize.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG
  2016-11-29 12:36 ` Guy Shapiro
@ 2016-11-30 17:02   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2016-11-30 17:02 UTC (permalink / raw)
  To: Guy Shapiro; +Cc: Haibo Chen, linux-input, fabio.estevam

On Tue, Nov 29, 2016 at 02:36:51PM +0200, Guy Shapiro wrote:
> On 28/11/2016 10:42, Haibo Chen wrote:
> >Add mask of each function bits of REG_ADC_CFG, and clear these
> >function bits first, otherwise use '|=' operation may get the
> >wrong setting which depends on the original value of REG_ADC_CFG.
> >
> >Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> >---
> >  drivers/input/touchscreen/imx6ul_tsc.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> Reviewed-by: Guy Shapiro <guy.shapiro@mobi-wize.com>

Applied, thank you.


-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-30 17:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28  8:42 [PATCH] input: touchscreen: imx6ul_tsc: add mask when set REG_ADC_CFG Haibo Chen
2016-11-29 12:36 ` Guy Shapiro
2016-11-30 17:02   ` Dmitry Torokhov

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.