cradle.c 5.7 KB

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