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