@@ -80,9 +80,17 @@ int rtc_read8(struct udevice *dev, unsigned int reg)
struct rtc_ops *ops = rtc_get_ops(dev);
assert(ops);
- if (!ops->read8)
- return -ENOSYS;
- return ops->read8(dev, reg);
+ if (ops->read8)
+ return ops->read8(dev, reg);
+ if (ops->read) {
+ u8 buf[1];
+ int ret = ops->read(dev, reg, buf, 1);
+
+ if (ret < 0)
+ return ret;
+ return buf[0];
+ }
+ return -ENOSYS;
}
int rtc_write8(struct udevice *dev, unsigned int reg, int val)
@@ -90,9 +98,13 @@ int rtc_write8(struct udevice *dev, unsigned int reg, int val)
struct rtc_ops *ops = rtc_get_ops(dev);
assert(ops);
- if (!ops->write8)
- return -ENOSYS;
- return ops->write8(dev, reg, val);
+ if (ops->write8)
+ return ops->write8(dev, reg, val);
+ if (ops->write) {
+ u8 buf[1] = { val };
+ return ops->write(dev, reg, buf, 1);
+ }
+ return -ENOSYS;
}
int rtc_read16(struct udevice *dev, unsigned int reg, u16 *valuep)