From 0df300e2a16ff0064ff82638f53639f78bac3fca Mon Sep 17 00:00:00 2001
From: Benjamin Larsson <benjamin.larsson@iopsys.eu>
Date: Thu, 23 Apr 2020 19:32:34 +0200
Subject: [PATCH] panther: fix wan sfp/copper switching

---
 iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B        | 4 +++-
 .../panther/base-files/lib/functions/marvell.sh             | 6 +++---
 iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan   | 3 +++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B b/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
index 8e6cb5d8e..80b8f57dd 100644
--- a/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
+++ b/iopsys-brcm63xx-arm/base-files/lib/db/boards/XG6846B
@@ -6,7 +6,9 @@ config board 'board'
 	option hasEthWan '1'
 	option hasVoice '0'
 	option hasDect '0'
-	option hasUsb '0'
+	option hasUsb '1'
+	option VoicePorts '0'
+	option VoiceLeds '0'
 	option hasWifi '0'
 	option hasSfp '1'
 	# Voice
diff --git a/iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh b/iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
index 792ae67c5..22fb08ebb 100644
--- a/iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
+++ b/iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
@@ -108,9 +108,9 @@ has_power() {
 wan_sfp_mode () {
         # check if there is a sfp-rom present and return 0 if so
         # returns 2 if there is an error
-        # i2cget -y 0 0x50 0x0 >/dev/null 2>&1
-        # return $?
-	return 0
+        i2cget -y 0 0x50 0x0 >/dev/null 2>&1
+        return $?
+        # return 0
 }
 
 disable_ext_led () {
diff --git a/iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan b/iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
index 8554f56aa..6d87a16c7 100755
--- a/iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
+++ b/iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
@@ -32,7 +32,10 @@ get_link() {
                                                 ubus call led.wan_speed set {\"state\":\"OK\"}
                                         else
                                                 ubus call led.wan_speed set {\"state\":\"NOTICE\"}
+                                        fi
                                 fi
+                        else
+                            ubus call led.wan_speed set {\"state\":\"OFF\"}
                         fi
                         sleep 5
                 else
-- 
GitLab