diff options
author | Rasmus Villemoes | 2020-07-06 22:01:10 +0200 |
---|---|---|
committer | Heiko Schocher | 2020-07-09 06:02:44 +0200 |
commit | d8be08805bc03d53b0dd6953792fba543a4f3890 (patch) | |
tree | 1236ca71b86c47aa4c135881018078dc6974a6ef /include/rtc.h | |
parent | 35d3982e23d3449d93bcc4f1990e929998d69936 (diff) |
rtc: add dm_rtc_read helper and ->read method
Some users may want to read multiple consecutive 8-bit
registers. Instead of each caller having to implement the loop,
provide a dm_rtc_read() helper. Also, allow a driver to provide a
->read method, which can be more efficient than reading one register
at a time.
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Diffstat (limited to 'include/rtc.h')
-rw-r--r-- | include/rtc.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/rtc.h b/include/rtc.h index 8aabfc1162a..f30e908221a 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -56,6 +56,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 * * @dev: Device to read from @@ -110,6 +122,17 @@ int dm_rtc_set(struct udevice *dev, struct rtc_time *time); int dm_rtc_reset(struct udevice *dev); /** + * dm_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 dm_rtc_read(struct udevice *dev, unsigned int reg, u8 *buf, unsigned int len); + +/** * rtc_read8() - Read an 8-bit register * * @dev: Device to read from |