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