Commit | Line | Data |
---|---|---|
022cbd73 | 1 | /* |
d0760b3b | 2 | * linux/arch/arm/mach-at91/board-sam9261ek.c |
022cbd73 AV |
3 | * |
4 | * Copyright (C) 2005 SAN People | |
5 | * Copyright (C) 2006 Atmel | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 | */ | |
21 | ||
22 | #include <linux/types.h> | |
23 | #include <linux/init.h> | |
24 | #include <linux/mm.h> | |
25 | #include <linux/module.h> | |
26 | #include <linux/platform_device.h> | |
27 | #include <linux/spi/spi.h> | |
23522728 | 28 | #include <linux/spi/ads7846.h> |
022cbd73 | 29 | #include <linux/dm9000.h> |
cdf95c73 | 30 | #include <linux/fb.h> |
d0f9b55e AV |
31 | #include <linux/gpio_keys.h> |
32 | #include <linux/input.h> | |
cdf95c73 AV |
33 | |
34 | #include <video/atmel_lcdc.h> | |
022cbd73 AV |
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> | |
b78eabde | 47 | #include <asm/arch/at91sam9_smc.h> |
022cbd73 AV |
48 | |
49 | #include "generic.h" | |
50 | ||
51 | ||
022cbd73 AV |
52 | static void __init ek_map_io(void) |
53 | { | |
54 | /* Initialize processor: 18.432 MHz crystal */ | |
55 | at91sam9261_initialize(18432000); | |
56 | ||
302c0ef7 AV |
57 | /* Setup the LEDs */ |
58 | at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14); | |
59 | ||
a3da1222 AV |
60 | /* DGBU on ttyS0. (Rx & Tx only) */ |
61 | at91_register_uart(0, 0, 0); | |
62 | ||
63 | /* set serial console to ttyS0 (ie, DBGU) */ | |
64 | at91_set_serial_console(0); | |
022cbd73 AV |
65 | } |
66 | ||
67 | static void __init ek_init_irq(void) | |
68 | { | |
69 | at91sam9261_init_interrupts(NULL); | |
70 | } | |
71 | ||
72 | ||
73 | /* | |
74 | * DM9000 ethernet device | |
75 | */ | |
76 | #if defined(CONFIG_DM9000) | |
77 | static struct resource at91sam9261_dm9000_resource[] = { | |
78 | [0] = { | |
79 | .start = AT91_CHIPSELECT_2, | |
80 | .end = AT91_CHIPSELECT_2 + 3, | |
81 | .flags = IORESOURCE_MEM | |
82 | }, | |
83 | [1] = { | |
84 | .start = AT91_CHIPSELECT_2 + 0x44, | |
85 | .end = AT91_CHIPSELECT_2 + 0xFF, | |
86 | .flags = IORESOURCE_MEM | |
87 | }, | |
88 | [2] = { | |
89 | .start = AT91_PIN_PC11, | |
90 | .end = AT91_PIN_PC11, | |
91 | .flags = IORESOURCE_IRQ | |
92 | } | |
93 | }; | |
94 | ||
95 | static struct dm9000_plat_data dm9000_platdata = { | |
96 | .flags = DM9000_PLATF_16BITONLY, | |
97 | }; | |
98 | ||
99 | static struct platform_device at91sam9261_dm9000_device = { | |
100 | .name = "dm9000", | |
101 | .id = 0, | |
102 | .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource), | |
103 | .resource = at91sam9261_dm9000_resource, | |
104 | .dev = { | |
105 | .platform_data = &dm9000_platdata, | |
106 | } | |
107 | }; | |
108 | ||
109 | static void __init ek_add_device_dm9000(void) | |
110 | { | |
111 | /* | |
112 | * Configure Chip-Select 2 on SMC for the DM9000. | |
113 | * Note: These timings were calculated for MASTER_CLOCK = 100000000 | |
114 | * according to the DM9000 timings. | |
115 | */ | |
116 | at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0)); | |
117 | at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8)); | |
118 | at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16)); | |
119 | at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1)); | |
120 | ||
121 | /* Configure Reset signal as output */ | |
122 | at91_set_gpio_output(AT91_PIN_PC10, 0); | |
123 | ||
124 | /* Configure Interrupt pin as input, no pull-up */ | |
125 | at91_set_gpio_input(AT91_PIN_PC11, 0); | |
126 | ||
127 | platform_device_register(&at91sam9261_dm9000_device); | |
128 | } | |
129 | #else | |
130 | static void __init ek_add_device_dm9000(void) {} | |
131 | #endif /* CONFIG_DM9000 */ | |
132 | ||
133 | ||
134 | /* | |
135 | * USB Host Port | |
136 | */ | |
137 | static struct at91_usbh_data __initdata ek_usbh_data = { | |
138 | .ports = 2, | |
139 | }; | |
140 | ||
141 | ||
142 | /* | |
143 | * USB Device Port | |
144 | */ | |
145 | static struct at91_udc_data __initdata ek_udc_data = { | |
146 | .vbus_pin = AT91_PIN_PB29, | |
147 | .pullup_pin = 0, /* pull-up driven by UDC */ | |
148 | }; | |
149 | ||
150 | ||
151 | /* | |
152 | * MCI (SD/MMC) | |
153 | */ | |
154 | static struct at91_mmc_data __initdata ek_mmc_data = { | |
155 | .wire4 = 1, | |
156 | // .det_pin = ... not connected | |
157 | // .wp_pin = ... not connected | |
158 | // .vcc_pin = ... not connected | |
159 | }; | |
160 | ||
161 | ||
162 | /* | |
163 | * NAND flash | |
164 | */ | |
165 | static struct mtd_partition __initdata ek_nand_partition[] = { | |
166 | { | |
167 | .name = "Partition 1", | |
168 | .offset = 0, | |
169 | .size = 256 * 1024, | |
170 | }, | |
171 | { | |
172 | .name = "Partition 2", | |
173 | .offset = 256 * 1024 , | |
174 | .size = MTDPART_SIZ_FULL, | |
175 | }, | |
176 | }; | |
177 | ||
cdea4606 | 178 | static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) |
022cbd73 AV |
179 | { |
180 | *num_partitions = ARRAY_SIZE(ek_nand_partition); | |
181 | return ek_nand_partition; | |
182 | } | |
183 | ||
184 | static struct at91_nand_data __initdata ek_nand_data = { | |
185 | .ale = 22, | |
186 | .cle = 21, | |
187 | // .det_pin = ... not connected | |
188 | .rdy_pin = AT91_PIN_PC15, | |
189 | .enable_pin = AT91_PIN_PC14, | |
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 | ||
23522728 AV |
198 | /* |
199 | * ADS7846 Touchscreen | |
200 | */ | |
201 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | |
202 | ||
203 | static int ads7843_pendown_state(void) | |
204 | { | |
205 | return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */ | |
206 | } | |
207 | ||
208 | static struct ads7846_platform_data ads_info = { | |
209 | .model = 7843, | |
210 | .x_min = 150, | |
211 | .x_max = 3830, | |
212 | .y_min = 190, | |
213 | .y_max = 3830, | |
214 | .vref_delay_usecs = 100, | |
215 | .x_plate_ohms = 450, | |
216 | .y_plate_ohms = 250, | |
217 | .pressure_max = 15000, | |
218 | .debounce_max = 1, | |
219 | .debounce_rep = 0, | |
220 | .debounce_tol = (~0), | |
221 | .get_pendown_state = ads7843_pendown_state, | |
222 | }; | |
223 | ||
224 | static void __init ek_add_device_ts(void) | |
225 | { | |
226 | at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */ | |
227 | at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */ | |
228 | } | |
229 | #else | |
230 | static void __init ek_add_device_ts(void) {} | |
231 | #endif | |
232 | ||
022cbd73 AV |
233 | /* |
234 | * SPI devices | |
235 | */ | |
236 | static struct spi_board_info ek_spi_devices[] = { | |
237 | { /* DataFlash chip */ | |
238 | .modalias = "mtd_dataflash", | |
239 | .chip_select = 0, | |
240 | .max_speed_hz = 15 * 1000 * 1000, | |
241 | .bus_num = 0, | |
242 | }, | |
23522728 AV |
243 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) |
244 | { | |
245 | .modalias = "ads7846", | |
246 | .chip_select = 2, | |
247 | .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ | |
248 | .bus_num = 0, | |
249 | .platform_data = &ads_info, | |
250 | .irq = AT91SAM9261_ID_IRQ0, | |
251 | }, | |
252 | #endif | |
022cbd73 AV |
253 | #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) |
254 | { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */ | |
255 | .modalias = "mtd_dataflash", | |
256 | .chip_select = 3, | |
257 | .max_speed_hz = 15 * 1000 * 1000, | |
258 | .bus_num = 0, | |
259 | }, | |
23522728 | 260 | #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE) |
022cbd73 | 261 | { /* AT73C213 DAC */ |
23522728 | 262 | .modalias = "at73c213", |
022cbd73 AV |
263 | .chip_select = 3, |
264 | .max_speed_hz = 10 * 1000 * 1000, | |
265 | .bus_num = 0, | |
266 | }, | |
267 | #endif | |
268 | }; | |
269 | ||
270 | ||
cdf95c73 AV |
271 | /* |
272 | * LCD Controller | |
273 | */ | |
274 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) | |
51708748 AV |
275 | |
276 | #if defined(CONFIG_FB_ATMEL_STN) | |
277 | ||
278 | /* STN */ | |
279 | static struct fb_videomode at91_stn_modes[] = { | |
280 | { | |
281 | .name = "SP06Q002 @ 75", | |
282 | .refresh = 75, | |
283 | .xres = 320, .yres = 240, | |
284 | .pixclock = KHZ2PICOS(1440), | |
285 | ||
286 | .left_margin = 1, .right_margin = 1, | |
287 | .upper_margin = 0, .lower_margin = 0, | |
288 | .hsync_len = 1, .vsync_len = 1, | |
289 | ||
290 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
291 | .vmode = FB_VMODE_NONINTERLACED, | |
292 | }, | |
293 | }; | |
294 | ||
295 | static struct fb_monspecs at91fb_default_stn_monspecs = { | |
296 | .manufacturer = "HIT", | |
297 | .monitor = "SP06Q002", | |
298 | ||
299 | .modedb = at91_stn_modes, | |
300 | .modedb_len = ARRAY_SIZE(at91_stn_modes), | |
301 | .hfmin = 15000, | |
302 | .hfmax = 64000, | |
303 | .vfmin = 50, | |
304 | .vfmax = 150, | |
305 | }; | |
306 | ||
307 | #define AT91SAM9261_DEFAULT_STN_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ | |
308 | | ATMEL_LCDC_DISTYPE_STNMONO \ | |
309 | | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE \ | |
310 | | ATMEL_LCDC_IFWIDTH_4 \ | |
311 | | ATMEL_LCDC_SCANMOD_SINGLE) | |
312 | ||
313 | static void at91_lcdc_stn_power_control(int on) | |
314 | { | |
315 | /* backlight */ | |
316 | if (on) { /* power up */ | |
317 | at91_set_gpio_value(AT91_PIN_PC14, 0); | |
318 | at91_set_gpio_value(AT91_PIN_PC15, 0); | |
319 | } else { /* power down */ | |
320 | at91_set_gpio_value(AT91_PIN_PC14, 1); | |
321 | at91_set_gpio_value(AT91_PIN_PC15, 1); | |
322 | } | |
323 | } | |
324 | ||
325 | static struct atmel_lcdfb_info __initdata ek_lcdc_data = { | |
326 | .default_bpp = 1, | |
327 | .default_dmacon = ATMEL_LCDC_DMAEN, | |
328 | .default_lcdcon2 = AT91SAM9261_DEFAULT_STN_LCDCON2, | |
329 | .default_monspecs = &at91fb_default_stn_monspecs, | |
330 | .atmel_lcdfb_power_control = at91_lcdc_stn_power_control, | |
331 | .guard_time = 1, | |
332 | }; | |
333 | ||
334 | #else | |
335 | ||
336 | /* TFT */ | |
cdf95c73 AV |
337 | static struct fb_videomode at91_tft_vga_modes[] = { |
338 | { | |
339 | .name = "TX09D50VM1CCA @ 60", | |
340 | .refresh = 60, | |
341 | .xres = 240, .yres = 320, | |
342 | .pixclock = KHZ2PICOS(4965), | |
343 | ||
344 | .left_margin = 1, .right_margin = 33, | |
345 | .upper_margin = 1, .lower_margin = 0, | |
346 | .hsync_len = 5, .vsync_len = 1, | |
347 | ||
348 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
349 | .vmode = FB_VMODE_NONINTERLACED, | |
350 | }, | |
351 | }; | |
352 | ||
51708748 | 353 | static struct fb_monspecs at91fb_default_tft_monspecs = { |
cdf95c73 AV |
354 | .manufacturer = "HIT", |
355 | .monitor = "TX09D50VM1CCA", | |
356 | ||
357 | .modedb = at91_tft_vga_modes, | |
358 | .modedb_len = ARRAY_SIZE(at91_tft_vga_modes), | |
359 | .hfmin = 15000, | |
360 | .hfmax = 64000, | |
361 | .vfmin = 50, | |
362 | .vfmax = 150, | |
363 | }; | |
364 | ||
51708748 | 365 | #define AT91SAM9261_DEFAULT_TFT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ |
cdf95c73 AV |
366 | | ATMEL_LCDC_DISTYPE_TFT \ |
367 | | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) | |
368 | ||
51708748 | 369 | static void at91_lcdc_tft_power_control(int on) |
cdf95c73 AV |
370 | { |
371 | if (on) | |
372 | at91_set_gpio_value(AT91_PIN_PA12, 0); /* power up */ | |
373 | else | |
374 | at91_set_gpio_value(AT91_PIN_PA12, 1); /* power down */ | |
375 | } | |
376 | ||
cdf95c73 | 377 | static struct atmel_lcdfb_info __initdata ek_lcdc_data = { |
a9a84c37 | 378 | .lcdcon_is_backlight = true, |
cdf95c73 AV |
379 | .default_bpp = 16, |
380 | .default_dmacon = ATMEL_LCDC_DMAEN, | |
51708748 AV |
381 | .default_lcdcon2 = AT91SAM9261_DEFAULT_TFT_LCDCON2, |
382 | .default_monspecs = &at91fb_default_tft_monspecs, | |
383 | .atmel_lcdfb_power_control = at91_lcdc_tft_power_control, | |
cdf95c73 AV |
384 | .guard_time = 1, |
385 | }; | |
51708748 | 386 | #endif |
cdf95c73 AV |
387 | |
388 | #else | |
389 | static struct atmel_lcdfb_info __initdata ek_lcdc_data; | |
390 | #endif | |
391 | ||
392 | ||
d0f9b55e AV |
393 | /* |
394 | * GPIO Buttons | |
395 | */ | |
396 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
397 | static struct gpio_keys_button ek_buttons[] = { | |
398 | { | |
399 | .gpio = AT91_PIN_PA27, | |
eaf858a9 | 400 | .code = BTN_0, |
d0f9b55e AV |
401 | .desc = "Button 0", |
402 | .active_low = 1, | |
403 | }, | |
404 | { | |
405 | .gpio = AT91_PIN_PA26, | |
eaf858a9 | 406 | .code = BTN_1, |
d0f9b55e AV |
407 | .desc = "Button 1", |
408 | .active_low = 1, | |
409 | }, | |
410 | { | |
411 | .gpio = AT91_PIN_PA25, | |
eaf858a9 | 412 | .code = BTN_2, |
d0f9b55e AV |
413 | .desc = "Button 2", |
414 | .active_low = 1, | |
415 | }, | |
416 | { | |
417 | .gpio = AT91_PIN_PA24, | |
eaf858a9 | 418 | .code = BTN_3, |
d0f9b55e AV |
419 | .desc = "Button 3", |
420 | .active_low = 1, | |
421 | } | |
422 | }; | |
423 | ||
424 | static struct gpio_keys_platform_data ek_button_data = { | |
425 | .buttons = ek_buttons, | |
426 | .nbuttons = ARRAY_SIZE(ek_buttons), | |
427 | }; | |
428 | ||
429 | static struct platform_device ek_button_device = { | |
430 | .name = "gpio-keys", | |
431 | .id = -1, | |
432 | .num_resources = 0, | |
433 | .dev = { | |
434 | .platform_data = &ek_button_data, | |
435 | } | |
436 | }; | |
437 | ||
438 | static void __init ek_add_device_buttons(void) | |
439 | { | |
302edfd0 AV |
440 | at91_set_gpio_input(AT91_PIN_PA27, 0); /* btn0 */ |
441 | at91_set_deglitch(AT91_PIN_PA27, 1); | |
442 | at91_set_gpio_input(AT91_PIN_PA26, 0); /* btn1 */ | |
443 | at91_set_deglitch(AT91_PIN_PA26, 1); | |
444 | at91_set_gpio_input(AT91_PIN_PA25, 0); /* btn2 */ | |
445 | at91_set_deglitch(AT91_PIN_PA25, 1); | |
446 | at91_set_gpio_input(AT91_PIN_PA24, 0); /* btn3 */ | |
447 | at91_set_deglitch(AT91_PIN_PA24, 1); | |
d0f9b55e AV |
448 | |
449 | platform_device_register(&ek_button_device); | |
450 | } | |
451 | #else | |
452 | static void __init ek_add_device_buttons(void) {} | |
453 | #endif | |
454 | ||
022cbd73 AV |
455 | static void __init ek_board_init(void) |
456 | { | |
457 | /* Serial */ | |
458 | at91_add_device_serial(); | |
459 | /* USB Host */ | |
460 | at91_add_device_usbh(&ek_usbh_data); | |
461 | /* USB Device */ | |
462 | at91_add_device_udc(&ek_udc_data); | |
463 | /* I2C */ | |
f230d3f5 | 464 | at91_add_device_i2c(NULL, 0); |
022cbd73 AV |
465 | /* NAND */ |
466 | at91_add_device_nand(&ek_nand_data); | |
467 | /* DM9000 ethernet */ | |
468 | ek_add_device_dm9000(); | |
469 | ||
470 | /* spi0 and mmc/sd share the same PIO pins */ | |
471 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) | |
472 | /* SPI */ | |
473 | at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); | |
23522728 AV |
474 | /* Touchscreen */ |
475 | ek_add_device_ts(); | |
022cbd73 AV |
476 | #else |
477 | /* MMC */ | |
d0760b3b | 478 | at91_add_device_mmc(0, &ek_mmc_data); |
022cbd73 | 479 | #endif |
cdf95c73 AV |
480 | /* LCD Controller */ |
481 | at91_add_device_lcdc(&ek_lcdc_data); | |
d0f9b55e AV |
482 | /* Push Buttons */ |
483 | ek_add_device_buttons(); | |
022cbd73 AV |
484 | } |
485 | ||
486 | MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK") | |
487 | /* Maintainer: Atmel */ | |
488 | .phys_io = AT91_BASE_SYS, | |
489 | .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc, | |
490 | .boot_params = AT91_SDRAM_BASE + 0x100, | |
491 | .timer = &at91sam926x_timer, | |
492 | .map_io = ek_map_io, | |
493 | .init_irq = ek_init_irq, | |
494 | .init_machine = ek_board_init, | |
495 | MACHINE_END |