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/of_serial.h>
22 #include <linux/i2c.h>
23 #include <linux/delay.h>
24 #include <linux/input.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>
41 #include "board-seaboard.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
,
51 .handle_break
= tegra_serial_handle_break
,
60 static struct platform_device debug_uart
= {
62 .id
= PLAT8250_DEV_PLATFORM
,
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},
81 static struct gpio_keys_button seaboard_gpio_keys_buttons
[] = {
84 .gpio
= TEGRA_GPIO_LIDSWITCH
,
89 .debounce_interval
= 1,
93 .gpio
= TEGRA_GPIO_POWERKEY
,
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
= {
110 .platform_data
= &seaboard_gpio_keys
,
114 static struct tegra_sdhci_platform_data sdhci_pdata1
= {
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
= {
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
,
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",
145 .platform_data
= &seaboard_audio_pdata
,
149 static struct platform_device
*seaboard_devices
[] __initdata
= {
152 &tegra_sdhci_device4
,
153 &tegra_sdhci_device3
,
154 &tegra_sdhci_device1
,
155 &seaboard_gpio_keys_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
= {
174 .gpio_base
= SEABOARD_GPIO_WM8903(0),
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)
193 gpio_status
= gpio_request(TEGRA_GPIO_USB1
, "VBUS_USB1");
194 if (gpio_status
< 0) {
195 pr_err("VBUS_USB1 request GPIO FAILED\n");
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");
204 gpio_set_value(TEGRA_GPIO_USB1
, 1);
206 platform_device_register(&tegra_ehci1_device
);
207 platform_device_register(&tegra_ehci3_device
);
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();
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();
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();
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
,
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
,
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
,