bf533-stamp.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 <netdev.h>
  29. #include <asm/io.h>
  30. #include "bf533-stamp.h"
  31. DECLARE_GLOBAL_DATA_PTR;
  32. int checkboard(void)
  33. {
  34. printf("Board: ADI BF533 Stamp board\n");
  35. printf(" Support: http://blackfin.uclinux.org/\n");
  36. return 0;
  37. }
  38. /* PF0 and PF1 are used to switch between the ethernet and flash:
  39. * PF0 PF1
  40. * flash: 0 0
  41. * ether: 1 0
  42. */
  43. void swap_to(int device_id)
  44. {
  45. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
  46. SSYNC();
  47. bfin_write_FIO_FLAG_C(PF1);
  48. if (device_id == ETHERNET)
  49. bfin_write_FIO_FLAG_S(PF0);
  50. else if (device_id == FLASH)
  51. bfin_write_FIO_FLAG_C(PF0);
  52. else
  53. printf("Unknown device to switch\n");
  54. SSYNC();
  55. }
  56. #if defined(CONFIG_MISC_INIT_R)
  57. /* miscellaneous platform dependent initialisations */
  58. int misc_init_r(void)
  59. {
  60. #ifdef CONFIG_STAMP_CF
  61. cf_ide_init();
  62. #endif
  63. return 0;
  64. }
  65. #endif
  66. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  67. #define STATUS_LED_OFF 0
  68. #define STATUS_LED_ON 1
  69. static void stamp_led_set(int LED1, int LED2, int LED3)
  70. {
  71. bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
  72. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
  73. if (LED1 == STATUS_LED_OFF)
  74. *pFIO_FLAG_S = PF2;
  75. else
  76. *pFIO_FLAG_C = PF2;
  77. if (LED2 == STATUS_LED_OFF)
  78. *pFIO_FLAG_S = PF3;
  79. else
  80. *pFIO_FLAG_C = PF3;
  81. if (LED3 == STATUS_LED_OFF)
  82. *pFIO_FLAG_S = PF4;
  83. else
  84. *pFIO_FLAG_C = PF4;
  85. SSYNC();
  86. }
  87. void show_boot_progress(int status)
  88. {
  89. switch (status) {
  90. case 1:
  91. stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
  92. break;
  93. case 2:
  94. stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
  95. break;
  96. case 3:
  97. stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
  98. break;
  99. case 4:
  100. stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
  101. break;
  102. case 5:
  103. case 6:
  104. stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
  105. break;
  106. case 7:
  107. case 8:
  108. stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
  109. break;
  110. case 9:
  111. case 10:
  112. case 11:
  113. case 12:
  114. case 13:
  115. case 14:
  116. case 15:
  117. stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
  118. break;
  119. default:
  120. stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
  121. break;
  122. }
  123. }
  124. #endif
  125. #ifdef CONFIG_STATUS_LED
  126. #include <status_led.h>
  127. static void set_led(int pf, int state)
  128. {
  129. switch (state) {
  130. case STATUS_LED_OFF: bfin_write_FIO_FLAG_S(pf); break;
  131. case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break;
  132. case STATUS_LED_ON: bfin_write_FIO_FLAG_C(pf); break;
  133. }
  134. }
  135. static void set_leds(led_id_t mask, int state)
  136. {
  137. if (mask & 0x1) set_led(PF2, state);
  138. if (mask & 0x2) set_led(PF3, state);
  139. if (mask & 0x4) set_led(PF4, state);
  140. }
  141. void __led_init(led_id_t mask, int state)
  142. {
  143. bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
  144. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
  145. }
  146. void __led_set(led_id_t mask, int state)
  147. {
  148. set_leds(mask, state);
  149. }
  150. void __led_toggle(led_id_t mask)
  151. {
  152. set_leds(mask, STATUS_LED_BLINKING);
  153. }
  154. #endif
  155. #ifdef CONFIG_SMC91111
  156. int board_eth_init(bd_t *bis)
  157. {
  158. return smc91111_initialize(0, CONFIG_SMC91111_BASE);
  159. }
  160. #endif