[U-Boot] [PATCH] Consolidate bootcount code into drivers/bootcount
Stefan Roese
sr at denx.de
Fri Jun 1 15:05:17 CEST 2012
Hi Christian,
On Friday 01 June 2012 14:51:32 Christian Riesch wrote:
> > +void bootcount_store(ulong a)
> > +{
> > + struct davinci_rtc *reg =
> > + (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
> > +
> > + /*
> > + * write RTC kick register to enable write
> > + * for RTC Scratch registers. Scratch0 and 1 are
> > + * used for bootcount values.
> > + */
> > + writel(RTC_KICK0R_WE, ®->kick0r);
> > + writel(RTC_KICK1R_WE, ®->kick1r);
> > + out_be32(®->scratch0, a);
> > + out_be32(®->scratch1, BOOTCOUNT_MAGIC);
>
> This code here seems to be copied from the enbw_cmc board. The
> calimain board uses writel instead of out_be32 for the scratch
> registers (because I didn't understand why we should use big endian on
> a little endian machine). So your patch changes the byte order here
> for the calimain board and thus breaks our boot counter support.
I missed this difference. Thanks for spotting.
> What's the reason for using out_be32 here?
I assume historical reasons, as all this bootcounter code is originated from
powerpc specific code. Heiko, is this correct?
> > +}
> > +
> > +ulong bootcount_load(void)
> > +{
> > + struct davinci_rtc *reg =
> > + (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
> > +
> > + if (in_be32(®->scratch1) != BOOTCOUNT_MAGIC)
> > + return 0;
> > + else
> > + return in_be32(®->scratch0);
>
> Same as above, the calimain board uses readl instead of in_be32.
>
> I replaced out_be32 by writel and in_be32 by readl and tested it on
> the calimain board, it works fine :-)
I see. Too bad, now we have two Davince boards using nearly the same driver,
one little endian and one big endian. If none of both boards can be changed,
then we need to add an configuration switch to select the endianess.
Heiko? Any comments?
Thanks,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
More information about the U-Boot
mailing list