rtc: Implement support for EPSON RX-8035
Subsystems (2)
v2 cover rtc: Implement support for EPSON RX-8035
The EPSON RX-8035[SA] is a I2C real time clock module with built-in oscillator[1]. It is a very close relative of the EPSON RX-8025 that is supported by the rtc-rx8025 driver.
The main difference is that the RX-8035 has inverted the 'oscillator stop' bit in the control register. The operation of the devices is otherwise identical for the features currently supported.
Curiously, the RX-8025 is also supported by the ds1307 driver as the time register set is compatible. The control registers, however, are not.
I have decided to implement the RX-8035 in rtc-rx8025 due the simplicity of that driver.
As best as I can determine, the rtc-rx8025 driver was in the tree some months[1] before rx8025 support was added to ds1307[2].
[1] - https://www5.epsondevice.com/en/products/rtc/rx8035sa.html
[2] - commit 3c2b9075cbdb541dbe486bde45925c9610de6f35
[3] - commit a216685818a54b4f15235068b53908f954850251
Changes in v2:
Coding style fixes as per suggestions
Use 'model' instead of 'type' in drvdata
Call rx8025_is_osc_stopped in a consistent manner
Mathew McBride (2):
rtc: rx8025: implement RX-8035 support
dt-bindings: rtc: add Epson RX-8025 and RX-8035
.../devicetree/bindings/rtc/trivial-rtc.yaml | 3 + drivers/rtc/rtc-rx8025.c | 59 +++++++++++++++++-- 2 files changed, 57 insertions(+), 5 deletions(-)
Signature · 1 line
2.30.1
PATCH v2 1/2 rtc: rx8025: implement RX-8035 support
The RX-8035 is a newer RTC from EPSON that is very similar to the RX-8025.
The key difference is in the oscillation stop (XSTP) bit which is inverted on the RX-8035.
--- drivers/rtc/rtc-rx8025.c | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-)
drivers/rtc/rtc-rx8025.c +53 -5
@@ -60,14 +60,23 @@#define RX8025_ADJ_DATA_MAX 62#define RX8025_ADJ_DATA_MIN -62 +enum rx_model { + model_rx_unknown, + model_rx_8025, + model_rx_8035, + model_last +}; +static const struct i2c_device_id rx8025_id[] = { - {"rx8025" ,0 }, + {"rx8025" , model_rx_8025 }, + {"rx8035" , model_rx_8035 }, { } };MODULE_DEVICE_TABLE (i2c, rx8025_id);struct rx8025_data {struct rtc_device *rtc; +enum rx_model model;u8 ctrl1; };
@@ -100,10 +109,26 @@ static s32 rx8025_write_regs(const struct i2c_client *client, length, values); } +static int rx8025_is_osc_stopped (enum rx_model model,int ctrl2) +{ +int xstp = ctrl2 &RX8025_BIT_CTRL2_XST ; +/* XSTP bit has different polarity on RX-8025 vs RX-8035. +* RX-8025: 0 == oscillator stopped +* RX-8035: 1 == oscillator stopped +*/ + +if (model == model_rx_8025) + xstp = !xstp; + +return xstp; +} +static int rx8025_check_validity (struct device *dev) {struct i2c_client *client =to_i2c_client (dev); +struct rx8025_data *drvdata =dev_get_drvdata (dev);int ctrl2; +int xstp; ctrl2 =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (ctrl2 <0 )
@@ -117,7 +142,8 @@ static int rx8025_check_validity(struct device *dev)return -EINVAL ; } -if (!(ctrl2 &RX8025_BIT_CTRL2_XST )) { + xstp =rx8025_is_osc_stopped (drvdata->model, ctrl2); +if (xstp) {dev_warn (dev,"crystal stopped, date is invalid\n" );return -EINVAL ; }
@@ -127,6 +153,7 @@ static int rx8025_check_validity(struct device *dev)static int rx8025_reset_validity (struct i2c_client *client) { +struct rx8025_data *drvdata =i2c_get_clientdata (client);int ctrl2 =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (ctrl2 <0 )
@@ -134,22 +161,28 @@ static int rx8025_reset_validity(struct i2c_client *client) ctrl2 &= ~(RX8025_BIT_CTRL2_PON |RX8025_BIT_CTRL2_VDET ); +if (drvdata->model == model_rx_8025) + ctrl2 |=RX8025_BIT_CTRL2_XST ; +else + ctrl2 &= ~(RX8025_BIT_CTRL2_XST ); +return rx8025_write_reg (client,RX8025_REG_CTRL2 , - ctrl2 |RX8025_BIT_CTRL2_XST ); + ctrl2); }static irqreturn_t rx8025_handle_irq (int irq,void *dev_id) {struct i2c_client *client = dev_id;struct rx8025_data *rx8025 =i2c_get_clientdata (client); -int status; +int status, xstp;rtc_lock (rx8025->rtc); status =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (status <0 ) goto out; -if (!(status &RX8025_BIT_CTRL2_XST )) + xstp =rx8025_is_osc_stopped (rx8025->model, status); +if (xstp)dev_warn (&client->dev,"Oscillation stop was detected," "you may have to readjust the clock\n" );
@@ -519,6 +552,21 @@ static int rx8025_probe(struct i2c_client *client,i2c_set_clientdata (client, rx8025); +if (id) { + rx8025->model = id->driver_data; +switch (rx8025->model) { +case model_rx_8025: +dev_info (&client->dev,"Model RX-8025" ); +break ; +case model_rx_8035: +dev_info (&client->dev,"Model RX-8035" ); +break ; +default : +dev_warn (&client->dev,"Unknown model: %d\n" , rx8025->model); +break ; + } + } + err =rx8025_init_client (client);if (err)return err;
Signature · 1 line
2.30.1
Re: [PATCH v2 1/2] rtc: rx8025: implement RX-8035 support
Hi,
2021年7月9日(金) 13:45 Mathew McBride <[email protected]>:
Quoted 8 lines
The RX-8035 is a newer RTC from EPSON that is very similar to the RX-8025.
The key difference is in the oscillation stop (XSTP) bit which is inverted on the RX-8035.
Signed-off-by Mathew McBride <[email protected]>
Reviewed- by: Nobuhiro Iwamatsu <[email protected]>
Best regards,
Nobuhiro
Quoted 135 lines
--- drivers/rtc/rtc-rx8025.c | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-)drivers/rtc/rtc-rx8025.c +53
-6@@ -60,14 +60,23 @@#define RX8025_ADJ_DATA_MAX 62#define RX8025_ADJ_DATA_MIN -62 +enum rx_model { + model_rx_unknown, + model_rx_8025, + model_rx_8035, + model_last +}; +static const struct i2c_device_id rx8025_id[] = { - {"rx8025" ,0 }, + {"rx8025" , model_rx_8025 }, + {"rx8035" , model_rx_8035 }, { } };MODULE_DEVICE_TABLE (i2c, rx8025_id);struct rx8025_data {struct rtc_device *rtc; +enum rx_model model;u8 ctrl1; };@@ -100,10 +109,26 @@ static s32 rx8025_write_regs(const struct i2c_client *client, length, values); } +static int rx8025_is_osc_stopped (enum rx_model model,int ctrl2) +{ +int xstp = ctrl2 &RX8025_BIT_CTRL2_XST ; +/* XSTP bit has different polarity on RX-8025 vs RX-8035. +* RX-8025: 0 == oscillator stopped +* RX-8035: 1 == oscillator stopped +*/ + +if (model == model_rx_8025) + xstp = !xstp; + +return xstp; +} +static int rx8025_check_validity (struct device *dev) {struct i2c_client *client =to_i2c_client (dev); +struct rx8025_data *drvdata =dev_get_drvdata (dev);int ctrl2; +int xstp; ctrl2 =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (ctrl2 <0 )@@ -117,7 +142,8 @@ static int rx8025_check_validity(struct device *dev)return -EINVAL ; } -if (!(ctrl2 &RX8025_BIT_CTRL2_XST )) { + xstp =rx8025_is_osc_stopped (drvdata->model, ctrl2); +if (xstp) {dev_warn (dev,"crystal stopped, date is invalid\n" );return -EINVAL ; }@@ -127,6 +153,7 @@ static int rx8025_check_validity(struct device *dev)static int rx8025_reset_validity (struct i2c_client *client) { +struct rx8025_data *drvdata =i2c_get_clientdata (client);int ctrl2 =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (ctrl2 <0 )@@ -134,22 +161,28 @@ static int rx8025_reset_validity(struct i2c_client *client) ctrl2 &= ~(RX8025_BIT_CTRL2_PON |RX8025_BIT_CTRL2_VDET ); +if (drvdata->model == model_rx_8025) + ctrl2 |=RX8025_BIT_CTRL2_XST ; +else + ctrl2 &= ~(RX8025_BIT_CTRL2_XST ); +return rx8025_write_reg (client,RX8025_REG_CTRL2 , - ctrl2 |RX8025_BIT_CTRL2_XST ); + ctrl2); }static irqreturn_t rx8025_handle_irq (int irq,void *dev_id) {struct i2c_client *client = dev_id;struct rx8025_data *rx8025 =i2c_get_clientdata (client); -int status; +int status, xstp;rtc_lock (rx8025->rtc); status =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (status <0 ) goto out; -if (!(status &RX8025_BIT_CTRL2_XST )) + xstp =rx8025_is_osc_stopped (rx8025->model, status); +if (xstp)dev_warn (&client->dev,"Oscillation stop was detected," "you may have to readjust the clock\n" );@@ -519,6 +552,21 @@ static int rx8025_probe(struct i2c_client *client,i2c_set_clientdata (client, rx8025); +if (id) { + rx8025->model = id->driver_data; +switch (rx8025->model) { +case model_rx_8025: +dev_info (&client->dev,"Model RX-8025" ); +break ; +case model_rx_8035: +dev_info (&client->dev,"Model RX-8035" ); +break ; +default : +dev_warn (&client->dev,"Unknown model: %d\n" , rx8025->model); +break ; + } + } + err =rx8025_init_client (client);if (err)return err; --2.30.1
Signature · 3 lines
Nobuhiro Iwamatsu
iwamatsu at {nigauri.org / debian.org}
GPG ID: 40AD1FA6PATCH v2 2/2 dt-bindings: rtc: add Epson RX-8025 and RX-8035
In reply to Mathew McBrideThese are supported by the rtc-rx8025 module. RX-8025 also has support in ds1307 due to compatible time registers.
--- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +3 -0
@@ -32,6 +32,9 @@ properties: - dallas,ds3232 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE - epson,rx8010 + # I2C-BUS INTERFACE REAL TIME CLOCK MODULE + - epson,rx8025 + - epson,rx8035 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE with Battery Backed RAM - epson,rx8571 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE
Signature · 1 line
2.30.1
Re: [PATCH v2 2/2] dt-bindings: rtc: add Epson RX-8025 and RX-8035
Quoted 8 lines · Mathew McBride
These are supported by the rtc-rx8025 module. RX-8025 also has support in ds1307 due to compatible time registers.
Signed-off-by Mathew McBride <[email protected]>--- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 3 +++ 1 file changed, 3 insertions(+)
Re: [PATCH v2 2/2] dt-bindings: rtc: add Epson RX-8025 and RX-8035
In reply to Mathew McBrideHi,
2021年7月9日(金) 13:45 Mathew McBride <[email protected]>:
Quoted 8 lines
These are supported by the rtc-rx8025 module. RX-8025 also has support in ds1307 due to compatible time registers.
Signed-off-by Mathew McBride <[email protected]>--- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 3 +++ 1 file changed, 3 insertions(+)
Best regards,
Nobuhiro
Quoted 18 lines
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +3
-1@@ -32,6 +32,9 @@ properties: - dallas,ds3232 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE - epson,rx8010 + # I2C-BUS INTERFACE REAL TIME CLOCK MODULE + - epson,rx8025 + - epson,rx8035 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE with Battery Backed RAM - epson,rx8571 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE --2.30.1
Signature · 3 lines
Nobuhiro Iwamatsu
iwamatsu at {nigauri.org / debian.org}
GPG ID: 40AD1FA6Quoted 10 lines · Mathew McBride
The EPSON RX-8035[SA] is a I2C real time clock module with built-in oscillator[1]. It is a very close relative of the EPSON RX-8025 that is supported by the rtc-rx8025 driver.
The main difference is that the RX-8035 has inverted the 'oscillator stop' bit in the control register. The operation of the devices is otherwise identical for the features currently supported.
[...]
Applied, thanks!
[1/2] rtc: rx8025: implement RX-8035 support
commit: f120e2e33ac8ba1adac4f59eaf1ae1705305158f
I did remove the switch and dev_info in an attempt to cut down on unecessary strings.
[2/2] dt-bindings: rtc: add Epson RX-8025 and RX-8035
commit: 8158da6a33f2656c2a98c30eb9185a44e215a6b6
Best regards,
Signature · 1 line
Alexandre Belloni <[email protected]>