blob: 01128f9a0597046f0ff7e443dd86b85b990a07a6 [file] [log] [blame]
Eric Bénard41a353d2009-07-30 07:20:03 +01001/*
2 * linux/arch/arm/mach-at91/board-cpu9krea.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2009 Eric Benard - eric@eukrea.com
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/clk.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
31#include <linux/mtd/physmap.h>
32
33#include <asm/setup.h>
34#include <asm/mach-types.h>
35#include <asm/irq.h>
36
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39#include <asm/mach/irq.h>
40
41#include <mach/hardware.h>
42#include <mach/board.h>
43#include <mach/gpio.h>
44#include <mach/at91sam9_smc.h>
45#include <mach/at91sam9260_matrix.h>
46
47#include "sam9_smc.h"
48#include "generic.h"
49
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080050static void __init cpu9krea_init_early(void)
Eric Bénard41a353d2009-07-30 07:20:03 +010051{
52 /* Initialize processor: 18.432 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080053 at91_initialize(18432000);
Eric Bénard41a353d2009-07-30 07:20:03 +010054
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
59 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
60 ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
61 ATMEL_UART_DCD | ATMEL_UART_RI);
62
63 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
64 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
65 ATMEL_UART_RTS);
66
67 /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
68 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
69 ATMEL_UART_RTS);
70
71 /* USART3 on ttyS4. (Rx, Tx) */
72 at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
73
74 /* USART4 on ttyS5. (Rx, Tx) */
75 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
76
77 /* USART5 on ttyS6. (Rx, Tx) */
78 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
79
80 /* set serial console to ttyS0 (ie, DBGU) */
81 at91_set_serial_console(0);
82}
83
84static void __init cpu9krea_init_irq(void)
85{
86 at91sam9260_init_interrupts(NULL);
87}
88
89/*
90 * USB Host port
91 */
92static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
93 .ports = 2,
94};
95
96/*
97 * USB Device port
98 */
99static struct at91_udc_data __initdata cpu9krea_udc_data = {
100 .vbus_pin = AT91_PIN_PC8,
101 .pullup_pin = 0, /* pull-up driven by UDC */
102};
103
104/*
105 * MACB Ethernet device
106 */
107static struct at91_eth_data __initdata cpu9krea_macb_data = {
108 .is_rmii = 1,
109};
110
111/*
112 * NAND flash
113 */
114static struct atmel_nand_data __initdata cpu9krea_nand_data = {
115 .ale = 21,
116 .cle = 22,
117 .rdy_pin = AT91_PIN_PC13,
118 .enable_pin = AT91_PIN_PC14,
119 .bus_width_16 = 0,
120};
121
122#ifdef CONFIG_MACH_CPU9260
123static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
124 .ncs_read_setup = 0,
125 .nrd_setup = 1,
126 .ncs_write_setup = 0,
127 .nwe_setup = 1,
128
129 .ncs_read_pulse = 3,
130 .nrd_pulse = 3,
131 .ncs_write_pulse = 3,
132 .nwe_pulse = 3,
133
134 .read_cycle = 5,
135 .write_cycle = 5,
136
137 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
138 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
139 .tdf_cycles = 2,
140};
141#else
142static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
143 .ncs_read_setup = 0,
144 .nrd_setup = 2,
145 .ncs_write_setup = 0,
146 .nwe_setup = 2,
147
148 .ncs_read_pulse = 4,
149 .nrd_pulse = 4,
150 .ncs_write_pulse = 4,
151 .nwe_pulse = 4,
152
153 .read_cycle = 7,
154 .write_cycle = 7,
155
156 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
157 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
158 .tdf_cycles = 3,
159};
160#endif
161
162static void __init cpu9krea_add_device_nand(void)
163{
164 sam9_smc_configure(3, &cpu9krea_nand_smc_config);
165 at91_add_device_nand(&cpu9krea_nand_data);
166}
167
168/*
169 * NOR flash
170 */
171static struct physmap_flash_data cpuat9260_nor_data = {
172 .width = 2,
173};
174
175#define NOR_BASE AT91_CHIPSELECT_0
176#define NOR_SIZE SZ_64M
177
178static struct resource nor_flash_resources[] = {
179 {
180 .start = NOR_BASE,
181 .end = NOR_BASE + NOR_SIZE - 1,
182 .flags = IORESOURCE_MEM,
183 }
184};
185
186static struct platform_device cpu9krea_nor_flash = {
187 .name = "physmap-flash",
188 .id = 0,
189 .dev = {
190 .platform_data = &cpuat9260_nor_data,
191 },
192 .resource = nor_flash_resources,
193 .num_resources = ARRAY_SIZE(nor_flash_resources),
194};
195
196#ifdef CONFIG_MACH_CPU9260
197static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
198 .ncs_read_setup = 0,
199 .nrd_setup = 1,
200 .ncs_write_setup = 0,
201 .nwe_setup = 1,
202
203 .ncs_read_pulse = 10,
204 .nrd_pulse = 10,
205 .ncs_write_pulse = 6,
206 .nwe_pulse = 6,
207
208 .read_cycle = 12,
209 .write_cycle = 8,
210
211 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
212 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
213 | AT91_SMC_DBW_16,
214 .tdf_cycles = 2,
215};
216#else
217static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
218 .ncs_read_setup = 0,
219 .nrd_setup = 1,
220 .ncs_write_setup = 0,
221 .nwe_setup = 1,
222
223 .ncs_read_pulse = 13,
224 .nrd_pulse = 13,
225 .ncs_write_pulse = 8,
226 .nwe_pulse = 8,
227
228 .read_cycle = 15,
229 .write_cycle = 10,
230
231 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
232 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
233 | AT91_SMC_DBW_16,
234 .tdf_cycles = 2,
235};
236#endif
237
238static __init void cpu9krea_add_device_nor(void)
239{
240 unsigned long csa;
241
242 csa = at91_sys_read(AT91_MATRIX_EBICSA);
243 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
244
245 /* configure chip-select 0 (NOR) */
246 sam9_smc_configure(0, &cpu9krea_nor_smc_config);
247
248 platform_device_register(&cpu9krea_nor_flash);
249}
250
251/*
252 * LEDs
253 */
254static struct gpio_led cpu9krea_leds[] = {
255 { /* LED1 */
256 .name = "LED1",
257 .gpio = AT91_PIN_PC11,
258 .active_low = 1,
259 .default_trigger = "timer",
260 },
261 { /* LED2 */
262 .name = "LED2",
263 .gpio = AT91_PIN_PC12,
264 .active_low = 1,
265 .default_trigger = "heartbeat",
266 },
267 { /* LED3 */
268 .name = "LED3",
269 .gpio = AT91_PIN_PC7,
270 .active_low = 1,
271 .default_trigger = "none",
272 },
273 { /* LED4 */
274 .name = "LED4",
275 .gpio = AT91_PIN_PC9,
276 .active_low = 1,
277 .default_trigger = "none",
278 }
279};
280
281static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {
282 {
283 I2C_BOARD_INFO("rtc-ds1307", 0x68),
284 .type = "ds1339",
285 },
286};
287
288/*
289 * GPIO Buttons
290 */
291#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
292static struct gpio_keys_button cpu9krea_buttons[] = {
293 {
294 .gpio = AT91_PIN_PC3,
295 .code = BTN_0,
296 .desc = "BP1",
297 .active_low = 1,
298 .wakeup = 1,
299 },
300 {
301 .gpio = AT91_PIN_PB20,
302 .code = BTN_1,
303 .desc = "BP2",
304 .active_low = 1,
305 .wakeup = 1,
306 }
307};
308
309static struct gpio_keys_platform_data cpu9krea_button_data = {
310 .buttons = cpu9krea_buttons,
311 .nbuttons = ARRAY_SIZE(cpu9krea_buttons),
312};
313
314static struct platform_device cpu9krea_button_device = {
315 .name = "gpio-keys",
316 .id = -1,
317 .num_resources = 0,
318 .dev = {
319 .platform_data = &cpu9krea_button_data,
320 }
321};
322
323static void __init cpu9krea_add_device_buttons(void)
324{
325 at91_set_gpio_input(AT91_PIN_PC3, 1); /* BP1 */
326 at91_set_deglitch(AT91_PIN_PC3, 1);
327 at91_set_gpio_input(AT91_PIN_PB20, 1); /* BP2 */
328 at91_set_deglitch(AT91_PIN_PB20, 1);
329
330 platform_device_register(&cpu9krea_button_device);
331}
332#else
333static void __init cpu9krea_add_device_buttons(void)
334{
335}
336#endif
337
338/*
339 * MCI (SD/MMC)
340 */
341static struct at91_mmc_data __initdata cpu9krea_mmc_data = {
342 .slot_b = 0,
343 .wire4 = 1,
344 .det_pin = AT91_PIN_PA29,
345};
346
347static void __init cpu9krea_board_init(void)
348{
349 /* NOR */
350 cpu9krea_add_device_nor();
351 /* Serial */
352 at91_add_device_serial();
353 /* USB Host */
354 at91_add_device_usbh(&cpu9krea_usbh_data);
355 /* USB Device */
356 at91_add_device_udc(&cpu9krea_udc_data);
357 /* NAND */
358 cpu9krea_add_device_nand();
359 /* Ethernet */
360 at91_add_device_eth(&cpu9krea_macb_data);
361 /* MMC */
362 at91_add_device_mmc(0, &cpu9krea_mmc_data);
363 /* I2C */
364 at91_add_device_i2c(cpu9krea_i2c_devices,
365 ARRAY_SIZE(cpu9krea_i2c_devices));
366 /* LEDs */
367 at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));
368 /* Push Buttons */
369 cpu9krea_add_device_buttons();
370}
371
372#ifdef CONFIG_MACH_CPU9260
373MACHINE_START(CPUAT9260, "Eukrea CPU9260")
374#else
375MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
376#endif
377 /* Maintainer: Eric Benard - EUKREA Electromatique */
Eric Bénard41a353d2009-07-30 07:20:03 +0100378 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800379 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800380 .init_early = cpu9krea_init_early,
Eric Bénard41a353d2009-07-30 07:20:03 +0100381 .init_irq = cpu9krea_init_irq,
382 .init_machine = cpu9krea_board_init,
383MACHINE_END