
Add a simple sandbox test for this uclass.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 3 ++- drivers/misc/Makefile | 1 + drivers/misc/itss_sandbox.c | 44 +++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/itss.c | 29 ++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/itss_sandbox.c create mode 100644 test/dm/itss.c
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index cd4409b7aea..ea435f16247 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -345,6 +345,10 @@ vss-microvolts = <0>; };
+ itss { + compatible = "sandbox,itss"; + }; + lcd { u-boot,dm-pre-reloc; compatible = "sandbox,lcd-sdl"; diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 6f4d8449290..a1104b03433 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -129,6 +129,8 @@ CONFIG_CROS_EC_I2C=y CONFIG_CROS_EC_LPC=y CONFIG_CROS_EC_SANDBOX=y CONFIG_CROS_EC_SPI=y +CONFIG_ITSS=y +CONFIG_P2SB=y CONFIG_PWRSEQ=y CONFIG_SPL_PWRSEQ=y CONFIG_I2C_EEPROM=y @@ -149,7 +151,6 @@ CONFIG_PCI=y CONFIG_DM_PCI=y CONFIG_DM_PCI_COMPAT=y CONFIG_PCI_SANDBOX=y -CONFIG_P2SB=y CONFIG_PHY=y CONFIG_PHY_SANDBOX=y CONFIG_PINCTRL=y diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index f715d6d6df5..83fbd193657 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_$(SPL_)I2C_EEPROM) += i2c_eeprom.o obj-$(CONFIG_IHS_FPGA) += ihs_fpga.o obj-$(CONFIG_IMX8) += imx8/ obj-$(CONFIG_ITSS) += itss-uclass.o +obj-$(CONFIG_SANDBOX) += itss_sandbox.o obj-$(CONFIG_LED_STATUS) += status_led.o obj-$(CONFIG_LED_STATUS_GPIO) += gpio_led.o obj-$(CONFIG_MPC83XX_SERDES) += mpc83xx_serdes.o diff --git a/drivers/misc/itss_sandbox.c b/drivers/misc/itss_sandbox.c new file mode 100644 index 00000000000..993106ffdc2 --- /dev/null +++ b/drivers/misc/itss_sandbox.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sandbox driver for itss + * + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <itss.h> + +static int sandbox_set_irq_polarity(struct udevice *dev, uint irq, + bool active_low) +{ + if (irq > 10) + return -EINVAL; + + return 0; +} + +static int sandbox_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num) +{ + if (pmc_gpe_num > 10) + return -ENOENT; + + return pmc_gpe_num + 1; +} + +static const struct itss_ops sandbox_itss_ops = { + .route_pmc_gpio_gpe = sandbox_route_pmc_gpio_gpe, + .set_irq_polarity = sandbox_set_irq_polarity, +}; + +static const struct udevice_id sandbox_itss_ids[] = { + { .compatible = "sandbox,itss"}, + { } +}; + +U_BOOT_DRIVER(sandbox_itss_drv) = { + .name = "sandbox_itss", + .id = UCLASS_ITSS, + .of_match = sandbox_itss_ids, + .ops = &sandbox_itss_ops, +}; diff --git a/test/dm/Makefile b/test/dm/Makefile index 52a2392a8e9..3868b5d4aa9 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_SOUND) += i2s.o +obj-$(CONFIG_ITSS) += itss.o obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MAILBOX) += mailbox.o obj-$(CONFIG_DM_MMC) += mmc.o diff --git a/test/dm/itss.c b/test/dm/itss.c new file mode 100644 index 00000000000..1ca1aeba9f4 --- /dev/null +++ b/test/dm/itss.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for ITSS uclass + * + * Copyright 2019 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <itss.h> +#include <dm/test.h> +#include <test/ut.h> + +/* Base test of the ITSS uclass */ +static int dm_test_itss_base(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_ITSS, &dev)); + + ut_asserteq(5, itss_route_pmc_gpio_gpe(dev, 4)); + ut_asserteq(-ENOENT, itss_route_pmc_gpio_gpe(dev, 14)); + + ut_assertok(itss_set_irq_polarity(dev, 4, true)); + ut_asserteq(-EINVAL, itss_set_irq_polarity(dev, 14, true)); + + return 0; +} +DM_TEST(dm_test_itss_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);