From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/20] iMX28: Add driver for internal RTC
Date: Thu, 10 Nov 2011 14:12:38 +0100 [thread overview]
Message-ID: <4EBBCDC6.9070008@denx.de> (raw)
In-Reply-To: <1320830307-4762-11-git-send-email-marek.vasut@gmail.com>
On 11/09/2011 10:18 AM, Marek Vasut wrote:
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> ---
> drivers/rtc/Makefile | 1 +
> drivers/rtc/mxsrtc.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 87 insertions(+), 0 deletions(-)
> create mode 100644 drivers/rtc/mxsrtc.c
>
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index a16f590..faf4fcd 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -57,6 +57,7 @@ COBJS-$(CONFIG_RTC_MK48T59) += mk48t59.o
> COBJS-$(CONFIG_RTC_MPC5200) += mpc5xxx.o
> COBJS-$(CONFIG_RTC_MPC8xx) += mpc8xx.o
> COBJS-$(CONFIG_RTC_MV) += mvrtc.o
> +COBJS-$(CONFIG_RTC_MXS) += mxsrtc.o
> COBJS-$(CONFIG_RTC_PCF8563) += pcf8563.o
> COBJS-$(CONFIG_RTC_PL031) += pl031.o
> COBJS-$(CONFIG_RTC_PT7C4338) += pt7c4338.o
> diff --git a/drivers/rtc/mxsrtc.c b/drivers/rtc/mxsrtc.c
> new file mode 100644
> index 0000000..5beb1a0
> --- /dev/null
> +++ b/drivers/rtc/mxsrtc.c
> @@ -0,0 +1,86 @@
> +/*
> + * Freescale i.MX28 RTC Driver
> + *
> + * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
> + * on behalf of DENX Software Engineering GmbH
> + *
> + * 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; either 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + *
> + */
> +
> +#include <common.h>
> +#include <rtc.h>
> +#include <asm/io.h>
> +#include <asm/arch/imx-regs.h>
> +#include <asm/arch/sys_proto.h>
> +
> +#define MXS_RTC_MAX_TIMEOUT 1000000
> +
> +/* Set time in seconds since 1970-01-01 */
> +int mxs_rtc_set_time(uint32_t secs)
> +{
> + struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
> + int ret;
> +
> + writel(secs, &rtc_regs->hw_rtc_seconds);
> +
> + /*
> + * The 0x80 here means seconds were copied to analog. This information
> + * is taken from the linux kernel driver for the STMP37xx RTC since
> + * documentation doesn't mention it.
> + */
> + ret = mx28_wait_mask_clr(&rtc_regs->hw_rtc_stat_reg,
> + 0x80 << RTC_STAT_STALE_REGS_OFFSET, MXS_RTC_MAX_TIMEOUT);
> +
> + if (ret)
> + printf("MXS RTC: Timeout waiting for update\n");
> +
> + return ret;
> +}
> +
> +int rtc_get(struct rtc_time *time)
> +{
> + struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
> + uint32_t secs;
> +
> + secs = readl(&rtc_regs->hw_rtc_seconds);
> + to_tm(secs, time);
> +
> + return 0;
> +}
> +
> +int rtc_set(struct rtc_time *time)
> +{
> + uint32_t secs;
> +
> + secs = mktime(time->tm_year, time->tm_mon, time->tm_mday,
> + time->tm_hour, time->tm_min, time->tm_sec);
> +
> + return mxs_rtc_set_time(secs);
> +}
> +
> +void rtc_reset(void)
> +{
> + struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
> + int ret;
> +
> + /* Set time to 1970-01-01 */
> + mxs_rtc_set_time(0);
> +
> + /* Reset the RTC block */
> + ret = mx28_reset_block(&rtc_regs->hw_rtc_ctrl_reg);
> + if (ret)
> + printf("MXS RTC: Block reset timeout\n");
> +}
Applied to u-boot-imx, thanks.
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
next prev parent reply other threads:[~2011-11-10 13:12 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 9:18 [U-Boot] [PATCH 00/20 FINAL] Support for the DENX M28 SoM Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 01/20] iMX28: Initial support for iMX28 CPU Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 02/20] iMX28: Add SSP MMC driver Marek Vasut
2011-11-10 13:08 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 03/20] FEC: Add support for iMX28 quirks Marek Vasut
2011-11-10 13:09 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 04/20] iMX28: Add PINMUX control Marek Vasut
2011-11-10 13:09 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 05/20] iMX28: Add I2C bus driver Marek Vasut
2011-11-09 9:38 ` Heiko Schocher
2011-11-09 10:46 ` Marek Vasut
2011-11-10 13:10 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 06/20] iMX28: Add GPIO control Marek Vasut
2011-11-10 13:11 ` Stefano Babic
2011-11-10 16:23 ` Mike Frysinger
2011-11-10 16:58 ` Marek Vasut
2011-11-10 17:10 ` Mike Frysinger
2011-11-10 17:44 ` Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 07/20] iMX28: Add SPI driver Marek Vasut
2011-11-10 13:11 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 08/20] iMX28: Add APBH DMA driver Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 09/20] iMX28: Add GPMI NAND driver Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 10/20] iMX28: Add driver for internal RTC Marek Vasut
2011-11-10 13:12 ` Stefano Babic [this message]
2011-11-09 9:18 ` [U-Boot] [PATCH 11/20] iMX28: Add image header generator tool Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 12/20] iMX28: Add u-boot.sb target to Makefile Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 13/20] iMX28: Add support for DENX M28EVK board Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 14/20] M28: Add MMC SPL Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 15/20] M28: Add doc/README.m28 documentation Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 16/20] iMX28: Fix ARM vector handling Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 17/20] M28: Add memory detection into SPL Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 18/20] iMX28: Add USB and USB PHY register definitions Marek Vasut
2011-11-10 13:15 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 19/20] iMX28: Add USB HOST driver Marek Vasut
2011-11-10 13:15 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 20/20] M28EVK: Enable USB HOST support Marek Vasut
2011-11-10 13:16 ` Stefano Babic
2011-11-11 14:07 ` Veli-Pekka Peltola
2011-11-11 17:49 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EBBCDC6.9070008@denx.de \
--to=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox