mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
board: ge: mx53ppd: Move check_time() to common location
We are going to be using check_time() on more than the mx53ppd, move this function to a common location. Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
This commit is contained in:
parent
1b25f2d9d7
commit
647155bcd5
4 changed files with 64 additions and 47 deletions
|
@ -4,4 +4,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-y := vpd_reader.o
|
||||
obj-y := vpd_reader.o ge_common.o
|
||||
|
|
55
board/ge/common/ge_common.c
Normal file
55
board/ge/common/ge_common.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2017 General Electric Company
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <i2c.h>
|
||||
#include <rtc.h>
|
||||
|
||||
void check_time(void)
|
||||
{
|
||||
int ret, i;
|
||||
struct rtc_time tm;
|
||||
u8 retry = 3;
|
||||
|
||||
unsigned int current_i2c_bus = i2c_get_bus_num();
|
||||
|
||||
ret = i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
rtc_init();
|
||||
|
||||
for (i = 0; i < retry; i++) {
|
||||
ret = rtc_get(&tm);
|
||||
if (!ret || ret == -EINVAL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
env_set("rtc_status", "RTC_ERROR");
|
||||
|
||||
if (tm.tm_year > 2037) {
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_mday = 1;
|
||||
tm.tm_wday = 2;
|
||||
tm.tm_mon = 1;
|
||||
tm.tm_year = 2036;
|
||||
|
||||
for (i = 0; i < retry; i++) {
|
||||
ret = rtc_set(&tm);
|
||||
if (!ret)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
env_set("rtc_status", "RTC_ERROR");
|
||||
}
|
||||
|
||||
i2c_set_bus_num(current_i2c_bus);
|
||||
}
|
||||
|
7
board/ge/common/ge_common.h
Normal file
7
board/ge/common/ge_common.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright 2017 General Electric Company
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
void check_time(void);
|
|
@ -33,8 +33,8 @@
|
|||
#include <watchdog.h>
|
||||
#include "ppd_gpio.h"
|
||||
#include <stdlib.h>
|
||||
#include "../../ge/common/ge_common.h"
|
||||
#include "../../ge/common/vpd_reader.h"
|
||||
#include <rtc.h>
|
||||
|
||||
#define MX53PPD_LCD_POWER IMX_GPIO_NR(3, 24)
|
||||
|
||||
|
@ -357,51 +357,6 @@ static int read_vpd(uint eeprom_bus)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void check_time(void)
|
||||
{
|
||||
int ret, i;
|
||||
struct rtc_time tm;
|
||||
u8 retry = 3;
|
||||
|
||||
unsigned int current_i2c_bus = i2c_get_bus_num();
|
||||
|
||||
ret = i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
rtc_init();
|
||||
|
||||
for (i = 0; i < retry; i++) {
|
||||
ret = rtc_get(&tm);
|
||||
if (!ret || ret == -EINVAL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
env_set("rtc_status", "RTC_ERROR");
|
||||
|
||||
if (tm.tm_year > 2037) {
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_mday = 1;
|
||||
tm.tm_wday = 2;
|
||||
tm.tm_mon = 1;
|
||||
tm.tm_year = 2036;
|
||||
|
||||
for (i = 0; i < retry; i++) {
|
||||
ret = rtc_set(&tm);
|
||||
if (!ret)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
env_set("rtc_status", "RTC_ERROR");
|
||||
}
|
||||
|
||||
i2c_set_bus_num(current_i2c_bus);
|
||||
}
|
||||
|
||||
int board_init(void)
|
||||
{
|
||||
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
|
||||
|
|
Loading…
Reference in a new issue