rtc: Add read8 and write8 support to isl1208 driver
authorTrent Piepho <tpiepho@impinj.com>
Thu, 31 May 2018 18:14:44 +0000 (11:14 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 8 Oct 2018 18:45:02 +0000 (14:45 -0400)
This can be used for device register access from board code.

This allows access to capabilities in the RTC chip not abstracted in
U-Boot's RTC class.  E.g., device NVRAM or a tamper detection circuit.

Cc: Klaus Goger <klaus.goger@theobroma-systems.com>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
drivers/rtc/isl1208.c

index 22ac0d2b083f3ceddf476face8c204f6cfce38f5..59a60b75b3072cb533e8e94c1d41c6e420514e95 100644 (file)
 #define RTC_STAT_BIT_BAT       0x02    /* BATTERY BIT */
 #define RTC_STAT_BIT_RTCF      0x01    /* REAL TIME CLOCK FAIL BIT */
 
+/*
+ * Read an RTC register
+ */
+
+static int isl1208_rtc_read8(struct udevice *dev, unsigned int reg)
+{
+       return dm_i2c_reg_read(dev, reg);
+}
+
+/*
+ * Write an RTC register
+ */
+
+static int isl1208_rtc_write8(struct udevice *dev, unsigned int reg, int val)
+{
+       return dm_i2c_reg_write(dev, reg, val);
+}
+
 /*
  * Get the current time from the RTC
  */
@@ -161,6 +179,8 @@ static const struct rtc_ops isl1208_rtc_ops = {
        .get = isl1208_rtc_get,
        .set = isl1208_rtc_set,
        .reset = isl1208_rtc_reset,
+       .read8 = isl1208_rtc_read8,
+       .write8 = isl1208_rtc_write8,
 };
 
 static const struct udevice_id isl1208_rtc_ids[] = {