1{ 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 { 139 "fru": {"$ref": "#/definitions/inventory_path" }, 140 141 "value": {"$ref": "#/definitions/boolean_value" } 142 }, 143 "required": ["fru", "value"], 144 "additionalProperties": false 145 }, 146 147 "inventory_path": 148 { 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 { 163 "fru": {"$ref": "#/definitions/inventory_path" }, 164 165 "keyword": {"$ref": "#/definitions/keyword" }, 166 167 "value": {"$ref": "#/definitions/string_value" }, 168 169 "byte_values": {"$ref": "#/definitions/bytes_values" } 170 }, 171 "required": ["fru", "keyword"], 172 "oneOf": [ 173 {"required": ["value"]}, 174 {"required": ["byte_values"]} 175 ], 176 "additionalProperties": false 177 }, 178 179 "keyword": 180 { 181 "type": "string", 182 "enum": ["CCIN", "Manufacturer", "Model", "PartNumber", "HW"] 183 }, 184 185 "string_value": 186 { 187 "type": "string" 188 }, 189 190 "i2c_bit": 191 { 192 "type": "object", 193 "properties": 194 { 195 "register": {"$ref": "#/definitions/register" }, 196 197 "position": {"$ref": "#/definitions/position" }, 198 199 "value": {"$ref": "#/definitions/bit_value" } 200 }, 201 "required": ["register", "position","value"], 202 "additionalProperties": false 203 }, 204 205 "register": 206 { 207 "type": "string", 208 "pattern": "^0x[0-9A-Fa-f]{2}$" 209 }, 210 211 "position": 212 { 213 "type": "integer", 214 "minimum": 0, 215 "maximum": 7 216 }, 217 218 "bit_value": 219 { 220 "type": "integer", 221 "minimum": 0, 222 "maximum": 1 223 }, 224 225 "i2c_byte": 226 { 227 "type": "object", 228 "properties": 229 { 230 "register": {"$ref": "#/definitions/register" }, 231 232 "value": {"$ref": "#/definitions/byte_value" }, 233 234 "mask": {"$ref": "#/definitions/byte_mask" } 235 }, 236 "required": ["register", "value"], 237 "additionalProperties": false 238 }, 239 240 "byte_value": 241 { 242 "type": "string", 243 "pattern": "^0x[0-9A-Fa-f]{2}$" 244 }, 245 246 "byte_mask": 247 { 248 "type": "string", 249 "pattern": "^0x[0-9A-Fa-f]{2}$" 250 }, 251 252 "i2c_bytes": 253 { 254 "type": "object", 255 "properties": 256 { 257 "register": {"$ref": "#/definitions/register" }, 258 259 "values": {"$ref": "#/definitions/bytes_values" }, 260 261 "masks": {"$ref": "#/definitions/bytes_masks" } 262 }, 263 "required": ["register", "values"], 264 "additionalProperties": false 265 }, 266 267 "bytes_values": 268 { 269 "type": "array", 270 "items": {"$ref": "#/definitions/byte_value" }, 271 "minItems": 1 272 }, 273 274 "bytes_masks": 275 { 276 "type": "array", 277 "items": {"$ref": "#/definitions/byte_mask" }, 278 "minItems": 1 279 }, 280 281 "if": 282 { 283 "type": "object", 284 "properties": 285 { 286 "condition": {"$ref": "#/definitions/action" }, 287 288 "then": {"$ref": "#/definitions/actions" }, 289 290 "else": {"$ref": "#/definitions/actions" } 291 }, 292 "required": ["condition", "then"], 293 "additionalProperties": false 294 }, 295 296 "pmbus_write_vout_command": 297 { 298 "type": "object", 299 "properties": 300 { 301 "volts": {"$ref": "#/definitions/volts" }, 302 303 "format": {"$ref": "#/definitions/write_vout_format" }, 304 305 "exponent": {"$ref": "#/definitions/exponent" }, 306 307 "is_verified": {"$ref": "#/definitions/is_verified" } 308 }, 309 "required": ["format"], 310 "additionalProperties": false 311 }, 312 313 "volts": 314 { 315 "type": "number" 316 }, 317 318 "write_vout_format": 319 { 320 "type": "string", 321 "enum": ["linear"] 322 }, 323 324 "exponent": 325 { 326 "type": "integer" 327 }, 328 329 "is_verified": 330 { 331 "type": "boolean" 332 }, 333 334 "pmbus_read_sensor": 335 { 336 "type": "object", 337 "properties": 338 { 339 "type": {"$ref": "#/definitions/pmbus_read_sensor_type" }, 340 341 "command": {"$ref": "#/definitions/pmbus_read_sensor_command" }, 342 343 "format": {"$ref": "#/definitions/read_sensor_format" }, 344 345 "exponent": {"$ref": "#/definitions/exponent" } 346 }, 347 "required": ["type", "command", "format"], 348 "additionalProperties": false 349 }, 350 351 "pmbus_read_sensor_type": 352 { 353 "type": "string", 354 "enum": ["iout", "iout_peak", "iout_valley", "pout", "temperature", "temperature_peak", "vout", "vout_peak", "vout_valley"] 355 }, 356 357 "pmbus_read_sensor_command": 358 { 359 "type": "string", 360 "pattern": "^0x[0-9a-fA-F]{2}$" 361 }, 362 363 "read_sensor_format": 364 { 365 "type": "string", 366 "enum": ["linear_11", "linear_16"] 367 }, 368 369 "chassis": 370 { 371 "type": "array", 372 "items": 373 { 374 "type": "object", 375 "properties": 376 { 377 "comments": {"$ref": "#/definitions/comments" }, 378 379 "number": {"$ref": "#/definitions/number" }, 380 381 "inventory_path": {"$ref": "#/definitions/inventory_path" }, 382 383 "devices": {"$ref": "#/definitions/devices" } 384 }, 385 386 "required": ["number"], 387 "additionalProperties": false 388 }, 389 "minItems": 1 390 }, 391 392 "number": 393 { 394 "type": "integer", 395 "minimum": 1 396 }, 397 398 "devices": 399 { 400 "type": "array", 401 "items": 402 { 403 "type": "object", 404 "properties": 405 { 406 "comments": {"$ref": "#/definitions/comments" }, 407 408 "id": {"$ref": "#/definitions/id" }, 409 410 "is_regulator": {"$ref": "#/definitions/is_regulator" }, 411 412 "fru": {"$ref": "#/definitions/inventory_path" }, 413 414 "i2c_interface": {"$ref": "#/definitions/i2c_interface" }, 415 416 "presence_detection": {"$ref": "#/definitions/presence_detection" }, 417 418 "configuration": {"$ref": "#/definitions/configuration" }, 419 420 "rails": {"$ref": "#/definitions/rails" } 421 }, 422 "required": ["id", "is_regulator", "fru", "i2c_interface"], 423 "if": 424 { 425 "properties": { "is_regulator": { "const": false } } 426 }, 427 "then": 428 { 429 "not" : { "required" : ["rails"] } 430 }, 431 "additionalProperties": false 432 }, 433 "minItems": 1 434 }, 435 436 "is_regulator": 437 { 438 "type": "boolean" 439 }, 440 441 "i2c_interface": 442 { 443 "type": "object", 444 445 "properties": 446 { 447 "bus": {"$ref": "#/definitions/bus" }, 448 449 "address": {"$ref": "#/definitions/address" } 450 }, 451 452 "required": ["bus", "address"], 453 "additionalProperties": false 454 }, 455 456 "bus": 457 { 458 "type": "integer", 459 "minimum": 0 460 }, 461 462 "address": 463 { 464 "type": "string", 465 "pattern": "^0x[0-9A-Fa-f]{2}$" 466 }, 467 468 "presence_detection": 469 { 470 "type": "object", 471 472 "properties": 473 { 474 "comments": {"$ref": "#/definitions/comments" }, 475 476 "rule_id": {"$ref": "#/definitions/id" }, 477 478 "actions": {"$ref": "#/definitions/actions" } 479 }, 480 "additionalProperties": false, 481 "oneOf": [ 482 {"required": ["rule_id"]}, 483 {"required": ["actions"]} 484 ] 485 }, 486 487 "configuration": 488 { 489 "type": "object", 490 491 "properties": 492 { 493 "comments": {"$ref": "#/definitions/comments" }, 494 495 "volts": {"$ref": "#/definitions/volts" }, 496 497 "rule_id": {"$ref": "#/definitions/id" }, 498 499 "actions": {"$ref": "#/definitions/actions" } 500 }, 501 "additionalProperties": false, 502 "oneOf": [ 503 {"required": ["rule_id"]}, 504 {"required": ["actions"]} 505 ] 506 }, 507 508 "rail": 509 { 510 "type": "object", 511 "properties": 512 { 513 "comments": {"$ref": "#/definitions/comments" }, 514 515 "id": {"$ref": "#/definitions/id" }, 516 517 "configuration": {"$ref": "#/definitions/configuration" }, 518 519 "sensor_monitoring": {"$ref": "#/definitions/sensor_monitoring" } 520 }, 521 522 "required": ["id"], 523 "additionalProperties": false 524 }, 525 526 "rails": 527 { 528 "type": "array", 529 "items": {"$ref": "#/definitions/rail" }, 530 "minItems": 1 531 }, 532 533 "sensor_monitoring": 534 { 535 "type": "object", 536 537 "properties": 538 { 539 "comments": {"$ref": "#/definitions/comments" }, 540 541 "rule_id": {"$ref": "#/definitions/id" }, 542 543 "actions": {"$ref": "#/definitions/actions" } 544 }, 545 "additionalProperties": false, 546 "oneOf": [ 547 {"required": ["rule_id"]}, 548 {"required": ["actions"]} 549 ] 550 } 551 552 } 553} 554