[RFC 5/5] commands: add hwclock
Sascha Hauer
s.hauer at pengutronix.de
Thu Jul 10 14:45:47 PDT 2014
On Thu, Jul 10, 2014 at 12:33:19PM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
> commands/Kconfig | 8 ++++++++
> commands/Makefile | 1 +
> commands/hwclock.c | 37 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 46 insertions(+)
>
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 61816f5..a594f7c 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -1691,6 +1691,14 @@ config CMD_GPIO
>
> Usage: gpio_set_value GPIO VALUE
>
> +config CMD_HWCLOCK
> + bool
> + depends on RTC_CLASS
> + prompt "hwclock command"
> + default y
> + help
> + The lspci command allows to query or set the hardware clock (RTC).
lspci? ;)
> +static int do_hwclock(int argc, char *argv[])
> +{
> + struct rtc_device *r;
> + struct rtc_time tm;
> + char *rtc_name;
> +
> + rtc_name = "rtc0";
> +
> + if (argc > 1)
> + rtc_name = argv[1];
> +
> + r = rtc_lookup(rtc_name);
> + if (IS_ERR(r))
> + return PTR_ERR(r);
> +
> + rtc_read_time(r, &tm);
> +
> + printf("%02d:%02d:%02d %02d-%02d-%04d\n",
> + tm.tm_hour, tm.tm_min, tm.tm_sec,
> + tm.tm_mday, tm.tm_mon, tm.tm_year);
> +
> + return 0;
> +}
> +
> +BAREBOX_CMD_START(hwclock)
> + .cmd = do_hwclock,
> + BAREBOX_CMD_DESC("query or set the hardware clock (RTC)")
This initial version doesn't allow to set the time.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list