U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Marek Vasut <marek.vasut+renesas@mailbox.org>, u-boot@lists.denx.de
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Fabio Estevam <festevam@gmail.com>,
	Fabrice Gasnier <fabrice.gasnier@foss.st.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Mathieu Othacehe <othacehe@gnu.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Nishanth Menon <nm@ti.com>,
	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
	Sean Anderson <seanga2@gmail.com>, Simon Glass <sjg@chromium.org>,
	Sumit Garg <sumit.garg@linaro.org>,
	Tim Harvey <tharvey@gateworks.com>, Tom Rini <trini@konsulko.com>,
	Xavier Drudis Ferran <xdrudis@tinet.cat>,
	u-boot-qcom@groups.io
Subject: Re: [PATCH v2 3/3] phy: test: Implement sandbox PHY .set_mode and DM test
Date: Tue, 09 Jul 2024 11:33:09 +0200	[thread overview]
Message-ID: <87msmqj4fe.fsf@baylibre.com> (raw)
In-Reply-To: <20240617173740.80822-3-marek.vasut+renesas@mailbox.org>

Hi Marek,

Thank you for the patch.

On lun., juin 17, 2024 at 19:36, Marek Vasut <marek.vasut+renesas@mailbox.org> wrote:

> Implement trivial extension to the sandbox PHY, which makes it pretend
> to support selecting USB Host mode and nothing else. Any other mode is
> rejected with -EINVAL. Any submode except for default submode 0 is
> rejected with -EOPNOTSUPP . The implementation behaves in this trivial
> way to permit easy unit testing using test which is also added in this
> commit.
>
> To run the test, use e.g. sandbox64_defconfig and run U-Boot as follows:
> $ ./u-boot -Tc 'ut dm phy_setup'
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
> Cc: Caleb Connolly <caleb.connolly@linaro.org>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Mathieu Othacehe <othacehe@gnu.org>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Neil Armstrong <neil.armstrong@linaro.org>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> Cc: Sean Anderson <seanga2@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Sumit Garg <sumit.garg@linaro.org>
> Cc: Tim Harvey <tharvey@gateworks.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Xavier Drudis Ferran <xdrudis@tinet.cat>
> Cc: u-boot-qcom@groups.io
> Cc: u-boot@lists.denx.de
> ---
> V2: New patch
> ---
>  drivers/phy/sandbox-phy.c | 13 +++++++++++++
>  test/dm/phy.c             |  7 +++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c
> index b159147a765..e70d20432e0 100644
> --- a/drivers/phy/sandbox-phy.c
> +++ b/drivers/phy/sandbox-phy.c
> @@ -72,6 +72,18 @@ static int sandbox_phy_exit(struct phy *phy)
>  	return 0;
>  }
>  
> +static int
> +sandbox_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
> +{
> +	if (submode)
> +		return -EOPNOTSUPP;
> +
> +	if (mode != PHY_MODE_USB_HOST)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
>  static int sandbox_phy_bind(struct udevice *dev)
>  {
>  	if (dev_get_driver_data(dev) != DRIVER_DATA)
> @@ -96,6 +108,7 @@ static struct phy_ops sandbox_phy_ops = {
>  	.power_off = sandbox_phy_power_off,
>  	.init = sandbox_phy_init,
>  	.exit = sandbox_phy_exit,
> +	.set_mode = sandbox_phy_set_mode,
>  };
>  
>  static const struct udevice_id sandbox_phy_ids[] = {
> diff --git a/test/dm/phy.c b/test/dm/phy.c
> index a90881b12ab..a93aa83ab10 100644
> --- a/test/dm/phy.c
> +++ b/test/dm/phy.c
> @@ -246,6 +246,13 @@ static int dm_test_phy_setup(struct unit_test_state *uts)
>  	ut_assertok(generic_setup_phy(parent, &phy, 0, PHY_MODE_USB_HOST, 0));
>  	ut_assertok(generic_shutdown_phy(&phy));
>  
> +	/* set_mode as USB Host passes, anything else is not supported */
> +	ut_assertok(generic_setup_phy(parent, &phy, 0, PHY_MODE_USB_HOST, 0));
> +	ut_assertok(generic_phy_set_mode(&phy, PHY_MODE_USB_HOST, 0));
> +	ut_asserteq(-EOPNOTSUPP, generic_phy_set_mode(&phy, PHY_MODE_USB_HOST, 1));
> +	ut_asserteq(-EINVAL, generic_phy_set_mode(&phy, PHY_MODE_USB_DEVICE, 0));
> +	ut_assertok(generic_shutdown_phy(&phy));
> +
>  	/* power_off fail with -EIO */
>  	ut_assertok(generic_setup_phy(parent, &phy, 1, PHY_MODE_USB_HOST, 0));
>  	ut_asserteq(-EIO, generic_shutdown_phy(&phy));
> -- 
> 2.43.0

  reply	other threads:[~2024-07-09  9:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 17:36 [PATCH v2 1/3] phy: Extend generic_setup_phy() with PHY mode and submode Marek Vasut
2024-06-17 17:36 ` [PATCH v2 2/3] phy: rcar: Split init and set_mode operations Marek Vasut
2024-07-09  9:24   ` Mattijs Korpershoek
2024-06-17 17:36 ` [PATCH v2 3/3] phy: test: Implement sandbox PHY .set_mode and DM test Marek Vasut
2024-07-09  9:33   ` Mattijs Korpershoek [this message]
2024-07-09  9:20 ` [PATCH v2 1/3] phy: Extend generic_setup_phy() with PHY mode and submode Mattijs Korpershoek
2024-09-08 18:11 ` Marek Vasut
2024-09-09  7:16   ` Mattijs Korpershoek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87msmqj4fe.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=caleb.connolly@linaro.org \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=festevam@gmail.com \
    --cc=iwamatsu@nigauri.org \
    --cc=jonas@kwiboo.se \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=neil.armstrong@linaro.org \
    --cc=nm@ti.com \
    --cc=othacehe@gnu.org \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=xdrudis@tinet.cat \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox