firmware: Update intel_sync_upstream script to accomodate JSL

Currently the script is implemented only for TGL. Update the script to
accomodate JSL SoC. Also move the script to firmware path.

BUG=None
TEST=ran ./intel_sync_upstream.sh jsl edk2-platforms JSL.2114.03
     ran ./intel_sync_upstream.sh jsl edk2 JSL.2114.03
     ran ./intel_sync_upstream.sh jsl fsp JSL.2114.03

Change-Id: I8fec34e81393659385945e209bfc60493fafe2f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2198195
Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Reviewed-by: Dossym Nurmukhanov <dossym@chromium.org>
Commit-Queue: Dossym Nurmukhanov <dossym@chromium.org>
diff --git a/contrib/firmware/tgl/intel_sync_upstream.sh b/contrib/firmware/intel_sync_upstream.sh
similarity index 86%
rename from contrib/firmware/tgl/intel_sync_upstream.sh
rename to contrib/firmware/intel_sync_upstream.sh
index 375d23c..8fe5a87 100755
--- a/contrib/firmware/tgl/intel_sync_upstream.sh
+++ b/contrib/firmware/intel_sync_upstream.sh
@@ -3,6 +3,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+SOC_LIST=(tgl jsl)
+declare -A SOC_EDK_LOCAL_DIR_MAP=( ["tgl"]="branch2-private" ["jsl"]="branch1-private" )
+
 function die()
 {
   if [ $1 -ne 0 ]; then
@@ -15,28 +18,33 @@
 function usage()
 {
   echo "Error: missing parameter."
-  echo "Usage: $0 [fsp|edk2|edk2-platforms] version_string"
-  echo "Example: $0 fsp 'TGL.2527_17'"
+  echo "Usage: $0 SOC [fsp|edk2|edk2-platforms] version_string"
+  echo "Example: $0 tgl fsp 'TGL.2527_17'"
   exit -42
 }
 
 # Verify param count
-if [ "$#" -ne "2" ]; then
+if [ "$#" -ne "3" ]; then
   usage
 fi;
-DIR="$1"
-VERSION="$2"
+SOC="$1"
+DIR="$2"
+VERSION="$3"
+
+if [[ ! "${SOC_LIST[*]}" =~ ${SOC} ]]; then
+  die 1 "SoC is not supported"
+fi
 
 case $DIR in
   fsp)
-    STAGING_PREFIX="tgl"
+    STAGING_PREFIX=${SOC}
     CHROMEOS_BRANCH=chromeos
     ;;
 
   edk2 | edk2-platforms)
     STAGING_PREFIX=$DIR
-    LOCAL_DIR=branch2-private
-    CHROMEOS_BRANCH=chromeos-tgl-$LOCAL_DIR
+    LOCAL_DIR="${SOC_EDK_LOCAL_DIR_MAP[${SOC}]}"
+    CHROMEOS_BRANCH=chromeos-${SOC}-$LOCAL_DIR
     ;;
 
   *)
@@ -60,8 +68,8 @@
 fi
 
 # Clone the repo where the staging changes need to be pushed
-pushd "${CHROMIUM_TOT_ROOT}/src/third_party/fsp/tgl/$DIR/$LOCAL_DIR" > /dev/null
-die $? "Can't find ${CHROMIUM_TOT_ROOT}/src/third_party/fsp/tgl/$DIR/$LOCAL_DIR"
+pushd "${CHROMIUM_TOT_ROOT}/src/third_party/fsp/${SOC}/$DIR/$LOCAL_DIR" > /dev/null
+die $? "Can't find ${CHROMIUM_TOT_ROOT}/src/third_party/fsp/${SOC}/$DIR/$LOCAL_DIR"
 
 # Add staging repo as remote repo to my local repo
 git remote add ${STAGING_PREFIX}-staging https://chrome-internal.googlesource.com/chromeos/third_party/intel-fsp/${STAGING_PREFIX}-staging