UPSTREAM: lib: Add real-time-clock functions

Add functions to convert between seconds and a struct rtc_time. Also
add a function that can display the time on the console.

BUG=chrome-os-partner:52220
BRANCH=none
TEST=(partial) with future commits and after setting RTC on the EC:
boot on gru into linux shell, check firmware log:

localhost ~ # grep Date: /sys/firmware/log
Date: 2016-06-20 (Monday) Time: 18:01:44

Then reboot ~10 seconds and check again:

localhost ~ # grep Date: /sys/firmware/log
Date: 2016-06-20 (Monday) Time: 18:01:54

BUG=None
BRANCH=None
TEST=None

Change-Id: Id148ccb7a18a05865b903307358666ff6c7b4a3d
Original-Signed-off-by: Martin Roth <martinroth@chromium.org>
Original-Original-Commit-Id: 3b02dbcd7d
Original-Change-Id: I344c385e2e4cb995d3a374025c205f01c38b660d
Original-Original-Signed-off-by: Simon Glass <sjg@chromium.org>
Original-Original-Reviewed-on: https://chromium-review.googlesource.com/351782
Original-Original-Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Original-Original-Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Original-Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/15301
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/358385
Reviewed-by: Martin Roth <martinroth@chromium.org>
This commit is contained in:
Simon Glass 2016-06-10 20:58:24 -06:00 committed by chrome-bot
parent 61dc13efa8
commit 7903c214ba
3 changed files with 14 additions and 5 deletions

View file

@ -25,5 +25,3 @@ verstage-y += lz4_wrapper.c
romstage-y += lz4_wrapper.c
ramstage-y += lz4_wrapper.c
postcar-y += lz4_wrapper.c
ramstage-y += rtc.c

View file

@ -81,6 +81,7 @@ ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
romstage-y += stack.c
ramstage-y += rtc.c
ifeq ($(CONFIG_EARLY_CBMEM_INIT),y)
romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c

View file

@ -1,8 +1,18 @@
/*
* (C) Copyright 2001
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
* This file is part of the coreboot project.
*
* (C) Copyright 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* 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; 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.
*
* SPDX-License-Identifier: GPL-2.0+
* From U-Boot 2016.05
*/