vcma9.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. /* adress of boot parameters */
  66. gd->bd->bi_boot_params = 0x30000100;
  67. icache_enable();
  68. dcache_enable();
  69. return 0;
  70. }
  71. /*
  72. * Get some Board/PLD Info
  73. */
  74. static u8 get_pld_reg(enum vcma9_pld_regs reg)
  75. {
  76. return readb(VCMA9_PLD_BASE + reg);
  77. }
  78. static u8 get_pld_version(void)
  79. {
  80. return (get_pld_reg(VCMA9_PLD_ID) >> 4) & 0x0F;
  81. }
  82. static u8 get_pld_revision(void)
  83. {
  84. return get_pld_reg(VCMA9_PLD_ID) & 0x0F;
  85. }
  86. static uchar get_board_pcb(void)
  87. {
  88. return ((get_pld_reg(VCMA9_PLD_BOARD) >> 4) & 0x03) + 'A';
  89. }
  90. static u8 get_nr_chips(void)
  91. {
  92. switch ((get_pld_reg(VCMA9_PLD_SDRAM) >> 4) & 0x0F) {
  93. case 0: return 4;
  94. case 1: return 1;
  95. case 2: return 2;
  96. default: return 0;
  97. }
  98. }
  99. static ulong get_chip_size(void)
  100. {
  101. switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
  102. case 0: return 16 * (1024*1024);
  103. case 1: return 32 * (1024*1024);
  104. case 2: return 8 * (1024*1024);
  105. case 3: return 8 * (1024*1024);
  106. default: return 0;
  107. }
  108. }
  109. static const char *get_chip_geom(void)
  110. {
  111. switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
  112. case 0: return "4Mx8x4";
  113. case 1: return "8Mx8x4";
  114. case 2: return "2Mx8x4";
  115. case 3: return "4Mx8x2";
  116. default: return "unknown";
  117. }
  118. }
  119. static void vcma9_show_info(char *board_name, char *serial)
  120. {
  121. printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n",
  122. board_name, serial,
  123. get_board_pcb(), get_pld_version(), get_pld_revision());
  124. printf("SDRAM: %d chips %s\n", get_nr_chips(), get_chip_geom());
  125. }
  126. int dram_init(void)
  127. {
  128. /* dram_init must store complete ramsize in gd->ram_size */
  129. gd->ram_size = get_chip_size() * get_nr_chips();
  130. return 0;
  131. }
  132. /*
  133. * Check Board Identity:
  134. */
  135. int checkboard(void)
  136. {
  137. char s[50];
  138. int i;
  139. backup_t *b = (backup_t *) s;
  140. i = getenv_f("serial#", s, 32);
  141. if ((i < 0) || strncmp (s, "VCMA9", 5)) {
  142. get_backup_values (b);
  143. if (strncmp (b->signature, "MPL\0", 4) != 0) {
  144. puts ("### No HW ID - assuming VCMA9");
  145. } else {
  146. b->serial_name[5] = 0;
  147. vcma9_show_info(b->serial_name, &b->serial_name[6]);
  148. }
  149. } else {
  150. s[5] = 0;
  151. vcma9_show_info(s, &s[6]);
  152. }
  153. return 0;
  154. }
  155. int board_late_init(void)
  156. {
  157. /*
  158. * check if environment is healthy, otherwise restore values
  159. * from shadow copy
  160. */
  161. check_env();
  162. return 0;
  163. }
  164. void vcma9_print_info(void)
  165. {
  166. char *s = getenv("serial#");
  167. if (!s) {
  168. puts ("### No HW ID - assuming VCMA9");
  169. } else {
  170. s[5] = 0;
  171. vcma9_show_info(s, &s[6]);
  172. }
  173. }
  174. #ifdef CONFIG_CMD_NET
  175. int board_eth_init(bd_t *bis)
  176. {
  177. int rc = 0;
  178. #ifdef CONFIG_CS8900
  179. rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
  180. #endif
  181. return rc;
  182. }
  183. #endif
  184. /*
  185. * Hardcoded flash setup:
  186. * Flash 0 is a non-CFI AMD AM29F400BB flash.
  187. */
  188. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  189. {
  190. info->portwidth = FLASH_CFI_16BIT;
  191. info->chipwidth = FLASH_CFI_BY16;
  192. info->interface = FLASH_CFI_X16;
  193. return 1;
  194. }