1 /*
2 * linux/arch/arm/mach-at91/board-neocore926.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation
6 * Copyright (C) 2008 ADENEO.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include <linux/types.h>
24 #include <linux/init.h>
25 #include <linux/mm.h>
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28 #include <linux/spi/spi.h>
29 #include <linux/spi/ads7846.h>
30 #include <linux/fb.h>
31 #include <linux/gpio_keys.h>
32 #include <linux/input.h>
33
34 #include <video/atmel_lcdc.h>
35
36 #include <asm/setup.h>
37 #include <asm/mach-types.h>
38 #include <asm/irq.h>
39 #include <asm/sizes.h>
40
41 #include <asm/mach/arch.h>
42 #include <asm/mach/map.h>
43 #include <asm/mach/irq.h>
44
45 #include <mach/hardware.h>
46 #include <mach/board.h>
47 #include <mach/gpio.h>
48 #include <mach/at91sam9_smc.h>
49
50 #include "sam9_smc.h"
51 #include "generic.h"
52
53
neocore926_map_io(void)54 static void __init neocore926_map_io(void)
55 {
56 /* Initialize processor: 20 MHz crystal */
57 at91sam9263_initialize(20000000);
58
59 /* DBGU on ttyS0. (Rx & Tx only) */
60 at91_register_uart(0, 0, 0);
61
62 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
63 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
64
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
67 }
68
neocore926_init_irq(void)69 static void __init neocore926_init_irq(void)
70 {
71 at91sam9263_init_interrupts(NULL);
72 }
73
74
75 /*
76 * USB Host port
77 */
78 static struct at91_usbh_data __initdata neocore926_usbh_data = {
79 .ports = 2,
80 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },
81 };
82
83 /*
84 * USB Device port
85 */
86 static struct at91_udc_data __initdata neocore926_udc_data = {
87 .vbus_pin = AT91_PIN_PA25,
88 .pullup_pin = 0, /* pull-up driven by UDC */
89 };
90
91
92 /*
93 * ADS7846 Touchscreen
94 */
95 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
ads7843_pendown_state(void)96 static int ads7843_pendown_state(void)
97 {
98 return !at91_get_gpio_value(AT91_PIN_PA15); /* Touchscreen PENIRQ */
99 }
100
101 static struct ads7846_platform_data ads_info = {
102 .model = 7843,
103 .x_min = 150,
104 .x_max = 3830,
105 .y_min = 190,
106 .y_max = 3830,
107 .vref_delay_usecs = 100,
108 .x_plate_ohms = 450,
109 .y_plate_ohms = 250,
110 .pressure_max = 15000,
111 .debounce_max = 1,
112 .debounce_rep = 0,
113 .debounce_tol = (~0),
114 .get_pendown_state = ads7843_pendown_state,
115 };
116
neocore926_add_device_ts(void)117 static void __init neocore926_add_device_ts(void)
118 {
119 at91_set_B_periph(AT91_PIN_PA15, 1); /* External IRQ1, with pullup */
120 at91_set_gpio_input(AT91_PIN_PC13, 1); /* Touchscreen BUSY signal */
121 }
122 #else
neocore926_add_device_ts(void)123 static void __init neocore926_add_device_ts(void) {}
124 #endif
125
126 /*
127 * SPI devices.
128 */
129 static struct spi_board_info neocore926_spi_devices[] = {
130 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
131 { /* DataFlash card */
132 .modalias = "mtd_dataflash",
133 .chip_select = 0,
134 .max_speed_hz = 15 * 1000 * 1000,
135 .bus_num = 0,
136 },
137 #endif
138 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
139 {
140 .modalias = "ads7846",
141 .chip_select = 1,
142 .max_speed_hz = 125000 * 16,
143 .bus_num = 0,
144 .platform_data = &ads_info,
145 .irq = AT91SAM9263_ID_IRQ1,
146 },
147 #endif
148 };
149
150
151 /*
152 * MCI (SD/MMC)
153 */
154 static struct at91_mmc_data __initdata neocore926_mmc_data = {
155 .wire4 = 1,
156 .det_pin = AT91_PIN_PE18,
157 .wp_pin = AT91_PIN_PE19,
158 };
159
160
161 /*
162 * MACB Ethernet device
163 */
164 static struct at91_eth_data __initdata neocore926_macb_data = {
165 .phy_irq_pin = AT91_PIN_PE31,
166 .is_rmii = 1,
167 };
168
169
170 /*
171 * NAND flash
172 */
173 static struct mtd_partition __initdata neocore926_nand_partition[] = {
174 {
175 .name = "Linux Kernel", /* "Partition 1", */
176 .offset = 0,
177 .size = SZ_8M,
178 },
179 {
180 .name = "Filesystem", /* "Partition 2", */
181 .offset = MTDPART_OFS_NXTBLK,
182 .size = SZ_32M,
183 },
184 {
185 .name = "Free", /* "Partition 3", */
186 .offset = MTDPART_OFS_NXTBLK,
187 .size = MTDPART_SIZ_FULL,
188 },
189 };
190
nand_partitions(int size,int * num_partitions)191 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
192 {
193 *num_partitions = ARRAY_SIZE(neocore926_nand_partition);
194 return neocore926_nand_partition;
195 }
196
197 static struct atmel_nand_data __initdata neocore926_nand_data = {
198 .ale = 21,
199 .cle = 22,
200 .rdy_pin = AT91_PIN_PB19,
201 .rdy_pin_active_low = 1,
202 .enable_pin = AT91_PIN_PD15,
203 .partition_info = nand_partitions,
204 };
205
206 static struct sam9_smc_config __initdata neocore926_nand_smc_config = {
207 .ncs_read_setup = 0,
208 .nrd_setup = 1,
209 .ncs_write_setup = 0,
210 .nwe_setup = 1,
211
212 .ncs_read_pulse = 4,
213 .nrd_pulse = 4,
214 .ncs_write_pulse = 4,
215 .nwe_pulse = 4,
216
217 .read_cycle = 6,
218 .write_cycle = 6,
219
220 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
221 .tdf_cycles = 2,
222 };
223
neocore926_add_device_nand(void)224 static void __init neocore926_add_device_nand(void)
225 {
226 /* configure chip-select 3 (NAND) */
227 sam9_smc_configure(3, &neocore926_nand_smc_config);
228
229 at91_add_device_nand(&neocore926_nand_data);
230 }
231
232
233 /*
234 * LCD Controller
235 */
236 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
237 static struct fb_videomode at91_tft_vga_modes[] = {
238 {
239 .name = "TX09D50VM1CCA @ 60",
240 .refresh = 60,
241 .xres = 240, .yres = 320,
242 .pixclock = KHZ2PICOS(5000),
243
244 .left_margin = 1, .right_margin = 33,
245 .upper_margin = 1, .lower_margin = 0,
246 .hsync_len = 5, .vsync_len = 1,
247
248 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
249 .vmode = FB_VMODE_NONINTERLACED,
250 },
251 };
252
253 static struct fb_monspecs at91fb_default_monspecs = {
254 .manufacturer = "HIT",
255 .monitor = "TX09D70VM1CCA",
256
257 .modedb = at91_tft_vga_modes,
258 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
259 .hfmin = 15000,
260 .hfmax = 64000,
261 .vfmin = 50,
262 .vfmax = 150,
263 };
264
265 #define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
266 | ATMEL_LCDC_DISTYPE_TFT \
267 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
268
at91_lcdc_power_control(int on)269 static void at91_lcdc_power_control(int on)
270 {
271 at91_set_gpio_value(AT91_PIN_PA30, on);
272 }
273
274 /* Driver datas */
275 static struct atmel_lcdfb_info __initdata neocore926_lcdc_data = {
276 .lcdcon_is_backlight = true,
277 .default_bpp = 16,
278 .default_dmacon = ATMEL_LCDC_DMAEN,
279 .default_lcdcon2 = AT91SAM9263_DEFAULT_LCDCON2,
280 .default_monspecs = &at91fb_default_monspecs,
281 .atmel_lcdfb_power_control = at91_lcdc_power_control,
282 .guard_time = 1,
283 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB555,
284 };
285
286 #else
287 static struct atmel_lcdfb_info __initdata neocore926_lcdc_data;
288 #endif
289
290
291 /*
292 * GPIO Buttons
293 */
294 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
295 static struct gpio_keys_button neocore926_buttons[] = {
296 { /* BP1, "leftclic" */
297 .code = BTN_LEFT,
298 .gpio = AT91_PIN_PC5,
299 .active_low = 1,
300 .desc = "left_click",
301 .wakeup = 1,
302 },
303 { /* BP2, "rightclic" */
304 .code = BTN_RIGHT,
305 .gpio = AT91_PIN_PC4,
306 .active_low = 1,
307 .desc = "right_click",
308 .wakeup = 1,
309 },
310 };
311
312 static struct gpio_keys_platform_data neocore926_button_data = {
313 .buttons = neocore926_buttons,
314 .nbuttons = ARRAY_SIZE(neocore926_buttons),
315 };
316
317 static struct platform_device neocore926_button_device = {
318 .name = "gpio-keys",
319 .id = -1,
320 .num_resources = 0,
321 .dev = {
322 .platform_data = &neocore926_button_data,
323 }
324 };
325
neocore926_add_device_buttons(void)326 static void __init neocore926_add_device_buttons(void)
327 {
328 at91_set_GPIO_periph(AT91_PIN_PC5, 0); /* left button */
329 at91_set_deglitch(AT91_PIN_PC5, 1);
330 at91_set_GPIO_periph(AT91_PIN_PC4, 0); /* right button */
331 at91_set_deglitch(AT91_PIN_PC4, 1);
332
333 platform_device_register(&neocore926_button_device);
334 }
335 #else
neocore926_add_device_buttons(void)336 static void __init neocore926_add_device_buttons(void) {}
337 #endif
338
339
340 /*
341 * AC97
342 */
343 static struct ac97c_platform_data neocore926_ac97_data = {
344 .reset_pin = AT91_PIN_PA13,
345 };
346
347
neocore926_board_init(void)348 static void __init neocore926_board_init(void)
349 {
350 /* Serial */
351 at91_add_device_serial();
352
353 /* USB Host */
354 at91_add_device_usbh(&neocore926_usbh_data);
355
356 /* USB Device */
357 at91_add_device_udc(&neocore926_udc_data);
358
359 /* SPI */
360 at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */
361 at91_add_device_spi(neocore926_spi_devices, ARRAY_SIZE(neocore926_spi_devices));
362
363 /* Touchscreen */
364 neocore926_add_device_ts();
365
366 /* MMC */
367 at91_add_device_mmc(1, &neocore926_mmc_data);
368
369 /* Ethernet */
370 at91_add_device_eth(&neocore926_macb_data);
371
372 /* NAND */
373 neocore926_add_device_nand();
374
375 /* I2C */
376 at91_add_device_i2c(NULL, 0);
377
378 /* LCD Controller */
379 at91_add_device_lcdc(&neocore926_lcdc_data);
380
381 /* Push Buttons */
382 neocore926_add_device_buttons();
383
384 /* AC97 */
385 at91_add_device_ac97(&neocore926_ac97_data);
386 }
387
388 MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926")
389 /* Maintainer: ADENEO */
390 .boot_params = AT91_SDRAM_BASE + 0x100,
391 .timer = &at91sam926x_timer,
392 .map_io = neocore926_map_io,
393 .init_irq = neocore926_init_irq,
394 .init_machine = neocore926_board_init,
395 MACHINE_END
396