bf537-stamp.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * U-boot - main board file
  3. *
  4. * Copyright (c) 2005-2008 Analog Devices Inc.
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  25. * MA 02110-1301 USA
  26. */
  27. #include <common.h>
  28. #include <config.h>
  29. #include <command.h>
  30. #include <asm/blackfin.h>
  31. #include <asm/net.h>
  32. #include <net.h>
  33. #include <asm/mach-common/bits/bootrom.h>
  34. #include <netdev.h>
  35. DECLARE_GLOBAL_DATA_PTR;
  36. int checkboard(void)
  37. {
  38. printf("Board: ADI BF537 stamp board\n");
  39. printf(" Support: http://blackfin.uclinux.org/\n");
  40. return 0;
  41. }
  42. #ifdef CONFIG_BFIN_MAC
  43. static void board_init_enetaddr(uchar *mac_addr)
  44. {
  45. #ifdef CONFIG_SYS_NO_FLASH
  46. # define USE_MAC_IN_FLASH 0
  47. #else
  48. # define USE_MAC_IN_FLASH 1
  49. #endif
  50. bool valid_mac = false;
  51. if (USE_MAC_IN_FLASH) {
  52. /* we cram the MAC in the last flash sector */
  53. uchar *board_mac_addr = (uchar *)0x203F0000;
  54. if (is_valid_ether_addr(board_mac_addr)) {
  55. memcpy(mac_addr, board_mac_addr, 6);
  56. valid_mac = true;
  57. }
  58. }
  59. if (!valid_mac) {
  60. puts("Warning: Generating 'random' MAC address\n");
  61. bfin_gen_rand_mac(mac_addr);
  62. }
  63. eth_setenv_enetaddr("ethaddr", mac_addr);
  64. }
  65. int board_eth_init(bd_t *bis)
  66. {
  67. return bfin_EMAC_initialize(bis);
  68. }
  69. #endif
  70. /* miscellaneous platform dependent initialisations */
  71. int misc_init_r(void)
  72. {
  73. #ifdef CONFIG_BFIN_MAC
  74. uchar enetaddr[6];
  75. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  76. board_init_enetaddr(enetaddr);
  77. #endif
  78. #ifndef CONFIG_SYS_NO_FLASH
  79. /* we use the last sector for the MAC address / POST LDR */
  80. extern flash_info_t flash_info[];
  81. flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
  82. #endif
  83. #ifdef CONFIG_BFIN_IDE
  84. cf_ide_init();
  85. #endif
  86. return 0;
  87. }