Hi Marek,

Thank you for the patch.

On lun., juin 17, 2024 at 19:36, Marek Vasut <[email protected]> 
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 <[email protected]>

Reviewed-by: Mattijs Korpershoek <[email protected]>

> ---
> Cc: Caleb Connolly <[email protected]>
> Cc: Fabio Estevam <[email protected]>
> Cc: Fabrice Gasnier <[email protected]>
> Cc: Jonas Karlman <[email protected]>
> Cc: Mathieu Othacehe <[email protected]>
> Cc: Mattijs Korpershoek <[email protected]>
> Cc: Neil Armstrong <[email protected]>
> Cc: Nishanth Menon <[email protected]>
> Cc: Nobuhiro Iwamatsu <[email protected]>
> Cc: Sean Anderson <[email protected]>
> Cc: Simon Glass <[email protected]>
> Cc: Sumit Garg <[email protected]>
> Cc: Tim Harvey <[email protected]>
> Cc: Tom Rini <[email protected]>
> Cc: Xavier Drudis Ferran <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> 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 via email to