diff mbox series

[RFC,6/6] test: dm: add SCMI pinctrl test

Message ID 20230906024011.17488-7-takahiro.akashi@linaro.org
State New
Headers show
Series firmware: scmi: add SCMI pinctrl protocol support | expand

Commit Message

AKASHI Takahiro Sept. 6, 2023, 2:40 a.m. UTC
In this test, SCMI-based pinmux feature is exercised.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

Comments

Simon Glass Sept. 10, 2023, 7:13 p.m. UTC | #1
Hi AKASHI,

On Tue, 5 Sept 2023 at 20:41, AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>
> In this test, SCMI-based pinmux feature is exercised.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
>
> diff --git a/test/dm/scmi.c b/test/dm/scmi.c
> index 423b6ef70b29..ca5a2e9c781e 100644
> --- a/test/dm/scmi.c
> +++ b/test/dm/scmi.c
> @@ -21,6 +21,7 @@
>  #include <scmi_protocols.h>
>  #include <asm/scmi_test.h>
>  #include <dm/device-internal.h>
> +#include <dm/pinctrl.h>
>  #include <dm/test.h>
>  #include <linux/kconfig.h>
>  #include <power/regulator.h>
> @@ -395,3 +396,64 @@ static int dm_test_scmi_voltage_domains(struct unit_test_state *uts)
>         return release_sandbox_scmi_test_devices(uts, dev);
>  }
>  DM_TEST(dm_test_scmi_voltage_domains, UT_TESTF_SCAN_FDT);
> +
> +/*
> + * This part is derived from test/dm/pinmux.c, So
> + *
> + * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
> + */
> +
> +static char buf[64];
> +#define test_muxing(selector, expected) do { \
> +       ut_assertok(pinctrl_get_pin_muxing(dev, selector, buf, sizeof(buf))); \
> +       ut_asserteq_str(expected, (char *)&buf); \

Can you instead make this a function?

> +} while (0)
> +
> +#define test_name(selector, expected) do { \
> +       ut_assertok(pinctrl_get_pin_name(dev, selector, buf, sizeof(buf))); \
> +       ut_asserteq_str(expected, (char *)&buf); \
> +} while (0)
> +
> +static int dm_test_scmi_pinmux(struct unit_test_state *uts)
> +{
> +       struct udevice *dev;
> +
> +       ut_assertok(uclass_get_device_by_name(UCLASS_PINCTRL, "protocol@19",
> +                                             &dev));
> +       ut_assertok(pinctrl_select_state(dev, "default"));
> +       test_muxing(0, "<unknown>");

ut_assertok(check_muxing(uts, ...));

> +       test_muxing(1, "<unknown>");
> +       test_muxing(2, "I2S.");
> +       test_muxing(3, "I2S.");
> +       test_muxing(4, "I2S.");
> +       test_muxing(5, "GPIO bias-pull-up.");
> +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> +       test_muxing(8, "GPIO bias-disable.");
> +
> +       ut_assertok(pinctrl_select_state(dev, "alternate"));
> +       test_muxing(0, "I2C drive-open-drain.");
> +       test_muxing(1, "I2C drive-open-drain.");
> +       test_muxing(2, "SPI.");
> +       test_muxing(3, "SPI.");
> +       test_muxing(4, "SPI.");
> +       test_muxing(5, "CS bias-pull-up.");
> +       test_muxing(6, "CS drive-open-drain output-mode output-value.");
> +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> +       test_muxing(8, "GPIO bias-disable.");
> +
> +       ut_assertok(pinctrl_select_state(dev, "0"));
> +       test_muxing(0, "I2C drive-open-drain.");
> +       test_muxing(1, "I2C drive-open-drain.");
> +       test_muxing(2, "I2S.");
> +       test_muxing(3, "I2S.");
> +       test_muxing(4, "I2S.");
> +       test_muxing(5, "GPIO bias-pull-up.");
> +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> +       test_muxing(8, "GPIO bias-disable.");
> +
> +       return 0;
> +}
> +
> +DM_TEST(dm_test_scmi_pinmux, UT_TESTF_SCAN_FDT);
> --
> 2.34.1
>

Regards,
Simon
AKASHI Takahiro Sept. 11, 2023, 5:47 a.m. UTC | #2
On Sun, Sep 10, 2023 at 01:13:30PM -0600, Simon Glass wrote:
> Hi AKASHI,
> 
> On Tue, 5 Sept 2023 at 20:41, AKASHI Takahiro
> <takahiro.akashi@linaro.org> wrote:
> >
> > In this test, SCMI-based pinmux feature is exercised.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 62 insertions(+)
> >
> > diff --git a/test/dm/scmi.c b/test/dm/scmi.c
> > index 423b6ef70b29..ca5a2e9c781e 100644
> > --- a/test/dm/scmi.c
> > +++ b/test/dm/scmi.c
> > @@ -21,6 +21,7 @@
> >  #include <scmi_protocols.h>
> >  #include <asm/scmi_test.h>
> >  #include <dm/device-internal.h>
> > +#include <dm/pinctrl.h>
> >  #include <dm/test.h>
> >  #include <linux/kconfig.h>
> >  #include <power/regulator.h>
> > @@ -395,3 +396,64 @@ static int dm_test_scmi_voltage_domains(struct unit_test_state *uts)
> >         return release_sandbox_scmi_test_devices(uts, dev);
> >  }
> >  DM_TEST(dm_test_scmi_voltage_domains, UT_TESTF_SCAN_FDT);
> > +
> > +/*
> > + * This part is derived from test/dm/pinmux.c, So
> > + *
> > + * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
> > + */
> > +
> > +static char buf[64];
> > +#define test_muxing(selector, expected) do { \
> > +       ut_assertok(pinctrl_get_pin_muxing(dev, selector, buf, sizeof(buf))); \
> > +       ut_asserteq_str(expected, (char *)&buf); \
> 
> Can you instead make this a function?

Sure, but please note that the whole scheme was borrowed
from test/dm/pinmux.c.

> > +} while (0)
> > +
> > +#define test_name(selector, expected) do { \
> > +       ut_assertok(pinctrl_get_pin_name(dev, selector, buf, sizeof(buf))); \
> > +       ut_asserteq_str(expected, (char *)&buf); \
> > +} while (0)
> > +
> > +static int dm_test_scmi_pinmux(struct unit_test_state *uts)
> > +{
> > +       struct udevice *dev;
> > +
> > +       ut_assertok(uclass_get_device_by_name(UCLASS_PINCTRL, "protocol@19",
> > +                                             &dev));
> > +       ut_assertok(pinctrl_select_state(dev, "default"));
> > +       test_muxing(0, "<unknown>");
> 
> ut_assertok(check_muxing(uts, ...));

Assertion for

> > +       test_muxing(1, "<unknown>");
> > +       test_muxing(2, "I2S.");
> > +       test_muxing(3, "I2S.");
> > +       test_muxing(4, "I2S.");
> > +       test_muxing(5, "GPIO bias-pull-up.");
> > +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > +       test_muxing(8, "GPIO bias-disable.");

this chunk of code?
It is not clear to me what is the advantage, though.

-Takahiro Akashi

> > +
> > +       ut_assertok(pinctrl_select_state(dev, "alternate"));
> > +       test_muxing(0, "I2C drive-open-drain.");
> > +       test_muxing(1, "I2C drive-open-drain.");
> > +       test_muxing(2, "SPI.");
> > +       test_muxing(3, "SPI.");
> > +       test_muxing(4, "SPI.");
> > +       test_muxing(5, "CS bias-pull-up.");
> > +       test_muxing(6, "CS drive-open-drain output-mode output-value.");
> > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > +       test_muxing(8, "GPIO bias-disable.");
> > +
> > +       ut_assertok(pinctrl_select_state(dev, "0"));
> > +       test_muxing(0, "I2C drive-open-drain.");
> > +       test_muxing(1, "I2C drive-open-drain.");
> > +       test_muxing(2, "I2S.");
> > +       test_muxing(3, "I2S.");
> > +       test_muxing(4, "I2S.");
> > +       test_muxing(5, "GPIO bias-pull-up.");
> > +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > +       test_muxing(8, "GPIO bias-disable.");
> > +
> > +       return 0;
> > +}
> > +
> > +DM_TEST(dm_test_scmi_pinmux, UT_TESTF_SCAN_FDT);
> > --
> > 2.34.1
> >
> 
> Regards,
> Simon
Simon Glass Sept. 22, 2023, 6:27 p.m. UTC | #3
Hi,

