Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: i386-randconfig-x016-201652 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> drivers/rtc/rtc-pcf8563.c:666:32: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 regmap = devm_regmap_init_spi(spi, );
   ^
   include/linux/regmap.h:505:6: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
 ^~~
>> drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
>> 'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^~~~
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^~
>> drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
>> read-only object
 spi->mode = SPI_MODE_3;
   ^
>> drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
>> 'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
>> drivers/rtc/rtc-pcf8563.c:676:12: warning: passing argument 1 of 'spi_setup' 
>> discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 spi_setup(spi);
   ^~~
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
>> drivers/rtc/rtc-pcf8563.c:678:20: warning: passing argument 1 of 
>> 'regmap_read' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:682:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
>> drivers/rtc/rtc-pcf8563.c:687:21: warning: passing argument 1 of 
>> 'regmap_write' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:692:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:697:21: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:703:20: warning: 

Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: i386-randconfig-x016-201652 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> drivers/rtc/rtc-pcf8563.c:666:32: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 regmap = devm_regmap_init_spi(spi, );
   ^
   include/linux/regmap.h:505:6: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
 ^~~
>> drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
>> 'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^~~~
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^~
>> drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
>> read-only object
 spi->mode = SPI_MODE_3;
   ^
>> drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
>> 'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
>> drivers/rtc/rtc-pcf8563.c:676:12: warning: passing argument 1 of 'spi_setup' 
>> discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 spi_setup(spi);
   ^~~
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
>> drivers/rtc/rtc-pcf8563.c:678:20: warning: passing argument 1 of 
>> 'regmap_read' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:682:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
>> drivers/rtc/rtc-pcf8563.c:687:21: warning: passing argument 1 of 
>> 'regmap_write' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:692:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:697:21: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:703:20: warning: 

Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> include/linux/regmap.h:667:27: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type
 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
  ^
   include/linux/regmap.h:505:3: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
  ^
   drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^
   drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
read-only object
 spi->mode = SPI_MODE_3;
   ^
   drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
   drivers/rtc/rtc-pcf8563.c:676:2: warning: passing argument 1 of 'spi_setup' 
discards 'const' qualifier from pointer target type
 spi_setup(spi);
 ^
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
   drivers/rtc/rtc-pcf8563.c:678:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:682:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:687:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:692:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:697:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:703:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct 

Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> include/linux/regmap.h:667:27: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type
 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
  ^
   include/linux/regmap.h:505:3: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
  ^
   drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^
   drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
read-only object
 spi->mode = SPI_MODE_3;
   ^
   drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
   drivers/rtc/rtc-pcf8563.c:676:2: warning: passing argument 1 of 'spi_setup' 
discards 'const' qualifier from pointer target type
 spi_setup(spi);
 ^
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
   drivers/rtc/rtc-pcf8563.c:678:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:682:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:687:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:692:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:697:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:703:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct 

[PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread Venkat Prashanth B U
This is a patch to support the SPI compatible PCA21125 device
with the I2C based rtc-pcf8563 driver using regmap layer.
Further this patch adds "pca8565" to the set of i2c ids.

Signed-off-by: Venkat Prashanth B U 
---
change log v3:
1. Add a regmap layer to I2C PCF8563 to support SPI PCA21125.
2. Add pca8565 to the set of i2c ids of rtc-pcf8563.
---
---
 drivers/rtc/rtc-pcf8563.c | 82 +++
 1 file changed, 82 insertions(+)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 1227cea..26c8b9b 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -59,6 +61,7 @@
 
 #define PCF8563_SC_LV  0x80 /* low voltage */
 #define PCF8563_MO_C   0x80 /* century */
+#define PCF8563_REG_SR 0x01 /*control-status register*/
 
 static struct i2c_driver pcf8563_driver;
 
@@ -84,6 +87,9 @@ struct pcf8563 {
struct i2c_client *client;
 #ifdef CONFIG_COMMON_CLK
struct clk_hw   clkout_hw;
+const  struct device *dev;
+const  struct regmap *regmap;
+   bool suspended;
 #endif
 };
 
@@ -629,6 +635,7 @@ static int pcf8563_probe(struct i2c_client *client,
 static const struct i2c_device_id pcf8563_id[] = {
{ "pcf8563", 0 },
{ "rtc8564", 0 },
+   { "pca8565", 0 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
@@ -636,11 +643,86 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);
 #ifdef CONFIG_OF
 static const struct of_device_id pcf8563_of_match[] = {
{ .compatible = "nxp,pcf8563" },
+   { .compatible = "nxp,pca8565" },
{}
 };
 MODULE_DEVICE_TABLE(of, pcf8563_of_match);
 #endif
 
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
+static int pca21125_probe(const struct spi_device *spi)
+{
+   int res;
+   unsigned int tmp;
+   static const struct regmap_config config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .write_flag_mask = 0x80,
+   };
+const struct regmap *regmap;
+const struct pcf8563 *pcf8563;
+
+   regmap = devm_regmap_init_spi(spi, );
+
+   if (IS_ERR(regmap)) {
+   dev_err(>dev, "%s: regmap allocation 
failed: %ld\n",
+   __func__, PTR_ERR(regmap));
+   return PTR_ERR(regmap);
+   }
+
+   spi->mode = SPI_MODE_3;
+   spi->bits_per_word = 8;
+   spi_setup(spi);
+
+   res = regmap_read(regmap, PCF8563_REG_SC, );
+
+   if (res)
+   return res;
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
+
+   if (res)
+   return res;
+
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
+
+   if (res)
+   return res;
+
+   /* Print our settings */
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Control Reg: 0x%02x\n", tmp);
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);
+
+   pcf8563->rtc = devm_rtc_device_register(>dev,
+   "pcf8563",
+   _rtc_ops, THIS_MODULE);
+}
+
+const struct spi_driver pca21125_driver = {
+   .driver = {
+   .name= "pca21125",
+   },
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
.name   = "rtc-pcf8563",
-- 
1.9.2



[PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread Venkat Prashanth B U
This is a patch to support the SPI compatible PCA21125 device
with the I2C based rtc-pcf8563 driver using regmap layer.
Further this patch adds "pca8565" to the set of i2c ids.

Signed-off-by: Venkat Prashanth B U 
---
change log v3:
1. Add a regmap layer to I2C PCF8563 to support SPI PCA21125.
2. Add pca8565 to the set of i2c ids of rtc-pcf8563.
---
---
 drivers/rtc/rtc-pcf8563.c | 82 +++
 1 file changed, 82 insertions(+)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 1227cea..26c8b9b 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -59,6 +61,7 @@
 
 #define PCF8563_SC_LV  0x80 /* low voltage */
 #define PCF8563_MO_C   0x80 /* century */
+#define PCF8563_REG_SR 0x01 /*control-status register*/
 
 static struct i2c_driver pcf8563_driver;
 
@@ -84,6 +87,9 @@ struct pcf8563 {
struct i2c_client *client;
 #ifdef CONFIG_COMMON_CLK
struct clk_hw   clkout_hw;
+const  struct device *dev;
+const  struct regmap *regmap;
+   bool suspended;
 #endif
 };
 
@@ -629,6 +635,7 @@ static int pcf8563_probe(struct i2c_client *client,
 static const struct i2c_device_id pcf8563_id[] = {
{ "pcf8563", 0 },
{ "rtc8564", 0 },
+   { "pca8565", 0 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
@@ -636,11 +643,86 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);
 #ifdef CONFIG_OF
 static const struct of_device_id pcf8563_of_match[] = {
{ .compatible = "nxp,pcf8563" },
+   { .compatible = "nxp,pca8565" },
{}
 };
 MODULE_DEVICE_TABLE(of, pcf8563_of_match);
 #endif
 
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
+static int pca21125_probe(const struct spi_device *spi)
+{
+   int res;
+   unsigned int tmp;
+   static const struct regmap_config config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .write_flag_mask = 0x80,
+   };
+const struct regmap *regmap;
+const struct pcf8563 *pcf8563;
+
+   regmap = devm_regmap_init_spi(spi, );
+
+   if (IS_ERR(regmap)) {
+   dev_err(>dev, "%s: regmap allocation 
failed: %ld\n",
+   __func__, PTR_ERR(regmap));
+   return PTR_ERR(regmap);
+   }
+
+   spi->mode = SPI_MODE_3;
+   spi->bits_per_word = 8;
+   spi_setup(spi);
+
+   res = regmap_read(regmap, PCF8563_REG_SC, );
+
+   if (res)
+   return res;
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
+
+   if (res)
+   return res;
+
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
+
+   if (res)
+   return res;
+
+   /* Print our settings */
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Control Reg: 0x%02x\n", tmp);
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);
+
+   pcf8563->rtc = devm_rtc_device_register(>dev,
+   "pcf8563",
+   _rtc_ops, THIS_MODULE);
+}
+
+const struct spi_driver pca21125_driver = {
+   .driver = {
+   .name= "pca21125",
+   },
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
.name   = "rtc-pcf8563",
-- 
1.9.2



Re: [PATCH] rtc: add support for rtc NXP pca21125

2016-10-18 Thread Alexandre Belloni
Hi,

Don't forget to Cc the rtc-linux mailing list.

Also, please please run checkpatch on your patches

On 18/10/2016 at 07:47:24 -0700, VENKAT PRASHANTH B U wrote :
> This is the patch to add support for
> NXP rtc pca21125
> 
> Signed-off-by: Venkat Prashanth B U <venkat.prashanth2...@gmail.com>
> ---
> ---
>  drivers/rtc/Kconfig|  12 
>  drivers/rtc/Makefile   |   1 +
>  drivers/rtc/rtc-pca21125.c | 164 
> +
>  3 files changed, 177 insertions(+)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index e215f50..df10e0e 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -686,6 +686,18 @@ config RTC_DRV_MAX6916
> This driver can also be built as a module. If so, the module
> will be called rtc-max6916.
>  
> +config RTC_DRV_PCA21125
> + tristate "NXP PCA21125"
> + help
> +   If you say yes here you will get support for the
> +   NXP PCA21125 SPI RTC chip.
> +
> +   This driver only supports the RTC feature, and not other chip
> +   features such as alarms.
> +
> +   This driver can also be built as a module. If so, the module
> +   will be called rtc-pca21125.
> +
>  config RTC_DRV_R9701
>   tristate "Epson RTC-9701JE"
>   help
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 7cf7ad5..2c6af37 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -105,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_NUC900)  += rtc-nuc900.o
>  obj-$(CONFIG_RTC_DRV_OMAP)   += rtc-omap.o
>  obj-$(CONFIG_RTC_DRV_OPAL)   += rtc-opal.o
>  obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o
> +obj-$(CONFIG_RTC_DRV_PCA21125)   += rtc-pca21125.o
>  obj-$(CONFIG_RTC_DRV_PCAP)   += rtc-pcap.o
>  obj-$(CONFIG_RTC_DRV_PCF2123)+= rtc-pcf2123.o
>  obj-$(CONFIG_RTC_DRV_PCF2127)+= rtc-pcf2127.o
> diff --git a/drivers/rtc/rtc-pca21125.c b/drivers/rtc/rtc-pca21125.c
> index e69de29..8d42e4e 100644
> --- a/drivers/rtc/rtc-pca21125.c
> +++ b/drivers/rtc/rtc-pca21125.c
The whole file is badly indented

> @@ -0,0 +1,164 @@
> + /* rtc-pca21125.c
> + *
> + * Driver for NXP  PCA21125 CMOS, SPI Compatible
> + * Real Time Clock
> + *
> + * Author : Venkat Prashanth B U <venkat.prashanth2...@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> + 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + 
> + /* Registers in pca21125 rtc */
> + 
> + #define PCA21125_SECONDS_REG0x02
> + #define PCA21125_MINUTES_REG0x03
> + #define PCA21125_HOURS_REG  0x04
> + #define PCA21125_DATE_REG   0x05
> + #define PCA21125_DAY_REG0x06
> + #define PCA21125_MONTH_REG  0x07
> + #define PCA21125_YEAR_REG   0x08

Those are defined but not used

> + #define PCA21125_CONTROL_REG0x01
> + #define PCA21125_STATUS_REG 0x00
> + #define PCA21125_CLOCK_BURST0x0D
> + 
> + static int pca21125_read_reg(struct device *dev, unsigned char address,
> + unsigned char *data)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + 
> + *data = address | 0x80;
> + 
> + return spi_write_then_read(spi, data, 1, data, 1);
> + }
> + 
> + static int pca21125_write_reg(struct device *dev, unsigned char address,
> + unsigned char data)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + unsigned char buf[2];
> + 
> + buf[0] = address & 0x7F;
> + buf[1] = data;
> + 
> + return spi_write_then_read(spi, buf, 2, NULL, 0);
> + }
> + 
> + static int pca21125_read_time(struct device *dev, struct rtc_time *dt)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + int err;
> + unsigned char buf[8];
> + 
> + buf[0] = PCA21125_CLOCK_BURST | 0x80;
> + 
> + err = spi_write_then_read(spi, buf, 1, buf, 8);
> + 
> + if (err)
> + return err;
> + 

I'm not sure to understand how this can actually work, time/date starts
at 0x2

> + dt->tm_sec = 

Re: [PATCH] rtc: add support for rtc NXP pca21125

2016-10-18 Thread Alexandre Belloni
Hi,

Don't forget to Cc the rtc-linux mailing list.

Also, please please run checkpatch on your patches

On 18/10/2016 at 07:47:24 -0700, VENKAT PRASHANTH B U wrote :
> This is the patch to add support for
> NXP rtc pca21125
> 
> Signed-off-by: Venkat Prashanth B U 
> ---
> ---
>  drivers/rtc/Kconfig|  12 
>  drivers/rtc/Makefile   |   1 +
>  drivers/rtc/rtc-pca21125.c | 164 
> +
>  3 files changed, 177 insertions(+)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index e215f50..df10e0e 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -686,6 +686,18 @@ config RTC_DRV_MAX6916
> This driver can also be built as a module. If so, the module
> will be called rtc-max6916.
>  
> +config RTC_DRV_PCA21125
> + tristate "NXP PCA21125"
> + help
> +   If you say yes here you will get support for the
> +   NXP PCA21125 SPI RTC chip.
> +
> +   This driver only supports the RTC feature, and not other chip
> +   features such as alarms.
> +
> +   This driver can also be built as a module. If so, the module
> +   will be called rtc-pca21125.
> +
>  config RTC_DRV_R9701
>   tristate "Epson RTC-9701JE"
>   help
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 7cf7ad5..2c6af37 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -105,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_NUC900)  += rtc-nuc900.o
>  obj-$(CONFIG_RTC_DRV_OMAP)   += rtc-omap.o
>  obj-$(CONFIG_RTC_DRV_OPAL)   += rtc-opal.o
>  obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o
> +obj-$(CONFIG_RTC_DRV_PCA21125)   += rtc-pca21125.o
>  obj-$(CONFIG_RTC_DRV_PCAP)   += rtc-pcap.o
>  obj-$(CONFIG_RTC_DRV_PCF2123)+= rtc-pcf2123.o
>  obj-$(CONFIG_RTC_DRV_PCF2127)+= rtc-pcf2127.o
> diff --git a/drivers/rtc/rtc-pca21125.c b/drivers/rtc/rtc-pca21125.c
> index e69de29..8d42e4e 100644
> --- a/drivers/rtc/rtc-pca21125.c
> +++ b/drivers/rtc/rtc-pca21125.c
The whole file is badly indented

