ssplyh 发表于 2017-7-6 12:42:46

imx6 mac地址设置

lib_arm/board.c  void start_armboot (void)                                                      
  {                                                                              
  ...
  eth_initialize(gd->bd);               ---------------------------+
  ...                                                                |      
  };                                                                     |      
  |      
  |      
  int eth_initialize(bd_t *bis)                            <-------------+      
  {                                                                              
  ......
  /* Try board-specific initialization first.If it fails or isn't         
  * present, try the cpu-specific initialization */                        
  if (board_eth_init(bis) < 0)                                                
  cpu_eth_init(bis);                        -------------+            
  ......                                                       |            
  }                                                                |            
  |            
  int cpu_eth_init(bd_t *bis)                           <--------+            
  {                                                                              
  int rc = -ENODEV;                                                         
  #if defined(CONFIG_MXC_FEC)                                                   
  rc = mxc_fec_initialize(bis);    ------+                                    
  |                                    
  /* Board level init */               |                                    
  enet_board_init();                     |                                    
  |                                    
  #endif                                     |                                    
  return rc;                           |                                    
  }                                          |                                    
  |                                    
  int mxc_fec_initialize(bd_t *bis)   <------+                                    
  {                                                                              
  ......
  if (fec_get_hwaddr(dev, ethaddr) == 0) {                  ------+      
  printf(&quot;got MAC address from IIM: %pM\n&quot;, ethaddr);         |      
  memcpy(dev->enetaddr, ethaddr, 6);                        |      
  fec_set_hwaddr(dev);                                        |      
  }                                                               |      
  }                                                                   |      
  |      
  return 1;                                                         |      
  }                                                                     |      
  |      
  static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)<--+      
  {                                                                              
  #ifdef CONFIG_GET_FEC_MAC_ADDR_FROM_IIM                                       
  fec_get_mac_addr(mac);                     -------+                     
  return 0;                                           |                     
  #else                                                   |                     
  return -1;                                          |                     
  #endif                                                |                     
  }                                                       |                     
  |                     
  #ifdef CONFIG_GET_FEC_MAC_ADDR_FROM_IIM               |                     
  int fec_get_mac_addr(unsigned char *mac)          <---- +                     
  {                                                                              
  #if 0                                                                           
  unsigned int value;                        //不读取寄存器中的值                              
  value = readl(OCOTP_BASE_ADDR + HW_OCOTP_MACn(0));                        
  mac = value & 0xff;                                                      
  mac = (value >> 8) & 0xff;                                             
  mac = (value >> 16) & 0xff;                                             
  mac = (value >> 24) & 0xff;                                             
  value = readl(OCOTP_BASE_ADDR + HW_OCOTP_MACn(1));                        
  mac = value & 0xff;                                                      
  mac = (value >> 8) & 0xff;                                             
  #else                                                                           
  eth_getenv_enetaddr(&quot;ethaddr&quot;, mac);          //使用环境变量设置的mac地址                              
  #endif                                                                        
  return 0;                                                                  
  }
页: [1]
查看完整版本: imx6 mac地址设置