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
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/i2c.h>
22 #include <linux/delay.h>
23 #include <linux/input.h>
25 #include <linux/gpio.h>
26 #include <linux/gpio_keys.h>
28 #include <sound/wm8903.h>
30 #include <mach/iomap.h>
31 #include <mach/irqs.h>
32 #include <mach/sdhci.h>
33 #include <mach/tegra_wm8903_pdata.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
39 #include "board-seaboard.h"
42 #include "gpio-names.h"
44 static struct plat_serial8250_port debug_uart_platform_data
[] = {
46 /* Memory and IRQ filled in before registration */
47 .flags
= UPF_BOOT_AUTOCONF
| UPF_FIXED_TYPE
,
57 static struct platform_device debug_uart
= {
59 .id
= PLAT8250_DEV_PLATFORM
,
61 .platform_data
= debug_uart_platform_data
,
65 static __initdata
struct tegra_clk_init_table seaboard_clk_init_table
[] = {
66 /* name parent rate enabled */
67 { "uartb", "pll_p", 216000000, true},
68 { "uartd", "pll_p", 216000000, true},
69 { "pll_a", "pll_p_out1", 56448000, true },
70 { "pll_a_out0", "pll_a", 11289600, true },
71 { "cdev1", NULL
, 0, true },
72 { "i2s1", "pll_a_out0", 11289600, false},
73 { "usbd", "clk_m", 12000000, true},
74 { "usb3", "clk_m", 12000000, true},
78 static struct gpio_keys_button seaboard_gpio_keys_buttons
[] = {
81 .gpio
= TEGRA_GPIO_LIDSWITCH
,
86 .debounce_interval
= 1,
90 .gpio
= TEGRA_GPIO_POWERKEY
,
98 static struct gpio_keys_platform_data seaboard_gpio_keys
= {
99 .buttons
= seaboard_gpio_keys_buttons
,
100 .nbuttons
= ARRAY_SIZE(seaboard_gpio_keys_buttons
),
103 static struct platform_device seaboard_gpio_keys_device
= {
107 .platform_data
= &seaboard_gpio_keys
,
111 static struct tegra_sdhci_platform_data sdhci_pdata1
= {
117 static struct tegra_sdhci_platform_data sdhci_pdata3
= {
118 .cd_gpio
= TEGRA_GPIO_SD2_CD
,
119 .wp_gpio
= TEGRA_GPIO_SD2_WP
,
120 .power_gpio
= TEGRA_GPIO_SD2_POWER
,
123 static struct tegra_sdhci_platform_data sdhci_pdata4
= {
130 static struct tegra_wm8903_platform_data seaboard_audio_pdata
= {
131 .gpio_spkr_en
= TEGRA_GPIO_SPKR_EN
,
132 .gpio_hp_det
= TEGRA_GPIO_HP_DET
,
134 .gpio_int_mic_en
= -1,
135 .gpio_ext_mic_en
= -1,
138 static struct platform_device seaboard_audio_device
= {
139 .name
= "tegra-snd-wm8903",
142 .platform_data
= &seaboard_audio_pdata
,
146 static struct platform_device
*seaboard_devices
[] __initdata
= {
149 &tegra_sdhci_device4
,
150 &tegra_sdhci_device3
,
151 &tegra_sdhci_device1
,
152 &seaboard_gpio_keys_device
,
156 &seaboard_audio_device
,
159 static struct i2c_board_info __initdata isl29018_device
= {
160 I2C_BOARD_INFO("isl29018", 0x44),
161 .irq
= TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ
),
164 static struct i2c_board_info __initdata adt7461_device
= {
165 I2C_BOARD_INFO("adt7461", 0x4c),
168 static struct wm8903_platform_data wm8903_pdata
= {
172 .gpio_base
= SEABOARD_GPIO_WM8903(0),
174 WM8903_GPIO_NO_CONFIG
,
175 WM8903_GPIO_NO_CONFIG
,
177 WM8903_GPIO_NO_CONFIG
,
178 WM8903_GPIO_NO_CONFIG
,
182 static struct i2c_board_info __initdata wm8903_device
= {
183 I2C_BOARD_INFO("wm8903", 0x1a),
184 .platform_data
= &wm8903_pdata
,
185 .irq
= TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ
),
188 static int seaboard_ehci_init(void)
192 gpio_status
= gpio_request(TEGRA_GPIO_USB1
, "VBUS_USB1");
193 if (gpio_status
< 0) {
194 pr_err("VBUS_USB1 request GPIO FAILED\n");
198 gpio_status
= gpio_direction_output(TEGRA_GPIO_USB1
, 1);
199 if (gpio_status
< 0) {
200 pr_err("VBUS_USB1 request GPIO DIRECTION FAILED\n");
203 gpio_set_value(TEGRA_GPIO_USB1
, 1);
205 platform_device_register(&tegra_ehci1_device
);
206 platform_device_register(&tegra_ehci3_device
);
211 static void __init
seaboard_i2c_init(void)
213 gpio_request(TEGRA_GPIO_ISL29018_IRQ
, "isl29018");
214 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ
);
216 i2c_register_board_info(0, &isl29018_device
, 1);
217 i2c_register_board_info(0, &wm8903_device
, 1);
219 i2c_register_board_info(3, &adt7461_device
, 1);
221 platform_device_register(&tegra_i2c_device1
);
222 platform_device_register(&tegra_i2c_device2
);
223 platform_device_register(&tegra_i2c_device3
);
224 platform_device_register(&tegra_i2c_device4
);
227 static void __init
seaboard_common_init(void)
229 seaboard_pinmux_init();
231 tegra_clk_init_from_table(seaboard_clk_init_table
);
233 tegra_sdhci_device1
.dev
.platform_data
= &sdhci_pdata1
;
234 tegra_sdhci_device3
.dev
.platform_data
= &sdhci_pdata3
;
235 tegra_sdhci_device4
.dev
.platform_data
= &sdhci_pdata4
;
237 platform_add_devices(seaboard_devices
, ARRAY_SIZE(seaboard_devices
));
239 seaboard_ehci_init();
242 static void __init
tegra_seaboard_init(void)
244 /* Seaboard uses UARTD for the debug port. */
245 debug_uart_platform_data
[0].membase
= IO_ADDRESS(TEGRA_UARTD_BASE
);
246 debug_uart_platform_data
[0].mapbase
= TEGRA_UARTD_BASE
;
247 debug_uart_platform_data
[0].irq
= INT_UARTD
;
249 seaboard_common_init();
254 static void __init
tegra_kaen_init(void)
256 /* Kaen uses UARTB for the debug port. */
257 debug_uart_platform_data
[0].membase
= IO_ADDRESS(TEGRA_UARTB_BASE
);
258 debug_uart_platform_data
[0].mapbase
= TEGRA_UARTB_BASE
;
259 debug_uart_platform_data
[0].irq
= INT_UARTB
;
261 seaboard_audio_pdata
.gpio_hp_mute
= TEGRA_GPIO_KAEN_HP_MUTE
;
262 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE
);
264 seaboard_common_init();
269 static void __init
tegra_wario_init(void)
271 /* Wario uses UARTB for the debug port. */
272 debug_uart_platform_data
[0].membase
= IO_ADDRESS(TEGRA_UARTB_BASE
);
273 debug_uart_platform_data
[0].mapbase
= TEGRA_UARTB_BASE
;
274 debug_uart_platform_data
[0].irq
= INT_UARTB
;
276 seaboard_common_init();
282 MACHINE_START(SEABOARD
, "seaboard")
283 .atag_offset
= 0x100,
284 .map_io
= tegra_map_common_io
,
285 .init_early
= tegra_init_early
,
286 .init_irq
= tegra_init_irq
,
287 .timer
= &tegra_timer
,
288 .init_machine
= tegra_seaboard_init
,
291 MACHINE_START(KAEN
, "kaen")
292 .atag_offset
= 0x100,
293 .map_io
= tegra_map_common_io
,
294 .init_early
= tegra_init_early
,
295 .init_irq
= tegra_init_irq
,
296 .timer
= &tegra_timer
,
297 .init_machine
= tegra_kaen_init
,
300 MACHINE_START(WARIO
, "wario")
301 .atag_offset
= 0x100,
302 .map_io
= tegra_map_common_io
,
303 .init_early
= tegra_init_early
,
304 .init_irq
= tegra_init_irq
,
305 .timer
= &tegra_timer
,
306 .init_machine
= tegra_wario_init
,