Patchwork [U-Boot] misc: pmic: fix regression in pmic_fsl.c (SPI)

login
register
mail settings
Submitter Helmut Raiger
Date Oct. 19, 2011, 4:48 p.m.
Message ID <1319042932-25508-1-git-send-email-helmut.raiger@hale.at>
Download mbox | patch
Permalink /patch/120659/
State Superseded
Headers show

Comments

Helmut Raiger - Oct. 19, 2011, 4:48 p.m.
This fixes write access to PMIC registers, the bug was
introduced partly in commit 64aac65099 and in commit c9fe76dd91.
It was tested on an i.mx31 with a mc13783.

Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
---
 drivers/misc/pmic_fsl.c |    5 +----
 drivers/misc/pmic_spi.c |    1 -
 2 files changed, 1 insertions(+), 5 deletions(-)
Stefano Babic - Oct. 19, 2011, 5:15 p.m.
On 10/19/2011 06:48 PM, Helmut Raiger wrote:
> This fixes write access to PMIC registers, the bug was
> introduced partly in commit 64aac65099 and in commit c9fe76dd91.
> It was tested on an i.mx31 with a mc13783.
> 
> Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
> ---
>  drivers/misc/pmic_fsl.c |    5 +----
>  drivers/misc/pmic_spi.c |    1 -
>  2 files changed, 1 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
> index b6e809a..0ff75ed 100644

Hi Helmut,

> --- a/drivers/misc/pmic_fsl.c
> +++ b/drivers/misc/pmic_fsl.c
> @@ -29,10 +29,7 @@
>  #if defined(CONFIG_PMIC_SPI)
>  static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
>  {
> -	if ((val == NULL) && (write))
> -		return *val & ~(1 << 31);
> -	else
> -		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
> +	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
>  }
>  #endif
>  
> diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
> index ff35377..e772884 100644
> --- a/drivers/misc/pmic_spi.c
> +++ b/drivers/misc/pmic_spi.c
> @@ -76,7 +76,6 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
>  	}
>  
>  	if (write) {
> -		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
>  		pmic_tx &= ~(1 << 31);

This fixes the issue with the Freescale PMIC, but...

The new driver introduces a level of abstraction to make easier to
introduce other PMICs that are driven with SPI / I2C. For this reason,
PMIC specific code must be inside the specific driver (pmic_fsl.c) and
not in the general (pmic_core.c and pmic_spi.c). And clearing the MSB is
part of the Freescale's protocol, and for this reason should be moved
inside the prepare function.

Best regards,
Stefano Babic
Helmut Raiger - Oct. 20, 2011, 6:41 a.m.
On 10/19/2011 07:15 PM, Stefano Babic wrote:
>
> This fixes the issue with the Freescale PMIC, but...
>
> The new driver introduces a level of abstraction to make easier to
> introduce other PMICs that are driven with SPI / I2C. For this reason,
> PMIC specific code must be inside the specific driver (pmic_fsl.c) and
> not in the general (pmic_core.c and pmic_spi.c). And clearing the MSB is
> part of the Freescale's protocol, and for this reason should be moved
> inside the prepare function.
>
> Best regards,
> Stefano Babic
>

Ah yes, I stumbled over git again (and again and again). :-[
See [Resend V2].

Helmut


--
Scanned by MailScanner.

Patch

diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
index b6e809a..0ff75ed 100644
--- a/drivers/misc/pmic_fsl.c
+++ b/drivers/misc/pmic_fsl.c
@@ -29,10 +29,7 @@ 
 #if defined(CONFIG_PMIC_SPI)
 static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 {
-	if ((val == NULL) && (write))
-		return *val & ~(1 << 31);
-	else
-		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
+	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
 }
 #endif
 
diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
index ff35377..e772884 100644
--- a/drivers/misc/pmic_spi.c
+++ b/drivers/misc/pmic_spi.c
@@ -76,7 +76,6 @@  static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
 	}
 
 	if (write) {
-		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
 		pmic_tx &= ~(1 << 31);
 		tmp = cpu_to_be32(pmic_tx);
 		if (spi_xfer(slave, pmic_spi_bitlen, &tmp, &pmic_rx,