/* * arch/arm/mach-tegra/board-enterprise.c * * Copyright (c) 2011, NVIDIA Corporation. * * 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 "board.h" #include "clock.h" #include "board-enterprise.h" #include "devices.h" #include "gpio-names.h" #include "fuse.h" static struct usb_mass_storage_platform_data tegra_usb_fsg_platform = { .vendor = "NVIDIA", .product = "Tegra 3", .nluns = 1, }; static struct platform_device tegra_usb_fsg_device = { .name = "usb_mass_storage", .id = -1, .dev = { .platform_data = &tegra_usb_fsg_platform, }, }; static struct plat_serial8250_port debug_uart_platform_data[] = { { .membase = IO_ADDRESS(TEGRA_UARTA_BASE), .mapbase = TEGRA_UARTA_BASE, .irq = INT_UARTA, .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE, .type = PORT_TEGRA, .iotype = UPIO_MEM, .regshift = 2, .uartclk = 216000000, }, { .flags = 0, } }; static struct platform_device debug_uart = { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = debug_uart_platform_data, }, }; /* !!!TODO: Change for enterprise (Taken from Cardhu) */ static struct tegra_utmip_config utmi_phy_config[] = { [0] = { .hssync_start_delay = 0, .idle_wait_delay = 17, .elastic_limit = 16, .term_range_adj = 6, .xcvr_setup = 15, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, }, [1] = { .hssync_start_delay = 0, .idle_wait_delay = 17, .elastic_limit = 16, .term_range_adj = 6, .xcvr_setup = 15, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, }, [2] = { .hssync_start_delay = 0, .idle_wait_delay = 17, .elastic_limit = 16, .term_range_adj = 6, .xcvr_setup = 8, .xcvr_lsfslew = 2, .xcvr_lsrslew = 2, }, }; #ifdef CONFIG_BCM4329_RFKILL static struct resource enterprise_bcm4329_rfkill_resources[] = { { .name = "bcm4329_nshutdown_gpio", .start = TEGRA_GPIO_PU0, .end = TEGRA_GPIO_PU0, .flags = IORESOURCE_IO, }, }; static struct platform_device enterprise_bcm4329_rfkill_device = { .name = "bcm4329_rfkill", .id = -1, .num_resources = ARRAY_SIZE(enterprise_bcm4329_rfkill_resources), .resource = enterprise_bcm4329_rfkill_resources, }; static noinline void __init enterprise_bt_rfkill(void) { platform_device_register(&enterprise_bcm4329_rfkill_device); return; } #else static inline void enterprise_bt_rfkill(void) { } #endif static __initdata struct tegra_clk_init_table enterprise_clk_init_table[] = { /* name parent rate enabled */ { "uarta", "pll_p", 216000000, true}, { "uartb", "pll_p", 216000000, false}, { "uartc", "pll_p", 216000000, false}, { "uartd", "pll_p", 216000000, false}, { "uarte", "pll_p", 216000000, false}, { "pll_m", NULL, 0, true}, { "hda", "pll_p", 108000000, false}, { "hda2codec_2x","pll_p", 48000000, false}, { "pwm", "clk_32k", 32768, false}, { "blink", "clk_32k", 32768, true}, { "pll_a", NULL, 56448000, false}, { "pll_a_out0", NULL, 11289600, false}, { "d_audio","pll_a_out0", 11289600, false}, { NULL, NULL, 0, 0}, }; static char *usb_functions[] = { "mtp", "usb_mass_storage" }; static char *usb_functions_adb[] = { "mtp", "adb", "usb_mass_storage" }; static struct android_usb_product usb_products[] = { { .product_id = 0x7102, .num_functions = ARRAY_SIZE(usb_functions), .functions = usb_functions, }, { .product_id = 0x7100, .num_functions = ARRAY_SIZE(usb_functions_adb), .functions = usb_functions_adb, }, }; /* standard android USB platform data */ static struct android_usb_platform_data andusb_plat = { .vendor_id = 0x0955, .product_id = 0x7100, .manufacturer_name = "NVIDIA", .product_name = "Enterprise", .serial_number = NULL, .num_products = ARRAY_SIZE(usb_products), .products = usb_products, .num_functions = ARRAY_SIZE(usb_functions_adb), .functions = usb_functions_adb, }; static struct platform_device androidusb_device = { .name = "android_usb", .id = -1, .dev = { .platform_data = &andusb_plat, }, }; static struct i2c_board_info __initdata enterprise_i2c_bus1_board_info[] = { { I2C_BOARD_INFO("wm8903", 0x1a), }, }; static struct tegra_i2c_platform_data enterprise_i2c1_platform_data = { .adapter_nr = 0, .bus_count = 1, .bus_clk_rate = { 100000, 0 }, }; static struct tegra_i2c_platform_data enterprise_i2c2_platform_data = { .adapter_nr = 1, .bus_count = 1, .bus_clk_rate = { 100000, 0 }, .is_clkon_always = true, }; static struct tegra_i2c_platform_data enterprise_i2c3_platform_data = { .adapter_nr = 2, .bus_count = 1, .bus_clk_rate = { 100000, 0 }, }; static struct tegra_i2c_platform_data enterprise_i2c4_platform_data = { .adapter_nr = 3, .bus_count = 1, .bus_clk_rate = { 100000, 0 }, }; static struct tegra_i2c_platform_data enterprise_i2c5_platform_data = { .adapter_nr = 4, .bus_count = 1, .bus_clk_rate = { 100000, 0 }, }; static struct tegra_audio_platform_data tegra_i2s_pdata[] = { [0] = { .i2s_master = true, .dma_on = true, /* use dma by default */ .i2s_master_clk = 44100, .dev_clk_rate = 11289600, .mode = AUDIO_FRAME_FORMAT_I2S, .fifo_fmt = AUDIO_FIFO_PACK_16, .bit_size = AUDIO_BIT_SIZE_16, .i2s_bus_width = 32, .dsp_bus_width = 16, }, [1] = { .i2s_master = true, .dma_on = true, /* use dma by default */ .i2s_master_clk = 8000, .dev_clk_rate = 1024000, .mode = AUDIO_FRAME_FORMAT_DSP, .fifo_fmt = AUDIO_FIFO_NOP, .bit_size = AUDIO_BIT_SIZE_16, .i2s_bus_width = 32, .dsp_bus_width = 16, }, [2] = { .i2s_master = true, .dma_on = true, /* use dma by default */ .i2s_master_clk = 8000, .dev_clk_rate = 1024000, .mode = AUDIO_FRAME_FORMAT_DSP, .fifo_fmt = AUDIO_FIFO_NOP, .bit_size = AUDIO_BIT_SIZE_16, .i2s_bus_width = 32, .dsp_bus_width = 16, }, }; static struct tegra_audio_platform_data tegra_spdif_pdata = { .dma_on = true, /* use dma by default */ .dev_clk_rate = 5644800, .mode = SPDIF_BIT_MODE_MODE16BIT, .fifo_fmt = AUDIO_FIFO_PACK_16, }; struct wired_jack_conf audio_wr_jack_conf = { .hp_det_n = TEGRA_GPIO_PW2, .en_mic_ext = TEGRA_GPIO_PX1, .en_mic_int = TEGRA_GPIO_PX0, }; static void enterprise_audio_init(void) { #if defined(CONFIG_SND_HDA_TEGRA) platform_device_register(&tegra_hda_device); #endif tegra_i2s_device1.dev.platform_data = &tegra_i2s_pdata[0]; platform_device_register(&tegra_i2s_device1); tegra_i2s_device2.dev.platform_data = &tegra_i2s_pdata[1]; platform_device_register(&tegra_i2s_device2); tegra_i2s_device3.dev.platform_data = &tegra_i2s_pdata[2]; platform_device_register(&tegra_i2s_device3); tegra_spdif_device.dev.platform_data = &tegra_spdif_pdata; platform_device_register(&tegra_spdif_device); } static void enterprise_i2c_init(void) { tegra_i2c_device1.dev.platform_data = &enterprise_i2c1_platform_data; tegra_i2c_device2.dev.platform_data = &enterprise_i2c2_platform_data; tegra_i2c_device3.dev.platform_data = &enterprise_i2c3_platform_data; tegra_i2c_device4.dev.platform_data = &enterprise_i2c4_platform_data; tegra_i2c_device5.dev.platform_data = &enterprise_i2c5_platform_data; // setting audio codec on i2c_4 i2c_register_board_info(4, enterprise_i2c_bus1_board_info, 1); platform_device_register(&tegra_i2c_device5); platform_device_register(&tegra_i2c_device4); platform_device_register(&tegra_i2c_device3); platform_device_register(&tegra_i2c_device2); platform_device_register(&tegra_i2c_device1); } static struct resource tegra_rtc_resources[] = { [0] = { .start = TEGRA_RTC_BASE, .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = INT_RTC, .end = INT_RTC, .flags = IORESOURCE_IRQ, }, }; static struct platform_device tegra_rtc_device = { .name = "tegra_rtc", .id = -1, .resource = tegra_rtc_resources, .num_resources = ARRAY_SIZE(tegra_rtc_resources), }; static struct platform_device tegra_camera = { .name = "tegra_camera", .id = -1, }; static struct platform_device *enterprise_devices[] __initdata = { &tegra_usb_fsg_device, &androidusb_device, &debug_uart, &tegra_uartb_device, &tegra_uartc_device, &tegra_uartd_device, &tegra_uarte_device, &pmu_device, &tegra_rtc_device, &tegra_udc_device, #if defined(CONFIG_TEGRA_IOVMM_SMMU) &tegra_smmu_device, #endif &tegra_wdt_device, &tegra_avp_device, &tegra_camera, &tegra_spi_device4, }; static struct usb_phy_plat_data tegra_usb_phy_pdata[] = { [0] = { .instance = 0, .vbus_gpio = -1, .vbus_reg_supply = "vdd_vbus_micro_usb", }, [1] = { .instance = 1, .vbus_gpio = -1, }, [2] = { .instance = 2, .vbus_gpio = -1, .vbus_reg_supply = "vdd_vbus_typea_usb", }, }; static struct tegra_ehci_platform_data tegra_ehci_pdata[] = { [0] = { .phy_config = &utmi_phy_config[0], .operating_mode = TEGRA_USB_HOST, .power_down_on_bus_suspend = 1, }, [1] = { .phy_config = &utmi_phy_config[1], .operating_mode = TEGRA_USB_HOST, .power_down_on_bus_suspend = 1, }, [2] = { .phy_config = &utmi_phy_config[2], .operating_mode = TEGRA_USB_HOST, .power_down_on_bus_suspend = 1, }, }; struct platform_device *tegra_usb_otg_host_register(void) { struct platform_device *pdev; void *platform_data; int val; pdev = platform_device_alloc(tegra_ehci1_device.name, tegra_ehci1_device.id); if (!pdev) return NULL; val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, tegra_ehci1_device.num_resources); if (val) goto error; pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), GFP_KERNEL); if (!platform_data) goto error; memcpy(platform_data, &tegra_ehci_pdata[0], sizeof(struct tegra_ehci_platform_data)); pdev->dev.platform_data = platform_data; val = platform_device_add(pdev); if (val) goto error_add; return pdev; error_add: kfree(platform_data); error: pr_err("%s: failed to add the host contoller device\n", __func__); platform_device_put(pdev); return NULL; } void tegra_usb_otg_host_unregister(struct platform_device *pdev) { platform_device_unregister(pdev); } static struct tegra_otg_platform_data tegra_otg_pdata = { .host_register = &tegra_usb_otg_host_register, .host_unregister = &tegra_usb_otg_host_unregister, }; static void enterprise_usb_init(void) { tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata)); tegra_otg_device.dev.platform_data = &tegra_otg_pdata; platform_device_register(&tegra_otg_device); tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1]; platform_device_register(&tegra_ehci2_device); tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2]; platform_device_register(&tegra_ehci3_device); } static void enterprise_gps_init(void) { tegra_gpio_enable(TEGRA_GPIO_PU2); tegra_gpio_enable(TEGRA_GPIO_PU3); } static void enterprise_modem_init(void) { tegra_gpio_enable(TEGRA_GPIO_PH5); } static void __init tegra_enterprise_init(void) { char serial[20]; tegra_common_init(); tegra_clk_init_from_table(enterprise_clk_init_table); enterprise_pinmux_init(); enterprise_i2c_init(); snprintf(serial, sizeof(serial), "%llx", tegra_chip_uid()); andusb_plat.serial_number = kstrdup(serial, GFP_KERNEL); platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices)); enterprise_audio_init(); enterprise_sdhci_init(); enterprise_regulator_init(); touch_init(); enterprise_usb_init(); enterprise_gps_init(); enterprise_modem_init(); enterprise_panel_init(); enterprise_bt_rfkill(); audio_wired_jack_init(); enterprise_emc_init(); } static void __init tegra_enterprise_reserve(void) { #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM) tegra_reserve(0, SZ_4M, SZ_8M); #else tegra_reserve(SZ_128M, SZ_4M, SZ_8M); #endif } MACHINE_START(TEGRA_ENTERPRISE, "tegra_enterprise") .boot_params = 0x80000100, .phys_io = IO_APB_PHYS, .io_pg_offst = ((IO_APB_VIRT) >> 18) & 0xfffc, .init_irq = tegra_init_irq, .init_machine = tegra_enterprise_init, .map_io = tegra_map_common_io, .reserve = tegra_enterprise_reserve, .timer = &tegra_timer, MACHINE_END