@@ -44,6 +44,30 @@ static inline uint32_t read_mpidr(void)
44
44
return BITS (res , 23 , 0 );
45
45
}
46
46
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
+ */
47
71
static uint32_t read_phandle_value_indexed (const void * dtb , int node ,
48
72
const char * name , int index )
49
73
{
@@ -59,6 +83,44 @@ static uint32_t read_phandle_value_indexed(const void *dtb, int node,
59
83
return fdt32_to_cpu (* (val + index ));
60
84
}
61
85
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
+ */
62
124
static uint32_t read_phandle_reg_indexed (const void * dtb , int node ,
63
125
const char * prop , int index )
64
126
{
@@ -77,11 +139,19 @@ static uint32_t read_phandle_reg_indexed(const void *dtb, int node,
77
139
return read_phandle_value_indexed (dtb , target , "reg" , used_index );
78
140
}
79
141
142
+ /**
143
+ * @brief The same as `read_phandle_value_indexed` but with default index 0
144
+ * @see read_phandle_value_indexed
145
+ */
80
146
static uint32_t read_phandle_value (const void * dtb , int node , const char * name )
81
147
{
82
148
return read_phandle_value_indexed (dtb , node , name , 0 );
83
149
}
84
150
151
+ /**
152
+ * @brief The same as `read_phandle_reg_indexed` but with default index 0
153
+ * @see read_phandle_reg_indexed
154
+ */
85
155
static uint32_t read_phandle_reg (const void * dtb , int node , const char * prop )
86
156
{
87
157
return read_phandle_reg_indexed (dtb , node , prop , 0 );
0 commit comments