]> Git Repo - u-boot.git/blob - test/dm/of_extra.c
Merge patch series "*** Commonize board code for K3 based SoMs ***"
[u-boot.git] / test / dm / of_extra.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2021 Google LLC
4  * Written by Simon Glass <[email protected]>
5  */
6
7 #include <dm.h>
8 #include <dm/of_extra.h>
9 #include <dm/test.h>
10 #include <test/ut.h>
11 #include <u-boot/sha256.h>
12
13 static int dm_test_ofnode_read_fmap_entry(struct unit_test_state *uts)
14 {
15         const char hash_expect[] = {
16                 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
17                 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
18                 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
19                 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
20         };
21         struct fmap_entry entry;
22         ofnode node;
23
24         node = ofnode_path("/cros-ec/flash/wp-ro");
25         ut_assertok(ofnode_read_fmap_entry(node, &entry));
26         ut_asserteq(0xf000, entry.offset);
27         ut_asserteq(0x1000, entry.length);
28         ut_asserteq(0x884, entry.used);
29         ut_asserteq(FMAP_COMPRESS_LZ4, entry.compress_algo);
30         ut_asserteq(0xcf8, entry.unc_length);
31         ut_asserteq(FMAP_HASH_SHA256, entry.hash_algo);
32         ut_asserteq(SHA256_SUM_LEN, entry.hash_size);
33         ut_asserteq_mem(hash_expect, entry.hash, SHA256_SUM_LEN);
34
35         return 0;
36 }
37 DM_TEST(dm_test_ofnode_read_fmap_entry, 0);
38
39 static int dm_test_ofnode_phy_is_fixed_link(struct unit_test_state *uts)
40 {
41         ofnode eth_node, phy_node, node;
42
43         eth_node = ofnode_path("/dsa-test/ports/port@0");
44         ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
45         node = ofnode_path("/dsa-test/ports/port@0/fixed-link");
46         ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
47
48         eth_node = ofnode_path("/dsa-test/ports/port@1");
49         ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
50         node = eth_node;
51         ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
52
53         return 0;
54 }
55 DM_TEST(dm_test_ofnode_phy_is_fixed_link, 0);
This page took 0.034818 seconds and 4 git commands to generate.