cm-bf527.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <net.h>
  11. #include <netdev.h>
  12. #include <asm/blackfin.h>
  13. #include <asm/net.h>
  14. #include <asm/mach-common/bits/otp.h>
  15. #include "../cm-bf537e/gpio_cfi_flash.h"
  16. DECLARE_GLOBAL_DATA_PTR;
  17. int checkboard(void)
  18. {
  19. printf("Board: Bluetechnix CM-BF527 board\n");
  20. printf(" Support: http://www.bluetechnix.at/\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. gpio_cfi_flash_init();
  57. return 0;
  58. }