2 * linux/arch/arm/mach-at91/board-cpu9krea.c
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2009 Eric Benard - eric@eukrea.com
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.
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.
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
23 #include <linux/types.h>
24 #include <linux/gpio.h>
25 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/platform_device.h>
29 #include <linux/clk.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/input.h>
32 #include <linux/mtd/physmap.h>
34 #include <asm/setup.h>
35 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/irq.h>
42 #include <mach/hardware.h>
43 #include <mach/board.h>
44 #include <mach/at91sam9_smc.h>
45 #include <mach/at91sam9260_matrix.h>
50 static void __init
cpu9krea_init_early(void)
52 /* Initialize processor: 18.432 MHz crystal */
53 at91_initialize(18432000);
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
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
);
63 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
64 at91_register_uart(AT91SAM9260_ID_US1
, 2, ATMEL_UART_CTS
|
67 /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
68 at91_register_uart(AT91SAM9260_ID_US2
, 3, ATMEL_UART_CTS
|
71 /* USART3 on ttyS4. (Rx, Tx) */
72 at91_register_uart(AT91SAM9260_ID_US3
, 4, 0);
74 /* USART4 on ttyS5. (Rx, Tx) */
75 at91_register_uart(AT91SAM9260_ID_US4
, 5, 0);
77 /* USART5 on ttyS6. (Rx, Tx) */
78 at91_register_uart(AT91SAM9260_ID_US5
, 6, 0);
80 /* set serial console to ttyS0 (ie, DBGU) */
81 at91_set_serial_console(0);
87 static struct at91_usbh_data __initdata cpu9krea_usbh_data
= {
94 static struct at91_udc_data __initdata cpu9krea_udc_data
= {
95 .vbus_pin
= AT91_PIN_PC8
,
96 .pullup_pin
= 0, /* pull-up driven by UDC */
100 * MACB Ethernet device
102 static struct at91_eth_data __initdata cpu9krea_macb_data
= {
109 static struct atmel_nand_data __initdata cpu9krea_nand_data
= {
112 .rdy_pin
= AT91_PIN_PC13
,
113 .enable_pin
= AT91_PIN_PC14
,
117 #ifdef CONFIG_MACH_CPU9260
118 static struct sam9_smc_config __initdata cpu9krea_nand_smc_config
= {
121 .ncs_write_setup
= 0,
126 .ncs_write_pulse
= 3,
132 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
133 | AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_DBW_8
,
137 static struct sam9_smc_config __initdata cpu9krea_nand_smc_config
= {
140 .ncs_write_setup
= 0,
145 .ncs_write_pulse
= 4,
151 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
152 | AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_DBW_8
,
157 static void __init
cpu9krea_add_device_nand(void)
159 sam9_smc_configure(3, &cpu9krea_nand_smc_config
);
160 at91_add_device_nand(&cpu9krea_nand_data
);
166 static struct physmap_flash_data cpuat9260_nor_data
= {
170 #define NOR_BASE AT91_CHIPSELECT_0
171 #define NOR_SIZE SZ_64M
173 static struct resource nor_flash_resources
[] = {
176 .end
= NOR_BASE
+ NOR_SIZE
- 1,
177 .flags
= IORESOURCE_MEM
,
181 static struct platform_device cpu9krea_nor_flash
= {
182 .name
= "physmap-flash",
185 .platform_data
= &cpuat9260_nor_data
,
187 .resource
= nor_flash_resources
,
188 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
191 #ifdef CONFIG_MACH_CPU9260
192 static struct sam9_smc_config __initdata cpu9krea_nor_smc_config
= {
195 .ncs_write_setup
= 0,
198 .ncs_read_pulse
= 10,
200 .ncs_write_pulse
= 6,
206 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
207 | AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_BAT_WRITE
212 static struct sam9_smc_config __initdata cpu9krea_nor_smc_config
= {
215 .ncs_write_setup
= 0,
218 .ncs_read_pulse
= 13,
220 .ncs_write_pulse
= 8,
226 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
227 | AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_BAT_WRITE
233 static __init
void cpu9krea_add_device_nor(void)
237 csa
= at91_sys_read(AT91_MATRIX_EBICSA
);
238 at91_sys_write(AT91_MATRIX_EBICSA
, csa
| AT91_MATRIX_VDDIOMSEL_3_3V
);
240 /* configure chip-select 0 (NOR) */
241 sam9_smc_configure(0, &cpu9krea_nor_smc_config
);
243 platform_device_register(&cpu9krea_nor_flash
);
249 static struct gpio_led cpu9krea_leds
[] = {
252 .gpio
= AT91_PIN_PC11
,
254 .default_trigger
= "timer",
258 .gpio
= AT91_PIN_PC12
,
260 .default_trigger
= "heartbeat",
264 .gpio
= AT91_PIN_PC7
,
266 .default_trigger
= "none",
270 .gpio
= AT91_PIN_PC9
,
272 .default_trigger
= "none",
276 static struct i2c_board_info __initdata cpu9krea_i2c_devices
[] = {
278 I2C_BOARD_INFO("rtc-ds1307", 0x68),
286 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
287 static struct gpio_keys_button cpu9krea_buttons
[] = {
289 .gpio
= AT91_PIN_PC3
,
296 .gpio
= AT91_PIN_PB20
,
304 static struct gpio_keys_platform_data cpu9krea_button_data
= {
305 .buttons
= cpu9krea_buttons
,
306 .nbuttons
= ARRAY_SIZE(cpu9krea_buttons
),
309 static struct platform_device cpu9krea_button_device
= {
314 .platform_data
= &cpu9krea_button_data
,
318 static void __init
cpu9krea_add_device_buttons(void)
320 at91_set_gpio_input(AT91_PIN_PC3
, 1); /* BP1 */
321 at91_set_deglitch(AT91_PIN_PC3
, 1);
322 at91_set_gpio_input(AT91_PIN_PB20
, 1); /* BP2 */
323 at91_set_deglitch(AT91_PIN_PB20
, 1);
325 platform_device_register(&cpu9krea_button_device
);
328 static void __init
cpu9krea_add_device_buttons(void)
336 static struct at91_mmc_data __initdata cpu9krea_mmc_data
= {
339 .det_pin
= AT91_PIN_PA29
,
342 static void __init
cpu9krea_board_init(void)
345 cpu9krea_add_device_nor();
347 at91_add_device_serial();
349 at91_add_device_usbh(&cpu9krea_usbh_data
);
351 at91_add_device_udc(&cpu9krea_udc_data
);
353 cpu9krea_add_device_nand();
355 at91_add_device_eth(&cpu9krea_macb_data
);
357 at91_add_device_mmc(0, &cpu9krea_mmc_data
);
359 at91_add_device_i2c(cpu9krea_i2c_devices
,
360 ARRAY_SIZE(cpu9krea_i2c_devices
));
362 at91_gpio_leds(cpu9krea_leds
, ARRAY_SIZE(cpu9krea_leds
));
364 cpu9krea_add_device_buttons();
367 #ifdef CONFIG_MACH_CPU9260
368 MACHINE_START(CPUAT9260
, "Eukrea CPU9260")
370 MACHINE_START(CPUAT9G20
, "Eukrea CPU9G20")
372 /* Maintainer: Eric Benard - EUKREA Electromatique */
373 .timer
= &at91sam926x_timer
,
374 .map_io
= at91_map_io
,
375 .init_early
= cpu9krea_init_early
,
376 .init_irq
= at91_init_irq_default
,
377 .init_machine
= cpu9krea_board_init
,