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