bf537-stamp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. void board_reset(void)
  43. {
  44. /* workaround for weak pull ups on ssel */
  45. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER)
  46. bfin_reset_boot_spi_cs(GPIO_PF10);
  47. }
  48. #ifdef CONFIG_BFIN_MAC
  49. static void board_init_enetaddr(uchar *mac_addr)
  50. {
  51. #ifdef CONFIG_SYS_NO_FLASH
  52. # define USE_MAC_IN_FLASH 0
  53. #else
  54. # define USE_MAC_IN_FLASH 1
  55. #endif
  56. bool valid_mac = false;
  57. if (USE_MAC_IN_FLASH) {
  58. /* we cram the MAC in the last flash sector */
  59. uchar *board_mac_addr = (uchar *)0x203F0000;
  60. if (is_valid_ether_addr(board_mac_addr)) {
  61. memcpy(mac_addr, board_mac_addr, 6);
  62. valid_mac = true;
  63. }
  64. }
  65. if (!valid_mac) {
  66. puts("Warning: Generating 'random' MAC address\n");
  67. bfin_gen_rand_mac(mac_addr);
  68. }
  69. eth_setenv_enetaddr("ethaddr", mac_addr);
  70. }
  71. int board_eth_init(bd_t *bis)
  72. {
  73. return bfin_EMAC_initialize(bis);
  74. }
  75. #endif
  76. /* miscellaneous platform dependent initialisations */
  77. int misc_init_r(void)
  78. {
  79. #ifdef CONFIG_BFIN_MAC
  80. uchar enetaddr[6];
  81. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  82. board_init_enetaddr(enetaddr);
  83. #endif
  84. #ifndef CONFIG_SYS_NO_FLASH
  85. /* we use the last sector for the MAC address / POST LDR */
  86. extern flash_info_t flash_info[];
  87. flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
  88. #endif
  89. #ifdef CONFIG_BFIN_IDE
  90. cf_ide_init();
  91. #endif
  92. return 0;
  93. }