diff mbox series

[14/20] dm: Add a test for of-platdata parent information

Message ID 20201003173142.3213123-15-sjg@chromium.org
State Accepted
Commit fbe27a54ebbe7433bbccf242f4edda61e2c1ba3e
Delegated to: Simon Glass
Headers show
Series dm: Enhance of-platdata to support parent devices | expand

Commit Message

Simon Glass Oct. 3, 2020, 5:31 p.m. UTC
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  |  1 +
 arch/sandbox/dts/sandbox.dtsi |  1 +
 configs/sandbox_spl_defconfig |  4 +++-
 drivers/i2c/sandbox_i2c.c     |  4 ++--
 drivers/rtc/sandbox_rtc.c     |  4 ++--
 test/dm/of_platdata.c         | 15 +++++++++++++++
 6 files changed, 24 insertions(+), 5 deletions(-)

Comments

Simon Glass Oct. 30, 2020, 3:34 a.m. UTC | #1
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  |  1 +
 arch/sandbox/dts/sandbox.dtsi |  1 +
 configs/sandbox_spl_defconfig |  4 +++-
 drivers/i2c/sandbox_i2c.c     |  4 ++--
 drivers/rtc/sandbox_rtc.c     |  4 ++--
 test/dm/of_platdata.c         | 15 +++++++++++++++
 6 files changed, 24 insertions(+), 5 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 20f68938297..8b50a402898 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -69,6 +69,7 @@ 
 		clock-frequency = <400000>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_i2c0>;
+		u-boot,dm-pre-reloc;
 	};
 
 	pcic: pci@0 {
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index ca7049fc974..2ec43b009bc 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -90,6 +90,7 @@ 
 			reg = <0x43>;
 			compatible = "sandbox-rtc";
 			sandbox,emul = <&emul0>;
+			u-boot,dm-pre-reloc;
 		};
 		sandbox_pmic: sandbox_pmic {
 			reg = <0x40>;
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 91215d23a0f..0cf8cf76577 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -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
diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index 57b1c60fde6..2cbdaf9cc73 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -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,
diff --git a/drivers/rtc/sandbox_rtc.c b/drivers/rtc/sandbox_rtc.c
index 852770a49cf..d0864b1df97 100644
--- a/drivers/rtc/sandbox_rtc.c
+++ b/drivers/rtc/sandbox_rtc.c
@@ -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,
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index e827d45ffb7..bad733fbee0 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -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