[PATCH 6/7] rtc: davinci: add driver model support
Lokesh Vutla
lokeshvutla at ti.com
Thu May 27 12:04:40 CEST 2021
On 07/05/21 9:45 am, Dario Binacchi wrote:
> Update the driver to support the device tree and the driver model.
> The read / write helpers in rtc_ops allow access to scratch registers
> only. The offset parameter is added to the address of the scratch0
> register.
>
> Signed-off-by: Dario Binacchi <dariobin at libero.it>
> ---
>
> drivers/rtc/davinci.c | 373 ++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 363 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/rtc/davinci.c b/drivers/rtc/davinci.c
> index 82e5eb3b43..b0a077cba7 100644
> --- a/drivers/rtc/davinci.c
> +++ b/drivers/rtc/davinci.c
> @@ -2,20 +2,20 @@
> /*
> * (C) Copyright 2011 DENX Software Engineering GmbH
> * Heiko Schocher <hs at denx.de>
> + * Copyright (C) 2021 Dario Binacchi <dariobin at libero.it>
> */
> #include <common.h>
> #include <command.h>
> +#include <dm.h>
> +#include <clk.h>
> #include <log.h>
> #include <rtc.h>
> #include <asm/io.h>
> #include <asm/davinci_rtc.h>
> #include <asm/arch/hardware.h>
> +#include <dm/device_compat.h>
> #include <linux/delay.h>
>
> -#if !defined(RTC_BASE) && defined(DAVINCI_RTC_BASE)
> -#define RTC_BASE DAVINCI_RTC_BASE
> -#endif
> -
> static void davinci_rtc_lock(struct davinci_rtc *rtc)
> {
> writel(0, &rtc->kick0r);
> @@ -52,9 +52,8 @@ static int davinci_rtc_wait_not_busy(struct davinci_rtc *rtc)
> return 0;
> }
>
> -int rtc_get(struct rtc_time *tmp)
> +static int davinci_rtc_get(struct davinci_rtc *rtc, struct rtc_time *tmp)
can we use use consistent naming? omap_rtc_<function>?
> {
> - struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
> unsigned long sec, min, hour, mday, wday, mon_cent, year;
> int ret;
>
> @@ -92,9 +91,8 @@ int rtc_get(struct rtc_time *tmp)
> return 0;
> }
>
> -int rtc_set(struct rtc_time *tmp)
> +static int davinci_rtc_set(struct davinci_rtc *rtc, const struct rtc_time *tmp)
> {
> - struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
> int ret;
>
> ret = davinci_rtc_wait_not_busy(rtc);
> @@ -119,10 +117,365 @@ int rtc_set(struct rtc_time *tmp)
> return 0;
> }
>
> +static void davinci_rtc_reset(struct davinci_rtc *rtc)
> +{
> + /* run RTC counter */
> + writeb(0x01, &rtc->ctrl);
> +}
> +
> +#if !CONFIG_IS_ENABLED(DM_RTC)
Are there any users of non-DM? If not can we just drop the support for non-DM?
Thanks and regards,
Lokesh
More information about the U-Boot
mailing list