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 export_gpio $(( presentPinBase + i )) 22 done 23else 24 echo "Can't find present gpio expander (addr: 0x24) !!" 25fi 26 27if [ -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 31 export_gpio $(( PwrGoodPinBase + i )) 32 done 33else 34 echo "Can't find powergood gpio expander (addr: 0x21) !!" 35fi 36 37cat > $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", 47 "NVMeDrivePresentPin": $(( presentPinBase + 3)), 48 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 3)) 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", 57 "NVMeDrivePresentPin": $(( presentPinBase + 2)), 58 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 2)) 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", 67 "NVMeDrivePresentPin": $(( presentPinBase + 1)), 68 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 1)) 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", 77 "NVMeDrivePresentPin": $(( presentPinBase + 0)), 78 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 0)) 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", 87 "NVMeDrivePresentPin": $(( presentPinBase + 7)), 88 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 7)) 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", 97 "NVMeDrivePresentPin": $(( presentPinBase + 6)), 98 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 6)) 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", 107 "NVMeDrivePresentPin": $(( presentPinBase + 5)), 108 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 5)) 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", 117 "NVMeDrivePresentPin": $(( presentPinBase + 4)), 118 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 4)) 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", 127 "NVMeDrivePresentPin": $(( presentPinBase + 11)), 128 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 11)) 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", 137 "NVMeDrivePresentPin": $(( presentPinBase + 10)), 138 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 10)) 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", 147 "NVMeDrivePresentPin": $(( presentPinBase + 9)), 148 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 9)) 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", 157 "NVMeDrivePresentPin": $(( presentPinBase + 8)), 158 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 8)) 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", 167 "NVMeDrivePresentPin": $(( presentPinBase + 15)), 168 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 15)) 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", 177 "NVMeDrivePresentPin": $(( presentPinBase + 14)), 178 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 14)) 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", 187 "NVMeDrivePresentPin": $(( presentPinBase + 13)), 188 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 13)) 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", 197 "NVMeDrivePresentPin": $(( presentPinBase + 12)), 198 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 12)) 199 } 200 ], 201 "threshold": [ 202 { 203 "criticalHigh": 72, 204 "criticalLow": 0, 205 "warningHigh": 72, 206 "warningLow": 0, 207 "maxValue": 127, 208 "minValue": -128 209 } 210 ] 211} 212EOF1 213