ARM: DT: Add DT entry for PWMs and Backlight
[linux-3.10.git] / arch / arm / mach-tegra / board-roth.c
index 746a86c..2c6e333 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-roth.c
  *
- * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2012-2013, 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
@@ -31,7 +31,9 @@
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/platform_data/tegra_usb.h>
-#include <linux/tegra_uart.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/rm31080a_ts.h>
+#include <linux/spi-tegra.h>
 #include <linux/memblock.h>
 #include <linux/rfkill-gpio.h>
 #include <linux/skbuff.h>
 #include <linux/regulator/consumer.h>
 #include <linux/max17048_battery.h>
 #include <linux/leds.h>
+#include <linux/leds_pwm.h>
 #include <linux/i2c/at24.h>
+#include <linux/issp.h>
 #include <linux/of_platform.h>
-#include <asm/hardware/gic.h>
+#include <linux/usb/tegra_usb_phy.h>
+#include <linux/clk/tegra.h>
+#include <linux/clocksource.h>
+#include <linux/irqchip.h>
+
+#include <asm/system_info.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/pinmux-t11.h>
 #include <mach/io_dpd.h>
 #include <mach/i2s.h>
+#include <mach/isomgr.h>
 #include <mach/tegra_asoc_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 <mach/edp.h>
 #include "devices.h"
 #include "gpio-names.h"
 #include "fuse.h"
+#include "iomap.h"
 #include "pm.h"
 #include "common.h"
 #include "tegra-board-id.h"
+#include "board-touch-raydium.h"
 
 #ifdef CONFIG_BT_BLUESLEEP
 static struct rfkill_gpio_platform_data roth_bt_rfkill_pdata = {
@@ -172,7 +179,7 @@ static __initdata struct tegra_clk_init_table roth_clk_init_table[] = {
        { "pll_m",      NULL,           0,              false},
        { "hda",        "pll_p",        108000000,      false},
        { "hda2codec_2x", "pll_p",      48000000,       false},
-       { "pwm",        "pll_p",        37000000,       false},
+       { "pwm",        "pll_p",        6000000,        false},
        { "blink",      "clk_32k",      32768,          true},
        { "i2s1",       "pll_a_out0",   0,              false},
        { "i2s3",       "pll_a_out0",   0,              false},
@@ -199,49 +206,35 @@ static __initdata struct tegra_clk_init_table roth_clk_init_table[] = {
 };
 
 static struct tegra_i2c_platform_data roth_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,
+       .bus_clk_rate   = 100000,
+       .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
+       .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
 };
 
 static struct tegra_i2c_platform_data roth_i2c2_platform_data = {
-       .adapter_nr     = 1,
-       .bus_count      = 1,
-       .bus_clk_rate   = { 100000, 0 },
+       .bus_clk_rate   = 100000,
        .is_clkon_always = true,
-       .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
-       .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
-       .arb_recovery = arb_lost_recovery,
+       .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
+       .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
 };
 
 static struct tegra_i2c_platform_data roth_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,
+       .bus_clk_rate   = 100000,
+       .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
+       .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
 };
 
 static struct tegra_i2c_platform_data roth_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,
+       .bus_clk_rate   = 10000,
+       .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
+       .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
 };
 
 static struct tegra_i2c_platform_data roth_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,
+       .bus_clk_rate   = 400000,
+       .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
+       .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
+       .needs_cl_dvfs_clock = true,
 };
 
 #if defined(CONFIG_ARCH_TEGRA_11x_SOC)
