bf526-ezbrd.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * U-boot - main board file
  3. *
  4. * Copyright (c) 2005-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <command.h>
  11. #include <net.h>
  12. #include <netdev.h>
  13. #include <asm/blackfin.h>
  14. #include <asm/net.h>
  15. #include <asm/mach-common/bits/otp.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. int checkboard(void)
  18. {
  19. printf("Board: ADI BF526 EZ-Board board\n");
  20. printf(" Support: http://blackfin.uclinux.org/\n");
  21. return 0;
  22. }
  23. #ifdef CONFIG_BFIN_MAC
  24. static void board_init_enetaddr(uchar *mac_addr)
  25. {
  26. bool valid_mac = false;
  27. /* the MAC is stored in OTP memory page 0xDF */
  28. uint32_t ret;
  29. uint64_t otp_mac;
  30. ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac);
  31. if (!(ret & OTP_MASTER_ERROR)) {
  32. uchar *otp_mac_p = (uchar *)&otp_mac;
  33. for (ret = 0; ret < 6; ++ret)
  34. mac_addr[ret] = otp_mac_p[5 - ret];
  35. if (is_valid_ether_addr(mac_addr))
  36. valid_mac = true;
  37. }
  38. if (!valid_mac) {
  39. puts("Warning: Generating 'random' MAC address\n");
  40. bfin_gen_rand_mac(mac_addr);
  41. }
  42. eth_setenv_enetaddr("ethaddr", mac_addr);
  43. }
  44. int board_eth_init(bd_t *bis)
  45. {
  46. return bfin_EMAC_initialize(bis);
  47. }
  48. #endif
  49. int misc_init_r(void)
  50. {
  51. #ifdef CONFIG_BFIN_MAC
  52. uchar enetaddr[6];
  53. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  54. board_init_enetaddr(enetaddr);
  55. #endif
  56. return 0;
  57. }