Skip to content

Commit 0e2e877

Browse files
rtc: pcf85063: differentiate pcf85063a and pcf85063tp
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 <[email protected]>
1 parent e89b60d commit 0e2e877

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
* NXP PCF85063 Real Time Clock
22

33
Required properties:
4-
- compatible: Should contain "nxp,pcf85063".
4+
- compatible: Should one of contain:
5+
"nxp,pcf85063",
6+
"nxp,pcf85063a",
7+
"nxp,pcf85063tp"
58
- reg: I2C address for chip.
69

710
Optional property:

drivers/rtc/rtc-pcf85063.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#define PCF85063_REG_SC 0x04 /* datetime */
3131
#define PCF85063_REG_SC_OS 0x80
3232

33+
struct pcf85063_config {
34+
struct regmap_config regmap;
35+
};
36+
3337
struct pcf85063 {
3438
struct rtc_device *rtc;
3539
struct regmap *regmap;
@@ -147,17 +151,29 @@ static int pcf85063_load_capacitance(struct pcf85063 *pcf85063,
147151
PCF85063_REG_CTRL1_CAP_SEL, reg);
148152
}
149153

150-
static const struct regmap_config regmap_config = {
151-
.reg_bits = 8,
152-
.val_bits = 8,
153-
.max_register = 0x11,
154+
static const struct pcf85063_config pcf85063a_config = {
155+
.regmap = {
156+
.reg_bits = 8,
157+
.val_bits = 8,
158+
.max_register = 0x11,
159+
},
160+
};
161+
162+
static const struct pcf85063_config pcf85063tp_config = {
163+
.regmap = {
164+
.reg_bits = 8,
165+
.val_bits = 8,
166+
.max_register = 0x0a,
167+
},
154168
};
155169

156170
static int pcf85063_probe(struct i2c_client *client)
157171
{
158172
struct pcf85063 *pcf85063;
159173
unsigned int tmp;
160174
int err;
175+
const struct pcf85063_config *config = &pcf85063tp_config;
176+
const void *data = of_device_get_match_data(&client->dev);
161177

162178
dev_dbg(&client->dev, "%s\n", __func__);
163179

@@ -166,7 +182,10 @@ static int pcf85063_probe(struct i2c_client *client)
166182
if (!pcf85063)
167183
return -ENOMEM;
168184

169-
pcf85063->regmap = devm_regmap_init_i2c(client, &regmap_config);
185+
if (data)
186+
config = data;
187+
188+
pcf85063->regmap = devm_regmap_init_i2c(client, &config->regmap);
170189
if (IS_ERR(pcf85063->regmap))
171190
return PTR_ERR(pcf85063->regmap);
172191

@@ -196,7 +215,9 @@ static int pcf85063_probe(struct i2c_client *client)
196215

197216
#ifdef CONFIG_OF
198217
static const struct of_device_id pcf85063_of_match[] = {
199-
{ .compatible = "nxp,pcf85063" },
218+
{ .compatible = "nxp,pcf85063", .data = &pcf85063tp_config },
219+
{ .compatible = "nxp,pcf85063tp", .data = &pcf85063tp_config },
220+
{ .compatible = "nxp,pcf85063a", .data = &pcf85063a_config },
200221
{}
201222
};
202223
MODULE_DEVICE_TABLE(of, pcf85063_of_match);

0 commit comments

Comments
 (0)