summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 07:25:30 +0300
committerSimon Glass <sjg@chromium.org>2021-03-26 07:03:08 +0300
commit728d04cc72855e23f6a9116e68911dcac5be4693 (patch)
treee363c8a2c362a9d144fe80c75fafc0a731f0de96 /drivers/rtc
parentabaed70990bd8eb2c9992a16465f8a9daa4c5f61 (diff)
downloadu-boot-728d04cc72855e23f6a9116e68911dcac5be4693.tar.xz
sandbox: i2c: Support i2c emulation with of-platdata
At present the i2c emulators require access to the devicetree, which is not possible (by design) with of-platdata. Add a way for drivers to record the of-platdata index of their emulator, so that we can still find the emulator. This allows i2c emulation to work with of-platdata. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/sandbox_rtc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/rtc/sandbox_rtc.c b/drivers/rtc/sandbox_rtc.c
index d0864b1df9..657e5c7be2 100644
--- a/drivers/rtc/sandbox_rtc.c
+++ b/drivers/rtc/sandbox_rtc.c
@@ -79,6 +79,18 @@ struct acpi_ops sandbox_rtc_acpi_ops = {
};
#endif
+static int sandbox_rtc_bind(struct udevice *dev)
+{
+#if CONFIG_IS_ENABLED(PLATDATA)
+ struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev);
+
+ /* Set up the emul_idx for i2c_emul_find() */
+ i2c_emul_set_idx(dev, plat->dtplat.sandbox_emul->idx);
+#endif
+
+ return 0;
+}
+
static const struct rtc_ops sandbox_rtc_ops = {
.get = sandbox_rtc_get,
.set = sandbox_rtc_set,
@@ -97,5 +109,6 @@ U_BOOT_DRIVER(sandbox_rtc) = {
.id = UCLASS_RTC,
.of_match = sandbox_rtc_ids,
.ops = &sandbox_rtc_ops,
+ .bind = sandbox_rtc_bind,
ACPI_OPS_PTR(&sandbox_rtc_acpi_ops)
};