Skip to content

Commit 5b3a3ad

Browse files
rtc: pcf85063: add Micro Crystal RV8263 support
The Micro Crystal RV8263 has the same IC as the pcf85063 but has an on board crystal. This means that the CAP_SEL bit has to be cleared so the correct capacitance is selected for the crystal. Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 05cb3a5 commit 5b3a3ad

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Required properties:
44
- compatible: Should one of contain:
55
"nxp,pcf85063",
66
"nxp,pcf85063a",
7-
"nxp,pcf85063tp"
7+
"nxp,pcf85063tp",
8+
"microcrystal,rv8263"
89
- reg: I2C address for chip.
910

1011
Optional property:

drivers/rtc/rtc-pcf85063.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*
66
* Author: Søren Andersen <[email protected]>
77
* Maintainers: http://www.nslu2-linux.org/
8+
*
9+
* Copyright (C) 2019 Micro Crystal AG
10+
* Author: Alexandre Belloni <[email protected]>
811
*/
912
#include <linux/i2c.h>
1013
#include <linux/bcd.h>
@@ -22,7 +25,10 @@
2225
*
2326
* PCF85063A -- Rev. 6 — 18 November 2015
2427
* PCF85063TP -- Rev. 4 — 6 May 2015
25-
*/
28+
*
29+
* https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-8263-C7_App-Manual.pdf
30+
* RV8263 -- Rev. 1.0 — January 2019
31+
*/
2632

2733
#define PCF85063_REG_CTRL1 0x00 /* status */
2834
#define PCF85063_REG_CTRL1_CAP_SEL BIT(0)
@@ -41,6 +47,7 @@
4147
struct pcf85063_config {
4248
struct regmap_config regmap;
4349
unsigned has_alarms:1;
50+
unsigned force_cap_7000:1;
4451
};
4552

4653
struct pcf85063 {
@@ -230,12 +237,17 @@ static const struct rtc_class_ops pcf85063_rtc_ops_alarm = {
230237
};
231238

232239
static int pcf85063_load_capacitance(struct pcf85063 *pcf85063,
233-
const struct device_node *np)
240+
const struct device_node *np,
241+
unsigned int force_cap)
234242
{
235243
u32 load = 7000;
236244
u8 reg = 0;
237245

238-
of_property_read_u32(np, "quartz-load-femtofarads", &load);
246+
if (force_cap)
247+
load = force_cap;
248+
else
249+
of_property_read_u32(np, "quartz-load-femtofarads", &load);
250+
239251
switch (load) {
240252
default:
241253
dev_warn(&pcf85063->rtc->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 7000",
@@ -269,6 +281,16 @@ static const struct pcf85063_config pcf85063tp_config = {
269281
},
270282
};
271283

284+
static const struct pcf85063_config rv8263_config = {
285+
.regmap = {
286+
.reg_bits = 8,
287+
.val_bits = 8,
288+
.max_register = 0x11,
289+
},
290+
.has_alarms = 1,
291+
.force_cap_7000 = 1,
292+
};
293+
272294
static int pcf85063_probe(struct i2c_client *client)
273295
{
274296
struct pcf85063 *pcf85063;
@@ -303,7 +325,8 @@ static int pcf85063_probe(struct i2c_client *client)
303325
if (IS_ERR(pcf85063->rtc))
304326
return PTR_ERR(pcf85063->rtc);
305327

306-
err = pcf85063_load_capacitance(pcf85063, client->dev.of_node);
328+
err = pcf85063_load_capacitance(pcf85063, client->dev.of_node,
329+
config->force_cap_7000 ? 7000 : 0);
307330
if (err < 0)
308331
dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
309332
err);
@@ -339,6 +362,7 @@ static const struct of_device_id pcf85063_of_match[] = {
339362
{ .compatible = "nxp,pcf85063", .data = &pcf85063tp_config },
340363
{ .compatible = "nxp,pcf85063tp", .data = &pcf85063tp_config },
341364
{ .compatible = "nxp,pcf85063a", .data = &pcf85063a_config },
365+
{ .compatible = "microcrystal,rv8263", .data = &rv8263_config },
342366
{}
343367
};
344368
MODULE_DEVICE_TABLE(of, pcf85063_of_match);

0 commit comments

Comments
 (0)