]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/earthlcd/favr-32-ezkit/favr-32-ezkit.c
avr32: Add simple paging support
[karo-tx-uboot.git] / board / earthlcd / favr-32-ezkit / favr-32-ezkit.c
1 /*
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 #include <netdev.h>
22
23 #include <asm/io.h>
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>
29
30 DECLARE_GLOBAL_DATA_PTR;
31
32 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
33         {
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)
37                                         | MMU_VMR_CACHE_NONE,
38         }, {
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,
43         },
44 };
45
46 static const struct sdram_config sdram_config = {
47         /* MT48LC4M32B2P-6 (16 MB) */
48         .data_bits      = SDRAM_DATA_32BIT,
49         .row_bits       = 12,
50         .col_bits       = 8,
51         .bank_bits      = 2,
52         .cas            = 3,
53         .twr            = 2,
54         .trc            = 7,
55         .trp            = 2,
56         .trcd           = 2,
57         .tras           = 5,
58         .txsr           = 5,
59         /* 15.6 us */
60         .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
61 };
62
63 int board_early_init_f(void)
64 {
65         /* Enable SDRAM in the EBI mux */
66         hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
67
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);
72 #endif
73 #if defined(CONFIG_MMC)
74         portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
75 #endif
76
77         return 0;
78 }
79
80 phys_size_t initdram(int board_type)
81 {
82         unsigned long expected_size;
83         unsigned long actual_size;
84         void *sdram_base;
85
86         sdram_base = uncached(EBI_SDRAM_BASE);
87
88         expected_size = sdram_init(sdram_base, &sdram_config);
89         actual_size = get_ram_size(sdram_base, expected_size);
90
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);
94
95         return actual_size;
96 }
97
98 int board_early_init_r(void)
99 {
100         gd->bd->bi_phy_id[0] = 0x01;
101         return 0;
102 }
103
104 #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
105 int board_eth_init(bd_t *bi)
106 {
107         return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
108 }
109 #endif