bf537-stamp.c 2.6 KB

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