Skip to contentSkip to conversation

rv3029 EEPROM handling

rtc-linux Michael Büsch 2 participants 10 messages Feb 27, 2016 – Feb 29, 2016 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

Hi,

I'm currently trying to use the Linux RV3029 RTC driver for one of my applications. So far the basic functionality works fine. However I need a way to (initially) program the EEPROM on the RTC chip to enable such things as temperature compensation or the trickle charger.
As of now the Linux driver does not support that though. So I'm wondering how we should implement that. As an initial idea I think we could have about some sysfs attributes for these settings. Is there a better way (more standard API) to do this?
If not, I'll do an implementation of this based on sysfs attributes.

Signature · 12 lines
Michael

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

Hi,

Quoted 11 lines · On 27/02/2016 at 15:39:18 +0100, Michael B=C3=BCsch wrote :

I'm currently trying to use the Linux RV3029 RTC driver for one of my applications. So far the basic functionality works fine. However I need a way to (initially) program the EEPROM on the RTC chip to enable such things as temperature compensation or the trickle charger.
As of now the Linux driver does not support that though. So I'm wondering how we should implement that. As an initial idea I think we could have about some sysfs attributes for these settings. Is there a better way (more standard API) to do this?
If not, I'll do an implementation of this based on sysfs attributes. =20

trickle charging is usually enabled using device tree, however, I'd really like to see more standardization on the property names.

I'm not sure yet about the temperature compensation. I've just merged the crystal offset modification api with a sysfs interface in rtc-next:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?h=3D=
rtc-next&id=3D5f23807caab7801c3333c68417bb13c7e2439193

But this doesn't seem enough for that particular RTC.

--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--=20
--=20
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "= rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 2 lines · On Sun, 28 Feb 2016 01:31:39 +0100 Alexandre Belloni…

trickle charging is usually enabled using device tree, however, I'd really like to see more standardization on the property names.

Is there an example of an rtc driver implementing this?
For the rv3029 it's more than just enabling it. It also has a bunch of charging resistors to choose from.

Quoted 5 lines

I'm not sure yet about the temperature compensation. I've just merged the crystal offset modification api with a sysfs interface in rtc-next:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?h=rtc-next&id=5f23807caab7801c3333c68417bb13c7e2439193

But this doesn't seem enough for that particular RTC.

The rv3029 does the compensation internally. It just needs to be enabled via a bit in its EEPROM. We could probably always set that bit though. I'm not sure whether there is a case where one would not want that.

Signature · 12 lines
Michael

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#3 lore raw
Quoted 10 lines · On 28/02/2016 at 09:44:52 +0100, Michael B=C3=BCsch wrote :

On Sun, 28 Feb 2016 01:31:39 +0100
Alexandre Belloni <[email protected]> wrote:
=20

Quoted 2 lines

trickle charging is usually enabled using device tree, however, I'd really like to see more standardization on the property names.

=20
Is there an example of an rtc driver implementing this?
For the rv3029 it's more than just enabling it. It also has a bunch of charging resistors to choose from.
=20

ds1339, ds1390 and bq32k are using trickle-resistor-ohms and trickle-diode-disable.

Quoted 3 lines
Quoted 3 lines

I'm not sure yet about the temperature compensation. I've just merged the crystal offset modification api with a sysfs interface in rtc-next:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?=

h=3Drtc-next&id=3D5f23807caab7801c3333c68417bb13c7e2439193

Quoted 8 lines
Quoted 2 lines

=20
But this doesn't seem enough for that particular RTC.

=20
The rv3029 does the compensation internally. It just needs to be enabled via a bit in its EEPROM. We could probably always set that bit though. I'm not sure whether there is a case where one would not want that.
=20

If you want to enable it without changing the values, just enable it unconditionally.

--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--=20
--=20
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "= rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
Quoted 2 lines · On Sun, 28 Feb 2016 11:41:10 +0100 Alexandre Belloni…

ds1339, ds1390 and bq32k are using trickle-resistor-ohms and trickle-diode-disable.

The rv3029 datasheet doesn't say anything about a diode (I think it still has one though). It merely talks about resistors connected between vdd and the battery pin.
So I'm not sure whether we should use the 'trickle-diode-disable' property here. One other possibility would be to use trickle-resistor-ohms=-1 or such to disable the charger.

Quoted 8 lines
Quoted 5 lines

The rv3029 does the compensation internally. It just needs to be enabled via a bit in its EEPROM. We could probably always set that bit though. I'm not sure whether there is a case where one would not want that.

If you want to enable it without changing the values, just enable it unconditionally.

I think the internal temperature compensation should be enabled by default and be disabled via DT property ('temp-compensation-disable' or such).

Signature · 12 lines
Michael

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#5 lore raw
Quoted 5 lines · On 28/02/2016 at 12:58:52 +0100, Michael B=C3=BCsch wrote :

On Sun, 28 Feb 2016 11:41:10 +0100
Alexandre Belloni <[email protected]> wrote:
=20

Quoted 2 lines

ds1339, ds1390 and bq32k are using trickle-resistor-ohms and trickle-diode-disable.

Quoted 9 lines

=20
=20
The rv3029 datasheet doesn't say anything about a diode (I think it still has one though). It merely talks about resistors connected between vdd and the battery pin.
So I'm not sure whether we should use the 'trickle-diode-disable' property here. One other possibility would be to use trickle-resistor-ohms=3D-1 or such to disable the charger. =20

More simply, don't enable the trickle charger if the trickle-resistor-ohms property is missing.

