tinker-rk3288.c 856 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2016 Rockchip Electronics Co., Ltd
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <eeprom.h>
  8. #include <env.h>
  9. #include <i2c_eeprom.h>
  10. #include <init.h>
  11. #include <netdev.h>
  12. #include <asm/arch-rockchip/bootrom.h>
  13. #include <asm/io.h>
  14. static int get_ethaddr_from_eeprom(u8 *addr)
  15. {
  16. int ret;
  17. struct udevice *dev;
  18. ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
  19. if (ret)
  20. return ret;
  21. return i2c_eeprom_read(dev, 0, addr, 6);
  22. }
  23. int rk3288_board_late_init(void)
  24. {
  25. u8 ethaddr[6];
  26. if (get_ethaddr_from_eeprom(ethaddr))
  27. return 0;
  28. if (is_valid_ethaddr(ethaddr))
  29. eth_env_set_enetaddr("ethaddr", ethaddr);
  30. return 0;
  31. }
  32. int mmc_get_env_dev(void)
  33. {
  34. u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
  35. if (bootdevice_brom_id == BROM_BOOTSOURCE_EMMC)
  36. return 0;
  37. return 1;
  38. }