Andrew Neyland | 7ebaff3 | 2023-08-29 14:48:27 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | findmtd() { |
| 4 | m=$(grep -xl "$1" /sys/class/mtd/*/name) |
| 5 | m=${m%/name} |
| 6 | m=${m##*/} |
| 7 | echo "$m" |
| 8 | } |
| 9 | |
| 10 | hostPrime=$(findmtd host-prime) |
| 11 | if test -z "$hostPrime" |
| 12 | then |
| 13 | echo "Unable to find mtd partition for ${hostPrime}" |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | hostSecond=$(findmtd host-second) |
| 18 | if test -z "$hostSecond" |
| 19 | then |
| 20 | echo "Unable to find mtd partition for ${hostSecond}" |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | vromPrime=$(findmtd vrom-prime) |
| 25 | if test -z "$vromPrime" |
| 26 | then |
| 27 | echo "Unable to find mtd partition for ${vromPrime}" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | vromSecond=$(findmtd vrom-second) |
| 32 | if test -z "$vromSecond" |
| 33 | then |
| 34 | echo "Unable to find mtd partition for ${vromSecond}" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | |
| 39 | #enable vrom |
| 40 | # host-prime to vrom-prime |
| 41 | dd if=/dev/"${hostPrime}" of=/dev/"${vromPrime}" |
| 42 | # host-second to vrom-second |
| 43 | dd if=/dev/"${hostSecond}" of=/dev/"${vromSecond}" |
| 44 | |
| 45 | # enable UART on rl300 |
| 46 | systemctl start obmc-console@ttyS3.service |
| 47 | |
| 48 | echo 0x1800008a > /sys/class/soc/srom/vromoff |
| 49 | |
| 50 | devmem 0xd1000008 8 128 |
| 51 | devmem 0xd1000009 8 36 |
| 52 | devmem 0xd1000041 8 255 |
| 53 | devmem 0xd100004b 8 8 |
| 54 | # setup PCIe ID |
| 55 | devmem 0x802f002e 16 0x03d8 |
| 56 | #enable debug vsp output |
| 57 | devmem 0x80fc0230 8 0x1 |
| 58 | |
| 59 | # Check the current power status |
| 60 | |
| 61 | currentstate=$(busctl get-property xyz.openbmc_project.State.Chassis0 /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | awk '{ print $2 }') |
| 62 | |
| 63 | |
| 64 | if [ "$currentstate" = "\"xyz.openbmc_project.State.Chassis.PowerState.On\"" ] |
| 65 | then |
| 66 | systemctl stop phosphor-virtual-sensor.service |
| 67 | sleep 2 |
| 68 | devmem 0x80fc0230 8 0x1 |
| 69 | systemctl start phosphor-virtual-sensor.service |
| 70 | fi |
| 71 | |
| 72 | while 'true' |
| 73 | do |
| 74 | sleep 1 |
| 75 | done |