tinker-rk3288.c 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 <net.h>
  12. #include <netdev.h>
  13. #include <asm/arch-rockchip/bootrom.h>
  14. #include <asm/io.h>
  15. static int get_ethaddr_from_eeprom(u8 *addr)
  16. {
  17. int ret;
  18. struct udevice *dev;
  19. ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
  20. if (ret)
  21. return ret;
  22. return i2c_eeprom_read(dev, 0, addr, 6);
  23. }
  24. int rk3288_board_late_init(void)
  25. {
  26. u8 ethaddr[6];
  27. if (get_ethaddr_from_eeprom(ethaddr))
  28. return 0;
  29. if (is_valid_ethaddr(ethaddr))
  30. eth_env_set_enetaddr("ethaddr", ethaddr);
  31. return 0;
  32. }
  33. int mmc_get_env_dev(void)
  34. {
  35. u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
  36. if (bootdevice_brom_id == BROM_BOOTSOURCE_EMMC)
  37. return 0;
  38. return 1;
  39. }