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>
#endif
/*---------------------------------------------------------------------*/
#endif
/*---------------------------------------------------------------------*/
+enum rx_model {
+ model_rx_8025,
+ model_rx_8035,
+};
+
/*
* RTC register addresses
*/
/*
* RTC register addresses
*/
static int rtc_write(struct udevice *dev, uchar reg, uchar val);
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
*/
/*
* Get the current time from the RTC
*/
printf("RTC: voltage drop detected\n");
rel = -1;
}
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;
}
printf("RTC: oscillator stop detected\n");
rel = -1;
}
ctl2 = rtc_read(RTC_CTL2_REG_ADDR);
ctl2 &= ~(RTC_CTL2_BIT_PON | RTC_CTL2_BIT_VDET);
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);
}
return rtc_write(dev, RTC_CTL2_REG_ADDR, ctl2);
}
};
static const struct udevice_id rx8025_rtc_ids[] = {
};
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,
.name = "rx8025_rtc",
.id = UCLASS_RTC,
.probe = rx8025_probe,