On Sun, 10 Sept 2023 at 23:47, AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>
> On Sun, Sep 10, 2023 at 01:13:30PM -0600, Simon Glass wrote:
> > Hi AKASHI,
> >
> > On Tue, 5 Sept 2023 at 20:41, AKASHI Takahiro
> > <takahiro.akashi@linaro.org> wrote:
> > >
> > > In this test, SCMI-based pinmux feature is exercised.
> > >
> > > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > > ---
> > >  test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 62 insertions(+)
> > >
> > > diff --git a/test/dm/scmi.c b/test/dm/scmi.c
> > > index 423b6ef70b29..ca5a2e9c781e 100644
> > > --- a/test/dm/scmi.c
> > > +++ b/test/dm/scmi.c
> > > @@ -21,6 +21,7 @@
> > >  #include <scmi_protocols.h>
> > >  #include <asm/scmi_test.h>
> > >  #include <dm/device-internal.h>
> > > +#include <dm/pinctrl.h>
> > >  #include <dm/test.h>
> > >  #include <linux/kconfig.h>
> > >  #include <power/regulator.h>
> > > @@ -395,3 +396,64 @@ static int dm_test_scmi_voltage_domains(struct unit_test_state *uts)
> > >         return release_sandbox_scmi_test_devices(uts, dev);
> > >  }
> > >  DM_TEST(dm_test_scmi_voltage_domains, UT_TESTF_SCAN_FDT);
> > > +
> > > +/*
> > > + * This part is derived from test/dm/pinmux.c, So
> > > + *
> > > + * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
> > > + */
> > > +
> > > +static char buf[64];
> > > +#define test_muxing(selector, expected) do { \
> > > +       ut_assertok(pinctrl_get_pin_muxing(dev, selector, buf, sizeof(buf))); \
> > > +       ut_asserteq_str(expected, (char *)&buf); \
> >
> > Can you instead make this a function?
>
> Sure, but please note that the whole scheme was borrowed
> from test/dm/pinmux.c.

I'm not sure if it is needed there, either. It is pretty ugly.

>
> > > +} while (0)
> > > +
> > > +#define test_name(selector, expected) do { \
> > > +       ut_assertok(pinctrl_get_pin_name(dev, selector, buf, sizeof(buf))); \
> > > +       ut_asserteq_str(expected, (char *)&buf); \
> > > +} while (0)
> > > +
> > > +static int dm_test_scmi_pinmux(struct unit_test_state *uts)
> > > +{
> > > +       struct udevice *dev;
> > > +
> > > +       ut_assertok(uclass_get_device_by_name(UCLASS_PINCTRL, "protocol@19",
> > > +                                             &dev));
> > > +       ut_assertok(pinctrl_select_state(dev, "default"));
> > > +       test_muxing(0, "<unknown>");
> >
> > ut_assertok(check_muxing(uts, ...));
>
> Assertion for
>
> > > +       test_muxing(1, "<unknown>");
> > > +       test_muxing(2, "I2S.");
> > > +       test_muxing(3, "I2S.");
> > > +       test_muxing(4, "I2S.");
> > > +       test_muxing(5, "GPIO bias-pull-up.");
> > > +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> > > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > > +       test_muxing(8, "GPIO bias-disable.");
>
> this chunk of code?
> It is not clear to me what is the advantage, though.

Avoiding macros, which are not needed.

>
> -Takahiro Akashi
>
> > > +
> > > +       ut_assertok(pinctrl_select_state(dev, "alternate"));
> > > +       test_muxing(0, "I2C drive-open-drain.");
> > > +       test_muxing(1, "I2C drive-open-drain.");
> > > +       test_muxing(2, "SPI.");
> > > +       test_muxing(3, "SPI.");
> > > +       test_muxing(4, "SPI.");
> > > +       test_muxing(5, "CS bias-pull-up.");
> > > +       test_muxing(6, "CS drive-open-drain output-mode output-value.");
> > > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > > +       test_muxing(8, "GPIO bias-disable.");
> > > +
> > > +       ut_assertok(pinctrl_select_state(dev, "0"));
> > > +       test_muxing(0, "I2C drive-open-drain.");
> > > +       test_muxing(1, "I2C drive-open-drain.");
> > > +       test_muxing(2, "I2S.");
> > > +       test_muxing(3, "I2S.");
> > > +       test_muxing(4, "I2S.");
> > > +       test_muxing(5, "GPIO bias-pull-up.");
> > > +       test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
> > > +       test_muxing(7, "GPIO bias-pull-down input-mode.");
> > > +       test_muxing(8, "GPIO bias-disable.");
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +DM_TEST(dm_test_scmi_pinmux, UT_TESTF_SCAN_FDT);
> > > --
> > > 2.34.1
> > >
> >
> > Regards,
> > Simon

Regards,
Simon
diff mbox series

Patch

diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index 423b6ef70b29..ca5a2e9c781e 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -21,6 +21,7 @@ 
 #include <scmi_protocols.h>
 #include <asm/scmi_test.h>
 #include <dm/device-internal.h>
+#include <dm/pinctrl.h>
 #include <dm/test.h>
 #include <linux/kconfig.h>
 #include <power/regulator.h>
@@ -395,3 +396,64 @@  static int dm_test_scmi_voltage_domains(struct unit_test_state *uts)
 	return release_sandbox_scmi_test_devices(uts, dev);
 }
 DM_TEST(dm_test_scmi_voltage_domains, UT_TESTF_SCAN_FDT);
