From: Andrew Lunn <andrew@lunn•ch>
To: "Marek Behún" <kabel@kernel•org>
Cc: linux-leds@vger•kernel.org, netdev@vger•kernel.org,
Pavel Machek <pavel@ucw•cz>, Dan Murphy <dmurphy@ti•com>,
Russell King <linux@armlinux•org.uk>,
Matthias Schiffer <matthias.schiffer@ew•tq-group.com>,
Jacek Anaszewski <jacek.anaszewski@gmail•com>,
Mauro Carvalho Chehab <mchehab+huawei@kernel•org>
Subject: Re: [PATCH leds v2 10/10] leds: turris-omnia: support offloading netdev trigger for WAN LED
Date: Tue, 1 Jun 2021 23:19:30 +0200 [thread overview]
Message-ID: <YLakYvTTO3BTG0q6@lunn.ch> (raw)
In-Reply-To: <20210601005155.27997-11-kabel@kernel.org>
> +static int omnia_led_trig_offload_wan(struct omnia_leds *leds,
> + struct omnia_led *led,
> + struct led_netdev_data *trig)
> +{
> + unsigned long period;
> + int ret, blink_rate;
> + bool link, rx, tx;
> + u8 fun;
> +
> + /* HW offload on WAN port is supported only via internal PHY */
> + if (trig->net_dev->sfp_bus || !trig->net_dev->phydev)
> + return -EOPNOTSUPP;
> +
> + link = test_bit(NETDEV_LED_LINK, &trig->mode);
> + rx = test_bit(NETDEV_LED_RX, &trig->mode);
> + tx = test_bit(NETDEV_LED_TX, &trig->mode);
> +
> + if (link && rx && tx)
> + fun = 0x1;
> + else if (!link && rx && tx)
> + fun = 0x4;
> + else
> + return -EOPNOTSUPP;
> +
> + period = jiffies_to_msecs(atomic_read(&trig->interval)) * 2;
> + blink_rate = wan_led_round_blink_rate(&period);
> + if (blink_rate < 0)
> + return blink_rate;
> +
> + mutex_lock(&leds->lock);
> +
> + if (!led->phydev) {
> + led->phydev = trig->net_dev->phydev;
> + get_device(&led->phydev->mdio.dev);
> + }
> +
> + /* set PHY's LED[0] pin to blink according to trigger setting */
> + ret = phy_modify_paged(led->phydev, MII_MARVELL_LED_PAGE,
> + MII_PHY_LED_TCR,
> + MII_PHY_LED_TCR_PULSESTR_MASK |
> + MII_PHY_LED_TCR_BLINKRATE_MASK,
> + (0 << MII_PHY_LED_TCR_PULSESTR_SHIFT) |
> + (blink_rate << MII_PHY_LED_TCR_BLINKRATE_SHIFT));
> + if (ret)
> + goto unlock;
> +
> + ret = phy_modify_paged(led->phydev, MII_MARVELL_LED_PAGE,
> + MII_PHY_LED_CTRL, 0xf, fun);
> + if (ret)
> + goto unlock;
This needs to be in the Marvell PHY driver. Please add a generic
interface any PHY driver can implement to allow its LEDs to be
controlled.
Andrew
next prev parent reply other threads:[~2021-06-01 21:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 0:51 [PATCH leds v2 00/10] Add support for offloading netdev trigger to HW + example implementation for Turris Omnia Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 01/10] leds: trigger: netdev: don't explicitly zero kzalloced data Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 02/10] leds: trigger: add API for HW offloading of triggers Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 03/10] leds: trigger: netdev: move trigger data structure to global include dir Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 04/10] leds: trigger: netdev: support HW offloading Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 05/10] leds: trigger: netdev: change spinlock to mutex Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 06/10] leds: core: inform trigger that it's deactivation is due to LED removal Marek Behún
2021-06-01 21:12 ` Andrew Lunn
2021-06-02 12:44 ` Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 07/10] leds: turris-omnia: refactor sw mode setting code into separate function Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 08/10] leds: turris-omnia: refactor brightness setting function Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 09/10] leds: turris-omnia: initialize each multicolor LED to white color Marek Behún
2021-06-01 0:51 ` [PATCH leds v2 10/10] leds: turris-omnia: support offloading netdev trigger for WAN LED Marek Behún
2021-06-01 1:44 ` Marek Behún
2021-06-01 21:19 ` Andrew Lunn [this message]
2025-10-16 11:43 ` [PATCH leds v2 00/10] Add support for offloading netdev trigger to HW + example implementation for Turris Omnia Lad, Prabhakar
2025-10-16 13:14 ` Andrew Lunn
2025-10-16 18:53 ` Lad, Prabhakar
2025-10-16 19:11 ` Andrew Lunn
2025-10-16 19:25 ` Lad, Prabhakar
2025-10-16 19:44 ` Andrew Lunn
2025-10-17 15:23 ` Lad, Prabhakar
2025-10-21 10:50 ` Lee Jones
2025-11-05 13:32 ` Lad, Prabhakar
2025-11-05 15:48 ` Andrew Lunn
2025-11-05 17:52 ` Lad, Prabhakar
2025-11-05 18:35 ` Andrew Lunn
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=YLakYvTTO3BTG0q6@lunn.ch \
--to=andrew@lunn$(echo .)ch \
--cc=dmurphy@ti$(echo .)com \
--cc=jacek.anaszewski@gmail$(echo .)com \
--cc=kabel@kernel$(echo .)org \
--cc=linux-leds@vger$(echo .)kernel.org \
--cc=linux@armlinux$(echo .)org.uk \
--cc=matthias.schiffer@ew$(echo .)tq-group.com \
--cc=mchehab+huawei@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pavel@ucw$(echo .)cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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