Anton D. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 2 | # |
| 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 | |
| 21 | set -e |
| 22 | |
| 23 | main() |
| 24 | { |
Anton D. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 25 | usage="Usage: $(basename "$0") -p PATH... -b BUS_NUMBER -r REVISION" |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 26 | 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. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 42 | printf "\nUnrecognized option\n" |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 43 | 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. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 60 | actual=$(i2cget -f -y "$bus" 0x52 0x9b w) |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 61 | |
| 62 | if (( actual >= revision )); then |
| 63 | state="true" |
| 64 | fi |
| 65 | |
| 66 | for path in $paths; do |
Anton D. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 67 | busctl call "$dbus" /xyz/openbmc_project/inventory \ |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 68 | xyz.openbmc_project.Inventory.Manager Notify 'a{oa{sa{sv}}}' 1 \ |
Anton D. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 69 | "$path" 1 \ |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 70 | xyz.openbmc_project.Inventory.Decorator.MeetsMinimumShipLevel \ |
Anton D. Kachalov | bc58dec | 2021-03-16 13:39:14 +0100 | [diff] [blame] | 71 | 1 MeetsMinimumShipLevel b "$state" |
Brad Bishop | 7b58737 | 2017-08-01 21:13:28 -0400 | [diff] [blame] | 72 | done |
| 73 | } |
| 74 | |
| 75 | main "$@" |