Leave out the trickle-diode-disable property

Quoted 3 lines

=20

Quoted 2 lines
Quoted 2 lines

The rv3029 does the compensation internally. It just needs to be enabled via a bit in its EEPROM. We could probably always set that bi=

t

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

though. I'm not sure whether there is a case where one would not want that.
=20

=20
If you want to enable it without changing the values, just enable it unconditionally.

Quoted 6 lines

=20
=20
I think the internal temperature compensation should be enabled by default and be disabled via DT property ('temp-compensation-disable' or such).
=20

That part is not HW related, it should not be in the device tree. I'd really just enable the temperature compensation else, this has to be done in sysfs

--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--=20
--=20
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "= rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

#6 lore raw
Quoted 4 lines · On Sun, 28 Feb 2016 13:36:18 +0100 Alexandre Belloni…

More simply, don't enable the trickle charger if the trickle-resistor-ohms property is missing.

Leave out the trickle-diode-disable property

D'oh indeed. :)

The rv3029 has a clkout pin that can be configured to various frequencies. So I added a 'clkout-hz' property for this.

Quoted 3 lines

That part is not HW related, it should not be in the device tree. I'd really just enable the temperature compensation else, this has to be done in sysfs

Ok.

Just for the record:
I started an initial implementation of this here in the rv3029 branch:
git://git.bues.ch/linux.git
http://bues.ch/gitweb?p=linux.git;a=shortlog;h=refs/heads/rv3029

Signature · 12 lines
Michael

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#7 lore raw
Quoted 7 lines · On 28/02/2016 at 18:14:50 +0100, Michael B=C3=BCsch wrote :

On Sun, 28 Feb 2016 13:36:18 +0100
Alexandre Belloni <[email protected]> wrote:
=20

Quoted 4 lines

More simply, don't enable the trickle charger if the trickle-resistor-ohms property is missing. =20
Leave out the trickle-diode-disable property

Quoted 6 lines

=20
D'oh indeed. :)
=20
The rv3029 has a clkout pin that can be configured to various frequencies. So I added a 'clkout-hz' property for this. =20

No, you have to use the CCF for that. For a recent example, see:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?h=3D=
rtc-next&id=3D578bb1d82bdd7fb86d5988fb775c871521a2761f

Quoted 10 lines
Quoted 3 lines

That part is not HW related, it should not be in the device tree. I'd really just enable the temperature compensation else, this has to be done in sysfs

=20
Ok.
=20
Just for the record:
I started an initial implementation of this here in the rv3029 branch:
git://git.bues.ch/linux.git
http://bues.ch/gitweb?p=3Dlinux.git;a=3Dshortlog;h=3Drefs/heads/rv3029

I had a really quick look, I'll review when you post patches. Please separate each functionality when submitting and use checkpatch.pl --strict

Also, to export the temperature, use hwmon, see:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?h=3D=
rtc-next&id=3D445c02076f1e60d2ee51503bf1288ef9f3bc8809

You may want to use regmap instead of defining your own update_bits (rv3029c2_i2c_maskset_reg) but that is a more invasie change that you may leave out for now.
--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--=20
--=20
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "= rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

#8 lore raw
Quoted 5 lines · On Sun, 28 Feb 2016 22:39:20 +0100 Alexandre Belloni…
Quoted 3 lines

The rv3029 has a clkout pin that can be configured to various frequencies. So I added a 'clkout-hz' property for this.

No, you have to use the CCF for that.

Oh, yes. That makes sense.

Quoted 2 lines

I had a really quick look, I'll review when you post patches. Please separate each functionality when submitting and use checkpatch.pl --strict

Yes, of course. Thanks for the hint. I'm not submitting stuff for the first time, though. :)

Quoted 2 lines

Also, to export the temperature, use hwmon, see:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?h=rtc-next&id=445c02076f1e60d2ee51503bf1288ef9f3bc8809

That is a rather weird API.
Is there a special naming scheme required for the attribute? What does the 'input' mean in 'temp1_input'? And why is it temp1 instead of temp0?

Quoted 3 lines

You may want to use regmap instead of defining your own update_bits (rv3029c2_i2c_maskset_reg) but that is a more invasie change that you may leave out for now.

Ok, I will do this last.
Don't hold your breath. :)

Signature · 12 lines
Michael

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#9 lore raw
Quoted 2 lines · On 29/02/2016 at 18:07:49 +0100, Michael B=C3=BCsch wrote :
Quoted 2 lines

Also, to export the temperature, use hwmon, see:
http://git.kernel.org/cgit/linux/kernel/git/abelloni/linux.git/commit/?=

h=3Drtc-next&id=3D445c02076f1e60d2ee51503bf1288ef9f3bc8809

Quoted 5 lines

=20
That is a rather weird API.
Is there a special naming scheme required for the attribute? What does the 'input' mean in 'temp1_input'? And why is it temp1 instead of temp0?

It means that you can read the value as opposed to output it for example on a 3d printing nozzle.

I'm not sure why it is indexed starting with 1 but probably because usually that's how user documentation is written. You'd have to ask the hwmon maintainers ;)

Quoted 8 lines

=20

Quoted 3 lines

You may want to use regmap instead of defining your own update_bits (rv3029c2_i2c_maskset_reg) but that is a more invasie change that you may leave out for now.

=20
Ok, I will do this last.
Don't hold your breath. :)
=20

I'm not even sure this is a good idea but I'd need to have a look at the code to know ;)

--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

--=20
--=20
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "= rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected].
For more options, visit https://groups.google.com/d/optout.