summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorMathew McBride <matt@traverse.com.au>2021-09-17 09:46:02 +0300
committerTom Rini <trini@konsulko.com>2021-10-03 21:40:56 +0300
commit9ca4ae2d2a7300e9d2bfdd0b818aacc854c7c617 (patch)
treef34591d6602970dfe709c4584f987c463aac9436 /drivers/rtc
parent152ef916f8f3a8b650aa7ab1ea5b4e9555011536 (diff)
downloadu-boot-9ca4ae2d2a7300e9d2bfdd0b818aacc854c7c617.tar.xz
rtc: rx8025: add support for EPSON RX8035.
The RX8035 is a newer model from EPSON which is very similar in operation to the RX8025. The changes mirror similar ones that will be in Linux 5.15: https://lore.kernel.org/all/20210709044518.28769-2-matt@traverse.com.au/ The UBOOT_DRIVER ID has also been corrected, previously it declared itself as rx8010sj_rtc which is a different driver. Signed-off-by: Mathew McBride <matt@traverse.com.au>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rx8025.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/drivers/rtc/rx8025.c b/drivers/rtc/rx8025.c
index 36e5b0122c..09bf365f63 100644
--- a/drivers/rtc/rx8025.c
+++ b/drivers/rtc/rx8025.c
@@ -24,6 +24,11 @@
#endif
/*---------------------------------------------------------------------*/
+enum rx_model {
+ model_rx_8025,
+ model_rx_8035,
+};
+
/*
* RTC register addresses
*/
@@ -64,6 +69,20 @@
static int rtc_write(struct udevice *dev, uchar reg, uchar val);
+static int rx8025_is_osc_stopped(enum rx_model model, int ctrl2)
+{
+ int xstp = ctrl2 & RTC_CTL2_BIT_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;
+}
+
/*
* Get the current time from the RTC
*/
@@ -101,8 +120,7 @@ static int rx8025_rtc_get(struct udevice *dev, struct rtc_time *tmp)
printf("RTC: voltage drop detected\n");
rel = -1;
}
-
- if (!(ctl2 & RTC_CTL2_BIT_XST)) {
+ if (rx8025_is_osc_stopped(dev->driver_data, ctl2)) {
printf("RTC: oscillator stop detected\n");
rel = -1;
}
@@ -180,7 +198,11 @@ static int rx8025_rtc_reset(struct udevice *dev)
ctl2 = rtc_read(RTC_CTL2_REG_ADDR);
ctl2 &= ~(RTC_CTL2_BIT_PON | RTC_CTL2_BIT_VDET);
- ctl2 |= RTC_CTL2_BIT_XST | RTC_CTL2_BIT_VDSL;
+
+ if (dev->driver_data == model_rx_8035)
+ ctl2 &= ~(RTC_CTL2_BIT_XST);
+ else
+ ctl2 |= RTC_CTL2_BIT_XST;
return rtc_write(dev, RTC_CTL2_REG_ADDR, ctl2);
}
@@ -223,11 +245,12 @@ static const struct rtc_ops rx8025_rtc_ops = {
};
static const struct udevice_id rx8025_rtc_ids[] = {
- { .compatible = "epson,rx8025" },
+ { .compatible = "epson,rx8025", .data = model_rx_8025 },
+ { .compatible = "epson,rx8035", .data = model_rx_8035 },
{ }
};
-U_BOOT_DRIVER(rx8010sj_rtc) = {
+U_BOOT_DRIVER(rx8025_rtc) = {
.name = "rx8025_rtc",
.id = UCLASS_RTC,
.probe = rx8025_probe,