blob: da69e754f93ce81f6e065ad36a611373a909ff06 [file] [log] [blame]
Hans-Christian Egtvedtd4b48b82008-08-06 14:42:13 +02001/*
2 * Copyright (C) 2008 Atmel Corporation
3 *
4 * See file CREDITS for list of people who contributed to this project.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <common.h>
21
22#include <asm/io.h>
23#include <asm/sdram.h>
24#include <asm/arch/clk.h>
25#include <asm/arch/gpio.h>
26#include <asm/arch/hmatrix.h>
27
28DECLARE_GLOBAL_DATA_PTR;
29
30static const struct sdram_config sdram_config = {
31 /* MT48LC4M32B2P-6 (16 MB) */
32 .data_bits = SDRAM_DATA_32BIT,
33 .row_bits = 12,
34 .col_bits = 8,
35 .bank_bits = 2,
36 .cas = 3,
37 .twr = 2,
38 .trc = 7,
39 .trp = 2,
40 .trcd = 2,
41 .tras = 5,
42 .txsr = 5,
43 /* 15.6 us */
44 .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
45};
46
47int board_early_init_f(void)
48{
49 /* Enable SDRAM in the EBI mux */
50 hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
51
52 gpio_enable_ebi();
53 gpio_enable_usart3();
54#if defined(CONFIG_MACB)
55 gpio_enable_macb0();
56#endif
57#if defined(CONFIG_MMC)
58 gpio_enable_mmci();
59#endif
60
61 return 0;
62}
63
64phys_size_t initdram(int board_type)
65{
66 unsigned long expected_size;
67 unsigned long actual_size;
68 void *sdram_base;
69
70 sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
71
72 expected_size = sdram_init(sdram_base, &sdram_config);
73 actual_size = get_ram_size(sdram_base, expected_size);
74
75 unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
76
77 if (expected_size != actual_size)
Haavard Skinnemoen984cdba2008-08-20 09:27:37 +020078 printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
Hans-Christian Egtvedtd4b48b82008-08-06 14:42:13 +020079 actual_size >> 20, expected_size >> 20);
80
81 return actual_size;
82}
83
84void board_init_info(void)
85{
86 gd->bd->bi_phy_id[0] = 0x01;
87}
88
89#if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
90extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
91
92int board_eth_init(bd_t *bi)
93{
94 return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
95}
96#endif