> @@ -0,0 +1,164 @@
> + /* rtc-pca21125.c
> + *
> + * Driver for NXP  PCA21125 CMOS, SPI Compatible
> + * Real Time Clock
> + *
> + * Author : Venkat Prashanth B U 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> + 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + #include 
> + 
> + /* Registers in pca21125 rtc */
> + 
> + #define PCA21125_SECONDS_REG0x02
> + #define PCA21125_MINUTES_REG0x03
> + #define PCA21125_HOURS_REG  0x04
> + #define PCA21125_DATE_REG   0x05
> + #define PCA21125_DAY_REG0x06
> + #define PCA21125_MONTH_REG  0x07
> + #define PCA21125_YEAR_REG   0x08

Those are defined but not used

> + #define PCA21125_CONTROL_REG0x01
> + #define PCA21125_STATUS_REG 0x00
> + #define PCA21125_CLOCK_BURST0x0D
> + 
> + static int pca21125_read_reg(struct device *dev, unsigned char address,
> + unsigned char *data)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + 
> + *data = address | 0x80;
> + 
> + return spi_write_then_read(spi, data, 1, data, 1);
> + }
> + 
> + static int pca21125_write_reg(struct device *dev, unsigned char address,
> + unsigned char data)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + unsigned char buf[2];
> + 
> + buf[0] = address & 0x7F;
> + buf[1] = data;
> + 
> + return spi_write_then_read(spi, buf, 2, NULL, 0);
> + }
> + 
> + static int pca21125_read_time(struct device *dev, struct rtc_time *dt)
> + {
> + struct spi_device *spi = to_spi_device(dev);
> + int err;
> + unsigned char buf[8];
> + 
> + buf[0] = PCA21125_CLOCK_BURST | 0x80;
> + 
> + err = spi_write_then_read(spi, buf, 1, buf, 8);
> + 
> + if (err)
> + return err;
> + 

I'm not sure to understand how this can actually work, time/date starts
at 0x2

> + dt->tm_sec = bcd2bin(buf[0]);
> + dt->tm_min = bcd2bin(buf[1]);
&

[PATCH] rtc: add support for rtc NXP pca21125

2016-10-18 Thread VENKAT PRASHANTH B U
This is the patch to add support for
NXP rtc pca21125

Signed-off-by: Venkat Prashanth B U <venkat.prashanth2...@gmail.com>
---
---
 drivers/rtc/Kconfig|  12 
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-pca21125.c | 164 +
 3 files changed, 177 insertions(+)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e215f50..df10e0e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -686,6 +686,18 @@ config RTC_DRV_MAX6916
  This driver can also be built as a module. If so, the module
  will be called rtc-max6916.
 
+config RTC_DRV_PCA21125
+   tristate "NXP PCA21125"
+   help
+ If you say yes here you will get support for the
+ NXP PCA21125 SPI RTC chip.
+
+ This driver only supports the RTC feature, and not other chip
+ features such as alarms.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-pca21125.
+
 config RTC_DRV_R9701
tristate "Epson RTC-9701JE"
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 7cf7ad5..2c6af37 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -105,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_NUC900)+= rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
 obj-$(CONFIG_RTC_DRV_PALMAS)   += rtc-palmas.o
