mbox series

[v1,pinctrl-next,0/1] add blink and activity functions to SGPIO

Message ID 20211229003729.618079-1-colin.foster@in-advantage.com (mailing list archive)
Headers show
Series add blink and activity functions to SGPIO | expand

Message

Colin Foster Dec. 29, 2021, 12:37 a.m. UTC
Expose a debugfs / devicetree interface for Microsemi SGPIO controllers.
By writing values of 2-5, the SGPIO pins can be configured for either
automatic blinking or activity.

The implementation is modeled after the code in
/drivers/pinctrl/pinctrl-ocelot.c.

I have only tested this with currently out-of-tree patches for the
VSC7512 that I hope to get in soon. They are not needed for VSC7513 /
VSC7514, SPARX5, or LUTON - but I don't have any hardware to test.

Of note: the 7512 chip has a discrepancy between the datasheet and the
registers. The datahseet claims 20Hz blink default frequency, the
registers claim 5 Hz default frequency for BMODE_0. I override the
OCELOT registers to correct for this. I don't know if that is needed for
LUTON or SPARX, but having two blink modes at the same frequency isn't
beneficial. As such, I make the blink modes match the 5Hz / 20Hz for the
two modes.

Tested with VSC7512 by way of:
echo SGPIO_O_p1b0 {blink0,blink1,activity0,activity1} > 
/sys/kernel/debug/pinctrl/pinctrl-sgpio-pinctrl-sgpio-output/pinmux-select

LEDs blink!


Colin Foster (1):
  pinctrl: microchip-sgpio: add activity and blink functionality

 drivers/pinctrl/pinctrl-microchip-sgpio.c | 135 +++++++++++++++++++++-
 1 file changed, 130 insertions(+), 5 deletions(-)

Comments

Andrew Lunn Dec. 29, 2021, 9:30 a.m. UTC | #1
On Tue, Dec 28, 2021 at 04:37:28PM -0800, Colin Foster wrote:
> Expose a debugfs / devicetree interface for Microsemi SGPIO controllers.
> By writing values of 2-5, the SGPIO pins can be configured for either
> automatic blinking or activity.
> 
> The implementation is modeled after the code in
> /drivers/pinctrl/pinctrl-ocelot.c.
> 
> I have only tested this with currently out-of-tree patches for the
> VSC7512 that I hope to get in soon. They are not needed for VSC7513 /
> VSC7514, SPARX5, or LUTON - but I don't have any hardware to test.
> 
> Of note: the 7512 chip has a discrepancy between the datasheet and the
> registers. The datahseet claims 20Hz blink default frequency, the
> registers claim 5 Hz default frequency for BMODE_0. I override the
> OCELOT registers to correct for this. I don't know if that is needed for
> LUTON or SPARX, but having two blink modes at the same frequency isn't
> beneficial. As such, I make the blink modes match the 5Hz / 20Hz for the
> two modes.
> 
> Tested with VSC7512 by way of:
> echo SGPIO_O_p1b0 {blink0,blink1,activity0,activity1} > 
> /sys/kernel/debug/pinctrl/pinctrl-sgpio-pinctrl-sgpio-output/pinmux-select

Hi Colin

Since this is an LED, you should be using the Linux LED interface in
/sys/class/leds. See Documentation/leds/leds-class.rst. It includes a
way to make an LED blink, using hardware.

Activity is another story. I assume you mean Ethernet frame Rx and Tx?
For that you should wait until the Ethernet LED offload code
eventually lands.

	   Andrew
Colin Foster Dec. 29, 2021, 7:08 p.m. UTC | #2
On Wed, Dec 29, 2021 at 10:30:54AM +0100, Andrew Lunn wrote:
> On Tue, Dec 28, 2021 at 04:37:28PM -0800, Colin Foster wrote:
> > Expose a debugfs / devicetree interface for Microsemi SGPIO controllers.
> > By writing values of 2-5, the SGPIO pins can be configured for either
> > automatic blinking or activity.
> > 
> > The implementation is modeled after the code in
> > /drivers/pinctrl/pinctrl-ocelot.c.
> > 
> > I have only tested this with currently out-of-tree patches for the
> > VSC7512 that I hope to get in soon. They are not needed for VSC7513 /
> > VSC7514, SPARX5, or LUTON - but I don't have any hardware to test.
> > 
> > Of note: the 7512 chip has a discrepancy between the datasheet and the
> > registers. The datahseet claims 20Hz blink default frequency, the
> > registers claim 5 Hz default frequency for BMODE_0. I override the
> > OCELOT registers to correct for this. I don't know if that is needed for
> > LUTON or SPARX, but having two blink modes at the same frequency isn't
> > beneficial. As such, I make the blink modes match the 5Hz / 20Hz for the
> > two modes.
> > 
> > Tested with VSC7512 by way of:
> > echo SGPIO_O_p1b0 {blink0,blink1,activity0,activity1} > 
> > /sys/kernel/debug/pinctrl/pinctrl-sgpio-pinctrl-sgpio-output/pinmux-select
> 
> Hi Colin
> 
> Since this is an LED, you should be using the Linux LED interface in
> /sys/class/leds. See Documentation/leds/leds-class.rst. It includes a
> way to make an LED blink, using hardware.

Hi Andrew,

With the static LEDs that is exactly how I have them configured. I was
happy when they all "just worked" when I tied them to the phy activity.
My thanks to all those who did this hard work before me!

I have noticed an issue in my setup where using a heartbeat trigger on
any of the outputs causes a kernel bug "scheduling while atomic." It
seems to be trying to interrupt spi_sync... Sorry, I'm getting off
track, and I'll deal with that in time. Luckily it is very reproducable!

> 
> Activity is another story. I assume you mean Ethernet frame Rx and Tx?
> For that you should wait until the Ethernet LED offload code
> eventually lands.

I've been following those threads a little bit. Seemingly a few emails
between August and November. I suspect it'll require at least some version 
of this patch, but it is probably best to wait and see where that lands
first. Thanks!

> 
> 	   Andrew