Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-12-13 Thread Andrew Morton
On Thu, 13 Dec 2012 18:34:20 +0530
Ashish Jangam  wrote:

> (This rtc patch is resend for merge)
> ---
> This is the RTC patch for the DA9055 PMIC. This patch has got dependency on
> the DA9055 MFD core.
> 
> This patch is functionally tested on Samsung SMDKV6410.
> 
> ...
>
> +static int __init da9055_rtc_device_init(struct da9055 *da9055,
> + struct da9055_pdata *pdata)
> +{
> + int ret;
> +
> + /* Enable RTC and the internal Crystal */
> + ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
> + DA9055_RTC_EN, DA9055_RTC_EN);
> + if (ret < 0)
> + return ret;
> + ret = da9055_reg_update(da9055, DA9055_REG_EN_32K,
> + DA9055_CRYSTAL_EN, DA9055_CRYSTAL_EN);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable RTC in Power Down mode */
> + ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
> + DA9055_RTC_MODE_PD, DA9055_RTC_MODE_PD);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable RTC in Reset mode */
> + if (pdata && pdata->reset_enable) {
> + ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
> + DA9055_RTC_MODE_SD,
> + DA9055_RTC_MODE_SD <<
> + DA9055_RTC_MODE_SD_SHIFT);
> + if (ret < 0)
> + return ret;
> + }
> +
> + /* Disable the RTC TICK ALM */
> + ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MO,
> + DA9055_RTC_TICK_WAKE_MASK, 0);
> + if (ret < 0)
> + return ret;

If one of these failure paths is taken, the hardware will be left in a
part-initialised state.  Is this wise?

> + return 0;
> +}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-12-13 Thread Ashish Jangam
(This rtc patch is resend for merge)
---
This is the RTC patch for the DA9055 PMIC. This patch has got dependency on
the DA9055 MFD core.

This patch is functionally tested on Samsung SMDKV6410.

Signed-off-by: David Dajun Chen 
Signed-off-by: Ashish Jangam 
---
changes since version v3:
- use of module_platform_driver macro
- add the regmap virtual irq map API
changes since version v2:
- Use of devm_request_threaded_irq API
---
 drivers/rtc/Kconfig  |   10 +
 drivers/rtc/Makefile |1 +
 drivers/rtc/rtc-da9055.c |  413 ++
 3 files changed, 424 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-da9055.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5bb0314..d0cea02 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -609,6 +609,16 @@ config RTC_DRV_DA9052
  Say y here to support the RTC driver for Dialog Semiconductor
  DA9052-BC and DA9053-AA/Bx PMICs.
 
+config RTC_DRV_DA9055
+   tristate "Dialog Semiconductor DA9055 RTC"
+   depends on MFD_DA9055
+   help
+ If you say yes here you will get support for the
+ RTC of the Dialog DA9055 PMIC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-da9055
+
 config RTC_DRV_EFI
tristate "EFI RTC"
depends on IA64
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 59e2132..c3f62c8 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_RTC_DRV_BQ4802)  += rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)+= rtc-coh901331.o
 obj-$(CONFIG_RTC_DRV_DA9052)   += rtc-da9052.o
+obj-$(CONFIG_RTC_DRV_DA9055)   += rtc-da9055.o
 obj-$(CONFIG_RTC_DRV_DAVINCI)  += rtc-davinci.o
 obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
 obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c
