[U-Boot] [PATCH 1/9] kmp204x: support for QRIO1 bootcounter

Valentin Longchamp valentin.longchamp at keymile.com
Tue Jan 14 09:29:25 CET 2014


Hi Stefan,

On 01/14/2014 07:58 AM, Stefan Roese wrote:
> Hi Valentin,
> 
> On 13.01.2014 17:29, Valentin Longchamp wrote:
>> From: Rainer Boschung <rainer.boschung at keymile.com>
>>
>> - make use of the QRIO1 32bit register at 0x20 as bootcounter register
>> - check for BOOTCOUNT_MAGIC pattern when before bootcounter value is read
>>
>> Signed-off-by: Rainer Boschung <rainer.boschung at keymile.com>
>> Signed-off-by: Valentin Longchamp <valentin.longchamp at keymile.com>
>> Acked-by: Valentin Longchamp <valentin.longchamp at keymile.com>
>> ---
>>
>>  board/keymile/kmp204x/kmp204x.c | 15 +++++++++------
>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/board/keymile/kmp204x/kmp204x.c b/board/keymile/kmp204x/kmp204x.c
>> index f02642a..b41929a 100644
>> --- a/board/keymile/kmp204x/kmp204x.c
>> +++ b/board/keymile/kmp204x/kmp204x.c
>> @@ -134,22 +134,25 @@ void qrio_prstcfg(u8 bit, u8 mode)
>>  }
>>  
>>  
>> -#define BOOTCOUNT_OFF	0x12
>> +#define BOOTCOUNT_OFF	0x20
>>  
>>  void bootcount_store(ulong counter)
>>  {
>> -	u8 val;
>>  	void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
>>  
>> -	val = (counter <= 255) ? (u8)counter : 255;
>> -	out_8(qrio_base + BOOTCOUNT_OFF, val);
>> +	out_be32(qrio_base + BOOTCOUNT_OFF, counter);
>>  }
>>  
>>  ulong bootcount_load(void)
>>  {
>> -	u8 val;
>> +	u32 val;
>>  	void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
>> -	val = in_8(qrio_base + BOOTCOUNT_OFF);
>> +	val = in_be32(qrio_base + BOOTCOUNT_OFF + 4);
>> +
>> +	if (val == BOOTCOUNT_MAGIC)
>> +		val = in_be32(qrio_base + BOOTCOUNT_OFF);
>> +	else
>> +		val = 0;
>>  	return val;
>>  }
> 
> Can't you just use the common bootcount driver
> (drivers/bootcount/bootcount.c) instead? Should be easy. Just define
> this in your config header:
> 
> #define CONFIG_BOOTCOUNT_LIMIT
> #define CONFIG_SYS_BOOTCOUNT_ADDR	(CONFIG_SYS_QRIO_BASE + 0x20)

Thanks for the input, I will use this.

Best regards

Valentin


More information about the U-Boot mailing list