rtc: pcf8563: add Epson RTC8564 compatible
Subsystems (2)
Alexandre Belloni
maintainerPATCH 1/5 rtc: pcf8563: add Epson RTC8564 compatible
Add a compatible string for the Epson RTC8564.
Signed-off-by Alexandre Belloni <[email protected]>
--- Documentation/devicetree/bindings/rtc/pcf8563.txt | 2 +- drivers/rtc/rtc-pcf8563.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/rtc/pcf8563.txt +1 -1
@@ -3,7 +3,7 @@ Philips PCF8563/Epson RTC8564 Real Time Clock Required properties: -- compatible: Should contain "nxp,pcf8563". +- compatible: Should contain "nxp,pcf8563" or "epson,rtc8564". - reg: I2C address for chip. Optional property:
drivers/rtc/rtc-pcf8563.c +1 -0
@@ -632,6 +632,7 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);#ifdef CONFIG_OF static const struct of_device_id pcf8563_of_match[] = { { .compatible ="nxp,pcf8563" }, + { .compatible ="epson,rtc8564" }, {} };MODULE_DEVICE_TABLE (of, pcf8563_of_match);
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 4/5 rtc: pcf8563: remove useless indirection
pcf8563_rtc_read_time and pcf8563_set_datetime are only used after casting dev to an i2c_client. Remove that useless indirection.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-pcf8563.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/rtc/rtc-pcf8563.c +6 -14
@@ -196,8 +196,9 @@ static irqreturn_t pcf8563_irq(int irq, void *dev_id)* In the routines that deal directly with the pcf8563 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. */ -static int pcf8563_get_datetime (struct i2c_client *client,struct rtc_time *tm) +static int pcf8563_rtc_read_time (struct device *dev,struct rtc_time *tm) { +struct i2c_client *client =to_i2c_client (dev);struct pcf8563 *pcf8563 =i2c_get_clientdata (client);unsigned char buf[9 ];int err;
@@ -244,8 +245,9 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)return 0 ; } -static int pcf8563_set_datetime (struct i2c_client *client,struct rtc_time *tm) +static int pcf8563_rtc_set_time (struct device *dev,struct rtc_time *tm) { +struct i2c_client *client =to_i2c_client (dev);struct pcf8563 *pcf8563 =i2c_get_clientdata (client);unsigned char buf[9 ];
@@ -299,8 +301,8 @@ static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long* because of the cached voltage_low value but do it * anyway for consistency. */ -if (pcf8563_get_datetime (to_i2c_client (dev), &tm)) -pcf8563_set_datetime (to_i2c_client (dev), &tm); +if (pcf8563_rtc_read_time (dev, &tm)) +pcf8563_rtc_set_time (dev, &tm);/* Clear the cached value. */ pcf8563->voltage_low =0 ;
@@ -314,16 +316,6 @@ static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long#define pcf8563_rtc_ioctl NULL#endif -static int pcf8563_rtc_read_time (struct device *dev,struct rtc_time *tm) -{ -return pcf8563_get_datetime (to_i2c_client (dev), tm); -} - -static int pcf8563_rtc_set_time (struct device *dev,struct rtc_time *tm) -{ -return pcf8563_set_datetime (to_i2c_client (dev), tm); -} -static int pcf8563_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *tm) {struct i2c_client *client =to_i2c_client (dev);
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 5/5 rtc: pcf8563: let the core handle range offsetting
In reply to Alexandre BelloniSet the RTC range properly and use the core windowing and offsetting to (unfortunately) map back to a 1970-2069 range.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-pcf8563.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pcf8563.c +5 -4
@@ -229,9 +229,7 @@ static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) tm->tm_mday =bcd2bin (buf[PCF8563_REG_DM ] &0x3F ); tm->tm_wday = buf[PCF8563_REG_DW ] &0x07 ; tm->tm_mon =bcd2bin (buf[PCF8563_REG_MO ] &0x1F ) -1 ;/* rtc mn 1-12 */ - tm->tm_year =bcd2bin (buf[PCF8563_REG_YR ]); -if (tm->tm_year <70 ) - tm->tm_year +=100 ;/* assume we are in 1970...2069 */ + tm->tm_year =bcd2bin (buf[PCF8563_REG_YR ]) +100 ;/* detect the polarity heuristically. see note above. */ pcf8563->c_polarity = (buf[PCF8563_REG_MO ] &PCF8563_MO_C ) ? (tm->tm_year >=100 ) : (tm->tm_year <100 );
@@ -268,7 +266,7 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) buf[PCF8563_REG_MO ] =bin2bcd (tm->tm_mon +1 );/* year and century */ - buf[PCF8563_REG_YR ] =bin2bcd (tm->tm_year %100 ); + buf[PCF8563_REG_YR ] =bin2bcd (tm->tm_year -100 );if (pcf8563->c_polarity ? (tm->tm_year >=100 ) : (tm->tm_year <100 )) buf[PCF8563_REG_MO ] |=PCF8563_MO_C ;
@@ -590,6 +588,9 @@ static int pcf8563_probe(struct i2c_client *client, pcf8563->rtc->ops = &pcf8563_rtc_ops;/* the pcf8563 alarm only supports a minute accuracy */ pcf8563->rtc->uie_unsupported =1 ; + pcf8563->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; + pcf8563->rtc->range_max =RTC_TIMESTAMP_END_2099 ; + pcf8563->rtc->set_start_time = true;if (client->irq >0 ) { err = devm_request_threaded_irq(&client->dev, client->irq,
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 2/5 rtc: pcf8563: add Microcrystal RV8564 compatible
In reply to Alexandre BelloniAdd a compatible string for the Microcrystal RV8564.
Signed-off-by Alexandre Belloni <[email protected]>
--- Documentation/devicetree/bindings/rtc/pcf8563.txt | 4 +++- drivers/rtc/rtc-pcf8563.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/rtc/pcf8563.txt +3 -1
@@ -3,7 +3,9 @@ Philips PCF8563/Epson RTC8564 Real Time Clock Required properties: -- compatible: Should contain "nxp,pcf8563" or "epson,rtc8564". +- compatible: Should contain "nxp,pcf8563", + "epson,rtc8564" or + "microcrystal,rv8564" - reg: I2C address for chip. Optional property:
drivers/rtc/rtc-pcf8563.c +1 -0
@@ -633,6 +633,7 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);static const struct of_device_id pcf8563_of_match[] = { { .compatible ="nxp,pcf8563" }, { .compatible ="epson,rtc8564" }, + { .compatible ="microcrystal,rv8564" }, {} };MODULE_DEVICE_TABLE (of, pcf8563_of_match);
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 3/5 rtc: pcf8563: convert to devm_rtc_allocate_device
In reply to Alexandre BelloniThis allows further improvement of the driver.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-pcf8563.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/rtc/rtc-pcf8563.c +9 -8
@@ -591,13 +591,14 @@ static int pcf8563_probe(struct i2c_client *client,return err; } - pcf8563->rtc =devm_rtc_device_register (&client->dev, - pcf8563_driver.driver.name, - &pcf8563_rtc_ops,THIS_MODULE ); - + pcf8563->rtc =devm_rtc_allocate_device (&client->dev);if (IS_ERR (pcf8563->rtc))return PTR_ERR (pcf8563->rtc); + pcf8563->rtc->ops = &pcf8563_rtc_ops; +/* the pcf8563 alarm only supports a minute accuracy */ + pcf8563->rtc->uie_unsupported =1 ; +if (client->irq >0 ) { err = devm_request_threaded_irq(&client->dev, client->irq, NULL, pcf8563_irq,
@@ -608,17 +609,17 @@ static int pcf8563_probe(struct i2c_client *client, client->irq);return err; } - } + err =rtc_register_device (pcf8563->rtc); +if (err) +return err; +#ifdef CONFIG_COMMON_CLK /* register clk in common clk framework */ pcf8563_clkout_register_clk (pcf8563);#endif -/* the pcf8563 alarm only supports a minute accuracy */ - pcf8563->rtc->uie_unsupported =1 ; -return 0 ; }
Signature · 1 line
2.21.0