[PATCH 08/14] rtc: Implement nvmem interface
Sean Anderson
sean.anderson at seco.com
Tue Feb 8 00:42:06 CET 2022
This adds nvmem support for RTCs with nvmem registers.
Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---
drivers/rtc/rtc-uclass.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
index e5ae6ea4d5..345185d2b8 100644
--- a/drivers/rtc/rtc-uclass.c
+++ b/drivers/rtc/rtc-uclass.c
@@ -11,6 +11,7 @@
#include <errno.h>
#include <log.h>
#include <rtc.h>
+#include <nvmem.h>
int dm_rtc_get(struct udevice *dev, struct rtc_time *time)
{
@@ -181,3 +182,21 @@ UCLASS_DRIVER(rtc) = {
.post_bind = dm_scan_fdt_dev,
#endif
};
+
+static int rtc_nvmem_read(struct udevice *dev, unsigned int offset, void *buf,
+ size_t size)
+{
+ return dm_rtc_read(dev, offset, buf, size);
+}
+
+static int rtc_nvmem_write(struct udevice *dev, unsigned int offset,
+ const void *buf, size_t size)
+{
+ return dm_rtc_write(dev, offset, buf, size);
+}
+
+NVMEM_INTERFACE(rtc) = {
+ .id = UCLASS_RTC,
+ .read = rtc_nvmem_read,
+ .write = rtc_nvmem_write,
+};
--
2.25.1
More information about the U-Boot
mailing list