linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: linux-rtc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH 07/12] rtc: pcf85063: differentiate pcf85063a and pcf85063tp
Date: Mon,  1 Apr 2019 18:08:11 +0200	[thread overview]
Message-ID: <20190401160816.17859-7-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20190401160816.17859-1-alexandre.belloni@bootlin.com>

As stated in a comment pcf85063a and pcf85063tp don't have the same number
of registers. Especially, pcf85063tp doesn't have alarm support.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 .../devicetree/bindings/rtc/nxp,pcf85063.txt  |  5 ++-
 drivers/rtc/rtc-pcf85063.c                    | 33 +++++++++++++++----
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
index d3e380ad712d..1e31afbfffe9 100644
--- a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
+++ b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
@@ -1,7 +1,10 @@
 * NXP PCF85063 Real Time Clock
 
 Required properties:
-- compatible: Should contain "nxp,pcf85063".
+- compatible: Should one of contain:
+	"nxp,pcf85063",
+	"nxp,pcf85063a",
+	"nxp,pcf85063tp"
 - reg: I2C address for chip.
 
 Optional property:
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 632e1c8a3957..7519da905128 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -30,6 +30,10 @@
 #define PCF85063_REG_SC			0x04 /* datetime */
 #define PCF85063_REG_SC_OS		0x80
 
+struct pcf85063_config {
+	struct regmap_config regmap;
+};
+
 struct pcf85063 {
 	struct rtc_device	*rtc;
 	struct regmap		*regmap;
@@ -147,10 +151,20 @@ static int pcf85063_load_capacitance(struct pcf85063 *pcf85063,
 				  PCF85063_REG_CTRL1_CAP_SEL, reg);
 }
 
-static const struct regmap_config regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-	.max_register = 0x11,
+static const struct pcf85063_config pcf85063a_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x11,
+	},
+};
+
+static const struct pcf85063_config pcf85063tp_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x0a,
+	},
 };
 
 static int pcf85063_probe(struct i2c_client *client)
@@ -158,6 +172,8 @@ static int pcf85063_probe(struct i2c_client *client)
 	struct pcf85063 *pcf85063;
 	unsigned int tmp;
 	int err;
+	const struct pcf85063_config *config = &pcf85063tp_config;
+	const void *data = of_device_get_match_data(&client->dev);
 
 	dev_dbg(&client->dev, "%s\n", __func__);
 
@@ -166,7 +182,10 @@ static int pcf85063_probe(struct i2c_client *client)
 	if (!pcf85063)
 		return -ENOMEM;
 
-	pcf85063->regmap = devm_regmap_init_i2c(client, &regmap_config);
+	if (data)
+		config = data;
+
+	pcf85063->regmap = devm_regmap_init_i2c(client, &config->regmap);
 	if (IS_ERR(pcf85063->regmap))
 		return PTR_ERR(pcf85063->regmap);
 
@@ -196,7 +215,9 @@ static int pcf85063_probe(struct i2c_client *client)
 
 #ifdef CONFIG_OF
 static const struct of_device_id pcf85063_of_match[] = {
-	{ .compatible = "nxp,pcf85063" },
+	{ .compatible = "nxp,pcf85063", .data = &pcf85063tp_config },
+	{ .compatible = "nxp,pcf85063tp", .data = &pcf85063tp_config },
+	{ .compatible = "nxp,pcf85063a", .data = &pcf85063a_config },
 	{}
 };
 MODULE_DEVICE_TABLE(of, pcf85063_of_match);
-- 
2.20.1


  parent reply	other threads:[~2019-04-01 16:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 16:08 [PATCH 01/12] rtc: pcf85063: switch to probe_new Alexandre Belloni
2019-04-01 16:08 ` [PATCH 02/12] rtc: pcf85063: convert to SPDX identifier Alexandre Belloni
2019-04-01 16:16   ` Joe Perches
2019-04-01 16:29     ` Alexandre Belloni
2019-04-01 16:33   ` [PATCH v2 " Alexandre Belloni
2019-04-01 16:08 ` [PATCH 03/12] rtc: pcf85063: remove bogus i2c functionality check Alexandre Belloni
2019-04-01 16:08 ` [PATCH 04/12] rtc: pcf85063: convert to devm_rtc_allocate_device Alexandre Belloni
2019-04-01 16:08 ` [PATCH 05/12] rtc: pcf85063: set range Alexandre Belloni
2019-04-01 16:08 ` [PATCH 06/12] rtc: pcf85063: switch to regmap Alexandre Belloni
2019-04-01 16:08 ` Alexandre Belloni [this message]
2019-04-01 16:08 ` [PATCH 08/12] rtc: pcf85063: add alarm support Alexandre Belloni
2019-04-01 16:08 ` [PATCH 09/12] rtc: pcf85063: Add Micro Crystal RV8263 support Alexandre Belloni
2019-04-01 16:08 ` [PATCH 10/12] rtc: pcf85063: add nvram support Alexandre Belloni
2019-04-01 16:08 ` [PATCH 11/12] rtc: pcf85063: add offset correction support Alexandre Belloni
2019-04-01 16:08 ` [PATCH 12/12] rtc: pcf85063: add RTC_VL_READ/RTC_VL_CLR support Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401160816.17859-7-alexandre.belloni@bootlin.com \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).