From 5a0edb34ac09a256154a61a485bb0d49f124c264 Mon Sep 17 00:00:00 2001
From: Samuel Angebault <angebault.samuel@gmail.com>
Date: Tue, 27 Mar 2018 09:32:05 -0700
Subject: [PATCH] [device]: Enable arista drivers for sonic-linux-kernel 4.9
 (#21)

* Enable arista drivers

* Add vfat ascii charset in initramfs

* Update boot0.j2 for 4.9 kernel

* Fix i2c offsets in sensors.conf

* Bump sonic-platform-modules-arista submodule
---
 .../x86_64-arista_7050_qx32/sensors.conf      | 20 +++++++++----------
 .../x86_64-arista_7050_qx32s/sensors.conf     | 10 +++++-----
 files/Aboot/boot0.j2                          |  6 ++++--
 files/initramfs-tools/modules                 |  1 +
 platform/broadcom/rules.mk                    |  2 +-
 .../broadcom/sonic-platform-modules-arista    |  2 +-
 6 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/device/arista/x86_64-arista_7050_qx32/sensors.conf b/device/arista/x86_64-arista_7050_qx32/sensors.conf
index 469f63eaf1e4..8b6ca752fe83 100644
--- a/device/arista/x86_64-arista_7050_qx32/sensors.conf
+++ b/device/arista/x86_64-arista_7050_qx32/sensors.conf
@@ -2,21 +2,21 @@
 # ------------------------------------------------
 #
 
-bus "i2c-2" "SCD SMBus master 0 bus 0"
-bus "i2c-3" "SCD SMBus master 0 bus 1"
-bus "i2c-5" "SCD SMBus master 0 bus 3"
-bus "i2c-6" "SCD SMBus master 0 bus 4"
-bus "i2c-7" "SCD SMBus master 0 bus 5"
+bus "i2c-5" "SCD 0000:04:00.0 SMBus master 0 bus 0"
+bus "i2c-6" "SCD 0000:04:00.0 SMBus master 0 bus 1"
+bus "i2c-8" "SCD 0000:04:00.0 SMBus master 0 bus 3"
+bus "i2c-9" "SCD 0000:04:00.0 SMBus master 0 bus 4"
+bus "i2c-10" "SCD 0000:04:00.0 SMBus master 0 bus 5"
 
 chip "k10temp-pci-00c3"
     label temp1 "Cpu temp sensor"
 
-chip "lm73-i2c-3-48"
+chip "lm73-i2c-6-48"
     label temp1 "Back panel temp sensor"
     set temp1_max 65
     #set temp1_max_alarm 75 # read-only
 
-chip "max6658-i2c-2-4c"
+chip "max6658-i2c-5-4c"
     label temp1 "Board temp sensor"
     set temp1_max 65
     set temp1_crit 75
@@ -26,7 +26,7 @@ chip "max6658-i2c-2-4c"
     set temp2_crit 75
 
 # disabled because of some eeprom corruption risks
-#chip "pmbus-i2c-3-4e"
+#chip "pmbus-i2c-6-4e"
 #    label temp1 "Power controller sensor 1"
 #    set temp1_max 60
 #    set temp1_crit 70
@@ -37,7 +37,7 @@ chip "max6658-i2c-2-4c"
 
 #    ignore curr1
 
-chip "dps460-i2c-5-58"
+chip "dps460-i2c-8-58"
     label temp1 "Power supply 1 inlet temp sensor"
     # maximum and critical thresholds are not supported for this psu
     set temp1_max 60
@@ -59,7 +59,7 @@ chip "dps460-i2c-5-58"
     set curr2_max 36
     set curr2_crit 37
 
-chip "dps460-i2c-6-58"
+chip "dps460-i2c-9-58"
     label temp1 "Power supply 2 inlet temp sensor"
     # maximum and critical thresholds are not supported for this psu
     set temp1_max 60
diff --git a/device/arista/x86_64-arista_7050_qx32s/sensors.conf b/device/arista/x86_64-arista_7050_qx32s/sensors.conf
index 9c2dd38597a3..6030de90eea5 100644
--- a/device/arista/x86_64-arista_7050_qx32s/sensors.conf
+++ b/device/arista/x86_64-arista_7050_qx32s/sensors.conf
@@ -2,11 +2,11 @@
 # ------------------------------------------------
 #
 
-bus "i2c-2" "SCD SMBus master 0 bus 0"
-bus "i2c-3" "SCD SMBus master 0 bus 1"
-bus "i2c-5" "SCD SMBus master 0 bus 3"
-bus "i2c-6" "SCD SMBus master 0 bus 4"
-bus "i2c-7" "SCD SMBus master 0 bus 5"
+bus "i2c-2" "SCD 0000:02:00.0 SMBus master 0 bus 0"
+bus "i2c-3" "SCD 0000:02:00.0 SMBus master 0 bus 1"
+bus "i2c-5" "SCD 0000:02:00.0 SMBus master 0 bus 3"
+bus "i2c-6" "SCD 0000:02:00.0 SMBus master 0 bus 4"
+bus "i2c-7" "SCD 0000:02:00.0 SMBus master 0 bus 5"
 
 chip "k10temp-pci-00c3"
     label temp1 "Cpu temp sensor"
diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2
index ee77746676e0..2dc75e2f83bb 100644
--- a/files/Aboot/boot0.j2
+++ b/files/Aboot/boot0.j2
@@ -153,12 +153,12 @@ platform_specific() {
     if [ "$platform" = "raven" ]; then
         aboot_machine=arista_7050_qx32
         flash_size=2000
-        echo "modprobe.blacklist=radeon" >>/tmp/append
+        echo "modprobe.blacklist=radeon,sp5100_tco acpi=off" >>/tmp/append
     fi
     if [ "$platform" = "crow" ]; then
         aboot_machine=arista_7050_qx32s
         flash_size=3700
-        echo "modprobe.blacklist=radeon" >>/tmp/append
+        echo "modprobe.blacklist=radeon,sp5100_tco" >>/tmp/append
     fi
     if [ "$sid" = "Upperlake" ] || [ "$sid" = "UpperlakeES" ]; then
         aboot_machine=arista_7060_cx32s
@@ -185,6 +185,8 @@ platform_specific() {
     fi
 
     echo "varlog_size=$varlog_size" >>/tmp/append
+    # disable deterministic interface naming
+    echo "net.ifnames=0" >>/tmp/append
 }
 
 get_uuid_for() {
diff --git a/files/initramfs-tools/modules b/files/initramfs-tools/modules
index 33f28b98b3f7..e7fcbef870d2 100644
--- a/files/initramfs-tools/modules
+++ b/files/initramfs-tools/modules
@@ -1,5 +1,6 @@
 squashfs
 overlay
 vfat
+nls_ascii
 nls_cp437
 nls_utf8
diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk
index a065506a4287..582af46b86a9 100755
--- a/platform/broadcom/rules.mk
+++ b/platform/broadcom/rules.mk
@@ -2,7 +2,7 @@ include $(PLATFORM_PATH)/sdk.mk
 include $(PLATFORM_PATH)/sai.mk
 include $(PLATFORM_PATH)/platform-modules-s6000.mk
 include $(PLATFORM_PATH)/platform-modules-dell.mk
-#include $(PLATFORM_PATH)/platform-modules-arista.mk
+include $(PLATFORM_PATH)/platform-modules-arista.mk
 include $(PLATFORM_PATH)/platform-modules-ingrasys.mk
 include $(PLATFORM_PATH)/platform-modules-accton.mk
 include $(PLATFORM_PATH)/platform-modules-inventec.mk
diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista
index 86221d907f27..ef8a53d6d095 160000
--- a/platform/broadcom/sonic-platform-modules-arista
+++ b/platform/broadcom/sonic-platform-modules-arista
@@ -1 +1 @@
-Subproject commit 86221d907f27e7f6df40393a5bfe217bf22b19af
+Subproject commit ef8a53d6d09560b6844b4f508ef18103f1df6c37