Skip to content

Commit 02ef037

Browse files
committed
lk2nd: smp: document refactored functions
Signed-off-by: Eugene Lepshy <fekz115@gmail.com>
1 parent 469cd3b commit 02ef037

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

lk2nd/smp/cpu-boot.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ static inline uint32_t read_mpidr(void)
4444
return BITS(res, 23, 0);
4545
}
4646

47+
/**
48+
* @brief This function used to read value by index of specified property
49+
*
50+
* Example of node:
51+
* @code
52+
* somenode {
53+
* someproperty = <1 2 3 4>;
54+
* };
55+
* @endcode
56+
*
57+
* So, to get second value(2) of this `someproperty` call this function
58+
* like this:
59+
*
60+
* @code
61+
* val = read_phandle_value_indexed(dtb, node, "someproperty", 1)
62+
* @endcode
63+
*
64+
* @param dtb The pointer to dtb
65+
* @param node phandle of node, where to search property
66+
* @param name property name
67+
* @param index if property value is tuple, index specifies which value
68+
* of tuple to return
69+
* @return value of specified property by index or 0 if not possible
70+
*/
4771
static uint32_t read_phandle_value_indexed(const void *dtb, int node,
4872
const char *name, int index)
4973
{
@@ -59,6 +83,44 @@ static uint32_t read_phandle_value_indexed(const void *dtb, int node,
5983
return fdt32_to_cpu(*(val + index));
6084
}
6185

86+
/**
87+
* @brief This function return reg value by index of specified node
88+
* @param dtb The pointer to dtb
89+
* @param node phandle of node, where to search target node
90+
* @param name target node name
91+
* @param index index of which reg tuple value to return
92+
*
93+
* Example of node:
94+
* @code
95+
* l2ccc_0: clock-controller@f900d000 {
96+
* compatible = "qcom,8994-l2ccc";
97+
* reg = <0xf900d000 0x1000>;
98+
* qcom,vctl-node = <&cluster0_spm>;
99+
* };
100+
*
101+
* cluster0_spm: qcom,spm@f9012000 {
102+
* compatible = "qcom,spm-v2";
103+
* #address-cells = <1>;
104+
* #size-cells = <1>;
105+
* reg = <0xf9012000 0x1000>,
106+
* <0xf900d210 0x8>;
107+
* };
108+
* @endcode
109+
*
110+
* So, to get second reg address of `cluster0_spm`(0xf900d210), call function
111+
* like this:
112+
*
113+
* @code
114+
* val = read_phandle_reg_indexed(dtb, node, "qcom,vctl-node", 1)
115+
* @endcode
116+
*
117+
* where `node` is on `l2ccc_0` now
118+
*
119+
* @note index specifies what tuple to use, not value
120+
* @note `node` must contain node with subnode called `name`
121+
*
122+
* @return value of specified node reg by index or 0 if not possible
123+
*/
62124
static uint32_t read_phandle_reg_indexed(const void *dtb, int node,
63125
const char *prop, int index)
64126
{
@@ -77,11 +139,19 @@ static uint32_t read_phandle_reg_indexed(const void *dtb, int node,
77139
return read_phandle_value_indexed(dtb, target, "reg", used_index);
78140
}
79141

142+
/**
143+
* @brief The same as `read_phandle_value_indexed` but with default index 0
144+
* @see read_phandle_value_indexed
145+
*/
80146
static uint32_t read_phandle_value(const void *dtb, int node, const char *name)
81147
{
82148
return read_phandle_value_indexed(dtb, node, name, 0);
83149
}
84150

151+
/**
152+
* @brief The same as `read_phandle_reg_indexed` but with default index 0
153+
* @see read_phandle_reg_indexed
154+
*/
85155
static uint32_t read_phandle_reg(const void *dtb, int node, const char *prop)
86156
{
87157
return read_phandle_reg_indexed(dtb, node, prop, 0);

0 commit comments

Comments
 (0)