blob: 6fa8c3d0f76e0dc47dfdd836f2d223de31d7e33e [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>
Stephen Warren4bee6412012-03-16 16:08:29 -060027#include <linux/platform_data/tegra_usb.h>
Olof Johanssond9a51fe2011-02-19 17:25:32 -080028
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,
Olof Johanssond9a51fe2011-02-19 17:25:32 -080051 .iotype = UPIO_MEM,
52 .regshift = 2,
53 .uartclk = 216000000,
54 }, {
55 .flags = 0,
56 }
57};
58
59static struct platform_device debug_uart = {
60 .name = "serial8250",
61 .id = PLAT8250_DEV_PLATFORM,
62 .dev = {
63 .platform_data = debug_uart_platform_data,
64 },
65};
66
67static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
68 /* name parent rate enabled */
69 { "uartb", "pll_p", 216000000, true},
70 { "uartd", "pll_p", 216000000, true},
Stephen Warrena697e692011-08-08 14:35:14 -060071 { "pll_a", "pll_p_out1", 56448000, true },
72 { "pll_a_out0", "pll_a", 11289600, true },
73 { "cdev1", NULL, 0, true },
74 { "i2s1", "pll_a_out0", 11289600, false},
Stephen Warrenbc24ed42011-08-08 14:35:15 -060075 { "usbd", "clk_m", 12000000, true},
76 { "usb3", "clk_m", 12000000, true},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080077 { NULL, NULL, 0, 0},
78};
79
80static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
81 {
82 .code = SW_LID,
83 .gpio = TEGRA_GPIO_LIDSWITCH,
84 .active_low = 0,
85 .desc = "Lid",
86 .type = EV_SW,
87 .wakeup = 1,
88 .debounce_interval = 1,
89 },
90 {
91 .code = KEY_POWER,
92 .gpio = TEGRA_GPIO_POWERKEY,
93 .active_low = 1,
94 .desc = "Power",
95 .type = EV_KEY,
96 .wakeup = 1,
97 },
98};
99
100static struct gpio_keys_platform_data seaboard_gpio_keys = {
101 .buttons = seaboard_gpio_keys_buttons,
102 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
103};
104
105static struct platform_device seaboard_gpio_keys_device = {
106 .name = "gpio-keys",
107 .id = -1,
108 .dev = {
109 .platform_data = &seaboard_gpio_keys,
110 }
111};
112
113static struct tegra_sdhci_platform_data sdhci_pdata1 = {
114 .cd_gpio = -1,
115 .wp_gpio = -1,
116 .power_gpio = -1,
117};
118
119static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700120 .cd_gpio = TEGRA_GPIO_SD2_CD,
121 .wp_gpio = TEGRA_GPIO_SD2_WP,
122 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800123};
124
125static struct tegra_sdhci_platform_data sdhci_pdata4 = {
126 .cd_gpio = -1,
127 .wp_gpio = -1,
128 .power_gpio = -1,
129 .is_8bit = 1,
130};
131
Stephen Warrena697e692011-08-08 14:35:14 -0600132static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
133 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
134 .gpio_hp_det = TEGRA_GPIO_HP_DET,
135 .gpio_hp_mute = -1,
136 .gpio_int_mic_en = -1,
137 .gpio_ext_mic_en = -1,
138};
139
140static struct platform_device seaboard_audio_device = {
141 .name = "tegra-snd-wm8903",
142 .id = 0,
143 .dev = {
144 .platform_data = &seaboard_audio_pdata,
145 },
146};
147
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800148static struct platform_device *seaboard_devices[] __initdata = {
149 &debug_uart,
150 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800151 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600152 &tegra_sdhci_device3,
153 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800154 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600155 &tegra_i2s_device1,
156 &tegra_das_device,
157 &tegra_pcm_device,
158 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800159};
160
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800161static struct i2c_board_info __initdata isl29018_device = {
162 I2C_BOARD_INFO("isl29018", 0x44),
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800163};
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 = {
Stephen Warrena697e692011-08-08 14:35:14 -0600175 0,
Stephen Warrena0f203d2011-12-02 15:08:37 -0700176 0,
177 WM8903_GPIO_CONFIG_ZERO,
178 0,
179 0,
Stephen Warrena697e692011-08-08 14:35:14 -0600180 },
181};
182
183static struct i2c_board_info __initdata wm8903_device = {
184 I2C_BOARD_INFO("wm8903", 0x1a),
185 .platform_data = &wm8903_pdata,
Stephen Warrena697e692011-08-08 14:35:14 -0600186};
187
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600188static int seaboard_ehci_init(void)
189{
Stephen Warren4bee6412012-03-16 16:08:29 -0600190 struct tegra_ehci_platform_data *pdata;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600191
Stephen Warren4bee6412012-03-16 16:08:29 -0600192 pdata = tegra_ehci1_device.dev.platform_data;
193 pdata->vbus_gpio = TEGRA_GPIO_USB1;
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600194
195 platform_device_register(&tegra_ehci1_device);
196 platform_device_register(&tegra_ehci3_device);
197
198 return 0;
199}
200
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800201static void __init seaboard_i2c_init(void)
202{
203 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
204 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
205
Stephen Warren21235522012-01-04 08:39:33 +0000206 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800207 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warren21235522012-01-04 08:39:33 +0000208
209 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
Stephen Warrena697e692011-08-08 14:35:14 -0600210 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800211
Stephen Warren29e9c682011-07-13 12:53:53 -0600212 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800213
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800214 platform_device_register(&tegra_i2c_device1);
215 platform_device_register(&tegra_i2c_device2);
216 platform_device_register(&tegra_i2c_device3);
217 platform_device_register(&tegra_i2c_device4);
218}
219
220static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800221{
222 seaboard_pinmux_init();
223
224 tegra_clk_init_from_table(seaboard_clk_init_table);
225
226 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
227 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
228 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
229
230 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
Stephen Warrenbc24ed42011-08-08 14:35:15 -0600231
232 seaboard_ehci_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800233}
234
235static void __init tegra_seaboard_init(void)
236{
237 /* Seaboard uses UARTD for the debug port. */
238 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
239 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
240 debug_uart_platform_data[0].irq = INT_UARTD;
241
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800242 seaboard_common_init();
243
244 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800245}
246
247static void __init tegra_kaen_init(void)
248{
249 /* Kaen uses UARTB for the debug port. */
250 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
251 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
252 debug_uart_platform_data[0].irq = INT_UARTB;
253
Stephen Warrena697e692011-08-08 14:35:14 -0600254 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
255 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
256
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800257 seaboard_common_init();
258
259 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800260}
261
262static void __init tegra_wario_init(void)
263{
264 /* Wario uses UARTB for the debug port. */
265 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
266 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
267 debug_uart_platform_data[0].irq = INT_UARTB;
268
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800269 seaboard_common_init();
270
271 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800272}
273
274
275MACHINE_START(SEABOARD, "seaboard")
Nicolas Pitreb61cafe2011-07-05 22:38:18 -0400276 .atag_offset = 0x100,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800277 .map_io = tegra_map_common_io,
Peter De Schrijverc37c07d2011-12-14 17:03:17 +0200278 .init_early = tegra20_init_early,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800279 .init_irq = tegra_init_irq,
Marc Zyngierafed2a22011-09-06 10:23:45 +0100280 .handle_irq = gic_handle_irq,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800281 .timer = &tegra_timer,
282 .init_machine = tegra_seaboard_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000283 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800284MACHINE_END
285
286MACHINE_START(KAEN, "kaen")
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_kaen_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(WARIO, "wario")
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_wario_init,
Russell Kingabea3f22011-11-05 08:48:33 +0000305 .restart = tegra_assert_system_reset,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800306MACHINE_END