pn62.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <mpc824x.h>
  24. #include <net.h>
  25. #include <pci.h>
  26. #include <netdev.h>
  27. #include "pn62.h"
  28. DECLARE_GLOBAL_DATA_PTR;
  29. static int get_serial_number (char *string, int size);
  30. static void get_mac_address(int id, u8 *mac);
  31. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  32. void show_boot_progress (int phase)
  33. {
  34. /*
  35. * Show phases of the bootm command on the front panel
  36. * LEDs and the scratchpad register #3 as well. We use
  37. * blinking LEDs for logical "1".
  38. */
  39. if (phase > 0) {
  40. set_led (8, (phase & 0x1) ? LED_SLOW_CLOCK : LED_0);
  41. set_led (9, (phase & 0x2) ? LED_SLOW_CLOCK : LED_0);
  42. set_led (10, (phase & 0x4) ? LED_SLOW_CLOCK : LED_0);
  43. set_led (11, (phase & 0x8) ? LED_SLOW_CLOCK : LED_0);
  44. }
  45. i2155x_write_scrapad (BOOT_STATUS, phase);
  46. if (phase < 0)
  47. i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
  48. }
  49. #endif
  50. void show_startup_phase (int phase)
  51. {
  52. /*
  53. * Show the phase of U-Boot startup on the front panel
  54. * LEDs and the scratchpad register #3 as well.
  55. */
  56. if (phase > 0) {
  57. set_led (8, (phase & 0x1) ? LED_1 : LED_0);
  58. set_led (9, (phase & 0x2) ? LED_1 : LED_0);
  59. set_led (10, (phase & 0x4) ? LED_1 : LED_0);
  60. set_led (11, (phase & 0x8) ? LED_1 : LED_0);
  61. }
  62. i2155x_write_scrapad (BOOT_STATUS, phase);
  63. if (phase < 0)
  64. i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
  65. }
  66. int checkboard (void)
  67. {
  68. show_startup_phase (1);
  69. puts ("Board: PN62\n");
  70. return 0;
  71. }
  72. phys_size_t initdram (int board_type)
  73. {
  74. long size;
  75. long new_bank0_end;
  76. long mear1;
  77. long emear1;
  78. show_startup_phase (2);
  79. size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
  80. new_bank0_end = size - 1;
  81. mear1 = mpc824x_mpc107_getreg (MEAR1);
  82. emear1 = mpc824x_mpc107_getreg (EMEAR1);
  83. mear1 = (mear1 & 0xFFFFFF00) |
  84. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
  85. emear1 = (emear1 & 0xFFFFFF00) |
  86. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
  87. mpc824x_mpc107_setreg (MEAR1, mear1);
  88. mpc824x_mpc107_setreg (EMEAR1, emear1);
  89. return (size);
  90. }
  91. /*
  92. * Initialize PCI Devices. We rely on auto-configuration.
  93. */
  94. #ifndef CONFIG_PCI_PNP
  95. #error "CONFIG_PCI_PNP is not defined, please correct!"
  96. #endif
  97. struct pci_controller hose = {
  98. };
  99. void pci_init_board (void)
  100. {
  101. show_startup_phase (4);
  102. pci_mpc824x_init (&hose);
  103. show_startup_phase (5);
  104. i2155x_init ();
  105. show_startup_phase (6);
  106. am79c95x_init ();
  107. show_startup_phase (7);
  108. }
  109. int misc_init_r (void)
  110. {
  111. char str[20];
  112. u8 mac[6];
  113. show_startup_phase (8);
  114. /*
  115. * Get serial number and ethernet addresses if not already defined
  116. * and update the board info structure and the environment.
  117. */
  118. if (getenv ("serial#") == NULL &&
  119. get_serial_number (str, strlen (str)) > 0) {
  120. setenv ("serial#", str);
  121. }
  122. show_startup_phase (9);
  123. if (!eth_getenv_enetaddr("ethaddr", mac)) {
  124. get_mac_address(0, mac);
  125. eth_setenv_enetaddr("ethaddr", mac);
  126. }
  127. show_startup_phase (10);
  128. #ifdef CONFIG_HAS_ETH1
  129. if (!eth_getenv_enetaddr("eth1addr", mac)) {
  130. get_mac_address(1, mac);
  131. eth_setenv_enetaddr("eth1addr", mac);
  132. }
  133. #endif /* CONFIG_HAS_ETH1 */
  134. show_startup_phase (11);
  135. /* Tell everybody that U-Boot is up and runnig */
  136. i2155x_write_scrapad (0, 0x12345678);
  137. return (0);
  138. }
  139. static int get_serial_number (char *string, int size)
  140. {
  141. int i;
  142. char c;
  143. if (size < I2155X_VPD_SN_SIZE)
  144. size = I2155X_VPD_SN_SIZE;
  145. for (i = 0; i < (size - 1); i++) {
  146. i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c);
  147. if (c == '\0')
  148. break;
  149. string[i] = c;
  150. }
  151. string[i] = '\0'; /* make sure it's terminated */
  152. return i;
  153. }
  154. static void get_mac_address(int id, u8 *mac)
  155. {
  156. i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
  157. }
  158. int board_eth_init(bd_t *bis)
  159. {
  160. return pci_eth_init(bis);
  161. }