21
21
22
22
#ifdef CONFIG_SOC_M467
23
23
#include <m460_eth.h>
24
+ #else
25
+ #include <numaker_eth.h>
24
26
#endif
25
27
26
28
LOG_MODULE_REGISTER (eth_numaker , CONFIG_ETHERNET_LOG_LEVEL );
27
29
28
30
/* Device EMAC Interface port */
29
31
#define NUMAKER_GMAC_INTF 0
30
- /* 2KB Data Flash at 0xFF800 */
31
- #define NUMAKER_DATA_FLASH (0xFF800U)
32
+
32
33
#define NUMAKER_MASK_32 (0xFFFFFFFFU)
33
34
#define NUMAKER_MII_CONFIG (ADVERTISE_CSMA | ADVERTISE_10HALF | ADVERTISE_10FULL | \
34
35
ADVERTISE_100HALF | ADVERTISE_100FULL)
35
36
#define NUMAKER_MII_LINKED (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)
36
37
37
38
extern synopGMACdevice GMACdev [GMAC_CNT ];
39
+
40
+ #ifdef CONFIG_NOCACHE_MEMORY
41
+ DmaDesc tx_desc [GMAC_CNT ][TRANSMIT_DESC_SIZE ] __nocache __aligned (64 );
42
+ DmaDesc rx_desc [GMAC_CNT ][RECEIVE_DESC_SIZE ] __nocache __aligned (64 );
43
+ struct sk_buff tx_buf [GMAC_CNT ][TRANSMIT_DESC_SIZE ] __nocache __aligned (64 );
44
+ struct sk_buff rx_buf [GMAC_CNT ][RECEIVE_DESC_SIZE ] __nocache __aligned (64 );
45
+ #else
38
46
extern struct sk_buff tx_buf [GMAC_CNT ][TRANSMIT_DESC_SIZE ];
39
47
extern struct sk_buff rx_buf [GMAC_CNT ][RECEIVE_DESC_SIZE ];
48
+ #endif
40
49
41
50
static uint32_t eth_phy_addr ;
42
51
@@ -167,33 +176,31 @@ static int reset_phy(synopGMACdevice *gmacdev)
167
176
168
177
static void m_numaker_read_mac_addr (char * mac )
169
178
{
179
+ #if DT_INST_PROP (0 , zephyr_random_mac_address )
180
+ gen_random_mac (mac , NUMAKER_OUI_B0 , NUMAKER_OUI_B1 , NUMAKER_OUI_B2 );
181
+ #else
170
182
uint32_t uid1 ;
171
- /* Fetch word 0 of data flash */
172
- uint32_t word0 = * (uint32_t * )(NUMAKER_DATA_FLASH + 0x04U );
183
+ uint32_t word0 ;
173
184
/*
174
- * Fetch word 1 of data flash
175
185
* we only want bottom 16 bits of word1 (MAC bits 32-47)
176
186
* and bit 9 forced to 1, bit 8 forced to 0
177
187
* Locally administered MAC, reduced conflicts
178
188
* http://en.wikipedia.org/wiki/MAC_address
179
189
*/
180
- uint32_t word1 = * (uint32_t * )NUMAKER_DATA_FLASH ;
181
-
182
- /* Not burn any mac address at the beginning of data flash */
183
- if (word0 == NUMAKER_MASK_32 ) {
184
- /* Generate a semi-unique MAC address from the UUID */
185
- SYS_UnlockReg ();
186
- /* Enable FMC ISP function */
187
- FMC_Open ();
188
- uid1 = FMC_ReadUID (1 );
189
- word1 = (uid1 & 0x003FFFFF ) | ((uid1 & 0x030000 ) << 6 ) >> 8 ;
190
- word0 = ((FMC_ReadUID (0 ) >> 4 ) << 20 ) | ((uid1 & 0xFF ) << 12 ) |
191
- (FMC_ReadUID (2 ) & 0xFFF );
192
- /* Disable FMC ISP function */
193
- FMC_Close ();
194
- /* Lock protected registers */
195
- SYS_LockReg ();
196
- }
190
+ uint32_t word1 ;
191
+
192
+ /* Generate a semi-unique MAC address from the UUID */
193
+ SYS_UnlockReg ();
194
+ /* Enable FMC ISP function */
195
+ FMC_Open ();
196
+ uid1 = FMC_ReadUID (1 );
197
+ word1 = (uid1 & 0x003FFFFF ) | ((uid1 & 0x030000 ) << 6 ) >> 8 ;
198
+ word0 = ((FMC_ReadUID (0 ) >> 4 ) << 20 ) | ((uid1 & 0xFF ) << 12 ) |
199
+ (FMC_ReadUID (2 ) & 0xFFF );
200
+ /* Disable FMC ISP function */
201
+ FMC_Close ();
202
+ /* Lock protected registers */
203
+ SYS_LockReg ();
197
204
198
205
word1 |= 0x00000200 ;
199
206
word1 &= 0x0000FEFF ;
@@ -204,7 +211,7 @@ static void m_numaker_read_mac_addr(char *mac)
204
211
mac [3 ] = (word0 & 0x00ff0000 ) >> 16 ;
205
212
mac [4 ] = (word0 & 0x0000ff00 ) >> 8 ;
206
213
mac [5 ] = (word0 & 0x000000ff );
207
-
214
+ #endif
208
215
LOG_INF ("mac address %02x:%02x:%02x:%02x:%02x:%02x" , mac [0 ], mac [1 ], mac [2 ], mac [3 ],
209
216
mac [4 ], mac [5 ]);
210
217
}
0 commit comments