ARM: DT: Add DT entry for PWMs and Backlight
[linux-3.10.git] / arch / arm / mach-tegra / board-roth.c
index 37ddb7a..2c6e333 100644 (file)
@@ -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/leds.h>
 #include <linux/leds_pwm.h>
 #include <linux/i2c/at24.h>
+#include <linux/issp.h>
 #include <linux/of_platform.h>
 #include <linux/usb/tegra_usb_phy.h>
-#include <asm/hardware/gic.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/irqs.h>
 #include <mach/pinmux.h>
-#include <mach/pinmux-tegra30.h>
+#include <mach/pinmux-t11.h>
 #include <mach/io_dpd.h>
 #include <mach/i2s.h>
 #include <mach/isomgr.h>
@@ -70,6 +76,7 @@
 #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},
@@ -227,6 +234,7 @@ static struct tegra_i2c_platform_data roth_i2c5_platform_data = {
        .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)
@@ -241,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;
@@ -268,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 = {
@@ -281,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)
 {
@@ -305,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();
@@ -392,30 +353,54 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
-static struct led_pwm roth_led_info[] = {
-       {
-               .name                   = "roth-led",
-               .default_trigger        = "none",
-               .pwm_id                 = 2,
-               .active_low             = 0,
-               .max_brightness         = 255,
-               .pwm_period_ns          = 10000000,
+
+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 led_pwm_platform_data roth_leds_pdata = {
-       .leds           = roth_led_info,
-       .num_leds       = ARRAY_SIZE(roth_led_info),
+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_leds_pwm_device = {
-       .name   = "leds_pwm",
-       .id     = -1,
+static struct platform_device roth_issp_device_p2560 = {
+       .name   = "issp",
        .dev    = {
-               .platform_data = &roth_leds_pdata,
+               .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,
@@ -443,9 +428,6 @@ static struct platform_device *roth_devices[] __initdata = {
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
        &tegra_aes_device,
 #endif
-
-       &tegra_pwfm_device,
-       &roth_leds_pwm_device,
 };
 
 #ifdef CONFIG_USB_SUPPORT
@@ -548,26 +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_clk_vefify_parents();
-       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();
@@ -578,7 +670,9 @@ static void __init tegra_roth_init(void)
        roth_emc_init();
        roth_edp_init();
        isomgr_init();
-       roth_panel_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
@@ -587,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
@@ -596,6 +689,7 @@ static void __init tegra_roth_init(void)
        roth_soctherm_init();
        roth_fan_init();
        tegra_register_fuse();
+       roth_issp_init();
 }
 
 static void __init roth_ramconsole_reserve(unsigned long size)
@@ -614,6 +708,10 @@ struct of_dev_auxdata roth_auxdata_lookup[] __initdata = {
        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
@@ -651,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_sys_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,