1#!/bin/bash 2# 3# Copyright (c) 2020 Ampere Computing LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Ampere Computing LLC mtjade: UART MUX/DEMUX for CPU0 UART0,1,4 and CPU1 UART1 18# Usage: ampere_uartmux_ctrl.sh <CPU UART port number> <UARTx_MODE> 19# <UARTx_MODE> of 1 sets CPU To BSP 20# <UARTx_MODE> of 2 sets SCP1 to SI2 21source /usr/sbin/kudo-lib.sh 22 23if [ $# -lt 1 ]; then 24 exit 1 25fi 26 27echo "Ampere UART MUX CTRL UART port $1 to mode" > /dev/ttyS0 28 29case "$1" in 30 ttyS1) 31 set_gpio_ctrl 167 out 1 32 ;; 33 ttyS3) 34 set_gpio_ctrl 161 out 1 35 set_gpio_ctrl 183 out 1 36 set_gpio_ctrl 198 out 0 37 ;; 38 *) 39 echo "Invalid tty passed to $0. Exiting!" > /dev/ttyS0 40 ;; 41esac 42 43