All of lore.kernel.org
 help / color / mirror / Atom feed
* [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support
@ 2019-07-16  8:15 Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock Biju Das
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

This patch series add RTC support for iWave iwg23s sbc based on RZ/G1C.

This patch series is based on linux-4.4.y-cip and all the patches
in this series are cherry-picked from linux rc tree.

This patch series depend on
https://patchwork.kernel.org/project/cip-dev/list/?series=146261

Alexandre Belloni (1):
  rtc: pcf85363: add .max_register in regmap_config

Biju Das (6):
  rtc: pcf85363: set time accurately
  dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  rtc: pcf85363: Add support for NXP pcf85263 rtc
  ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  ARM: multi_v7_defconfig: Enable NXP pcf85363 rtc
  ARM: dts: iwg23s-sbc: Enable RTC

Eric Nelson (1):
  rtc: add support for NXP PCF85363 real-time clock

Fabrizio Castro (2):
  ARM: dts: r8a77470: Add I2C4 support
  ARM: dts: r8a77470: Add I2C[0123] support

 Documentation/devicetree/bindings/rtc/pcf85363.txt |  17 ++
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts          |  18 ++
 arch/arm/boot/dts/r8a77470.dtsi                    |  68 ++++++
 arch/arm/configs/multi_v7_defconfig                |   1 +
 arch/arm/configs/shmobile_defconfig                |   1 +
 drivers/rtc/Kconfig                                |   9 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-pcf85363.c                         | 234 +++++++++++++++++++++
 8 files changed, 349 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/pcf85363.txt
 create mode 100644 drivers/rtc/rtc-pcf85363.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-17 11:29   ` Pavel Machek
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 02/10] rtc: pcf85363: add .max_register in regmap_config Biju Das
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

From: Eric Nelson <eric@nelint.com>

commit a9687aa2764dd2669602bd19dc636cbeef5293d5 upstream.

Note that alarms are not currently implemented.

64 bytes of nvmem is supported and exposed in
sysfs (# is the instance number, starting with 0):

	/sys/bus/nvmem/devices/pcf85363-#/nvmem

Signed-off-by: Eric Nelson <eric@nelint.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
[Removed rtc nvmem support. Added I2C ID table to rtc-pcf85363.c
 Updated Kconfig description for rtc-pcf85363]
---
 Documentation/devicetree/bindings/rtc/pcf85363.txt |  17 ++
 drivers/rtc/Kconfig                                |   9 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-pcf85363.c                         | 197 +++++++++++++++++++++
 4 files changed, 224 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/pcf85363.txt
 create mode 100644 drivers/rtc/rtc-pcf85363.c

diff --git a/Documentation/devicetree/bindings/rtc/pcf85363.txt b/Documentation/devicetree/bindings/rtc/pcf85363.txt
new file mode 100644
index 0000000..76fdabc
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/pcf85363.txt
@@ -0,0 +1,17 @@
+NXP PCF85363 Real Time Clock
+============================
+
+Required properties:
+- compatible: Should contain "nxp,pcf85363".
+- reg: I2C address for chip.
+
+Optional properties:
+- interrupts: IRQ line for the RTC (not implemented).
+
+Example:
+
+pcf85363: pcf85363 at 51 {
+	compatible = "nxp,pcf85363";
+	reg = <0x51>;
+};
+
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 2a52424..8f2fed5 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -419,6 +419,15 @@ config RTC_DRV_PCF8523
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-pcf8523.
 
+config RTC_DRV_PCF85363
+	tristate "NXP PCF85363"
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for the PCF85363 RTC chip.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-pcf85363.
+
 config RTC_DRV_PCF8563
 	tristate "Philips PCF8563/Epson RTC8564"
 	help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 231f764..8419d5b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PCF2123)	+= rtc-pcf2123.o
 obj-$(CONFIG_RTC_DRV_PCF2127)	+= rtc-pcf2127.o
 obj-$(CONFIG_RTC_DRV_PCF50633)	+= rtc-pcf50633.o
 obj-$(CONFIG_RTC_DRV_PCF85063)	+= rtc-pcf85063.o
+obj-$(CONFIG_RTC_DRV_PCF85363)	+= rtc-pcf85363.o
 obj-$(CONFIG_RTC_DRV_PCF8523)	+= rtc-pcf8523.o
 obj-$(CONFIG_RTC_DRV_PCF8563)	+= rtc-pcf8563.o
 obj-$(CONFIG_RTC_DRV_PCF8583)	+= rtc-pcf8583.o
diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
new file mode 100644
index 0000000..54fc1a7
--- /dev/null
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -0,0 +1,197 @@
+/*
+ * drivers/rtc/rtc-pcf85363.c
+ *
+ * Driver for NXP PCF85363 real-time clock.
+ *
+ * Copyright (C) 2017 Eric Nelson
+ *
+ * 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.
+ *
+ * Based loosely on rtc-8583 by Russell King, Wolfram Sang and Juergen Beisert
+ */
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/rtc.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/bcd.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+/*
+ * Date/Time registers
+ */
+#define DT_100THS	0x00
+#define DT_SECS		0x01
+#define DT_MINUTES	0x02
+#define DT_HOURS	0x03
+#define DT_DAYS		0x04
+#define DT_WEEKDAYS	0x05
+#define DT_MONTHS	0x06
+#define DT_YEARS	0x07
+
+/*
+ * Alarm registers
+ */
+#define DT_SECOND_ALM1	0x08
+#define DT_MINUTE_ALM1	0x09
+#define DT_HOUR_ALM1	0x0a
+#define DT_DAY_ALM1	0x0b
+#define DT_MONTH_ALM1	0x0c
+#define DT_MINUTE_ALM2	0x0d
+#define DT_HOUR_ALM2	0x0e
+#define DT_WEEKDAY_ALM2	0x0f
+#define DT_ALARM_EN	0x10
+
+/*
+ * Time stamp registers
+ */
+#define DT_TIMESTAMP1	0x11
+#define DT_TIMESTAMP2	0x17
+#define DT_TIMESTAMP3	0x1d
+#define DT_TS_MODE	0x23
+
+/*
+ * control registers
+ */
+#define CTRL_OFFSET	0x24
+#define CTRL_OSCILLATOR	0x25
+#define CTRL_BATTERY	0x26
+#define CTRL_PIN_IO	0x27
+#define CTRL_FUNCTION	0x28
+#define CTRL_INTA_EN	0x29
+#define CTRL_INTB_EN	0x2a
+#define CTRL_FLAGS	0x2b
+#define CTRL_RAMBYTE	0x2c
+#define CTRL_WDOG	0x2d
+#define CTRL_STOP_EN	0x2e
+#define CTRL_RESETS	0x2f
+#define CTRL_RAM	0x40
+
+#define NVRAM_SIZE	0x40
+
+static struct i2c_driver pcf85363_driver;
+
+struct pcf85363 {
+	struct device		*dev;
+	struct rtc_device	*rtc;
+	struct regmap		*regmap;
+};
+
+static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pcf85363 *pcf85363 = dev_get_drvdata(dev);
+	unsigned char buf[DT_YEARS + 1];
+	int ret, len = sizeof(buf);
+
+	/* read the RTC date and time registers all at once */
+	ret = regmap_bulk_read(pcf85363->regmap, DT_100THS, buf, len);
+	if (ret) {
+		dev_err(dev, "%s: error %d\n", __func__, ret);
+		return ret;
+	}
+
+	tm->tm_year = bcd2bin(buf[DT_YEARS]);
+	/* adjust for 1900 base of rtc_time */
+	tm->tm_year += 100;
+
+	tm->tm_wday = buf[DT_WEEKDAYS] & 7;
+	buf[DT_SECS] &= 0x7F;
+	tm->tm_sec = bcd2bin(buf[DT_SECS]);
+	buf[DT_MINUTES] &= 0x7F;
+	tm->tm_min = bcd2bin(buf[DT_MINUTES]);
+	tm->tm_hour = bcd2bin(buf[DT_HOURS]);
+	tm->tm_mday = bcd2bin(buf[DT_DAYS]);
+	tm->tm_mon = bcd2bin(buf[DT_MONTHS]) - 1;
+
+	return 0;
+}
+
+static int pcf85363_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pcf85363 *pcf85363 = dev_get_drvdata(dev);
+	unsigned char buf[DT_YEARS + 1];
+	int len = sizeof(buf);
+
+	buf[DT_100THS] = 0;
+	buf[DT_SECS] = bin2bcd(tm->tm_sec);
+	buf[DT_MINUTES] = bin2bcd(tm->tm_min);
+	buf[DT_HOURS] = bin2bcd(tm->tm_hour);
+	buf[DT_DAYS] = bin2bcd(tm->tm_mday);
+	buf[DT_WEEKDAYS] = tm->tm_wday;
+	buf[DT_MONTHS] = bin2bcd(tm->tm_mon + 1);
+	buf[DT_YEARS] = bin2bcd(tm->tm_year % 100);
+
+	return regmap_bulk_write(pcf85363->regmap, DT_100THS,
+				 buf, len);
+}
+
+static const struct rtc_class_ops rtc_ops = {
+	.read_time	= pcf85363_rtc_read_time,
+	.set_time	= pcf85363_rtc_set_time,
+};
+
+static const struct regmap_config regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static int pcf85363_probe(struct i2c_client *client,
+			  const struct i2c_device_id *id)
+{
+	struct pcf85363 *pcf85363;
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+		return -ENODEV;
+
+	pcf85363 = devm_kzalloc(&client->dev, sizeof(struct pcf85363),
+				GFP_KERNEL);
+	if (!pcf85363)
+		return -ENOMEM;
+
+	pcf85363->regmap = devm_regmap_init_i2c(client, &regmap_config);
+	if (IS_ERR(pcf85363->regmap)) {
+		dev_err(&client->dev, "regmap allocation failed\n");
+		return PTR_ERR(pcf85363->regmap);
+	}
+
+	pcf85363->dev = &client->dev;
+	i2c_set_clientdata(client, pcf85363);
+
+	pcf85363->rtc = devm_rtc_device_register(pcf85363->dev,
+						pcf85363_driver.driver.name,
+						&rtc_ops, THIS_MODULE);
+
+	return PTR_ERR_OR_ZERO(pcf85363->rtc);
+}
+
+static const struct i2c_device_id pcf85363_id[] = {
+	{ "pcf85363", 0 },
+	{ }
+};
+
+static const struct of_device_id dev_ids[] = {
+	{ .compatible = "nxp,pcf85363" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, dev_ids);
+
+static struct i2c_driver pcf85363_driver = {
+	.driver	= {
+		.name	= "pcf85363",
+		.of_match_table = of_match_ptr(dev_ids),
+	},
+	.probe	= pcf85363_probe,
+	.id_table = pcf85363_id,
+};
+
+module_i2c_driver(pcf85363_driver);
+
+MODULE_AUTHOR("Eric Nelson");
+MODULE_DESCRIPTION("pcf85363 I2C RTC driver");
+MODULE_LICENSE("GPL");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 02/10] rtc: pcf85363: add .max_register in regmap_config
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately Biju Das
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

commit c57849dde003db3e21d33eab906dba2202f9294e upstream.

This helps debugging as it allows reading registers from debugfs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/rtc/rtc-pcf85363.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index 54fc1a7..5fbc6df 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -139,6 +139,7 @@ static const struct rtc_class_ops rtc_ops = {
 static const struct regmap_config regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
+	.max_register = 0x7f,
 };
 
 static int pcf85363_probe(struct i2c_client *client,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 02/10] rtc: pcf85363: add .max_register in regmap_config Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16 21:03   ` Pavel Machek
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 04/10] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit 188306ac9536ec47674ffa9dd330f69927679aeb upstream.

