[U-Boot] [PATCH] Consolidate bootcount code into drivers/bootcount

Christian Riesch christian.riesch at omicron.at
Fri Jun 1 14:51:32 CEST 2012


Hi Stefan,

On Fri, Jun 1, 2012 at 11:52 AM, Stefan Roese <sr at denx.de> wrote:
> This patch moves all bootcount implementations into a common
> directory: drivers/bootcount. The generic bootcount driver
> (bootcount.c) is now usable not only by powerpc platforms, but
> others as well. Highbank is already moved to this "generic"
> code. For all other non-generic implementations, SoC specific
> drivers have been created (e.g. bootcount_at91.c).

Thank you for this patch! I have reviewed and tested the
davinci/calimain parts of it, please see below.

[...]

> diff --git a/drivers/bootcount/bootcount_davinci.c b/drivers/bootcount/bootcount_davinci.c
> new file mode 100644
> index 0000000..8674eb7
> --- /dev/null
> +++ b/drivers/bootcount/bootcount_davinci.c
> @@ -0,0 +1,50 @@
> +/*
> + * (C) Copyright 2011
> + * Heiko Schocher, DENX Software Engineering, hs at denx.de.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/arch/da850_lowlevel.h>
> +#include <asm/arch/davinci_misc.h>
> +
> +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, &reg->kick0r);
> +       writel(RTC_KICK1R_WE, &reg->kick1r);
> +       out_be32(&reg->scratch0, a);
> +       out_be32(&reg->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.

What's the reason for using out_be32 here?

> +}
> +
> +ulong bootcount_load(void)
> +{
> +       struct davinci_rtc *reg =
> +               (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
> +
> +       if (in_be32(&reg->scratch1) != BOOTCOUNT_MAGIC)
> +               return 0;
> +       else
> +               return in_be32(&reg->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 :-)

Regards, Christian


More information about the U-Boot mailing list