blob: 5b687b8258c03b97cdec766ed5ed20969f0dc803 [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>
28
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,
Dan Williamsbf03f652012-04-10 14:10:53 -070051 .handle_break = tegra_serial_handle_break,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080052 .iotype = UPIO_MEM,
53 .regshift = 2,
54 .uartclk = 216000000,
55 }, {
56 .flags = 0,
57 }
58};
59
60static struct platform_device debug_uart = {
61 .name = "serial8250",
62 .id = PLAT8250_DEV_PLATFORM,
63 .dev = {
64 .platform_data = debug_uart_platform_data,
65 },
66};
67
68static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
69 /* name parent rate enabled */
70 { "uartb", "pll_p", 216000000, true},
71 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060072 { "pll_a", "pll_p_out1", 56448000, true },
73 { "pll_a_out0", "pll_a", 11289600, true },
74 { "cdev1", NULL, 0, true },
75 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060076 { "usbd", "clk_m", 12000000, true},
77 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080078 { NULL, NULL, 0, 0},
79};
80
81static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
82 {
83 .code = SW_LID,
84 .gpio = TEGRA_GPIO_LIDSWITCH,
85 .active_low = 0,
86 .desc = "Lid",
87 .type = EV_SW,
88 .wakeup = 1,
89 .debounce_interval = 1,
90 },
91 {
92 .code = KEY_POWER,
93 .gpio = TEGRA_GPIO_POWERKEY,
94 .active_low = 1,
95 .desc = "Power",
96 .type = EV_KEY,
97 .wakeup = 1,
98 },
99};
100
101static struct gpio_keys_platform_data seaboard_gpio_keys = {
102 .buttons = seaboard_gpio_keys_buttons,
103 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
104};
105
106static struct platform_device seaboard_gpio_keys_device = {
107 .name = "gpio-keys",
108 .id = -1,
109 .dev = {
110 .platform_data = &seaboard_gpio_keys,
111 }
112};
113
114static struct tegra_sdhci_platform_data sdhci_pdata1 = {
115 .cd_gpio = -1,
116 .wp_gpio = -1,
117 .power_gpio = -1,
118};
119
120static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700121 .cd_gpio = TEGRA_GPIO_SD2_CD,
122 .wp_gpio = TEGRA_GPIO_SD2_WP,
123 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800124};
125
126static struct tegra_sdhci_platform_data sdhci_pdata4 = {
127 .cd_gpio = -1,
128 .wp_gpio = -1,
129 .power_gpio = -1,
130 .is_8bit = 1,
131};
132
Stephen Warrena697e692011-08-08 14:35:14 -0600133static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
134 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
135 .gpio_hp_det = TEGRA_GPIO_HP_DET,
136 .gpio_hp_mute = -1,
137 .gpio_int_mic_en = -1,
138 .gpio_ext_mic_en = -1,
139};
140
141static struct platform_device seaboard_audio_device = {
142 .name = "tegra-snd-wm8903",
143 .id = 0,
144 .dev = {
145 .platform_data = &seaboard_audio_pdata,
146 },
147};
148
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800149static struct platform_device *seaboard_devices[] __initdata = {
150 &debug_uart,
151 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800152 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600153 &tegra_sdhci_device3,
154 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800155 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600156 &tegra_i2s_device1,
157 &tegra_das_device,
158 &tegra_pcm_device,
159 &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{
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
Stephen Warren21235522012-01-04 08:39:33 +0000217 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800218 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warren21235522012-01-04 08:39:33 +0000219
220 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
Stephen Warrena697e692011-08-08 14:35:14 -0600221 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800222
Stephen Warren29e9c682011-07-13 12:53:53 -0600223 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800224
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800225 platform_device_register(&tegra_i2c_device1);
226 platform_device_register(&tegra_i2c_device2);
227 platform_device_register(&tegra_i2c_device3);
228 platform_device_register(&tegra_i2c_device4);
229}
230
231static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800232{
233 seaboard_pinmux_init();
234
235 tegra_clk_init_from_table(seaboard_clk_init_table);
236
237 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
238 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
239 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
240
241 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600242
243 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800244}
245
246static void __init tegra_seaboard_init(void)
247{
248 /* Seaboard uses UARTD for the debug port. */
249 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
250 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
251 debug_uart_platform_data[0].irq = INT_UARTD;
252
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_kaen_init(void)
259{
260 /* Kaen 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
Stephen Warrena697e692011-08-08 14:35:14 -0600265 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
266 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
267
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800268 seaboard_common_init();
269
270 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800271}
272
273static void __init tegra_wario_init(void)
274{
275 /* Wario uses UARTB for the debug port. */
276 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
277 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
278 debug_uart_platform_data[0].irq = INT_UARTB;
279
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800280 seaboard_common_init();
281
282 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800283}
284
285
286MACHINE_START(SEABOARD, "seaboard")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400287 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800288 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200289 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800290 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100291 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800292 .timer = &tegra_timer,
293 .init_machine = tegra_seaboard_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000294 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800295MACHINE_END
296
297MACHINE_START(KAEN, "kaen")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400298 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800299 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200300 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800301 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100302 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800303 .timer = &tegra_timer,
304 .init_machine = tegra_kaen_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000305 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800306MACHINE_END
307
308MACHINE_START(WARIO, "wario")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400309 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800310 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200311 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800312 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100313 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800314 .timer = &tegra_timer,
315 .init_machine = tegra_wario_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000316 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800317MACHINE_END