As per 8.2.6 Setting and reading the time in RTC mode, first stop the clok,
then reset it before setting the date and time registers. Finally, start
the clock.

This uses register address wrap around from 0x2f to 0x00 for efficiency.

This allows to set the clock with a millisecond accuracy (drift is not
corrected in this example):

RTC        System
1325388767 1325388767.000029180
1325388768 1325388768.000018362
1325388769 1325388769.000006544
1325388770 1325388769.999992725
1325388771 1325388770.999974544

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/rtc/rtc-pcf85363.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index 5fbc6df..dc57a6f 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -73,6 +73,10 @@
 #define CTRL_RESETS	0x2f
 #define CTRL_RAM	0x40
 
+#define STOP_EN_STOP	BIT(0)
+
+#define RESET_CPR	0xa4
+
 #define NVRAM_SIZE	0x40
 
 static struct i2c_driver pcf85363_driver;
@@ -115,8 +119,12 @@ static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm)
 static int pcf85363_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
 	struct pcf85363 *pcf85363 = dev_get_drvdata(dev);
-	unsigned char buf[DT_YEARS + 1];
-	int len = sizeof(buf);
+	unsigned char tmp[11];
+	unsigned char *buf = &tmp[2];
+	int ret;
+
+	tmp[0] = STOP_EN_STOP;
+	tmp[1] = RESET_CPR;
 
 	buf[DT_100THS] = 0;
 	buf[DT_SECS] = bin2bcd(tm->tm_sec);
