diff options
Diffstat (limited to 'test/dm/of_platdata.c')
-rw-r--r-- | test/dm/of_platdata.c | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index 0463cf0b433..ec41087a558 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: GPL-2.0+ #include <common.h> +#include <clk.h> #include <dm.h> #include <dt-structs.h> +#include <irq.h> #include <dm/test.h> #include <test/test.h> #include <test/ut.h> +#include <asm-generic/gpio.h> #include <asm/global_data.h> /* Test that we can find a device using of-platdata */ @@ -27,11 +30,9 @@ static int dm_test_of_plat_props(struct unit_test_state *uts) struct udevice *dev; int i; - /* Skip the clock */ - ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev)); - ut_asserteq_str("sandbox_clk_test", dev->name); + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_spl_test", + &dev)); - ut_assertok(uclass_next_device_err(&dev)); plat = dev_get_plat(dev); ut_assert(plat->boolval); ut_asserteq(1, plat->intval); @@ -222,3 +223,59 @@ static int dm_test_of_plat_parent(struct unit_test_state *uts) } DM_TEST(dm_test_of_plat_parent, UT_TESTF_SCAN_PDATA); #endif + +/* Test clocks with of-platdata */ +static int dm_test_of_plat_clk(struct unit_test_state *uts) +{ + struct dtd_sandbox_clk_test *plat; + struct udevice *dev; + struct clk clk; + + ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev)); + ut_asserteq_str("sandbox_clk_test", dev->name); + plat = dev_get_plat(dev); + + ut_assertok(clk_get_by_phandle(dev, &plat->clocks[0], &clk)); + ut_asserteq_str("sandbox_fixed_clock", clk.dev->name); + + return 0; +} +DM_TEST(dm_test_of_plat_clk, UT_TESTF_SCAN_PDATA); + +/* Test irqs with of-platdata */ +static int dm_test_of_plat_irq(struct unit_test_state *uts) +{ + struct dtd_sandbox_irq_test *plat; + struct udevice *dev; + struct irq irq; + + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_irq_test", + &dev)); + plat = dev_get_plat(dev); + + ut_assertok(irq_get_by_phandle(dev, &plat->interrupts_extended[0], + &irq)); + ut_asserteq_str("sandbox_irq", irq.dev->name); + + return 0; +} +DM_TEST(dm_test_of_plat_irq, UT_TESTF_SCAN_PDATA); + +/* Test GPIOs with of-platdata */ +static int dm_test_of_plat_gpio(struct unit_test_state *uts) +{ + struct dtd_sandbox_gpio_test *plat; + struct udevice *dev; + struct gpio_desc desc; + + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_gpio_test", + &dev)); + plat = dev_get_plat(dev); + + ut_assertok(gpio_request_by_phandle(dev, &plat->test_gpios[0], &desc, + GPIOD_IS_OUT)); + ut_asserteq_str("sandbox_gpio", desc.dev->name); + + return 0; +} +DM_TEST(dm_test_of_plat_gpio, UT_TESTF_SCAN_PDATA); |