[kernel] r19782 - in dists/sid/linux/debian: . patches patches/features/arm
Ben Hutchings
benh at alioth.debian.org
Mon Jan 28 04:28:31 UTC 2013
Author: benh
Date: Mon Jan 28 04:28:29 2013
New Revision: 19782
Log:
[armel/kirkwood] rtc-s35390a: add wakealarm support (Closes: #693997)
Added:
dists/sid/linux/debian/patches/features/arm/rtc-s35390a-wakealarm.patch
Modified:
dists/sid/linux/debian/changelog
dists/sid/linux/debian/patches/series
Modified: dists/sid/linux/debian/changelog
==============================================================================
--- dists/sid/linux/debian/changelog Mon Jan 28 00:22:35 2013 (r19781)
+++ dists/sid/linux/debian/changelog Mon Jan 28 04:28:29 2013 (r19782)
@@ -102,6 +102,7 @@
* md: protect against crash upon fsync on ro array (Closes: #696650)
* net: Add alx driver for Atheros AR8161 and AR8162 (Closes: #699129)
- Mark as staging, since it has not been accepted upstream
+ * [armel/kirkwood] rtc-s35390a: add wakealarm support (Closes: #693997)
[ Aurelien Jarno ]
* [armhf/vexpress] Add kernel udebs.
Added: dists/sid/linux/debian/patches/features/arm/rtc-s35390a-wakealarm.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/sid/linux/debian/patches/features/arm/rtc-s35390a-wakealarm.patch Mon Jan 28 04:28:29 2013 (r19782)
@@ -0,0 +1,178 @@
+From: Michael Langer <michael.brainbug.langer at googlemail.com>
+Date: Thu, 4 Oct 2012 17:14:37 -0700
+Subject: drivers/rtc/rtc-s35390a.c: add wakealarm support for rtc-s35390A rtc
+ chip
+
+commit 542dd33a4925757c93b2c811b19434822a6c1a73 upstream.
+
+Add basic get/set alarm support for the Seiko Instruments S-35390A. The
+chip is used on the QNAP TS-219P+ NAS device.
+
+Signed-off-by: Michael Langer <michael.brainbug.langer at googlemail.com>
+Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
+---
+ drivers/rtc/rtc-s35390a.c | 116 +++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 116 insertions(+)
+
+diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
+index cc5c516..8a09232 100644
+--- a/drivers/rtc/rtc-s35390a.c
++++ b/drivers/rtc/rtc-s35390a.c
+@@ -19,6 +19,8 @@
+ #define S35390A_CMD_STATUS1 0
+ #define S35390A_CMD_STATUS2 1
+ #define S35390A_CMD_TIME1 2
++#define S35390A_CMD_TIME2 3
++#define S35390A_CMD_INT2_REG1 5
+
+ #define S35390A_BYTE_YEAR 0
+ #define S35390A_BYTE_MONTH 1
+@@ -28,12 +30,23 @@
+ #define S35390A_BYTE_MINS 5
+ #define S35390A_BYTE_SECS 6
+
++#define S35390A_ALRM_BYTE_WDAY 0
++#define S35390A_ALRM_BYTE_HOURS 1
++#define S35390A_ALRM_BYTE_MINS 2
++
+ #define S35390A_FLAG_POC 0x01
+ #define S35390A_FLAG_BLD 0x02
+ #define S35390A_FLAG_24H 0x40
+ #define S35390A_FLAG_RESET 0x80
+ #define S35390A_FLAG_TEST 0x01
+
++#define S35390A_INT2_MODE_MASK 0xF0
++
++#define S35390A_INT2_MODE_NOINTR 0x00
++#define S35390A_INT2_MODE_FREQ 0x10
++#define S35390A_INT2_MODE_ALARM 0x40
++#define S35390A_INT2_MODE_PMIN_EDG 0x20
++
+ static const struct i2c_device_id s35390a_id[] = {
+ { "s35390a", 0 },
+ { }
+@@ -193,6 +206,104 @@ static int s35390a_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+ return rtc_valid_tm(tm);
+ }
+
++static int s35390a_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
++{
++ struct s35390a *s35390a = i2c_get_clientdata(client);
++ char buf[3], sts = 0;
++ int err, i;
++
++ dev_dbg(&client->dev, "%s: alm is secs=%d, mins=%d, hours=%d mday=%d, "\
++ "mon=%d, year=%d, wday=%d\n", __func__, alm->time.tm_sec,
++ alm->time.tm_min, alm->time.tm_hour, alm->time.tm_mday,
++ alm->time.tm_mon, alm->time.tm_year, alm->time.tm_wday);
++
++ /* disable interrupt */
++ err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
++ if (err < 0)
++ return err;
++
++ /* clear pending interrupt, if any */
++ err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, &sts, sizeof(sts));
++ if (err < 0)
++ return err;
++
++ if (alm->enabled)
++ sts = S35390A_INT2_MODE_ALARM;
++ else
++ sts = S35390A_INT2_MODE_NOINTR;
++
++ /* This chip expects the bits of each byte to be in reverse order */
++ sts = bitrev8(sts);
++
++ /* set interupt mode*/
++ err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
++ if (err < 0)
++ return err;
++
++ if (alm->time.tm_wday != -1)
++ buf[S35390A_ALRM_BYTE_WDAY] = bin2bcd(alm->time.tm_wday) | 0x80;
++
++ buf[S35390A_ALRM_BYTE_HOURS] = s35390a_hr2reg(s35390a,
++ alm->time.tm_hour) | 0x80;
++ buf[S35390A_ALRM_BYTE_MINS] = bin2bcd(alm->time.tm_min) | 0x80;
++
++ if (alm->time.tm_hour >= 12)
++ buf[S35390A_ALRM_BYTE_HOURS] |= 0x40;
++
++ for (i = 0; i < 3; ++i)
++ buf[i] = bitrev8(buf[i]);
++
++ err = s35390a_set_reg(s35390a, S35390A_CMD_INT2_REG1, buf,
++ sizeof(buf));
++
++ return err;
++}
++
++static int s35390a_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
++{
++ struct s35390a *s35390a = i2c_get_clientdata(client);
++ char buf[3], sts;
++ int i, err;
++
++ err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
++ if (err < 0)
++ return err;
++
++ if (bitrev8(sts) != S35390A_INT2_MODE_ALARM)
++ return -EINVAL;
++
++ err = s35390a_get_reg(s35390a, S35390A_CMD_INT2_REG1, buf, sizeof(buf));
++ if (err < 0)
++ return err;
++
++ /* This chip returns the bits of each byte in reverse order */
++ for (i = 0; i < 3; ++i) {
++ buf[i] = bitrev8(buf[i]);
++ buf[i] &= ~0x80;
++ }
++
++ alm->time.tm_wday = bcd2bin(buf[S35390A_ALRM_BYTE_WDAY]);
++ alm->time.tm_hour = s35390a_reg2hr(s35390a,
++ buf[S35390A_ALRM_BYTE_HOURS]);
++ alm->time.tm_min = bcd2bin(buf[S35390A_ALRM_BYTE_MINS]);
++
++ dev_dbg(&client->dev, "%s: alm is mins=%d, hours=%d, wday=%d\n",
++ __func__, alm->time.tm_min, alm->time.tm_hour,
++ alm->time.tm_wday);
++
++ return 0;
++}
++
++static int s35390a_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
++{
++ return s35390a_read_alarm(to_i2c_client(dev), alm);
++}
++
++static int s35390a_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
++{
++ return s35390a_set_alarm(to_i2c_client(dev), alm);
++}
++
+ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)
+ {
+ return s35390a_get_datetime(to_i2c_client(dev), tm);
+@@ -206,6 +317,9 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm)
+ static const struct rtc_class_ops s35390a_rtc_ops = {
+ .read_time = s35390a_rtc_read_time,
+ .set_time = s35390a_rtc_set_time,
++ .set_alarm = s35390a_rtc_set_alarm,
++ .read_alarm = s35390a_rtc_read_alarm,
++
+ };
+
+ static struct i2c_driver s35390a_driver;
+@@ -270,6 +384,8 @@ static int s35390a_probe(struct i2c_client *client,
+ if (s35390a_get_datetime(client, &tm) < 0)
+ dev_warn(&client->dev, "clock needs to be set\n");
+
++ device_set_wakeup_capable(&client->dev, 1);
++
+ s35390a->rtc = rtc_device_register(s35390a_driver.driver.name,
+ &client->dev, &s35390a_rtc_ops, THIS_MODULE);
+
Modified: dists/sid/linux/debian/patches/series
==============================================================================
--- dists/sid/linux/debian/patches/series Mon Jan 28 00:22:35 2013 (r19781)
+++ dists/sid/linux/debian/patches/series Mon Jan 28 04:28:29 2013 (r19782)
@@ -481,3 +481,4 @@
features/all/alx/alx-add-new-QCA-ethernet-driver-which-supercedes-atl.patch
features/all/alx/remove-atl1c-devices-from-alx.patch
features/all/alx/mark-as-staging.patch
+features/arm/rtc-s35390a-wakealarm.patch
More information about the Kernel-svn-changes
mailing list