ARM: tegra: dalmore: creating board files
Change-Id: I5c3fe127403b1a01c82d88b821a4a28cad25d026
Signed-off-by: aghuge <aghuge@nvidia.com>
Reviewed-on: http://git-master/r/118305
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
diff --git a/arch/arm/mach-tegra/board-dalmore.c b/arch/arm/mach-tegra/board-dalmore.c
new file mode 100644
index 0000000..7111994
--- /dev/null
+++ b/arch/arm/mach-tegra/board-dalmore.c
@@ -0,0 +1,551 @@
+/*
+ * arch/arm/mach-tegra/board-dalmore.c
+ *
+ * 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 version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/ctype.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/serial_8250.h>
+#include <linux/i2c.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/i2c-tegra.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/platform_data/tegra_usb.h>
+#include <linux/spi/spi.h>
+#include <linux/tegra_uart.h>
+#include <linux/memblock.h>
+#include <linux/spi-tegra.h>
+#include <linux/nfc/pn544.h>
+#include <linux/skbuff.h>
+#include <linux/ti_wilink_st.h>
+#include <linux/regulator/consumer.h>
+#include <linux/smb349-charger.h>
+#include <linux/max17048_battery.h>
+#include <linux/leds.h>
+#include <linux/i2c/at24.h>
+
+#include <asm/hardware/gic.h>
+
+#include <mach/clk.h>
+#include <mach/iomap.h>
+#include <mach/irqs.h>
+#include <mach/pinmux.h>
+#include <mach/pinmux-tegra30.h>
+#include <mach/iomap.h>
+#include <mach/io.h>
+#include <mach/io_dpd.h>
+#include <mach/i2s.h>
+#include <mach/tegra_rt5640_pdata.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/usb_phy.h>
+#include <mach/gpio-tegra.h>
+#include <mach/tegra_fiq_debugger.h>
+
+#include "board.h"
+#include "clock.h"
+#include "board-dalmore.h"
+#include "devices.h"
+#include "gpio-names.h"
+#include "fuse.h"
+#include "pm.h"
+#include "common.h"
+
+static __initdata struct tegra_clk_init_table dalmore_clk_init_table[] = {
+ /* name parent rate enabled */
+ { "pll_m", NULL, 0, false},
+ { "hda", "pll_p", 108000000, false},
+ { "hda2codec_2x", "pll_p", 48000000, false},
+ { "pwm", "pll_p", 3187500, false},
+ { "blink", "clk_32k", 32768, true},
+ { "i2s1", "pll_a_out0", 0, false},
+ { "i2s3", "pll_a_out0", 0, false},
+ { "i2s4", "pll_a_out0", 0, false},
+ { "spdif_out", "pll_a_out0", 0, false},
+ { "d_audio", "clk_m", 12000000, false},
+ { "dam0", "clk_m", 12000000, false},
+ { "dam1", "clk_m", 12000000, false},
+ { "dam2", "clk_m", 12000000, false},
+ { "audio1", "i2s1_sync", 0, false},
+ { "audio3", "i2s3_sync", 0, false},
+ { "vi_sensor", "pll_p", 150000000, false},
+ { "i2c1", "pll_p", 3200000, false},
+ { "i2c2", "pll_p", 3200000, false},
+ { "i2c3", "pll_p", 3200000, false},
+ { "i2c4", "pll_p", 3200000, false},
+ { "i2c5", "pll_p", 3200000, false},
+ { NULL, NULL, 0, 0},
+};
+
+static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
+ .adapter_nr = 0,
+ .bus_count = 1,
+ .bus_clk_rate = { 100000, 0 },
+ .scl_gpio = {TEGRA_GPIO_I2C1_SCL, 0},
+ .sda_gpio = {TEGRA_GPIO_I2C1_SDA, 0},
+ .arb_recovery = arb_lost_recovery,
+};
+
+static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
+ .adapter_nr = 1,
+ .bus_count = 1,
+ .bus_clk_rate = { 100000, 0 },
+ .is_clkon_always = true,
+ .scl_gpio = {TEGRA_GPIO_I2C2_SCL, 0},
+ .sda_gpio = {TEGRA_GPIO_I2C2_SDA, 0},
+ .arb_recovery = arb_lost_recovery,
+};
+
+static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
+ .adapter_nr = 2,
+ .bus_count = 1,
+ .bus_clk_rate = { 100000, 0 },
+ .scl_gpio = {TEGRA_GPIO_I2C3_SCL, 0},
+ .sda_gpio = {TEGRA_GPIO_I2C3_SDA, 0},
+ .arb_recovery = arb_lost_recovery,
+};
+
+static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
+ .adapter_nr = 3,
+ .bus_count = 1,
+ .bus_clk_rate = { 10000, 0 },
+ .scl_gpio = {TEGRA_GPIO_I2C4_SCL, 0},
+ .sda_gpio = {TEGRA_GPIO_I2C4_SDA, 0},
+ .arb_recovery = arb_lost_recovery,
+};
+
+static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
+ .adapter_nr = 4,
+ .bus_count = 1,
+ .bus_clk_rate = { 400000, 0 },
+ .scl_gpio = {TEGRA_GPIO_I2C5_SCL, 0},
+ .sda_gpio = {TEGRA_GPIO_I2C5_SDA, 0},
+ .arb_recovery = arb_lost_recovery,
+};
+
+
+
+static void dalmore_i2c_init(void)
+{
+ struct board_info board_info;
+
+ tegra_get_board_info(&board_info);
+
+ tegra_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
+ tegra_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
+ tegra_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
+ tegra_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
+ tegra_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
+
+ 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 platform_device *dalmore_uart_devices[] __initdata = {
+ &tegra_uarta_device,
+ &tegra_uartb_device,
+ &tegra_uartc_device,
+ &tegra_uartd_device,
+ &tegra_uarte_device,
+};
+static struct uart_clk_parent uart_parent_clk[] = {
+ [0] = {.name = "clk_m"},
+ [1] = {.name = "pll_p"},
+#ifndef CONFIG_TEGRA_PLLM_RESTRICTED
+ [2] = {.name = "pll_m"},
+#endif
+};
+
+static struct tegra_uart_platform_data dalmore_uart_pdata;
+static struct tegra_uart_platform_data dalmore_loopback_uart_pdata;
+
+static void __init uart_debug_init(void)
+{
+ int debug_port_id;
+
+ debug_port_id = get_tegra_uart_debug_port_id();
+ if (debug_port_id < 0)
+ debug_port_id = 3;
+
+ switch (debug_port_id) {
+ case 0:
+ /* UARTA is the debug port. */
+ pr_info("Selecting UARTA as the debug console\n");
+ dalmore_uart_devices[0] = &debug_uarta_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uarta_device.dev.platform_data))->mapbase;
+ break;
+
+ case 1:
+ /* UARTB is the debug port. */
+ pr_info("Selecting UARTB as the debug console\n");
+ dalmore_uart_devices[1] = &debug_uartb_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uartb");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uartb_device.dev.platform_data))->mapbase;
+ break;
+
+ case 2:
+ /* UARTC is the debug port. */
+ pr_info("Selecting UARTC as the debug console\n");
+ dalmore_uart_devices[2] = &debug_uartc_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uartc");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uartc_device.dev.platform_data))->mapbase;
+ break;
+
+ case 3:
+ /* UARTD is the debug port. */
+ pr_info("Selecting UARTD as the debug console\n");
+ dalmore_uart_devices[3] = &debug_uartd_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uartd");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uartd_device.dev.platform_data))->mapbase;
+ break;
+
+ case 4:
+ /* UARTE is the debug port. */
+ pr_info("Selecting UARTE as the debug console\n");
+ dalmore_uart_devices[4] = &debug_uarte_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uarte");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uarte_device.dev.platform_data))->mapbase;
+ break;
+
+ default:
+ pr_info("The debug console id %d is invalid, Assuming UARTA",
+ debug_port_id);
+ dalmore_uart_devices[0] = &debug_uarta_device;
+ debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
+ debug_uart_port_base = ((struct plat_serial8250_port *)(
+ debug_uarta_device.dev.platform_data))->mapbase;
+ break;
+ }
+}
+
+static void __init dalmore_uart_init(void)
+{
+ struct clk *c;
+ int i;
+
+ 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);
+ }
+ dalmore_uart_pdata.parent_clk_list = uart_parent_clk;
+ dalmore_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
+ dalmore_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
+ dalmore_loopback_uart_pdata.parent_clk_count =
+ ARRAY_SIZE(uart_parent_clk);
+ dalmore_loopback_uart_pdata.is_loopback = true;
+ tegra_uarta_device.dev.platform_data = &dalmore_uart_pdata;
+ tegra_uartb_device.dev.platform_data = &dalmore_uart_pdata;
+ tegra_uartc_device.dev.platform_data = &dalmore_uart_pdata;
+ tegra_uartd_device.dev.platform_data = &dalmore_uart_pdata;
+ /* UARTE is used for loopback test purpose */
+ tegra_uarte_device.dev.platform_data = &dalmore_loopback_uart_pdata;
+
+ /* Register low speed only if it is selected */
+ if (!is_tegra_debug_uartport_hs()) {
+ uart_debug_init();
+ /* Clock enable for the debug channel */
+ if (!IS_ERR_OR_NULL(debug_uart_clk)) {
+ 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, clk_get_rate(c));
+ } else {
+ pr_err("Not getting the clock %s for debug console\n",
+ debug_uart_clk->name);
+ }
+ }
+
+ platform_add_devices(dalmore_uart_devices,
+ ARRAY_SIZE(dalmore_uart_devices));
+}
+
+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 tegra_rt5640_platform_data dalmore_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,
+};
+
+static struct platform_device dalmore_audio_device = {
+ .name = "tegra-snd-rt5640",
+ .id = 0,
+ .dev = {
+ .platform_data = &dalmore_audio_pdata,
+ },
+};
+
+
+static struct platform_device *dalmore_devices[] __initdata = {
+ &tegra_pmu_device,
+ &tegra_rtc_device,
+ &tegra_udc_device,
+#if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
+ &tegra_smmu_device,
+#endif
+#if defined(CONFIG_TEGRA_AVP)
+ &tegra_avp_device,
+#endif
+#if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
+ &tegra_se_device,
+#endif
+ &tegra_ahub_device,
+ &tegra_pcm_device,
+ &dalmore_audio_device,
+ &tegra_hda_device,
+#if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
+ &tegra_aes_device,
+#endif
+};
+
+static struct tegra_usb_platform_data tegra_udc_pdata = {
+ .port_otg = true,
+ .has_hostpc = true,
+ .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 = true,
+ .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
+ .op_mode = TEGRA_USB_OPMODE_HOST,
+ .u_data.host = {
+ .vbus_gpio = -1,
+ .vbus_reg = "usb_vbus_otg",
+ .hot_plug = true,
+ .remote_wakeup_supported = true,
+ .power_off_on_suspend = true,
+ },
+ .u_cfg.utmi = {
+ .hssync_start_delay = 0,
+ .elastic_limit = 16,
+ .idle_wait_delay = 17,
+ .term_range_adj = 6,
+ .xcvr_setup = 15,
+ .xcvr_lsfslew = 2,
+ .xcvr_lsrslew = 2,
+ .xcvr_setup_offset = 0,
+ .xcvr_use_fuses = 1,
+ },
+};
+
+
+static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
+ .port_otg = false,
+ .has_hostpc = true,
+ .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
+ .op_mode = TEGRA_USB_OPMODE_HOST,
+ .u_data.host = {
+ .vbus_gpio = -1,
+ .vbus_reg = NULL,
+ .hot_plug = false,
+ .remote_wakeup_supported = true,
+ .power_off_on_suspend = true,
+
+ },
+ .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_otg_data tegra_otg_pdata = {
+ .ehci_device = &tegra_ehci1_device,
+ .ehci_pdata = &tegra_ehci1_utmi_pdata,
+};
+
+#if CONFIG_USB_SUPPORT
+static void dalmore_usb_init(void)
+{
+ tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
+ platform_device_register(&tegra_otg_device);
+
+ /* Setup the udc platform data */
+ tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
+
+ tegra_ehci2_device.dev.platform_data = &tegra_ehci2_utmi_pdata;
+ platform_device_register(&tegra_ehci2_device);
+}
+
+static void dalmore_modem_init(void)
+{
+ int ret;
+
+ ret = gpio_request(TEGRA_GPIO_W_DISABLE, "w_disable_gpio");
+ if (ret < 0)
+ pr_err("%s: gpio_request failed for gpio %d\n",
+ __func__, TEGRA_GPIO_W_DISABLE);
+ else
+ gpio_direction_output(TEGRA_GPIO_W_DISABLE, 1);
+
+
+ ret = gpio_request(TEGRA_GPIO_MODEM_RSVD1, "Port_V_PIN_0");
+ if (ret < 0)
+ pr_err("%s: gpio_request failed for gpio %d\n",
+ __func__, TEGRA_GPIO_MODEM_RSVD1);
+ else
+ gpio_direction_input(TEGRA_GPIO_MODEM_RSVD1);
+
+
+ ret = gpio_request(TEGRA_GPIO_MODEM_RSVD2, "Port_H_PIN_7");
+ if (ret < 0)
+ pr_err("%s: gpio_request failed for gpio %d\n",
+ __func__, TEGRA_GPIO_MODEM_RSVD2);
+ else
+ gpio_direction_output(TEGRA_GPIO_MODEM_RSVD2, 1);
+
+}
+
+#else
+static void dalmore_usb_init(void) { }
+static void dalmore_modem_init(void) { }
+#endif
+
+static void dalmore_audio_init(void)
+{
+ struct board_info board_info;
+
+ tegra_get_board_info(&board_info);
+
+ dalmore_audio_pdata.codec_name = "rt5640.4-001c";
+ dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
+}
+
+static void __init tegra_dalmore_init(void)
+{
+ tegra_clk_init_from_table(dalmore_clk_init_table);
+ tegra_enable_pinmux();
+ dalmore_pinmux_init();
+ dalmore_i2c_init();
+ dalmore_usb_init();
+ dalmore_uart_init();
+ dalmore_audio_init();
+ platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
+ tegra_ram_console_debug_init();
+ tegra_io_dpd_init();
+ dalmore_sdhci_init();
+ dalmore_regulator_init();
+ dalmore_suspend_init();
+ dalmore_emc_init();
+ tegra_release_bootloader_fb();
+ dalmore_modem_init();
+#ifdef CONFIG_TEGRA_WDT_RECOVERY
+ tegra_wdt_recovery_init();
+#endif
+ tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
+}
+
+static void __init dalmore_ramconsole_reserve(unsigned long size)
+{
+ tegra_ram_console_debug_reserve(SZ_1M);
+}
+
+static void __init tegra_dalmore_reserve(void)
+{
+#if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
+ /* support 1920X1200 with 24bpp */
+ tegra_reserve(0, SZ_8M + SZ_1M, SZ_8M + SZ_1M);
+#else
+ tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
+#endif
+ dalmore_ramconsole_reserve(SZ_1M);
+}
+
+MACHINE_START(DALMORE, "dalmore")
+ .atag_offset = 0x100,
+ .soc = &tegra_soc_desc,
+ .map_io = tegra_map_common_io,
+ .reserve = tegra_dalmore_reserve,
+ .init_early = tegra30_init_early,
+ .init_irq = tegra_init_irq,
+ .handle_irq = gic_handle_irq,
+ .timer = &tegra_timer,
+ .init_machine = tegra_dalmore_init,
+ .restart = tegra_assert_system_reset,
+MACHINE_END