Re: [PATCH] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-24 Thread Lee Jones
On Tue, 23 Sep 2014, Stanimir Varbanov wrote:

> Hi Paul,
> 
> On 09/23/2014 11:50 AM, Paul Bolle wrote:
> > Hi Stanimar,
> > 
> > On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
> >> Adds support for RTC device inside PM8941 PMIC. The RTC
> >> in this PMIC have two register spaces. Thus the rtc-pm8xxx
> >> is slightly reworked to reflect these differences.
> >>
> >> The register set for different PMIC chips are selected
> >> on DT compatible string base.
> >>
> >> Signed-off-by: Stanimir Varbanov 
> > 
> > This patch just landed in next-20140923 as commit 99abd227988a
> > ("drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc").
> > 
> >> --- a/drivers/rtc/Kconfig
> >> +++ b/drivers/rtc/Kconfig
> >> @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
> >>  
> >>  config RTC_DRV_PM8XXX
> >>tristate "Qualcomm PMIC8XXX RTC"
> >> -  depends on MFD_PM8XXX
> >> +  depends on MFD_PM8XXX || MFD_SPMI_PMIC
> > 
> > There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
> > it's currently queued somewhere. Is that correct?
> 
> The MFD driver which adds MFD_SPMI_PMIC symbol is still pending in the
> mailing list. I will ask Lee Jones to add it to the MFD queue for 3.18.

MFD_SPMI_PMIC has now been merged.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-24 Thread Lee Jones
On Tue, 23 Sep 2014, Stanimir Varbanov wrote:

 Hi Paul,
 
 On 09/23/2014 11:50 AM, Paul Bolle wrote:
  Hi Stanimar,
  
  On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
  Adds support for RTC device inside PM8941 PMIC. The RTC
  in this PMIC have two register spaces. Thus the rtc-pm8xxx
  is slightly reworked to reflect these differences.
 
  The register set for different PMIC chips are selected
  on DT compatible string base.
 
  Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
  
  This patch just landed in next-20140923 as commit 99abd227988a
  (drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc).
  
  --- a/drivers/rtc/Kconfig
  +++ b/drivers/rtc/Kconfig
  @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
   
   config RTC_DRV_PM8XXX
 tristate Qualcomm PMIC8XXX RTC
  -  depends on MFD_PM8XXX
  +  depends on MFD_PM8XXX || MFD_SPMI_PMIC
  
  There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
  it's currently queued somewhere. Is that correct?
 
 The MFD driver which adds MFD_SPMI_PMIC symbol is still pending in the
 mailing list. I will ask Lee Jones to add it to the MFD queue for 3.18.

MFD_SPMI_PMIC has now been merged.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Stanimir Varbanov
Hi Paul,

On 09/23/2014 11:50 AM, Paul Bolle wrote:
> Hi Stanimar,
> 
> On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
>> Adds support for RTC device inside PM8941 PMIC. The RTC
>> in this PMIC have two register spaces. Thus the rtc-pm8xxx
>> is slightly reworked to reflect these differences.
>>
>> The register set for different PMIC chips are selected
>> on DT compatible string base.
>>
>> Signed-off-by: Stanimir Varbanov 
> 
> This patch just landed in next-20140923 as commit 99abd227988a
> ("drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc").
> 
>> --- a/drivers/rtc/Kconfig
>> +++ b/drivers/rtc/Kconfig
>> @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
>>  
>>  config RTC_DRV_PM8XXX
>>  tristate "Qualcomm PMIC8XXX RTC"
>> -depends on MFD_PM8XXX
>> +depends on MFD_PM8XXX || MFD_SPMI_PMIC
> 
> There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
> it's currently queued somewhere. Is that correct?

The MFD driver which adds MFD_SPMI_PMIC symbol is still pending in the
mailing list. I will ask Lee Jones to add it to the MFD queue for 3.18.

