tegra, serial8250: add ->handle_break() uart_port op
[linux-2.6/btrfs-unstable.git] / arch / arm / mach-tegra / board-seaboard.c
blob5b687b8258c03b97cdec766ed5ed20969f0dc803
1 /*
2 * Copyright (c) 2010, 2011 NVIDIA Corporation.
3 * Copyright (C) 2010, 2011 Google, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/serial_8250.h>
21 #include <linux/of_serial.h>
22 #include <linux/i2c.h>
23 #include <linux/delay.h>
24 #include <linux/input.h>
25 #include <linux/io.h>
26 #include <linux/gpio.h>
27 #include <linux/gpio_keys.h>
29 #include <sound/wm8903.h>
31 #include <mach/iomap.h>
32 #include <mach/irqs.h>
33 #include <mach/sdhci.h>
34 #include <mach/tegra_wm8903_pdata.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/hardware/gic.h>
40 #include "board.h"
41 #include "board-seaboard.h"
42 #include "clock.h"
43 #include "devices.h"
44 #include "gpio-names.h"
46 static struct plat_serial8250_port debug_uart_platform_data[] = {
48 /* Memory and IRQ filled in before registration */
49 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
50 .type = PORT_TEGRA,
51 .handle_break = tegra_serial_handle_break,
52 .iotype = UPIO_MEM,
53 .regshift = 2,
54 .uartclk = 216000000,
55 }, {
56 .flags = 0,
60 static struct platform_device debug_uart = {
61 .name = "serial8250",
62 .id = PLAT8250_DEV_PLATFORM,
63 .dev = {
64 .platform_data = debug_uart_platform_data,
68 static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
69 /* name parent rate enabled */
70 { "uartb", "pll_p", 216000000, true},
71 { "uartd", "pll_p", 216000000, true},
72 { "pll_a", "pll_p_out1", 56448000, true },
73 { "pll_a_out0", "pll_a", 11289600, true },
74 { "cdev1", NULL, 0, true },
75 { "i2s1", "pll_a_out0", 11289600, false},
76 { "usbd", "clk_m", 12000000, true},
77 { "usb3", "clk_m", 12000000, true},
78 { NULL, NULL, 0, 0},
81 static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
83 .code = SW_LID,
84 .gpio = TEGRA_GPIO_LIDSWITCH,
85 .active_low = 0,
86 .desc = "Lid",
87 .type = EV_SW,
88 .wakeup = 1,
89 .debounce_interval = 1,
92 .code = KEY_POWER,
93 .gpio = TEGRA_GPIO_POWERKEY,
94 .active_low = 1,
95 .desc = "Power",
96 .type = EV_KEY,
97 .wakeup = 1,
101 static struct gpio_keys_platform_data seaboard_gpio_keys = {
102 .buttons = seaboard_gpio_keys_buttons,
103 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
106 static struct platform_device seaboard_gpio_keys_device = {
107 .name = "gpio-keys",
108 .id = -1,
109 .dev = {
110 .platform_data = &seaboard_gpio_keys,
114 static struct tegra_sdhci_platform_data sdhci_pdata1 = {
115 .cd_gpio = -1,
116 .wp_gpio = -1,
117 .power_gpio = -1,
120 static struct tegra_sdhci_platform_data sdhci_pdata3 = {
121 .cd_gpio = TEGRA_GPIO_SD2_CD,
122 .wp_gpio = TEGRA_GPIO_SD2_WP,
123 .power_gpio = TEGRA_GPIO_SD2_POWER,
126 static struct tegra_sdhci_platform_data sdhci_pdata4 = {
127 .cd_gpio = -1,
128 .wp_gpio = -1,
129 .power_gpio = -1,
130 .is_8bit = 1,
133 static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
134 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
135 .gpio_hp_det = TEGRA_GPIO_HP_DET,
136 .gpio_hp_mute = -1,
137 .gpio_int_mic_en = -1,
138 .gpio_ext_mic_en = -1,
141 static struct platform_device seaboard_audio_device = {
142 .name = "tegra-snd-wm8903",
143 .id = 0,
144 .dev = {
145 .platform_data = &seaboard_audio_pdata,
149 static struct platform_device *seaboard_devices[] __initdata = {
150 &debug_uart,
151 &tegra_pmu_device,
152 &tegra_sdhci_device4,
153 &tegra_sdhci_device3,
154 &tegra_sdhci_device1,
155 &seaboard_gpio_keys_device,
156 &tegra_i2s_device1,
157 &tegra_das_device,
158 &tegra_pcm_device,
159 &seaboard_audio_device,
162 static struct i2c_board_info __initdata isl29018_device = {
163 I2C_BOARD_INFO("isl29018", 0x44),
166 static struct i2c_board_info __initdata adt7461_device = {
167 I2C_BOARD_INFO("adt7461", 0x4c),
170 static struct wm8903_platform_data wm8903_pdata = {
171 .irq_active_low = 0,
172 .micdet_cfg = 0,
173 .micdet_delay = 100,
174 .gpio_base = SEABOARD_GPIO_WM8903(0),
175 .gpio_cfg = {
178 WM8903_GPIO_CONFIG_ZERO,
184 static struct i2c_board_info __initdata wm8903_device = {
185 I2C_BOARD_INFO("wm8903", 0x1a),
186 .platform_data = &wm8903_pdata,
189 static int seaboard_ehci_init(void)
191 int gpio_status;
193 gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1");
194 if (gpio_status < 0) {
195 pr_err("VBUS_USB1 request GPIO FAILED\n");
196 WARN_ON(1);
199 gpio_status = gpio_direction_output(TEGRA_GPIO_USB1, 1);
200 if (gpio_status < 0) {
201 pr_err("VBUS_USB1 request GPIO DIRECTION FAILED\n");
202 WARN_ON(1);
204 gpio_set_value(TEGRA_GPIO_USB1, 1);
206 platform_device_register(&tegra_ehci1_device);
207 platform_device_register(&tegra_ehci3_device);
209 return 0;
212 static void __init seaboard_i2c_init(void)
214 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
215 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
217 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
218 i2c_register_board_info(0, &isl29018_device, 1);
220 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
221 i2c_register_board_info(0, &wm8903_device, 1);
223 i2c_register_board_info(3, &adt7461_device, 1);
225 platform_device_register(&tegra_i2c_device1);
226 platform_device_register(&tegra_i2c_device2);
227 platform_device_register(&tegra_i2c_device3);
228 platform_device_register(&tegra_i2c_device4);
231 static void __init seaboard_common_init(void)
233 seaboard_pinmux_init();
235 tegra_clk_init_from_table(seaboard_clk_init_table);
237 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
238 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
239 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
241 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
243 seaboard_ehci_init();
246 static void __init tegra_seaboard_init(void)
248 /* Seaboard uses UARTD for the debug port. */
249 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
250 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
251 debug_uart_platform_data[0].irq = INT_UARTD;
253 seaboard_common_init();
255 seaboard_i2c_init();
258 static void __init tegra_kaen_init(void)
260 /* Kaen uses UARTB for the debug port. */
261 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
262 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
263 debug_uart_platform_data[0].irq = INT_UARTB;
265 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
266 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
268 seaboard_common_init();
270 seaboard_i2c_init();
273 static void __init tegra_wario_init(void)
275 /* Wario uses UARTB for the debug port. */
276 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
277 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
278 debug_uart_platform_data[0].irq = INT_UARTB;
280 seaboard_common_init();
282 seaboard_i2c_init();
286 MACHINE_START(SEABOARD, "seaboard")
287 .atag_offset = 0x100,
288 .map_io = tegra_map_common_io,
289 .init_early = tegra20_init_early,
290 .init_irq = tegra_init_irq,
291 .handle_irq = gic_handle_irq,
292 .timer = &tegra_timer,
293 .init_machine = tegra_seaboard_init,
294 .restart = tegra_assert_system_reset,
295 MACHINE_END
297 MACHINE_START(KAEN, "kaen")
298 .atag_offset = 0x100,
299 .map_io = tegra_map_common_io,
300 .init_early = tegra20_init_early,
301 .init_irq = tegra_init_irq,
302 .handle_irq = gic_handle_irq,
303 .timer = &tegra_timer,
304 .init_machine = tegra_kaen_init,
305 .restart = tegra_assert_system_reset,
306 MACHINE_END
308 MACHINE_START(WARIO, "wario")
309 .atag_offset = 0x100,
310 .map_io = tegra_map_common_io,
311 .init_early = tegra20_init_early,
312 .init_irq = tegra_init_irq,
313 .handle_irq = gic_handle_irq,
314 .timer = &tegra_timer,
315 .init_machine = tegra_wario_init,
316 .restart = tegra_assert_system_reset,
317 MACHINE_END