@@ -256,19 +249,10 @@ static struct i2c_board_info __initdata roth_codec_tfa9887R_info = {
 static struct i2c_board_info __initdata roth_codec_tfa9887L_info = {
        I2C_BOARD_INFO("tfa9887L", 0x34),
 };
-
-/* On A01, Left Speaker is moved to 0x34 */
-static struct i2c_board_info __initdata roth_codec_tfa9887L_info_a01 = {
-       I2C_BOARD_INFO("tfa9887L", 0x34),
-};
 #endif
 
 static void roth_i2c_init(void)
 {
-       struct board_info board_info;
-
-       tegra_get_board_info(&board_info);
-
        tegra11_i2c_device1.dev.platform_data = &roth_i2c1_platform_data;
        tegra11_i2c_device2.dev.platform_data = &roth_i2c2_platform_data;
        tegra11_i2c_device3.dev.platform_data = &roth_i2c3_platform_data;
@@ -283,11 +267,7 @@ static void roth_i2c_init(void)
 
        i2c_register_board_info(0, &rt5640_board_info, 1);
        i2c_register_board_info(0, &roth_codec_tfa9887R_info, 1);
-
-       if (board_info.fab >= BOARD_FAB_A01)
-               i2c_register_board_info(0, &roth_codec_tfa9887L_info_a01, 1);
-       else
-               i2c_register_board_info(0, &roth_codec_tfa9887L_info, 1);
+       i2c_register_board_info(0, &roth_codec_tfa9887L_info, 1);
 }
 
 static struct platform_device *roth_uart_devices[] __initdata = {
@@ -296,16 +276,6 @@ static struct platform_device *roth_uart_devices[] __initdata = {
        &tegra_uartc_device,
        &tegra_uartd_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 roth_uart_pdata;
-static struct tegra_uart_platform_data roth_loopback_uart_pdata;
 
 static void __init uart_debug_init(void)
 {
@@ -320,30 +290,6 @@ static void __init uart_debug_init(void)
 
 static void __init roth_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);
-       }
-       roth_uart_pdata.parent_clk_list = uart_parent_clk;
-       roth_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
-       roth_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
-       roth_loopback_uart_pdata.parent_clk_count =
-                                               ARRAY_SIZE(uart_parent_clk);
-       roth_loopback_uart_pdata.is_loopback = true;
-       tegra_uarta_device.dev.platform_data = &roth_uart_pdata;
-       tegra_uartb_device.dev.platform_data = &roth_uart_pdata;
-       tegra_uartc_device.dev.platform_data = &roth_uart_pdata;
-       tegra_uartd_device.dev.platform_data = &roth_uart_pdata;
-
        /* Register low speed only if it is selected */
        if (!is_tegra_debug_uartport_hs())
                uart_debug_init();
@@ -407,6 +353,55 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
+
+static struct issp_platform_data roth_issp_pdata_p2454 = {
+       .reset_gpio     = TEGRA_GPIO_PH4,
+       .data_gpio      = TEGRA_GPIO_PH6,
+       .clk_gpio       = TEGRA_GPIO_PH7,
+       .fw_name        = "p2454-uc.fw",
+       .si_id          = {0x00, 0xA2, 0x52, 0x21}, /* CY7C64345 */
+       .block_size     = 128,
+       .blocks         = 128,
+       .security_size  = 64,
+       .version_addr   = 0x0286,
+       .force_update   = 1,
+};
+
+static struct platform_device roth_issp_device_p2454 = {
+       .name   = "issp",
+       .dev    = {
+               .platform_data = &roth_issp_pdata_p2454,
+       },
+};
+
+static struct issp_platform_data roth_issp_pdata_p2560 = {
+       .reset_gpio     = TEGRA_GPIO_PH4,
+       .data_gpio      = TEGRA_GPIO_PH6,
+       .clk_gpio       = TEGRA_GPIO_PH7,
+       .fw_name        = "p2560-uc.fw",
+       .si_id          = {0x00, 0xA2, 0x52, 0x21}, /* CY7C64345 */
+       .block_size     = 128,
+       .blocks         = 128,
+       .security_size  = 64,
+       .version_addr   = 0x0286,
+       .force_update   = 0,
+};
+
+static struct platform_device roth_issp_device_p2560 = {
+       .name   = "issp",
+       .dev    = {
+               .platform_data = &roth_issp_pdata_p2560,
+       },
+};
+
+static void __init roth_issp_init(void)
+{
+       if (system_rev == P2454)
+               platform_device_register(&roth_issp_device_p2454);
+       else
+               platform_device_register(&roth_issp_device_p2560);
+}
+
 static struct platform_device *roth_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
@@ -482,6 +477,7 @@ static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
                .xcvr_lsrslew = 2,
                .xcvr_setup_offset = 0,
                .xcvr_use_fuses = 1,
+               .vbus_oc_map = 0x4,
        },
 };
 
