blob: 71e9f3fc7fba28ffbd893c978342d3c7ad7c53e5 [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>
Dan Williamsbf03f652012-04-10 14:10:53 -070021#include <linux/of_serial.h>
Olof Johanssonf9a795a2011-03-04 15:21:53 -080022#include <linux/i2c.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080023#include <linux/delay.h>
24#include <linux/input.h>
25#include <linux/io.h>
Olof Johanssonf9a795a2011-03-04 15:21:53 -080026#include <linux/gpio.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080027#include <linux/gpio_keys.h>
Stephen Warren4bee6412012-03-16 16:08:29 -060028#include <linux/platform_data/tegra_usb.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080029
Stephen Warrena697e692011-08-08 14:35:14 -060030#include <sound/wm8903.h>
31
Olof Johanssond9a51fe2011-02-19 17:25:32 -080032#include <mach/iomap.h>
33#include <mach/irqs.h>
34#include <mach/sdhci.h>
Stephen Warrena697e692011-08-08 14:35:14 -060035#include <mach/tegra_wm8903_pdata.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080036
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
Marc Zyngierafed2a22011-09-06 10:23:45 +010039#include <asm/hardware/gic.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080040
41#include "board.h"
42#include "board-seaboard.h"
43#include "clock.h"
44#include "devices.h"
45#include "gpio-names.h"
46
47static struct plat_serial8250_port debug_uart_platform_data[] = {
48 {
49 /* Memory and IRQ filled in before registration */
Stephen Warren11b3adb2011-08-08 15:01:05 -060050 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
51 .type = PORT_TEGRA,
Dan Williamsbf03f652012-04-10 14:10:53 -070052 .handle_break = tegra_serial_handle_break,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080053 .iotype = UPIO_MEM,
54 .regshift = 2,
55 .uartclk = 216000000,
56 }, {
57 .flags = 0,
58 }
59};
60
61static struct platform_device debug_uart = {
62 .name = "serial8250",
63 .id = PLAT8250_DEV_PLATFORM,
64 .dev = {
65 .platform_data = debug_uart_platform_data,
66 },
67};
68
69static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
70 /* name parent rate enabled */
71 { "uartb", "pll_p", 216000000, true},
72 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060073 { "pll_a", "pll_p_out1", 56448000, true },
74 { "pll_a_out0", "pll_a", 11289600, true },
75 { "cdev1", NULL, 0, true },
76 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060077 { "usbd", "clk_m", 12000000, true},
78 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080079 { NULL, NULL, 0, 0},
80};
81
82static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
83 {
84 .code = SW_LID,
85 .gpio = TEGRA_GPIO_LIDSWITCH,
86 .active_low = 0,
87 .desc = "Lid",
88 .type = EV_SW,
89 .wakeup = 1,
90 .debounce_interval = 1,
91 },
92 {
93 .code = KEY_POWER,
94 .gpio = TEGRA_GPIO_POWERKEY,
95 .active_low = 1,
96 .desc = "Power",
97 .type = EV_KEY,
98 .wakeup = 1,
99 },
100};
101
102static struct gpio_keys_platform_data seaboard_gpio_keys = {
103 .buttons = seaboard_gpio_keys_buttons,
104 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
105};
106
107static struct platform_device seaboard_gpio_keys_device = {
108 .name = "gpio-keys",
109 .id = -1,
110 .dev = {
111 .platform_data = &seaboard_gpio_keys,
112 }
113};
114
115static struct tegra_sdhci_platform_data sdhci_pdata1 = {
116 .cd_gpio = -1,
117 .wp_gpio = -1,
118 .power_gpio = -1,
119};
120
121static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700122 .cd_gpio = TEGRA_GPIO_SD2_CD,
123 .wp_gpio = TEGRA_GPIO_SD2_WP,
124 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800125};
126
127static struct tegra_sdhci_platform_data sdhci_pdata4 = {
128 .cd_gpio = -1,
129 .wp_gpio = -1,
130 .power_gpio = -1,
131 .is_8bit = 1,
132};
133
Stephen Warrena697e692011-08-08 14:35:14 -0600134static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
135 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
136 .gpio_hp_det = TEGRA_GPIO_HP_DET,
137 .gpio_hp_mute = -1,
138 .gpio_int_mic_en = -1,
139 .gpio_ext_mic_en = -1,
140};
141
142static struct platform_device seaboard_audio_device = {
143 .name = "tegra-snd-wm8903",
144 .id = 0,
145 .dev = {
146 .platform_data = &seaboard_audio_pdata,
147 },
148};
149
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800150static struct platform_device *seaboard_devices[] __initdata = {
151 &debug_uart,
152 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800153 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600154 &tegra_sdhci_device3,
155 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800156 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600157 &tegra_i2s_device1,
158 &tegra_das_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600159 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800160};
161
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800162static struct i2c_board_info __initdata isl29018_device = {
163 I2C_BOARD_INFO("isl29018", 0x44),
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800164};
165
166static struct i2c_board_info __initdata adt7461_device = {
167 I2C_BOARD_INFO("adt7461", 0x4c),
168};
169
Stephen Warrena697e692011-08-08 14:35:14 -0600170static 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 = {
Stephen Warrena697e692011-08-08 14:35:14 -0600176 0,
Stephen Warrena0f203d2011-12-02 15:08:37 -0700177 0,
178 WM8903_GPIO_CONFIG_ZERO,
179 0,
180 0,
Stephen Warrena697e692011-08-08 14:35:14 -0600181 },
182};
183
184static struct i2c_board_info __initdata wm8903_device = {
185 I2C_BOARD_INFO("wm8903", 0x1a),
186 .platform_data = &wm8903_pdata,
Stephen Warrena697e692011-08-08 14:35:14 -0600187};
188
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600189static int seaboard_ehci_init(void)
190{
Stephen Warren4bee6412012-03-16 16:08:29 -0600191 struct tegra_ehci_platform_data *pdata;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600192
Stephen Warren4bee6412012-03-16 16:08:29 -0600193 pdata = tegra_ehci1_device.dev.platform_data;
194 pdata->vbus_gpio = TEGRA_GPIO_USB1;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600195
196 platform_device_register(&tegra_ehci1_device);
197 platform_device_register(&tegra_ehci3_device);
198
199 return 0;
200}
201
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800202static void __init seaboard_i2c_init(void)
203{
Stephen Warren21235522012-01-04 08:39:33 +0000204 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800205 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warren21235522012-01-04 08:39:33 +0000206
207 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
Stephen Warrena697e692011-08-08 14:35:14 -0600208 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800209
Stephen Warren29e9c682011-07-13 12:53:53 -0600210 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800211
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800212 platform_device_register(&tegra_i2c_device1);
213 platform_device_register(&tegra_i2c_device2);
214 platform_device_register(&tegra_i2c_device3);
215 platform_device_register(&tegra_i2c_device4);
216}
217
218static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800219{
220 seaboard_pinmux_init();
221
222 tegra_clk_init_from_table(seaboard_clk_init_table);
223
224 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
225 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
226 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
227
228 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600229
230 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800231}
232
233static void __init tegra_seaboard_init(void)
234{
235 /* Seaboard uses UARTD for the debug port. */
236 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
237 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
238 debug_uart_platform_data[0].irq = INT_UARTD;
239
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800240 seaboard_common_init();
241
242 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800243}
244
245static void __init tegra_kaen_init(void)
246{
247 /* Kaen uses UARTB for the debug port. */
248 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
249 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
250 debug_uart_platform_data[0].irq = INT_UARTB;
251
Stephen Warrena697e692011-08-08 14:35:14 -0600252 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
Stephen Warrena697e692011-08-08 14:35:14 -0600253
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800254 seaboard_common_init();
255
256 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800257}
258
259static void __init tegra_wario_init(void)
260{
261 /* Wario uses UARTB for the debug port. */
262 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
263 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
264 debug_uart_platform_data[0].irq = INT_UARTB;
265
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800266 seaboard_common_init();
267
268 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800269}
270
271
272MACHINE_START(SEABOARD, "seaboard")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400273 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800274 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200275 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800276 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100277 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800278 .timer = &tegra_timer,
279 .init_machine = tegra_seaboard_init,
Shawn Guo390e0cf2012-05-02 17:08:06 +0800280 .init_late = tegra_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000281 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800282MACHINE_END
283
284MACHINE_START(KAEN, "kaen")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400285 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800286 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200287 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800288 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100289 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800290 .timer = &tegra_timer,
291 .init_machine = tegra_kaen_init,
Shawn Guo390e0cf2012-05-02 17:08:06 +0800292 .init_late = tegra_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000293 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800294MACHINE_END
295
296MACHINE_START(WARIO, "wario")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400297 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800298 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200299 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800300 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100301 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800302 .timer = &tegra_timer,
303 .init_machine = tegra_wario_init,
Shawn Guo390e0cf2012-05-02 17:08:06 +0800304 .init_late = tegra_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000305 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800306MACHINE_END