]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: Add a test for of-platdata parent information
authorSimon Glass <sjg@chromium.org>
Sat, 3 Oct 2020 17:31:36 +0000 (11:31 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 29 Oct 2020 20:42:18 +0000 (14:42 -0600)
Add a simple test that we can obtain the correct parent for an I2C
device. This requires updating the driver names to match the compatible
strings, adding them to the devicetree and enabling a few options.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/sandbox.dts
arch/sandbox/dts/sandbox.dtsi
configs/sandbox_spl_defconfig
drivers/i2c/sandbox_i2c.c
drivers/rtc/sandbox_rtc.c
test/dm/of_platdata.c

index 20f689382979f71a15fa273425b3dd93976640c7..8b50a4028983b3222008e848d7a0a45d85b5f497 100644 (file)
@@ -69,6 +69,7 @@
                clock-frequency = <400000>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_i2c0>;
+               u-boot,dm-pre-reloc;
        };
 
        pcic: pci@0 {
index 6a0338b212bdd57a457a12459c16e332c646afc0..81cdc55b0d4d10205bc7c7f052ac9c91e2a4cf1a 100644 (file)
@@ -90,6 +90,7 @@
                        reg = <0x43>;
                        compatible = "sandbox-rtc";
                        sandbox,emul = <&emul0>;
+                       u-boot,dm-pre-reloc;
                };
                sandbox_pmic: sandbox_pmic {
                        reg = <0x40>;
index db723cdf983702b117a143c47a9428add582bcd4..d47a6252de111a7415fa48a2cf89c08abeb696d3 100644 (file)
@@ -26,6 +26,8 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_HANDOFF=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_RTC_SUPPORT=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_BOOTZ=y
@@ -120,7 +122,6 @@ CONFIG_I2C_CROS_EC_LDO=y
 CONFIG_DM_I2C_GPIO=y
 CONFIG_SYS_I2C_SANDBOX=y
 CONFIG_I2C_MUX=y
-CONFIG_SPL_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
@@ -187,6 +188,7 @@ CONFIG_REMOTEPROC_SANDBOX=y
 CONFIG_DM_RESET=y
 CONFIG_SANDBOX_RESET=y
 CONFIG_DM_RTC=y
+CONFIG_SPL_DM_RTC=y
 CONFIG_SANDBOX_SERIAL=y
 CONFIG_SOUND=y
 CONFIG_SOUND_SANDBOX=y
index 57b1c60fde6da10352fbe442cbd6e5feccb03ab8..2cbdaf9cc736c3a07fd1a3fac98cbec52d23b50c 100644 (file)
@@ -93,8 +93,8 @@ static const struct udevice_id sandbox_i2c_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(i2c_sandbox) = {
-       .name   = "i2c_sandbox",
+U_BOOT_DRIVER(sandbox_i2c) = {
+       .name   = "sandbox_i2c",
        .id     = UCLASS_I2C,
        .of_match = sandbox_i2c_ids,
        .ops    = &sandbox_i2c_ops,
index 852770a49cf8d9b97696b317c3f53f3b427b7684..d0864b1df97de7cc8f96cb09552510f749374d47 100644 (file)
@@ -92,8 +92,8 @@ static const struct udevice_id sandbox_rtc_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(rtc_sandbox) = {
-       .name   = "rtc-sandbox",
+U_BOOT_DRIVER(sandbox_rtc) = {
+       .name   = "sandbox_rtc",
        .id     = UCLASS_RTC,
        .of_match = sandbox_rtc_ids,
        .ops    = &sandbox_rtc_ops,
index e827d45ffb76f53c6d1a5e5e98e2c128e75554de..bad733fbee094b50a8bca2bd2840ab00c8805f05 100644 (file)
@@ -205,3 +205,18 @@ static int dm_test_of_platdata_phandle(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_of_platdata_phandle, UT_TESTF_SCAN_PDATA);
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_PARENT)
+/* Test that device parents are correctly set up */
+static int dm_test_of_platdata_parent(struct unit_test_state *uts)
+{
+       struct udevice *rtc, *i2c;
+
+       ut_assertok(uclass_first_device_err(UCLASS_RTC, &rtc));
+       ut_assertok(uclass_first_device_err(UCLASS_I2C, &i2c));
+       ut_asserteq_ptr(i2c, dev_get_parent(rtc));
+
+       return 0;
+}
+DM_TEST(dm_test_of_platdata_parent, UT_TESTF_SCAN_PDATA);
+#endif