10
10
#if defined(CONFIG_OF_LIBFDT ) && defined(CONFIG_OF_BOARD_SETUP )
11
11
12
12
#include <winbond-otp.h>
13
-
14
- #define WIFI_STA_MAC_ADDRESS_OFFSET 0x1003
15
- #define WIFI_AP_MAC_ADDRESS_OFFSET 0x1009
16
- #define DCXO_OFFSET 0x2003
13
+ #include "otp.h"
17
14
18
15
DECLARE_GLOBAL_DATA_PTR ;
19
16
@@ -24,13 +21,15 @@ static void fixup_wifi_mac(void *blob, int node)
24
21
memset (wifi_sta_mac_addr , 0 , sizeof (wifi_sta_mac_addr ));
25
22
memset (wifi_ap_mac_addr , 0 , sizeof (wifi_ap_mac_addr ));
26
23
27
- /* Read MAC addresses from OTP */
28
- if (read_otp_data (WIFI_STA_MAC_ADDRESS_OFFSET , MAC_ADDR_LEN ,
29
- (char * )wifi_sta_mac_addr )
30
- || read_otp_data (WIFI_AP_MAC_ADDRESS_OFFSET , MAC_ADDR_LEN ,
31
- (char * )wifi_ap_mac_addr )) {
32
- printf ("WARNING: Could not read Wifi MAC addresses from OTP\n" );
33
- return ;
24
+ if (read_otp_version (VERSION_REG0_OFFSET ) >= 1 ) {
25
+ /* Read MAC addresses from OTP */
26
+ if (read_otp_data (WIFI_STA_MAC_ADDRESS_OFFSET , MAC_ADDR_LEN ,
27
+ (char * )wifi_sta_mac_addr )
28
+ || read_otp_data (WIFI_AP_MAC_ADDRESS_OFFSET , MAC_ADDR_LEN ,
29
+ (char * )wifi_ap_mac_addr )) {
30
+ printf ("WARNING: Could not read Wifi MAC addresses from OTP\n" );
31
+ return ;
32
+ }
34
33
}
35
34
36
35
/* Set Wifi STA and AP MAC address in device tree */
@@ -52,11 +51,14 @@ static void fixup_wifi_calibration(void *blob, int node)
52
51
int len ;
53
52
char dcxo ;
54
53
char * rf_params_prop ;
55
-
56
- /* Read calibration data from OTP */
57
- if (read_otp_data (DCXO_OFFSET , sizeof (dcxo ), & dcxo )) {
58
- printf ("WARNING: Could not read dcxo from OTP\n" );
59
- return ;
54
+ int version_reg1 = read_otp_version (VERSION_REG1_OFFSET );
55
+
56
+ if (version_reg1 >= 1 ) {
57
+ /* Read calibration data from OTP */
58
+ if (read_otp_data (DCXO_OFFSET , sizeof (dcxo ), & dcxo )) {
59
+ printf ("WARNING: Could not read dcxo from OTP\n" );
60
+ return ;
61
+ }
60
62
}
61
63
62
64
/* Overwrite first byte of rf-params property with DXCO */
@@ -66,7 +68,9 @@ static void fixup_wifi_calibration(void *blob, int node)
66
68
return ;
67
69
}
68
70
69
- rf_params_prop [0 ] = dcxo ;
71
+ if (version_reg1 >= 1 )
72
+ rf_params_prop [0 ] = dcxo ;
73
+
70
74
fdt_setprop (blob , node , "rf-params" , rf_params_prop , len );
71
75
}
72
76
0 commit comments