vcma9.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * (C) Copyright 2002
  3. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  4. * Marius Groeger <mgroeger@sysgo.de>
  5. *
  6. * (C) Copyright 2002, 2010
  7. * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
  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 <common.h>
  28. #include <netdev.h>
  29. #include <i2c.h>
  30. #include <asm/io.h>
  31. #include <asm/arch/s3c24x0_cpu.h>
  32. #include "vcma9.h"
  33. #include "../common/common_util.h"
  34. DECLARE_GLOBAL_DATA_PTR;
  35. /*
  36. * Miscellaneous platform dependent initialisations
  37. */
  38. int board_early_init_f(void)
  39. {
  40. struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
  41. /* set up the I/O ports */
  42. writel(0x007FFFFF, &gpio->gpacon);
  43. writel(0x002AAAAA, &gpio->gpbcon);
  44. writel(0x000002BF, &gpio->gpbup);
  45. writel(0xAAAAAAAA, &gpio->gpccon);
  46. writel(0x0000FFFF, &gpio->gpcup);
  47. writel(0xAAAAAAAA, &gpio->gpdcon);
  48. writel(0x0000FFFF, &gpio->gpdup);
  49. writel(0xAAAAAAAA, &gpio->gpecon);
  50. writel(0x000037F7, &gpio->gpeup);
  51. writel(0x00000000, &gpio->gpfcon);
  52. writel(0x00000000, &gpio->gpfup);
  53. writel(0xFFEAFF5A, &gpio->gpgcon);
  54. writel(0x0000F0DC, &gpio->gpgup);
  55. writel(0x0028AAAA, &gpio->gphcon);
  56. writel(0x00000656, &gpio->gphup);
  57. /* setup correct IRQ modes for NIC (rising edge mode) */
  58. writel((readl(&gpio->extint2) & ~(7<<8)) | (4<<8), &gpio->extint2);
  59. /* select USB port 2 to be host or device (setup as host for now) */
  60. writel(readl(&gpio->misccr) | 0x08, &gpio->misccr);
  61. return 0;
  62. }
  63. int board_init(void)
  64. {
  65. /* arch number of VCMA9-Board */
  66. gd->bd->bi_arch_number = MACH_TYPE_MPL_VCMA9;
  67. /* adress of boot parameters */
  68. gd->bd->bi_boot_params = 0x30000100;
  69. icache_enable();
  70. dcache_enable();
  71. return 0;
  72. }
  73. /*
  74. * Get some Board/PLD Info
  75. */
  76. static u8 get_pld_reg(enum vcma9_pld_regs reg)
  77. {
  78. return readb(VCMA9_PLD_BASE + reg);
  79. }
  80. static u8 get_pld_version(void)
  81. {
  82. return (get_pld_reg(VCMA9_PLD_ID) >> 4) & 0x0F;
  83. }
  84. static u8 get_pld_revision(void)
  85. {
  86. return get_pld_reg(VCMA9_PLD_ID) & 0x0F;
  87. }
  88. static uchar get_board_pcb(void)
  89. {
  90. return ((get_pld_reg(VCMA9_PLD_BOARD) >> 4) & 0x03) + 'A';
  91. }
  92. static u8 get_nr_chips(void)
  93. {
  94. switch ((get_pld_reg(VCMA9_PLD_SDRAM) >> 4) & 0x0F) {
  95. case 0: return 4;
  96. case 1: return 1;
  97. case 2: return 2;
  98. default: return 0;
  99. }
  100. }
  101. static ulong get_chip_size(void)
  102. {
  103. switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
  104. case 0: return 16 * (1024*1024);
  105. case 1: return 32 * (1024*1024);
  106. case 2: return 8 * (1024*1024);
  107. case 3: return 8 * (1024*1024);
  108. default: return 0;
  109. }
  110. }
  111. static const char *get_chip_geom(void)
  112. {
  113. switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
  114. case 0: return "4Mx8x4";
  115. case 1: return "8Mx8x4";
  116. case 2: return "2Mx8x4";
  117. case 3: return "4Mx8x2";
  118. default: return "unknown";
  119. }
  120. }
  121. static void vcma9_show_info(char *board_name, char *serial)
  122. {
  123. printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n",
  124. board_name, serial,
  125. get_board_pcb(), get_pld_version(), get_pld_revision());
  126. printf("SDRAM: %d chips %s\n", get_nr_chips(), get_chip_geom());
  127. }
  128. int dram_init(void)
  129. {
  130. /* dram_init must store complete ramsize in gd->ram_size */
  131. gd->ram_size = get_chip_size() * get_nr_chips();
  132. return 0;
  133. }
  134. /*
  135. * Check Board Identity:
  136. */
  137. int checkboard(void)
  138. {
  139. char s[50];
  140. int i;
  141. backup_t *b = (backup_t *) s;
  142. i = getenv_f("serial#", s, 32);
  143. if ((i < 0) || strncmp (s, "VCMA9", 5)) {
  144. get_backup_values (b);
  145. if (strncmp (b->signature, "MPL\0", 4) != 0) {
  146. puts ("### No HW ID - assuming VCMA9");
  147. } else {
  148. b->serial_name[5] = 0;
  149. vcma9_show_info(b->serial_name, &b->serial_name[6]);
  150. }
  151. } else {
  152. s[5] = 0;
  153. vcma9_show_info(s, &s[6]);
  154. }
  155. return 0;
  156. }
  157. int board_late_init(void)
  158. {
  159. /*
  160. * check if environment is healthy, otherwise restore values
  161. * from shadow copy
  162. */
  163. check_env();
  164. return 0;
  165. }
  166. void vcma9_print_info(void)
  167. {
  168. char *s = getenv("serial#");
  169. if (!s) {
  170. puts ("### No HW ID - assuming VCMA9");
  171. } else {
  172. s[5] = 0;
  173. vcma9_show_info(s, &s[6]);
  174. }
  175. }
  176. #ifdef CONFIG_CMD_NET
  177. int board_eth_init(bd_t *bis)
  178. {
  179. int rc = 0;
  180. #ifdef CONFIG_CS8900
  181. rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
  182. #endif
  183. return rc;
  184. }
  185. #endif
  186. /*
  187. * Hardcoded flash setup:
  188. * Flash 0 is a non-CFI AMD AM29F400BB flash.
  189. */
  190. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  191. {
  192. info->portwidth = FLASH_CFI_16BIT;
  193. info->chipwidth = FLASH_CFI_BY16;
  194. info->interface = FLASH_CFI_X16;
  195. return 1;
  196. }