George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | TARGET_FILE_NAME="/etc/nvme/nvme_config.json" |
| 4 | |
| 5 | export_gpio() { |
| 6 | if [ ! -d "/sys/class/gpio/gpio$1" ]; then |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 7 | echo "$1" >/sys/class/gpio/export |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 8 | fi |
| 9 | } |
| 10 | |
| 11 | # Get NVMeDrivePresentPins |
| 12 | # 1-0024 |
| 13 | |
| 14 | # Get NVMeDrivePwrGoodPins |
| 15 | # 1-0021 |
| 16 | |
| 17 | if [ -d "/sys/bus/i2c/drivers/pca953x/1-0024" ]; then |
| 18 | presentPinBase="$(cat /sys/bus/i2c/drivers/pca953x/1-0024/gpio/gpiochip*/base)" |
| 19 | for i in {0..15}; |
| 20 | do |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 21 | export_gpio $(( presentPinBase + i )) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 22 | done |
| 23 | else |
| 24 | echo "Can't find present gpio expander (addr: 0x24) !!" |
| 25 | fi |
| 26 | |
| 27 | if [ -d "/sys/bus/i2c/drivers/pca953x/1-0021" ]; then |
| 28 | PwrGoodPinBase="$(cat /sys/bus/i2c/drivers/pca953x/1-0021/gpio/gpiochip*/base)" |
| 29 | for i in {0..15}; |
| 30 | do |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 31 | export_gpio $(( PwrGoodPinBase + i )) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 32 | done |
| 33 | else |
| 34 | echo "Can't find powergood gpio expander (addr: 0x21) !!" |
| 35 | fi |
| 36 | |
| 37 | cat > $TARGET_FILE_NAME << EOF1 |
| 38 | { |
| 39 | "config": [ |
| 40 | { |
| 41 | "NVMeDriveIndex": 0, |
| 42 | "NVMeDriveBusID": 47, |
| 43 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_0_fault", |
| 44 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_0_locate", |
| 45 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_0_locate", |
| 46 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_0_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 47 | "NVMeDrivePresentPin": $(( presentPinBase + 3)), |
| 48 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 3)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 49 | }, |
| 50 | { |
| 51 | "NVMeDriveIndex": 1, |
| 52 | "NVMeDriveBusID": 46, |
| 53 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_1_fault", |
| 54 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_1_locate", |
| 55 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_1_locate", |
| 56 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_1_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 57 | "NVMeDrivePresentPin": $(( presentPinBase + 2)), |
| 58 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 2)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 59 | }, |
| 60 | { |
| 61 | "NVMeDriveIndex": 2, |
| 62 | "NVMeDriveBusID": 45, |
| 63 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_2_fault", |
| 64 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_2_locate", |
| 65 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_2_locate", |
| 66 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_2_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 67 | "NVMeDrivePresentPin": $(( presentPinBase + 1)), |
| 68 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 1)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 69 | }, |
| 70 | { |
| 71 | "NVMeDriveIndex": 3, |
| 72 | "NVMeDriveBusID": 44, |
| 73 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_3_fault", |
| 74 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_3_locate", |
| 75 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_3_locate", |
| 76 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_3_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 77 | "NVMeDrivePresentPin": $(( presentPinBase + 0)), |
| 78 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 0)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 79 | }, |
| 80 | { |
| 81 | "NVMeDriveIndex": 4, |
| 82 | "NVMeDriveBusID": 39, |
| 83 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_4_fault", |
| 84 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_4_locate", |
| 85 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_4_locate", |
| 86 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_4_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 87 | "NVMeDrivePresentPin": $(( presentPinBase + 7)), |
| 88 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 7)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 89 | }, |
| 90 | { |
| 91 | "NVMeDriveIndex": 5, |
| 92 | "NVMeDriveBusID": 38, |
| 93 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_5_fault", |
| 94 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_5_locate", |
| 95 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_5_locate", |
| 96 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_5_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 97 | "NVMeDrivePresentPin": $(( presentPinBase + 6)), |
| 98 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 6)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 99 | }, |
| 100 | { |
| 101 | "NVMeDriveIndex": 6, |
| 102 | "NVMeDriveBusID": 37, |
| 103 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_6_fault", |
| 104 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_6_locate", |
| 105 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_6_locate", |
| 106 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_6_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 107 | "NVMeDrivePresentPin": $(( presentPinBase + 5)), |
| 108 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 5)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 109 | }, |
| 110 | { |
| 111 | "NVMeDriveIndex": 7, |
| 112 | "NVMeDriveBusID": 36, |
| 113 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_7_fault", |
| 114 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_7_locate", |
| 115 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_7_locate", |
| 116 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_7_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 117 | "NVMeDrivePresentPin": $(( presentPinBase + 4)), |
| 118 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 4)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 119 | }, |
| 120 | { |
| 121 | "NVMeDriveIndex": 8, |
| 122 | "NVMeDriveBusID": 31, |
| 123 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_8_fault", |
| 124 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_8_locate", |
| 125 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_8_locate", |
| 126 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_8_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 127 | "NVMeDrivePresentPin": $(( presentPinBase + 11)), |
| 128 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 11)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 129 | }, |
| 130 | { |
| 131 | "NVMeDriveIndex": 9, |
| 132 | "NVMeDriveBusID": 30, |
| 133 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_9_fault", |
| 134 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_9_locate", |
| 135 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_9_locate", |
| 136 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_9_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 137 | "NVMeDrivePresentPin": $(( presentPinBase + 10)), |
| 138 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 10)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 139 | }, |
| 140 | { |
| 141 | "NVMeDriveIndex": 10, |
| 142 | "NVMeDriveBusID": 29, |
| 143 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_10_fault", |
| 144 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_10_locate", |
| 145 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_10_locate", |
| 146 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_10_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 147 | "NVMeDrivePresentPin": $(( presentPinBase + 9)), |
| 148 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 9)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 149 | }, |
| 150 | { |
| 151 | "NVMeDriveIndex": 11, |
| 152 | "NVMeDriveBusID": 28, |
| 153 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_11_fault", |
| 154 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_11_locate", |
| 155 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_11_locate", |
| 156 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_11_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 157 | "NVMeDrivePresentPin": $(( presentPinBase + 8)), |
| 158 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 8)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 159 | }, |
| 160 | { |
| 161 | "NVMeDriveIndex": 12, |
| 162 | "NVMeDriveBusID": 27, |
| 163 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_12_fault", |
| 164 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_12_locate", |
| 165 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_12_locate", |
| 166 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_12_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 167 | "NVMeDrivePresentPin": $(( presentPinBase + 15)), |
| 168 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 15)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 169 | }, |
| 170 | { |
| 171 | "NVMeDriveIndex": 13, |
| 172 | "NVMeDriveBusID": 26, |
| 173 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_13_fault", |
| 174 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_13_locate", |
| 175 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_13_locate", |
| 176 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_13_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 177 | "NVMeDrivePresentPin": $(( presentPinBase + 14)), |
| 178 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 14)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 179 | }, |
| 180 | { |
| 181 | "NVMeDriveIndex": 14, |
| 182 | "NVMeDriveBusID": 25, |
| 183 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_14_fault", |
| 184 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_14_locate", |
| 185 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_14_locate", |
| 186 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_14_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 187 | "NVMeDrivePresentPin": $(( presentPinBase + 13)), |
| 188 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 13)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 189 | }, |
| 190 | { |
| 191 | "NVMeDriveIndex": 15, |
| 192 | "NVMeDriveBusID": 24, |
| 193 | "NVMeDriveFaultLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_15_fault", |
| 194 | "NVMeDriveLocateLEDGroupPath": "/xyz/openbmc_project/led/groups/led_u2_15_locate", |
| 195 | "NVMeDriveLocateLEDControllerBusName": "xyz.openbmc_project.LED.Controller.led_u2_15_locate", |
| 196 | "NVMeDriveLocateLEDControllerPath": "/xyz/openbmc_project/led/physical/led_u2_15_locate", |
Patrick Williams | 8c22623 | 2023-04-15 20:05:21 -0500 | [diff] [blame^] | 197 | "NVMeDrivePresentPin": $(( presentPinBase + 12)), |
| 198 | "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 12)) |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 199 | } |
| 200 | ], |
| 201 | "threshold": [ |
| 202 | { |
George Hung | b36f363 | 2021-07-05 11:26:28 +0800 | [diff] [blame] | 203 | "criticalHigh": 72, |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 204 | "criticalLow": 0, |
George Hung | b36f363 | 2021-07-05 11:26:28 +0800 | [diff] [blame] | 205 | "warningHigh": 72, |
George Hung | 9dcc357 | 2020-06-30 15:48:16 +0800 | [diff] [blame] | 206 | "warningLow": 0, |
| 207 | "maxValue": 127, |
| 208 | "minValue": -128 |
| 209 | } |
| 210 | ] |
| 211 | } |
| 212 | EOF1 |