bf537-stamp.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. #if defined(CONFIG_BFIN_IDE)
  43. void cf_outb(unsigned char val, volatile unsigned char *addr)
  44. {
  45. *(addr) = val;
  46. SSYNC();
  47. }
  48. unsigned char cf_inb(volatile unsigned char *addr)
  49. {
  50. volatile unsigned char c;
  51. c = *(addr);
  52. SSYNC();
  53. return c;
  54. }
  55. void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
  56. {
  57. int i;
  58. for (i = 0; i < words; i++)
  59. *(sect_buf + i) = *(addr);
  60. SSYNC();
  61. }
  62. void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
  63. {
  64. int i;
  65. for (i = 0; i < words; i++)
  66. *(addr) = *(sect_buf + i);
  67. SSYNC();
  68. }
  69. #endif /* CONFIG_BFIN_IDE */
  70. phys_size_t initdram(int board_type)
  71. {
  72. gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
  73. gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
  74. return gd->bd->bi_memsize;
  75. }
  76. void board_reset(void)
  77. {
  78. /* workaround for weak pull ups on ssel */
  79. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER) {
  80. bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~PF10);
  81. bfin_write_PORTFIO_SET(PF10);
  82. udelay(1);
  83. }
  84. }
  85. #ifdef CONFIG_BFIN_MAC
  86. static void board_init_enetaddr(uchar *mac_addr)
  87. {
  88. #ifdef CONFIG_SYS_NO_FLASH
  89. # define USE_MAC_IN_FLASH 0
  90. #else
  91. # define USE_MAC_IN_FLASH 1
  92. #endif
  93. bool valid_mac = false;
  94. if (USE_MAC_IN_FLASH) {
  95. /* we cram the MAC in the last flash sector */
  96. uchar *board_mac_addr = (uchar *)0x203F0000;
  97. if (is_valid_ether_addr(board_mac_addr)) {
  98. memcpy(mac_addr, board_mac_addr, 6);
  99. valid_mac = true;
  100. }
  101. }
  102. if (!valid_mac) {
  103. puts("Warning: Generating 'random' MAC address\n");
  104. bfin_gen_rand_mac(mac_addr);
  105. }
  106. eth_setenv_enetaddr("ethaddr", mac_addr);
  107. }
  108. int board_eth_init(bd_t *bis)
  109. {
  110. return bfin_EMAC_initialize(bis);
  111. }
  112. #endif
  113. #if defined(CONFIG_MISC_INIT_R)
  114. /* miscellaneous platform dependent initialisations */
  115. int misc_init_r(void)
  116. {
  117. #ifdef CONFIG_BFIN_MAC
  118. uchar enetaddr[6];
  119. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  120. board_init_enetaddr(enetaddr);
  121. #endif
  122. #ifndef CONFIG_SYS_NO_FLASH
  123. /* we use the last sector for the MAC address / POST LDR */
  124. extern flash_info_t flash_info[];
  125. flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
  126. #endif
  127. #if defined(CONFIG_BFIN_IDE)
  128. #if defined(CONFIG_BFIN_TRUE_IDE)
  129. /* Enable ATASEL when in True IDE mode */
  130. printf("Using CF True IDE Mode\n");
  131. cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA);
  132. udelay(1000);
  133. #elif defined(CONFIG_BFIN_CF_IDE)
  134. /* Disable ATASEL when we're in Common Memory Mode */
  135. printf("Using CF Common Memory Mode\n");
  136. cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS);
  137. udelay(1000);
  138. #elif defined(CONFIG_BFIN_HDD_IDE)
  139. printf("Using HDD IDE Mode\n");
  140. #endif
  141. ide_init();
  142. #endif /* CONFIG_BFIN_IDE */
  143. return 0;
  144. }
  145. #endif /* CONFIG_MISC_INIT_R */