blob: 237a94a1f44a86df088ec46663af119f79da18f9 [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 */
47 .flags = UPF_BOOT_AUTOCONF,
48 .iotype = UPIO_MEM,
49 .regshift = 2,
50 .uartclk = 216000000,
51 }, {
52 .flags = 0,
53 }
54};
55
56static struct platform_device debug_uart = {
57 .name = "serial8250",
58 .id = PLAT8250_DEV_PLATFORM,
59 .dev = {
60 .platform_data = debug_uart_platform_data,
61 },
62};
63
64static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
65 /* name parent rate enabled */
66 { "uartb", "pll_p", 216000000, true},
67 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060068 { "pll_a", "pll_p_out1", 56448000, true },
69 { "pll_a_out0", "pll_a", 11289600, true },
70 { "cdev1", NULL, 0, true },
71 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060072 { "usbd", "clk_m", 12000000, true},
73 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080074 { NULL, NULL, 0, 0},
75};
76
77static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
78 {
79 .code = SW_LID,
80 .gpio = TEGRA_GPIO_LIDSWITCH,
81 .active_low = 0,
82 .desc = "Lid",
83 .type = EV_SW,
84 .wakeup = 1,
85 .debounce_interval = 1,
86 },
87 {
88 .code = KEY_POWER,
89 .gpio = TEGRA_GPIO_POWERKEY,
90 .active_low = 1,
91 .desc = "Power",
92 .type = EV_KEY,
93 .wakeup = 1,
94 },
95};
96
97static struct gpio_keys_platform_data seaboard_gpio_keys = {
98 .buttons = seaboard_gpio_keys_buttons,
99 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
100};
101
102static struct platform_device seaboard_gpio_keys_device = {
103 .name = "gpio-keys",
104 .id = -1,
105 .dev = {
106 .platform_data = &seaboard_gpio_keys,
107 }
108};
109
110static struct tegra_sdhci_platform_data sdhci_pdata1 = {
111 .cd_gpio = -1,
112 .wp_gpio = -1,
113 .power_gpio = -1,
114};
115
116static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700117 .cd_gpio = TEGRA_GPIO_SD2_CD,
118 .wp_gpio = TEGRA_GPIO_SD2_WP,
119 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800120};
121
122static struct tegra_sdhci_platform_data sdhci_pdata4 = {
123 .cd_gpio = -1,
124 .wp_gpio = -1,
125 .power_gpio = -1,
126 .is_8bit = 1,
127};
128
Stephen Warrena697e692011-08-08 14:35:14 -0600129static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
130 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
131 .gpio_hp_det = TEGRA_GPIO_HP_DET,
132 .gpio_hp_mute = -1,
133 .gpio_int_mic_en = -1,
134 .gpio_ext_mic_en = -1,
135};
136
137static struct platform_device seaboard_audio_device = {
138 .name = "tegra-snd-wm8903",
139 .id = 0,
140 .dev = {
141 .platform_data = &seaboard_audio_pdata,
142 },
143};
144
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800145static struct platform_device *seaboard_devices[] __initdata = {
146 &debug_uart,
147 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800148 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600149 &tegra_sdhci_device3,
150 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800151 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600152 &tegra_i2s_device1,
153 &tegra_das_device,
154 &tegra_pcm_device,
155 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800156};
157
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800158static struct i2c_board_info __initdata isl29018_device = {
159 I2C_BOARD_INFO("isl29018", 0x44),
160 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
161};
162
163static struct i2c_board_info __initdata adt7461_device = {
164 I2C_BOARD_INFO("adt7461", 0x4c),
165};
166
Stephen Warrena697e692011-08-08 14:35:14 -0600167static struct wm8903_platform_data wm8903_pdata = {
168 .irq_active_low = 0,
169 .micdet_cfg = 0,
170 .micdet_delay = 100,
171 .gpio_base = SEABOARD_GPIO_WM8903(0),
172 .gpio_cfg = {
173 WM8903_GPIO_NO_CONFIG,
174 WM8903_GPIO_NO_CONFIG,
175 0,
176 WM8903_GPIO_NO_CONFIG,
177 WM8903_GPIO_NO_CONFIG,
178 },
179};
180
181static struct i2c_board_info __initdata wm8903_device = {
182 I2C_BOARD_INFO("wm8903", 0x1a),
183 .platform_data = &wm8903_pdata,
184 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
185};
186
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600187static int seaboard_ehci_init(void)
188{
189 int gpio_status;
190
191 gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1");
192 if (gpio_status < 0) {
193 pr_err("VBUS_USB1 request GPIO FAILED\n");
194 WARN_ON(1);
195 }
196
197 gpio_status = gpio_direction_output(TEGRA_GPIO_USB1, 1);
198 if (gpio_status < 0) {
199 pr_err("VBUS_USB1 request GPIO DIRECTION FAILED\n");
200 WARN_ON(1);
201 }
202 gpio_set_value(TEGRA_GPIO_USB1, 1);
203
204 platform_device_register(&tegra_ehci1_device);
205 platform_device_register(&tegra_ehci3_device);
206
207 return 0;
208}
209
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800210static void __init seaboard_i2c_init(void)
211{
212 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
213 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
214
215 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warrena697e692011-08-08 14:35:14 -0600216 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800217
Stephen Warren29e9c682011-07-13 12:53:53 -0600218 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800219
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800220 platform_device_register(&tegra_i2c_device1);
221 platform_device_register(&tegra_i2c_device2);
222 platform_device_register(&tegra_i2c_device3);
223 platform_device_register(&tegra_i2c_device4);
224}
225
226static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800227{
228 seaboard_pinmux_init();
229
230 tegra_clk_init_from_table(seaboard_clk_init_table);
231
232 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
233 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
234 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
235
236 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600237
238 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800239}
240
241static void __init tegra_seaboard_init(void)
242{
243 /* Seaboard uses UARTD for the debug port. */
244 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
245 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
246 debug_uart_platform_data[0].irq = INT_UARTD;
247
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800248 seaboard_common_init();
249
250 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800251}
252
253static void __init tegra_kaen_init(void)
254{
255 /* Kaen uses UARTB for the debug port. */
256 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
257 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
258 debug_uart_platform_data[0].irq = INT_UARTB;
259
Stephen Warrena697e692011-08-08 14:35:14 -0600260 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
261 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
262
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800263 seaboard_common_init();
264
265 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800266}
267
268static void __init tegra_wario_init(void)
269{
270 /* Wario uses UARTB for the debug port. */
271 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
272 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
273 debug_uart_platform_data[0].irq = INT_UARTB;
274
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800275 seaboard_common_init();
276
277 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800278}
279
280
281MACHINE_START(SEABOARD, "seaboard")
282 .boot_params = 0x00000100,
283 .map_io = tegra_map_common_io,
284 .init_early = tegra_init_early,
285 .init_irq = tegra_init_irq,
286 .timer = &tegra_timer,
287 .init_machine = tegra_seaboard_init,
288MACHINE_END
289
290MACHINE_START(KAEN, "kaen")
291 .boot_params = 0x00000100,
292 .map_io = tegra_map_common_io,
293 .init_early = tegra_init_early,
294 .init_irq = tegra_init_irq,
295 .timer = &tegra_timer,
296 .init_machine = tegra_kaen_init,
297MACHINE_END
298
299MACHINE_START(WARIO, "wario")
300 .boot_params = 0x00000100,
301 .map_io = tegra_map_common_io,
302 .init_early = tegra_init_early,
303 .init_irq = tegra_init_irq,
304 .timer = &tegra_timer,
305 .init_machine = tegra_wario_init,
306MACHINE_END