hub405.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <asm/processor.h>
  25. #include <command.h>
  26. #include <malloc.h>
  27. extern void lxt971_no_sleep(void);
  28. int board_early_init_f (void)
  29. {
  30. /*
  31. * IRQ 0-15 405GP internally generated; active high; level sensitive
  32. * IRQ 16 405GP internally generated; active low; level sensitive
  33. * IRQ 17-24 RESERVED
  34. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  35. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  36. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  37. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  38. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  39. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  40. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  41. */
  42. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  43. mtdcr(uicer, 0x00000000); /* disable all ints */
  44. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  45. mtdcr(uicpr, 0xFFFFFF9F); /* set int polarities */
  46. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  47. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  48. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  49. /*
  50. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  51. */
  52. mtebc (epcr, 0xa8400000); /* ebc always driven */
  53. return 0;
  54. }
  55. int misc_init_f (void)
  56. {
  57. return 0; /* dummy implementation */
  58. }
  59. int misc_init_r (void)
  60. {
  61. volatile unsigned char *duart0_mcr = (unsigned char *)((ulong)DUART0_BA + 4);
  62. volatile unsigned char *duart1_mcr = (unsigned char *)((ulong)DUART1_BA + 4);
  63. volatile unsigned char *duart2_mcr = (unsigned char *)((ulong)DUART2_BA + 4);
  64. volatile unsigned char *duart3_mcr = (unsigned char *)((ulong)DUART3_BA + 4);
  65. volatile unsigned char *led_reg = (unsigned char *)((ulong)DUART0_BA + 0x20);
  66. unsigned long val;
  67. int delay, flashcnt;
  68. char *str;
  69. /*
  70. * Enable interrupts in exar duart mcr[3]
  71. */
  72. *duart0_mcr = 0x08;
  73. *duart1_mcr = 0x08;
  74. *duart2_mcr = 0x08;
  75. *duart3_mcr = 0x08;
  76. /*
  77. * Set RS232/RS422 control (RS232 = high on GPIO)
  78. */
  79. val = in32(GPIO0_OR);
  80. val &= ~(CFG_UART2_RS232 | CFG_UART3_RS232 | CFG_UART4_RS232 | CFG_UART5_RS232);
  81. str = getenv("phys0");
  82. if (!str || (str && (str[0] == '0')))
  83. val |= CFG_UART2_RS232;
  84. str = getenv("phys1");
  85. if (!str || (str && (str[0] == '0')))
  86. val |= CFG_UART3_RS232;
  87. str = getenv("phys2");
  88. if (!str || (str && (str[0] == '0')))
  89. val |= CFG_UART4_RS232;
  90. str = getenv("phys3");
  91. if (!str || (str && (str[0] == '0')))
  92. val |= CFG_UART5_RS232;
  93. out32(GPIO0_OR, val);
  94. /*
  95. * Set NAND-FLASH GPIO signals to default
  96. */
  97. out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
  98. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
  99. /*
  100. * check board type and setup AP power
  101. */
  102. str = getenv("bd_type"); /* this is only set on non prototype hardware */
  103. if (str != NULL) {
  104. if ((strcmp(str, "swch405") == 0) || (strcmp(str, "hub405") == 0)) {
  105. unsigned char led_reg_default = 0;
  106. str = getenv("ap_pwr");
  107. if (!str || (str && (str[0] == '1')))
  108. led_reg_default = 0x04 | 0x02 ; /* U2_LED | AP_PWR */
  109. /*
  110. * Flash LEDs on SWCH405
  111. */
  112. for (flashcnt = 0; flashcnt < 3; flashcnt++) {
  113. *led_reg = led_reg_default; /* LED_A..D off */
  114. for (delay = 0; delay < 100; delay++)
  115. udelay(1000);
  116. *led_reg = led_reg_default | 0xf0; /* LED_A..D on */
  117. for (delay = 0; delay < 50; delay++)
  118. udelay(1000);
  119. }
  120. *led_reg = led_reg_default;
  121. }
  122. }
  123. /*
  124. * Reset external DUARTs
  125. */
  126. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_DUART_RST); /* set reset to high */
  127. udelay(10); /* wait 10us */
  128. out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_DUART_RST); /* set reset to low */
  129. udelay(1000); /* wait 1ms */
  130. return (0);
  131. }
  132. /*
  133. * Check Board Identity:
  134. */
  135. int checkboard (void)
  136. {
  137. unsigned char str[64];
  138. int i = getenv_r ("serial#", str, sizeof(str));
  139. puts ("Board: ");
  140. if (i == -1) {
  141. puts ("### No HW ID - assuming HUB405");
  142. } else {
  143. puts(str);
  144. }
  145. putc ('\n');
  146. /*
  147. * Disable sleep mode in LXT971
  148. */
  149. lxt971_no_sleep();
  150. return 0;
  151. }
  152. long int initdram (int board_type)
  153. {
  154. unsigned long val;
  155. mtdcr(memcfga, mem_mb0cf);
  156. val = mfdcr(memcfgd);
  157. #if 0
  158. printf("\nmb0cf=%x\n", val); /* test-only */
  159. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  160. #endif
  161. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  162. }
  163. int testdram (void)
  164. {
  165. /* TODO: XXX XXX XXX */
  166. printf ("test: 16 MB - ok\n");
  167. return (0);
  168. }
  169. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  170. #include <linux/mtd/nand.h>
  171. extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
  172. void nand_init(void)
  173. {
  174. nand_probe(CFG_NAND_BASE);
  175. if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
  176. print_size(nand_dev_desc[0].totlen, "\n");
  177. }
  178. }
  179. #endif