@@ -507,6 +503,7 @@ static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
                .xcvr_lsrslew = 2,
                .xcvr_setup_offset = 0,
                .xcvr_use_fuses = 1,
+               .vbus_oc_map = 0x5,
        },
 };
 
@@ -533,25 +530,136 @@ static void roth_usb_init(void) { }
 
 static void roth_audio_init(void)
 {
-       struct board_info board_info;
-
-       tegra_get_board_info(&board_info);
-
        roth_audio_pdata.codec_name = "rt5640.0-001c";
        roth_audio_pdata.codec_dai_name = "rt5640-aif1";
 }
 
 
+static struct platform_device *roth_spi_devices[] __initdata = {
+       &tegra11_spi_device4,
+};
+
+struct spi_clk_parent spi_parent_clk_roth[] = {
+       [0] = {.name = "pll_p"},
+#ifndef CONFIG_TEGRA_PLLM_RESTRICTED
+       [1] = {.name = "pll_m"},
+       [2] = {.name = "clk_m"},
+#else
+       [1] = {.name = "clk_m"},
+#endif
+};
+
+static struct tegra_spi_platform_data roth_spi_pdata = {
+       .is_dma_based           = false,
+       .max_dma_buffer         = 16 * 1024,
+       .is_clkon_always        = false,
+       .max_rate               = 25000000,
+};
+
+static void __init roth_spi_init(void)
+{
+       int i;
+       struct clk *c;
+
+       for (i = 0; i < ARRAY_SIZE(spi_parent_clk_roth); ++i) {
+               c = tegra_get_clock_by_name(spi_parent_clk_roth[i].name);
+               if (IS_ERR_OR_NULL(c)) {
+                       pr_err("Not able to get the clock for %s\n",
+                               spi_parent_clk_roth[i].name);
+                       continue;
+               }
+               spi_parent_clk_roth[i].parent_clk = c;
+               spi_parent_clk_roth[i].fixed_clk_rate = clk_get_rate(c);
+       }
+       roth_spi_pdata.parent_clk_list = spi_parent_clk_roth;
+       roth_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_roth);
+       tegra11_spi_device4.dev.platform_data = &roth_spi_pdata;
+       platform_add_devices(roth_spi_devices,
+               ARRAY_SIZE(roth_spi_devices));
+}
+
+static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
+       /* name         parent          rate            enabled */
+       { "extern2",    "pll_p",        41000000,       false},
+       { "clk_out_2",  "extern2",      40800000,       false},
+       { NULL,         NULL,           0,              0},
+};
+
+struct rm_spi_ts_platform_data rm31080ts_roth_data = {
+       .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
+       .config = 0,
+       .platform_id = RM_PLATFORM_R005,
+       .name_of_clock = "clk_out_2",
+       .name_of_clock_con = "extern2",
+};
+
+static struct tegra_spi_device_controller_data dev_cdata = {
+       .rx_clk_tap_delay = 16,
+       .tx_clk_tap_delay = 16,
+};
+
+struct spi_board_info rm31080a_roth_spi_board[1] = {
+       {
+        .modalias = "rm_ts_spidev",
+        .bus_num = 3,
+        .chip_select = 2,
+        .max_speed_hz = 12 * 1000 * 1000,
+        .mode = SPI_MODE_0,
+        .controller_data = &dev_cdata,
+        .platform_data = &rm31080ts_roth_data,
+        },
+};
+
+static int __init roth_touch_init(void)
+{
+       struct board_info board_info;
+       int touch_panel_id = tegra_get_touch_panel_id();
+
+       tegra_get_board_info(&board_info);
+       if (touch_panel_id == PANEL_TPK ||
+                       touch_panel_id == PANEL_WINTEK) {
+               int err;
+               err = gpio_request(TOUCH_GPIO_CLK, "touch-gpio-clk");
+               if (err < 0)
+                       pr_err("%s: gpio_request failed %d\n",
+                               __func__, err);
+               else {
+                       err = gpio_direction_output(TOUCH_GPIO_CLK, 0);
+                       if (err < 0)
+                               pr_err("%s: set output failed %d\n",
+                               __func__, err);
+                       gpio_free(TOUCH_GPIO_CLK);
+               }
+               tegra_pinmux_set_pullupdown(TOUCH_GPIO_CLK_PG,
+                                               TEGRA_PUPD_NORMAL);
+               tegra_pinmux_set_tristate(TOUCH_GPIO_CLK_PG,
+                                               TEGRA_TRI_TRISTATE);
+               rm31080ts_roth_data.name_of_clock = NULL;
+               rm31080ts_roth_data.name_of_clock_con = NULL;
+       } else
+               tegra_clk_init_from_table(touch_clk_init_table);
+       rm31080a_roth_spi_board[0].irq =
+               gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
+       touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
+                               TOUCH_GPIO_RST_RAYDIUM_SPI,
+                               &rm31080ts_roth_data,
+                               &rm31080a_roth_spi_board[0],
+                               ARRAY_SIZE(rm31080a_roth_spi_board));
+       return 0;
+}
+
 static void __init tegra_roth_init(void)
 {
        tegra_clk_init_from_table(roth_clk_init_table);
-       tegra_smmu_init();
+       tegra_clk_verify_parents();
        tegra_soc_device_init("roth");
        tegra_enable_pinmux();
        roth_pinmux_init();
        roth_i2c_init();
+       roth_spi_init();
        roth_usb_init();
        roth_uart_init();
+       roth_led_init();
        roth_audio_init();
        platform_add_devices(roth_devices, ARRAY_SIZE(roth_devices));
        //tegra_ram_console_debug_init();
@@ -561,7 +669,10 @@ static void __init tegra_roth_init(void)
        roth_suspend_init();
        roth_emc_init();
        roth_edp_init();
-       roth_panel_init();
+       isomgr_init();
+       roth_touch_init();
+       /* roth will pass a null board id to panel_init */
+       roth_panel_init(0);
        roth_kbc_init();
        roth_pmon_init();
 #ifdef CONFIG_BT_BLUESLEEP
@@ -570,7 +681,6 @@ static void __init tegra_roth_init(void)
 #elif defined CONFIG_BLUEDROID_PM
        roth_setup_bluedroid_pm();
 #endif
-       tegra_release_bootloader_fb();
 #ifdef CONFIG_TEGRA_WDT_RECOVERY
        tegra_wdt_recovery_init();
 #endif
@@ -578,6 +688,8 @@ static void __init tegra_roth_init(void)
        roth_sensors_init();
        roth_soctherm_init();
        roth_fan_init();
+       tegra_register_fuse();
+       roth_issp_init();
 }
 
 static void __init roth_ramconsole_reserve(unsigned long size)
