bf526-ezbrd.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifdef CONFIG_SYS_NO_FLASH
  27. # define USE_MAC_IN_FLASH 0
  28. #else
  29. # define USE_MAC_IN_FLASH 1
  30. #endif
  31. bool valid_mac = false;
  32. if (USE_MAC_IN_FLASH) {
  33. /* we cram the MAC in the last flash sector */
  34. uchar *board_mac_addr = (uchar *)0x203F0096;
  35. if (is_valid_ether_addr(board_mac_addr)) {
  36. memcpy(mac_addr, board_mac_addr, 6);
  37. valid_mac = true;
  38. }
  39. }
  40. if (!valid_mac) {
  41. puts("Warning: Generating 'random' MAC address\n");
  42. bfin_gen_rand_mac(mac_addr);
  43. }
  44. eth_setenv_enetaddr("ethaddr", mac_addr);
  45. }
  46. int board_eth_init(bd_t *bis)
  47. {
  48. return bfin_EMAC_initialize(bis);
  49. }
  50. #endif
  51. int misc_init_r(void)
  52. {
  53. #ifdef CONFIG_BFIN_MAC
  54. uchar enetaddr[6];
  55. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  56. board_init_enetaddr(enetaddr);
  57. #endif
  58. #ifndef CONFIG_SYS_NO_FLASH
  59. /* we use the last sector for the MAC address / POST LDR */
  60. extern flash_info_t flash_info[];
  61. flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
  62. #endif
  63. return 0;
  64. }