devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Addding a property that silently breaks linux kernel driver?
@ 2018-09-06 21:18 Sam Ravnborg
  2018-09-07 10:40 ` Vladimir Zapolskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2018-09-06 21:18 UTC (permalink / raw)
  To: devicetree; +Cc: san

Hi all.

The NXP RTC support that two different capacitors are connected.
The default (what the RTC is programmed to after reset) is 7 pF.
But one may also connect 12.5 pF to save power.
To use the 12.5 pF the RTC needs to be properly configured.

The RTC can only support either 7 pF or 12.5 pF.

A wrongly configured RTC will loose several hours in a week.


We came up with the following binding:
==========================================
* NXP PCF8523 Real Time Clock

NXP PCF8523 Real Time Clock

Required properties:
- compatible: Should contain "nxp,pcf8523".
- reg: I2C address for chip.

Optional property:
- nxp,quartz_load_12.5pF: The capacitive load on the quartz is 12.5pf,
  which differ from the default value of 7pf

Example:

pcf8523: pcf8523@68 {
       compatible = "nxp,pcf85063";
       reg = <0x68>;
       nxp,quartz_load_12.5pF;
};
=======================================

The Q:
The above scheme will SILENTLY break out-of-tree Linux users because
we will change so if nothing is specified the RTC is configured to 7 pF.
And you need to specify if 12.5 pF is used.

But all users of the kernel driver will assume 12.5 pF, because this
is the driver default. But not the default of the RTC.

We will change all in-kernel device trees when we add this, but...

Should we try do do this in a way so we respect the current
kernel driver implmentation, or should we respect the reset default
value of the RTC?

	Sam

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

* Re: Addding a property that silently breaks linux kernel driver?
  2018-09-06 21:18 Addding a property that silently breaks linux kernel driver? Sam Ravnborg
@ 2018-09-07 10:40 ` Vladimir Zapolskiy
  2018-09-07 17:51   ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Zapolskiy @ 2018-09-07 10:40 UTC (permalink / raw)
  To: Sam Ravnborg, devicetree; +Cc: san

Hi Sam,

On 09/07/2018 12:18 AM, Sam Ravnborg wrote:
> Hi all.
> 
> The NXP RTC support that two different capacitors are connected.
> The default (what the RTC is programmed to after reset) is 7 pF.
> But one may also connect 12.5 pF to save power.
> To use the 12.5 pF the RTC needs to be properly configured.
> 
> The RTC can only support either 7 pF or 12.5 pF.
> 
> A wrongly configured RTC will loose several hours in a week.
> 
> 
> We came up with the following binding:
> ==========================================
> * NXP PCF8523 Real Time Clock
> 
> NXP PCF8523 Real Time Clock
> 
> Required properties:
> - compatible: Should contain "nxp,pcf8523".
> - reg: I2C address for chip.
> 
> Optional property:
> - nxp,quartz_load_12.5pF: The capacitive load on the quartz is 12.5pf,
>   which differ from the default value of 7pf
> 
> Example:
> 
> pcf8523: pcf8523@68 {
>        compatible = "nxp,pcf85063";
>        reg = <0x68>;
>        nxp,quartz_load_12.5pF;
> };
> =======================================
> 
> The Q:
> The above scheme will SILENTLY break out-of-tree Linux users because
> we will change so if nothing is specified the RTC is configured to 7 pF.

That's the expected behaviour.

> And you need to specify if 12.5 pF is used.
> 
> But all users of the kernel driver will assume 12.5 pF, because this
> is the driver default. But not the default of the RTC.

I've opened the driver rtc-pcf85063 and PCF85063A.pdf datasheet, and I don't
see why 12.5 pF internal oscillator capacitor selection is the default one,
it is not.

The only touched configuration of PCF85063_REG_CTRL1 register is STOP bit,
CAP_SEL bit value is unmodified by the driver.

So I would assume it should be fine just to add a new property for 12.5pF
load capacitance.

> 
> We will change all in-kernel device trees when we add this, but...
> 
> Should we try do do this in a way so we respect the current
> kernel driver implmentation, or should we respect the reset default
> value of the RTC?
> 
> 	Sam
> 

--
Best wishes,
Vladimir

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

* Re: Addding a property that silently breaks linux kernel driver?
  2018-09-07 10:40 ` Vladimir Zapolskiy
@ 2018-09-07 17:51   ` Sam Ravnborg
  0 siblings, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2018-09-07 17:51 UTC (permalink / raw)
  To: Vladimir Zapolskiy; +Cc: devicetree, san

Hi Vladimir.

Thanks for taking your time to investigate this!

> > The NXP RTC support that two different capacitors are connected.
> > The default (what the RTC is programmed to after reset) is 7 pF.
> > But one may also connect 12.5 pF to save power.
> > To use the 12.5 pF the RTC needs to be properly configured.
> > 
> > The RTC can only support either 7 pF or 12.5 pF.
> > 
> > A wrongly configured RTC will loose several hours in a week.
> > 
> > 
> > We came up with the following binding:
> > ==========================================
> > * NXP PCF8523 Real Time Clock
> > 
> > NXP PCF8523 Real Time Clock
> > 
> > Required properties:
> > - compatible: Should contain "nxp,pcf8523".
> > - reg: I2C address for chip.
> > 
> > Optional property:
> > - nxp,quartz_load_12.5pF: The capacitive load on the quartz is 12.5pf,
> >   which differ from the default value of 7pf
> > 
> > Example:
> > 
> > pcf8523: pcf8523@68 {
> >        compatible = "nxp,pcf85063";
> >        reg = <0x68>;
> >        nxp,quartz_load_12.5pF;
> > };
> > =======================================
> > 
> > The Q:
> > The above scheme will SILENTLY break out-of-tree Linux users because
> > we will change so if nothing is specified the RTC is configured to 7 pF.
> 
> That's the expected behaviour.
> 
> > And you need to specify if 12.5 pF is used.
> > 
> > But all users of the kernel driver will assume 12.5 pF, because this
> > is the driver default. But not the default of the RTC.
> 
> I've opened the driver rtc-pcf85063 and PCF85063A.pdf datasheet, and I don't
> see why 12.5 pF internal oscillator capacitor selection is the default one,
> it is not.
> 
> The only touched configuration of PCF85063_REG_CTRL1 register is STOP bit,
> CAP_SEL bit value is unmodified by the driver.
> 
> So I would assume it should be fine just to add a new property for 12.5pF
> load capacitance.

The rtc-pcf8523 set CAP_SEL to select an x-tal with 7 pF capacitance.
See the call to pcf8523_select_capacitance(client, true);

The rtc-pcf85063 driver will not touch the CAP-SEL bit, so the default value
of 0 (equals 7 pF) is kept.

So we have two drivers where one set 7 pF and the other 12.5 pF.

I will do a small re-spin of my patchset and post them for
further comments/discussions.

	Sam

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

end of thread, other threads:[~2018-09-07 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 21:18 Addding a property that silently breaks linux kernel driver? Sam Ravnborg
2018-09-07 10:40 ` Vladimir Zapolskiy
2018-09-07 17:51   ` Sam Ravnborg

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