blob: ef4c07470ffec65c56886eaeb942f3650c0ceaf1 [file] [log] [blame]
Bob Kingdcb4b3b2019-12-17 18:07:06 +08001{
2 "$schema": "http://json-schema.org/schema#",
3 "title": "JSON schema for the phosphor-regulators config file",
4 "$id": "https://github.com/openbmc/phosphor-power/tree/master/phosphor-regulators/schema/config_schema.json",
5 "description": "This schema describes the JSON format for the phosphor-regulators configuration file.",
6 "type": "object",
Bob Kingdcb4b3b2019-12-17 18:07:06 +08007 "properties":
8 {
9 "comments":
10 {
11 "$ref": "#/definitions/comments"
12 },
13 "rules":
14 {
15 "$ref": "#/definitions/rules"
16 },
17 "chassis":
18 {
19 "$ref": "#/definitions/chassis"
20 }
21 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080022 "required": ["chassis"],
23 "additionalProperties": false,
Bob Kingdcb4b3b2019-12-17 18:07:06 +080024 "definitions":
25 {
26 "rules":
27 {
28 "type": "array",
29 "items":
30 {
31 "type": "object",
32 "properties":
33 {
34 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080035 "id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080036 "actions": {"$ref": "#/definitions/actions" }
37 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080038 "required": ["id", "actions"],
39 "additionalProperties": false
40 },
41 "minItems": 1
42 },
43
44 "comments":
45 {
46 "type": "array",
47 "items":
48 {
49 "type": "string"
50 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080051 "minItems": 1
52 },
53
54 "id":
55 {
56 "type": "string",
57 "pattern": "^[A-Za-z0-9_]+$"
58 },
59
60 "action":
61 {
62 "type": "object",
63 "properties":
64 {
65 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080066 "and": {"$ref": "#/definitions/actions" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080067 "compare_presence": {"$ref": "#/definitions/compare_presence" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080068 "compare_vpd": {"$ref": "#/definitions/compare_vpd" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080069 "i2c_compare_bit": {"$ref": "#/definitions/i2c_bit" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080070 "i2c_compare_byte": {"$ref": "#/definitions/i2c_byte" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080071 "i2c_compare_bytes": {"$ref": "#/definitions/i2c_bytes" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080072 "i2c_write_bit": {"$ref": "#/definitions/i2c_bit" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080073 "i2c_write_byte": {"$ref": "#/definitions/i2c_byte" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080074 "i2c_write_bytes": {"$ref": "#/definitions/i2c_bytes" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080075 "if": {"$ref": "#/definitions/if" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080076 "not": {"$ref": "#/definitions/action" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080077 "or": {"$ref": "#/definitions/actions" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080078 "pmbus_read_sensor": {"$ref": "#/definitions/pmbus_read_sensor" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080079 "pmbus_write_vout_command": {"$ref": "#/definitions/pmbus_write_vout_command" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080080 "run_rule": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +080081 "set_device": {"$ref": "#/definitions/id" }
82 },
83 "additionalProperties": false,
84 "oneOf": [
85 {"required": ["and"]},
86 {"required": ["compare_presence"]},
87 {"required": ["compare_vpd"]},
88 {"required": ["i2c_compare_bit"]},
89 {"required": ["i2c_compare_byte"]},
90 {"required": ["i2c_compare_bytes"]},
91 {"required": ["i2c_write_bit"]},
92 {"required": ["i2c_write_byte"]},
93 {"required": ["i2c_write_bytes"]},
94 {"required": ["if"]},
95 {"required": ["not"]},
96 {"required": ["or"]},
97 {"required": ["pmbus_write_vout_command"]},
98 {"required": ["pmbus_read_sensor"]},
99 {"required": ["run_rule"]},
100 {"required": ["set_device"]}
101 ]
102 },
103
104 "actions":
105 {
106 "type": "array",
107 "items": {"$ref": "#/definitions/action" },
108 "minItems": 1
109 },
110
111 "compare_presence":
112 {
113 "type": "object",
114 "properties":
115 {
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500116 "fru": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800117 "value": {"$ref": "#/definitions/boolean_value" }
118 },
119 "required": ["fru", "value"],
120 "additionalProperties": false
121 },
122
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500123 "inventory_path":
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800124 {
125 "type": "string",
126 "minLength": 1
127 },
128
129 "boolean_value":
130 {
131 "type": "boolean"
132 },
133
134 "compare_vpd":
135 {
136 "type": "object",
137 "properties":
138 {
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500139 "fru": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800140 "keyword": {"$ref": "#/definitions/keyword" },
Matt Spinleraacc2aa2021-05-25 09:31:35 -0600141 "value": {"$ref": "#/definitions/string_value" },
Matt Spinleraacc2aa2021-05-25 09:31:35 -0600142 "byte_values": {"$ref": "#/definitions/bytes_values" }
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800143 },
Matt Spinleraacc2aa2021-05-25 09:31:35 -0600144 "required": ["fru", "keyword"],
145 "oneOf": [
146 {"required": ["value"]},
147 {"required": ["byte_values"]}
148 ],
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800149 "additionalProperties": false
150 },
151
152 "keyword":
153 {
154 "type": "string",
Matt Spinleraacc2aa2021-05-25 09:31:35 -0600155 "enum": ["CCIN", "Manufacturer", "Model", "PartNumber", "HW"]
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800156 },
157
158 "string_value":
159 {
160 "type": "string"
161 },
162
163 "i2c_bit":
164 {
165 "type": "object",
166 "properties":
167 {
168 "register": {"$ref": "#/definitions/register" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800169 "position": {"$ref": "#/definitions/position" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800170 "value": {"$ref": "#/definitions/bit_value" }
171 },
172 "required": ["register", "position","value"],
173 "additionalProperties": false
174 },
175
176 "register":
177 {
178 "type": "string",
179 "pattern": "^0x[0-9A-Fa-f]{2}$"
180 },
181
182 "position":
183 {
184 "type": "integer",
185 "minimum": 0,
186 "maximum": 7
187 },
188
189 "bit_value":
190 {
191 "type": "integer",
192 "minimum": 0,
193 "maximum": 1
194 },
195
196 "i2c_byte":
197 {
198 "type": "object",
199 "properties":
200 {
201 "register": {"$ref": "#/definitions/register" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800202 "value": {"$ref": "#/definitions/byte_value" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800203 "mask": {"$ref": "#/definitions/byte_mask" }
204 },
205 "required": ["register", "value"],
206 "additionalProperties": false
207 },
208
209 "byte_value":
210 {
211 "type": "string",
212 "pattern": "^0x[0-9A-Fa-f]{2}$"
213 },
214
215 "byte_mask":
216 {
217 "type": "string",
218 "pattern": "^0x[0-9A-Fa-f]{2}$"
219 },
220
221 "i2c_bytes":
222 {
223 "type": "object",
224 "properties":
225 {
226 "register": {"$ref": "#/definitions/register" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800227 "values": {"$ref": "#/definitions/bytes_values" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800228 "masks": {"$ref": "#/definitions/bytes_masks" }
229 },
230 "required": ["register", "values"],
231 "additionalProperties": false
232 },
233
234 "bytes_values":
235 {
236 "type": "array",
237 "items": {"$ref": "#/definitions/byte_value" },
238 "minItems": 1
239 },
240
241 "bytes_masks":
242 {
243 "type": "array",
244 "items": {"$ref": "#/definitions/byte_mask" },
245 "minItems": 1
246 },
247
248 "if":
249 {
250 "type": "object",
251 "properties":
252 {
253 "condition": {"$ref": "#/definitions/action" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800254 "then": {"$ref": "#/definitions/actions" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800255 "else": {"$ref": "#/definitions/actions" }
256 },
257 "required": ["condition", "then"],
258 "additionalProperties": false
259 },
260
261 "pmbus_write_vout_command":
262 {
263 "type": "object",
264 "properties":
265 {
266 "volts": {"$ref": "#/definitions/volts" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800267 "format": {"$ref": "#/definitions/write_vout_format" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800268 "exponent": {"$ref": "#/definitions/exponent" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800269 "is_verified": {"$ref": "#/definitions/is_verified" }
270 },
271 "required": ["format"],
272 "additionalProperties": false
273 },
274
275 "volts":
276 {
277 "type": "number"
278 },
279
280 "write_vout_format":
281 {
282 "type": "string",
283 "enum": ["linear"]
284 },
285
286 "exponent":
287 {
288 "type": "integer"
289 },
290
291 "is_verified":
292 {
293 "type": "boolean"
294 },
295
296 "pmbus_read_sensor":
297 {
298 "type": "object",
299 "properties":
300 {
301 "type": {"$ref": "#/definitions/pmbus_read_sensor_type" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800302 "command": {"$ref": "#/definitions/pmbus_read_sensor_command" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800303 "format": {"$ref": "#/definitions/read_sensor_format" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800304 "exponent": {"$ref": "#/definitions/exponent" }
305 },
306 "required": ["type", "command", "format"],
307 "additionalProperties": false
308 },
309
310 "pmbus_read_sensor_type":
311 {
312 "type": "string",
313 "enum": ["iout", "iout_peak", "iout_valley", "pout", "temperature", "temperature_peak", "vout", "vout_peak", "vout_valley"]
314 },
315
316 "pmbus_read_sensor_command":
317 {
318 "type": "string",
319 "pattern": "^0x[0-9a-fA-F]{2}$"
320 },
321
322 "read_sensor_format":
323 {
324 "type": "string",
325 "enum": ["linear_11", "linear_16"]
326 },
327
328 "chassis":
329 {
330 "type": "array",
331 "items":
332 {
333 "type": "object",
334 "properties":
335 {
336 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800337 "number": {"$ref": "#/definitions/number" },
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500338 "inventory_path": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800339 "devices": {"$ref": "#/definitions/devices" }
340 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800341 "required": ["number"],
342 "additionalProperties": false
343 },
344 "minItems": 1
345 },
346
347 "number":
348 {
349 "type": "integer",
350 "minimum": 1
351 },
352
353 "devices":
354 {
355 "type": "array",
356 "items":
357 {
358 "type": "object",
359 "properties":
360 {
361 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800362 "id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800363 "is_regulator": {"$ref": "#/definitions/is_regulator" },
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500364 "fru": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800365 "i2c_interface": {"$ref": "#/definitions/i2c_interface" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800366 "presence_detection": {"$ref": "#/definitions/presence_detection" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800367 "configuration": {"$ref": "#/definitions/configuration" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800368 "rails": {"$ref": "#/definitions/rails" }
369 },
370 "required": ["id", "is_regulator", "fru", "i2c_interface"],
371 "if":
372 {
373 "properties": { "is_regulator": { "const": false } }
374 },
375 "then":
376 {
377 "not" : { "required" : ["rails"] }
378 },
379 "additionalProperties": false
380 },
381 "minItems": 1
382 },
383
384 "is_regulator":
385 {
386 "type": "boolean"
387 },
388
389 "i2c_interface":
390 {
391 "type": "object",
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800392 "properties":
393 {
394 "bus": {"$ref": "#/definitions/bus" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800395 "address": {"$ref": "#/definitions/address" }
396 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800397 "required": ["bus", "address"],
398 "additionalProperties": false
399 },
400
401 "bus":
402 {
403 "type": "integer",
404 "minimum": 0
405 },
406
407 "address":
408 {
409 "type": "string",
410 "pattern": "^0x[0-9A-Fa-f]{2}$"
411 },
412
413 "presence_detection":
414 {
415 "type": "object",
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800416 "properties":
417 {
418 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800419 "rule_id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800420 "actions": {"$ref": "#/definitions/actions" }
421 },
422 "additionalProperties": false,
423 "oneOf": [
424 {"required": ["rule_id"]},
425 {"required": ["actions"]}
426 ]
427 },
428
429 "configuration":
430 {
431 "type": "object",
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800432 "properties":
433 {
434 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800435 "volts": {"$ref": "#/definitions/volts" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800436 "rule_id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800437 "actions": {"$ref": "#/definitions/actions" }
438 },
439 "additionalProperties": false,
440 "oneOf": [
441 {"required": ["rule_id"]},
442 {"required": ["actions"]}
443 ]
444 },
445
446 "rail":
447 {
448 "type": "object",
449 "properties":
450 {
451 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800452 "id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800453 "configuration": {"$ref": "#/definitions/configuration" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800454 "sensor_monitoring": {"$ref": "#/definitions/sensor_monitoring" }
455 },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800456 "required": ["id"],
457 "additionalProperties": false
458 },
459
460 "rails":
461 {
462 "type": "array",
463 "items": {"$ref": "#/definitions/rail" },
464 "minItems": 1
465 },
466
467 "sensor_monitoring":
468 {
469 "type": "object",
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800470 "properties":
471 {
472 "comments": {"$ref": "#/definitions/comments" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800473 "rule_id": {"$ref": "#/definitions/id" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800474 "actions": {"$ref": "#/definitions/actions" }
475 },
476 "additionalProperties": false,
477 "oneOf": [
478 {"required": ["rule_id"]},
479 {"required": ["actions"]}
480 ]
481 }
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800482 }
483}