@@ -585,14 +697,34 @@ static void __init roth_ramconsole_reserve(unsigned long size)
        tegra_ram_console_debug_reserve(SZ_1M);
 }
 
+#ifdef CONFIG_USE_OF
+struct of_dev_auxdata roth_auxdata_lookup[] __initdata = {
+       OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
+               NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
+               NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
+       {}
+};
+#endif
+
 static void __init tegra_roth_dt_init(void)
 {
-       tegra_roth_init();
-
 #ifdef CONFIG_USE_OF
        of_platform_populate(NULL,
-               of_default_bus_match_table, NULL, NULL);
+               of_default_bus_match_table, roth_auxdata_lookup,
+               &platform_bus);
 #endif
+
+       tegra_roth_init();
 }
 
 static void __init tegra_roth_reserve(void)
@@ -617,9 +749,8 @@ MACHINE_START(ROTH, "roth")
        .map_io         = tegra_map_common_io,
        .reserve        = tegra_roth_reserve,
        .init_early     = tegra11x_init_early,
-       .init_irq       = tegra_dt_init_irq,
-       .handle_irq     = gic_handle_irq,
-       .timer          = &tegra_timer,
+       .init_irq       = irqchip_init,
+       .init_time      = clocksource_of_init,
        .init_machine   = tegra_roth_dt_init,
        .restart        = tegra_assert_system_reset,
        .dt_compat      = roth_dt_board_compat,