linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063
@ 2018-09-24 11:23 Urs Fässler
  2018-09-24 11:23 ` [PATCH 2/2] rtc: pcf85063: add support for oscillator capacitor selection Urs Fässler
  2018-09-24 12:18 ` [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Alexandre Belloni
  0 siblings, 2 replies; 5+ messages in thread
From: Urs Fässler @ 2018-09-24 11:23 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, lukas.stockmann, pascal.bach, urs.fassler

Add a device tree property to configure the used capacitor for the
oscillator.

Signed-off-by: Urs Fässler <urs.fassler@bbv.ch>
Signed-off-by: Lukas Stockmann <lukas.stockmann@siemens.com>
Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
---
 .../devicetree/bindings/rtc/pcf85063.txt      | 20 +++++++++++++++++++
 .../devicetree/bindings/trivial-devices.txt   |  1 -
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/pcf85063.txt

diff --git a/Documentation/devicetree/bindings/rtc/pcf85063.txt b/Documentation/devicetree/bindings/rtc/pcf85063.txt
new file mode 100644
index 000000000000..e987d1042545
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/pcf85063.txt
@@ -0,0 +1,20 @@
+NXP PCF85063 Tiny Real Time Clock
+=================================
+
+Required properties:
+- compatible: should contain "nxp,pcf85063".
+- reg: I2C address for chip.
+
+Optional properties:
+- cap-sel: internal oscillator capacitor selection. Possible values are:
+	- 0: 7 pF
+	- 1: 12.5 pF
+	The selection is not changed if the property is not specified.
+
+Example:
+
+pcf85063: pcf85063@51 {
+	compatible = "nxp,pcf85063";
+	reg = <0x51>;
+	cap-sel = <1>;
+};
diff --git a/Documentation/devicetree/bindings/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt
index 763a2808a95c..abd3a818fb40 100644
--- a/Documentation/devicetree/bindings/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/trivial-devices.txt
@@ -171,7 +171,6 @@ nxp,pcf2127		Real-time clock
 nxp,pcf2129		Real-time clock
 nxp,pcf8523		Real-time Clock
 nxp,pcf8563		Real-time clock/calendar
-nxp,pcf85063		Tiny Real-Time Clock
 oki,ml86v7667		OKI ML86V7667 video decoder
 ovti,ov5642		OV5642: Color CMOS QSXGA (5-megapixel) Image Sensor with OmniBSI and Embedded TrueFocus
 pericom,pt7c4338	Real-time Clock Module
-- 
2.18.0

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

* [PATCH 2/2] rtc: pcf85063: add support for oscillator capacitor selection
  2018-09-24 11:23 [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Urs Fässler
@ 2018-09-24 11:23 ` Urs Fässler
  2018-09-24 12:18 ` [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Alexandre Belloni
  1 sibling, 0 replies; 5+ messages in thread
From: Urs Fässler @ 2018-09-24 11:23 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, lukas.stockmann, pascal.bach, urs.fassler

Configure the oscillator capacitor selection if specified.

Co-developed-by: Lukas Stockmann <lukas.stockmann@siemens.com>
Signed-off-by: Urs Fässler <urs.fassler@bbv.ch>
Signed-off-by: Lukas Stockmann <lukas.stockmann@siemens.com>
Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
---
 drivers/rtc/rtc-pcf85063.c | 54 +++++++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 283c2335b01b..69ee72f00164 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -180,21 +180,67 @@ static const struct rtc_class_ops pcf85063_rtc_ops = {
 	.set_time	= pcf85063_rtc_set_time
 };
 
+
+#ifdef CONFIG_OF
+static int setup_oscillator_capacitor(struct i2c_client *client, u8 ctrl1)
+{
+	int ret;
+	u32 cap_sel;
+
+	ret = of_property_read_u32(client->dev.of_node, "cap-sel", &cap_sel);
+	if (ret != 0) {
+		/* no capacitor selection defined, but that is ok */
+		return 0;
+	}
+
+	if ((cap_sel & 0xfe) != 0) {
+		dev_err(&client->dev,
+			 "Unsupported cap-sel value %u in dt\n", cap_sel);
+		return -EINVAL;
+	}
+
+	ctrl1 = (ctrl1 & 0xfe) | cap_sel;
+	ret = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ctrl1);
+
+	if (ret < 0) {
+		dev_err(&client->dev, "set oscillator capacitor failed\n");
+		return -EIO;
+	}
+
+	dev_info(&client->dev,
+		 "set oscillator capacitor selection to %u\n", cap_sel);
+
+	return 0;
+}
+#else
+static int setup_oscillator_capacitor(struct i2c_client *client, u8 ctrl1)
+{
+	return 0;
+}
+#endif
+
 static int pcf85063_probe(struct i2c_client *client,
 				const struct i2c_device_id *id)
 {
 	struct rtc_device *rtc;
-	int err;
+	int ret;
+	u8 ctrl1;
 
 	dev_dbg(&client->dev, "%s\n", __func__);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
 
-	err = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1);
-	if (err < 0) {
+	ret = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1);
+	if (ret < 0) {
 		dev_err(&client->dev, "RTC chip is not present\n");
-		return err;
+		return ret;
+	}
+	ctrl1 = ret;
+
+	ret = setup_oscillator_capacitor(client, ctrl1);
+	if (ret < 0) {
+		return ret;
 	}
 
 	rtc = devm_rtc_device_register(&client->dev,
-- 
2.18.0

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

* Re: [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063
  2018-09-24 11:23 [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Urs Fässler
  2018-09-24 11:23 ` [PATCH 2/2] rtc: pcf85063: add support for oscillator capacitor selection Urs Fässler
@ 2018-09-24 12:18 ` Alexandre Belloni
  2018-09-26 20:44   ` Sam Ravnborg
  1 sibling, 1 reply; 5+ messages in thread
From: Alexandre Belloni @ 2018-09-24 12:18 UTC (permalink / raw)
  To: Urs Fässler, Sam Ravnborg
  Cc: a.zummo, robh+dt, mark.rutland, linux-rtc, devicetree,
	lukas.stockmann, pascal.bach

Hello Urs,

You probably want to synchronize with Sam and his series:
http://patchwork.ozlabs.org/project/rtc-linux/list/?series=64664&state=*

On 24/09/2018 13:23:39+0200, Urs Fässler wrote:
> Add a device tree property to configure the used capacitor for the
> oscillator.
> 
> Signed-off-by: Urs Fässler <urs.fassler@bbv.ch>
> Signed-off-by: Lukas Stockmann <lukas.stockmann@siemens.com>
> Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
> ---
>  .../devicetree/bindings/rtc/pcf85063.txt      | 20 +++++++++++++++++++
>  .../devicetree/bindings/trivial-devices.txt   |  1 -
>  2 files changed, 20 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/rtc/pcf85063.txt
> 
> diff --git a/Documentation/devicetree/bindings/rtc/pcf85063.txt b/Documentation/devicetree/bindings/rtc/pcf85063.txt
> new file mode 100644
> index 000000000000..e987d1042545
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/pcf85063.txt
> @@ -0,0 +1,20 @@
> +NXP PCF85063 Tiny Real Time Clock
> +=================================
> +
> +Required properties:
> +- compatible: should contain "nxp,pcf85063".
> +- reg: I2C address for chip.
> +
> +Optional properties:
> +- cap-sel: internal oscillator capacitor selection. Possible values are:
> +	- 0: 7 pF
> +	- 1: 12.5 pF
> +	The selection is not changed if the property is not specified.
> +
> +Example:
> +
> +pcf85063: pcf85063@51 {
> +	compatible = "nxp,pcf85063";
> +	reg = <0x51>;
> +	cap-sel = <1>;
> +};
> diff --git a/Documentation/devicetree/bindings/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt
> index 763a2808a95c..abd3a818fb40 100644
> --- a/Documentation/devicetree/bindings/trivial-devices.txt
> +++ b/Documentation/devicetree/bindings/trivial-devices.txt
> @@ -171,7 +171,6 @@ nxp,pcf2127		Real-time clock
>  nxp,pcf2129		Real-time clock
>  nxp,pcf8523		Real-time Clock
>  nxp,pcf8563		Real-time clock/calendar
> -nxp,pcf85063		Tiny Real-Time Clock
>  oki,ml86v7667		OKI ML86V7667 video decoder
>  ovti,ov5642		OV5642: Color CMOS QSXGA (5-megapixel) Image Sensor with OmniBSI and Embedded TrueFocus
>  pericom,pt7c4338	Real-time Clock Module
> -- 
> 2.18.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063
  2018-09-24 12:18 ` [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Alexandre Belloni
@ 2018-09-26 20:44   ` Sam Ravnborg
  2018-10-03  9:01     ` Urs Fässler
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2018-09-26 20:44 UTC (permalink / raw)
  To: Alexandre Belloni, Urs Fässler
  Cc: Urs Fässler, a.zummo, robh+dt, mark.rutland, linux-rtc,
	devicetree, lukas.stockmann, pascal.bach

Hi Urs.

On Mon, Sep 24, 2018 at 02:18:02PM +0200, Alexandre Belloni wrote:
> Hello Urs,
> 
> You probably want to synchronize with Sam and his series:
> http://patchwork.ozlabs.org/project/rtc-linux/list/?series=64664&state=*

We will likely add a new property that can be used
in general. See above mail series (recent mails).

I will copy you on my next submission (in a week or so).

	Sam

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

* Re: [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063
  2018-09-26 20:44   ` Sam Ravnborg
@ 2018-10-03  9:01     ` Urs Fässler
  0 siblings, 0 replies; 5+ messages in thread
From: Urs Fässler @ 2018-10-03  9:01 UTC (permalink / raw)
  To: Sam Ravnborg, Alexandre Belloni
  Cc: a.zummo, robh+dt, mark.rutland, linux-rtc, devicetree,
	lukas.stockmann, pascal.bach

Hi Sam,
I reviewed your patch. I would also recommend to remove the "nxp,"
prefix for the device tree property. Otherwise we are be happy to use
our patch since it fulfills our needs and is more general than our
version.

Urs


On Wed, 2018-09-26 at 22:44 +0200, Sam Ravnborg wrote:
> Hi Urs.
> 
> On Mon, Sep 24, 2018 at 02:18:02PM +0200, Alexandre Belloni wrote:
> > Hello Urs,
> > 
> > You probably want to synchronize with Sam and his series:
> > http://patchwork.ozlabs.org/project/rtc-linux/list/?series=64664&state=*
> 
> We will likely add a new property that can be used
> in general. See above mail series (recent mails).
> 
> I will copy you on my next submission (in a week or so).
> 
> 	Sam


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

end of thread, other threads:[~2018-10-03  9:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-24 11:23 [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Urs Fässler
2018-09-24 11:23 ` [PATCH 2/2] rtc: pcf85063: add support for oscillator capacitor selection Urs Fässler
2018-09-24 12:18 ` [PATCH 1/2] dt-bindings: rtc: add capacitor selection for pcf85063 Alexandre Belloni
2018-09-26 20:44   ` Sam Ravnborg
2018-10-03  9:01     ` Urs Fässler

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).