mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-10-30 19:48:19 +00:00 
			
		
		
		
	Create board/$(VENDOR)/common folder to accommodate the common code shared by other atmel boards, now put the code to set ethernet mac address from eeprom, which uses the i2c eeprom driver. Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com> Reviewed-by: Simon Glass <sjg@chromium.org>
		
			
				
	
	
		
			37 lines
		
	
	
		
			675 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			675 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Copyright (C) 2017 Microchip
 | |
|  *		      Wenyou Yang <wenyou.yang@microchip.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier:	GPL-2.0+
 | |
|  */
 | |
| 
 | |
| #include <common.h>
 | |
| #include <dm.h>
 | |
| #include <i2c_eeprom.h>
 | |
| #include <netdev.h>
 | |
| 
 | |
| int at91_set_ethaddr(int offset)
 | |
| {
 | |
| 	const int ETH_ADDR_LEN = 6;
 | |
| 	unsigned char ethaddr[ETH_ADDR_LEN];
 | |
| 	const char *ETHADDR_NAME = "ethaddr";
 | |
| 	struct udevice *dev;
 | |
| 	int ret;
 | |
| 
 | |
| 	if (env_get(ETHADDR_NAME))
 | |
| 		return 0;
 | |
| 
 | |
| 	ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
 | |
| 	if (ret)
 | |
| 		return ret;
 | |
| 
 | |
| 	ret = i2c_eeprom_read(dev, offset, ethaddr, 6);
 | |
| 	if (ret)
 | |
| 		return ret;
 | |
| 
 | |
| 	if (is_valid_ethaddr(ethaddr))
 | |
| 		eth_env_set_enetaddr(ETHADDR_NAME, ethaddr);
 | |
| 
 | |
| 	return 0;
 | |
| }
 |