blob: 9f259c220bfd218dd13e0078474b972e5fd2a6a2 [file] [log] [blame]
wdenk1fe2c702003-03-06 21:55:29 +00001/*
2 * (C) Copyright 2002
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
5 *
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +00006 * (C) Copyright 2002, 2010
wdenk1fe2c702003-03-06 21:55:29 +00007 * 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
28#include <common.h>
Ben Warren3bf5d832009-08-25 13:09:37 -070029#include <netdev.h>
wdenk1fe2c702003-03-06 21:55:29 +000030#include <i2c.h>
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000031#include <asm/io.h>
32#include <asm/arch/s3c24x0_cpu.h>
wdenk1fe2c702003-03-06 21:55:29 +000033
34#include "vcma9.h"
35#include "../common/common_util.h"
36
Wolfgang Denk6405a152006-03-31 18:32:53 +020037DECLARE_GLOBAL_DATA_PTR;
wdenk1fe2c702003-03-06 21:55:29 +000038
wdenk1fe2c702003-03-06 21:55:29 +000039/*
40 * Miscellaneous platform dependent initialisations
41 */
42
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000043int board_early_init_f(void)
wdenk1fe2c702003-03-06 21:55:29 +000044{
kevin.morfitt@fearnside-systems.co.uk1464f4d2009-10-10 13:33:11 +090045 struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
wdenk1fe2c702003-03-06 21:55:29 +000046
wdenk1fe2c702003-03-06 21:55:29 +000047 /* set up the I/O ports */
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000048 writel(0x007FFFFF, &gpio->gpacon);
49 writel(0x002AAAAA, &gpio->gpbcon);
50 writel(0x000002BF, &gpio->gpbup);
51 writel(0xAAAAAAAA, &gpio->gpccon);
52 writel(0x0000FFFF, &gpio->gpcup);
53 writel(0xAAAAAAAA, &gpio->gpdcon);
54 writel(0x0000FFFF, &gpio->gpdup);
55 writel(0xAAAAAAAA, &gpio->gpecon);
56 writel(0x000037F7, &gpio->gpeup);
57 writel(0x00000000, &gpio->gpfcon);
58 writel(0x00000000, &gpio->gpfup);
59 writel(0xFFEAFF5A, &gpio->gpgcon);
60 writel(0x0000F0DC, &gpio->gpgup);
61 writel(0x0028AAAA, &gpio->gphcon);
62 writel(0x00000656, &gpio->gphup);
wdenk1fe2c702003-03-06 21:55:29 +000063
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000064 /* setup correct IRQ modes for NIC (rising edge mode) */
65 writel((readl(&gpio->extint2) & ~(7<<8)) | (4<<8), &gpio->extint2);
wdenk7539dea2003-06-19 23:01:32 +000066
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000067 /* select USB port 2 to be host or device (setup as host for now) */
68 writel(readl(&gpio->misccr) | 0x08, &gpio->misccr);
wdenk1fe2c702003-03-06 21:55:29 +000069
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000070 return 0;
71}
wdenk1fe2c702003-03-06 21:55:29 +000072
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000073int board_init(void)
74{
wdenk1fe2c702003-03-06 21:55:29 +000075 /* adress of boot parameters */
76 gd->bd->bi_boot_params = 0x30000100;
77
78 icache_enable();
79 dcache_enable();
80
81 return 0;
82}
83
wdenk7539dea2003-06-19 23:01:32 +000084/*
wdenk1fe2c702003-03-06 21:55:29 +000085 * Get some Board/PLD Info
86 */
87
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000088static u8 get_pld_reg(enum vcma9_pld_regs reg)
wdenk1fe2c702003-03-06 21:55:29 +000089{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000090 return readb(VCMA9_PLD_BASE + reg);
wdenk1fe2c702003-03-06 21:55:29 +000091}
92
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000093static u8 get_pld_version(void)
wdenk1fe2c702003-03-06 21:55:29 +000094{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000095 return (get_pld_reg(VCMA9_PLD_ID) >> 4) & 0x0F;
wdenk1fe2c702003-03-06 21:55:29 +000096}
97
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +000098static u8 get_pld_revision(void)
wdenk1fe2c702003-03-06 21:55:29 +000099{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000100 return get_pld_reg(VCMA9_PLD_ID) & 0x0F;
wdenk1fe2c702003-03-06 21:55:29 +0000101}
102
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000103static uchar get_board_pcb(void)
wdenk1fe2c702003-03-06 21:55:29 +0000104{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000105 return ((get_pld_reg(VCMA9_PLD_BOARD) >> 4) & 0x03) + 'A';
wdenk1fe2c702003-03-06 21:55:29 +0000106}
107
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000108static u8 get_nr_chips(void)
wdenk25521902003-09-13 19:01:12 +0000109{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000110 switch ((get_pld_reg(VCMA9_PLD_SDRAM) >> 4) & 0x0F) {
wdenk25521902003-09-13 19:01:12 +0000111 case 0: return 4;
112 case 1: return 1;
113 case 2: return 2;
114 default: return 0;
115 }
116}
117
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000118static ulong get_chip_size(void)
wdenk25521902003-09-13 19:01:12 +0000119{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000120 switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
wdenk25521902003-09-13 19:01:12 +0000121 case 0: return 16 * (1024*1024);
122 case 1: return 32 * (1024*1024);
123 case 2: return 8 * (1024*1024);
124 case 3: return 8 * (1024*1024);
125 default: return 0;
wdenk9c53f402003-10-15 23:53:47 +0000126 }
wdenk25521902003-09-13 19:01:12 +0000127}
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000128
129static const char *get_chip_geom(void)
wdenk25521902003-09-13 19:01:12 +0000130{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000131 switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) {
wdenk25521902003-09-13 19:01:12 +0000132 case 0: return "4Mx8x4";
133 case 1: return "8Mx8x4";
134 case 2: return "2Mx8x4";
135 case 3: return "4Mx8x2";
136 default: return "unknown";
137 }
138}
139
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000140static void vcma9_show_info(char *board_name, char *serial)
wdenk25521902003-09-13 19:01:12 +0000141{
142 printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n",
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000143 board_name, serial,
144 get_board_pcb(), get_pld_version(), get_pld_revision());
145 printf("SDRAM: %d chips %s\n", get_nr_chips(), get_chip_geom());
wdenk25521902003-09-13 19:01:12 +0000146}
147
148int dram_init(void)
149{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000150 /* dram_init must store complete ramsize in gd->ram_size */
151 gd->ram_size = get_chip_size() * get_nr_chips();
wdenk25521902003-09-13 19:01:12 +0000152 return 0;
153}
154
wdenk1fe2c702003-03-06 21:55:29 +0000155/*
156 * Check Board Identity:
157 */
158
159int checkboard(void)
160{
Wolfgang Denk585f0882007-10-13 23:51:14 +0200161 char s[50];
wdenk1fe2c702003-03-06 21:55:29 +0000162 int i;
163 backup_t *b = (backup_t *) s;
164
Wolfgang Denk76af2782010-07-24 21:55:43 +0200165 i = getenv_f("serial#", s, 32);
wdenk1fe2c702003-03-06 21:55:29 +0000166 if ((i < 0) || strncmp (s, "VCMA9", 5)) {
167 get_backup_values (b);
168 if (strncmp (b->signature, "MPL\0", 4) != 0) {
169 puts ("### No HW ID - assuming VCMA9");
170 } else {
171 b->serial_name[5] = 0;
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000172 vcma9_show_info(b->serial_name, &b->serial_name[6]);
wdenk1fe2c702003-03-06 21:55:29 +0000173 }
174 } else {
175 s[5] = 0;
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000176 vcma9_show_info(s, &s[6]);
wdenk1fe2c702003-03-06 21:55:29 +0000177 }
wdenk1fe2c702003-03-06 21:55:29 +0000178
wdenk1fe2c702003-03-06 21:55:29 +0000179 return 0;
180}
181
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000182int board_late_init(void)
wdenk1fe2c702003-03-06 21:55:29 +0000183{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000184 /*
185 * check if environment is healthy, otherwise restore values
186 * from shadow copy
187 */
188 check_env();
wdenk1fe2c702003-03-06 21:55:29 +0000189 return 0;
190}
wdenk1fe2c702003-03-06 21:55:29 +0000191
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000192void vcma9_print_info(void)
wdenk9c53f402003-10-15 23:53:47 +0000193{
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000194 char *s = getenv("serial#");
wdenk9c53f402003-10-15 23:53:47 +0000195
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000196 if (!s) {
wdenk25521902003-09-13 19:01:12 +0000197 puts ("### No HW ID - assuming VCMA9");
wdenk25521902003-09-13 19:01:12 +0000198 } else {
199 s[5] = 0;
David Müller (ELSOFT AG)d3a4d252011-05-01 21:52:51 +0000200 vcma9_show_info(s, &s[6]);
wdenk25521902003-09-13 19:01:12 +0000201 }
wdenk1fe2c702003-03-06 21:55:29 +0000202}
Ben Warren3bf5d832009-08-25 13:09:37 -0700203
204#ifdef CONFIG_CMD_NET
205int board_eth_init(bd_t *bis)
206{
207 int rc = 0;
208#ifdef CONFIG_CS8900
209 rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
210#endif
211 return rc;
212}
213#endif
David Müller (ELSOFT AG)7fbcd3b2011-05-01 21:52:50 +0000214
215/*
216 * Hardcoded flash setup:
217 * Flash 0 is a non-CFI AMD AM29F400BB flash.
218 */
219ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
220{
221 info->portwidth = FLASH_CFI_16BIT;
222 info->chipwidth = FLASH_CFI_BY16;
223 info->interface = FLASH_CFI_X16;
224 return 1;
225}