-- 
regards,
Stan
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Stanimir Varbanov
On 09/20/2014 02:03 AM, Andrew Morton wrote:
> On Fri, 12 Sep 2014 12:44:04 +0300 Stanimir Varbanov  
> wrote:
> 
>> Adds support for RTC device inside PM8941 PMIC. The RTC
>> in this PMIC have two register spaces. Thus the rtc-pm8xxx
>> is slightly reworked to reflect these differences.
>>
>> The register set for different PMIC chips are selected
>> on DT compatible string base.
> 
> checkpatch (which you obviously didn't use!) says
> 
> WARNING: DT compatible string "qcom,pm8941-rtc" appears un-documented -- 
> check ./Documentation/devicetree/bindings/
> #414: FILE: drivers/rtc/rtc-pm8xxx.c:435:
> +   { .compatible = "qcom,pm8941-rtc", .data = _regs },

Ahh, sorry for inconvenience I forgot to run checkpatch over this patch.

I will send follow-up patch which will add the compatible string in the
pm8xxx binding document.

-- 
regards,
Stan
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Paul Bolle
Hi Stanimar,

On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
> Adds support for RTC device inside PM8941 PMIC. The RTC
> in this PMIC have two register spaces. Thus the rtc-pm8xxx
> is slightly reworked to reflect these differences.
> 
> The register set for different PMIC chips are selected
> on DT compatible string base.
> 
> Signed-off-by: Stanimir Varbanov 

This patch just landed in next-20140923 as commit 99abd227988a
("drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc").

> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
>  
>  config RTC_DRV_PM8XXX
>   tristate "Qualcomm PMIC8XXX RTC"
> - depends on MFD_PM8XXX
> + depends on MFD_PM8XXX || MFD_SPMI_PMIC

There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
it's currently queued somewhere. Is that correct?

>   help
> If you say yes here you get support for the
> Qualcomm PMIC8XXX RTC.

Thanks,


Paul Bolle

--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Paul Bolle
Hi Stanimar,

On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
 Adds support for RTC device inside PM8941 PMIC. The RTC
 in this PMIC have two register spaces. Thus the rtc-pm8xxx
 is slightly reworked to reflect these differences.
 
 The register set for different PMIC chips are selected
 on DT compatible string base.
 
 Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com

This patch just landed in next-20140923 as commit 99abd227988a
(drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc).

 --- a/drivers/rtc/Kconfig
 +++ b/drivers/rtc/Kconfig
 @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
  
  config RTC_DRV_PM8XXX
   tristate Qualcomm PMIC8XXX RTC
 - depends on MFD_PM8XXX
 + depends on MFD_PM8XXX || MFD_SPMI_PMIC

There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
it's currently queued somewhere. Is that correct?

   help
 If you say yes here you get support for the
 Qualcomm PMIC8XXX RTC.

Thanks,


Paul Bolle

--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Stanimir Varbanov
On 09/20/2014 02:03 AM, Andrew Morton wrote:
 On Fri, 12 Sep 2014 12:44:04 +0300 Stanimir Varbanov svarba...@mm-sol.com 
 wrote:
 
 Adds support for RTC device inside PM8941 PMIC. The RTC
 in this PMIC have two register spaces. Thus the rtc-pm8xxx
 is slightly reworked to reflect these differences.

 The register set for different PMIC chips are selected
 on DT compatible string base.
 
 checkpatch (which you obviously didn't use!) says
 
 WARNING: DT compatible string qcom,pm8941-rtc appears un-documented -- 
 check ./Documentation/devicetree/bindings/
 #414: FILE: drivers/rtc/rtc-pm8xxx.c:435:
 +   { .compatible = qcom,pm8941-rtc, .data = pm8941_regs },

Ahh, sorry for inconvenience I forgot to run checkpatch over this patch.

I will send follow-up patch which will add the compatible string in the
pm8xxx binding document.

-- 
regards,
Stan
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-23 Thread Stanimir Varbanov
Hi Paul,

On 09/23/2014 11:50 AM, Paul Bolle wrote:
 Hi Stanimar,
 
 On Fri, 2014-09-12 at 12:44 +0300, Stanimir Varbanov wrote:
 Adds support for RTC device inside PM8941 PMIC. The RTC
 in this PMIC have two register spaces. Thus the rtc-pm8xxx
 is slightly reworked to reflect these differences.

 The register set for different PMIC chips are selected
 on DT compatible string base.

 Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
 
 This patch just landed in next-20140923 as commit 99abd227988a
 (drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc).
 
 --- a/drivers/rtc/Kconfig
 +++ b/drivers/rtc/Kconfig
 @@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
  
  config RTC_DRV_PM8XXX
  tristate Qualcomm PMIC8XXX RTC
 -depends on MFD_PM8XXX
 +depends on MFD_PM8XXX || MFD_SPMI_PMIC
 
 There's currently no Kconfig symbol MFD_SPMI_PMIC in linux-next. I guess
 it's currently queued somewhere. Is that correct?

The MFD driver which adds MFD_SPMI_PMIC symbol is still pending in the
mailing list. I will ask Lee Jones to add it to the MFD queue for 3.18.

-- 
regards,
Stan
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-19 Thread Andrew Morton
On Fri, 12 Sep 2014 12:44:04 +0300 Stanimir Varbanov  
wrote:

> Adds support for RTC device inside PM8941 PMIC. The RTC
> in this PMIC have two register spaces. Thus the rtc-pm8xxx
> is slightly reworked to reflect these differences.
> 
> The register set for different PMIC chips are selected
> on DT compatible string base.

checkpatch (which you obviously didn't use!) says

WARNING: DT compatible string "qcom,pm8941-rtc" appears un-documented -- check 
./Documentation/devicetree/bindings/
#414: FILE: drivers/rtc/rtc-pm8xxx.c:435:
+   { .compatible = "qcom,pm8941-rtc", .data = _regs },
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-19 Thread Andrew Morton
On Fri, 12 Sep 2014 12:44:04 +0300 Stanimir Varbanov svarba...@mm-sol.com 
wrote:

 Adds support for RTC device inside PM8941 PMIC. The RTC
 in this PMIC have two register spaces. Thus the rtc-pm8xxx
 is slightly reworked to reflect these differences.
 
 The register set for different PMIC chips are selected
 on DT compatible string base.

checkpatch (which you obviously didn't use!) says

WARNING: DT compatible string qcom,pm8941-rtc appears un-documented -- check 
./Documentation/devicetree/bindings/
#414: FILE: drivers/rtc/rtc-pm8xxx.c:435:
+   { .compatible = qcom,pm8941-rtc, .data = pm8941_regs },
--
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] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-12 Thread Stanimir Varbanov
Adds support for RTC device inside PM8941 PMIC. The RTC
in this PMIC have two register spaces. Thus the rtc-pm8xxx
is slightly reworked to reflect these differences.

The register set for different PMIC chips are selected
on DT compatible string base.

Signed-off-by: Stanimir Varbanov 
---
 drivers/rtc/Kconfig  |2 +-
 drivers/rtc/rtc-pm8xxx.c |  217 --
 2 files changed, 134 insertions(+), 85 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index a168e96..7dd323c 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
 
 config RTC_DRV_PM8XXX
tristate "Qualcomm PMIC8XXX RTC"
-   depends on MFD_PM8XXX
+   depends on MFD_PM8XXX || MFD_SPMI_PMIC
help
  If you say yes here you get support for the
  Qualcomm PMIC8XXX RTC.
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 197699f..c30e9d9 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -27,21 +27,36 @@
 
 /* RTC_CTRL register bit fields */
 #define PM8xxx_RTC_ENABLE  BIT(7)
-#define PM8xxx_RTC_ALARM_ENABLEBIT(1)
 #define PM8xxx_RTC_ALARM_CLEAR BIT(0)
 
 #define NUM_8_BIT_RTC_REGS 0x4
 
 /**
+ * struct pm8xxx_rtc_regs - describe RTC registers per PMIC versions
+ * @ctrl: base address of control register
+ * @write: base address of write register
+ * @read: base address of read register
+ * @alarm_ctrl: base address of alarm control register
+ * @alarm_ctrl2: base address of alarm control2 register
+ * @alarm_rw: base address of alarm read-write register
+ * @alarm_en: alarm enable mask
+ */
+struct pm8xxx_rtc_regs {
+   unsigned int ctrl;
+   unsigned int write;
+   unsigned int read;
+   unsigned int alarm_ctrl;
+   unsigned int alarm_ctrl2;
+   unsigned int alarm_rw;
+   unsigned int alarm_en;
+};
+
+/**
  * struct pm8xxx_rtc -  rtc driver internal structure
  * @rtc:   rtc device for this driver.
  * @regmap:regmap used to access RTC registers
  * @allow_set_time:indicates whether writing to the RTC is allowed
  * @rtc_alarm_irq: rtc alarm irq number.
- * @rtc_base:  address of rtc control register.
- * @rtc_read_base: base address of read registers.
- * @rtc_write_base:base address of write registers.
- * @alarm_rw_base: base address of alarm registers.
  * @ctrl_reg:  rtc control register.
  * @rtc_dev:   device structure.
  * @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
@@ -51,11 +66,7 @@ struct pm8xxx_rtc {
struct regmap *regmap;
bool allow_set_time;
int rtc_alarm_irq;
-   int rtc_base;
-   int rtc_read_base;
-   int rtc_write_base;
-   int alarm_rw_base;
-   u8 ctrl_reg;
+   const struct pm8xxx_rtc_regs *regs;
struct device *rtc_dev;
spinlock_t ctrl_reg_lock;
 };
@@ -71,8 +82,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 {
int rc, i;
unsigned long secs, irq_flags;
-   u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, ctrl_reg;
+   u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
+   unsigned int ctrl_reg;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
+   const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
 
if (!rtc_dd->allow_set_time)
return -EACCES;
@@ -87,30 +100,32 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
 
spin_lock_irqsave(_dd->ctrl_reg_lock, irq_flags);
-   ctrl_reg = rtc_dd->ctrl_reg;
 
-   if (ctrl_reg & PM8xxx_RTC_ALARM_ENABLE) {
+   rc = regmap_read(rtc_dd->regmap, regs->ctrl, _reg);
+   if (rc)
+   goto rtc_rw_fail;
+
+   if (ctrl_reg & regs->alarm_en) {
alarm_enabled = 1;
-   ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE;
-   rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg);
+   ctrl_reg &= ~regs->alarm_en;
+   rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
if (rc) {
dev_err(dev, "Write to RTC control register failed\n");
goto rtc_rw_fail;
}
-   rtc_dd->ctrl_reg = ctrl_reg;
} else {
spin_unlock_irqrestore(_dd->ctrl_reg_lock, irq_flags);
}
 
/* Write 0 to Byte[0] */
-   rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_write_base, 0);
+   rc = regmap_write(rtc_dd->regmap, regs->write, 0);
if (rc) {
dev_err(dev, "Write to RTC write data register failed\n");
goto rtc_rw_fail;
}
 
/* Write Byte[1], Byte[2], Byte[3] */
-   rc = regmap_bulk_write(rtc_dd->regmap, rtc_dd->rtc_write_base + 1,
+   rc = 

[PATCH] rtc: pm8xxx: rework to support pm8941 rtc

2014-09-12 Thread Stanimir Varbanov
Adds support for RTC device inside PM8941 PMIC. The RTC
in this PMIC have two register spaces. Thus the rtc-pm8xxx
is slightly reworked to reflect these differences.

The register set for different PMIC chips are selected
on DT compatible string base.

Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
---
 drivers/rtc/Kconfig  |2 +-
 drivers/rtc/rtc-pm8xxx.c |  217 --
 2 files changed, 134 insertions(+), 85 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index a168e96..7dd323c 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1283,7 +1283,7 @@ config RTC_DRV_LPC32XX
 
 config RTC_DRV_PM8XXX
tristate Qualcomm PMIC8XXX RTC
-   depends on MFD_PM8XXX
+   depends on MFD_PM8XXX || MFD_SPMI_PMIC
help
  If you say yes here you get support for the
  Qualcomm PMIC8XXX RTC.
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 197699f..c30e9d9 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -27,21 +27,36 @@
 
 /* RTC_CTRL register bit fields */
 #define PM8xxx_RTC_ENABLE  BIT(7)
-#define PM8xxx_RTC_ALARM_ENABLEBIT(1)
 #define PM8xxx_RTC_ALARM_CLEAR BIT(0)
 
 #define NUM_8_BIT_RTC_REGS 0x4
 
 /**
+ * struct pm8xxx_rtc_regs - describe RTC registers per PMIC versions
+ * @ctrl: base address of control register
+ * @write: base address of write register
+ * @read: base address of read register
+ * @alarm_ctrl: base address of alarm control register
+ * @alarm_ctrl2: base address of alarm control2 register
+ * @alarm_rw: base address of alarm read-write register
+ * @alarm_en: alarm enable mask
+ */
+struct pm8xxx_rtc_regs {
+   unsigned int ctrl;
+   unsigned int write;
+   unsigned int read;
+   unsigned int alarm_ctrl;
+   unsigned int alarm_ctrl2;
+   unsigned int alarm_rw;
+   unsigned int alarm_en;
+};
+
+/**
  * struct pm8xxx_rtc -  rtc driver internal structure
  * @rtc:   rtc device for this driver.
  * @regmap:regmap used to access RTC registers
  * @allow_set_time:indicates whether writing to the RTC is allowed
  * @rtc_alarm_irq: rtc alarm irq number.
- * @rtc_base:  address of rtc control register.
- * @rtc_read_base: base address of read registers.
- * @rtc_write_base:base address of write registers.
- * @alarm_rw_base: base address of alarm registers.
  * @ctrl_reg:  rtc control register.
  * @rtc_dev:   device structure.
  * @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
@@ -51,11 +66,7 @@ struct pm8xxx_rtc {
struct regmap *regmap;
bool allow_set_time;
int rtc_alarm_irq;
-   int rtc_base;
-   int rtc_read_base;
-   int rtc_write_base;
-   int alarm_rw_base;
-   u8 ctrl_reg;
+   const struct pm8xxx_rtc_regs *regs;
struct device *rtc_dev;
spinlock_t ctrl_reg_lock;
 };
@@ -71,8 +82,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 {
int rc, i;
unsigned long secs, irq_flags;
-   u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, ctrl_reg;
+   u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
+   unsigned int ctrl_reg;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
+   const struct pm8xxx_rtc_regs *regs = rtc_dd-regs;
 
if (!rtc_dd-allow_set_time)
return -EACCES;
@@ -87,30 +100,32 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
dev_dbg(dev, Seconds value to be written to RTC = %lu\n, secs);
 
spin_lock_irqsave(rtc_dd-ctrl_reg_lock, irq_flags);
-   ctrl_reg = rtc_dd-ctrl_reg;
 
-   if (ctrl_reg  PM8xxx_RTC_ALARM_ENABLE) {
+   rc = regmap_read(rtc_dd-regmap, regs-ctrl, ctrl_reg);
+   if (rc)
+   goto rtc_rw_fail;
+
+   if (ctrl_reg  regs-alarm_en) {
alarm_enabled = 1;
-   ctrl_reg = ~PM8xxx_RTC_ALARM_ENABLE;
-   rc = regmap_write(rtc_dd-regmap, rtc_dd-rtc_base, ctrl_reg);
+   ctrl_reg = ~regs-alarm_en;
+   rc = regmap_write(rtc_dd-regmap, regs-ctrl, ctrl_reg);
if (rc) {
dev_err(dev, Write to RTC control register failed\n);
goto rtc_rw_fail;
}
-   rtc_dd-ctrl_reg = ctrl_reg;
} else {
spin_unlock_irqrestore(rtc_dd-ctrl_reg_lock, irq_flags);
}
 
/* Write 0 to Byte[0] */
-   rc = regmap_write(rtc_dd-regmap, rtc_dd-rtc_write_base, 0);
+   rc = regmap_write(rtc_dd-regmap, regs-write, 0);
if (rc) {
dev_err(dev, Write to RTC write data register failed\n);
goto rtc_rw_fail;
}
 
/* Write Byte[1], Byte[2], Byte[3] */
-   rc = regmap_bulk_write(rtc_dd-regmap, rtc_dd-rtc_write_base + 1,
+   rc =