meta-ampere: console: refactor configuration

Refactor console configuration for Mt.Jade and Mt.Mitchell to avoid
duplication and make the configuration files simpler.

Tested:
1. IPMI sol on Mt.Jade and Mt.Mitchell works
2. SOL SSH on Mt.Jade and Mt.Mitchell work for all console ports

Change-Id: I68d1a3c6be530ca93f8adc1dd61906ba8b206dc5
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uart_console_setup.sh b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uart_console_setup.sh
new file mode 100644
index 0000000..fa8d5e9
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uart_console_setup.sh
@@ -0,0 +1,40 @@
+#!/bin/sh -e
+#
+# Platform can add tty ports for console server to OBMC_CONSOLE_TTYS in their
+# bbappend. The target tty devices exposed by kernel will then start their
+# corresponding obmc-console-server instance and the
+# obmc-console@<tty-port>.service will execute this script to direct the uart
+# port of the <tty-port> to BMC
+
+tty="$1"
+uart=0
+
+case "${tty}" in
+ "ttyS0") uart=1
+ ;;
+ "ttyS1") uart=2
+ ;;
+ "ttyS2") uart=3
+ ;;
+ "ttyS3") uart=4
+ ;;
+ "ttyS7")
+   # Socket 1 UART 1 connects directly to BMC UART 8
+   echo "Ampere UART MUX CTRL UART port 8 to mode 2"
+   exit 0
+ ;;
+ "ttyS8")
+   # Socket 1 UART 4 connects directly to BMC UART 9
+   echo "Ampere UART MUX CTRL UART port 9 to mode 2"
+   exit 0
+ ;;
+ *) echo "Invalid tty passed to $0. Exiting!"
+    exit 1;
+ ;;
+esac
+
+# Default the host routing through the mux to use the BMC (2)
+# This allows the SoL console in webui, and the ssh port 2200, to work
+# upon startup. If UART transcievers are installed on the header and required,
+# this value should be set to 1
+/usr/sbin/ampere_uartmux_ctrl.sh ${uart} 2
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console_%.bbappend b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console_%.bbappend
index 605c9e1..c45db95 100644
--- a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console_%.bbappend
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console_%.bbappend
@@ -5,25 +5,20 @@
 OBMC_CONSOLE_TTYS = "ttyS0 ttyS1 ttyS2 ttyS3 ttyS7 ttyS8"
 CONSOLE_CLIENT = "2200 2201 2202 2203 2204 2205"
 
-CONSOLE_SERVER_CONF_FMT = "file://server.{0}.conf"
-CONSOLE_CLIENT_CONF_FMT = "file://client.{0}.conf"
-CONSOLE_CLIENT_SERVICE_FMT = "obmc-console-ssh@{0}.service"
-
 SRC_URI += " \
              ${@compose_list(d, 'CONSOLE_SERVER_CONF_FMT', 'OBMC_CONSOLE_TTYS')} \
              ${@compose_list(d, 'CONSOLE_CLIENT_CONF_FMT', 'CONSOLE_CLIENT')} \
+             file://ampere_uart_console_setup.sh \
            "
 
 SYSTEMD_SERVICE:${PN}:append = " \
                                   ${@compose_list(d, 'CONSOLE_CLIENT_SERVICE_FMT', 'CONSOLE_CLIENT')} \
                                 "
-SYSTEMD_SERVICE:${PN}:remove = "obmc-console-ssh.socket"
-
-FILES:${PN}:remove = "${systemd_system_unitdir}/obmc-console-ssh@.service.d/use-socket.conf"
-
-PACKAGECONFIG:append = " concurrent-servers"
 
 do_install:append() {
+    # Script to set host's uart muxes to BMC
+    install -m 0755 ${WORKDIR}/ampere_uart_console_setup.sh ${D}${sbindir}
+
     # Install the console client configurations
-    install -m 0644 ${WORKDIR}/client.*.conf ${D}${sysconfdir}/${BPN}/
+    install -m 0644 ${WORKDIR}/client.*.conf ${D}${sysconfdir}/${BPN}
 }
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
index d3a1eb60..e2d5396 100644
--- a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
@@ -1,3 +1,3 @@
-SOCKET_ID=default
+#SOCKET_ID defaults to "default"
 MODE=stream
 STREAM_DST=/run/rsyslog/console/cpu