]>
Commit | Line | Data |
---|---|---|
86640cae AV |
1 | /* |
2 | * linux/arch/arm/mach-at91/board-cap9adk.c | |
3 | * | |
4 | * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> | |
5 | * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> | |
6 | * Copyright (C) 2005 SAN People | |
7 | * Copyright (C) 2007 Atmel Corporation. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | */ | |
23 | ||
24 | #include <linux/types.h> | |
25 | #include <linux/init.h> | |
26 | #include <linux/mm.h> | |
27 | #include <linux/module.h> | |
28 | #include <linux/platform_device.h> | |
29 | #include <linux/spi/spi.h> | |
30 | #include <linux/spi/ads7846.h> | |
31 | #include <linux/fb.h> | |
32 | #include <linux/mtd/physmap.h> | |
33 | ||
34 | #include <video/atmel_lcdc.h> | |
35 | ||
36 | #include <asm/hardware.h> | |
37 | #include <asm/setup.h> | |
38 | #include <asm/mach-types.h> | |
39 | #include <asm/irq.h> | |
40 | ||
41 | #include <asm/mach/arch.h> | |
42 | #include <asm/mach/map.h> | |
43 | #include <asm/mach/irq.h> | |
44 | ||
45 | #include <asm/arch/board.h> | |
46 | #include <asm/arch/gpio.h> | |
47 | #include <asm/arch/at91cap9_matrix.h> | |
b78eabde | 48 | #include <asm/arch/at91sam9_smc.h> |
86640cae AV |
49 | |
50 | #include "generic.h" | |
51 | ||
52 | ||
53 | static void __init cap9adk_map_io(void) | |
54 | { | |
55 | /* Initialize processor: 12 MHz crystal */ | |
56 | at91cap9_initialize(12000000); | |
57 | ||
58 | /* Setup the LEDs: USER1 and USER2 LED for cpu/timer... */ | |
59 | at91_init_leds(AT91_PIN_PA10, AT91_PIN_PA11); | |
60 | /* ... POWER LED always on */ | |
61 | at91_set_gpio_output(AT91_PIN_PC29, 1); | |
62 | ||
63 | /* Setup the serial ports and console */ | |
64 | at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */ | |
65 | at91_set_serial_console(0); | |
66 | } | |
67 | ||
68 | static void __init cap9adk_init_irq(void) | |
69 | { | |
70 | at91cap9_init_interrupts(NULL); | |
71 | } | |
72 | ||
73 | ||
74 | /* | |
75 | * USB Host port | |
76 | */ | |
77 | static struct at91_usbh_data __initdata cap9adk_usbh_data = { | |
78 | .ports = 2, | |
79 | }; | |
80 | ||
7c8cf665 SP |
81 | /* |
82 | * USB HS Device port | |
83 | */ | |
84 | static struct usba_platform_data __initdata cap9adk_usba_udc_data = { | |
85 | .vbus_pin = AT91_PIN_PB31, | |
86 | }; | |
86640cae AV |
87 | |
88 | /* | |
89 | * ADS7846 Touchscreen | |
90 | */ | |
91 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | |
92 | static int ads7843_pendown_state(void) | |
93 | { | |
94 | return !at91_get_gpio_value(AT91_PIN_PC4); /* Touchscreen PENIRQ */ | |
95 | } | |
96 | ||
97 | static struct ads7846_platform_data ads_info = { | |
98 | .model = 7843, | |
99 | .x_min = 150, | |
100 | .x_max = 3830, | |
101 | .y_min = 190, | |
102 | .y_max = 3830, | |
103 | .vref_delay_usecs = 100, | |
104 | .x_plate_ohms = 450, | |
105 | .y_plate_ohms = 250, | |
106 | .pressure_max = 15000, | |
107 | .debounce_max = 1, | |
108 | .debounce_rep = 0, | |
109 | .debounce_tol = (~0), | |
110 | .get_pendown_state = ads7843_pendown_state, | |
111 | }; | |
112 | ||
113 | static void __init cap9adk_add_device_ts(void) | |
114 | { | |
115 | at91_set_gpio_input(AT91_PIN_PC4, 1); /* Touchscreen PENIRQ */ | |
116 | at91_set_gpio_input(AT91_PIN_PC5, 1); /* Touchscreen BUSY */ | |
117 | } | |
118 | #else | |
119 | static void __init cap9adk_add_device_ts(void) {} | |
120 | #endif | |
121 | ||
122 | ||
123 | /* | |
124 | * SPI devices. | |
125 | */ | |
126 | static struct spi_board_info cap9adk_spi_devices[] = { | |
127 | #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) | |
128 | { /* DataFlash card */ | |
129 | .modalias = "mtd_dataflash", | |
130 | .chip_select = 0, | |
131 | .max_speed_hz = 15 * 1000 * 1000, | |
132 | .bus_num = 0, | |
133 | }, | |
134 | #endif | |
135 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | |
136 | { | |
137 | .modalias = "ads7846", | |
138 | .chip_select = 3, /* can be 2 or 3, depending on J2 jumper */ | |
139 | .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ | |
140 | .bus_num = 0, | |
141 | .platform_data = &ads_info, | |
142 | .irq = AT91_PIN_PC4, | |
143 | }, | |
144 | #endif | |
145 | }; | |
146 | ||
147 | ||
148 | /* | |
149 | * MCI (SD/MMC) | |
150 | */ | |
151 | static struct at91_mmc_data __initdata cap9adk_mmc_data = { | |
152 | .wire4 = 1, | |
153 | // .det_pin = ... not connected | |
154 | // .wp_pin = ... not connected | |
155 | // .vcc_pin = ... not connected | |
156 | }; | |
157 | ||
158 | ||
159 | /* | |
160 | * MACB Ethernet device | |
161 | */ | |
162 | static struct at91_eth_data __initdata cap9adk_macb_data = { | |
163 | .is_rmii = 1, | |
164 | }; | |
165 | ||
166 | ||
167 | /* | |
168 | * NAND flash | |
169 | */ | |
170 | static struct mtd_partition __initdata cap9adk_nand_partitions[] = { | |
171 | { | |
172 | .name = "NAND partition", | |
173 | .offset = 0, | |
174 | .size = MTDPART_SIZ_FULL, | |
175 | }, | |
176 | }; | |
177 | ||
178 | static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) | |
179 | { | |
180 | *num_partitions = ARRAY_SIZE(cap9adk_nand_partitions); | |
181 | return cap9adk_nand_partitions; | |
182 | } | |
183 | ||
184 | static struct at91_nand_data __initdata cap9adk_nand_data = { | |
185 | .ale = 21, | |
186 | .cle = 22, | |
187 | // .det_pin = ... not connected | |
188 | // .rdy_pin = ... not connected | |
189 | .enable_pin = AT91_PIN_PD15, | |
190 | .partition_info = nand_partitions, | |
191 | #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16) | |
192 | .bus_width_16 = 1, | |
193 | #else | |
194 | .bus_width_16 = 0, | |
195 | #endif | |
196 | }; | |
197 | ||
198 | ||
199 | /* | |
200 | * NOR flash | |
201 | */ | |
202 | static struct mtd_partition cap9adk_nor_partitions[] = { | |
203 | { | |
204 | .name = "NOR partition", | |
205 | .offset = 0, | |
206 | .size = MTDPART_SIZ_FULL, | |
207 | }, | |
208 | }; | |
209 | ||
210 | static struct physmap_flash_data cap9adk_nor_data = { | |
211 | .width = 2, | |
212 | .parts = cap9adk_nor_partitions, | |
213 | .nr_parts = ARRAY_SIZE(cap9adk_nor_partitions), | |
214 | }; | |
215 | ||
216 | #define NOR_BASE AT91_CHIPSELECT_0 | |
217 | #define NOR_SIZE 0x800000 | |
218 | ||
219 | static struct resource nor_flash_resources[] = { | |
220 | { | |
221 | .start = NOR_BASE, | |
222 | .end = NOR_BASE + NOR_SIZE - 1, | |
223 | .flags = IORESOURCE_MEM, | |
224 | } | |
225 | }; | |
226 | ||
227 | static struct platform_device cap9adk_nor_flash = { | |
228 | .name = "physmap-flash", | |
229 | .id = 0, | |
230 | .dev = { | |
231 | .platform_data = &cap9adk_nor_data, | |
232 | }, | |
233 | .resource = nor_flash_resources, | |
234 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
235 | }; | |
236 | ||
237 | static __init void cap9adk_add_device_nor(void) | |
238 | { | |
239 | unsigned long csa; | |
240 | ||
241 | csa = at91_sys_read(AT91_MATRIX_EBICSA); | |
242 | at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V); | |
243 | ||
244 | /* set the bus interface characteristics */ | |
245 | at91_sys_write(AT91_SMC_SETUP(0), AT91_SMC_NWESETUP_(4) | AT91_SMC_NCS_WRSETUP_(2) | |
246 | | AT91_SMC_NRDSETUP_(4) | AT91_SMC_NCS_RDSETUP_(2)); | |
247 | ||
248 | at91_sys_write(AT91_SMC_PULSE(0), AT91_SMC_NWEPULSE_(8) | AT91_SMC_NCS_WRPULSE_(10) | |
249 | | AT91_SMC_NRDPULSE_(8) | AT91_SMC_NCS_RDPULSE_(10)); | |
250 | ||
251 | at91_sys_write(AT91_SMC_CYCLE(0), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16)); | |
252 | ||
253 | at91_sys_write(AT91_SMC_MODE(0), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | |
254 | | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | |
255 | | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1)); | |
256 | ||
257 | platform_device_register(&cap9adk_nor_flash); | |
258 | } | |
259 | ||
260 | ||
261 | /* | |
262 | * LCD Controller | |
263 | */ | |
264 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) | |
265 | static struct fb_videomode at91_tft_vga_modes[] = { | |
266 | { | |
267 | .name = "TX09D50VM1CCA @ 60", | |
268 | .refresh = 60, | |
269 | .xres = 240, .yres = 320, | |
270 | .pixclock = KHZ2PICOS(4965), | |
271 | ||
272 | .left_margin = 1, .right_margin = 33, | |
273 | .upper_margin = 1, .lower_margin = 0, | |
274 | .hsync_len = 5, .vsync_len = 1, | |
275 | ||
276 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
277 | .vmode = FB_VMODE_NONINTERLACED, | |
278 | }, | |
279 | }; | |
280 | ||
281 | static struct fb_monspecs at91fb_default_monspecs = { | |
282 | .manufacturer = "HIT", | |
283 | .monitor = "TX09D70VM1CCA", | |
284 | ||
285 | .modedb = at91_tft_vga_modes, | |
286 | .modedb_len = ARRAY_SIZE(at91_tft_vga_modes), | |
287 | .hfmin = 15000, | |
288 | .hfmax = 64000, | |
289 | .vfmin = 50, | |
290 | .vfmax = 150, | |
291 | }; | |
292 | ||
293 | #define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ | |
294 | | ATMEL_LCDC_DISTYPE_TFT \ | |
295 | | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) | |
296 | ||
297 | static void at91_lcdc_power_control(int on) | |
298 | { | |
299 | if (on) | |
300 | at91_set_gpio_value(AT91_PIN_PC0, 0); /* power up */ | |
301 | else | |
302 | at91_set_gpio_value(AT91_PIN_PC0, 1); /* power down */ | |
303 | } | |
304 | ||
305 | /* Driver datas */ | |
306 | static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = { | |
307 | .default_bpp = 16, | |
308 | .default_dmacon = ATMEL_LCDC_DMAEN, | |
309 | .default_lcdcon2 = AT91CAP9_DEFAULT_LCDCON2, | |
310 | .default_monspecs = &at91fb_default_monspecs, | |
311 | .atmel_lcdfb_power_control = at91_lcdc_power_control, | |
312 | .guard_time = 1, | |
313 | }; | |
314 | ||
315 | #else | |
316 | static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data; | |
317 | #endif | |
318 | ||
319 | ||
320 | /* | |
321 | * AC97 | |
322 | */ | |
323 | static struct atmel_ac97_data cap9adk_ac97_data = { | |
324 | // .reset_pin = ... not connected | |
325 | }; | |
326 | ||
327 | ||
328 | static void __init cap9adk_board_init(void) | |
329 | { | |
330 | /* Serial */ | |
331 | at91_add_device_serial(); | |
332 | /* USB Host */ | |
6cab4860 | 333 | set_irq_type(AT91CAP9_ID_UHP, IRQ_TYPE_LEVEL_HIGH); |
86640cae | 334 | at91_add_device_usbh(&cap9adk_usbh_data); |
7c8cf665 | 335 | /* USB HS */ |
6cab4860 | 336 | set_irq_type(AT91CAP9_ID_UDPHS, IRQ_TYPE_LEVEL_HIGH); |
7c8cf665 | 337 | at91_add_device_usba(&cap9adk_usba_udc_data); |
86640cae AV |
338 | /* SPI */ |
339 | at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices)); | |
340 | /* Touchscreen */ | |
341 | cap9adk_add_device_ts(); | |
342 | /* MMC */ | |
343 | at91_add_device_mmc(1, &cap9adk_mmc_data); | |
344 | /* Ethernet */ | |
345 | at91_add_device_eth(&cap9adk_macb_data); | |
346 | /* NAND */ | |
347 | at91_add_device_nand(&cap9adk_nand_data); | |
348 | /* NOR Flash */ | |
349 | cap9adk_add_device_nor(); | |
350 | /* I2C */ | |
351 | at91_add_device_i2c(NULL, 0); | |
352 | /* LCD Controller */ | |
6cab4860 | 353 | set_irq_type(AT91CAP9_ID_LCDC, IRQ_TYPE_LEVEL_HIGH); |
86640cae AV |
354 | at91_add_device_lcdc(&cap9adk_lcdc_data); |
355 | /* AC97 */ | |
356 | at91_add_device_ac97(&cap9adk_ac97_data); | |
357 | } | |
358 | ||
359 | MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK") | |
360 | /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */ | |
361 | .phys_io = AT91_BASE_SYS, | |
362 | .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc, | |
363 | .boot_params = AT91_SDRAM_BASE + 0x100, | |
364 | .timer = &at91sam926x_timer, | |
365 | .map_io = cap9adk_map_io, | |
366 | .init_irq = cap9adk_init_irq, | |
367 | .init_machine = cap9adk_board_init, | |
368 | MACHINE_END |