@@ -39,6 +39,24 @@ int dm_rtc_reset(struct udevice *dev)
return ops->reset(dev);
}
+int rtc_read(struct udevice *dev, unsigned int reg, u8 *buf, unsigned int len)
+{
+ struct rtc_ops *ops = rtc_get_ops(dev);
+
+ assert(ops);
+ if (ops->read)
+ return ops->read(dev, reg, buf, len);
+ if (!ops->read8)
+ return -ENOSYS;
+ while (len--) {
+ int ret = ops->read8(dev, reg++);
+ if (ret < 0)
+ return ret;
+ *buf++ = ret;
+ }
+ return 0;
+}
+
int rtc_read8(struct udevice *dev, unsigned int reg)
{
struct rtc_ops *ops = rtc_get_ops(dev);
@@ -55,6 +55,18 @@ struct rtc_ops {
*/
int (*reset)(struct udevice *dev);
+ /**
+ * read() - Read multiple 8-bit registers
+ *
+ * @dev: Device to read from
+ * @reg: First register to read
+ * @buf: Output buffer
+ * @len: Number of registers to read
+ * @return 0 if OK, -ve on error
+ */
+ int (*read)(struct udevice *dev, unsigned int reg,
+ u8 *buf, unsigned int len);
+
/**
* read8() - Read an 8-bit register
*
@@ -109,6 +121,17 @@ int dm_rtc_set(struct udevice *dev, struct rtc_time *time);
*/
int dm_rtc_reset(struct udevice *dev);
+/**
+ * rtc_read() - Read multiple 8-bit registers
+ *
+ * @dev: Device to read from
+ * @reg: First register to read
+ * @buf: Output buffer
+ * @len: Number of registers to read
+ * @return 0 if OK, -ve on error
+ */
+int rtc_read(struct udevice *dev, unsigned int reg, u8 *buf, unsigned int len);
+
/**
* rtc_read8() - Read an 8-bit register
*