cradle.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * (C) Copyright 2002
  3. * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.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., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <asm/arch/pxa-regs.h>
  28. #include <common.h>
  29. #include <netdev.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /* ------------------------------------------------------------------------- */
  32. /* local prototypes */
  33. void set_led (int led, int color);
  34. void error_code_halt (int code);
  35. int init_sio (int led, unsigned long base);
  36. inline void cradle_outb (unsigned short val, unsigned long base,
  37. unsigned long reg);
  38. inline unsigned char cradle_inb (unsigned long base, unsigned long reg);
  39. inline void sleep (int i);
  40. inline void
  41. /**********************************************************/
  42. sleep (int i)
  43. /**********************************************************/
  44. {
  45. while (i--) {
  46. udelay (1000000);
  47. }
  48. }
  49. void
  50. /**********************************************************/
  51. error_code_halt (int code)
  52. /**********************************************************/
  53. {
  54. while (1) {
  55. led_code (code, RED);
  56. sleep (1);
  57. led_code (0, OFF);
  58. sleep (1);
  59. }
  60. }
  61. void
  62. /**********************************************************/
  63. led_code (int code, int color)
  64. /**********************************************************/
  65. {
  66. int i;
  67. code &= 0xf; /* only 4 leds */
  68. for (i = 0; i < 4; i++) {
  69. if (code & (1 << i)) {
  70. set_led (i, color);
  71. } else {
  72. set_led (i, OFF);
  73. }
  74. }
  75. }
  76. void
  77. /**********************************************************/
  78. set_led (int led, int color)
  79. /**********************************************************/
  80. {
  81. int shift = led * 2;
  82. unsigned long mask = 0x3 << shift;
  83. CRADLE_LED_CLR_REG = mask; /* clear bits */
  84. CRADLE_LED_SET_REG = (color << shift); /* set bits */
  85. udelay (5000);
  86. }
  87. inline void
  88. /**********************************************************/
  89. cradle_outb (unsigned short val, unsigned long base, unsigned long reg)
  90. /**********************************************************/
  91. {
  92. *(volatile unsigned short *) (base + (reg * 2)) = val;
  93. }
  94. inline unsigned char
  95. /**********************************************************/
  96. cradle_inb (unsigned long base, unsigned long reg)
  97. /**********************************************************/
  98. {
  99. unsigned short val;
  100. val = *(volatile unsigned short *) (base + (reg * 2));
  101. return (val & 0xff);
  102. }
  103. int
  104. /**********************************************************/
  105. init_sio (int led, unsigned long base)
  106. /**********************************************************/
  107. {
  108. unsigned char val;
  109. set_led (led, YELLOW);
  110. val = cradle_inb (base, CRADLE_SIO_INDEX);
  111. val = cradle_inb (base, CRADLE_SIO_INDEX);
  112. if (val != 0) {
  113. set_led (led, RED);
  114. return -1;
  115. }
  116. /* map SCC2 to COM1 */
  117. cradle_outb (0x01, base, CRADLE_SIO_INDEX);
  118. cradle_outb (0x00, base, CRADLE_SIO_DATA);
  119. /* enable SCC2 extended regs */
  120. cradle_outb (0x40, base, CRADLE_SIO_INDEX);
  121. cradle_outb (0xa0, base, CRADLE_SIO_DATA);
  122. /* enable SCC2 clock multiplier */
  123. cradle_outb (0x51, base, CRADLE_SIO_INDEX);
  124. cradle_outb (0x04, base, CRADLE_SIO_DATA);
  125. /* enable SCC2 */
  126. cradle_outb (0x00, base, CRADLE_SIO_INDEX);
  127. cradle_outb (0x04, base, CRADLE_SIO_DATA);
  128. /* map SCC2 DMA to channel 0 */
  129. cradle_outb (0x4f, base, CRADLE_SIO_INDEX);
  130. cradle_outb (0x09, base, CRADLE_SIO_DATA);
  131. /* read ID from SIO to check operation */
  132. cradle_outb (0xe4, base, 0x3f8 + 0x3);
  133. val = cradle_inb (base, 0x3f8 + 0x0);
  134. if ((val & 0xf0) != 0x20) {
  135. set_led (led, RED);
  136. /* disable SCC2 */
  137. cradle_outb (0, base, CRADLE_SIO_INDEX);
  138. cradle_outb (0, base, CRADLE_SIO_DATA);
  139. return -1;
  140. }
  141. /* set back to bank 0 */
  142. cradle_outb (0, base, 0x3f8 + 0x3);
  143. set_led (led, GREEN);
  144. return 0;
  145. }
  146. /*
  147. * Miscelaneous platform dependent initialisations
  148. */
  149. int
  150. /**********************************************************/
  151. board_late_init (void)
  152. /**********************************************************/
  153. {
  154. return (0);
  155. }
  156. int
  157. /**********************************************************/
  158. board_init (void)
  159. /**********************************************************/
  160. {
  161. led_code (0xf, YELLOW);
  162. /* arch number of HHP Cradle */
  163. gd->bd->bi_arch_number = MACH_TYPE_HHP_CRADLE;
  164. /* adress of boot parameters */
  165. gd->bd->bi_boot_params = 0xa0000100;
  166. /* Init SIOs to enable SCC2 */
  167. udelay (100000); /* delay makes it look neat */
  168. init_sio (0, CRADLE_SIO1_PHYS);
  169. udelay (100000);
  170. init_sio (1, CRADLE_SIO2_PHYS);
  171. udelay (100000);
  172. init_sio (2, CRADLE_SIO3_PHYS);
  173. udelay (100000);
  174. set_led (3, GREEN);
  175. return 1;
  176. }
  177. int
  178. /**********************************************************/
  179. dram_init (void)
  180. /**********************************************************/
  181. {
  182. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  183. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  184. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  185. gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
  186. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  187. gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
  188. gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
  189. gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
  190. return (PHYS_SDRAM_1_SIZE +
  191. PHYS_SDRAM_2_SIZE +
  192. PHYS_SDRAM_3_SIZE +
  193. PHYS_SDRAM_4_SIZE );
  194. }
  195. #ifdef CONFIG_CMD_NET
  196. int board_eth_init(bd_t *bis)
  197. {
  198. int rc = 0;
  199. #ifdef CONFIG_SMC91111
  200. rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
  201. #endif
  202. return rc;
  203. }
  204. #endif