+
+/*
+ * This part is derived from test/dm/pinmux.c, So
+ *
+ * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
+ */
+
+static char buf[64];
+#define test_muxing(selector, expected) do { \
+	ut_assertok(pinctrl_get_pin_muxing(dev, selector, buf, sizeof(buf))); \
+	ut_asserteq_str(expected, (char *)&buf); \
+} while (0)
+
+#define test_name(selector, expected) do { \
+	ut_assertok(pinctrl_get_pin_name(dev, selector, buf, sizeof(buf))); \
+	ut_asserteq_str(expected, (char *)&buf); \
+} while (0)
+
+static int dm_test_scmi_pinmux(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_PINCTRL, "protocol@19",
+					      &dev));
+	ut_assertok(pinctrl_select_state(dev, "default"));
+	test_muxing(0, "<unknown>");
+	test_muxing(1, "<unknown>");
+	test_muxing(2, "I2S.");
+	test_muxing(3, "I2S.");
+	test_muxing(4, "I2S.");
+	test_muxing(5, "GPIO bias-pull-up.");
+	test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
+	test_muxing(7, "GPIO bias-pull-down input-mode.");
+	test_muxing(8, "GPIO bias-disable.");
+
+	ut_assertok(pinctrl_select_state(dev, "alternate"));
+	test_muxing(0, "I2C drive-open-drain.");
+	test_muxing(1, "I2C drive-open-drain.");
+	test_muxing(2, "SPI.");
+	test_muxing(3, "SPI.");
+	test_muxing(4, "SPI.");
+	test_muxing(5, "CS bias-pull-up.");
+	test_muxing(6, "CS drive-open-drain output-mode output-value.");
+	test_muxing(7, "GPIO bias-pull-down input-mode.");
+	test_muxing(8, "GPIO bias-disable.");
+
+	ut_assertok(pinctrl_select_state(dev, "0"));
+	test_muxing(0, "I2C drive-open-drain.");
+	test_muxing(1, "I2C drive-open-drain.");
+	test_muxing(2, "I2S.");
+	test_muxing(3, "I2S.");
+	test_muxing(4, "I2S.");
+	test_muxing(5, "GPIO bias-pull-up.");
+	test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
+	test_muxing(7, "GPIO bias-pull-down input-mode.");
+	test_muxing(8, "GPIO bias-disable.");
+
+	return 0;
+}
+
+DM_TEST(dm_test_scmi_pinmux, UT_TESTF_SCAN_FDT);