@@ -127,8 +135,12 @@ static int pcf85363_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	buf[DT_MONTHS] = bin2bcd(tm->tm_mon + 1);
 	buf[DT_YEARS] = bin2bcd(tm->tm_year % 100);
 
-	return regmap_bulk_write(pcf85363->regmap, DT_100THS,
-				 buf, len);
+	ret = regmap_bulk_write(pcf85363->regmap, CTRL_STOP_EN,
+				tmp, sizeof(tmp));
+	if (ret)
+		return ret;
+
+	return regmap_write(pcf85363->regmap, CTRL_STOP_EN, 0);
 }
 
 static const struct rtc_class_ops rtc_ops = {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 04/10] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (2 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit bae5e94bea188e652d798eeb4b92b88a355591f6 upstream.

The pcf85263 RTC is compatible with the pcf85363 RTC.

The difference between the pcf85263 and pcf85363 RTC is that the latter has
64 bytes more RAM. This renders them incompatible from a DT point of view.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 Documentation/devicetree/bindings/rtc/pcf85363.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/pcf85363.txt b/Documentation/devicetree/bindings/rtc/pcf85363.txt
index 76fdabc..94adc1c 100644
--- a/Documentation/devicetree/bindings/rtc/pcf85363.txt
+++ b/Documentation/devicetree/bindings/rtc/pcf85363.txt
@@ -1,8 +1,8 @@
-NXP PCF85363 Real Time Clock
+NXP PCF85263/PCF85363 Real Time Clock
 ============================
 
 Required properties:
-- compatible: Should contain "nxp,pcf85363".
+- compatible: Should contain "nxp,pcf85263" or "nxp,pcf85363".
 - reg: I2C address for chip.
 
 Optional properties:
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (3 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 04/10] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-17  7:08   ` nobuhiro1.iwamatsu at toshiba.co.jp
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 06/10] ARM: dts: r8a77470: Add I2C4 support Biju Das
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit fc979933bcf162595b6004d0de4effb64c323152 upstream.

Add support for NXP pcf85263 real-time clock. pcf85263 rtc is compatible
with pcf85363,except that pcf85363 has additional 64 bytes of RAM.

1 byte of nvmem is supported and exposed in sysfs (# is the instance
number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
[ Removed rtc nvmem support. Added I2C ID table for rtc-pcf85263 ]
---
 drivers/rtc/rtc-pcf85363.c | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index dc57a6f..64217f1 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -87,6 +87,11 @@ struct pcf85363 {
 	struct regmap		*regmap;
 };
 
+struct pcf85x63_config {
+	struct regmap_config regmap;
+	unsigned int num_nvram;
+};
+
 static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	struct pcf85363 *pcf85363 = dev_get_drvdata(dev);
@@ -148,16 +153,33 @@ static const struct rtc_class_ops rtc_ops = {
 	.set_time	= pcf85363_rtc_set_time,
 };
 
-static const struct regmap_config regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-	.max_register = 0x7f,
+static const struct pcf85x63_config pcf_85263_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x2f,
+	},
+	.num_nvram = 1
+};
+
+static const struct pcf85x63_config pcf_85363_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x7f,
+	},
+	.num_nvram = 2
 };
 
 static int pcf85363_probe(struct i2c_client *client,
 			  const struct i2c_device_id *id)
 {
 	struct pcf85363 *pcf85363;
+	const struct pcf85x63_config *config = &pcf_85363_config;
+	const void *data = of_device_get_match_data(&client->dev);
+
+	if (data)
+		config = data;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
@@ -167,7 +189,7 @@ static int pcf85363_probe(struct i2c_client *client,
 	if (!pcf85363)
 		return -ENOMEM;
 
-	pcf85363->regmap = devm_regmap_init_i2c(client, &regmap_config);
+	pcf85363->regmap = devm_regmap_init_i2c(client, &config->regmap);
 	if (IS_ERR(pcf85363->regmap)) {
 		dev_err(&client->dev, "regmap allocation failed\n");
 		return PTR_ERR(pcf85363->regmap);
@@ -185,12 +207,14 @@ static int pcf85363_probe(struct i2c_client *client,
 
 static const struct i2c_device_id pcf85363_id[] = {
 	{ "pcf85363", 0 },
+	{ "pcf85263", 0 },
 	{ }
 };
 
 static const struct of_device_id dev_ids[] = {
-	{ .compatible = "nxp,pcf85363" },
-	{}
+	{ .compatible = "nxp,pcf85263", .data = &pcf_85263_config },
+	{ .compatible = "nxp,pcf85363", .data = &pcf_85363_config },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dev_ids);
 
@@ -206,5 +230,5 @@ static struct i2c_driver pcf85363_driver = {
 module_i2c_driver(pcf85363_driver);
 
 MODULE_AUTHOR("Eric Nelson");
-MODULE_DESCRIPTION("pcf85363 I2C RTC driver");
+MODULE_DESCRIPTION("pcf85263/pcf85363 I2C RTC driver");
 MODULE_LICENSE("GPL");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 06/10] ARM: dts: r8a77470: Add I2C4 support
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (4 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 07/10] ARM: dts: r8a77470: Add I2C[0123] support Biju Das
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

From: Fabrizio Castro <fabrizio.castro@bp.renesas.com>

commit 3578859661975f8ccb9d8d49c97784d5ff5467df upstream.

Add I2C4 support to RZ/G1C (a.k.a. r8a77470) SoC specific
device tree.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
[Reworked clocks and power-domains properties. Removed resets properties]
---
 arch/arm/boot/dts/r8a77470.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/r8a77470.dtsi b/arch/arm/boot/dts/r8a77470.dtsi
index a10afa2..7b3c4a2 100644
--- a/arch/arm/boot/dts/r8a77470.dtsi
+++ b/arch/arm/boot/dts/r8a77470.dtsi
@@ -211,6 +211,18 @@
 			reg = <0 0xe6300000 0 0x20000>;
 		};
 
+		i2c4: i2c at e6520000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "renesas,i2c-r8a77470",
+				     "renesas,rcar-gen2-i2c";
+			reg = <0 0xe6520000 0 0x40>;
+			interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp9_clks R8A77470_CLK_I2C4>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		dmac0: dma-controller at e6700000 {
 			compatible = "renesas,dmac-r8a77470",
 				     "renesas,rcar-dmac";
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 07/10] ARM: dts: r8a77470: Add I2C[0123] support
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (5 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 06/10] ARM: dts: r8a77470: Add I2C4 support Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 08/10] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

From: Fabrizio Castro <fabrizio.castro@bp.renesas.com>

commit 4f94af57237ad1c9c6328b468fd8fbbd19c2fb78 upstream.

Add device tree nodes for the I2C[0123] controllers. Also, add
the aliases node.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
[Reworked clocks and power-domains properties. Removed resets properties]
---
 arch/arm/boot/dts/r8a77470.dtsi | 56 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/arch/arm/boot/dts/r8a77470.dtsi b/arch/arm/boot/dts/r8a77470.dtsi
index 7b3c4a2..524bba6 100644
--- a/arch/arm/boot/dts/r8a77470.dtsi
+++ b/arch/arm/boot/dts/r8a77470.dtsi
@@ -14,6 +14,14 @@
 	#address-cells = <2>;
 	#size-cells = <2>;
 
+	aliases {
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
+		i2c3 = &i2c3;
+		i2c4 = &i2c4;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -211,6 +219,54 @@
 			reg = <0 0xe6300000 0 0x20000>;
 		};
 
+		i2c0: i2c at e6508000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "renesas,i2c-r8a77470",
+				     "renesas,rcar-gen2-i2c";
+			reg = <0 0xe6508000 0 0x40>;
+			interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp9_clks R8A77470_CLK_I2C0>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
+		i2c1: i2c at e6518000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "renesas,i2c-r8a77470",
+				     "renesas,rcar-gen2-i2c";
+			reg = <0 0xe6518000 0 0x40>;
+			interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp9_clks R8A77470_CLK_I2C1>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
+		i2c2: i2c at e6530000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "renesas,i2c-r8a77470",
+				     "renesas,rcar-gen2-i2c";
+			reg = <0 0xe6530000 0 0x40>;
+			interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp9_clks R8A77470_CLK_I2C2>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
+		i2c3: i2c at e6540000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "renesas,i2c-r8a77470",
+				     "renesas,rcar-gen2-i2c";
+			reg = <0 0xe6540000 0 0x40>;
+			interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp9_clks R8A77470_CLK_I2C3>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		i2c4: i2c at e6520000 {
 			#address-cells = <1>;
 			#size-cells = <0>;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 08/10] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (6 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 07/10] ARM: dts: r8a77470: Add I2C[0123] support Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 09/10] ARM: multi_v7_defconfig: Enable NXP pcf85363 rtc Biju Das
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit 71e3039dd7c377118608321d6c1f2ecb35da4c17 upstream.

The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase hardware
support enable the driver in the shmobile_defconfig multiplatform
configuration.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/configs/shmobile_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig
index 4770cd8..4074631 100644
--- a/arch/arm/configs/shmobile_defconfig
+++ b/arch/arm/configs/shmobile_defconfig
@@ -188,6 +188,7 @@ CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_RS5C372=y
+CONFIG_RTC_DRV_PCF85363=y
 CONFIG_RTC_DRV_BQ32K=y
 CONFIG_RTC_DRV_S35390A=y
 CONFIG_RTC_DRV_RX8581=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 09/10] ARM: multi_v7_defconfig: Enable NXP pcf85363 rtc
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (7 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 08/10] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 10/10] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
  2019-07-17 11:45 ` [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Pavel Machek
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit e5168ec09d993d2b64cd9ee8d4cff269e53538be upstream.

The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase
hardware support enable the driver in the multi_v7_defconfig
multiplatform configuration.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index cfaf564..a3ba031 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -608,6 +608,7 @@ CONFIG_RTC_DRV_MAX77686=y
 CONFIG_RTC_DRV_RK808=m
 CONFIG_RTC_DRV_MAX77802=m
 CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_PCF85363=m
 CONFIG_RTC_DRV_BQ32K=m
 CONFIG_RTC_DRV_PALMAS=y
 CONFIG_RTC_DRV_ST_LPC=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 10/10] ARM: dts: iwg23s-sbc: Enable RTC
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (8 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 09/10] ARM: multi_v7_defconfig: Enable NXP pcf85363 rtc Biju Das
@ 2019-07-16  8:15 ` Biju Das
  2019-07-17 11:45 ` [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Pavel Machek
  10 siblings, 0 replies; 19+ messages in thread
From: Biju Das @ 2019-07-16  8:15 UTC (permalink / raw)
  To: cip-dev

commit 55327bff832c9903a9133cdad56783b54bd8596a upstream.

Enable NXP pcf85263 real time clock for the iWave SBC based on RZ/G1C.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts b/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
index 48b168d..fea316d 100644
--- a/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
+++ b/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
@@ -48,12 +48,30 @@
 	clock-frequency = <20000000>;
 };
 
+&i2c3 {
+	pinctrl-0 = <&i2c3_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+	clock-frequency = <400000>;
+
+	rtc at 51 {
+		compatible = "nxp,pcf85263";
+		reg = <0x51>;
+	};
+};
+
 &pfc {
 	avb_pins: avb {
 		groups = "avb_mdio", "avb_gmii_tx_rx";
 		function = "avb";
 	};
 
+	i2c3_pins: i2c3 {
+		groups = "i2c3_c";
+		function = "i2c3";
+	};
+
 	qspi0_pins: qspi0 {
 		groups = "qspi0_ctrl", "qspi0_data2";
 		function = "qspi0";
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately Biju Das
@ 2019-07-16 21:03   ` Pavel Machek
  2019-07-17  7:47     ` Biju Das
  0 siblings, 1 reply; 19+ messages in thread
From: Pavel Machek @ 2019-07-16 21:03 UTC (permalink / raw)
  To: cip-dev

On Tue 2019-07-16 09:15:14, Biju Das wrote:
> commit 188306ac9536ec47674ffa9dd330f69927679aeb upstream.
> 
> As per 8.2.6 Setting and reading the time in RTC mode, first stop the clok,
> then reset it before setting the date and time registers. Finally, start
> the clock.
> 
> This uses register address wrap around from 0x2f to 0x00 for
> efficiency.

How does wrap around work? AFAICT it is supposed to have ram at 0x40.

Does it really provide increased efficiency (given regmap layer in
between) and will such trick cause problems in future? If regmap is
not aware of register mirrors it might get confused and provide stale
values, for example...

Best regards,
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190716/f24183ef/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
@ 2019-07-17  7:08   ` nobuhiro1.iwamatsu at toshiba.co.jp
  2019-07-17  7:16     ` Biju Das
  0 siblings, 1 reply; 19+ messages in thread
From: nobuhiro1.iwamatsu at toshiba.co.jp @ 2019-07-17  7:08 UTC (permalink / raw)
  To: cip-dev

Hi,

> -----Original Message-----
> From: cip-dev-bounces at lists.cip-project.org
> [mailto:cip-dev-bounces at lists.cip-project.org] On Behalf Of Biju Das
> Sent: Tuesday, July 16, 2019 5:15 PM
> To: cip-dev at lists.cip-project.org
> Cc: Biju Das <biju.das@bp.renesas.com>
> Subject: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support
> for NXP pcf85263 rtc
> 
> commit fc979933bcf162595b6004d0de4effb64c323152 upstream.
> 
> Add support for NXP pcf85263 real-time clock. pcf85263 rtc is compatible
> with pcf85363,except that pcf85363 has additional 64 bytes of RAM.
> 
> 1 byte of nvmem is supported and exposed in sysfs (# is the instance
> number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com> [ Removed rtc nvmem
> support. Added I2C ID table for rtc-pcf85263 ]

You've deleted Alexandre's Signed-off-by tag from original patch.

Best regards,
  Nobuhiro

> ---
>  drivers/rtc/rtc-pcf85363.c | 40
> ++++++++++++++++++++++++++++++++--------
>  1 file changed, 32 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
> index dc57a6f..64217f1 100644
> --- a/drivers/rtc/rtc-pcf85363.c
> +++ b/drivers/rtc/rtc-pcf85363.c
> @@ -87,6 +87,11 @@ struct pcf85363 {
>  	struct regmap		*regmap;
>  };
> 
> +struct pcf85x63_config {
> +	struct regmap_config regmap;
> +	unsigned int num_nvram;
> +};
> +
>  static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time
> *tm)  {
>  	struct pcf85363 *pcf85363 = dev_get_drvdata(dev); @@ -148,16
> +153,33 @@ static const struct rtc_class_ops rtc_ops = {
>  	.set_time	= pcf85363_rtc_set_time,
>  };
> 
> -static const struct regmap_config regmap_config = {
> -	.reg_bits = 8,
> -	.val_bits = 8,
> -	.max_register = 0x7f,
> +static const struct pcf85x63_config pcf_85263_config = {
> +	.regmap = {
> +		.reg_bits = 8,
> +		.val_bits = 8,
> +		.max_register = 0x2f,
> +	},
> +	.num_nvram = 1
> +};
> +
> +static const struct pcf85x63_config pcf_85363_config = {
> +	.regmap = {
> +		.reg_bits = 8,
> +		.val_bits = 8,
> +		.max_register = 0x7f,
> +	},
> +	.num_nvram = 2
>  };
> 
>  static int pcf85363_probe(struct i2c_client *client,
>  			  const struct i2c_device_id *id)
>  {
>  	struct pcf85363 *pcf85363;
> +	const struct pcf85x63_config *config = &pcf_85363_config;
> +	const void *data = of_device_get_match_data(&client->dev);
> +
> +	if (data)
> +		config = data;
> 
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
>  		return -ENODEV;
> @@ -167,7 +189,7 @@ static int pcf85363_probe(struct i2c_client *client,
>  	if (!pcf85363)
>  		return -ENOMEM;
> 
> -	pcf85363->regmap = devm_regmap_init_i2c(client,
> &regmap_config);
> +	pcf85363->regmap = devm_regmap_init_i2c(client,
> &config->regmap);
>  	if (IS_ERR(pcf85363->regmap)) {
>  		dev_err(&client->dev, "regmap allocation failed\n");
>  		return PTR_ERR(pcf85363->regmap);
> @@ -185,12 +207,14 @@ static int pcf85363_probe(struct i2c_client
> *client,
> 
>  static const struct i2c_device_id pcf85363_id[] = {
>  	{ "pcf85363", 0 },
> +	{ "pcf85263", 0 },
>  	{ }
>  };
> 
>  static const struct of_device_id dev_ids[] = {
> -	{ .compatible = "nxp,pcf85363" },
> -	{}
> +	{ .compatible = "nxp,pcf85263", .data = &pcf_85263_config },
> +	{ .compatible = "nxp,pcf85363", .data = &pcf_85363_config },
> +	{ /* sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, dev_ids);
> 
> @@ -206,5 +230,5 @@ static struct i2c_driver pcf85363_driver =
> {  module_i2c_driver(pcf85363_driver);
> 
>  MODULE_AUTHOR("Eric Nelson");
> -MODULE_DESCRIPTION("pcf85363 I2C RTC driver");
> +MODULE_DESCRIPTION("pcf85263/pcf85363 I2C RTC driver");
>  MODULE_LICENSE("GPL");
> --
> 2.7.4
> 
> _______________________________________________
> cip-dev mailing list
> cip-dev at lists.cip-project.org
> https://lists.cip-project.org/mailman/listinfo/cip-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2019-07-17  7:08   ` nobuhiro1.iwamatsu at toshiba.co.jp
@ 2019-07-17  7:16     ` Biju Das
  2019-07-17 23:20       ` nobuhiro1.iwamatsu at toshiba.co.jp
  0 siblings, 1 reply; 19+ messages in thread
From: Biju Das @ 2019-07-17  7:16 UTC (permalink / raw)
  To: cip-dev

Hi Nobuhiro,

Thanks for the feedback.

> Subject: RE: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for
> NXP pcf85263 rtc
> 
> Hi,
> 
> > -----Original Message-----
> > From: cip-dev-bounces at lists.cip-project.org
> > [mailto:cip-dev-bounces at lists.cip-project.org] On Behalf Of Biju Das
> > Sent: Tuesday, July 16, 2019 5:15 PM
> > To: cip-dev at lists.cip-project.org
> > Cc: Biju Das <biju.das@bp.renesas.com>
> > Subject: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support
> > for NXP pcf85263 rtc
> >
> > commit fc979933bcf162595b6004d0de4effb64c323152 upstream.
> >
> > Add support for NXP pcf85263 real-time clock. pcf85263 rtc is
> > compatible with pcf85363,except that pcf85363 has additional 64 bytes of
> RAM.
> >
> > 1 byte of nvmem is supported and exposed in sysfs (# is the instance
> > number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com> [ Removed rtc nvmem
> > support. Added I2C ID table for rtc-pcf85263 ]
> 
> You've deleted Alexandre's Signed-off-by tag from original patch.

Thanks for pointing this out. It is a mistake.  Can you please fix this while applying to the tree?

Or 

Do you want me to send another patch fixing this? Please let me know.

Regards,
Biju

[>] 
> > ---
> >  drivers/rtc/rtc-pcf85363.c | 40
> > ++++++++++++++++++++++++++++++++--------
> >  1 file changed, 32 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
> > index dc57a6f..64217f1 100644
> > --- a/drivers/rtc/rtc-pcf85363.c
> > +++ b/drivers/rtc/rtc-pcf85363.c
> > @@ -87,6 +87,11 @@ struct pcf85363 {
> >  	struct regmap		*regmap;
> >  };
> >
> > +struct pcf85x63_config {
> > +	struct regmap_config regmap;
> > +	unsigned int num_nvram;
> > +};
> > +
> >  static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time
> > *tm)  {
> >  	struct pcf85363 *pcf85363 = dev_get_drvdata(dev); @@ -148,16
> > +153,33 @@ static const struct rtc_class_ops rtc_ops = {
> >  	.set_time	= pcf85363_rtc_set_time,
> >  };
> >
> > -static const struct regmap_config regmap_config = {
> > -	.reg_bits = 8,
> > -	.val_bits = 8,
> > -	.max_register = 0x7f,
> > +static const struct pcf85x63_config pcf_85263_config = {
> > +	.regmap = {
> > +		.reg_bits = 8,
> > +		.val_bits = 8,
> > +		.max_register = 0x2f,
> > +	},
> > +	.num_nvram = 1
> > +};
> > +
> > +static const struct pcf85x63_config pcf_85363_config = {
> > +	.regmap = {
> > +		.reg_bits = 8,
> > +		.val_bits = 8,
> > +		.max_register = 0x7f,
> > +	},
> > +	.num_nvram = 2
> >  };
> >
> >  static int pcf85363_probe(struct i2c_client *client,
> >  			  const struct i2c_device_id *id)
> >  {
> >  	struct pcf85363 *pcf85363;
> > +	const struct pcf85x63_config *config = &pcf_85363_config;
> > +	const void *data = of_device_get_match_data(&client->dev);
> > +
> > +	if (data)
> > +		config = data;
> >
> >  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
> >  		return -ENODEV;
> > @@ -167,7 +189,7 @@ static int pcf85363_probe(struct i2c_client *client,
> >  	if (!pcf85363)
> >  		return -ENOMEM;
> >
> > -	pcf85363->regmap = devm_regmap_init_i2c(client,
> > &regmap_config);
> > +	pcf85363->regmap = devm_regmap_init_i2c(client,
> > &config->regmap);
> >  	if (IS_ERR(pcf85363->regmap)) {
> >  		dev_err(&client->dev, "regmap allocation failed\n");
> >  		return PTR_ERR(pcf85363->regmap);
> > @@ -185,12 +207,14 @@ static int pcf85363_probe(struct i2c_client
> > *client,
> >
> >  static const struct i2c_device_id pcf85363_id[] = {
> >  	{ "pcf85363", 0 },
> > +	{ "pcf85263", 0 },
> >  	{ }
> >  };
> >
> >  static const struct of_device_id dev_ids[] = {
> > -	{ .compatible = "nxp,pcf85363" },
> > -	{}
> > +	{ .compatible = "nxp,pcf85263", .data = &pcf_85263_config },
> > +	{ .compatible = "nxp,pcf85363", .data = &pcf_85363_config },
> > +	{ /* sentinel */ }
> >  };
> >  MODULE_DEVICE_TABLE(of, dev_ids);
> >
> > @@ -206,5 +230,5 @@ static struct i2c_driver pcf85363_driver = {
> > module_i2c_driver(pcf85363_driver);
> >
> >  MODULE_AUTHOR("Eric Nelson");
> > -MODULE_DESCRIPTION("pcf85363 I2C RTC driver");
> > +MODULE_DESCRIPTION("pcf85263/pcf85363 I2C RTC driver");
> >  MODULE_LICENSE("GPL");
> > --
> > 2.7.4
> >
> > _______________________________________________
> > cip-dev mailing list
> > cip-dev at lists.cip-project.org
> > https://lists.cip-project.org/mailman/listinfo/cip-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately
  2019-07-16 21:03   ` Pavel Machek
@ 2019-07-17  7:47     ` Biju Das
  2019-07-23 18:12       ` Ben Hutchings
  0 siblings, 1 reply; 19+ messages in thread
From: Biju Das @ 2019-07-17  7:47 UTC (permalink / raw)
  To: cip-dev

Hi Pavel,

Thanks for the feedback.

> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: Tuesday, July 16, 2019 10:04 PM
> To: Biju Das <biju.das@bp.renesas.com>
> Cc: cip-dev at lists.cip-project.org
> Subject: Re: [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time
> accurately
> 
> On Tue 2019-07-16 09:15:14, Biju Das wrote:
> > commit 188306ac9536ec47674ffa9dd330f69927679aeb upstream.
> >
> > As per 8.2.6 Setting and reading the time in RTC mode, first stop the
> > clok, then reset it before setting the date and time registers.
> > Finally, start the clock.
> >
> > This uses register address wrap around from 0x2f to 0x00 for
> > efficiency.
>
> How does wrap around work? AFAICT it is supposed to have ram at 0x40.
> 
Please see the document [1]  and [2] section 8, that have the details related to wrap around.
[1] https://www.nxp.com/docs/en/data-sheet/PCF85363A.pdf
[2] https://www.nxp.com/docs/en/data-sheet/PCF85263A.pdf

Regards,
Biju

> Does it really provide increased efficiency (given regmap layer in
> between) and will such trick cause problems in future? If regmap is not
> aware of register mirrors it might get confused and provide stale values, for
> example...
> 
> Best regards,
> 								Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures)
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock Biju Das
@ 2019-07-17 11:29   ` Pavel Machek
  0 siblings, 0 replies; 19+ messages in thread
From: Pavel Machek @ 2019-07-17 11:29 UTC (permalink / raw)
  To: cip-dev

On Tue 2019-07-16 09:15:12, Biju Das wrote:
> From: Eric Nelson <eric@nelint.com>
> 
> commit a9687aa2764dd2669602bd19dc636cbeef5293d5 upstream.
> 
> Note that alarms are not currently implemented.
> 
> 64 bytes of nvmem is supported and exposed in
> sysfs (# is the instance number, starting with 0):
> 
> 	/sys/bus/nvmem/devices/pcf85363-#/nvmem
>


Just FYI, git does not like your whitespace:

Applying: rtc: add support for NXP PCF85363 real-time clock
/data/pavel/cip/k/.git/rebase-apply/patch:32: new blank line at EOF.
+

Best regards,
							Pavel

>  Documentation/devicetree/bindings/rtc/pcf85363.txt |  17 ++
>  drivers/rtc/Kconfig                                |   9 +
>  drivers/rtc/Makefile                               |   1 +
>  drivers/rtc/rtc-pcf85363.c                         | 197 +++++++++++++++++++++
>  4 files changed, 224 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/rtc/pcf85363.txt
>  create mode 100644 drivers/rtc/rtc-pcf85363.c
> 
> diff --git a/Documentation/devicetree/bindings/rtc/pcf85363.txt b/Documentation/devicetree/bindings/rtc/pcf85363.txt
> new file mode 100644
> index 0000000..76fdabc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/pcf85363.txt
> @@ -0,0 +1,17 @@
> +NXP PCF85363 Real Time Clock
> +============================
> +
> +Required properties:
> +- compatible: Should contain "nxp,pcf85363".
> +- reg: I2C address for chip.
> +
> +Optional properties:
> +- interrupts: IRQ line for the RTC (not implemented).
> +
> +Example:
> +
> +pcf85363: pcf85363 at 51 {
> +	compatible = "nxp,pcf85363";
> +	reg = <0x51>;
> +};
> +

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190717/af0c24f1/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support
  2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
                   ` (9 preceding siblings ...)
  2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 10/10] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
@ 2019-07-17 11:45 ` Pavel Machek
  10 siblings, 0 replies; 19+ messages in thread
From: Pavel Machek @ 2019-07-17 11:45 UTC (permalink / raw)
  To: cip-dev

Hi!

> This patch series add RTC support for iWave iwg23s sbc based on RZ/G1C.
> 
> This patch series is based on linux-4.4.y-cip and all the patches
> in this series are cherry-picked from linux rc tree.

I have add Signed-off-by: in 5/10 and applied the series.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190717/f4c5b071/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2019-07-17  7:16     ` Biju Das
@ 2019-07-17 23:20       ` nobuhiro1.iwamatsu at toshiba.co.jp
  0 siblings, 0 replies; 19+ messages in thread
From: nobuhiro1.iwamatsu at toshiba.co.jp @ 2019-07-17 23:20 UTC (permalink / raw)
  To: cip-dev

Hi,

> -----Original Message-----
> From: Biju Das [mailto:biju.das at bp.renesas.com]
> Sent: Wednesday, July 17, 2019 4:16 PM
> To: iwamatsu nobuhiro(?? ?? ????????)
> <nobuhiro1.iwamatsu@toshiba.co.jp>; cip-dev at lists.cip-project.org
> Subject: RE: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support
> for NXP pcf85263 rtc
> 
> Hi Nobuhiro,
> 
> Thanks for the feedback.
> 
> > Subject: RE: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add
> > support for NXP pcf85263 rtc
> >
> > Hi,
> >
> > > -----Original Message-----
> > > From: cip-dev-bounces at lists.cip-project.org
> > > [mailto:cip-dev-bounces at lists.cip-project.org] On Behalf Of Biju Das
> > > Sent: Tuesday, July 16, 2019 5:15 PM
> > > To: cip-dev at lists.cip-project.org
> > > Cc: Biju Das <biju.das@bp.renesas.com>
> > > Subject: [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add
> > > support for NXP pcf85263 rtc
> > >
> > > commit fc979933bcf162595b6004d0de4effb64c323152 upstream.
> > >
> > > Add support for NXP pcf85263 real-time clock. pcf85263 rtc is
> > > compatible with pcf85363,except that pcf85363 has additional 64
> > > bytes of
> > RAM.
> > >
> > > 1 byte of nvmem is supported and exposed in sysfs (# is the instance
> > > number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem
> > >
> > > Signed-off-by: Biju Das <biju.das@bp.renesas.com> [ Removed rtc
> > > nvmem support. Added I2C ID table for rtc-pcf85263 ]
> >
> > You've deleted Alexandre's Signed-off-by tag from original patch.
> 
> Thanks for pointing this out. It is a mistake.  Can you please fix this
> while applying to the tree?
> 
> Or
> 
> Do you want me to send another patch fixing this? Please let me know.
> 

Pavel applied this patch with signed-off-by tag. Thanks Pavel.

Best regards,
  Nobuhiro

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately
  2019-07-17  7:47     ` Biju Das
@ 2019-07-23 18:12       ` Ben Hutchings
  0 siblings, 0 replies; 19+ messages in thread
From: Ben Hutchings @ 2019-07-23 18:12 UTC (permalink / raw)
  To: cip-dev

On Wed, 2019-07-17 at 07:47 +0000, Biju Das wrote:
> Hi Pavel,
> 
> Thanks for the feedback.
> 
> > -----Original Message-----
> > From: Pavel Machek <pavel@denx.de>
> > Sent: Tuesday, July 16, 2019 10:04 PM
> > To: Biju Das <biju.das@bp.renesas.com>
> > Cc: cip-dev at lists.cip-project.org
> > Subject: Re: [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time
> > accurately
> > 
> > On Tue 2019-07-16 09:15:14, Biju Das wrote:
> > > commit 188306ac9536ec47674ffa9dd330f69927679aeb upstream.
> > > 
> > > As per 8.2.6 Setting and reading the time in RTC mode, first stop the
> > > clok, then reset it before setting the date and time registers.
> > > Finally, start the clock.
> > > 
> > > This uses register address wrap around from 0x2f to 0x00 for
> > > efficiency.
> > 
> > How does wrap around work? AFAICT it is supposed to have ram at 0x40.
> > 
> Please see the document [1]  and [2] section 8, that have the details related to wrap around.
> [1] https://www.nxp.com/docs/en/data-sheet/PCF85363A.pdf
> [2] https://www.nxp.com/docs/en/data-sheet/PCF85263A.pdf

Regardless of what the hardware does...

> > Does it really provide increased efficiency (given regmap layer in
> > between) and will such trick cause problems in future? If regmap is not
> > aware of register mirrors it might get confused and provide stale values, for
> > example...

...I think Pavel is right on this point.  regmap doesn't seem to have
any provision for register addresses wrapping around, and it looks like
this causes a buffer overrun in the register cache.

Ben.

-- 
Ben Hutchings, Software Developer                         Codethink Ltd
https://www.codethink.co.uk/                 Dale House, 35 Dale Street
                                     Manchester, M1 2HF, United Kingdom

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-07-23 18:12 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16  8:15 [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 01/10] rtc: add support for NXP PCF85363 real-time clock Biju Das
2019-07-17 11:29   ` Pavel Machek
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 02/10] rtc: pcf85363: add .max_register in regmap_config Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 03/10] rtc: pcf85363: set time accurately Biju Das
2019-07-16 21:03   ` Pavel Machek
2019-07-17  7:47     ` Biju Das
2019-07-23 18:12       ` Ben Hutchings
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 04/10] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 05/10] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
2019-07-17  7:08   ` nobuhiro1.iwamatsu at toshiba.co.jp
2019-07-17  7:16     ` Biju Das
2019-07-17 23:20       ` nobuhiro1.iwamatsu at toshiba.co.jp
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 06/10] ARM: dts: r8a77470: Add I2C4 support Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 07/10] ARM: dts: r8a77470: Add I2C[0123] support Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 08/10] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 09/10] ARM: multi_v7_defconfig: Enable NXP pcf85363 rtc Biju Das
2019-07-16  8:15 ` [cip-dev] [PATCH 4.4.y-cip 10/10] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
2019-07-17 11:45 ` [cip-dev] [PATCH 4.4.y-cip 00/10] Add RTC support Pavel Machek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.