mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-16 09:48:16 +00:00
65cc0e2a65
The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
43 lines
798 B
C
43 lines
798 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2013
|
|
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
*/
|
|
|
|
#include <bootcount.h>
|
|
#include <linux/compiler.h>
|
|
#include <i2c.h>
|
|
|
|
#define BC_MAGIC 0xbc
|
|
|
|
void bootcount_store(ulong a)
|
|
{
|
|
unsigned char buf[3];
|
|
int ret;
|
|
|
|
buf[0] = BC_MAGIC;
|
|
buf[1] = (a & 0xff);
|
|
ret = i2c_write(CFG_SYS_I2C_RTC_ADDR, CONFIG_SYS_BOOTCOUNT_ADDR,
|
|
CONFIG_BOOTCOUNT_ALEN, buf, 2);
|
|
if (ret != 0)
|
|
puts("Error writing bootcount\n");
|
|
}
|
|
|
|
ulong bootcount_load(void)
|
|
{
|
|
unsigned char buf[3];
|
|
int ret;
|
|
|
|
ret = i2c_read(CFG_SYS_I2C_RTC_ADDR, CONFIG_SYS_BOOTCOUNT_ADDR,
|
|
CONFIG_BOOTCOUNT_ALEN, buf, 2);
|
|
if (ret != 0) {
|
|
puts("Error loading bootcount\n");
|
|
return 0;
|
|
}
|
|
if (buf[0] == BC_MAGIC)
|
|
return buf[1];
|
|
|
|
bootcount_store(0);
|
|
|
|
return 0;
|
|
}
|