blob: a0184fb4422291adf9940e81c48291f893132800 [file] [log] [blame]
Olof Johanssond9a51fe2011-02-19 17:25:32 -08001/*
2 * Copyright (c) 2010, 2011 NVIDIA Corporation.
3 * Copyright (C) 2010, 2011 Google, Inc.
4 *
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.
9 *
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.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/serial_8250.h>
Olof Johanssonf9a795a2011-03-04 15:21:53 -080021#include <linux/i2c.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080022#include <linux/delay.h>
23#include <linux/input.h>
24#include <linux/io.h>
Olof Johanssonf9a795a2011-03-04 15:21:53 -080025#include <linux/gpio.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080026#include <linux/gpio_keys.h>
Stephen Warren4bee6412012-03-16 16:08:29 -060027#include <linux/platform_data/tegra_usb.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080028
Stephen Warrena697e692011-08-08 14:35:14 -060029#include <sound/wm8903.h>
30
Olof Johanssond9a51fe2011-02-19 17:25:32 -080031#include <mach/iomap.h>
32#include <mach/irqs.h>
33#include <mach/sdhci.h>
Stephen Warrena697e692011-08-08 14:35:14 -060034#include <mach/tegra_wm8903_pdata.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080035
36#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
Marc Zyngierafed2a22011-09-06 10:23:45 +010038#include <asm/hardware/gic.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080039
40#include "board.h"
41#include "board-seaboard.h"
42#include "clock.h"
43#include "devices.h"
44#include "gpio-names.h"
45
46static struct plat_serial8250_port debug_uart_platform_data[] = {
47 {
48 /* Memory and IRQ filled in before registration */
Stephen Warren11b3adb2011-08-08 15:01:05 -060049 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
50 .type = PORT_TEGRA,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080051 .iotype = UPIO_MEM,
52 .regshift = 2,
53 .uartclk = 216000000,
54 }, {
55 .flags = 0,
56 }
57};
58
59static struct platform_device debug_uart = {
60 .name = "serial8250",
61 .id = PLAT8250_DEV_PLATFORM,
62 .dev = {
63 .platform_data = debug_uart_platform_data,
64 },
65};
66
67static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
68 /* name parent rate enabled */
69 { "uartb", "pll_p", 216000000, true},
70 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060071 { "pll_a", "pll_p_out1", 56448000, true },
72 { "pll_a_out0", "pll_a", 11289600, true },
73 { "cdev1", NULL, 0, true },
74 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060075 { "usbd", "clk_m", 12000000, true},
76 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080077 { NULL, NULL, 0, 0},
78};
79
80static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
81 {
82 .code = SW_LID,
83 .gpio = TEGRA_GPIO_LIDSWITCH,
84 .active_low = 0,
85 .desc = "Lid",
86 .type = EV_SW,
87 .wakeup = 1,
88 .debounce_interval = 1,
89 },
90 {
91 .code = KEY_POWER,
92 .gpio = TEGRA_GPIO_POWERKEY,
93 .active_low = 1,
94 .desc = "Power",
95 .type = EV_KEY,
96 .wakeup = 1,
97 },
98};
99
100static struct gpio_keys_platform_data seaboard_gpio_keys = {
101 .buttons = seaboard_gpio_keys_buttons,
102 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
103};
104
105static struct platform_device seaboard_gpio_keys_device = {
106 .name = "gpio-keys",
107 .id = -1,
108 .dev = {
109 .platform_data = &seaboard_gpio_keys,
110 }
111};
112
113static struct tegra_sdhci_platform_data sdhci_pdata1 = {
114 .cd_gpio = -1,
115 .wp_gpio = -1,
116 .power_gpio = -1,
117};
118
119static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700120 .cd_gpio = TEGRA_GPIO_SD2_CD,
121 .wp_gpio = TEGRA_GPIO_SD2_WP,
122 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800123};
124
125static struct tegra_sdhci_platform_data sdhci_pdata4 = {
126 .cd_gpio = -1,
127 .wp_gpio = -1,
128 .power_gpio = -1,
129 .is_8bit = 1,
130};
131
Stephen Warrena697e692011-08-08 14:35:14 -0600132static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
133 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
134 .gpio_hp_det = TEGRA_GPIO_HP_DET,
135 .gpio_hp_mute = -1,
136 .gpio_int_mic_en = -1,
137 .gpio_ext_mic_en = -1,
138};
139
140static struct platform_device seaboard_audio_device = {
141 .name = "tegra-snd-wm8903",
142 .id = 0,
143 .dev = {
144 .platform_data = &seaboard_audio_pdata,
145 },
146};
147
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800148static struct platform_device *seaboard_devices[] __initdata = {
149 &debug_uart,
150 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800151 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600152 &tegra_sdhci_device3,
153 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800154 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600155 &tegra_i2s_device1,
156 &tegra_das_device,
157 &tegra_pcm_device,
158 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800159};
160
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800161static struct i2c_board_info __initdata isl29018_device = {
162 I2C_BOARD_INFO("isl29018", 0x44),
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800163};
164
165static struct i2c_board_info __initdata adt7461_device = {
166 I2C_BOARD_INFO("adt7461", 0x4c),
167};
168
Stephen Warrena697e692011-08-08 14:35:14 -0600169static struct wm8903_platform_data wm8903_pdata = {
170 .irq_active_low = 0,
171 .micdet_cfg = 0,
172 .micdet_delay = 100,
173 .gpio_base = SEABOARD_GPIO_WM8903(0),
174 .gpio_cfg = {
Stephen Warrena697e692011-08-08 14:35:14 -0600175 0,
Stephen Warrena0f203d2011-12-02 15:08:37 -0700176 0,
177 WM8903_GPIO_CONFIG_ZERO,
178 0,
179 0,
Stephen Warrena697e692011-08-08 14:35:14 -0600180 },
181};
182
183static struct i2c_board_info __initdata wm8903_device = {
184 I2C_BOARD_INFO("wm8903", 0x1a),
185 .platform_data = &wm8903_pdata,
Stephen Warrena697e692011-08-08 14:35:14 -0600186};
187
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600188static int seaboard_ehci_init(void)
189{
Stephen Warren4bee6412012-03-16 16:08:29 -0600190 struct tegra_ehci_platform_data *pdata;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600191
Stephen Warren4bee6412012-03-16 16:08:29 -0600192 pdata = tegra_ehci1_device.dev.platform_data;
193 pdata->vbus_gpio = TEGRA_GPIO_USB1;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600194
195 platform_device_register(&tegra_ehci1_device);
196 platform_device_register(&tegra_ehci3_device);
197
198 return 0;
199}
200
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800201static void __init seaboard_i2c_init(void)
202{
Stephen Warren21235522012-01-04 08:39:33 +0000203 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800204 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warren21235522012-01-04 08:39:33 +0000205
206 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
Stephen Warrena697e692011-08-08 14:35:14 -0600207 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800208
Stephen Warren29e9c682011-07-13 12:53:53 -0600209 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800210
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800211 platform_device_register(&tegra_i2c_device1);
212 platform_device_register(&tegra_i2c_device2);
213 platform_device_register(&tegra_i2c_device3);
214 platform_device_register(&tegra_i2c_device4);
215}
216
217static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800218{
219 seaboard_pinmux_init();
220
221 tegra_clk_init_from_table(seaboard_clk_init_table);
222
223 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
224 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
225 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
226
227 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600228
229 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800230}
231
232static void __init tegra_seaboard_init(void)
233{
234 /* Seaboard uses UARTD for the debug port. */
235 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
236 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
237 debug_uart_platform_data[0].irq = INT_UARTD;
238
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800239 seaboard_common_init();
240
241 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800242}
243
244static void __init tegra_kaen_init(void)
245{
246 /* Kaen uses UARTB for the debug port. */
247 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
248 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
249 debug_uart_platform_data[0].irq = INT_UARTB;
250
Stephen Warrena697e692011-08-08 14:35:14 -0600251 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
Stephen Warrena697e692011-08-08 14:35:14 -0600252
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800253 seaboard_common_init();
254
255 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800256}
257
258static void __init tegra_wario_init(void)
259{
260 /* Wario 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;
264
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800265 seaboard_common_init();
266
267 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800268}
269
270
271MACHINE_START(SEABOARD, "seaboard")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400272 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800273 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200274 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800275 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100276 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800277 .timer = &tegra_timer,
278 .init_machine = tegra_seaboard_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000279 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800280MACHINE_END
281
282MACHINE_START(KAEN, "kaen")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400283 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800284 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200285 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800286 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100287 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800288 .timer = &tegra_timer,
289 .init_machine = tegra_kaen_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000290 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800291MACHINE_END
292
293MACHINE_START(WARIO, "wario")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400294 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800295 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200296 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800297 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100298 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800299 .timer = &tegra_timer,
300 .init_machine = tegra_wario_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000301 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800302MACHINE_END