Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,11 @@
[Unit]
Description = Mt.Jade Platform Initialization
[Service]
Restart=no
RemainAfterExit=true
Type=oneshot
ExecStart=/usr/sbin/ampere_platform_init.sh
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,51 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
source /usr/sbin/gpio-defs.sh
source /usr/sbin/ampere_uart_console_setup.sh
# Configure to boot from MAIN SPI-HOST
gpio_configure_output "$SPI0_BACKUP_SEL" 0
gpio_configure_input "$S0_I2C9_ALERT_L"
gpio_configure_input "$S1_I2C9_ALERT_L"
gpio_configure_input "$GPIO_BMC_VGA_FRONT_PRES_L"
gpio_configure_input "$GPIO_S0_VRHOT_L"
gpio_configure_input "$GPIO_S1_VRHOT_L"
gpio_configure_output "$BMC_VGA_SEL" 1
# =======================================================
# Below GPIOs are controlled by other services so just
# initialize in A/C power only.
bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
if [ "$bootstatus" == '32' ]; then
gpio_configure_output "$BMC_GPIOR2_EXT_HIGHTEMP_L" 1
gpio_configure_output "$GPIO_BMC_VR_PMBUS_SEL_L" 1
gpio_configure_output "$GPIO_BMC_I2C6_RESET_L" 1
# Initialize OCP register
gpio_configure_output "$OCP_MAIN_PWREN" 0
# Configure SPI-NOR/EEPROM switching
gpio_configure_output "$SPI0_PROGRAM_SEL" 0
gpio_configure_output "$BMC_I2C_BACKUP_SEL" 1
gpio_configure_output "$SPI0_BACKUP_SEL" 0
# Initialize BMC_SYS_PSON_L, SHD_REQ_L, BMC_SYSRESET_L
gpio_configure_output "$SYS_PSON_L" 1
gpio_configure_output "$S0_SHD_REQ_L" 1
gpio_configure_output "$S0_SYSRESET_L" 1
gpio_configure_output "$S1_SYSRESET_L" 1
# RTC Lock, SPECIAL_BOOT
gpio_configure_output "$RTC_LOCK" 0
gpio_configure_output "$S0_SPECIAL_BOOT" 0
gpio_configure_output "$S1_SPECIAL_BOOT" 0
fi
gpio_configure_output "$BMC_READY" 1
# =======================================================
# Setting uart muxes to BMC as default
uart_console_setup
@@ -0,0 +1,57 @@
#!/bin/sh -e
#
# Copyright (c) 2020 Ampere Computing LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# shellcheck disable=SC2039
# shellcheck disable=SC2112
# shellcheck disable=SC3010
# shellcheck disable=SC3030
# shellcheck disable=SC3054
export obmc_console_tty=("ttyS0" "ttyS1" "ttyS2" "ttyS3")
function get_uart_port()
{
tty=$1
case "${tty}" in
"ttyS0") uart=1
;;
"ttyS1") uart=2
;;
"ttyS2") uart=3
;;
"ttyS3") uart=4
;;
*) echo "Invalid tty passed to $0. Exiting!"
exit 1;
;;
esac
echo $uart
}
function uart_console_setup()
{
# 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
for tty in "${obmc_console_tty[@]}"; do
uart=$(get_uart_port "$tty")
if [ "${uart}" -ne 0 ]
then
/usr/sbin/ampere_uartmux_ctrl.sh "${uart}" 2
fi
done
}
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright (c) 2021 Ampere Computing LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Ampere Computing LLC: UART MUX/DEMUX for CPU0 UART0,1,4 and CPU1 UART1
# Usage: ampere_uartmux_ctrl.sh <CPU UART port number> <UARTx_MODE>
# <UARTx_MODE> of 1 sets CPU To HDR_CONN
# <UARTx_MODE> of 2 sets BMC to CPU (eg dropbear ssh server on port 2200)
# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
if [ $# -lt 2 ]; then
exit 1
fi
case "$1" in
1) GPIO_UARTx_MODE0=56
;;
2) GPIO_UARTx_MODE0=57
;;
3) GPIO_UARTx_MODE0=58
;;
4) GPIO_UARTx_MODE0=59
;;
*) echo "Invalid UART port selection"
exit 1
;;
esac
echo "Ampere UART MUX CTRL UART port $1 to mode $2"
case "$2" in
1) gpio_configure_output "${GPIO_UARTx_MODE0}" 0
exit 0
;;
2) gpio_configure_output "${GPIO_UARTx_MODE0}" 1
exit 0
;;
*) echo "Invalid UART mode selection"
exit 1
;;
esac