Bob King | dcb4b3b | 2019-12-17 18:07:06 +0800 | [diff] [blame] | 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/fru" }, |
| 140 | |
| 141 | "value": {"$ref": "#/definitions/boolean_value" } |
| 142 | }, |
| 143 | "required": ["fru", "value"], |
| 144 | "additionalProperties": false |
| 145 | }, |
| 146 | |
| 147 | "fru": |
| 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/fru" }, |
| 164 | |
| 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 | |
| 375 | "devices": {"$ref": "#/definitions/devices" } |
| 376 | }, |
| 377 | |
| 378 | "required": ["number"], |
| 379 | "additionalProperties": false |
| 380 | }, |
| 381 | "minItems": 1 |
| 382 | }, |
| 383 | |
| 384 | "number": |
| 385 | { |
| 386 | "type": "integer", |
| 387 | "minimum": 1 |
| 388 | }, |
| 389 | |
| 390 | "devices": |
| 391 | { |
| 392 | "type": "array", |
| 393 | "items": |
| 394 | { |
| 395 | "type": "object", |
| 396 | "properties": |
| 397 | { |
| 398 | "comments": {"$ref": "#/definitions/comments" }, |
| 399 | |
| 400 | "id": {"$ref": "#/definitions/id" }, |
| 401 | |
| 402 | "is_regulator": {"$ref": "#/definitions/is_regulator" }, |
| 403 | |
| 404 | "fru": {"$ref": "#/definitions/fru" }, |
| 405 | |
| 406 | "i2c_interface": {"$ref": "#/definitions/i2c_interface" }, |
| 407 | |
| 408 | "presence_detection": {"$ref": "#/definitions/presence_detection" }, |
| 409 | |
| 410 | "configuration": {"$ref": "#/definitions/configuration" }, |
| 411 | |
| 412 | "rails": {"$ref": "#/definitions/rails" } |
| 413 | }, |
| 414 | "required": ["id", "is_regulator", "fru", "i2c_interface"], |
| 415 | "if": |
| 416 | { |
| 417 | "properties": { "is_regulator": { "const": false } } |
| 418 | }, |
| 419 | "then": |
| 420 | { |
| 421 | "not" : { "required" : ["rails"] } |
| 422 | }, |
| 423 | "additionalProperties": false |
| 424 | }, |
| 425 | "minItems": 1 |
| 426 | }, |
| 427 | |
| 428 | "is_regulator": |
| 429 | { |
| 430 | "type": "boolean" |
| 431 | }, |
| 432 | |
| 433 | "i2c_interface": |
| 434 | { |
| 435 | "type": "object", |
| 436 | |
| 437 | "properties": |
| 438 | { |
| 439 | "bus": {"$ref": "#/definitions/bus" }, |
| 440 | |
| 441 | "address": {"$ref": "#/definitions/address" } |
| 442 | }, |
| 443 | |
| 444 | "required": ["bus", "address"], |
| 445 | "additionalProperties": false |
| 446 | }, |
| 447 | |
| 448 | "bus": |
| 449 | { |
| 450 | "type": "integer", |
| 451 | "minimum": 0 |
| 452 | }, |
| 453 | |
| 454 | "address": |
| 455 | { |
| 456 | "type": "string", |
| 457 | "pattern": "^0x[0-9A-Fa-f]{2}$" |
| 458 | }, |
| 459 | |
| 460 | "presence_detection": |
| 461 | { |
| 462 | "type": "object", |
| 463 | |
| 464 | "properties": |
| 465 | { |
| 466 | "comments": {"$ref": "#/definitions/comments" }, |
| 467 | |
| 468 | "rule_id": {"$ref": "#/definitions/id" }, |
| 469 | |
| 470 | "actions": {"$ref": "#/definitions/actions" } |
| 471 | }, |
| 472 | "additionalProperties": false, |
| 473 | "oneOf": [ |
| 474 | {"required": ["rule_id"]}, |
| 475 | {"required": ["actions"]} |
| 476 | ] |
| 477 | }, |
| 478 | |
| 479 | "configuration": |
| 480 | { |
| 481 | "type": "object", |
| 482 | |
| 483 | "properties": |
| 484 | { |
| 485 | "comments": {"$ref": "#/definitions/comments" }, |
| 486 | |
| 487 | "volts": {"$ref": "#/definitions/volts" }, |
| 488 | |
| 489 | "rule_id": {"$ref": "#/definitions/id" }, |
| 490 | |
| 491 | "actions": {"$ref": "#/definitions/actions" } |
| 492 | }, |
| 493 | "additionalProperties": false, |
| 494 | "oneOf": [ |
| 495 | {"required": ["rule_id"]}, |
| 496 | {"required": ["actions"]} |
| 497 | ] |
| 498 | }, |
| 499 | |
| 500 | "rail": |
| 501 | { |
| 502 | "type": "object", |
| 503 | "properties": |
| 504 | { |
| 505 | "comments": {"$ref": "#/definitions/comments" }, |
| 506 | |
| 507 | "id": {"$ref": "#/definitions/id" }, |
| 508 | |
| 509 | "configuration": {"$ref": "#/definitions/configuration" }, |
| 510 | |
| 511 | "sensor_monitoring": {"$ref": "#/definitions/sensor_monitoring" } |
| 512 | }, |
| 513 | |
| 514 | "required": ["id"], |
| 515 | "additionalProperties": false |
| 516 | }, |
| 517 | |
| 518 | "rails": |
| 519 | { |
| 520 | "type": "array", |
| 521 | "items": {"$ref": "#/definitions/rail" }, |
| 522 | "minItems": 1 |
| 523 | }, |
| 524 | |
| 525 | "sensor_monitoring": |
| 526 | { |
| 527 | "type": "object", |
| 528 | |
| 529 | "properties": |
| 530 | { |
| 531 | "comments": {"$ref": "#/definitions/comments" }, |
| 532 | |
| 533 | "rule_id": {"$ref": "#/definitions/id" }, |
| 534 | |
| 535 | "actions": {"$ref": "#/definitions/actions" } |
| 536 | }, |
| 537 | "additionalProperties": false, |
| 538 | "oneOf": [ |
| 539 | {"required": ["rule_id"]}, |
| 540 | {"required": ["actions"]} |
| 541 | ] |
| 542 | } |
| 543 | |
| 544 | } |
| 545 | } |