Patchwork [U-Boot,resend,1/7] mtd/st_smi: Clear error flags while initiating a fresh write

login
register
mail settings
Submitter Vipin Kumar
Date Dec. 6, 2012, 6:21 a.m.
Message ID <a7038d57434608a84607baaf457846dc9f37bb10.1354774371.git.vipin.kumar@st.com>
Download mbox | patch
Permalink /patch/204133/
State Superseded
Headers show

Comments

Vipin Kumar - Dec. 6, 2012, 6:21 a.m.
SMI controller reports an error when the code tries to write on the flash area
with Write Enable command not issued or the bank has come out of the write mode.

This error is reported even with a fresh write once the ERF1 or ERF2 is set.
Clear these flags while initiating a fresh write

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
---
 drivers/mtd/st_smi.c | 2 ++
 1 file changed, 2 insertions(+)
Stefan Roese - Dec. 6, 2012, 7:37 a.m.
On 12/06/2012 07:21 AM, Vipin Kumar wrote:
> SMI controller reports an error when the code tries to write on the flash area
> with Write Enable command not issued or the bank has come out of the write mode.
> 
> This error is reported even with a fresh write once the ERF1 or ERF2 is set.
> Clear these flags while initiating a fresh write
> 
> Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
> ---
>  drivers/mtd/st_smi.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c
> index 7507e5d..fad4420 100644
> --- a/drivers/mtd/st_smi.c
> +++ b/drivers/mtd/st_smi.c
> @@ -392,6 +392,8 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr,
>  		return -1;
>  	}
>  
> +	writel(readl(&smicntl->smi_sr) & ~(ERF1 | ERF2), &smicntl->smi_sr);

Better use:

	clrbits_le32(&smicntl->smi_sr, ERF1 | ERF2)

Thanks,
Stefan
Vipin Kumar - Dec. 6, 2012, 8:16 a.m.
On 12/6/2012 1:07 PM, Stefan Roese wrote:
> On 12/06/2012 07:21 AM, Vipin Kumar wrote:
>> SMI controller reports an error when the code tries to write on the flash area
>> with Write Enable command not issued or the bank has come out of the write mode.
>>
>> This error is reported even with a fresh write once the ERF1 or ERF2 is set.
>> Clear these flags while initiating a fresh write
>>
>> Signed-off-by: Vipin Kumar<vipin.kumar@st.com>
>> ---
>>   drivers/mtd/st_smi.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c
>> index 7507e5d..fad4420 100644
>> --- a/drivers/mtd/st_smi.c
>> +++ b/drivers/mtd/st_smi.c
>> @@ -392,6 +392,8 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr,
>>   		return -1;
>>   	}
>>
>> +	writel(readl(&smicntl->smi_sr)&  ~(ERF1 | ERF2),&smicntl->smi_sr);
>
> Better use:
>
> 	clrbits_le32(&smicntl->smi_sr, ERF1 | ERF2)
>

Thanks.. I would use it and send a v2

> Thanks,
> Stefan
>
>

Patch

diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c
index 7507e5d..fad4420 100644
--- a/drivers/mtd/st_smi.c
+++ b/drivers/mtd/st_smi.c
@@ -392,6 +392,8 @@  static int smi_write(unsigned int *src_addr, unsigned int *dst_addr,
 		return -1;
 	}
 
+	writel(readl(&smicntl->smi_sr) & ~(ERF1 | ERF2), &smicntl->smi_sr);
+
 	if (smi_wait_till_ready(banknum, CONFIG_SYS_FLASH_WRITE_TOUT))
 		return -EBUSY;