+obj-$(CONFIG_RTC_DRV_PCA21125) += rtc-pca21125.o
 obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
 obj-$(CONFIG_RTC_DRV_PCF2123)  += rtc-pcf2123.o
 obj-$(CONFIG_RTC_DRV_PCF2127)  += rtc-pcf2127.o
diff --git a/drivers/rtc/rtc-pca21125.c b/drivers/rtc/rtc-pca21125.c
index e69de29..8d42e4e 100644
--- a/drivers/rtc/rtc-pca21125.c
+++ b/drivers/rtc/rtc-pca21125.c
@@ -0,0 +1,164 @@
+   /* rtc-pca21125.c
+   *
+   * Driver for NXP  PCA21125 CMOS, SPI Compatible
+   * Real Time Clock
+   *
+   * Author : Venkat Prashanth B U <venkat.prashanth2...@gmail.com>
+   *
+   * This program is free software; you can redistribute it and/or modify
+   * it under the terms of the GNU General Public License version 2 as
+   * published by the Free Software Foundation.
+   *
+   */
+   
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   
+   /* Registers in pca21125 rtc */
+   
+   #define PCA21125_SECONDS_REG0x02
+   #define PCA21125_MINUTES_REG0x03
+   #define PCA21125_HOURS_REG  0x04
+   #define PCA21125_DATE_REG   0x05
+   #define PCA21125_DAY_REG0x06
+   #define PCA21125_MONTH_REG  0x07
+   #define PCA21125_YEAR_REG   0x08
+   #define PCA21125_CONTROL_REG0x01
+   #define PCA21125_STATUS_REG 0x00
+   #define PCA21125_CLOCK_BURST0x0D
+   
+   static int pca21125_read_reg(struct device *dev, unsigned char address,
+   unsigned char *data)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   
+   *data = address | 0x80;
+   
+   return spi_write_then_read(spi, data, 1, data, 1);
+   }
+   
+   static int pca21125_write_reg(struct device *dev, unsigned char address,
+   unsigned char data)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+   
+   buf[0] = address & 0x7F;
+   buf[1] = data;
+   
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+   }
+   
+   static int pca21125_read_time(struct device *dev, struct rtc_time *dt)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   unsigned char buf[8];
+   
+   buf[0] = PCA21125_CLOCK_BURST | 0x80;
+   
+   err = spi_write_then_read(spi, buf, 1, buf, 8);
+   
+   if (err)
+   return err;
+   
+   dt->tm_sec = bcd2bin(buf[0]);
+   dt->tm_min = bcd2bin(buf[1]);
+   dt->tm_hour = bcd2bin(buf[2] & 0x3F);
+   dt->tm_mday = bcd2bin(buf[3]);
+   dt->tm_mon = bcd2bin(buf[4]) - 1;
+   dt->tm_wday = bcd2bin(buf[5]) - 1;
+   dt->tm_year = bcd2bin(buf[6]) + 100;
+   
+   return rtc_valid_tm(dt);
+   }
+   
+   static int pca21125_set_time(struct device *dev, struct rtc_time *dt)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[9];
+   
+   if (dt->tm_year < 100 || dt->tm_year > 199) {
+   dev_err(>dev, "Year must be between 2000 and 2099. 
It's %d.\n"

[PATCH] rtc: add support for rtc NXP pca21125

2016-10-18 Thread VENKAT PRASHANTH B U
This is the patch to add support for
NXP rtc pca21125

Signed-off-by: Venkat Prashanth B U 
---
---
 drivers/rtc/Kconfig|  12 
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-pca21125.c | 164 +
 3 files changed, 177 insertions(+)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e215f50..df10e0e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -686,6 +686,18 @@ config RTC_DRV_MAX6916
  This driver can also be built as a module. If so, the module
  will be called rtc-max6916.
 
+config RTC_DRV_PCA21125
+   tristate "NXP PCA21125"
+   help
+ If you say yes here you will get support for the
+ NXP PCA21125 SPI RTC chip.
+
+ This driver only supports the RTC feature, and not other chip
+ features such as alarms.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-pca21125.
+
 config RTC_DRV_R9701
tristate "Epson RTC-9701JE"
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 7cf7ad5..2c6af37 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -105,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_NUC900)+= rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
 obj-$(CONFIG_RTC_DRV_PALMAS)   += rtc-palmas.o
+obj-$(CONFIG_RTC_DRV_PCA21125) += rtc-pca21125.o
 obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
 obj-$(CONFIG_RTC_DRV_PCF2123)  += rtc-pcf2123.o
 obj-$(CONFIG_RTC_DRV_PCF2127)  += rtc-pcf2127.o
diff --git a/drivers/rtc/rtc-pca21125.c b/drivers/rtc/rtc-pca21125.c
index e69de29..8d42e4e 100644
--- a/drivers/rtc/rtc-pca21125.c
+++ b/drivers/rtc/rtc-pca21125.c
@@ -0,0 +1,164 @@
+   /* rtc-pca21125.c
+   *
+   * Driver for NXP  PCA21125 CMOS, SPI Compatible
+   * Real Time Clock
+   *
+   * Author : Venkat Prashanth B U 
+   *
+   * This program is free software; you can redistribute it and/or modify
+   * it under the terms of the GNU General Public License version 2 as
+   * published by the Free Software Foundation.
+   *
+   */
+   
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+   
+   /* Registers in pca21125 rtc */
+   
+   #define PCA21125_SECONDS_REG0x02
+   #define PCA21125_MINUTES_REG0x03
+   #define PCA21125_HOURS_REG  0x04
+   #define PCA21125_DATE_REG   0x05
+   #define PCA21125_DAY_REG0x06
+   #define PCA21125_MONTH_REG  0x07
+   #define PCA21125_YEAR_REG   0x08
+   #define PCA21125_CONTROL_REG0x01
+   #define PCA21125_STATUS_REG 0x00
+   #define PCA21125_CLOCK_BURST0x0D
+   
+   static int pca21125_read_reg(struct device *dev, unsigned char address,
+   unsigned char *data)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   
+   *data = address | 0x80;
+   
+   return spi_write_then_read(spi, data, 1, data, 1);
+   }
+   
+   static int pca21125_write_reg(struct device *dev, unsigned char address,
+   unsigned char data)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+   
+   buf[0] = address & 0x7F;
+   buf[1] = data;
+   
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+   }
+   
+   static int pca21125_read_time(struct device *dev, struct rtc_time *dt)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   unsigned char buf[8];
+   
+   buf[0] = PCA21125_CLOCK_BURST | 0x80;
+   
+   err = spi_write_then_read(spi, buf, 1, buf, 8);
+   
+   if (err)
+   return err;
+   
+   dt->tm_sec = bcd2bin(buf[0]);
+   dt->tm_min = bcd2bin(buf[1]);
+   dt->tm_hour = bcd2bin(buf[2] & 0x3F);
+   dt->tm_mday = bcd2bin(buf[3]);
+   dt->tm_mon = bcd2bin(buf[4]) - 1;
+   dt->tm_wday = bcd2bin(buf[5]) - 1;
+   dt->tm_year = bcd2bin(buf[6]) + 100;
+   
+   return rtc_valid_tm(dt);
+   }
+   
+   static int pca21125_set_time(struct device *dev, struct rtc_time *dt)
+   {
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[9];
+   
+   if (dt->tm_year < 100 || dt->tm_year > 199) {
+   dev_err(>dev, "Year must be between 2000 and 2099. 
It's %d.\n",
+   dt->tm_year + 1900);
+   r