[PATCH v4 5/7] test: Add tests for the multiplexer framework
Simon Glass
sjg at chromium.org
Tue Oct 27 05:52:04 CET 2020
Hi Pratyush,
On Fri, 16 Oct 2020 at 04:46, Pratyush Yadav <p.yadav at ti.com> wrote:
>
> From: Jean-Jacques Hiblot <jjhiblot at ti.com>
>
> Provide tests to check the behavior of the multiplexer framework.
>
> Two sets of tests are added. One is using an emulated multiplexer driver
> that can be used to test basic functionality like select, deselect, etc.
> The other is using the mmio mux which adds tests specific to it.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
> Signed-off-by: Pratyush Yadav <p.yadav at ti.com>
> ---
>
> Notes:
> Changes in v4:
>
> - Add an emulated mux driver that makes it easier to test some basic
> functionality. It is used to test basic things like setting default
> state, and simple set/unset functionality. The MMIO test is still kept
> around for testing the mmio mux driver.
>
> - Add a node for the emulated mux driver in test.dts
>
> - Drop dm_test_mux_mmio_default_state(). This functionality is
> exercised by the emulated mux test.
>
> - Drop some unused includes from mux-mmio.c
>
> - s/DM_TESTF/UT_TESTF/g
>
> arch/sandbox/dts/test.dts | 33 +++++++++
> configs/sandbox_defconfig | 2 +
> test/dm/Makefile | 2 +
> test/dm/mux-emul.c | 105 +++++++++++++++++++++++++++++
> test/dm/mux-mmio.c | 138 ++++++++++++++++++++++++++++++++++++++
> 5 files changed, 280 insertions(+)
> create mode 100644 test/dm/mux-emul.c
> create mode 100644 test/dm/mux-mmio.c
>
Reviewed-by: Simon Glass <sjg at chromium.org>
nits below
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index fa84b2c10f..70ccb4951a 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -3,6 +3,7 @@
> #include <dt-bindings/gpio/gpio.h>
> #include <dt-bindings/gpio/sandbox-gpio.h>
> #include <dt-bindings/pinctrl/sandbox-pinmux.h>
> +#include <dt-bindings/mux/mux.h>
>
> / {
> model = "sandbox";
> @@ -133,6 +134,12 @@
> interrupts-extended = <&irq 3 0>;
> acpi,name = "GHIJ";
> phandle-value = <&gpio_c 10>, <0xFFFFFFFF 20>, <&gpio_a 30>;
> +
> + mux-controls = <&muxcontroller0 0>, <&muxcontroller0 1>,
> + <&muxcontroller0 2>, <&muxcontroller0 3>,
> + <&muxcontroller1>;
> + mux-control-names = "mux0", "mux1", "mux2", "mux3", "mux4";
> + mux-syscon = <&syscon3>;
> };
>
> junk {
> @@ -170,6 +177,9 @@
> compatible = "denx,u-boot-fdt-test";
> ping-expect = <3>;
> ping-add = <3>;
> +
> + mux-controls = <&muxcontroller0 0>;
> + mux-control-names = "mux0";
> };
>
> phy_provider0: gen_phy at 0 {
> @@ -884,6 +894,29 @@
> 0x58 8>;
> };
>
> + syscon3: syscon at 3 {
> + compatible = "simple-mfd", "syscon";
> + reg = <0x000100 0x10>;
> +
> + muxcontroller0: a-mux-controller {
> + compatible = "mmio-mux";
> + #mux-control-cells = <1>;
> +
> + mux-reg-masks = <0x0 0x30>, /* 0: reg 0x0, bits 5:4 */
> + <0xc 0x1E>, /* 1: reg 0xc, bits 4:1 */
> + <0x4 0xFF>; /* 2: reg 0x4, bits 7:0 */
> + idle-states = <MUX_IDLE_AS_IS>, <0x02>, <0x73>;
> + u-boot,mux-autoprobe;
> + };
> + };
> +
> + muxcontroller1: emul-mux-controller {
> + compatible = "mux-emul";
> + #mux-control-cells = <0>;
> + u-boot,mux-autoprobe;
> + idle-state = <0xabcd>;
> + };
> +
> timer at 0 {
> compatible = "sandbox,timer";
> clock-frequency = <1000000>;
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 6ac2919977..f3c4883032 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -179,6 +179,8 @@ CONFIG_SPI_FLASH_SPANSION=y
> CONFIG_SPI_FLASH_STMICRO=y
> CONFIG_SPI_FLASH_SST=y
> CONFIG_SPI_FLASH_WINBOND=y
> +CONFIG_MULTIPLEXER=y
> +CONFIG_MUX_MMIO=y
> CONFIG_DM_ETH=y
> CONFIG_NVME=y
> CONFIG_PCI=y
> diff --git a/test/dm/Makefile b/test/dm/Makefile
> index e2b0798388..93484b48eb 100644
> --- a/test/dm/Makefile
> +++ b/test/dm/Makefile
> @@ -57,6 +57,8 @@ obj-$(CONFIG_DM_SPI_FLASH) += sf.o
> obj-$(CONFIG_SMEM) += smem.o
> obj-$(CONFIG_DM_SPI) += spi.o
> obj-y += syscon.o
> +obj-$(CONFIG_MUX_MMIO) += mux-mmio.o
> +obj-$(CONFIG_MULTIPLEXER) += mux-emul.o
> obj-$(CONFIG_DM_USB) += usb.o
> obj-$(CONFIG_DM_PMIC) += pmic.o
> obj-$(CONFIG_DM_REGULATOR) += regulator.o
> diff --git a/test/dm/mux-emul.c b/test/dm/mux-emul.c
> new file mode 100644
> index 0000000000..141fd4d908
> --- /dev/null
> +++ b/test/dm/mux-emul.c
> @@ -0,0 +1,105 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
> + * Pratyush Yadav <p.yadav at ti.com>
> + */
> +#include <common.h>
> +#include <dm.h>
> +#include <mux.h>
> +#include <mux-internal.h>
> +#include <dm/test.h>
> +#include <test/ut.h>
> +
> +struct mux_emul_priv {
> + u32 state;
> +};
> +
> +static int mux_emul_set(struct mux_control *mux, int state)
> +{
> + struct mux_emul_priv *priv = dev_get_priv(mux->dev);
> +
> + priv->state = state;
blank line before last return
> + return 0;
> +}
> +
Regards,
Simon
More information about the U-Boot
mailing list