/* * arch/arm/mach-tegra/board-ventana.c * * Copyright (c) 2010-2011 NVIDIA Corporation. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "board.h" #include "clock.h" #include "board-ventana.h" #include "devices.h" #include "gpio-names.h" #include "fuse.h" #include "wakeups-t2.h" #include "pm.h" static struct rfkill_gpio_platform_data ventana_bt_rfkill_pdata[] = { { .name = "bt_rfkill", .shutdown_gpio = TEGRA_GPIO_PU0, .reset_gpio = TEGRA_GPIO_INVALID, .type = RFKILL_TYPE_BLUETOOTH, }, }; static struct platform_device ventana_bt_rfkill_device = { .name = "rfkill_gpio", .id = -1, .dev = { .platform_data = ventana_bt_rfkill_pdata, }, }; static void __init ventana_bt_rfkill(void) { /*Add Clock Resource*/ clk_add_alias("bcm4329_32k_clk", ventana_bt_rfkill_device.name, \ "blink", NULL); return; } static struct resource ventana_bluesleep_resources[] = { [0] = { .name = "gpio_host_wake", .start = TEGRA_GPIO_PU6, .end = TEGRA_GPIO_PU6, .flags = IORESOURCE_IO, }, [1] = { .name = "gpio_ext_wake", .start = TEGRA_GPIO_PU1, .end = TEGRA_GPIO_PU1, .flags = IORESOURCE_IO, }, [2] = { .name = "host_wake", .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PU6), .end = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PU6), .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, }, }; static struct platform_device ventana_bluesleep_device = { .name = "bluesleep", .id = -1, .num_resources = ARRAY_SIZE(ventana_bluesleep_resources), .resource = ventana_bluesleep_resources, }; static void __init ventana_setup_bluesleep(void) { platform_device_register(&ventana_bluesleep_device); return; } static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = { /* name parent rate enabled */ { "blink", "clk_32k", 32768, false}, { "pll_p_out4", "pll_p", 24000000, true }, { "pwm", "clk_32k", 32768, false}, { "i2s1", "pll_a_out0", 0, false}, { "i2s2", "pll_a_out0", 0, false}, { "spdif_out", "pll_a_out0", 0, false}, { NULL, NULL, 0, 0}, }; static struct tegra_i2c_platform_data ventana_i2c1_platform_data = { .adapter_nr = 0, .bus_count = 1, .bus_clk_rate = { 400000, 0 }, .slave_addr = 0x00FC, .scl_gpio = {TEGRA_GPIO_PC4, 0}, .sda_gpio = {TEGRA_GPIO_PC5, 0}, .arb_recovery = arb_lost_recovery, }; static const struct tegra_pingroup_config i2c2_ddc = { .pingroup = TEGRA_PINGROUP_DDC, .func = TEGRA_MUX_I2C2, }; static const struct tegra_pingroup_config i2c2_gen2 = { .pingroup = TEGRA_PINGROUP_PTA, .func = TEGRA_MUX_I2C2, }; static struct tegra_i2c_platform_data ventana_i2c2_platform_data = { .adapter_nr = 1, .bus_count = 2, .bus_clk_rate = { 10000, 10000 }, .bus_mux = { &i2c2_ddc, &i2c2_gen2 }, .bus_mux_len = { 1, 1 }, .slave_addr = 0x00FC, .scl_gpio = {0, TEGRA_GPIO_PT5}, .sda_gpio = {0, TEGRA_GPIO_PT6}, .arb_recovery = arb_lost_recovery, }; static struct tegra_i2c_platform_data ventana_i2c3_platform_data = { .adapter_nr = 3, .bus_count = 1, .bus_clk_rate = { 400000, 0 }, .slave_addr = 0x00FC, .scl_gpio = {TEGRA_GPIO_PBB2, 0}, .sda_gpio = {TEGRA_GPIO_PBB3, 0}, .arb_recovery = arb_lost_recovery, }; static struct tegra_i2c_platform_data ventana_dvc_platform_data = { .adapter_nr = 4, .bus_count = 1, .bus_clk_rate = { 400000, 0 }, .is_dvc = true, .scl_gpio = {TEGRA_GPIO_PZ6, 0}, .sda_gpio = {TEGRA_GPIO_PZ7, 0}, .arb_recovery = arb_lost_recovery, }; static struct wm8903_platform_data ventana_wm8903_pdata = { .irq_active_low = 0, .micdet_cfg = 0, .micdet_delay = 100, .gpio_base = WM8903_GPIO_BASE, .gpio_cfg = { (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP1_FN_SHIFT), (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP2_FN_SHIFT) | WM8903_GP2_DIR, 0, WM8903_GPIO_NO_CONFIG, WM8903_GPIO_NO_CONFIG, }, }; static struct i2c_board_info __initdata wm8903_board_info = { I2C_BOARD_INFO("wm8903", 0x1a), .platform_data = &ventana_wm8903_pdata, .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ), }; static void ventana_i2c_init(void) { tegra_i2c_device1.dev.platform_data = &ventana_i2c1_platform_data; tegra_i2c_device2.dev.platform_data = &ventana_i2c2_platform_data; tegra_i2c_device3.dev.platform_data = &ventana_i2c3_platform_data; tegra_i2c_device4.dev.platform_data = &ventana_dvc_platform_data; platform_device_register(&tegra_i2c_device1); platform_device_register(&tegra_i2c_device2); platform_device_register(&tegra_i2c_device3); platform_device_register(&tegra_i2c_device4); i2c_register_board_info(0, &wm8903_board_info, 1); } static struct platform_device *ventana_uart_devices[] __initdata = { &tegra_uartb_device, &tegra_uartc_device, &tegra_uartd_device, }; static struct uart_clk_parent uart_parent_clk[] = { [0] = {.name = "pll_p"}, [1] = {.name = "pll_m"}, [2] = {.name = "clk_m"}, }; static struct tegra_uart_platform_data ventana_uart_pdata; static void __init uart_debug_init(void) { unsigned long rate; struct clk *c; /* UARTD is the debug port. */ pr_info("Selecting UARTD as the debug console\n"); ventana_uart_devices[2] = &debug_uartd_device; debug_uart_port_base = ((struct plat_serial8250_port *)( debug_uartd_device.dev.platform_data))->mapbase; debug_uart_clk = clk_get_sys("serial8250.0", "uartd"); /* Clock enable for the debug channel */ if (!IS_ERR_OR_NULL(debug_uart_clk)) { rate = ((struct plat_serial8250_port *)( debug_uartd_device.dev.platform_data))->uartclk; pr_info("The debug console clock name is %s\n", debug_uart_clk->name); c = tegra_get_clock_by_name("pll_p"); if (IS_ERR_OR_NULL(c)) pr_err("Not getting the parent clock pll_p\n"); else clk_set_parent(debug_uart_clk, c); clk_enable(debug_uart_clk); clk_set_rate(debug_uart_clk, rate); } else { pr_err("Not getting the clock %s for debug console\n", debug_uart_clk->name); } } static void __init ventana_uart_init(void) { int i; struct clk *c; for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) { c = tegra_get_clock_by_name(uart_parent_clk[i].name); if (IS_ERR_OR_NULL(c)) { pr_err("Not able to get the clock for %s\n", uart_parent_clk[i].name); continue; } uart_parent_clk[i].parent_clk = c; uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c); } ventana_uart_pdata.parent_clk_list = uart_parent_clk; ventana_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk); tegra_uartb_device.dev.platform_data = &ventana_uart_pdata; tegra_uartc_device.dev.platform_data = &ventana_uart_pdata; tegra_uartd_device.dev.platform_data = &ventana_uart_pdata; /* Register low speed only if it is selected */ if (!is_tegra_debug_uartport_hs()) uart_debug_init(); platform_add_devices(ventana_uart_devices, ARRAY_SIZE(ventana_uart_devices)); } #ifdef CONFIG_KEYBOARD_GPIO #define GPIO_KEY(_id, _gpio, _iswake) \ { \ .code = _id, \ .gpio = TEGRA_GPIO_##_gpio, \ .active_low = 1, \ .desc = #_id, \ .type = EV_KEY, \ .wakeup = _iswake, \ .debounce_interval = 10, \ } static struct gpio_keys_button ventana_keys[] = { [0] = GPIO_KEY(KEY_FIND, PQ3, 0), [1] = GPIO_KEY(KEY_HOME, PQ1, 0), [2] = GPIO_KEY(KEY_BACK, PQ2, 0), [3] = GPIO_KEY(KEY_VOLUMEUP, PQ5, 0), [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0), [5] = GPIO_KEY(KEY_POWER, PV2, 1), [6] = GPIO_KEY(KEY_MENU, PC7, 0), }; #define PMC_WAKE_STATUS 0x14 static int ventana_wakeup_key(void) { unsigned long status = readl(IO_ADDRESS(TEGRA_PMC_BASE) + PMC_WAKE_STATUS); return (status & (1 << TEGRA_WAKE_GPIO_PV2)) ? KEY_POWER : KEY_RESERVED; } static struct gpio_keys_platform_data ventana_keys_platform_data = { .buttons = ventana_keys, .nbuttons = ARRAY_SIZE(ventana_keys), .wakeup_key = ventana_wakeup_key, }; static struct platform_device ventana_keys_device = { .name = "gpio-keys", .id = 0, .dev = { .platform_data = &ventana_keys_platform_data, }, }; #endif static struct platform_device tegra_camera = { .name = "tegra_camera", .id = -1, }; static struct tegra_asoc_platform_data ventana_audio_pdata = { .gpio_spkr_en = TEGRA_GPIO_SPKR_EN, .gpio_hp_det = TEGRA_GPIO_HP_DET, .gpio_hp_mute = -1, .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN, .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN, .i2s_param[HIFI_CODEC] = { .audio_port_id = 0, .is_i2s_master = 1, .i2s_mode = TEGRA_DAIFMT_I2S, }, .i2s_param[BASEBAND] = { .audio_port_id = -1, }, .i2s_param[BT_SCO] = { .audio_port_id = 3, .is_i2s_master = 1, .i2s_mode = TEGRA_DAIFMT_DSP_A, }, }; static struct platform_device ventana_audio_device = { .name = "tegra-snd-wm8903", .id = 0, .dev = { .platform_data = &ventana_audio_pdata, }, }; static struct platform_device *ventana_devices[] __initdata = { &tegra_pmu_device, &tegra_gart_device, &tegra_aes_device, #ifdef CONFIG_KEYBOARD_GPIO &ventana_keys_device, #endif &tegra_wdt_device, &tegra_avp_device, &tegra_camera, &tegra_i2s_device1, &tegra_i2s_device2, &tegra_spdif_device, &tegra_das_device, &spdif_dit_device, &bluetooth_dit_device, &ventana_bt_rfkill_device, &tegra_pcm_device, &ventana_audio_device, }; static struct mxt_platform_data atmel_mxt_info = { .x_line = 27, .y_line = 42, .x_size = 768, .y_size = 1366, .blen = 0x20, .threshold = 0x3C, .voltage = 3300000, .orient = MXT_ROTATED_90, .irqflags = IRQF_TRIGGER_FALLING, }; static struct i2c_board_info __initdata i2c_info[] = { { I2C_BOARD_INFO("atmel_mxt_ts", 0x5A), .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6), .platform_data = &atmel_mxt_info, }, }; static int __init ventana_touch_init_atmel(void) { gpio_request(TEGRA_GPIO_PV6, "atmel-irq"); gpio_direction_input(TEGRA_GPIO_PV6); gpio_request(TEGRA_GPIO_PQ7, "atmel-reset"); gpio_direction_output(TEGRA_GPIO_PQ7, 0); msleep(1); gpio_set_value(TEGRA_GPIO_PQ7, 1); msleep(100); i2c_register_board_info(0, i2c_info, 1); return 0; } static struct panjit_i2c_ts_platform_data panjit_data = { .gpio_reset = TEGRA_GPIO_PQ7, }; static struct i2c_board_info __initdata ventana_i2c_bus1_touch_info[] = { { I2C_BOARD_INFO("panjit_touch", 0x3), .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6), .platform_data = &panjit_data, }, }; static int __init ventana_touch_init_panjit(void) { i2c_register_board_info(0, ventana_i2c_bus1_touch_info, 1); return 0; } static int __init ventana_gps_init(void) { struct clk *clk32 = clk_get_sys(NULL, "blink"); if (!IS_ERR(clk32)) { clk_set_rate(clk32,clk32->parent->rate); clk_enable(clk32); } return 0; } static struct tegra_usb_platform_data tegra_udc_pdata = { .port_otg = true, .has_hostpc = false, .phy_intf = TEGRA_USB_PHY_INTF_UTMI, .op_mode = TEGRA_USB_OPMODE_DEVICE, .u_data.dev = { .vbus_pmu_irq = 0, .vbus_gpio = -1, .charging_supported = false, .remote_wakeup_supported = false, }, .u_cfg.utmi = { .hssync_start_delay = 0, .elastic_limit = 16, .idle_wait_delay = 17, .term_range_adj = 6, .xcvr_setup = 8, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, .xcvr_setup_offset = 0, .xcvr_use_fuses = 1, }, }; static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = { .port_otg = true, .has_hostpc = false, .phy_intf = TEGRA_USB_PHY_INTF_UTMI, .op_mode = TEGRA_USB_OPMODE_HOST, .u_data.host = { .vbus_gpio = TEGRA_GPIO_PD0, .vbus_reg = NULL, .hot_plug = true, .remote_wakeup_supported = false, .power_off_on_suspend = false, }, .u_cfg.utmi = { .hssync_start_delay = 9, .elastic_limit = 16, .idle_wait_delay = 17, .term_range_adj = 6, .xcvr_setup = 8, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, }, }; static void ulpi_link_platform_open(void) { int reset_gpio = TEGRA_GPIO_PV1; gpio_request(reset_gpio, "ulpi_phy_reset"); gpio_direction_output(reset_gpio, 0); msleep(5); gpio_direction_output(reset_gpio, 1); } static struct tegra_usb_phy_platform_ops ulpi_link_plat_ops = { .open = ulpi_link_platform_open, }; static struct tegra_usb_platform_data tegra_ehci2_ulpi_link_pdata = { .port_otg = false, .has_hostpc = false, .phy_intf = TEGRA_USB_PHY_INTF_ULPI_LINK, .op_mode = TEGRA_USB_OPMODE_HOST, .u_data.host = { .vbus_gpio = -1, .vbus_reg = NULL, .hot_plug = false, .remote_wakeup_supported = false, .power_off_on_suspend = true, }, .u_cfg.ulpi = { .shadow_clk_delay = 10, .clock_out_delay = 1, .data_trimmer = 4, .stpdirnxt_trimmer = 4, .dir_trimmer = 4, .clk = "cdev2", }, .ops = &ulpi_link_plat_ops, }; static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = { .port_otg = false, .has_hostpc = false, .phy_intf = TEGRA_USB_PHY_INTF_UTMI, .op_mode = TEGRA_USB_OPMODE_HOST, .u_data.host = { .vbus_gpio = TEGRA_GPIO_PD3, .vbus_reg = NULL, .hot_plug = true, .remote_wakeup_supported = false, .power_off_on_suspend = false, }, .u_cfg.utmi = { .hssync_start_delay = 9, .elastic_limit = 16, .idle_wait_delay = 17, .term_range_adj = 6, .xcvr_setup = 8, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, }, }; static struct tegra_usb_otg_data tegra_otg_pdata = { .ehci_device = &tegra_ehci1_device, .ehci_pdata = &tegra_ehci1_utmi_pdata, }; static void ventana_usb_init(void) { /* OTG should be the first to be registered */ tegra_otg_device.dev.platform_data = &tegra_otg_pdata; platform_device_register(&tegra_otg_device); tegra_udc_device.dev.platform_data = &tegra_udc_pdata; platform_device_register(&tegra_udc_device); tegra_ehci2_device.dev.platform_data = &tegra_ehci2_ulpi_link_pdata; platform_device_register(&tegra_ehci2_device); tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata; platform_device_register(&tegra_ehci3_device); } static void __init tegra_ventana_init(void) { struct board_info BoardInfo; tegra_clk_init_from_table(ventana_clk_init_table); ventana_pinmux_init(); ventana_i2c_init(); ventana_uart_init(); platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices)); tegra_ram_console_debug_init(); ventana_sdhci_init(); ventana_charge_init(); ventana_regulator_init(); ventana_charger_init(); tegra_get_board_info(&BoardInfo); /* boards with sku > 0 have atmel touch panels */ if (BoardInfo.sku) { pr_info("Initializing Atmel touch driver\n"); ventana_touch_init_atmel(); } else { pr_info("Initializing Panjit touch driver\n"); ventana_touch_init_panjit(); } ventana_usb_init(); ventana_gps_init(); ventana_panel_init(); ventana_sensors_init(); ventana_bt_rfkill(); ventana_emc_init(); ventana_setup_bluesleep(); tegra_release_bootloader_fb(); } int __init tegra_ventana_protected_aperture_init(void) { if (!machine_is_ventana()) return 0; tegra_protected_aperture_init(tegra_grhost_aperture); return 0; } late_initcall(tegra_ventana_protected_aperture_init); void __init tegra_ventana_reserve(void) { if (memblock_reserve(0x0, 4096) < 0) pr_warn("Cannot reserve first 4K of memory for safety\n"); tegra_reserve(SZ_256M, SZ_8M + SZ_1M, SZ_16M); tegra_ram_console_debug_reserve(SZ_1M); } static const char *ventana_dt_board_compat[] = { "nvidia,ventana", NULL }; MACHINE_START(VENTANA, "ventana") .boot_params = 0x00000100, .map_io = tegra_map_common_io, .init_early = tegra_init_early, .init_irq = tegra_init_irq, .reserve = tegra_ventana_reserve, .timer = &tegra_timer, .init_machine = tegra_ventana_init, .dt_compat = ventana_dt_board_compat, MACHINE_END