From: varkabhadram@gmail.com (Varka Bhadram)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/6] rtc: sun6i: Add sun6i RTC driver
Date: Fri, 25 Jul 2014 16:06:01 +0530 [thread overview]
Message-ID: <53D23311.5000402@gmail.com> (raw)
In-Reply-To: <1406279608-489-2-git-send-email-wens@csie.org>
On 07/25/2014 02:43 PM, Chen-Yu Tsai wrote:
> This patch introduces the driver for the RTC in the Allwinner A31 and
> A23 SoCs.
>
> Unlike the RTC found in A10/A20 SoCs, which was part of the timer, the
> RTC in A31/A23 are a separate hardware block, which also contain a few
> controls for the RTC block hardware (a regulator and RTC block GPIO pin
> latches), while also having separate interrupts for the alarms.
>
> The hardware is different enough to make a different driver for it.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
> .../devicetree/bindings/rtc/sun6i-rtc.txt | 17 +
> drivers/rtc/Kconfig | 7 +
> drivers/rtc/Makefile | 1 +
> drivers/rtc/rtc-sun6i.c | 447 +++++++++++++++++++++
> 4 files changed, 472 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
> create mode 100644 drivers/rtc/rtc-sun6i.c
>
(....)
> +static int sun6i_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
> +{
> + struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
> + u32 date = 0;
> + u32 time = 0;
> + int year;
> +
> + year = rtc_tm->tm_year + 1900;
> + if (year < SUN6I_YEAR_MIN || year > SUN6I_YEAR_MAX) {
> + dev_err(dev, "rtc only supports year in range %d - %d\n",
> + SUN6I_YEAR_MIN, SUN6I_YEAR_MAX);
dev_err(dev, "rtc only supports year in range %d - %d\n",
SUN6I_YEAR_MIN, SUN6I_YEAR_MAX);
> + return -EINVAL;
> + }
> +
> + rtc_tm->tm_year -= SUN6I_YEAR_OFF;
> + rtc_tm->tm_mon += 1;
> +
> + date = SUN6I_DATE_SET_DAY_VALUE(rtc_tm->tm_mday) |
> + SUN6I_DATE_SET_MON_VALUE(rtc_tm->tm_mon) |
> + SUN6I_DATE_SET_YEAR_VALUE(rtc_tm->tm_year);
> +
> + if (is_leap_year(year))
> + date |= SUN6I_LEAP_SET_VALUE(1);
> +
> + time = SUN6I_TIME_SET_SEC_VALUE(rtc_tm->tm_sec) |
> + SUN6I_TIME_SET_MIN_VALUE(rtc_tm->tm_min) |
> + SUN6I_TIME_SET_HOUR_VALUE(rtc_tm->tm_hour);
> +
> + /* Check whether registers are writable */
> + if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
> + SUN6I_LOSC_CTRL_ACC_MASK, 50)) {
if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
SUN6I_LOSC_CTRL_ACC_MASK, 50)
> + dev_err(dev, "rtc is still busy.\n");
> + return -EBUSY;
> + }
> +
> + writel(time, chip->base + SUN6I_RTC_HMS);
> +
> + /*
> + * After writing the RTC HH-MM-SS register, the
> + * SUN6I_LOSC_CTRL_RTC_HMS_ACC bit is set and it will not
> + * be cleared until the real writing operation is finished
> + */
> +
> + if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
> + SUN6I_LOSC_CTRL_RTC_HMS_ACC, 50)) {
same..
> + dev_err(dev, "Failed to set rtc time.\n");
> + return -ETIMEDOUT;
> + }
> +
> + writel(date, chip->base + SUN6I_RTC_YMD);
> +
> + /*
> + * After writing the RTC YY-MM-DD register, the
> + * SUN6I_LOSC_CTRL_RTC_YMD_ACC bit is set and it will not
> + * be cleared until the real writing operation is finished
> + */
> +
> + if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
> + SUN6I_LOSC_CTRL_RTC_YMD_ACC, 50)) {
same...
--
Regards,
Varka Bhadram.
next prev parent reply other threads:[~2014-07-25 10:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 9:13 [PATCH v3 0/6] ARM: sunxi: RTC support for A31/A23 Chen-Yu Tsai
2014-07-25 9:13 ` [PATCH v3 1/6] rtc: sun6i: Add sun6i RTC driver Chen-Yu Tsai
2014-07-25 10:36 ` Varka Bhadram [this message]
2014-07-25 9:13 ` [PATCH v3 2/6] rtc: sunxi: Depend on platforms sun4i/sun7i that actually have the rtc Chen-Yu Tsai
2014-07-25 9:13 ` [PATCH v3 3/6] ARM: dts: sun6i: add rtc device node Chen-Yu Tsai
2014-07-25 9:13 ` [PATCH v3 4/6] ARM: dts: sun8i: " Chen-Yu Tsai
2014-07-25 9:13 ` [PATCH v3 5/6] ARM: sunxi: Add A31 RTC driver to sunxi_defconfig Chen-Yu Tsai
2014-07-25 9:13 ` [PATCH v3 6/6] ARM: sunxi: Add A31 RTC driver to multi_v7_defconfig Chen-Yu Tsai
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=53D23311.5000402@gmail.com \
--to=varkabhadram@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).