Hi Jonas, On 20 April 2017 at 12:23, Jonas Karlman <jo...@kwiboo.se> wrote: > Set ethernet mac address in late init for Tinker Board, > prevents getting a random mac address each boot. > > Read mac address from eeprom, first 6 bytes from m24c08@50. > Same as /etc/init.d/rockchip.sh on Tinker OS. > > Signed-off-by: Jonas Karlman <jo...@kwiboo.se> > --- > > Changes in v2: > - Change to use i2c_eeprom device driver > > arch/arm/dts/rk3288-tinker.dts | 7 ++++++ > board/rockchip/tinker_rk3288/tinker-rk3288.c | 33 > ++++++++++++++++++++++++++++ > configs/tinker-rk3288_defconfig | 3 +++ > 3 files changed, 43 insertions(+) > > diff --git a/arch/arm/dts/rk3288-tinker.dts b/arch/arm/dts/rk3288-tinker.dts > index 22881cb785..ea2f715922 100644 > --- a/arch/arm/dts/rk3288-tinker.dts > +++ b/arch/arm/dts/rk3288-tinker.dts > @@ -67,3 +67,10 @@ > &gpio8 { > u-boot,dm-pre-reloc; > }; > + > +&i2c2 { > + m24c08@50 { > + compatible = "at,24c08", "i2c-eeprom"; > + reg = <0x50>; > + }; > +}; > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c > b/board/rockchip/tinker_rk3288/tinker-rk3288.c > index 79541a3939..e0e8744599 100644 > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c > @@ -5,3 +5,36 @@ > */ > > #include <common.h> > +#include <dm.h> > +#include <i2c_eeprom.h> > +#include <netdev.h> > + > +static int get_ethaddr_from_eeprom(u8 *addr) > +{ > + int ret; > + struct udevice *dev; > + const struct i2c_eeprom_ops *ops; > + > + ret = uclass_get_device_by_name(UCLASS_I2C_EEPROM, "m24c08@50", &dev);
Can you use uclass_first_device_err()? There is probably only one I2C eeprom on the board. > + if (ret) > + return ret; > + > + ops = device_get_ops(dev); > + if (!ops->read) > + return -ENOSYS; > + > + return ops->read(dev, 0x0, addr, 6); Unfortunately there is no exported i2c_eeprom_read() / write() functions, but there should be. Can you please add these to i2c_eeprom.c in a separate patch? The functions should call the operation, since things outside a uclass should not access the operations directly. The new functions should be declared in the header file too. See pch.h for an example of how to do that. Then you can call that here. Sorry for the extra work. > +} > + > +int rk_board_late_init(void) > +{ > + u8 ethaddr[6]; > + > + if (get_ethaddr_from_eeprom(ethaddr)) > + return 0; > + > + if (is_valid_ethaddr(ethaddr)) > + eth_setenv_enetaddr("ethaddr", ethaddr); > + > + return 0; > +} > diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig > index cec39384b3..dc3699d5c4 100644 > --- a/configs/tinker-rk3288_defconfig > +++ b/configs/tinker-rk3288_defconfig > @@ -11,6 +11,7 @@ CONFIG_CONSOLE_MUX=y > # CONFIG_DISPLAY_CPUINFO is not set > CONFIG_SPL_STACK_R=y > CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 > +CONFIG_SPL_I2C_SUPPORT=y > # CONFIG_CMD_IMLS is not set > CONFIG_CMD_GPT=y > CONFIG_CMD_MMC=y > @@ -39,6 +40,8 @@ CONFIG_CLK=y > CONFIG_SPL_CLK=y > CONFIG_ROCKCHIP_GPIO=y > CONFIG_SYS_I2C_ROCKCHIP=y > +CONFIG_MISC=y > +CONFIG_I2C_EEPROM=y > CONFIG_MMC_DW=y > CONFIG_MMC_DW_ROCKCHIP=y > CONFIG_DM_ETH=y > -- > 2.11.0 > Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot