blob: 9b2eca1f5283c0c5c285a1942952ee971a6b8cd5 [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>
27
Stephen Warrena697e692011-08-08 14:35:14 -060028#include <sound/wm8903.h>
29
Olof Johanssond9a51fe2011-02-19 17:25:32 -080030#include <mach/iomap.h>
31#include <mach/irqs.h>
32#include <mach/sdhci.h>
Stephen Warrena697e692011-08-08 14:35:14 -060033#include <mach/tegra_wm8903_pdata.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080034
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37
38#include "board.h"
39#include "board-seaboard.h"
40#include "clock.h"
41#include "devices.h"
42#include "gpio-names.h"
43
44static struct plat_serial8250_port debug_uart_platform_data[] = {
45 {
46 /* Memory and IRQ filled in before registration */
Stephen Warren11b3adb2011-08-08 15:01:05 -060047 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
48 .type = PORT_TEGRA,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080049 .iotype = UPIO_MEM,
50 .regshift = 2,
51 .uartclk = 216000000,
52 }, {
53 .flags = 0,
54 }
55};
56
57static struct platform_device debug_uart = {
58 .name = "serial8250",
59 .id = PLAT8250_DEV_PLATFORM,
60 .dev = {
61 .platform_data = debug_uart_platform_data,
62 },
63};
64
65static __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},
Stephen Warrena697e692011-08-08 14:35:14 -060069 { "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},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060073 { "usbd", "clk_m", 12000000, true},
74 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080075 { NULL, NULL, 0, 0},
76};
77
78static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
79 {
80 .code = SW_LID,
81 .gpio = TEGRA_GPIO_LIDSWITCH,
82 .active_low = 0,
83 .desc = "Lid",
84 .type = EV_SW,
85 .wakeup = 1,
86 .debounce_interval = 1,
87 },
88 {
89 .code = KEY_POWER,
90 .gpio = TEGRA_GPIO_POWERKEY,
91 .active_low = 1,
92 .desc = "Power",
93 .type = EV_KEY,
94 .wakeup = 1,
95 },
96};
97
98static struct gpio_keys_platform_data seaboard_gpio_keys = {
99 .buttons = seaboard_gpio_keys_buttons,
100 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
101};
102
103static struct platform_device seaboard_gpio_keys_device = {
104 .name = "gpio-keys",
105 .id = -1,
106 .dev = {
107 .platform_data = &seaboard_gpio_keys,
108 }
109};
110
111static struct tegra_sdhci_platform_data sdhci_pdata1 = {
112 .cd_gpio = -1,
113 .wp_gpio = -1,
114 .power_gpio = -1,
115};
116
117static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700118 .cd_gpio = TEGRA_GPIO_SD2_CD,
119 .wp_gpio = TEGRA_GPIO_SD2_WP,
120 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800121};
122
123static struct tegra_sdhci_platform_data sdhci_pdata4 = {
124 .cd_gpio = -1,
125 .wp_gpio = -1,
126 .power_gpio = -1,
127 .is_8bit = 1,
128};
129
Stephen Warrena697e692011-08-08 14:35:14 -0600130static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
131 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
132 .gpio_hp_det = TEGRA_GPIO_HP_DET,
133 .gpio_hp_mute = -1,
134 .gpio_int_mic_en = -1,
135 .gpio_ext_mic_en = -1,
136};
137
138static struct platform_device seaboard_audio_device = {
139 .name = "tegra-snd-wm8903",
140 .id = 0,
141 .dev = {
142 .platform_data = &seaboard_audio_pdata,
143 },
144};
145
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800146static struct platform_device *seaboard_devices[] __initdata = {
147 &debug_uart,
148 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800149 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600150 &tegra_sdhci_device3,
151 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800152 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600153 &tegra_i2s_device1,
154 &tegra_das_device,
155 &tegra_pcm_device,
156 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800157};
158
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800159static struct i2c_board_info __initdata isl29018_device = {
160 I2C_BOARD_INFO("isl29018", 0x44),
161 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
162};
163
164static struct i2c_board_info __initdata adt7461_device = {
165 I2C_BOARD_INFO("adt7461", 0x4c),
166};
167
Stephen Warrena697e692011-08-08 14:35:14 -0600168static struct wm8903_platform_data wm8903_pdata = {
169 .irq_active_low = 0,
170 .micdet_cfg = 0,
171 .micdet_delay = 100,
172 .gpio_base = SEABOARD_GPIO_WM8903(0),
173 .gpio_cfg = {
174 WM8903_GPIO_NO_CONFIG,
175 WM8903_GPIO_NO_CONFIG,
176 0,
177 WM8903_GPIO_NO_CONFIG,
178 WM8903_GPIO_NO_CONFIG,
179 },
180};
181
182static 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),
186};
187
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600188static int seaboard_ehci_init(void)
189{
190 int gpio_status;
191
192 gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1");
193 if (gpio_status < 0) {
194 pr_err("VBUS_USB1 request GPIO FAILED\n");
195 WARN_ON(1);
196 }
197
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");
201 WARN_ON(1);
202 }
203 gpio_set_value(TEGRA_GPIO_USB1, 1);
204
205 platform_device_register(&tegra_ehci1_device);
206 platform_device_register(&tegra_ehci3_device);
207
208 return 0;
209}
210
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800211static void __init seaboard_i2c_init(void)
212{
213 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
214 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
215
216 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warrena697e692011-08-08 14:35:14 -0600217 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800218
Stephen Warren29e9c682011-07-13 12:53:53 -0600219 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800220
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800221 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);
225}
226
227static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800228{
229 seaboard_pinmux_init();
230
231 tegra_clk_init_from_table(seaboard_clk_init_table);
232
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;
236
237 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600238
239 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800240}
241
242static void __init tegra_seaboard_init(void)
243{
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;
248
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800249 seaboard_common_init();
250
251 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800252}
253
254static void __init tegra_kaen_init(void)
255{
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;
260
Stephen Warrena697e692011-08-08 14:35:14 -0600261 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
262 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
263
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800264 seaboard_common_init();
265
266 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800267}
268
269static void __init tegra_wario_init(void)
270{
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;
275
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800276 seaboard_common_init();
277
278 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800279}
280
281
282MACHINE_START(SEABOARD, "seaboard")
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,
285 .init_early = tegra_init_early,
286 .init_irq = tegra_init_irq,
287 .timer = &tegra_timer,
288 .init_machine = tegra_seaboard_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000289 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800290MACHINE_END
291
292MACHINE_START(KAEN, "kaen")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400293 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800294 .map_io = tegra_map_common_io,
295 .init_early = tegra_init_early,
296 .init_irq = tegra_init_irq,
297 .timer = &tegra_timer,
298 .init_machine = tegra_kaen_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000299 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800300MACHINE_END
301
302MACHINE_START(WARIO, "wario")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400303 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800304 .map_io = tegra_map_common_io,
305 .init_early = tegra_init_early,
306 .init_irq = tegra_init_irq,
307 .timer = &tegra_timer,
308 .init_machine = tegra_wario_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000309 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800310MACHINE_END