blob: d75d4b74d1e5f1e54a196f2e53ebd85d1a8c2d7b [file] [log] [blame]
Joel Stanley42ed6de2018-05-11 13:34:07 +09301#!/bin/sh
2# Copyright 2018 IBM Corp
3# SPDX-License-Identifier: Apache-2.0
4# Authored May 2018, Joel Stanley <joel@jms.id.au>
5#
6# This script sets the SIO scratch registers 0x2D in order to configure
7# hostboot. It supports boot flags v1 as defined in hostboot source:
8# src/usr/initservice/bootconfig/bootconfig_ast2400.C
9# src/usr/console/ast2400.C
10#
11# BOOT_FLAGS_VERSION_REG = 0x28,
12# Serial config reg: 0x2d
13# Serial config mask: 0xc0
14#
15# NONE = 0x00, // No output selected
16# SELECT_SUART = 0x40, // SIO Uart
17# SELECT_VUART = 0x80, // SOL virtual uart
18# RESERVED = 0xc0, // Reserved
19
20
21SYSFS_SIO=/sys/devices/platform/ahb/ahb:apb/1e789000.lpc/1e789080.lpc-host/1e789080.lpc-host:regs
22SYSFS_SIO28=$SYSFS_SIO/sio_28
23SYSFS_SIO2D=$SYSFS_SIO/sio_2d
24
25FLAGS_VERSION1=$((0x42))
26
27usage()
28{
29 echo "usage: hb_settings [[-u|--uart vuart|suart|none] | [-s|--show] | [-h]]"
30}
31
32show_regs()
33{
34 SIO28=$(cat $SYSFS_SIO28)
35 SIO2D=$(cat $SYSFS_SIO2D)
36
37 case $SIO28 in
38 $FLAGS_VERSION1)
39 echo "Boot flags version 1"
40 ;;
41 * )
42 echo "Unknown boot flags version"
43 ;;
44 esac
45
46 case $(($SIO2D >> 6)) in
47 0)
48 echo "Hostboot serial output disabled"
49 ;;
50 1)
51 echo "Hostboot serial output on SUART"
52 ;;
53 2)
54 echo "Hostboot serial output on VUART"
55 ;;
56 3)
57 echo "Reserved value"
58 ;;
59 * )
60 echo "Invalid uart value"
61 ;;
62 esac
63}
64
65set_regs()
66{
67 case $uart in
68 suart)
69 echo "Hostboot serial output on SUART"
70 VAL=0x40
71 ;;
72 vuart)
73 echo "Hostboot serial output on VUART"
74 VAL=0x80
75 ;;
76 none)
77 echo "Hostboot serial output disabled"
78 VAL=0x00
79 ;;
80 * )
81 echo "Invalid uart value"
82 usage
83 exit 1
84 esac
85
86 echo $FLAGS_VERSION1 > $SYSFS_SIO28
87 echo $VAL > $SYSFS_SIO2D
88}
89
90while [ "$1" != "" ]; do
91 case $1 in
92 -u | --uart) shift
93 uart=$1
94 set_regs
95 exit
96 ;;
97 -s | --show ) show_regs
98 exit
99 ;;
100 -h | --help ) usage
101 exit
102 ;;
103 * ) usage
104 exit 1
105 esac
106 shift
107done
108
109usage
110exit 0