blob: 323be600645583b59422b1f41ff42a2511608cfe [file] [log] [blame]
George Hung9dcc3572020-06-30 15:48:16 +08001#!/bin/bash
2
3TARGET_FILE_NAME="/etc/nvme/nvme_config.json"
4
5export_gpio() {
6 if [ ! -d "/sys/class/gpio/gpio$1" ]; then
Patrick Williams8c226232023-04-15 20:05:21 -05007 echo "$1" >/sys/class/gpio/export
George Hung9dcc3572020-06-30 15:48:16 +08008 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
Patrick Williams8c226232023-04-15 20:05:21 -050021 export_gpio $(( presentPinBase + i ))
George Hung9dcc3572020-06-30 15:48:16 +080022 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
Patrick Williams8c226232023-04-15 20:05:21 -050031 export_gpio $(( PwrGoodPinBase + i ))
George Hung9dcc3572020-06-30 15:48:16 +080032 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",
Patrick Williams8c226232023-04-15 20:05:21 -050047 "NVMeDrivePresentPin": $(( presentPinBase + 3)),
48 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 3))
George Hung9dcc3572020-06-30 15:48:16 +080049 },
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 Williams8c226232023-04-15 20:05:21 -050057 "NVMeDrivePresentPin": $(( presentPinBase + 2)),
58 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 2))
George Hung9dcc3572020-06-30 15:48:16 +080059 },
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 Williams8c226232023-04-15 20:05:21 -050067 "NVMeDrivePresentPin": $(( presentPinBase + 1)),
68 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 1))
George Hung9dcc3572020-06-30 15:48:16 +080069 },
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 Williams8c226232023-04-15 20:05:21 -050077 "NVMeDrivePresentPin": $(( presentPinBase + 0)),
78 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 0))
George Hung9dcc3572020-06-30 15:48:16 +080079 },
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 Williams8c226232023-04-15 20:05:21 -050087 "NVMeDrivePresentPin": $(( presentPinBase + 7)),
88 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 7))
George Hung9dcc3572020-06-30 15:48:16 +080089 },
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 Williams8c226232023-04-15 20:05:21 -050097 "NVMeDrivePresentPin": $(( presentPinBase + 6)),
98 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 6))
George Hung9dcc3572020-06-30 15:48:16 +080099 },
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 Williams8c226232023-04-15 20:05:21 -0500107 "NVMeDrivePresentPin": $(( presentPinBase + 5)),
108 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 5))
George Hung9dcc3572020-06-30 15:48:16 +0800109 },
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 Williams8c226232023-04-15 20:05:21 -0500117 "NVMeDrivePresentPin": $(( presentPinBase + 4)),
118 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 4))
George Hung9dcc3572020-06-30 15:48:16 +0800119 },
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 Williams8c226232023-04-15 20:05:21 -0500127 "NVMeDrivePresentPin": $(( presentPinBase + 11)),
128 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 11))
George Hung9dcc3572020-06-30 15:48:16 +0800129 },
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 Williams8c226232023-04-15 20:05:21 -0500137 "NVMeDrivePresentPin": $(( presentPinBase + 10)),
138 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 10))
George Hung9dcc3572020-06-30 15:48:16 +0800139 },
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 Williams8c226232023-04-15 20:05:21 -0500147 "NVMeDrivePresentPin": $(( presentPinBase + 9)),
148 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 9))
George Hung9dcc3572020-06-30 15:48:16 +0800149 },
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 Williams8c226232023-04-15 20:05:21 -0500157 "NVMeDrivePresentPin": $(( presentPinBase + 8)),
158 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 8))
George Hung9dcc3572020-06-30 15:48:16 +0800159 },
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 Williams8c226232023-04-15 20:05:21 -0500167 "NVMeDrivePresentPin": $(( presentPinBase + 15)),
168 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 15))
George Hung9dcc3572020-06-30 15:48:16 +0800169 },
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 Williams8c226232023-04-15 20:05:21 -0500177 "NVMeDrivePresentPin": $(( presentPinBase + 14)),
178 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 14))
George Hung9dcc3572020-06-30 15:48:16 +0800179 },
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 Williams8c226232023-04-15 20:05:21 -0500187 "NVMeDrivePresentPin": $(( presentPinBase + 13)),
188 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 13))
George Hung9dcc3572020-06-30 15:48:16 +0800189 },
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 Williams8c226232023-04-15 20:05:21 -0500197 "NVMeDrivePresentPin": $(( presentPinBase + 12)),
198 "NVMeDrivePwrGoodPin": $(( PwrGoodPinBase + 12))
George Hung9dcc3572020-06-30 15:48:16 +0800199 }
200 ],
201 "threshold": [
202 {
George Hungb36f3632021-07-05 11:26:28 +0800203 "criticalHigh": 72,
George Hung9dcc3572020-06-30 15:48:16 +0800204 "criticalLow": 0,
George Hungb36f3632021-07-05 11:26:28 +0800205 "warningHigh": 72,
George Hung9dcc3572020-06-30 15:48:16 +0800206 "warningLow": 0,
207 "maxValue": 127,
208 "minValue": -128
209 }
210 ]
211}
212EOF1