1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include <common.h>
23#include <netdev.h>
24
25#include <asm/io.h>
26#include <asm/sdram.h>
27#include <asm/arch/clk.h>
28#include <asm/arch/gpio.h>
29#include <asm/arch/hmatrix.h>
30#include <asm/arch/mmu.h>
31#include <asm/arch/portmux.h>
32#include <atmel_lcdc.h>
33#include <lcd.h>
34
35#include "../../../arch/avr32/cpu/hsmc3.h"
36
37struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
38 {
39 .virt_pgno = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
40 .nr_pages = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
41 .phys = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
42 | MMU_VMR_CACHE_NONE,
43 }, {
44 .virt_pgno = EBI_SRAM_CS2_BASE >> PAGE_SHIFT,
45 .nr_pages = EBI_SRAM_CS2_SIZE >> PAGE_SHIFT,
46 .phys = (EBI_SRAM_CS2_BASE >> PAGE_SHIFT)
47 | MMU_VMR_CACHE_NONE,
48 }, {
49 .virt_pgno = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
50 .nr_pages = EBI_SDRAM_SIZE >> PAGE_SHIFT,
51 .phys = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
52 | MMU_VMR_CACHE_WRBACK,
53 },
54};
55
56#if defined(CONFIG_LCD)
57
58vidinfo_t panel_info = {
59 .vl_col = 480,
60 .vl_row = 272,
61 .vl_clk = 5000000,
62 .vl_sync = ATMEL_LCDC_INVCLK_INVERTED |
63 ATMEL_LCDC_INVLINE_INVERTED |
64 ATMEL_LCDC_INVFRAME_INVERTED,
65 .vl_bpix = LCD_COLOR16,
66 .vl_tft = 1,
67 .vl_hsync_len = 42,
68 .vl_left_margin = 1,
69 .vl_right_margin = 1,
70 .vl_vsync_len = 1,
71 .vl_upper_margin = 12,
72 .vl_lower_margin = 1,
73 .mmio = LCDC_BASE,
74};
75
76void lcd_enable(void)
77{
78}
79
80void lcd_disable(void)
81{
82}
83#endif
84
85DECLARE_GLOBAL_DATA_PTR;
86
87static const struct sdram_config sdram_config = {
88 .data_bits = SDRAM_DATA_16BIT,
89 .row_bits = 13,
90 .col_bits = 9,
91 .bank_bits = 2,
92 .cas = 3,
93 .twr = 2,
94 .trc = 6,
95 .trp = 2,
96 .trcd = 2,
97 .tras = 6,
98 .txsr = 6,
99
100 .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
101};
102
103int board_early_init_f(void)
104{
105
106 hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
107
108
109 portmux_enable_ebi(16, 26, PORTMUX_EBI_CS(2), PORTMUX_DRIVE_HIGH);
110 portmux_enable_usart1(PORTMUX_DRIVE_MIN);
111
112
113 portmux_select_gpio(PORTMUX_PORT_D, 1 << 15,
114 PORTMUX_DIR_OUTPUT | PORTMUX_INIT_HIGH);
115
116
117
118 portmux_select_gpio(PORTMUX_PORT_E, (1 << 19) | (1 << 20) | (1 << 23),
119 PORTMUX_DIR_INPUT);
120
121 portmux_select_gpio(PORTMUX_PORT_B, (1 << 19) | (1 << 29),
122 PORTMUX_DIR_INPUT);
123
124 portmux_select_gpio(PORTMUX_PORT_E, 1 << 21,
125 PORTMUX_DIR_INPUT | PORTMUX_PULL_UP);
126
127
128 if (gpio_get_value(GPIO_PIN_PE(21)) == 1)
129 gd->flags |= (GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE);
130
131
132 portmux_select_gpio(PORTMUX_PORT_E, 1 << 24, PORTMUX_DIR_INPUT);
133 portmux_select_gpio(PORTMUX_PORT_C, 1 << 18,
134 PORTMUX_DIR_OUTPUT | PORTMUX_INIT_HIGH);
135
136 udelay(5000);
137
138
139 gpio_set_value(GPIO_PIN_PC(18), 0);
140
141
142 hsmc3_writel(MODE2, 0x20121003);
143 hsmc3_writel(CYCLE2, 0x000a0009);
144 hsmc3_writel(PULSE2, 0x0a060806);
145 hsmc3_writel(SETUP2, 0x00030102);
146
147
148 hsmc3_writel(MODE3, 0x10120001);
149 hsmc3_writel(CYCLE3, 0x001e001d);
150 hsmc3_writel(PULSE3, 0x08040704);
151 hsmc3_writel(SETUP3, 0x02050204);
152
153#if defined(CONFIG_MACB)
154
155 portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
156 portmux_enable_macb1(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
157#endif
158
159#if defined(CONFIG_MMC)
160 portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
161#endif
162
163#if defined(CONFIG_LCD)
164 portmux_enable_lcdc(1);
165#endif
166
167 return 0;
168}
169
170phys_size_t initdram(int board_type)
171{
172 unsigned long expected_size;
173 unsigned long actual_size;
174 void *sdram_base;
175
176 sdram_base = uncached(EBI_SDRAM_BASE);
177
178 expected_size = sdram_init(sdram_base, &sdram_config);
179 actual_size = get_ram_size(sdram_base, expected_size);
180
181 if (expected_size != actual_size)
182 printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
183 actual_size >> 20, expected_size >> 20);
184
185 return actual_size;
186}
187
188int board_early_init_r(void)
189{
190 gd->bd->bi_phy_id[0] = 0x01;
191 gd->bd->bi_phy_id[1] = 0x03;
192 return 0;
193}
194
195int board_postclk_init(void)
196{
197
198 gclk_enable_output(0, PORTMUX_DRIVE_LOW);
199 gclk_set_rate(0, GCLK_PARENT_OSC0, 10000000);
200 return 0;
201}
202
203
204#ifdef CONFIG_ATMEL_SPI
205#include <spi.h>
206
207int spi_cs_is_valid(unsigned int bus, unsigned int cs)
208{
209 return (bus == 0) && (cs == 0);
210}
211
212void spi_cs_activate(struct spi_slave *slave)
213{
214}
215
216void spi_cs_deactivate(struct spi_slave *slave)
217{
218}
219#endif
220
221#ifdef CONFIG_CMD_NET
222int board_eth_init(bd_t *bi)
223{
224 macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0, bi->bi_phy_id[0]);
225 macb_eth_initialize(1, (void *)ATMEL_BASE_MACB1, bi->bi_phy_id[1]);
226
227 return 0;
228}
229#endif
230