blob: c6ef268f8abdf6e7f093228e07919bf0e5a80d6f [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",
7
8 "properties":
9 {
10 "comments":
11 {
12 "$ref": "#/definitions/comments"
13 },
14 "rules":
15 {
16 "$ref": "#/definitions/rules"
17 },
18 "chassis":
19 {
20 "$ref": "#/definitions/chassis"
21 }
22 },
23
24 "required": ["chassis"],
25 "additionalProperties": false,
26
27 "definitions":
28 {
29 "rules":
30 {
31 "type": "array",
32 "items":
33 {
34 "type": "object",
35 "properties":
36 {
37 "comments": {"$ref": "#/definitions/comments" },
38
39 "id": {"$ref": "#/definitions/id" },
40
41 "actions": {"$ref": "#/definitions/actions" }
42 },
43
44 "required": ["id", "actions"],
45 "additionalProperties": false
46 },
47 "minItems": 1
48 },
49
50 "comments":
51 {
52 "type": "array",
53 "items":
54 {
55 "type": "string"
56 },
57
58 "minItems": 1
59 },
60
61 "id":
62 {
63 "type": "string",
64 "pattern": "^[A-Za-z0-9_]+$"
65 },
66
67 "action":
68 {
69 "type": "object",
70 "properties":
71 {
72 "comments": {"$ref": "#/definitions/comments" },
73
74 "and": {"$ref": "#/definitions/actions" },
75
76 "compare_presence": {"$ref": "#/definitions/compare_presence" },
77
78 "compare_vpd": {"$ref": "#/definitions/compare_vpd" },
79
80 "i2c_compare_bit": {"$ref": "#/definitions/i2c_bit" },
81
82 "i2c_compare_byte": {"$ref": "#/definitions/i2c_byte" },
83
84 "i2c_compare_bytes": {"$ref": "#/definitions/i2c_bytes" },
85
86 "i2c_write_bit": {"$ref": "#/definitions/i2c_bit" },
87
88 "i2c_write_byte": {"$ref": "#/definitions/i2c_byte" },
89
90 "i2c_write_bytes": {"$ref": "#/definitions/i2c_bytes" },
91
92 "if": {"$ref": "#/definitions/if" },
93
94 "not": {"$ref": "#/definitions/action" },
95
96 "or": {"$ref": "#/definitions/actions" },
97
98 "pmbus_read_sensor": {"$ref": "#/definitions/pmbus_read_sensor" },
99
100 "pmbus_write_vout_command": {"$ref": "#/definitions/pmbus_write_vout_command" },
101
102 "run_rule": {"$ref": "#/definitions/id" },
103
104 "set_device": {"$ref": "#/definitions/id" }
105 },
106 "additionalProperties": false,
107 "oneOf": [
108 {"required": ["and"]},
109 {"required": ["compare_presence"]},
110 {"required": ["compare_vpd"]},
111 {"required": ["i2c_compare_bit"]},
112 {"required": ["i2c_compare_byte"]},
113 {"required": ["i2c_compare_bytes"]},
114 {"required": ["i2c_write_bit"]},
115 {"required": ["i2c_write_byte"]},
116 {"required": ["i2c_write_bytes"]},
117 {"required": ["if"]},
118 {"required": ["not"]},
119 {"required": ["or"]},
120 {"required": ["pmbus_write_vout_command"]},
121 {"required": ["pmbus_read_sensor"]},
122 {"required": ["run_rule"]},
123 {"required": ["set_device"]}
124 ]
125 },
126
127 "actions":
128 {
129 "type": "array",
130 "items": {"$ref": "#/definitions/action" },
131 "minItems": 1
132 },
133
134 "compare_presence":
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
141 "value": {"$ref": "#/definitions/boolean_value" }
142 },
143 "required": ["fru", "value"],
144 "additionalProperties": false
145 },
146
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500147 "inventory_path":
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800148 {
149 "type": "string",
150 "minLength": 1
151 },
152
153 "boolean_value":
154 {
155 "type": "boolean"
156 },
157
158 "compare_vpd":
159 {
160 "type": "object",
161 "properties":
162 {
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500163 "fru": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800164
165 "keyword": {"$ref": "#/definitions/keyword" },
166
167 "value": {"$ref": "#/definitions/string_value" }
168 },
169 "required": ["fru", "keyword", "value"],
170 "additionalProperties": false
171 },
172
173 "keyword":
174 {
175 "type": "string",
176 "enum": ["CCIN", "Manufacturer", "Model", "PartNumber"]
177 },
178
179 "string_value":
180 {
181 "type": "string"
182 },
183
184 "i2c_bit":
185 {
186 "type": "object",
187 "properties":
188 {
189 "register": {"$ref": "#/definitions/register" },
190
191 "position": {"$ref": "#/definitions/position" },
192
193 "value": {"$ref": "#/definitions/bit_value" }
194 },
195 "required": ["register", "position","value"],
196 "additionalProperties": false
197 },
198
199 "register":
200 {
201 "type": "string",
202 "pattern": "^0x[0-9A-Fa-f]{2}$"
203 },
204
205 "position":
206 {
207 "type": "integer",
208 "minimum": 0,
209 "maximum": 7
210 },
211
212 "bit_value":
213 {
214 "type": "integer",
215 "minimum": 0,
216 "maximum": 1
217 },
218
219 "i2c_byte":
220 {
221 "type": "object",
222 "properties":
223 {
224 "register": {"$ref": "#/definitions/register" },
225
226 "value": {"$ref": "#/definitions/byte_value" },
227
228 "mask": {"$ref": "#/definitions/byte_mask" }
229 },
230 "required": ["register", "value"],
231 "additionalProperties": false
232 },
233
234 "byte_value":
235 {
236 "type": "string",
237 "pattern": "^0x[0-9A-Fa-f]{2}$"
238 },
239
240 "byte_mask":
241 {
242 "type": "string",
243 "pattern": "^0x[0-9A-Fa-f]{2}$"
244 },
245
246 "i2c_bytes":
247 {
248 "type": "object",
249 "properties":
250 {
251 "register": {"$ref": "#/definitions/register" },
252
253 "values": {"$ref": "#/definitions/bytes_values" },
254
255 "masks": {"$ref": "#/definitions/bytes_masks" }
256 },
257 "required": ["register", "values"],
258 "additionalProperties": false
259 },
260
261 "bytes_values":
262 {
263 "type": "array",
264 "items": {"$ref": "#/definitions/byte_value" },
265 "minItems": 1
266 },
267
268 "bytes_masks":
269 {
270 "type": "array",
271 "items": {"$ref": "#/definitions/byte_mask" },
272 "minItems": 1
273 },
274
275 "if":
276 {
277 "type": "object",
278 "properties":
279 {
280 "condition": {"$ref": "#/definitions/action" },
281
282 "then": {"$ref": "#/definitions/actions" },
283
284 "else": {"$ref": "#/definitions/actions" }
285 },
286 "required": ["condition", "then"],
287 "additionalProperties": false
288 },
289
290 "pmbus_write_vout_command":
291 {
292 "type": "object",
293 "properties":
294 {
295 "volts": {"$ref": "#/definitions/volts" },
296
297 "format": {"$ref": "#/definitions/write_vout_format" },
298
299 "exponent": {"$ref": "#/definitions/exponent" },
300
301 "is_verified": {"$ref": "#/definitions/is_verified" }
302 },
303 "required": ["format"],
304 "additionalProperties": false
305 },
306
307 "volts":
308 {
309 "type": "number"
310 },
311
312 "write_vout_format":
313 {
314 "type": "string",
315 "enum": ["linear"]
316 },
317
318 "exponent":
319 {
320 "type": "integer"
321 },
322
323 "is_verified":
324 {
325 "type": "boolean"
326 },
327
328 "pmbus_read_sensor":
329 {
330 "type": "object",
331 "properties":
332 {
333 "type": {"$ref": "#/definitions/pmbus_read_sensor_type" },
334
335 "command": {"$ref": "#/definitions/pmbus_read_sensor_command" },
336
337 "format": {"$ref": "#/definitions/read_sensor_format" },
338
339 "exponent": {"$ref": "#/definitions/exponent" }
340 },
341 "required": ["type", "command", "format"],
342 "additionalProperties": false
343 },
344
345 "pmbus_read_sensor_type":
346 {
347 "type": "string",
348 "enum": ["iout", "iout_peak", "iout_valley", "pout", "temperature", "temperature_peak", "vout", "vout_peak", "vout_valley"]
349 },
350
351 "pmbus_read_sensor_command":
352 {
353 "type": "string",
354 "pattern": "^0x[0-9a-fA-F]{2}$"
355 },
356
357 "read_sensor_format":
358 {
359 "type": "string",
360 "enum": ["linear_11", "linear_16"]
361 },
362
363 "chassis":
364 {
365 "type": "array",
366 "items":
367 {
368 "type": "object",
369 "properties":
370 {
371 "comments": {"$ref": "#/definitions/comments" },
372
373 "number": {"$ref": "#/definitions/number" },
374
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500375 "inventory_path": {"$ref": "#/definitions/inventory_path" },
376
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800377 "devices": {"$ref": "#/definitions/devices" }
378 },
379
380 "required": ["number"],
381 "additionalProperties": false
382 },
383 "minItems": 1
384 },
385
386 "number":
387 {
388 "type": "integer",
389 "minimum": 1
390 },
391
392 "devices":
393 {
394 "type": "array",
395 "items":
396 {
397 "type": "object",
398 "properties":
399 {
400 "comments": {"$ref": "#/definitions/comments" },
401
402 "id": {"$ref": "#/definitions/id" },
403
404 "is_regulator": {"$ref": "#/definitions/is_regulator" },
405
Shawn McCarneyecbeeea2021-04-29 21:08:18 -0500406 "fru": {"$ref": "#/definitions/inventory_path" },
Bob Kingdcb4b3b2019-12-17 18:07:06 +0800407
408 "i2c_interface": {"$ref": "#/definitions/i2c_interface" },
409
410 "presence_detection": {"$ref": "#/definitions/presence_detection" },
411
412 "configuration": {"$ref": "#/definitions/configuration" },
413
414 "rails": {"$ref": "#/definitions/rails" }
415 },
416 "required": ["id", "is_regulator", "fru", "i2c_interface"],
417 "if":
418 {
419 "properties": { "is_regulator": { "const": false } }
420 },
421 "then":
422 {
423 "not" : { "required" : ["rails"] }
424 },
425 "additionalProperties": false
426 },
427 "minItems": 1
428 },
429
430 "is_regulator":
431 {
432 "type": "boolean"
433 },
434
435 "i2c_interface":
436 {
437 "type": "object",
438
439 "properties":
440 {
441 "bus": {"$ref": "#/definitions/bus" },
442
443 "address": {"$ref": "#/definitions/address" }
444 },
445
446 "required": ["bus", "address"],
447 "additionalProperties": false
448 },
449
450 "bus":
451 {
452 "type": "integer",
453 "minimum": 0
454 },
455
456 "address":
457 {
458 "type": "string",
459 "pattern": "^0x[0-9A-Fa-f]{2}$"
460 },
461
462 "presence_detection":
463 {
464 "type": "object",
465
466 "properties":
467 {
468 "comments": {"$ref": "#/definitions/comments" },
469
470 "rule_id": {"$ref": "#/definitions/id" },
471
472 "actions": {"$ref": "#/definitions/actions" }
473 },
474 "additionalProperties": false,
475 "oneOf": [
476 {"required": ["rule_id"]},
477 {"required": ["actions"]}
478 ]
479 },
480
481 "configuration":
482 {
483 "type": "object",
484
485 "properties":
486 {
487 "comments": {"$ref": "#/definitions/comments" },
488
489 "volts": {"$ref": "#/definitions/volts" },
490
491 "rule_id": {"$ref": "#/definitions/id" },
492
493 "actions": {"$ref": "#/definitions/actions" }
494 },
495 "additionalProperties": false,
496 "oneOf": [
497 {"required": ["rule_id"]},
498 {"required": ["actions"]}
499 ]
500 },
501
502 "rail":
503 {
504 "type": "object",
505 "properties":
506 {
507 "comments": {"$ref": "#/definitions/comments" },
508
509 "id": {"$ref": "#/definitions/id" },
510
511 "configuration": {"$ref": "#/definitions/configuration" },
512
513 "sensor_monitoring": {"$ref": "#/definitions/sensor_monitoring" }
514 },
515
516 "required": ["id"],
517 "additionalProperties": false
518 },
519
520 "rails":
521 {
522 "type": "array",
523 "items": {"$ref": "#/definitions/rail" },
524 "minItems": 1
525 },
526
527 "sensor_monitoring":
528 {
529 "type": "object",
530
531 "properties":
532 {
533 "comments": {"$ref": "#/definitions/comments" },
534
535 "rule_id": {"$ref": "#/definitions/id" },
536
537 "actions": {"$ref": "#/definitions/actions" }
538 },
539 "additionalProperties": false,
540 "oneOf": [
541 {"required": ["rule_id"]},
542 {"required": ["actions"]}
543 ]
544 }
545
546 }
547}