blob: 07cd8e4885c952476791f0c94a7903ffbc1c3fc1 [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},
Olof Johanssond9a51fe2011-02-19 17:25:32 -080072 { NULL, NULL, 0, 0},
73};
74
75static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
76 {
77 .code = SW_LID,
78 .gpio = TEGRA_GPIO_LIDSWITCH,
79 .active_low = 0,
80 .desc = "Lid",
81 .type = EV_SW,
82 .wakeup = 1,
83 .debounce_interval = 1,
84 },
85 {
86 .code = KEY_POWER,
87 .gpio = TEGRA_GPIO_POWERKEY,
88 .active_low = 1,
89 .desc = "Power",
90 .type = EV_KEY,
91 .wakeup = 1,
92 },
93};
94
95static struct gpio_keys_platform_data seaboard_gpio_keys = {
96 .buttons = seaboard_gpio_keys_buttons,
97 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
98};
99
100static struct platform_device seaboard_gpio_keys_device = {
101 .name = "gpio-keys",
102 .id = -1,
103 .dev = {
104 .platform_data = &seaboard_gpio_keys,
105 }
106};
107
108static struct tegra_sdhci_platform_data sdhci_pdata1 = {
109 .cd_gpio = -1,
110 .wp_gpio = -1,
111 .power_gpio = -1,
112};
113
114static struct tegra_sdhci_platform_data sdhci_pdata3 = {
Stephen Warren986afbe2011-03-04 22:44:28 -0700115 .cd_gpio = TEGRA_GPIO_SD2_CD,
116 .wp_gpio = TEGRA_GPIO_SD2_WP,
117 .power_gpio = TEGRA_GPIO_SD2_POWER,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800118};
119
120static struct tegra_sdhci_platform_data sdhci_pdata4 = {
121 .cd_gpio = -1,
122 .wp_gpio = -1,
123 .power_gpio = -1,
124 .is_8bit = 1,
125};
126
Stephen Warrena697e692011-08-08 14:35:14 -0600127static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
128 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
129 .gpio_hp_det = TEGRA_GPIO_HP_DET,
130 .gpio_hp_mute = -1,
131 .gpio_int_mic_en = -1,
132 .gpio_ext_mic_en = -1,
133};
134
135static struct platform_device seaboard_audio_device = {
136 .name = "tegra-snd-wm8903",
137 .id = 0,
138 .dev = {
139 .platform_data = &seaboard_audio_pdata,
140 },
141};
142
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800143static struct platform_device *seaboard_devices[] __initdata = {
144 &debug_uart,
145 &tegra_pmu_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800146 &tegra_sdhci_device4,
Stephen Warrencfeb34e2011-05-31 15:14:08 -0600147 &tegra_sdhci_device3,
148 &tegra_sdhci_device1,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800149 &seaboard_gpio_keys_device,
Stephen Warrena697e692011-08-08 14:35:14 -0600150 &tegra_i2s_device1,
151 &tegra_das_device,
152 &tegra_pcm_device,
153 &seaboard_audio_device,
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800154};
155
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800156static struct i2c_board_info __initdata isl29018_device = {
157 I2C_BOARD_INFO("isl29018", 0x44),
158 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
159};
160
161static struct i2c_board_info __initdata adt7461_device = {
162 I2C_BOARD_INFO("adt7461", 0x4c),
163};
164
Stephen Warrena697e692011-08-08 14:35:14 -0600165static struct wm8903_platform_data wm8903_pdata = {
166 .irq_active_low = 0,
167 .micdet_cfg = 0,
168 .micdet_delay = 100,
169 .gpio_base = SEABOARD_GPIO_WM8903(0),
170 .gpio_cfg = {
171 WM8903_GPIO_NO_CONFIG,
172 WM8903_GPIO_NO_CONFIG,
173 0,
174 WM8903_GPIO_NO_CONFIG,
175 WM8903_GPIO_NO_CONFIG,
176 },
177};
178
179static struct i2c_board_info __initdata wm8903_device = {
180 I2C_BOARD_INFO("wm8903", 0x1a),
181 .platform_data = &wm8903_pdata,
182 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
183};
184
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800185static void __init seaboard_i2c_init(void)
186{
187 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
188 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
189
190 i2c_register_board_info(0, &isl29018_device, 1);
Stephen Warrena697e692011-08-08 14:35:14 -0600191 i2c_register_board_info(0, &wm8903_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800192
Stephen Warren29e9c682011-07-13 12:53:53 -0600193 i2c_register_board_info(3, &adt7461_device, 1);
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800194
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800195 platform_device_register(&tegra_i2c_device1);
196 platform_device_register(&tegra_i2c_device2);
197 platform_device_register(&tegra_i2c_device3);
198 platform_device_register(&tegra_i2c_device4);
199}
200
201static void __init seaboard_common_init(void)
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800202{
203 seaboard_pinmux_init();
204
205 tegra_clk_init_from_table(seaboard_clk_init_table);
206
207 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
208 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
209 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
210
211 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
212}
213
214static void __init tegra_seaboard_init(void)
215{
216 /* Seaboard uses UARTD for the debug port. */
217 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
218 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
219 debug_uart_platform_data[0].irq = INT_UARTD;
220
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800221 seaboard_common_init();
222
223 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800224}
225
226static void __init tegra_kaen_init(void)
227{
228 /* Kaen uses UARTB for the debug port. */
229 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
230 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
231 debug_uart_platform_data[0].irq = INT_UARTB;
232
Stephen Warrena697e692011-08-08 14:35:14 -0600233 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
234 tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
235
Olof Johanssonf9a795a2011-03-04 15:21:53 -0800236 seaboard_common_init();
237
238 seaboard_i2c_init();
Olof Johanssond9a51fe2011-02-19 17:25:32 -0800239}
240
241static void __init tegra_wario_init(void)
242{
243 /* Wario uses UARTB for the debug port. */
244 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
245 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
246 debug_uart_platform_data[0].irq = INT_UARTB;
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
253
254MACHINE_START(SEABOARD, "seaboard")
255 .boot_params = 0x00000100,
256 .map_io = tegra_map_common_io,
257 .init_early = tegra_init_early,
258 .init_irq = tegra_init_irq,
259 .timer = &tegra_timer,
260 .init_machine = tegra_seaboard_init,
261MACHINE_END
262
263MACHINE_START(KAEN, "kaen")
264 .boot_params = 0x00000100,
265 .map_io = tegra_map_common_io,
266 .init_early = tegra_init_early,
267 .init_irq = tegra_init_irq,
268 .timer = &tegra_timer,
269 .init_machine = tegra_kaen_init,
270MACHINE_END
271
272MACHINE_START(WARIO, "wario")
273 .boot_params = 0x00000100,
274 .map_io = tegra_map_common_io,
275 .init_early = tegra_init_early,
276 .init_irq = tegra_init_irq,
277 .timer = &tegra_timer,
278 .init_machine = tegra_wario_init,
279MACHINE_END