"Das U-Boot" Source Tree

test: dm: Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle

Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle() op.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

authored by

Christian Marangi and committed by
Tom Rini
2c19bd15 2d31a279

+54 -4
+7
arch/sandbox/dts/other.dts
··· 32 32 <&other_gpio_b 5 GPIO_ACTIVE_HIGH 3 2 1>, 33 33 <0>, <&other_gpio_a 12>; 34 34 other-phandle-value = <&other_gpio_c 10>, <0xFFFFFFFF 20>, <&other_gpio_a 30>; 35 + other-phandle-nodes = <&other_phandle_node_1>, <&other_phandle_node_2>; 35 36 }; 36 37 37 38 other_gpio_a: other-gpio-a { ··· 44 45 45 46 other_gpio_c: other-gpio-c { 46 47 #gpio-cells = <2>; 48 + }; 49 + 50 + other_phandle_node_1: other-phandle-node-1 { 51 + }; 52 + 53 + other_phandle_node_2: other-phandle-node-2 { 47 54 }; 48 55 49 56 target: target {
+7
arch/sandbox/dts/test.dts
··· 296 296 compatible = "sandbox,dsi-host"; 297 297 }; 298 298 299 + phandle_node_1: phandle-node-1 { 300 + }; 301 + 302 + phandle_node_2: phandle-node-2 { 303 + }; 304 + 299 305 a-test { 300 306 reg = <0 1>; 301 307 compatible = "denx,u-boot-fdt-test"; ··· 334 340 interrupts-extended = <&irq 3 0>; 335 341 acpi,name = "GHIJ"; 336 342 phandle-value = <&gpio_c 10>, <0xFFFFFFFF 20>, <&gpio_a 30>; 343 + phandle-nodes = <&phandle_node_1>, <&phandle_node_2>; 337 344 338 345 mux-controls = <&muxcontroller0 0>, <&muxcontroller0 1>, 339 346 <&muxcontroller0 2>, <&muxcontroller0 3>,
+40 -4
test/dm/ofnode.c
··· 280 280 } 281 281 DM_TEST(dm_test_ofnode_read_ot, UTF_SCAN_FDT | UTF_OTHER_FDT); 282 282 283 - /* test ofnode_count_/parse_phandle_with_args() */ 283 + /* test ofnode_count_/parse/_phandle_with_args() */ 284 284 static int dm_test_ofnode_phandle(struct unit_test_state *uts) 285 285 { 286 286 struct ofnode_phandle_args args; 287 - ofnode node; 287 + ofnode node, phandle, target; 288 288 int ret; 289 289 const char prop[] = "test-gpios"; 290 290 const char cell[] = "#gpio-cells"; 291 291 const char prop2[] = "phandle-value"; 292 + const char prop3[] = "phandle-nodes"; 292 293 293 294 node = ofnode_path("/a-test"); 294 295 ut_assert(ofnode_valid(node)); ··· 351 352 ut_asserteq(30, args.args[0]); 352 353 ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 3, &args); 353 354 ut_asserteq(-ENOENT, ret); 355 + 356 + /* Test ofnode_parse_phandle */ 357 + phandle = ofnode_parse_phandle(node, "missing", 0); 358 + ut_assert(ofnode_equal(ofnode_null(), phandle)); 359 + 360 + target = ofnode_path("/phandle-node-1"); 361 + ut_assert(ofnode_valid(target)); 362 + phandle = ofnode_parse_phandle(node, prop3, 0); 363 + ut_assert(ofnode_equal(target, phandle)); 364 + 365 + target = ofnode_path("/phandle-node-2"); 366 + ut_assert(ofnode_valid(target)); 367 + phandle = ofnode_parse_phandle(node, prop3, 1); 368 + ut_assert(ofnode_equal(target, phandle)); 369 + 370 + phandle = ofnode_parse_phandle(node, prop3, 3); 371 + ut_assert(ofnode_equal(ofnode_null(), phandle)); 354 372 355 373 return 0; 356 374 } 357 375 DM_TEST(dm_test_ofnode_phandle, UTF_SCAN_PDATA | UTF_SCAN_FDT); 358 376 359 - /* test oftree_count_/parse_phandle_with_args() with 'other' tree */ 377 + /* test oftree_count_/parse/_phandle_with_args() with 'other' tree */ 360 378 static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) 361 379 { 362 380 oftree otree = get_other_oftree(uts); 363 381 struct ofnode_phandle_args args; 364 - ofnode node; 382 + ofnode node, phandle, target; 365 383 int ret; 366 384 const char prop[] = "other-test-gpios"; 367 385 const char cell[] = "#gpio-cells"; 368 386 const char prop2[] = "other-phandle-value"; 387 + const char prop3[] = "other-phandle-nodes"; 369 388 370 389 node = oftree_path(otree, "/other-a-test"); 371 390 ut_assert(ofnode_valid(node)); ··· 428 447 ut_asserteq(30, args.args[0]); 429 448 ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 3, &args); 430 449 ut_asserteq(-ENOENT, ret); 450 + 451 + /* Test oftree_parse_phandle */ 452 + phandle = oftree_parse_phandle(otree, node, "missing", 0); 453 + ut_assert(ofnode_equal(ofnode_null(), phandle)); 454 + 455 + target = oftree_path(otree, "/other-phandle-node-1"); 456 + ut_assert(ofnode_valid(target)); 457 + phandle = oftree_parse_phandle(otree, node, prop3, 0); 458 + ut_assert(ofnode_equal(target, phandle)); 459 + 460 + target = oftree_path(otree, "/other-phandle-node-2"); 461 + ut_assert(ofnode_valid(target)); 462 + phandle = oftree_parse_phandle(otree, node, prop3, 1); 463 + ut_assert(ofnode_equal(target, phandle)); 464 + 465 + phandle = oftree_parse_phandle(otree, node, prop3, 3); 466 + ut_assert(ofnode_equal(ofnode_null(), phandle)); 431 467 432 468 return 0; 433 469 }