rtc: rv3029: Add update_bits helper for eeprom access
PATCH 1/2 rtc: rv3029: Add update_bits helper for eeprom access
In reply to a message not in the archiveThis simplifies the update of single bits in the eeprom.
--- drivers/rtc/rtc-rv3029c2.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
drivers/rtc/rtc-rv3029c2.c +25 -14
@@ -308,6 +308,24 @@ static int rv3029_eeprom_write(struct i2c_client *client, u8 reg,return ret; } +static int rv3029_eeprom_update_bits (struct i2c_client *client, +u8 reg,u8 mask,u8 set) +{ +u8 buf; +int ret; + + ret =rv3029_eeprom_read (client, reg, &buf,1 ); +if (ret <0 ) +return ret; + buf &= ~mask; + buf |= set & mask; + ret =rv3029_eeprom_write (client, reg, &buf,1 ); +if (ret <0 ) +return ret; + +return 0 ; +} +static int rv3029_i2c_read_time (struct i2c_client *client,struct rtc_time *tm) {
@@ -588,23 +606,16 @@ static void rv3029_trickle_config(struct i2c_client *client)const struct rv3029_trickle_tab_elem *elem;int i, err;u32 ohms; -u8 eectrl; +u8 trickle_set_bits;if (!of_node)return ;/* Configure the trickle charger. */ - err =rv3029_eeprom_read (client,RV3029_CONTROL_E2P_EECTRL , - &eectrl,1 ); -if (err <0 ) { -dev_err (&client->dev, -"Failed to read trickle charger config\n" ); -return ; - } err =of_property_read_u32 (of_node,"trickle-resistor-ohms" , &ohms);if (err) {/* Disable trickle charger. */ - eectrl &= ~RV3029_TRICKLE_MASK ; + trickle_set_bits =0 ; }else {/* Enable trickle charger. */ for (i =0 ; i <ARRAY_SIZE (rv3029_trickle_tab); i++) {
@@ -612,17 +623,17 @@ static void rv3029_trickle_config(struct i2c_client *client)if (elem->r >= ohms)break ; } - eectrl &= ~RV3029_TRICKLE_MASK ; - eectrl |= elem->conf; + trickle_set_bits = elem->conf;dev_info (&client->dev,"Trickle charger enabled at %d ohms resistance.\n" , elem->r); } - err =rv3029_eeprom_write (client,RV3029_CONTROL_E2P_EECTRL , - &eectrl,1 ); + err =rv3029_eeprom_update_bits (client,RV3029_CONTROL_E2P_EECTRL , +RV3029_TRICKLE_MASK , + trickle_set_bits);if (err <0 ) {dev_err (&client->dev, -"Failed to write trickle charger config\n" ); +"Failed to update trickle charger config\n" ); } }
Signature · 12 lines
2.7.0 -- -- 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.
PATCH 2/2 rtc: rv3029: Add thermometer hwmon support
In reply to a message not in the archiveThis adds support to
- enable/disable the thermometer
- set the temperature scanning interval
- read the current temperature that is used for temp compensation. via hwmon interface
--- drivers/rtc/Kconfig | 9 ++++ drivers/rtc/rtc-rv3029c2.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+)
drivers/rtc/Kconfig +9 -0
@@ -601,6 +601,15 @@ config RTC_DRV_RV3029C2 This driver can also be built as a module. If so, the module will be called rtc-rv3029c2. +config RTC_DRV_RV3029_HWMON + bool "HWMON support for RV3029" + depends on RTC_DRV_RV3029C2 && HWMON + depends on !(RTC_DRV_RV3029C2=y && HWMON=m) + default y + help + Say Y here if you want to expose temperature sensor data on + rtc-rv3029c2. + config RTC_DRV_RV8803 tristate "Micro Crystal RV8803" help
drivers/rtc/rtc-rv3029c2.c +120 -0
138 lines not on this page · raw message
Signature · 12 lines
2.7.0 -- -- 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.
Alexandre Belloni
AppliedQuoted 6 lines · On 10/03/2016 at 18:34:23 +0100, Michael B=C3=BCsch wrote :
This simplifies the update of single bits in the eeprom. =20
Signed-off-by Michael Buesch <[email protected]>--- drivers/rtc/rtc-rv3029c2.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
Applied, thanks.
--=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.
Alexandre Belloni
Applied[rtc-linux] Re: [PATCH 2/2] rtc: rv3029: Add thermometer hwmon support
In reply to Michael BüschQuoted 10 lines · On 10/03/2016 at 18:34:46 +0100, Michael B=C3=BCsch wrote :
This adds support to
- enable/disable the thermometer
- set the temperature scanning interval
- read the current temperature that is used for temp compensation. via hwmon interface
=20Signed-off-by Michael Buesch <[email protected]>--- drivers/rtc/Kconfig | 9 ++++
drivers/rtc/rtc-rv3029c2.c| 120 +++++++++++++++++++++++++++++++++++++++=
++++++
Quoted 2 lines
2 files changed, 129 insertions(+)=20
Applied, thanks.
--=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.