blob: 6b47395044f643239529d5a0c1ba31c658629f0e [file] [log] [blame]
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +01001#!/bin/bash
Brad Bishop7b587372017-08-01 21:13:28 -04002#
3# Copyright © 2017 IBM Corporation
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
18# Check a max31785 firmware revision and set the MSL property
19# on the specified inventory items.
20
21set -e
22
23main()
24{
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010025 usage="Usage: $(basename "$0") -p PATH... -b BUS_NUMBER -r REVISION"
Brad Bishop7b587372017-08-01 21:13:28 -040026 while getopts p:b:r:h key; do
27 case $key in
28 p)
29 paths=$OPTARG
30 ;;
31 b)
32 bus=$OPTARG
33 ;;
34 r)
35 revision=$OPTARG
36 ;;
37 h)
38 echo "$usage" >&2
39 exit
40 ;;
41 \?)
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010042 printf "\nUnrecognized option\n"
Brad Bishop7b587372017-08-01 21:13:28 -040043 echo "$usage" >&2
44 exit 1
45 ;;
46 esac
47 done
48
49 if [ -z "$paths" ] || [ -z "$bus" ] || [ -z "$revision" ]; then
50 echo "Missing option" >&2
51 echo "$usage" >&2
52 exit 1
53 fi
54
55 local state="false"
56 local actual
57 local dbus
58
59 dbus=$(mapper get-service /xyz/openbmc_project/inventory)
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010060 actual=$(i2cget -f -y "$bus" 0x52 0x9b w)
Brad Bishop7b587372017-08-01 21:13:28 -040061
62 if (( actual >= revision )); then
63 state="true"
64 fi
65
66 for path in $paths; do
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010067 busctl call "$dbus" /xyz/openbmc_project/inventory \
Brad Bishop7b587372017-08-01 21:13:28 -040068 xyz.openbmc_project.Inventory.Manager Notify 'a{oa{sa{sv}}}' 1 \
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010069 "$path" 1 \
Brad Bishop7b587372017-08-01 21:13:28 -040070 xyz.openbmc_project.Inventory.Decorator.MeetsMinimumShipLevel \
Anton D. Kachalovbc58dec2021-03-16 13:39:14 +010071 1 MeetsMinimumShipLevel b "$state"
Brad Bishop7b587372017-08-01 21:13:28 -040072 done
73}
74
75main "$@"