bf527-ezkit.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 BF527 EZ-Kit board\n");
  20. printf(" Support: http://blackfin.uclinux.org/\n");
  21. return 0;
  22. }
  23. phys_size_t initdram(int board_type)
  24. {
  25. gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
  26. gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
  27. return gd->bd->bi_memsize;
  28. }
  29. #ifdef CONFIG_BFIN_MAC
  30. static void board_init_enetaddr(uchar *mac_addr)
  31. {
  32. bool valid_mac = false;
  33. /* the MAC is stored in OTP memory page 0xDF */
  34. uint32_t ret;
  35. uint64_t otp_mac;
  36. ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac);
  37. if (!(ret & OTP_MASTER_ERROR)) {
  38. uchar *otp_mac_p = (uchar *)&otp_mac;
  39. for (ret = 0; ret < 6; ++ret)
  40. mac_addr[ret] = otp_mac_p[5 - ret];
  41. if (is_valid_ether_addr(mac_addr))
  42. valid_mac = true;
  43. }
  44. if (!valid_mac) {
  45. puts("Warning: Generating 'random' MAC address\n");
  46. bfin_gen_rand_mac(mac_addr);
  47. }
  48. eth_setenv_enetaddr("ethaddr", mac_addr);
  49. }
  50. int board_eth_init(bd_t *bis)
  51. {
  52. return bfin_EMAC_initialize(bis);
  53. }
  54. #endif
  55. int misc_init_r(void)
  56. {
  57. #ifdef CONFIG_BFIN_MAC
  58. uchar enetaddr[6];
  59. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  60. board_init_enetaddr(enetaddr);
  61. #endif
  62. return 0;
  63. }