]> Git Repo - J-u-boot.git/blobdiff - drivers/rtc/i2c_rtc_emul.c
Merge tag 'xilinx-for-v2023.04-rc1' of https://source.denx.de/u-boot/custodians/u...
[J-u-boot.git] / drivers / rtc / i2c_rtc_emul.c
index 5a2a154e65316567114a2825762c28848d0160c9..c307d6036dd5b87ca4fc256a47d3938ccdbb980e 100644 (file)
 #define debug_buffer(x, ...)
 #endif
 
-/**
- * struct sandbox_i2c_rtc_plat_data - platform data for the RTC
- *
- * @base_time:         Base system time when RTC device was bound
- * @offset:            RTC offset from current system time
- * @use_system_time:   true to use system time, false to use @base_time
- * @reg:               Register values
- */
-struct sandbox_i2c_rtc_plat_data {
-       long base_time;
-       long offset;
-       bool use_system_time;
-       u8 reg[REG_COUNT];
-};
-
-struct sandbox_i2c_rtc {
-       unsigned int offset_secs;
-};
-
 long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time,
                                int offset)
 {
@@ -57,6 +38,7 @@ long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time,
        plat->use_system_time = use_system_time;
        if (offset != -1)
                plat->offset = offset;
+       os_set_time_offset(plat->offset);
 
        return old_offset;
 }
@@ -80,7 +62,7 @@ static void reset_time(struct udevice *dev)
 
        os_localtime(&now);
        plat->base_time = rtc_mktime(&now);
-       plat->offset = 0;
+       plat->offset = os_get_time_offset();
        plat->use_system_time = true;
 }
 
@@ -115,6 +97,7 @@ static int sandbox_i2c_rtc_set(struct udevice *dev, const struct rtc_time *time)
                now = plat->base_time;
        }
        plat->offset = rtc_mktime(time) - now;
+       os_set_time_offset(plat->offset);
 
        return 0;
 }
@@ -220,8 +203,17 @@ static int sandbox_i2c_rtc_bind(struct udevice *dev)
        return 0;
 }
 
+static int sandbox_i2c_rtc_probe(struct udevice *dev)
+{
+       const u8 mac[] = { 0x02, 0x00, 0x11, 0x22, 0x33, 0x48 };
+       struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev);
+
+       memcpy(&plat->reg[0x40], mac, sizeof(mac));
+       return 0;
+}
+
 static const struct udevice_id sandbox_i2c_rtc_ids[] = {
-       { .compatible = "sandbox,i2c-rtc" },
+       { .compatible = "sandbox,i2c-rtc-emul" },
        { }
 };
 
@@ -230,6 +222,7 @@ U_BOOT_DRIVER(sandbox_i2c_rtc_emul) = {
        .id             = UCLASS_I2C_EMUL,
        .of_match       = sandbox_i2c_rtc_ids,
        .bind           = sandbox_i2c_rtc_bind,
+       .probe          = sandbox_i2c_rtc_probe,
        .priv_auto      = sizeof(struct sandbox_i2c_rtc),
        .plat_auto      = sizeof(struct sandbox_i2c_rtc_plat_data),
        .ops            = &sandbox_i2c_rtc_emul_ops,
This page took 0.029451 seconds and 4 git commands to generate.