Merge branch 'linux-tegra-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-ventana.c
1 /*
2  * arch/arm/mach-tegra/board-ventana.c
3  *
4  * Copyright (c) 2010, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/ctype.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/serial_8250.h>
28 #include <linux/i2c.h>
29 #include <linux/i2c/panjit_ts.h>
30 #include <linux/dma-mapping.h>
31 #include <linux/delay.h>
32 #include <linux/i2c-tegra.h>
33 #include <linux/gpio.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/input.h>
36 #include <linux/usb/android_composite.h>
37
38 #include <mach/clk.h>
39 #include <mach/iomap.h>
40 #include <mach/irqs.h>
41 #include <mach/pinmux.h>
42 #include <mach/iomap.h>
43 #include <mach/io.h>
44
45 #include <asm/mach-types.h>
46 #include <asm/mach/arch.h>
47
48 #include "board.h"
49 #include "clock.h"
50 #include "board-ventana.h"
51 #include "devices.h"
52 #include "gpio-names.h"
53 #include "fuse.h"
54
55 static struct plat_serial8250_port debug_uart_platform_data[] = {
56         {
57                 .membase        = IO_ADDRESS(TEGRA_UARTD_BASE),
58                 .mapbase        = TEGRA_UARTD_BASE,
59                 .irq            = INT_UARTD,
60                 .flags          = UPF_BOOT_AUTOCONF,
61                 .iotype         = UPIO_MEM,
62                 .regshift       = 2,
63                 .uartclk        = 216000000,
64         }, {
65                 .flags          = 0,
66         }
67 };
68
69 static struct platform_device debug_uart = {
70         .name = "serial8250",
71         .id = PLAT8250_DEV_PLATFORM,
72         .dev = {
73                 .platform_data = debug_uart_platform_data,
74         },
75 };
76
77 static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = {
78         /* name         parent          rate            enabled */
79         { "uartd",      "pll_p",        216000000,      true},
80         { "pll_m",      "clk_m",        600000000,      true},
81         { "pwm",        "clk_32k",      32768,          false},
82         { NULL,         NULL,           0,              0},
83 };
84
85 static char *usb_functions[] = { "mtp" };
86 static char *usb_functions_adb[] = { "mtp", "adb" };
87
88 static struct android_usb_product usb_products[] = {
89         {
90                 .product_id     = 0x7102,
91                 .num_functions  = ARRAY_SIZE(usb_functions),
92                 .functions      = usb_functions,
93         },
94         {
95                 .product_id     = 0x7100,
96                 .num_functions  = ARRAY_SIZE(usb_functions_adb),
97                 .functions      = usb_functions_adb,
98         },
99 };
100
101 /* standard android USB platform data */
102 static struct android_usb_platform_data andusb_plat = {
103         .vendor_id              = 0x0955,
104         .product_id             = 0x7100,
105         .manufacturer_name      = "NVIDIA",
106         .product_name           = "Ventana",
107         .serial_number          = NULL,
108         .num_products = ARRAY_SIZE(usb_products),
109         .products = usb_products,
110         .num_functions = ARRAY_SIZE(usb_functions_adb),
111         .functions = usb_functions_adb,
112 };
113
114 static struct platform_device androidusb_device = {
115         .name   = "android_usb",
116         .id     = -1,
117         .dev    = {
118                 .platform_data  = &andusb_plat,
119         },
120 };
121
122 static struct tegra_i2c_platform_data ventana_i2c1_platform_data = {
123         .adapter_nr     = 0,
124         .bus_count      = 1,
125         .bus_clk_rate   = { 400000, 0 },
126 };
127
128 static const struct tegra_pingroup_config i2c2_ddc = {
129         .pingroup       = TEGRA_PINGROUP_DDC,
130         .func           = TEGRA_MUX_I2C2,
131 };
132
133 static const struct tegra_pingroup_config i2c2_gen2 = {
134         .pingroup       = TEGRA_PINGROUP_PTA,
135         .func           = TEGRA_MUX_I2C2,
136 };
137
138 static struct tegra_i2c_platform_data ventana_i2c2_platform_data = {
139         .adapter_nr     = 1,
140         .bus_count      = 2,
141         .bus_clk_rate   = { 400000, 100000 },
142         .bus_mux        = { &i2c2_ddc, &i2c2_gen2 },
143         .bus_mux_len    = { 1, 1 },
144 };
145
146 static struct tegra_i2c_platform_data ventana_i2c3_platform_data = {
147         .adapter_nr     = 3,
148         .bus_count      = 1,
149         .bus_clk_rate   = { 400000, 0 },
150 };
151
152 static struct tegra_i2c_platform_data ventana_dvc_platform_data = {
153         .adapter_nr     = 4,
154         .bus_count      = 1,
155         .bus_clk_rate   = { 400000, 0 },
156         .is_dvc         = true,
157 };
158
159 static void ventana_i2c_init(void)
160 {
161         tegra_i2c_device1.dev.platform_data = &ventana_i2c1_platform_data;
162         tegra_i2c_device2.dev.platform_data = &ventana_i2c2_platform_data;
163         tegra_i2c_device3.dev.platform_data = &ventana_i2c3_platform_data;
164         tegra_i2c_device4.dev.platform_data = &ventana_dvc_platform_data;
165
166         platform_device_register(&tegra_i2c_device4);
167         platform_device_register(&tegra_i2c_device3);
168         platform_device_register(&tegra_i2c_device2);
169         platform_device_register(&tegra_i2c_device1);
170 }
171
172 #define GPIO_KEY(_id, _gpio, _iswake)           \
173         {                                       \
174                 .code = _id,                    \
175                 .gpio = TEGRA_GPIO_##_gpio,     \
176                 .active_low = 1,                \
177                 .desc = #_id,                   \
178                 .type = EV_KEY,                 \
179                 .wakeup = _iswake,              \
180                 .debounce_interval = 10,        \
181         }
182
183 static struct gpio_keys_button ventana_keys[] = {
184         [0] = GPIO_KEY(KEY_MENU, PQ3, 0),
185         [1] = GPIO_KEY(KEY_HOME, PQ1, 0),
186         [2] = GPIO_KEY(KEY_BACK, PQ2, 0),
187         [3] = GPIO_KEY(KEY_VOLUMEUP, PQ5, 0),
188         [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0),
189         [5] = GPIO_KEY(KEY_POWER, PV2, 1),
190 };
191
192 static struct gpio_keys_platform_data ventana_keys_platform_data = {
193         .buttons        = ventana_keys,
194         .nbuttons       = ARRAY_SIZE(ventana_keys),
195 };
196
197 static struct platform_device ventana_keys_device = {
198         .name   = "gpio-keys",
199         .id     = 0,
200         .dev    = {
201                 .platform_data  = &ventana_keys_platform_data,
202         },
203 };
204
205 static struct platform_device *ventana_devices[] __initdata = {
206         &tegra_otg_device,
207         &androidusb_device,
208         &debug_uart,
209         &pmu_device,
210         &tegra_udc_device,
211         &tegra_gart_device,
212         &tegra_aes_device,
213         &ventana_keys_device,
214 };
215
216 static void ventana_keys_init(void)
217 {
218         int i;
219
220         for (i = 0; i < ARRAY_SIZE(ventana_keys); i++)
221                 tegra_gpio_enable(ventana_keys[i].gpio);
222 }
223
224 static struct panjit_i2c_ts_platform_data panjit_data = {
225         .gpio_reset = TEGRA_GPIO_PQ7,
226 };
227
228 static const struct i2c_board_info ventana_i2c_bus1_touch_info[] = {
229         {
230                 I2C_BOARD_INFO("panjit_touch", 0x3),
231                 .irq            = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
232                 .platform_data  = &panjit_data,
233         },
234 };
235
236 static int __init ventana_touch_init(void)
237 {
238         tegra_gpio_enable(TEGRA_GPIO_PV6);
239
240         tegra_gpio_enable(TEGRA_GPIO_PQ7);
241         i2c_register_board_info(0, ventana_i2c_bus1_touch_info, 1);
242
243         return 0;
244 }
245
246 static void __init tegra_ventana_init(void)
247 {
248         char serial[20];
249
250         tegra_common_init();
251         tegra_clk_init_from_table(ventana_clk_init_table);
252         ventana_pinmux_init();
253
254         snprintf(serial, sizeof(serial), "%llx", tegra_chip_uid());
255         andusb_plat.serial_number = kstrdup(serial, GFP_KERNEL);
256         platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices));
257
258         ventana_sdhci_init();
259         ventana_i2c_init();
260         ventana_regulator_init();
261         ventana_touch_init();
262         ventana_keys_init();
263         ventana_panel_init();
264 }
265
266 MACHINE_START(VENTANA, "ventana")
267         .boot_params    = 0x00000100,
268         .phys_io        = IO_APB_PHYS,
269         .io_pg_offst    = ((IO_APB_VIRT) >> 18) & 0xfffc,
270         .init_irq       = tegra_init_irq,
271         .init_machine   = tegra_ventana_init,
272         .map_io         = tegra_map_common_io,
273         .timer          = &tegra_timer,
274 MACHINE_END