From 094410d12a17c32d66c083247adf933174e90680 Mon Sep 17 00:00:00 2001
From: Markus Gothe <markus.gothe@genexis.eu>
Date: Mon, 10 May 2021 17:53:25 +0200
Subject: [PATCH] RM#30920 - FT-PX2310, manual control of 10G Ethernet PHY LED

Add necessary callback-script and LED mapping for 10GBE PHY LED.

This commit updates LED mapping and adds a script which should be
used to control the LED. The script is based on the commands in
the ticket and Eduardo's work for Sphinx1.

Change-Id: Ibf98802e410f197384ad0ce73bf51d28ebd494dc
---
 .../base-files/sbin/external_led_ctrl.sh      | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100755 iopsys-brcm63xx-arm/tiger/base-files/sbin/external_led_ctrl.sh

diff --git a/iopsys-brcm63xx-arm/tiger/base-files/sbin/external_led_ctrl.sh b/iopsys-brcm63xx-arm/tiger/base-files/sbin/external_led_ctrl.sh
new file mode 100755
index 000000000..5fa11fd9d
--- /dev/null
+++ b/iopsys-brcm63xx-arm/tiger/base-files/sbin/external_led_ctrl.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+readonly LEDPHY="$1"
+readonly ARGUMENT="$2"
+readonly PARAMETER="$3"
+
+if [ "$ARGUMENT" = "setup" -o "$ARGUMENT" = "exit_testmode" ]; then
+        # Default
+        echo write45 2 "$LEDPHY" 0xa83b 0xa482 > /proc/driver/phy/cmd
+        # Green
+        echo write45 2 "$LEDPHY" 0xa838 0x80 > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa8f3 0x0 > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa83a 0x0 > /proc/driver/phy/cmd
+        # Yellow
+        echo write45 2 "$LEDPHY" 0xa832 0x18 > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa8f1 0xc > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa834 0x0 > /proc/driver/phy/cmd
+
+        # Led blink stretch
+        echo write45 2 "$LEDPHY" 0xa8ec 0x02ff > /proc/driver/phy/cmd
+        rm -rf "/tmp/external_led_testmode_${LEDPHY}"
+elif [ "$ARGUMENT" = "enter_testmode" ]; then
+        echo write45 2 "$LEDPHY" 0xa832 0x20 > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa838 0x20 > /proc/driver/phy/cmd
+        echo write45 2 "$LEDPHY" 0xa83b 0x0 > /proc/driver/phy/cmd
+        touch "/tmp/external_led_testmode_${LEDPHY}"
+elif [ "$ARGUMENT" = "brightness" ]; then
+        if [ "$PARAMETER" = "0" ]; then
+                echo write45 2 "$LEDPHY" 0xa832 0x20 > /proc/driver/phy/cmd
+                echo write45 2 "$LEDPHY" 0xa838 0x20 > /proc/driver/phy/cmd
+                echo write45 2 "$LEDPHY" 0xa83b 0x0 > /proc/driver/phy/cmd
+        else
+                if [ ! -f "/tmp/external_led_testmode_${LEDPHY}" ]; then
+                        # Default
+                        echo write45 2 "$LEDPHY" 0xa83b 0xa482 > /proc/driver/phy/cmd
+                        # Green
+                        echo write45 2 "$LEDPHY" 0xa838 0x80 > /proc/driver/phy/cmd
+                        echo write45 2 "$LEDPHY" 0xa8f3 0x0 > /proc/driver/phy/cmd
+                        echo write45 2 "$LEDPHY" 0xa83a 0x0 > /proc/driver/phy/cmd
+                        # Yellow
+                        echo write45 2 "$LEDPHY" 0xa832 0x18 > /proc/driver/phy/cmd
+                        echo write45 2 "$LEDPHY" 0xa8f1 0xc > /proc/driver/phy/cmd
+                        echo write45 2 "$LEDPHY" 0xa834 0x0 > /proc/driver/phy/cmd
+
+                        # Led blink stretch
+                        echo write45 2 "$LEDPHY" 0xa8ec 0x02ff > /proc/driver/phy/cmd
+                else
+                        echo write45 2 "$LEDPHY" 0xa832 0x20 > /proc/driver/phy/cmd
+                        echo write45 2 "$LEDPHY" 0xa838 0x20 > /proc/driver/phy/cmd
+                        # 10GE LEDs turn on
+                        echo write45 2 "$LEDPHY" 0xa83b 0x2080 > /proc/driver/phy/cmd
+                fi
+        fi
+fi
-- 
GitLab