#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)
{
plat->use_system_time = use_system_time;
if (offset != -1)
plat->offset = offset;
+ os_set_time_offset(plat->offset);
return old_offset;
}
os_localtime(&now);
plat->base_time = rtc_mktime(&now);
- plat->offset = 0;
+ plat->offset = os_get_time_offset();
plat->use_system_time = true;
}
now = plat->base_time;
}
plat->offset = rtc_mktime(time) - now;
+ os_set_time_offset(plat->offset);
return 0;
}
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" },
{ }
};
.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,