2 * arch/arm/mach-tegra/board-ventana.c
4 * Copyright (c) 2010-2011, NVIDIA Corporation.
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.
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
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.
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/platform_data/tegra_usb.h>
37 #include <linux/mfd/tps6586x.h>
38 #include <linux/memblock.h>
39 #include <linux/i2c/atmel_mxt_ts.h>
40 #include <linux/tegra_uart.h>
42 #include <sound/wm8903.h>
45 #include <mach/gpio-tegra.h>
46 #include <mach/iomap.h>
47 #include <mach/irqs.h>
48 #include <mach/pinmux.h>
49 #include <mach/pinmux-tegra20.h>
50 #include <mach/iomap.h>
53 #include <mach/tegra_wm8903_pdata.h>
55 #include <asm/hardware/gic.h>
56 #include <asm/mach-types.h>
57 #include <asm/mach/arch.h>
58 #include <mach/usb_phy.h>
62 #include "board-ventana.h"
64 #include "gpio-names.h"
66 #include "wakeups-t2.h"
69 static struct tegra_utmip_config utmi_phy_config[] = {
71 .hssync_start_delay = 9,
72 .idle_wait_delay = 17,
76 .xcvr_setup_offset = 0,
82 .hssync_start_delay = 9,
83 .idle_wait_delay = 17,
87 .xcvr_setup_offset = 0,
94 static struct tegra_ulpi_config ulpi_phy_config = {
95 .reset_gpio = TEGRA_GPIO_PG2,
99 static struct resource ventana_bcm4329_rfkill_resources[] = {
101 .name = "bcm4329_nshutdown_gpio",
102 .start = TEGRA_GPIO_PU0,
103 .end = TEGRA_GPIO_PU0,
104 .flags = IORESOURCE_IO,
108 static struct platform_device ventana_bcm4329_rfkill_device = {
109 .name = "bcm4329_rfkill",
111 .num_resources = ARRAY_SIZE(ventana_bcm4329_rfkill_resources),
112 .resource = ventana_bcm4329_rfkill_resources,
115 static void __init ventana_bt_rfkill(void)
117 /*Add Clock Resource*/
118 clk_add_alias("bcm4329_32k_clk", ventana_bcm4329_rfkill_device.name, \
123 static struct resource ventana_bluesleep_resources[] = {
125 .name = "gpio_host_wake",
126 .start = TEGRA_GPIO_PU6,
127 .end = TEGRA_GPIO_PU6,
128 .flags = IORESOURCE_IO,
131 .name = "gpio_ext_wake",
132 .start = TEGRA_GPIO_PU1,
133 .end = TEGRA_GPIO_PU1,
134 .flags = IORESOURCE_IO,
138 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PU6),
139 .end = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PU6),
140 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
144 static struct platform_device ventana_bluesleep_device = {
147 .num_resources = ARRAY_SIZE(ventana_bluesleep_resources),
148 .resource = ventana_bluesleep_resources,
151 static void __init ventana_setup_bluesleep(void)
153 platform_device_register(&ventana_bluesleep_device);
154 tegra_gpio_enable(TEGRA_GPIO_PU6);
155 tegra_gpio_enable(TEGRA_GPIO_PU1);
159 static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = {
160 /* name parent rate enabled */
161 { "blink", "clk_32k", 32768, false},
162 { "pll_p_out4", "pll_p", 24000000, true },
163 { "pwm", "clk_32k", 32768, false},
164 { "i2s1", "pll_a_out0", 0, false},
165 { "i2s2", "pll_a_out0", 0, false},
166 { "spdif_out", "pll_a_out0", 0, false},
170 static struct tegra_ulpi_config ventana_ehci2_ulpi_phy_config = {
171 .reset_gpio = TEGRA_GPIO_PV1,
175 static struct tegra_ehci_platform_data ventana_ehci2_ulpi_platform_data = {
176 .operating_mode = TEGRA_USB_HOST,
177 .power_down_on_bus_suspend = 1,
178 .phy_config = &ventana_ehci2_ulpi_phy_config,
179 .phy_type = TEGRA_USB_PHY_TYPE_LINK_ULPI,
180 .default_enable = true,
183 static struct tegra_i2c_platform_data ventana_i2c1_platform_data = {
186 .bus_clk_rate = { 400000, 0 },
187 .slave_addr = 0x00FC,
188 .scl_gpio = {TEGRA_GPIO_PC4, 0},
189 .sda_gpio = {TEGRA_GPIO_PC5, 0},
190 .arb_recovery = arb_lost_recovery,
193 static const struct tegra_pingroup_config i2c2_ddc = {
194 .pingroup = TEGRA_PINGROUP_DDC,
195 .func = TEGRA_MUX_I2C2,
198 static const struct tegra_pingroup_config i2c2_gen2 = {
199 .pingroup = TEGRA_PINGROUP_PTA,
200 .func = TEGRA_MUX_I2C2,
203 static struct tegra_i2c_platform_data ventana_i2c2_platform_data = {
206 .bus_clk_rate = { 100000, 10000 },
207 .bus_mux = { &i2c2_ddc, &i2c2_gen2 },
208 .bus_mux_len = { 1, 1 },
209 .slave_addr = 0x00FC,
210 .scl_gpio = {0, TEGRA_GPIO_PT5},
211 .sda_gpio = {0, TEGRA_GPIO_PT6},
212 .arb_recovery = arb_lost_recovery,
215 static struct tegra_i2c_platform_data ventana_i2c3_platform_data = {
218 .bus_clk_rate = { 400000, 0 },
219 .slave_addr = 0x00FC,
220 .scl_gpio = {TEGRA_GPIO_PBB2, 0},
221 .sda_gpio = {TEGRA_GPIO_PBB3, 0},
222 .arb_recovery = arb_lost_recovery,
225 static struct tegra_i2c_platform_data ventana_dvc_platform_data = {
228 .bus_clk_rate = { 400000, 0 },
230 .scl_gpio = {TEGRA_GPIO_PZ6, 0},
231 .sda_gpio = {TEGRA_GPIO_PZ7, 0},
232 .arb_recovery = arb_lost_recovery,
235 static struct wm8903_platform_data ventana_wm8903_pdata = {
239 .gpio_base = WM8903_GPIO_BASE,
241 (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP1_FN_SHIFT),
242 (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP2_FN_SHIFT) |
245 WM8903_GPIO_NO_CONFIG,
246 WM8903_GPIO_NO_CONFIG,
250 static struct i2c_board_info __initdata wm8903_board_info = {
251 I2C_BOARD_INFO("wm8903", 0x1a),
252 .platform_data = &ventana_wm8903_pdata,
253 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
256 static void ventana_i2c_init(void)
258 tegra_i2c_device1.dev.platform_data = &ventana_i2c1_platform_data;
259 tegra_i2c_device2.dev.platform_data = &ventana_i2c2_platform_data;
260 tegra_i2c_device3.dev.platform_data = &ventana_i2c3_platform_data;
261 tegra_i2c_device4.dev.platform_data = &ventana_dvc_platform_data;
263 platform_device_register(&tegra_i2c_device1);
264 platform_device_register(&tegra_i2c_device2);
265 platform_device_register(&tegra_i2c_device3);
266 platform_device_register(&tegra_i2c_device4);
268 i2c_register_board_info(0, &wm8903_board_info, 1);
270 static struct platform_device *ventana_uart_devices[] __initdata = {
276 static struct uart_clk_parent uart_parent_clk[] = {
277 [0] = {.name = "pll_p"},
278 [1] = {.name = "pll_m"},
279 [2] = {.name = "clk_m"},
282 static struct tegra_uart_platform_data ventana_uart_pdata;
284 static void __init uart_debug_init(void)
289 /* UARTD is the debug port. */
290 pr_info("Selecting UARTD as the debug console\n");
291 ventana_uart_devices[2] = &debug_uartd_device;
292 debug_uart_port_base = ((struct plat_serial8250_port *)(
293 debug_uartd_device.dev.platform_data))->mapbase;
294 debug_uart_clk = clk_get_sys("serial8250.0", "uartd");
296 /* Clock enable for the debug channel */
297 if (!IS_ERR_OR_NULL(debug_uart_clk)) {
298 rate = ((struct plat_serial8250_port *)(
299 debug_uartd_device.dev.platform_data))->uartclk;
300 pr_info("The debug console clock name is %s\n",
301 debug_uart_clk->name);
302 c = tegra_get_clock_by_name("pll_p");
303 if (IS_ERR_OR_NULL(c))
304 pr_err("Not getting the parent clock pll_p\n");
306 clk_set_parent(debug_uart_clk, c);
308 clk_enable(debug_uart_clk);
309 clk_set_rate(debug_uart_clk, rate);
311 pr_err("Not getting the clock %s for debug console\n",
312 debug_uart_clk->name);
316 static void __init ventana_uart_init(void)
321 for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
322 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
323 if (IS_ERR_OR_NULL(c)) {
324 pr_err("Not able to get the clock for %s\n",
325 uart_parent_clk[i].name);
328 uart_parent_clk[i].parent_clk = c;
329 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
331 ventana_uart_pdata.parent_clk_list = uart_parent_clk;
332 ventana_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
333 tegra_uartb_device.dev.platform_data = &ventana_uart_pdata;
334 tegra_uartc_device.dev.platform_data = &ventana_uart_pdata;
335 tegra_uartd_device.dev.platform_data = &ventana_uart_pdata;
337 /* Register low speed only if it is selected */
338 if (!is_tegra_debug_uartport_hs())
341 platform_add_devices(ventana_uart_devices,
342 ARRAY_SIZE(ventana_uart_devices));
345 #ifdef CONFIG_KEYBOARD_GPIO
346 #define GPIO_KEY(_id, _gpio, _iswake) \
349 .gpio = TEGRA_GPIO_##_gpio, \
354 .debounce_interval = 10, \
357 static struct gpio_keys_button ventana_keys[] = {
358 [0] = GPIO_KEY(KEY_FIND, PQ3, 0),
359 [1] = GPIO_KEY(KEY_HOME, PQ1, 0),
360 [2] = GPIO_KEY(KEY_BACK, PQ2, 0),
361 [3] = GPIO_KEY(KEY_VOLUMEUP, PQ5, 0),
362 [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0),
363 [5] = GPIO_KEY(KEY_POWER, PV2, 1),
364 [6] = GPIO_KEY(KEY_MENU, PC7, 0),
367 #define PMC_WAKE_STATUS 0x14
369 static int ventana_wakeup_key(void)
371 unsigned long status =
372 readl(IO_ADDRESS(TEGRA_PMC_BASE) + PMC_WAKE_STATUS);
374 return status & TEGRA_WAKE_GPIO_PV2 ? KEY_POWER : KEY_RESERVED;
377 static struct gpio_keys_platform_data ventana_keys_platform_data = {
378 .buttons = ventana_keys,
379 .nbuttons = ARRAY_SIZE(ventana_keys),
380 .wakeup_key = ventana_wakeup_key,
383 static struct platform_device ventana_keys_device = {
387 .platform_data = &ventana_keys_platform_data,
391 static void ventana_keys_init(void)
395 for (i = 0; i < ARRAY_SIZE(ventana_keys); i++)
396 tegra_gpio_enable(ventana_keys[i].gpio);
400 static struct platform_device tegra_camera = {
401 .name = "tegra_camera",
405 static struct tegra_wm8903_platform_data ventana_audio_pdata = {
406 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
407 .gpio_hp_det = TEGRA_GPIO_HP_DET,
409 .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN,
410 .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN,
413 static struct platform_device ventana_audio_device = {
414 .name = "tegra-snd-wm8903",
417 .platform_data = &ventana_audio_pdata,
421 static struct platform_device *ventana_devices[] __initdata = {
425 #ifdef CONFIG_KEYBOARD_GPIO
426 &ventana_keys_device,
436 &bluetooth_dit_device,
437 &ventana_bcm4329_rfkill_device,
439 &ventana_audio_device,
443 static struct mxt_platform_data atmel_mxt_info = {
451 .orient = MXT_ROTATED_90,
452 .irqflags = IRQF_TRIGGER_FALLING,
455 static struct i2c_board_info __initdata i2c_info[] = {
457 I2C_BOARD_INFO("atmel_mxt_ts", 0x5A),
458 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
459 .platform_data = &atmel_mxt_info,
463 static int __init ventana_touch_init_atmel(void)
465 tegra_gpio_enable(TEGRA_GPIO_PV6);
466 tegra_gpio_enable(TEGRA_GPIO_PQ7);
468 gpio_request(TEGRA_GPIO_PV6, "atmel-irq");
469 gpio_direction_input(TEGRA_GPIO_PV6);
471 gpio_request(TEGRA_GPIO_PQ7, "atmel-reset");
472 gpio_direction_output(TEGRA_GPIO_PQ7, 0);
474 gpio_set_value(TEGRA_GPIO_PQ7, 1);
477 i2c_register_board_info(0, i2c_info, 1);
482 static struct panjit_i2c_ts_platform_data panjit_data = {
483 .gpio_reset = TEGRA_GPIO_PQ7,
486 static struct i2c_board_info __initdata ventana_i2c_bus1_touch_info[] = {
488 I2C_BOARD_INFO("panjit_touch", 0x3),
489 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
490 .platform_data = &panjit_data,
494 static int __init ventana_touch_init_panjit(void)
496 tegra_gpio_enable(TEGRA_GPIO_PV6);
498 tegra_gpio_enable(TEGRA_GPIO_PQ7);
499 i2c_register_board_info(0, ventana_i2c_bus1_touch_info, 1);
504 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
507 .vbus_irq = TPS6586X_INT_BASE + TPS6586X_INT_USB_DET,
508 .vbus_gpio = TEGRA_GPIO_PD0,
516 .vbus_gpio = TEGRA_GPIO_PD3,
520 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
522 .phy_config = &utmi_phy_config[0],
523 .operating_mode = TEGRA_USB_HOST,
524 .power_down_on_bus_suspend = 1,
525 .default_enable = true,
528 .phy_config = &ulpi_phy_config,
529 .operating_mode = TEGRA_USB_HOST,
530 .power_down_on_bus_suspend = 1,
531 .phy_type = TEGRA_USB_PHY_TYPE_LINK_ULPI,
532 .default_enable = true,
535 .phy_config = &utmi_phy_config[1],
536 .operating_mode = TEGRA_USB_HOST,
537 .power_down_on_bus_suspend = 1,
539 .default_enable = true,
543 static struct tegra_otg_platform_data tegra_otg_pdata = {
544 .ehci_device = &tegra_ehci1_device,
545 .ehci_pdata = &tegra_ehci_pdata[0],
548 static int __init ventana_gps_init(void)
550 struct clk *clk32 = clk_get_sys(NULL, "blink");
551 if (!IS_ERR(clk32)) {
552 clk_set_rate(clk32,clk32->parent->rate);
556 tegra_gpio_enable(TEGRA_GPIO_PZ3);
560 static void ventana_usb_init(void)
562 tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata));
563 /* OTG should be the first to be registered */
564 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
565 platform_device_register(&tegra_otg_device);
567 platform_device_register(&tegra_udc_device);
568 platform_device_register(&tegra_ehci2_device);
570 tegra_ehci3_device.dev.platform_data=&tegra_ehci_pdata[2];
571 platform_device_register(&tegra_ehci3_device);
574 static void __init tegra_ventana_init(void)
576 struct board_info BoardInfo;
578 tegra_clk_init_from_table(ventana_clk_init_table);
579 ventana_pinmux_init();
582 tegra_ehci2_device.dev.platform_data
583 = &ventana_ehci2_ulpi_platform_data;
584 platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices));
585 tegra_ram_console_debug_init();
586 ventana_sdhci_init();
587 ventana_charge_init();
588 ventana_regulator_init();
589 ventana_charger_init();
591 tegra_get_board_info(&BoardInfo);
593 /* boards with sku > 0 have atmel touch panels */
595 pr_info("Initializing Atmel touch driver\n");
596 ventana_touch_init_atmel();
598 pr_info("Initializing Panjit touch driver\n");
599 ventana_touch_init_panjit();
602 #ifdef CONFIG_KEYBOARD_GPIO
608 ventana_panel_init();
609 ventana_sensors_init();
613 ventana_setup_bluesleep();
614 tegra_release_bootloader_fb();
617 int __init tegra_ventana_protected_aperture_init(void)
619 if (!machine_is_ventana())
622 tegra_protected_aperture_init(tegra_grhost_aperture);
625 late_initcall(tegra_ventana_protected_aperture_init);
627 void __init tegra_ventana_reserve(void)
629 if (memblock_reserve(0x0, 4096) < 0)
630 pr_warn("Cannot reserve first 4K of memory for safety\n");
632 tegra_reserve(SZ_256M, SZ_8M + SZ_1M, SZ_16M);
633 tegra_ram_console_debug_reserve(SZ_1M);
636 MACHINE_START(VENTANA, "ventana")
637 .map_io = tegra_map_common_io,
638 .init_early = tegra20_init_early,
639 .init_irq = tegra_init_irq,
640 .handle_irq = gic_handle_irq,
641 .reserve = tegra_ventana_reserve,
642 .timer = &tegra_timer,
643 .init_machine = tegra_ventana_init,
644 .restart = tegra_assert_system_reset,