From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: "Mylène Josserand" <mylene.josserand@free-electrons.com>
Cc: rtc-linux@googlegroups.com,
Alessandro Zummo <a.zummo@towertech.it>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] rtc: rv3029: enable AE_x bits on set_alarm
Date: Sat, 23 Apr 2016 01:37:16 +0200 [thread overview]
Message-ID: <20160422233716.GH17051@piout.net> (raw)
In-Reply-To: <ca637cf527c3b7e9fbd0cab08ca35c1dfb97ca67.1461250479.git.mylene.josserand@free-electrons.com>
On 21/04/2016 at 20:24:18 +0200, Mylène Josserand wrote :
> The RTC RV3029 handles different types of alarms : seconds, minutes, ...
> These alarms can be enabled or disabled individually using an AE_x bit
> which is the last bit (BIT(7)) on each alarm registers.
>
> To prepare the alarm IRQ support, the current code enables all the alarm
> types by setting each AE_x to 1.
> It also fixes month and weekday errors : it was performing -1 instead
> of +1.
>
> Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
> ---
> drivers/rtc/rtc-rv3029c2.c | 23 ++++++++++++++++-------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
> index a849005..42de1a3 100644
> --- a/drivers/rtc/rtc-rv3029c2.c
> +++ b/drivers/rtc/rtc-rv3029c2.c
> @@ -76,6 +76,7 @@
> #define RV3029_A_DW 0x14
> #define RV3029_A_MO 0x15
> #define RV3029_A_YR 0x16
> +#define RV3029_A_AE_X BIT(7)
> #define RV3029_ALARM_SECTION_LEN 0x07
>
> /* timer section */
> @@ -436,14 +437,22 @@ static int rv3029_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
> dev_err(dev, "%s: reading SR failed\n", __func__);
> return -EIO;
> }
> - regs[RV3029_A_SC - RV3029_A_SC] = bin2bcd(tm->tm_sec & 0x7f);
> - regs[RV3029_A_MN - RV3029_A_SC] = bin2bcd(tm->tm_min & 0x7f);
> - regs[RV3029_A_HR - RV3029_A_SC] = bin2bcd(tm->tm_hour & 0x3f);
> - regs[RV3029_A_DT - RV3029_A_SC] = bin2bcd(tm->tm_mday & 0x3f);
> - regs[RV3029_A_MO - RV3029_A_SC] = bin2bcd((tm->tm_mon & 0x1f) - 1);
> - regs[RV3029_A_DW - RV3029_A_SC] = bin2bcd((tm->tm_wday & 7) - 1);
> - regs[RV3029_A_YR - RV3029_A_SC] = bin2bcd((tm->tm_year & 0x7f) - 100);
>
> + /* Activate all the alarms with AE_x bit */
> + regs[RV3029_A_SC - RV3029_A_SC] = (bin2bcd(tm->tm_sec)) | RV3029_A_AE_X;
> + regs[RV3029_A_MN - RV3029_A_SC] = (bin2bcd(tm->tm_min)) | RV3029_A_AE_X;
> + regs[RV3029_A_HR - RV3029_A_SC] = (bin2bcd(tm->tm_hour & 0x3f))
> + | RV3029_A_AE_X;
> + regs[RV3029_A_DT - RV3029_A_SC] = (bin2bcd(tm->tm_mday & 0x3f))
> + | RV3029_A_AE_X;
> + regs[RV3029_A_MO - RV3029_A_SC] = (bin2bcd((tm->tm_mon & 0x1f) + 1))
> + | RV3029_A_AE_X;
> + regs[RV3029_A_DW - RV3029_A_SC] = (bin2bcd((tm->tm_wday & 7) + 1))
> + | RV3029_A_AE_X;
> + regs[RV3029_A_YR - RV3029_A_SC] = (bin2bcd((tm->tm_year) - 100))
> + | RV3029_A_AE_X;
> +
Alarms probably never worked anyway because this still suffers form
another bug:
(bin2bcd(tm->tm_hour & 0x3f)) should be (bin2bcd(tm->tm_hour) & 0x3f),
and the same for the other members.
note that (bin2bcd((tm->tm_mon & 0x1f) + 1)) must be
(bin2bcd(tm->tm_mon + 1) & 0x1f)
etc...
> + /* Write the alarm */
> ret = rv3029_write_regs(dev, RV3029_A_SC, regs,
> RV3029_ALARM_SECTION_LEN);
> if (ret < 0)
> --
> 2.8.0.rc3
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-04-22 23:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 18:24 [PATCH 0/6] add support for Microcrystal RV-3049 Mylène Josserand
2016-04-21 18:24 ` [PATCH 1/6] rtc: rv3029: remove 'i2c' in functions names Mylène Josserand
2016-04-21 18:24 ` [PATCH 2/6] rtc: rv3029: convert to use regmap Mylène Josserand
2016-04-21 18:24 ` [PATCH 3/6] rtc: rv3029: Add support of RV3049 Mylène Josserand
2016-04-21 18:24 ` [PATCH 4/6] rtc: rv3029: Removes some checks and warnings Mylène Josserand
2016-04-22 23:29 ` Alexandre Belloni
2016-04-22 23:31 ` Alexandre Belloni
2016-04-21 18:24 ` [PATCH 5/6] rtc: rv3029: enable AE_x bits on set_alarm Mylène Josserand
2016-04-22 23:37 ` Alexandre Belloni [this message]
2016-04-21 18:24 ` [PATCH 6/6] rtc: rv3029: add alarm IRQ Mylène Josserand
2016-04-22 23:48 ` Alexandre Belloni
2016-04-28 22:00 ` [PATCH V2 0/6] add support for Microcrystal RV-3049 Mylène Josserand
2016-04-28 22:00 ` [PATCH V2 1/6] rtc: rv3029: remove 'i2c' in functions names Mylène Josserand
2016-04-28 22:00 ` [PATCH V2 2/6] rtc: rv3029: convert to use regmap Mylène Josserand
2016-04-28 22:00 ` [PATCH V2 3/6] rtc: rv3029: Add support of RV3049 Mylène Josserand
2016-04-28 22:00 ` [PATCH V2 4/6] rtc: rv3029: Removes some checks and warnings Mylène Josserand
2016-04-28 22:00 ` [PATCH V2 5/6] rtc: rv3029: fix alarm support Mylène Josserand
2016-05-03 8:25 ` Alexandre Belloni
2016-04-28 22:00 ` [PATCH V2 6/6] rtc: rv3029: add alarm IRQ Mylène Josserand
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=20160422233716.GH17051@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=mylene.josserand@free-electrons.com \
--cc=rtc-linux@googlegroups.com \
/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