diff mbox series

[27/40] mfd: ti_am335x_tscadc: Move control register configuration

Message ID 20210825152518.379386-28-miquel.raynal@bootlin.com
State New
Headers show
Series TI AM437X ADC1 | expand

Commit Message

Miquel Raynal Aug. 25, 2021, 3:25 p.m. UTC
The datasheet states that most of the configuration should be set in the
control register in the first place, before actually enabling the
hardware. So far only half of the configuration was made in the first
step, which does not make really sense and would complicating the code
when introducing support for the am437x hardware.

Let's move that register write a bit below to enclose more configuration.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Aug. 30, 2021, 2:03 p.m. UTC | #1
On Wed, 25 Aug 2021 17:25:05 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The datasheet states that most of the configuration should be set in the
> control register in the first place, before actually enabling the
> hardware.

Reference always good. 

> So far only half of the configuration was made in the first
> step, which does not make really sense and would complicating the code
> when introducing support for the am437x hardware.
> 
> Let's move that register write a bit below to enclose more configuration.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Looks fine to me otherwise.

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index a40091830cea..1a30610dc65f 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -224,7 +224,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->ctrl = CNTRLREG_STEPID;
>  	if (tscadc->data->has_tsc) {
>  		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
> -		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  		if (use_tsc) {
>  			tscadc->ctrl |= CNTRLREG_TSC_ENB;
>  			if (tscmag_wires == 5)
> @@ -235,6 +234,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  
>  	}
>  
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> +
>  	tscadc_idle_config(tscadc);
>  
>  	/* Enable the TSC module enable bit */
diff mbox series

Patch

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index a40091830cea..1a30610dc65f 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -224,7 +224,6 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->ctrl = CNTRLREG_STEPID;
 	if (tscadc->data->has_tsc) {
 		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
-		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 		if (use_tsc) {
 			tscadc->ctrl |= CNTRLREG_TSC_ENB;
 			if (tscmag_wires == 5)
@@ -235,6 +234,8 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 
 	}
 
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
+
 	tscadc_idle_config(tscadc);
 
 	/* Enable the TSC module enable bit */