LAN969x SGPIO
1. SoC Resources
The Serial GPIO Controller for LAN969x supports as many Serial GPIOs as configured in the device tree.
The EVB-LAN9696-24port EVB has 128 input and 128 output.
2. Kernel configurations
Following kernel config options should be enabled to use LAN969x GPIO Controller:
-
CONFIG_PINCTRL_MICROCHIP_SGPIO
- Serial GPIO controller config option.
3. Devicetree Configuration
To use SGPIO pins of a specific peripheral, configure following properties in the device tree:
-
compatible
must be set to"microchip,sparx5-sgpio"
. -
reg
must be set to<0xe2010230 0x118>
. -
clocks
must refer to the 320MHz core clock<&fx100_clk>
. -
reset-names
must be set to"switch"
. -
resets
must refer to the switch reset controllers reset signal, e.g.<&reset 0>
. -
#address-cells
must be 1. -
#size-cells
must be 0.
For each direction there must be a child node.
For the IN direction the following properties must be provided:
-
compatible
must be set to"microchip,sparx5-sgpio-bank"
. -
reg
must be set to<0>
. -
gpio-controller
must be set. -
#gpio-cells
must be set to 3. -
interrupts
must be set to<GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>
.
Peripheral |
Shared Peripheral Interrupt |
CPU INTR |
sgpio |
48 |
16 |
- Note
-
Shared peripheral interrupt lines start at index ID32. So, CPU INTR must be calculated as [Shared peripheral interrupt number - 32].
-
interrupt-controller
must be set. -
#interrupt-cells
must be set to 3. -
#address-cells
must be set to 0.
-
For the OUT direction the following properties must be provided:
-
compatible
must be set to"microchip,sparx5-sgpio-bank"
. -
reg
must be set to 1. -
gpio-controller
must be set. -
#gpio-cells
must be set to 3.
3.2. Example
Following example shows how an SGPIO controller should be defined in the DT to enable SGPIO pins for a mux controller and an SFP.
The clients refer to the IN and OUT directions to get the appropriate SGPIOs.
dtsi file:
sgpio: gpio@e2010230 { compatible = "microchip,sparx5-sgpio"; reg = <0xe2010230 0x118>; clocks = <&fx100_clk>; resets = <&reset 0>; reset-names = "switch"; #address-cells = <1>; #size-cells = <0>; status = "disabled"; sgpio_in: gpio@0 { compatible = "microchip,sparx5-sgpio-bank"; reg = <0>; gpio-controller; #gpio-cells = <3>; interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; interrupt-controller; #interrupt-cells = <3>; #address-cells = <0>; }; sgpio_out: gpio@1 { compatible = "microchip,sparx5-sgpio-bank"; reg = <1>; gpio-controller; #gpio-cells = <3>; }; };
dts file changes to use the SGPIO:
&gpio { sgpio_pins: sgpio-pins { /* SCK, D0, D1, LD */ pins = "GPIO_5", "GPIO_6", "GPIO_7", "GPIO_8"; function = "sgpio_a"; }; }; &sgpio { pinctrl-0 = <&sgpio_pins>; pinctrl-names = "default"; microchip,sgpio-port-ranges = <0 1>, <6 9>; status = "okay"; gpio@0 { ngpios = <128>; }; gpio@1 { ngpios = <128>; }; }; / { mux-controller { compatible = "gpio-mux"; #mux-control-cells = <0>; mux-gpios = <&sgpio_out 1 2 GPIO_ACTIVE_LOW>, <&sgpio_out 1 3 GPIO_ACTIVE_LOW>; }; sfp0: sfp0 { compatible = "sff,sfp"; i2c-bus = <&i2c_sfp0>; tx-disable-gpios = <&sgpio_out 6 2 GPIO_ACTIVE_HIGH>; los-gpios = <&sgpio_in 6 0 GPIO_ACTIVE_HIGH>; mod-def0-gpios = <&sgpio_in 6 1 GPIO_ACTIVE_LOW>; tx-fault-gpios = <&sgpio_in 6 2 GPIO_ACTIVE_HIGH>; }; };
4. UserSpace
4.1. Confirm instances are created
Checking if the SGPIO driver is registered:
# cat /sys/kernel/debug/pinctrl/pinctrl-devices name [pinmux] [pinconf] lan969x-pinctrl yes yes e2010230.gpio-input yes yes e2010230.gpio-output yes yes
Here the lan969x-pinctrl is the device described on this page, and the e2010230.gpio-input and e2010230.gpio-output are the Serial GPIO Controllers two direction nodes - each of them being its own pin controller device.
4.2. Setting the SFP LEDs
The LEDs for the SFP cages are available via SGPIOs:
leds { compatible = "gpio-leds"; led-s6-green { label = "s6:green"; gpios = <&sgpio_out 6 0 GPIO_ACTIVE_LOW>; default-state = "off"; }; led-s6-yellow { label = "s6:yellow"; gpios = <&sgpio_out 6 1 GPIO_ACTIVE_LOW>; default-state = "off"; }; ... more LED nodes follows... };
You can locate the LEDs in sysfs with:
# find /sys/class/leds/ /sys/class/leds/ /sys/class/leds/s7:green /sys/class/leds/s6:yellow /sys/class/leds/s7:yellow /sys/class/leds/s8:yellow /sys/class/leds/s8:green /sys/class/leds/s9:yellow /sys/class/leds/s9:green /sys/class/leds/s6:green /sys/class/leds/mmc0::
Now you can turn on the green LED of the Serdes 6 SFP using:
# echo 1 > /sys/class/leds/s6:green/brightness
And you can turn it off again using;
# echo 0 > /sys/class/leds/s6:green/brightness