Merge branch 'next/fixes2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/linux...
[pandora-kernel.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/i2c-tegra.h>
23 #include <linux/delay.h>
24 #include <linux/input.h>
25 #include <linux/io.h>
26 #include <linux/gpio.h>
27 #include <linux/gpio_keys.h>
28
29 #include <mach/iomap.h>
30 #include <mach/irqs.h>
31 #include <mach/sdhci.h>
32
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35
36 #include "board.h"
37 #include "board-seaboard.h"
38 #include "clock.h"
39 #include "devices.h"
40 #include "gpio-names.h"
41
42 static struct plat_serial8250_port debug_uart_platform_data[] = {
43         {
44                 /* Memory and IRQ filled in before registration */
45                 .flags          = UPF_BOOT_AUTOCONF,
46                 .iotype         = UPIO_MEM,
47                 .regshift       = 2,
48                 .uartclk        = 216000000,
49         }, {
50                 .flags          = 0,
51         }
52 };
53
54 static struct platform_device debug_uart = {
55         .name = "serial8250",
56         .id = PLAT8250_DEV_PLATFORM,
57         .dev = {
58                 .platform_data = debug_uart_platform_data,
59         },
60 };
61
62 static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
63         /* name         parent          rate            enabled */
64         { "uartb",      "pll_p",        216000000,      true},
65         { "uartd",      "pll_p",        216000000,      true},
66         { NULL,         NULL,           0,              0},
67 };
68
69 static struct tegra_i2c_platform_data seaboard_i2c1_platform_data = {
70         .bus_clk_rate   = 400000.
71 };
72
73 static struct tegra_i2c_platform_data seaboard_i2c2_platform_data = {
74         .bus_clk_rate   = 400000,
75 };
76
77 static struct tegra_i2c_platform_data seaboard_i2c3_platform_data = {
78         .bus_clk_rate   = 400000,
79 };
80
81 static struct tegra_i2c_platform_data seaboard_dvc_platform_data = {
82         .bus_clk_rate   = 400000,
83 };
84
85 static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
86         {
87                 .code           = SW_LID,
88                 .gpio           = TEGRA_GPIO_LIDSWITCH,
89                 .active_low     = 0,
90                 .desc           = "Lid",
91                 .type           = EV_SW,
92                 .wakeup         = 1,
93                 .debounce_interval = 1,
94         },
95         {
96                 .code           = KEY_POWER,
97                 .gpio           = TEGRA_GPIO_POWERKEY,
98                 .active_low     = 1,
99                 .desc           = "Power",
100                 .type           = EV_KEY,
101                 .wakeup         = 1,
102         },
103 };
104
105 static struct gpio_keys_platform_data seaboard_gpio_keys = {
106         .buttons        = seaboard_gpio_keys_buttons,
107         .nbuttons       = ARRAY_SIZE(seaboard_gpio_keys_buttons),
108 };
109
110 static struct platform_device seaboard_gpio_keys_device = {
111         .name           = "gpio-keys",
112         .id             = -1,
113         .dev            = {
114                 .platform_data = &seaboard_gpio_keys,
115         }
116 };
117
118 static struct tegra_sdhci_platform_data sdhci_pdata1 = {
119         .cd_gpio        = -1,
120         .wp_gpio        = -1,
121         .power_gpio     = -1,
122 };
123
124 static struct tegra_sdhci_platform_data sdhci_pdata3 = {
125         .cd_gpio        = TEGRA_GPIO_SD2_CD,
126         .wp_gpio        = TEGRA_GPIO_SD2_WP,
127         .power_gpio     = TEGRA_GPIO_SD2_POWER,
128 };
129
130 static struct tegra_sdhci_platform_data sdhci_pdata4 = {
131         .cd_gpio        = -1,
132         .wp_gpio        = -1,
133         .power_gpio     = -1,
134         .is_8bit        = 1,
135 };
136
137 static struct platform_device *seaboard_devices[] __initdata = {
138         &debug_uart,
139         &tegra_pmu_device,
140         &tegra_sdhci_device1,
141         &tegra_sdhci_device3,
142         &tegra_sdhci_device4,
143         &seaboard_gpio_keys_device,
144 };
145
146 static struct i2c_board_info __initdata isl29018_device = {
147         I2C_BOARD_INFO("isl29018", 0x44),
148         .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
149 };
150
151 static struct i2c_board_info __initdata adt7461_device = {
152         I2C_BOARD_INFO("adt7461", 0x4c),
153 };
154
155 static void __init seaboard_i2c_init(void)
156 {
157         gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
158         gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
159
160         i2c_register_board_info(0, &isl29018_device, 1);
161
162         i2c_register_board_info(3, &adt7461_device, 1);
163
164         tegra_i2c_device1.dev.platform_data = &seaboard_i2c1_platform_data;
165         tegra_i2c_device2.dev.platform_data = &seaboard_i2c2_platform_data;
166         tegra_i2c_device3.dev.platform_data = &seaboard_i2c3_platform_data;
167         tegra_i2c_device4.dev.platform_data = &seaboard_dvc_platform_data;
168
169         platform_device_register(&tegra_i2c_device1);
170         platform_device_register(&tegra_i2c_device2);
171         platform_device_register(&tegra_i2c_device3);
172         platform_device_register(&tegra_i2c_device4);
173 }
174
175 static void __init seaboard_common_init(void)
176 {
177         seaboard_pinmux_init();
178
179         tegra_clk_init_from_table(seaboard_clk_init_table);
180
181         tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
182         tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
183         tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
184
185         platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
186 }
187
188 static void __init tegra_seaboard_init(void)
189 {
190         /* Seaboard uses UARTD for the debug port. */
191         debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
192         debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
193         debug_uart_platform_data[0].irq = INT_UARTD;
194
195         seaboard_common_init();
196
197         seaboard_i2c_init();
198 }
199
200 static void __init tegra_kaen_init(void)
201 {
202         /* Kaen uses UARTB for the debug port. */
203         debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
204         debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
205         debug_uart_platform_data[0].irq = INT_UARTB;
206
207         seaboard_common_init();
208
209         seaboard_i2c_init();
210 }
211
212 static void __init tegra_wario_init(void)
213 {
214         /* Wario uses UARTB for the debug port. */
215         debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
216         debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
217         debug_uart_platform_data[0].irq = INT_UARTB;
218
219         seaboard_common_init();
220
221         seaboard_i2c_init();
222 }
223
224
225 MACHINE_START(SEABOARD, "seaboard")
226         .boot_params    = 0x00000100,
227         .map_io         = tegra_map_common_io,
228         .init_early     = tegra_init_early,
229         .init_irq       = tegra_init_irq,
230         .timer          = &tegra_timer,
231         .init_machine   = tegra_seaboard_init,
232 MACHINE_END
233
234 MACHINE_START(KAEN, "kaen")
235         .boot_params    = 0x00000100,
236         .map_io         = tegra_map_common_io,
237         .init_early     = tegra_init_early,
238         .init_irq       = tegra_init_irq,
239         .timer          = &tegra_timer,
240         .init_machine   = tegra_kaen_init,
241 MACHINE_END
242
243 MACHINE_START(WARIO, "wario")
244         .boot_params    = 0x00000100,
245         .map_io         = tegra_map_common_io,
246         .init_early     = tegra_init_early,
247         .init_irq       = tegra_init_irq,
248         .timer          = &tegra_timer,
249         .init_machine   = tegra_wario_init,
250 MACHINE_END