Re: [PATCH net v3] net: phy: intel-xway: enable integrated led functions

From: Tim Harvey
Date: Tue Feb 01 2022 - 15:55:07 EST


On Tue, Apr 20, 2021 at 10:51 PM Martin Schiller <ms@xxxxxxxxxx> wrote:
>
> The Intel xway phys offer the possibility to deactivate the integrated
> LED function and to control the LEDs manually.
> If this was set by the bootloader, it must be ensured that the
> integrated LED function is enabled for all LEDs when loading the driver.
>
> Before commit 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
> the LEDs were enabled by a soft-reset of the PHY (using
> genphy_soft_reset). Initialize the XWAY_MDIO_LED with it's default
> value (which is applied during a soft reset) instead of adding back
> the soft reset. This brings back the default LED configuration while
> still preventing an excessive amount of soft resets.
>
> Fixes: 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
> Signed-off-by: Martin Schiller <ms@xxxxxxxxxx>
> ---
>
> Changes to v2:
> o Fixed commit message
> o Fixed email recipients once again.
>
> Changes to v1:
> Added additional email recipients.
>
> ---
> drivers/net/phy/intel-xway.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/net/phy/intel-xway.c b/drivers/net/phy/intel-xway.c
> index 6eac50d4b42f..d453ec016168 100644
> --- a/drivers/net/phy/intel-xway.c
> +++ b/drivers/net/phy/intel-xway.c
> @@ -11,6 +11,18 @@
>
> #define XWAY_MDIO_IMASK 0x19 /* interrupt mask */
> #define XWAY_MDIO_ISTAT 0x1A /* interrupt status */
> +#define XWAY_MDIO_LED 0x1B /* led control */
> +
> +/* bit 15:12 are reserved */
> +#define XWAY_MDIO_LED_LED3_EN BIT(11) /* Enable the integrated function of LED3 */
> +#define XWAY_MDIO_LED_LED2_EN BIT(10) /* Enable the integrated function of LED2 */
> +#define XWAY_MDIO_LED_LED1_EN BIT(9) /* Enable the integrated function of LED1 */
> +#define XWAY_MDIO_LED_LED0_EN BIT(8) /* Enable the integrated function of LED0 */
> +/* bit 7:4 are reserved */
> +#define XWAY_MDIO_LED_LED3_DA BIT(3) /* Direct Access to LED3 */
> +#define XWAY_MDIO_LED_LED2_DA BIT(2) /* Direct Access to LED2 */
> +#define XWAY_MDIO_LED_LED1_DA BIT(1) /* Direct Access to LED1 */
> +#define XWAY_MDIO_LED_LED0_DA BIT(0) /* Direct Access to LED0 */
>
> #define XWAY_MDIO_INIT_WOL BIT(15) /* Wake-On-LAN */
> #define XWAY_MDIO_INIT_MSRE BIT(14)
> @@ -159,6 +171,15 @@ static int xway_gphy_config_init(struct phy_device *phydev)
> /* Clear all pending interrupts */
> phy_read(phydev, XWAY_MDIO_ISTAT);
>
> + /* Ensure that integrated led function is enabled for all leds */
> + err = phy_write(phydev, XWAY_MDIO_LED,
> + XWAY_MDIO_LED_LED0_EN |
> + XWAY_MDIO_LED_LED1_EN |
> + XWAY_MDIO_LED_LED2_EN |
> + XWAY_MDIO_LED_LED3_EN);
> + if (err)
> + return err;
> +
> phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDCH,
> XWAY_MMD_LEDCH_NACS_NONE |
> XWAY_MMD_LEDCH_SBF_F02HZ |
> --
> 2.20.1
>

Hi Martin,

Similar to my response in another thread to how be393dd685d2 ("net:
phy: intel-xway: Add RGMII internal delay configuration") which
changes the tx/rx interna delays to default values of 2ns if the
common delay properties are not found in the dt and thus may override
what boot firmware configured, I do not like the fact that this patch
just overrides LED configuration that boot firmware may have setup.

I am aware that there is not much consistency in PHY's for LED
configuration which makes coming up with common dt bindings impossible
but I feel that if PHY drivers add LED configuration they should only
apply it if new bindings are found instructing it to. Perhaps it makes
sense to at least create a common binding that allows configuration of
LED's here?

As a person responsible for boot firmware through kernel for a set of
boards I continue to do the following to keep Linux from mucking with
various PHY configurations:
- remove PHY reset pins from Linux DT's to keep Linux from hard resetting PHY's
- disabling PHY drivers

What are your thoughts about this?

Best regards,

Tim