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