@@ -44,25 +44,48 @@ static inline uint32_t read_mpidr(void)
44
44
return BITS (res , 23 , 0 );
45
45
}
46
46
47
- static uint32_t read_phandle_reg (const void * dtb , int node , const char * prop )
47
+ static uint32_t read_phandle_value_indexed (const void * dtb , int node ,
48
+ const char * name , int index )
49
+ {
50
+ const fdt32_t * val ;
51
+ int len ;
52
+
53
+ val = fdt_getprop (dtb , node , name , & len );
54
+ if (len < (int )sizeof (* val )) {
55
+ dprintf (CRITICAL , "Cannot read %s property of node: %d\n" ,
56
+ name , len );
57
+ return 0 ;
58
+ }
59
+ return fdt32_to_cpu (* (val + index ));
60
+ }
61
+
62
+ static uint32_t read_phandle_reg_indexed (const void * dtb , int node ,
63
+ const char * prop , int index )
48
64
{
49
65
const fdt32_t * val ;
50
- int target , len ;
66
+ /*
67
+ * used_index is index multiplied by 2 because we want to use the first
68
+ * value from the second tuple, not the second value from the first tuple
69
+ */
70
+ int target , len , used_index = index * 2 ;
51
71
52
72
target = lkfdt_lookup_phandle (dtb , node , prop );
53
73
if (target < 0 ) {
54
74
dprintf (CRITICAL , "Cannot find %s node in %s: %d\n" ,
55
75
prop , fdt_get_name (dtb , node , NULL ), target );
56
76
return 0 ;
57
77
}
78
+ return read_phandle_value_indexed (dtb , target , "reg" , used_index );
79
+ }
58
80
59
- val = fdt_getprop (dtb , target , "reg" , & len );
60
- if (len < (int )sizeof (* val )) {
61
- dprintf (CRITICAL , "Cannot read reg property of %s node: %d\n" ,
62
- prop , len );
63
- return 0 ;
64
- }
65
- return fdt32_to_cpu (* val );
81
+ static uint32_t read_phandle_value (const void * dtb , int node , const char * name )
82
+ {
83
+ return read_phandle_value_indexed (dtb , node , name , 0 );
84
+ }
85
+
86
+ static uint32_t read_phandle_reg (const void * dtb , int node , const char * prop )
87
+ {
88
+ return read_phandle_reg_indexed (dtb , node , prop , 0 );
66
89
}
67
90
68
91
bool cpu_boot (const void * dtb , int node , uint32_t mpidr )
0 commit comments