2 * Copyright (C) 2008 Atmel Corporation
4 * See file CREDITS for list of people who contributed to this project.
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)
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
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
24 #include <asm/sdram.h>
25 #include <asm/arch/clk.h>
26 #include <asm/arch/hmatrix.h>
27 #include <asm/arch/mmu.h>
28 #include <asm/arch/portmux.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
34 .virt_pgno = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
35 .nr_pages = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
36 .phys = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
39 .virt_pgno = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
40 .nr_pages = EBI_SDRAM_SIZE >> PAGE_SHIFT,
41 .phys = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
42 | MMU_VMR_CACHE_WRBACK,
46 static const struct sdram_config sdram_config = {
47 /* MT48LC4M32B2P-6 (16 MB) */
48 .data_bits = SDRAM_DATA_32BIT,
60 .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
63 int board_early_init_f(void)
65 /* Enable SDRAM in the EBI mux */
66 hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
68 portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH);
69 portmux_enable_usart3(PORTMUX_DRIVE_MIN);
70 #if defined(CONFIG_MACB)
71 portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
73 #if defined(CONFIG_MMC)
74 portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
80 phys_size_t initdram(int board_type)
82 unsigned long expected_size;
83 unsigned long actual_size;
86 sdram_base = uncached(EBI_SDRAM_BASE);
88 expected_size = sdram_init(sdram_base, &sdram_config);
89 actual_size = get_ram_size(sdram_base, expected_size);
91 if (expected_size != actual_size)
92 printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
93 actual_size >> 20, expected_size >> 20);
98 int board_early_init_r(void)
100 gd->bd->bi_phy_id[0] = 0x01;
104 #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
105 int board_eth_init(bd_t *bi)
107 return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);