[U-Boot] [PATCH] rockchip: tinker: set ethaddr in late init
Simon Glass
sjg at chromium.org
Tue Apr 18 04:01:23 UTC 2017
Hi Jonas,
On 17 April 2017 at 15:13, Jonas Karlman <jonas at 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 0x50 on i2c2.
> Same as /etc/init.d/rockchip.sh on Tinker OS.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
> ---
>
> board/rockchip/tinker_rk3288/tinker-rk3288.c | 26
++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c
b/board/rockchip/tinker_rk3288/tinker-rk3288.c
> index 79541a3939..48165b2545 100644
> --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
> +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
> @@ -5,3 +5,29 @@
> */
>
> #include <common.h>
> +#include <i2c.h>
> +#include <netdev.h>
> +
> +int rk_board_late_init(void)
> +{
> + struct udevice *dev;
> + int ret;
> + u8 mac[6];
> +
> + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev);
> + if (ret) {
> + debug("failed to get eeprom\n");
> + return 0;
> + }
I'm sure this works, but really we should have this chip mentioned in the
device tree under &i2c2. Then we should be able to use the i2c_eeprom
driver. I cannot see this board supported in Linux to figure out how it
does it there.
I think tinker is the CHIP board, right? Are there instructions somewhere
on how to load U-Boot onto it?
> +
> + ret = dm_i2c_read(dev, 0x0, mac, 6);
> + if (ret) {
> + debug("failed to read mac\n");
> + return 0;
> + }
> +
> + if (is_valid_ethaddr(mac))
> + eth_setenv_enetaddr("ethaddr", mac);
> +
> + return 0;
> +}
> --
> 2.11.0
>
Regards,
Simon
More information about the U-Boot
mailing list