]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rtc: pcf85063: differentiate pcf85063a and pcf85063tp
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 1 Apr 2019 16:08:11 +0000 (18:08 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 4 Apr 2019 08:07:11 +0000 (10:07 +0200)
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>
Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
drivers/rtc/rtc-pcf85063.c

index d3e380ad712d6ce089befccab53b0100252be71b..1e31afbfffe9974527121fdfdf55091fbfa4ab97 100644 (file)
@@ -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:
index 37be02a17addf61be7cd320ace03f957130f7554..cba60e7031c3dfad69e05bc45659566f92dd4b3d 100644 (file)
 #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);