blob: cfc74d46a09e40d30caaf5a8dac712a733c8cc48 [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>
Marc Zyngierafed2a22011-09-06 10:23:45 +010037#include <asm/hardware/gic.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080038
39#include "board.h"
40#include "board-seaboard.h"
41#include "clock.h"
42#include "devices.h"
43#include "gpio-names.h"
44
45static struct plat_serial8250_port debug_uart_platform_data[] = {
46 {
47 /* Memory and IRQ filled in before registration */
Stephen Warren11b3adb2011-08-08 15:01:05 -060048 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
49 .type = PORT_TEGRA,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080050 .iotype = UPIO_MEM,
51 .regshift = 2,
52 .uartclk = 216000000,
53 }, {
54 .flags = 0,
55 }
56};
57
58static struct platform_device debug_uart = {
59 .name = "serial8250",
60 .id = PLAT8250_DEV_PLATFORM,
61 .dev = {
62 .platform_data = debug_uart_platform_data,
63 },
64};
65
66static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
67 /* name parent rate enabled */
68 { "uartb", "pll_p", 216000000, true},
69 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060070 { "pll_a", "pll_p_out1", 56448000, true },
71 { "pll_a_out0", "pll_a", 11289600, true },
72 { "cdev1", NULL, 0, true },
73 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060074 { "usbd", "clk_m", 12000000, true},
75 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080076 { NULL, NULL, 0, 0},
77};
78
79static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
80 {
81 .code = SW_LID,
82 .gpio = TEGRA_GPIO_LIDSWITCH,
83 .active_low = 0,
84 .desc = "Lid",
85 .type = EV_SW,
86 .wakeup = 1,
87 .debounce_interval = 1,
88 },
89 {
90 .code = KEY_POWER,
91 .gpio = TEGRA_GPIO_POWERKEY,
92 .active_low = 1,
93 .desc = "Power",
94 .type = EV_KEY,
95 .wakeup = 1,
96 },
97};
98
99static struct gpio_keys_platform_data seaboard_gpio_keys = {
100 .buttons = seaboard_gpio_keys_buttons,
101 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
102};
103
104static struct platform_device seaboard_gpio_keys_device = {
105 .name = "gpio-keys",
106 .id = -1,
107 .dev = {
108 .platform_data = &seaboard_gpio_keys,
109 }
110};
111
112static struct tegra_sdhci_platform_data sdhci_pdata1 = {
113 .cd_gpio = -1,
114 .wp_gpio = -1,
115 .power_gpio = -1,
116};
117
118static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700119 .cd_gpio = TEGRA_GPIO_SD2_CD,
120 .wp_gpio = TEGRA_GPIO_SD2_WP,
121 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800122};
123
124static struct tegra_sdhci_platform_data sdhci_pdata4 = {
125 .cd_gpio = -1,
126 .wp_gpio = -1,
127 .power_gpio = -1,
128 .is_8bit = 1,
129};
130
Stephen Warrena697e692011-08-08 14:35:14 -0600131static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
132 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
133 .gpio_hp_det = TEGRA_GPIO_HP_DET,
134 .gpio_hp_mute = -1,
135 .gpio_int_mic_en = -1,
136 .gpio_ext_mic_en = -1,
137};
138
139static struct platform_device seaboard_audio_device = {
140 .name = "tegra-snd-wm8903",
141 .id = 0,
142 .dev = {
143 .platform_data = &seaboard_audio_pdata,
144 },
145};
146
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800147static struct platform_device *seaboard_devices[] __initdata = {
148 &debug_uart,
149 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800150 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600151 &tegra_sdhci_device3,
152 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800153 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600154 &tegra_i2s_device1,
155 &tegra_das_device,
156 &tegra_pcm_device,
157 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800158};
159
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800160static struct i2c_board_info __initdata isl29018_device = {
161 I2C_BOARD_INFO("isl29018", 0x44),
162 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
163};
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 = {
175 WM8903_GPIO_NO_CONFIG,
176 WM8903_GPIO_NO_CONFIG,
177 0,
178 WM8903_GPIO_NO_CONFIG,
179 WM8903_GPIO_NO_CONFIG,
180 },
181};
182
183static struct i2c_board_info __initdata wm8903_device = {
184 I2C_BOARD_INFO("wm8903", 0x1a),
185 .platform_data = &wm8903_pdata,
186 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
187};
188
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600189static int seaboard_ehci_init(void)
190{
191 int gpio_status;
192
193 gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1");
194 if (gpio_status < 0) {
195 pr_err("VBUS_USB1 request GPIO FAILED\n");
196 WARN_ON(1);
197 }
198
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");
202 WARN_ON(1);
203 }
204 gpio_set_value(TEGRA_GPIO_USB1, 1);
205
206 platform_device_register(&tegra_ehci1_device);
207 platform_device_register(&tegra_ehci3_device);
208
209 return 0;
210}
211
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800212static void __init seaboard_i2c_init(void)
213{
214 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
215 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
216
217 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warrena697e692011-08-08 14:35:14 -0600218 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800219
Stephen Warren29e9c682011-07-13 12:53:53 -0600220 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800221
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800222 platform_device_register(&tegra_i2c_device1);
223 platform_device_register(&tegra_i2c_device2);
224 platform_device_register(&tegra_i2c_device3);
225 platform_device_register(&tegra_i2c_device4);
226}
227
228static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800229{
230 seaboard_pinmux_init();
231
232 tegra_clk_init_from_table(seaboard_clk_init_table);
233
234 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
235 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
236 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
237
238 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600239
240 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800241}
242
243static void __init tegra_seaboard_init(void)
244{
245 /* Seaboard uses UARTD for the debug port. */
246 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
247 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
248 debug_uart_platform_data[0].irq = INT_UARTD;
249
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800250 seaboard_common_init();
251
252 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800253}
254
255static void __init tegra_kaen_init(void)
256{
257 /* Kaen uses UARTB for the debug port. */
258 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
259 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
260 debug_uart_platform_data[0].irq = INT_UARTB;
261
Stephen Warrena697e692011-08-08 14:35:14 -0600262 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
263 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
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
270static void __init tegra_wario_init(void)
271{
272 /* Wario uses UARTB for the debug port. */
273 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
274 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
275 debug_uart_platform_data[0].irq = INT_UARTB;
276
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800277 seaboard_common_init();
278
279 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800280}
281
282
283MACHINE_START(SEABOARD, "seaboard")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400284 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800285 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200286 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800287 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100288 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800289 .timer = &tegra_timer,
290 .init_machine = tegra_seaboard_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000291 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800292MACHINE_END
293
294MACHINE_START(KAEN, "kaen")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400295 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800296 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200297 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800298 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100299 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800300 .timer = &tegra_timer,
301 .init_machine = tegra_kaen_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000302 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800303MACHINE_END
304
305MACHINE_START(WARIO, "wario")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400306 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800307 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200308 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800309 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100310 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800311 .timer = &tegra_timer,
312 .init_machine = tegra_wario_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000313 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800314MACHINE_END