Merge tag 'ux500-gpio-pins-for-3.5' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-seaboard.c
1 /*
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>
21 #include <linux/i2c.h>
22 #include <linux/delay.h>
23 #include <linux/input.h>
24 #include <linux/io.h>
25 #include <linux/gpio.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/platform_data/tegra_usb.h>
28
29 #include <sound/wm8903.h>
30
31 #include <mach/iomap.h>
32 #include <mach/irqs.h>
33 #include <mach/sdhci.h>
34 #include <mach/tegra_wm8903_pdata.h>
35
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/hardware/gic.h>
39
40 #include "board.h"
41 #include "board-seaboard.h"
42 #include "clock.h"
43 #include "devices.h"
44 #include "gpio-names.h"
45
46 static struct plat_serial8250_port debug_uart_platform_data[] = {
47         {
48                 /* Memory and IRQ filled in before registration */
49                 .flags          = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
50                 .type           = PORT_TEGRA,
51                 .iotype         = UPIO_MEM,
52                 .regshift       = 2,
53                 .uartclk        = 216000000,
54         }, {
55                 .flags          = 0,
56         }
57 };
58
59 static 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
67 static __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},
71         { "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},
75         { "usbd",       "clk_m",        12000000,       true},
76         { "usb3",       "clk_m",        12000000,       true},
77         { NULL,         NULL,           0,              0},
78 };
79
80 static 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
100 static struct gpio_keys_platform_data seaboard_gpio_keys = {
101         .buttons        = seaboard_gpio_keys_buttons,
102         .nbuttons       = ARRAY_SIZE(seaboard_gpio_keys_buttons),
103 };
104
105 static 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
113 static struct tegra_sdhci_platform_data sdhci_pdata1 = {
114         .cd_gpio        = -1,
115         .wp_gpio        = -1,
116         .power_gpio     = -1,
117 };
118
119 static struct tegra_sdhci_platform_data sdhci_pdata3 = {
120         .cd_gpio        = TEGRA_GPIO_SD2_CD,
121         .wp_gpio        = TEGRA_GPIO_SD2_WP,
122         .power_gpio     = TEGRA_GPIO_SD2_POWER,
123 };
124
125 static 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
132 static 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
140 static 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
148 static struct platform_device *seaboard_devices[] __initdata = {
149         &debug_uart,
150         &tegra_pmu_device,
151         &tegra_sdhci_device4,
152         &tegra_sdhci_device3,
153         &tegra_sdhci_device1,
154         &seaboard_gpio_keys_device,
155         &tegra_i2s_device1,
156         &tegra_das_device,
157         &tegra_pcm_device,
158         &seaboard_audio_device,
159 };
160
161 static struct i2c_board_info __initdata isl29018_device = {
162         I2C_BOARD_INFO("isl29018", 0x44),
163 };
164
165 static struct i2c_board_info __initdata adt7461_device = {
166         I2C_BOARD_INFO("adt7461", 0x4c),
167 };
168
169 static 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                 0,
176                 0,
177                 WM8903_GPIO_CONFIG_ZERO,
178                 0,
179                 0,
180         },
181 };
182
183 static struct i2c_board_info __initdata wm8903_device = {
184         I2C_BOARD_INFO("wm8903", 0x1a),
185         .platform_data = &wm8903_pdata,
186 };
187
188 static int seaboard_ehci_init(void)
189 {
190         struct tegra_ehci_platform_data *pdata;
191
192         pdata = tegra_ehci1_device.dev.platform_data;
193         pdata->vbus_gpio = TEGRA_GPIO_USB1;
194
195         platform_device_register(&tegra_ehci1_device);
196         platform_device_register(&tegra_ehci3_device);
197
198         return 0;
199 }
200
201 static void __init seaboard_i2c_init(void)
202 {
203         isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
204         i2c_register_board_info(0, &isl29018_device, 1);
205
206         wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
207         i2c_register_board_info(0, &wm8903_device, 1);
208
209         i2c_register_board_info(3, &adt7461_device, 1);
210
211         platform_device_register(&tegra_i2c_device1);
212         platform_device_register(&tegra_i2c_device2);
213         platform_device_register(&tegra_i2c_device3);
214         platform_device_register(&tegra_i2c_device4);
215 }
216
217 static void __init seaboard_common_init(void)
218 {
219         seaboard_pinmux_init();
220
221         tegra_clk_init_from_table(seaboard_clk_init_table);
222
223         tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
224         tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
225         tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
226
227         platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
228
229         seaboard_ehci_init();
230 }
231
232 static void __init tegra_seaboard_init(void)
233 {
234         /* Seaboard uses UARTD for the debug port. */
235         debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
236         debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
237         debug_uart_platform_data[0].irq = INT_UARTD;
238
239         seaboard_common_init();
240
241         seaboard_i2c_init();
242 }
243
244 static void __init tegra_kaen_init(void)
245 {
246         /* Kaen uses UARTB for the debug port. */
247         debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
248         debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
249         debug_uart_platform_data[0].irq = INT_UARTB;
250
251         seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
252
253         seaboard_common_init();
254
255         seaboard_i2c_init();
256 }
257
258 static void __init tegra_wario_init(void)
259 {
260         /* Wario 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
265         seaboard_common_init();
266
267         seaboard_i2c_init();
268 }
269
270
271 MACHINE_START(SEABOARD, "seaboard")
272         .atag_offset    = 0x100,
273         .map_io         = tegra_map_common_io,
274         .init_early     = tegra20_init_early,
275         .init_irq       = tegra_init_irq,
276         .handle_irq     = gic_handle_irq,
277         .timer          = &tegra_timer,
278         .init_machine   = tegra_seaboard_init,
279         .restart        = tegra_assert_system_reset,
280 MACHINE_END
281
282 MACHINE_START(KAEN, "kaen")
283         .atag_offset    = 0x100,
284         .map_io         = tegra_map_common_io,
285         .init_early     = tegra20_init_early,
286         .init_irq       = tegra_init_irq,
287         .handle_irq     = gic_handle_irq,
288         .timer          = &tegra_timer,
289         .init_machine   = tegra_kaen_init,
290         .restart        = tegra_assert_system_reset,
291 MACHINE_END
292
293 MACHINE_START(WARIO, "wario")
294         .atag_offset    = 0x100,
295         .map_io         = tegra_map_common_io,
296         .init_early     = tegra20_init_early,
297         .init_irq       = tegra_init_irq,
298         .handle_irq     = gic_handle_irq,
299         .timer          = &tegra_timer,
300         .init_machine   = tegra_wario_init,
301         .restart        = tegra_assert_system_reset,
302 MACHINE_END