new file mode 100644
index 000..a60d109
--- /dev/null
+++ b/drivers/rtc/rtc-da9055.c
@@ -0,0 +1,413 @@
+/*
+ * Real time clock driver for DA9055
+ *
+ * Copyright(c) 2012 Dialog Semiconductor Ltd.
+ *
+ * Author: Dajun Dajun Chen 
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct da9055_rtc {
+   struct rtc_device *rtc;
+   struct da9055 *da9055;
+   int alarm_enable;
+};
+
+static int da9055_rtc_enable_alarm(struct da9055_rtc *rtc, bool enable)
+{
+   int ret;
+   if (enable) {
+   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
+   DA9055_RTC_ALM_EN,
+   DA9055_RTC_ALM_EN);
+   if (ret != 0)
+   dev_err(rtc->da9055->dev, "Failed to enable ALM: %d\n",
+   ret);
+   rtc->alarm_enable = 1;
+   } else {
+   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
+   DA9055_RTC_ALM_EN, 0);
+   if (ret != 0)
+   dev_err(rtc->da9055->dev,
+   "Failed to disable ALM: %d\n", ret);
+   rtc->alarm_enable = 0;
+   }
+   return ret;
+}
+
+static irqreturn_t da9055_rtc_alm_irq(int irq, void *data)
+{
+   struct da9055_rtc *rtc = data;
+
+   da9055_rtc_enable_alarm(rtc, 0);
+   rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
+
+   return IRQ_HANDLED;
+}
+
+static int da9055_read_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
+{
+   int ret;
+   uint8_t v[5];
+
+   ret = da9055_group_read(da9055, DA9055_REG_ALARM_MI, 5, v);
+   if (ret != 0) {
+   dev_err(da9055->dev, "Failed to group read ALM: %d\n", ret);
+   return ret;
+   }
+
+   rtc_tm->tm_year = (v[4] & DA9055_RTC_ALM_YEAR) + 100;
+   rtc_tm->tm_mon  = (v[3] & DA9055_RTC_ALM_MONTH) - 1;
+   rtc_tm->tm_mday = v[2] & DA9055_RTC_ALM_DAY;
+   rtc_tm->tm_hour = v[1] & DA9055_RTC_ALM_HOUR;
+   rtc_tm->tm_min  = v[0] & DA9055_RTC_ALM_MIN;
+
+   return rtc_valid_tm(rtc_tm);
+}
+
+static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
+{
+   int ret;
+   uint8_t v[2];
+
+   rtc_tm->tm_year -= 100;
+   rtc_tm->tm_mon += 1;
+
+   ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MI,
+   DA9055_RTC_ALM_MIN, rtc_tm->tm_min);
+   if (ret != 0) {
+   dev_err(da9055->dev, "Failed to write ALRM MIN: %d\n", ret);
+   return ret;
+   }
+
+   v[0] = rtc_tm->tm_hour;
+   v[1] = rtc_tm->tm_mday;
+
+   ret = da9055_group_w

Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-12-12 Thread Ashish Jangam
On Wed, 2012-12-12 at 13:11 -0800, Andrew Morton wrote:
> On Mon, 10 Dec 2012 11:12:29 +0530
> Ashish Jangam  wrote:
> 
> > On Wed, 2012-11-28 at 14:54 +0530, Ashish Jangam wrote:
> > > On Tue, 2012-11-27 at 14:23 -0800, Andrew Morton wrote:
> > > > On Fri, 23 Nov 2012 15:41:03 +0530
> > > > Ashish Jangam  wrote:
> > > > 
> > > > > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > > > > Does this patch looks good?
> > > > > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > > > > This is the RTC patch for the DA9055 PMIC. This patch has got 
> > > > > > > dependency on
> > > > > > > the DA9055 MFD core.
> > > > > > > 
> > > > > > > This patch is functionally tested on Samsung SMDKV6410.
> > > > 
> > > > "shubhro " made a comment, but it was 
> > > > ignored:
> > > > 
> > > > : On Thu, 11 Oct 2012 16:53:34 +0530
> > > > : shubhro  wrote:
> > > > : 
> > > > : > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> > > > : > > +#define da9055_rtc_freeze NULL
> > > > : > > +#endif
> > > > : > > +
> > > > : > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> > > > : > > + .suspend = da9055_rtc_suspend,
> > > > : > > + .resume = da9055_rtc_resume,
> > > > : > > +
> > > > : > > + .freeze = da9055_rtc_freeze,
> > > > : > > + .thaw = da9055_rtc_resume,
> > > > : > > + .restore = da9055_rtc_resume,
> > > > : > > +
> > > > : > > + .poweroff = da9055_rtc_suspend,
> > > > : > > +};
> > > > : > You may want to use simple dev pm ops
> > > To support generic PM ops these additional ops were supported.
> > Are there any further comments on this patch.
> 
> Is the patch usable against current mainline?  "This patch has got
> dependency on the DA9055 MFD core".  What is the status of that?
The dependent DA9055 MFD core is merged.
> 
> If the patch is ready to go then please refresh it, retest and resend?
> 
Ok, I can test and resend it.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-12-12 Thread Andrew Morton
On Mon, 10 Dec 2012 11:12:29 +0530
Ashish Jangam  wrote:

> On Wed, 2012-11-28 at 14:54 +0530, Ashish Jangam wrote:
> > On Tue, 2012-11-27 at 14:23 -0800, Andrew Morton wrote:
> > > On Fri, 23 Nov 2012 15:41:03 +0530
> > > Ashish Jangam  wrote:
> > > 
> > > > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > > > Does this patch looks good?
> > > > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > > > This is the RTC patch for the DA9055 PMIC. This patch has got 
> > > > > > dependency on
> > > > > > the DA9055 MFD core.
> > > > > > 
> > > > > > This patch is functionally tested on Samsung SMDKV6410.
> > > 
> > > "shubhro " made a comment, but it was ignored:
> > > 
> > > : On Thu, 11 Oct 2012 16:53:34 +0530
> > > : shubhro  wrote:
> > > : 
> > > : > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> > > : > > +#define da9055_rtc_freeze NULL
> > > : > > +#endif
> > > : > > +
> > > : > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> > > : > > +   .suspend = da9055_rtc_suspend,
> > > : > > +   .resume = da9055_rtc_resume,
> > > : > > +
> > > : > > +   .freeze = da9055_rtc_freeze,
> > > : > > +   .thaw = da9055_rtc_resume,
> > > : > > +   .restore = da9055_rtc_resume,
> > > : > > +
> > > : > > +   .poweroff = da9055_rtc_suspend,
> > > : > > +};
> > > : > You may want to use simple dev pm ops
> > To support generic PM ops these additional ops were supported.
> Are there any further comments on this patch.

Is the patch usable against current mainline?  "This patch has got
dependency on the DA9055 MFD core".  What is the status of that?

If the patch is ready to go then please refresh it, retest and resend?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-12-09 Thread Ashish Jangam
On Wed, 2012-11-28 at 14:54 +0530, Ashish Jangam wrote:
> On Tue, 2012-11-27 at 14:23 -0800, Andrew Morton wrote:
> > On Fri, 23 Nov 2012 15:41:03 +0530
> > Ashish Jangam  wrote:
> > 
> > > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > > Does this patch looks good?
> > > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > > This is the RTC patch for the DA9055 PMIC. This patch has got 
> > > > > dependency on
> > > > > the DA9055 MFD core.
> > > > > 
> > > > > This patch is functionally tested on Samsung SMDKV6410.
> > 
> > "shubhro " made a comment, but it was ignored:
> > 
> > : On Thu, 11 Oct 2012 16:53:34 +0530
> > : shubhro  wrote:
> > : 
> > : > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> > : > > +#define da9055_rtc_freeze NULL
> > : > > +#endif
> > : > > +
> > : > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> > : > > + .suspend = da9055_rtc_suspend,
> > : > > + .resume = da9055_rtc_resume,
> > : > > +
> > : > > + .freeze = da9055_rtc_freeze,
> > : > > + .thaw = da9055_rtc_resume,
> > : > > + .restore = da9055_rtc_resume,
> > : > > +
> > : > > + .poweroff = da9055_rtc_suspend,
> > : > > +};
> > : > You may want to use simple dev pm ops
> To support generic PM ops these additional ops were supported.
Are there any further comments on this patch.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-28 Thread Ashish Jangam
On Tue, 2012-11-27 at 14:23 -0800, Andrew Morton wrote:
> On Fri, 23 Nov 2012 15:41:03 +0530
> Ashish Jangam  wrote:
> 
> > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > Does this patch looks good?
> > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > This is the RTC patch for the DA9055 PMIC. This patch has got 
> > > > dependency on
> > > > the DA9055 MFD core.
> > > > 
> > > > This patch is functionally tested on Samsung SMDKV6410.
> > > > 
> > >
> 
> (Top-posting repaired. Please don't top-post).
> 
> > Any comments on this patch.
> 
> "shubhro " made a comment, but it was ignored:
> 
> : On Thu, 11 Oct 2012 16:53:34 +0530
> : shubhro  wrote:
> : 
> : > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> : > > +#define da9055_rtc_freeze NULL
> : > > +#endif
> : > > +
> : > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> : > > +   .suspend = da9055_rtc_suspend,
> : > > +   .resume = da9055_rtc_resume,
> : > > +
> : > > +   .freeze = da9055_rtc_freeze,
> : > > +   .thaw = da9055_rtc_resume,
> : > > +   .restore = da9055_rtc_resume,
> : > > +
> : > > +   .poweroff = da9055_rtc_suspend,
> : > > +};
> : > You may want to use simple dev pm ops
> 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-28 Thread Ashish Jangam
On Tue, 2012-11-27 at 14:23 -0800, Andrew Morton wrote:
> On Fri, 23 Nov 2012 15:41:03 +0530
> Ashish Jangam  wrote:
> 
> > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > Does this patch looks good?
> > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > This is the RTC patch for the DA9055 PMIC. This patch has got 
> > > > dependency on
> > > > the DA9055 MFD core.
> > > > 
> > > > This patch is functionally tested on Samsung SMDKV6410.
> > > > 
> > >
> 
> (Top-posting repaired. Please don't top-post).
> 
> > Any comments on this patch.
> 
> "shubhro " made a comment, but it was ignored:
> 
> : On Thu, 11 Oct 2012 16:53:34 +0530
> : shubhro  wrote:
> : 
> : > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> : > > +#define da9055_rtc_freeze NULL
> : > > +#endif
> : > > +
> : > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> : > > +   .suspend = da9055_rtc_suspend,
> : > > +   .resume = da9055_rtc_resume,
> : > > +
> : > > +   .freeze = da9055_rtc_freeze,
> : > > +   .thaw = da9055_rtc_resume,
> : > > +   .restore = da9055_rtc_resume,
> : > > +
> : > > +   .poweroff = da9055_rtc_suspend,
> : > > +};
> : > You may want to use simple dev pm ops
To support generic PM ops these additional ops were supported.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-27 Thread Andrew Morton
On Fri, 23 Nov 2012 15:41:03 +0530
Ashish Jangam  wrote:

> On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > Does this patch looks good?
> > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > This is the RTC patch for the DA9055 PMIC. This patch has got dependency 
> > > on
> > > the DA9055 MFD core.
> > > 
> > > This patch is functionally tested on Samsung SMDKV6410.
> > > 
> >

(Top-posting repaired. Please don't top-post).

> Any comments on this patch.

"shubhro " made a comment, but it was ignored:

: On Thu, 11 Oct 2012 16:53:34 +0530
: shubhro  wrote:
: 
: > On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
: > > +#define da9055_rtc_freeze NULL
: > > +#endif
: > > +
: > > +static const struct dev_pm_ops da9055_rtc_pm_ops = {
: > > + .suspend = da9055_rtc_suspend,
: > > + .resume = da9055_rtc_resume,
: > > +
: > > + .freeze = da9055_rtc_freeze,
: > > + .thaw = da9055_rtc_resume,
: > > + .restore = da9055_rtc_resume,
: > > +
: > > + .poweroff = da9055_rtc_suspend,
: > > +};
: > You may want to use simple dev pm ops


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-23 Thread Ashish Jangam
On Fri, 2012-11-23 at 16:39 +0530, Venu Byravarasu wrote:
> > -Original Message-
> > From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> > ow...@vger.kernel.org] On Behalf Of Ashish Jangam
> > Sent: Friday, November 23, 2012 3:41 PM
> > To: a...@linux-foundation.org
> > Cc: linux-kernel@vger.kernel.org; sa...@linux.intel.com;
> > p_gortma...@yahoo.com; dc...@diasemi.com; rtc-
> > li...@googlegroups.com; Alessandro Zummo
> > Subject: Re: [Patch v3 3/7] rtc: DA9055 RTC driver
> > 
> > Any comments on this patch.
> > On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > > Does this patch looks good?
> > > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > > This is the RTC patch for the DA9055 PMIC. This patch has got
> > dependency on
> > > > the DA9055 MFD core.
> > > >
> > > > This patch is functionally tested on Samsung SMDKV6410.
> > > >
> > > > Signed-off-by: David Dajun Chen 
> > > > Signed-off-by: Ashish Jangam 
> > > > ---
> > > > changes since version v3:
> > > > - use of module_platform_driver macro
> > > > - add the regmap virtual irq map API.
> > > > changes since version v2:
> > > > - Use of devm_request_threaded_irq API
> > > > ---
> > > >  drivers/rtc/Kconfig  |   10 +
> > > >  drivers/rtc/Makefile |1 +
> > > >  drivers/rtc/rtc-da9055.c |  413
> > ++
> > > >  3 files changed, 424 insertions(+), 0 deletions(-)
> > > >  mode change 100644 => 100755 drivers/rtc/Kconfig
> > > >  create mode 100644 drivers/rtc/rtc-da9055.c
> > > >
> 
> > > > +static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time
> > *rtc_tm)
> > > > +{
> > > > +   int ret;
> > > > +   uint8_t v[2];
> > > > +
> > > > +   rtc_tm->tm_year -= 100;
> > > > +   rtc_tm->tm_mon += 1;
> > > > +
> > > > +   ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MI,
> > > > +   DA9055_RTC_ALM_MIN, rtc_tm->tm_min);
> > > > +   if (ret != 0) {
> > > > +   dev_err(da9055->dev, "Failed to write ALRM MIN: %d\n",
> > ret);
> > > > +   return ret;
> > > > +   }
> > > > +
> > > > +   v[0] = rtc_tm->tm_hour;
> > > > +   v[1] = rtc_tm->tm_mday;
> > > > +
> > > > +   ret = da9055_group_write(da9055, DA9055_REG_ALARM_H, 2, v);
> 
> Why don't you write all registers at once using single multi byte
> write command as you already used in da9055_rtc_set_time() ?
Unlike TIME/Date registers some of the ALARM register bits has got few
other bits which should not get modified during the setting of ALARM
therefore reg_update was used for those ALARM register.   


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-23 Thread Venu Byravarasu
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Ashish Jangam
> Sent: Friday, November 23, 2012 3:41 PM
> To: a...@linux-foundation.org
> Cc: linux-kernel@vger.kernel.org; sa...@linux.intel.com;
> p_gortma...@yahoo.com; dc...@diasemi.com; rtc-
> li...@googlegroups.com; Alessandro Zummo
> Subject: Re: [Patch v3 3/7] rtc: DA9055 RTC driver
> 
> Any comments on this patch.
> On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> > Does this patch looks good?
> > On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > > This is the RTC patch for the DA9055 PMIC. This patch has got
> dependency on
> > > the DA9055 MFD core.
> > >
> > > This patch is functionally tested on Samsung SMDKV6410.
> > >
> > > Signed-off-by: David Dajun Chen 
> > > Signed-off-by: Ashish Jangam 
> > > ---
> > > changes since version v3:
> > > - use of module_platform_driver macro
> > > - add the regmap virtual irq map API.
> > > changes since version v2:
> > > - Use of devm_request_threaded_irq API
> > > ---
> > >  drivers/rtc/Kconfig  |   10 +
> > >  drivers/rtc/Makefile |1 +
> > >  drivers/rtc/rtc-da9055.c |  413
> ++
> > >  3 files changed, 424 insertions(+), 0 deletions(-)
> > >  mode change 100644 => 100755 drivers/rtc/Kconfig
> > >  create mode 100644 drivers/rtc/rtc-da9055.c
> > >

> > > +static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time
> *rtc_tm)
> > > +{
> > > + int ret;
> > > + uint8_t v[2];
> > > +
> > > + rtc_tm->tm_year -= 100;
> > > + rtc_tm->tm_mon += 1;
> > > +
> > > + ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MI,
> > > + DA9055_RTC_ALM_MIN, rtc_tm->tm_min);
> > > + if (ret != 0) {
> > > + dev_err(da9055->dev, "Failed to write ALRM MIN: %d\n",
> ret);
> > > + return ret;
> > > + }
> > > +
> > > + v[0] = rtc_tm->tm_hour;
> > > + v[1] = rtc_tm->tm_mday;
> > > +
> > > + ret = da9055_group_write(da9055, DA9055_REG_ALARM_H, 2, v);

Why don't you write all registers at once using single multi byte
write command as you already used in da9055_rtc_set_time() ?

> > > + if (ret < 0)
> > > + return ret;
> > > +
> > > + ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MO,
> > > + DA9055_RTC_ALM_MONTH, rtc_tm-
> >tm_mon);
> > > + if (ret < 0)
> > > + dev_err(da9055->dev, "Failed to write ALM Month:%d\n",
> ret);

> > > +
> > > +static int da9055_rtc_set_time(struct device *dev, struct rtc_time *tm)
> > > +{
> > > + struct da9055_rtc *rtc;
> > > + uint8_t v[6];
> > > +
> > > + rtc = dev_get_drvdata(dev);
> > > +
> > > + v[0] = tm->tm_sec;
> > > + v[1] = tm->tm_min;
> > > + v[2] = tm->tm_hour;
> > > + v[3] = tm->tm_mday;
> > > + v[4] = tm->tm_mon + 1;
> > > + v[5] = tm->tm_year - 100;
> > > +
> > > + return da9055_group_write(rtc->da9055, DA9055_REG_COUNT_S, 6,
> v);
> > > +}
> > > +
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [Patch v3 3/7] rtc: DA9055 RTC driver

2012-11-23 Thread Ashish Jangam
Any comments on this patch.
On Tue, 2012-10-23 at 15:33 +0530, Ashish Jangam wrote:
> Does this patch looks good?
> On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> > This is the RTC patch for the DA9055 PMIC. This patch has got dependency on
> > the DA9055 MFD core.
> > 
> > This patch is functionally tested on Samsung SMDKV6410.
> > 
> > Signed-off-by: David Dajun Chen 
> > Signed-off-by: Ashish Jangam 
> > ---
> > changes since version v3:
> > - use of module_platform_driver macro
> > - add the regmap virtual irq map API.
> > changes since version v2:
> > - Use of devm_request_threaded_irq API
> > ---
> >  drivers/rtc/Kconfig  |   10 +
> >  drivers/rtc/Makefile |1 +
> >  drivers/rtc/rtc-da9055.c |  413 
> > ++
> >  3 files changed, 424 insertions(+), 0 deletions(-)
> >  mode change 100644 => 100755 drivers/rtc/Kconfig
> >  create mode 100644 drivers/rtc/rtc-da9055.c
> > 
> > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> > old mode 100644
> > new mode 100755
> > index fabc99a..6050f8b
> > --- a/drivers/rtc/Kconfig
> > +++ b/drivers/rtc/Kconfig
> > @@ -571,6 +571,16 @@ config RTC_DRV_DA9052
> >   Say y here to support the RTC driver for Dialog Semiconductor
> >   DA9052-BC and DA9053-AA/Bx PMICs.
> >  
> > +config RTC_DRV_DA9055
> > +   tristate "Dialog Semiconductor DA9055 RTC"
> > +   depends on MFD_DA9055
> > +   help
> > + If you say yes here you will get support for the
> > + RTC of the Dialog DA9055 PMIC.
> > +
> > + This driver can also be built as a module. If so, the module
> > + will be called rtc-da9055
> > +
> >  config RTC_DRV_EFI
> > tristate "EFI RTC"
> > depends on IA64
> > diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> > index 0d5b2b6..b4c162f 100644
> > --- a/drivers/rtc/Makefile
> > +++ b/drivers/rtc/Makefile
> > @@ -29,6 +29,7 @@ obj-$(CONFIG_RTC_DRV_BQ4802)  += rtc-bq4802.o
> >  obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
> >  obj-$(CONFIG_RTC_DRV_COH901331)+= rtc-coh901331.o
> >  obj-$(CONFIG_RTC_DRV_DA9052)   += rtc-da9052.o
> > +obj-$(CONFIG_RTC_DRV_DA9055)   += rtc-da9055.o
> >  obj-$(CONFIG_RTC_DRV_DAVINCI)  += rtc-davinci.o
> >  obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
> >  obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
> > diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c
> > new file mode 100644
> > index 000..2304647
> > --- /dev/null
> > +++ b/drivers/rtc/rtc-da9055.c
> > @@ -0,0 +1,413 @@
> > +/*
> > + * Real time clock driver for DA9055
> > + *
> > + * Copyright(c) 2012 Dialog Semiconductor Ltd.
> > + *
> > + * Author: Dajun Dajun Chen 
> > + *
> > + * 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.
> > + *
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct da9055_rtc {
> > +   struct rtc_device *rtc;
> > +   struct da9055 *da9055;
> > +   int alarm_enable;
> > +};
> > +
> > +static int da9055_rtc_enable_alarm(struct da9055_rtc *rtc, bool enable)
> > +{
> > +   int ret;
> > +   if (enable) {
> > +   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
> > +   DA9055_RTC_ALM_EN,
> > +   DA9055_RTC_ALM_EN);
> > +   if (ret != 0)
> > +   dev_err(rtc->da9055->dev, "Failed to enable ALM: %d\n",
> > +   ret);
> > +   rtc->alarm_enable = 1;
> > +   } else {
> > +   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
> > +   DA9055_RTC_ALM_EN, 0);
> > +   if (ret != 0)
> > +   dev_err(rtc->da9055->dev,
> > +   "Failed to disable ALM: %d\n", ret);
> > +   rtc->alarm_enable = 0;
> > +   }
> > +   return ret;
> > +}
> > +
> > +static irqreturn_t da9055_rtc_alm_irq(int irq, void *data)
> > +{
> > +   struct da9055_rtc *rtc = data;
> > +
> > +   da9055_rtc_enable_alarm(rtc, 0);
> > +   rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
> > +
> > +   return IRQ_HANDLED;
> > +}
> > +
> > +static int da9055_read_alarm(struct da9055 *da9055, struct rtc_time 
> > *rtc_tm)
> > +{
> > +   int ret;
> > +   uint8_t v[5];
> > +
> > +   ret = da9055_group_read(da9055, DA9055_REG_ALARM_MI, 5, v);
> > +   if (ret != 0) {
> > +   dev_err(da9055->dev, "Failed to group read ALM: %d\n", ret);
> > +   return ret;
> > +   }
> > +
> > +   rtc_tm->tm_year = (v[4] & DA9055_RTC_ALM_YEAR) + 100;
> > +   rtc_tm->tm_mon  = (v[3] & DA9055_RTC_ALM_MONTH) - 1;
> > +   rtc_tm->tm_mday = v[2] & DA9055_RTC_ALM_DAY;
> > +   rtc_tm->tm_hour = v[1] & DA9055_RTC_ALM_HOUR;
> > +   rtc_tm->tm_min  = v[0] & DA9055_RTC_ALM_MIN;
> > +
> 

Re: [Patch v3 3/7] RTC: DA9055 RTC driver

2012-10-23 Thread Ashish Jangam
Does this patch looks good?
On Thu, 2012-10-11 at 16:10 +0530, Ashish Jangam wrote:
> This is the RTC patch for the DA9055 PMIC. This patch has got dependency on
> the DA9055 MFD core.
> 
> This patch is functionally tested on Samsung SMDKV6410.
> 
> Signed-off-by: David Dajun Chen 
> Signed-off-by: Ashish Jangam 
> ---
> changes since version v3:
> - use of module_platform_driver macro
> - add the regmap virtual irq map API.
> changes since version v2:
> - Use of devm_request_threaded_irq API
> ---
>  drivers/rtc/Kconfig  |   10 +
>  drivers/rtc/Makefile |1 +
>  drivers/rtc/rtc-da9055.c |  413 
> ++
>  3 files changed, 424 insertions(+), 0 deletions(-)
>  mode change 100644 => 100755 drivers/rtc/Kconfig
>  create mode 100644 drivers/rtc/rtc-da9055.c
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> old mode 100644
> new mode 100755
> index fabc99a..6050f8b
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -571,6 +571,16 @@ config RTC_DRV_DA9052
> Say y here to support the RTC driver for Dialog Semiconductor
> DA9052-BC and DA9053-AA/Bx PMICs.
>  
> +config RTC_DRV_DA9055
> + tristate "Dialog Semiconductor DA9055 RTC"
> + depends on MFD_DA9055
> + help
> +   If you say yes here you will get support for the
> +   RTC of the Dialog DA9055 PMIC.
> +
> +   This driver can also be built as a module. If so, the module
> +   will be called rtc-da9055
> +
>  config RTC_DRV_EFI
>   tristate "EFI RTC"
>   depends on IA64
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 0d5b2b6..b4c162f 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -29,6 +29,7 @@ obj-$(CONFIG_RTC_DRV_BQ4802)+= rtc-bq4802.o
>  obj-$(CONFIG_RTC_DRV_CMOS)   += rtc-cmos.o
>  obj-$(CONFIG_RTC_DRV_COH901331)  += rtc-coh901331.o
>  obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o
> +obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o
>  obj-$(CONFIG_RTC_DRV_DAVINCI)+= rtc-davinci.o
>  obj-$(CONFIG_RTC_DRV_DM355EVM)   += rtc-dm355evm.o
>  obj-$(CONFIG_RTC_DRV_VRTC)   += rtc-mrst.o
> diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c
> new file mode 100644
> index 000..2304647
> --- /dev/null
> +++ b/drivers/rtc/rtc-da9055.c
> @@ -0,0 +1,413 @@
> +/*
> + * Real time clock driver for DA9055
> + *
> + * Copyright(c) 2012 Dialog Semiconductor Ltd.
> + *
> + * Author: Dajun Dajun Chen 
> + *
> + * 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.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +struct da9055_rtc {
> + struct rtc_device *rtc;
> + struct da9055 *da9055;
> + int alarm_enable;
> +};
> +
> +static int da9055_rtc_enable_alarm(struct da9055_rtc *rtc, bool enable)
> +{
> + int ret;
> + if (enable) {
> + ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
> + DA9055_RTC_ALM_EN,
> + DA9055_RTC_ALM_EN);
> + if (ret != 0)
> + dev_err(rtc->da9055->dev, "Failed to enable ALM: %d\n",
> + ret);
> + rtc->alarm_enable = 1;
> + } else {
> + ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
> + DA9055_RTC_ALM_EN, 0);
> + if (ret != 0)
> + dev_err(rtc->da9055->dev,
> + "Failed to disable ALM: %d\n", ret);
> + rtc->alarm_enable = 0;
> + }
> + return ret;
> +}
> +
> +static irqreturn_t da9055_rtc_alm_irq(int irq, void *data)
> +{
> + struct da9055_rtc *rtc = data;
> +
> + da9055_rtc_enable_alarm(rtc, 0);
> + rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int da9055_read_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
> +{
> + int ret;
> + uint8_t v[5];
> +
> + ret = da9055_group_read(da9055, DA9055_REG_ALARM_MI, 5, v);
> + if (ret != 0) {
> + dev_err(da9055->dev, "Failed to group read ALM: %d\n", ret);
> + return ret;
> + }
> +
> + rtc_tm->tm_year = (v[4] & DA9055_RTC_ALM_YEAR) + 100;
> + rtc_tm->tm_mon  = (v[3] & DA9055_RTC_ALM_MONTH) - 1;
> + rtc_tm->tm_mday = v[2] & DA9055_RTC_ALM_DAY;
> + rtc_tm->tm_hour = v[1] & DA9055_RTC_ALM_HOUR;
> + rtc_tm->tm_min  = v[0] & DA9055_RTC_ALM_MIN;
> +
> + return rtc_valid_tm(rtc_tm);
> +}
> +
> +static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
> +{
> + int ret;
> + uint8_t v[2];
> +
> + rtc_tm->tm_year -= 100;
> + rtc_tm->tm_mon += 1;
> +
> + ret = da9055_reg_update(da9055, D

Re: [Patch v3 3/7] RTC: DA9055 RTC driver

2012-10-11 Thread shubhro
On Thursday 11 October 2012 04:10 PM, Ashish Jangam wrote:
> +#define da9055_rtc_freeze NULL
> +#endif
> +
> +static const struct dev_pm_ops da9055_rtc_pm_ops = {
> + .suspend = da9055_rtc_suspend,
> + .resume = da9055_rtc_resume,
> +
> + .freeze = da9055_rtc_freeze,
> + .thaw = da9055_rtc_resume,
> + .restore = da9055_rtc_resume,
> +
> + .poweroff = da9055_rtc_suspend,
> +};
You may want to use simple dev pm ops
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Patch v3 3/7] RTC: DA9055 RTC driver

2012-10-11 Thread Ashish Jangam
This is the RTC patch for the DA9055 PMIC. This patch has got dependency on
the DA9055 MFD core.

This patch is functionally tested on Samsung SMDKV6410.

Signed-off-by: David Dajun Chen 
Signed-off-by: Ashish Jangam 
---
changes since version v3:
- use of module_platform_driver macro
- add the regmap virtual irq map API.
changes since version v2:
- Use of devm_request_threaded_irq API
---
 drivers/rtc/Kconfig  |   10 +
 drivers/rtc/Makefile |1 +
 drivers/rtc/rtc-da9055.c |  413 ++
 3 files changed, 424 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 drivers/rtc/Kconfig
 create mode 100644 drivers/rtc/rtc-da9055.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
old mode 100644
new mode 100755
index fabc99a..6050f8b
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -571,6 +571,16 @@ config RTC_DRV_DA9052
  Say y here to support the RTC driver for Dialog Semiconductor
  DA9052-BC and DA9053-AA/Bx PMICs.
 
+config RTC_DRV_DA9055
+   tristate "Dialog Semiconductor DA9055 RTC"
+   depends on MFD_DA9055
+   help
+ If you say yes here you will get support for the
+ RTC of the Dialog DA9055 PMIC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-da9055
+
 config RTC_DRV_EFI
tristate "EFI RTC"
depends on IA64
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 0d5b2b6..b4c162f 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_RTC_DRV_BQ4802)  += rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)+= rtc-coh901331.o
 obj-$(CONFIG_RTC_DRV_DA9052)   += rtc-da9052.o
+obj-$(CONFIG_RTC_DRV_DA9055)   += rtc-da9055.o
 obj-$(CONFIG_RTC_DRV_DAVINCI)  += rtc-davinci.o
 obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
 obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c
new file mode 100644
index 000..2304647
--- /dev/null
+++ b/drivers/rtc/rtc-da9055.c
@@ -0,0 +1,413 @@
+/*
+ * Real time clock driver for DA9055
+ *
+ * Copyright(c) 2012 Dialog Semiconductor Ltd.
+ *
+ * Author: Dajun Dajun Chen 
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct da9055_rtc {
+   struct rtc_device *rtc;
+   struct da9055 *da9055;
+   int alarm_enable;
+};
+
+static int da9055_rtc_enable_alarm(struct da9055_rtc *rtc, bool enable)
+{
+   int ret;
+   if (enable) {
+   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
+   DA9055_RTC_ALM_EN,
+   DA9055_RTC_ALM_EN);
+   if (ret != 0)
+   dev_err(rtc->da9055->dev, "Failed to enable ALM: %d\n",
+   ret);
+   rtc->alarm_enable = 1;
+   } else {
+   ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
+   DA9055_RTC_ALM_EN, 0);
+   if (ret != 0)
+   dev_err(rtc->da9055->dev,
+   "Failed to disable ALM: %d\n", ret);
+   rtc->alarm_enable = 0;
+   }
+   return ret;
+}
+
+static irqreturn_t da9055_rtc_alm_irq(int irq, void *data)
+{
+   struct da9055_rtc *rtc = data;
+
+   da9055_rtc_enable_alarm(rtc, 0);
+   rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
+
+   return IRQ_HANDLED;
+}
+
+static int da9055_read_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
+{
+   int ret;
+   uint8_t v[5];
+
+   ret = da9055_group_read(da9055, DA9055_REG_ALARM_MI, 5, v);
+   if (ret != 0) {
+   dev_err(da9055->dev, "Failed to group read ALM: %d\n", ret);
+   return ret;
+   }
+
+   rtc_tm->tm_year = (v[4] & DA9055_RTC_ALM_YEAR) + 100;
+   rtc_tm->tm_mon  = (v[3] & DA9055_RTC_ALM_MONTH) - 1;
+   rtc_tm->tm_mday = v[2] & DA9055_RTC_ALM_DAY;
+   rtc_tm->tm_hour = v[1] & DA9055_RTC_ALM_HOUR;
+   rtc_tm->tm_min  = v[0] & DA9055_RTC_ALM_MIN;
+
+   return rtc_valid_tm(rtc_tm);
+}
+
+static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
+{
+   int ret;
+   uint8_t v[2];
+
+   rtc_tm->tm_year -= 100;
+   rtc_tm->tm_mon += 1;
+
+   ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MI,
+   DA9055_RTC_ALM_MIN, rtc_tm->tm_min);
+   if (ret != 0) {
+   dev_err(da9055->dev, "Failed to write ALRM MIN: %d\n", ret);
+   return ret;
+   }
+
+   v[0] = rtc_tm->tm_hour;
+   v[1] = rtc_tm->tm_m