ARM: at91: drop at91_set_serial_console
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-at91 / board-sam9rlek.c
1 /*
2  *  Copyright (C) 2005 SAN People
3  *  Copyright (C) 2007 Atmel Corporation
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file COPYING in the main directory of this archive for
7  * more details.
8  */
9
10 #include <linux/types.h>
11 #include <linux/gpio.h>
12 #include <linux/init.h>
13 #include <linux/mm.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/spi/spi.h>
17 #include <linux/fb.h>
18 #include <linux/clk.h>
19 #include <linux/input.h>
20 #include <linux/gpio_keys.h>
21
22 #include <video/atmel_lcdc.h>
23
24 #include <asm/setup.h>
25 #include <asm/mach-types.h>
26 #include <asm/irq.h>
27
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
31
32 #include <mach/hardware.h>
33 #include <mach/board.h>
34 #include <mach/at91sam9_smc.h>
35 #include <mach/at91_shdwc.h>
36
37 #include "sam9_smc.h"
38 #include "generic.h"
39
40
41 static void __init ek_init_early(void)
42 {
43         /* Initialize processor: 12.000 MHz crystal */
44         at91_initialize(12000000);
45
46         /* DBGU on ttyS0. (Rx & Tx only) */
47         at91_register_uart(0, 0, 0);
48
49         /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
50         at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
51 }
52
53 /*
54  * USB HS Device port
55  */
56 static struct usba_platform_data __initdata ek_usba_udc_data = {
57         .vbus_pin       = AT91_PIN_PA8,
58 };
59
60
61 /*
62  * MCI (SD/MMC)
63  */
64 static struct at91_mmc_data __initdata ek_mmc_data = {
65         .wire4          = 1,
66         .det_pin        = AT91_PIN_PA15,
67         .wp_pin         = -EINVAL,
68         .vcc_pin        = -EINVAL,
69 };
70
71
72 /*
73  * NAND flash
74  */
75 static struct mtd_partition __initdata ek_nand_partition[] = {
76         {
77                 .name   = "Partition 1",
78                 .offset = 0,
79                 .size   = SZ_256K,
80         },
81         {
82                 .name   = "Partition 2",
83                 .offset = MTDPART_OFS_NXTBLK,
84                 .size   = MTDPART_SIZ_FULL,
85         },
86 };
87
88 static struct atmel_nand_data __initdata ek_nand_data = {
89         .ale            = 21,
90         .cle            = 22,
91         .det_pin        = -EINVAL,
92         .rdy_pin        = AT91_PIN_PD17,
93         .enable_pin     = AT91_PIN_PB6,
94         .ecc_mode       = NAND_ECC_SOFT,
95         .on_flash_bbt   = 1,
96         .parts          = ek_nand_partition,
97         .num_parts      = ARRAY_SIZE(ek_nand_partition),
98 };
99
100 static struct sam9_smc_config __initdata ek_nand_smc_config = {
101         .ncs_read_setup         = 0,
102         .nrd_setup              = 1,
103         .ncs_write_setup        = 0,
104         .nwe_setup              = 1,
105
106         .ncs_read_pulse         = 3,
107         .nrd_pulse              = 3,
108         .ncs_write_pulse        = 3,
109         .nwe_pulse              = 3,
110
111         .read_cycle             = 5,
112         .write_cycle            = 5,
113
114         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
115         .tdf_cycles             = 2,
116 };
117
118 static void __init ek_add_device_nand(void)
119 {
120         /* configure chip-select 3 (NAND) */
121         sam9_smc_configure(0, 3, &ek_nand_smc_config);
122
123         at91_add_device_nand(&ek_nand_data);
124 }
125
126
127 /*
128  * SPI devices
129  */
130 static struct spi_board_info ek_spi_devices[] = {
131         {       /* DataFlash chip */
132                 .modalias       = "mtd_dataflash",
133                 .chip_select    = 0,
134                 .max_speed_hz   = 15 * 1000 * 1000,
135                 .bus_num        = 0,
136         },
137 };
138
139
140 /*
141  * LCD Controller
142  */
143 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
144 static struct fb_videomode at91_tft_vga_modes[] = {
145         {
146                 .name           = "TX09D50VM1CCA @ 60",
147                 .refresh        = 60,
148                 .xres           = 240,          .yres           = 320,
149                 .pixclock       = KHZ2PICOS(4965),
150
151                 .left_margin    = 1,            .right_margin   = 33,
152                 .upper_margin   = 1,            .lower_margin   = 0,
153                 .hsync_len      = 5,            .vsync_len      = 1,
154
155                 .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
156                 .vmode          = FB_VMODE_NONINTERLACED,
157         },
158 };
159
160 static struct fb_monspecs at91fb_default_monspecs = {
161         .manufacturer   = "HIT",
162         .monitor        = "TX09D50VM1CCA",
163
164         .modedb         = at91_tft_vga_modes,
165         .modedb_len     = ARRAY_SIZE(at91_tft_vga_modes),
166         .hfmin          = 15000,
167         .hfmax          = 64000,
168         .vfmin          = 50,
169         .vfmax          = 150,
170 };
171
172 #define AT91SAM9RL_DEFAULT_LCDCON2      (ATMEL_LCDC_MEMOR_LITTLE \
173                                         | ATMEL_LCDC_DISTYPE_TFT \
174                                         | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
175
176 static void at91_lcdc_power_control(int on)
177 {
178         if (on)
179                 at91_set_gpio_value(AT91_PIN_PC1, 0);   /* power up */
180         else
181                 at91_set_gpio_value(AT91_PIN_PC1, 1);   /* power down */
182 }
183
184 /* Driver datas */
185 static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
186         .lcdcon_is_backlight            = true,
187         .default_bpp                    = 16,
188         .default_dmacon                 = ATMEL_LCDC_DMAEN,
189         .default_lcdcon2                = AT91SAM9RL_DEFAULT_LCDCON2,
190         .default_monspecs               = &at91fb_default_monspecs,
191         .atmel_lcdfb_power_control      = at91_lcdc_power_control,
192         .guard_time                     = 1,
193         .lcd_wiring_mode                = ATMEL_LCDC_WIRING_RGB,
194 };
195
196 #else
197 static struct atmel_lcdfb_info __initdata ek_lcdc_data;
198 #endif
199
200
201 /*
202  * AC97
203  * reset_pin is not connected: NRST
204  */
205 static struct ac97c_platform_data ek_ac97_data = {
206         .reset_pin      = -EINVAL,
207 };
208
209
210 /*
211  * LEDs
212  */
213 static struct gpio_led ek_leds[] = {
214         {       /* "bottom" led, green, userled1 to be defined */
215                 .name                   = "ds1",
216                 .gpio                   = AT91_PIN_PD15,
217                 .active_low             = 1,
218                 .default_trigger        = "none",
219         },
220         {       /* "bottom" led, green, userled2 to be defined */
221                 .name                   = "ds2",
222                 .gpio                   = AT91_PIN_PD16,
223                 .active_low             = 1,
224                 .default_trigger        = "none",
225         },
226         {       /* "power" led, yellow */
227                 .name                   = "ds3",
228                 .gpio                   = AT91_PIN_PD14,
229                 .default_trigger        = "heartbeat",
230         }
231 };
232
233
234 /*
235  * Touchscreen
236  */
237 static struct at91_tsadcc_data ek_tsadcc_data = {
238         .adc_clock              = 1000000,
239         .pendet_debounce        = 0x0f,
240         .ts_sample_hold_time    = 0x03,
241 };
242
243
244 /*
245  * GPIO Buttons
246  */
247 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
248 static struct gpio_keys_button ek_buttons[] = {
249         {
250                 .gpio           = AT91_PIN_PB0,
251                 .code           = BTN_2,
252                 .desc           = "Right Click",
253                 .active_low     = 1,
254                 .wakeup         = 1,
255         },
256         {
257                 .gpio           = AT91_PIN_PB1,
258                 .code           = BTN_1,
259                 .desc           = "Left Click",
260                 .active_low     = 1,
261                 .wakeup         = 1,
262         }
263 };
264
265 static struct gpio_keys_platform_data ek_button_data = {
266         .buttons        = ek_buttons,
267         .nbuttons       = ARRAY_SIZE(ek_buttons),
268 };
269
270 static struct platform_device ek_button_device = {
271         .name           = "gpio-keys",
272         .id             = -1,
273         .num_resources  = 0,
274         .dev            = {
275                 .platform_data  = &ek_button_data,
276         }
277 };
278
279 static void __init ek_add_device_buttons(void)
280 {
281         at91_set_gpio_input(AT91_PIN_PB1, 1);   /* btn1 */
282         at91_set_deglitch(AT91_PIN_PB1, 1);
283         at91_set_gpio_input(AT91_PIN_PB0, 1);   /* btn2 */
284         at91_set_deglitch(AT91_PIN_PB0, 1);
285
286         platform_device_register(&ek_button_device);
287 }
288 #else
289 static void __init ek_add_device_buttons(void) {}
290 #endif
291
292
293 static void __init ek_board_init(void)
294 {
295         /* Serial */
296         at91_add_device_serial();
297         /* USB HS */
298         at91_add_device_usba(&ek_usba_udc_data);
299         /* I2C */
300         at91_add_device_i2c(NULL, 0);
301         /* NAND */
302         ek_add_device_nand();
303         /* SPI */
304         at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
305         /* MMC */
306         at91_add_device_mmc(0, &ek_mmc_data);
307         /* LCD Controller */
308         at91_add_device_lcdc(&ek_lcdc_data);
309         /* AC97 */
310         at91_add_device_ac97(&ek_ac97_data);
311         /* Touch Screen Controller */
312         at91_add_device_tsadcc(&ek_tsadcc_data);
313         /* LEDs */
314         at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
315         /* Push Buttons */
316         ek_add_device_buttons();
317 }
318
319 MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
320         /* Maintainer: Atmel */
321         .timer          = &at91sam926x_timer,
322         .map_io         = at91_map_io,
323         .init_early     = ek_init_early,
324         .init_irq       = at91_init_irq_default,
325         .init_machine   = ek_board_init,
326 MACHINE_END