drivers: video: tegra: detect platform at runtime
Chetan Kumar N G [Thu, 27 Jun 2013 17:55:34 +0000 (10:55 -0700)]
This change is a part of the effort to enable runtime
platform detection and reduce compile-time conditionals.

Bug 1333554

Change-Id: Ie70edf370e361a07f58b610d58bc09eebe156ffd
Signed-off-by: Chetan Kumar N G <chetankumarn@nvidia.com>
Reviewed-on: http://git-master/r/264030
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>

drivers/video/tegra/dc/dsi.c
drivers/video/tegra/dc/window.c
drivers/video/tegra/fb.c

index 0e765ef..1152e67 100644 (file)
@@ -39,6 +39,7 @@
 #include <mach/dc.h>
 #include <mach/fb.h>
 #include <mach/csi.h>
+#include <mach/hardware.h>
 #include <linux/nvhost.h>
 
 #include "dc_reg.h"
 #define APB_MISC_GP_MIPI_PAD_CTRL_0    (TEGRA_APB_MISC_BASE + 0x820)
 #define DSIB_MODE_ENABLE               0x2
 
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
-#define DSI_USE_SYNC_POINTS 0
-#else
-#define DSI_USE_SYNC_POINTS 1
-#endif
-
 #define S_TO_MS(x)                     (1000 * (x))
 #define MS_TO_US(x)                    (1000 * (x))
 
@@ -97,9 +92,7 @@
 #define DSI_LP_OP_READ                 0x2
 
 #define DSI_HOST_IDLE_PERIOD           1000
-#if DSI_USE_SYNC_POINTS
 static atomic_t dsi_syncpt_rst = ATOMIC_INIT(0);
-#endif
 
 static bool enable_read_debug;
 module_param(enable_read_debug, bool, 0644);
@@ -811,10 +804,8 @@ static void tegra_dsi_init_sw(struct tegra_dc *dc,
 
        dev_info(&dc->ndev->dev, "DSI: HS clock rate is %d\n",
                                        dsi->target_hs_clk_khz);
-
-#if DSI_USE_SYNC_POINTS
-       dsi->syncpt_id = NVSYNCPT_DSI;
-#endif
+       if (!tegra_cpu_is_asim())
+               dsi->syncpt_id = NVSYNCPT_DSI;
 
        /*
         * Force video clock to be continuous mode if
@@ -1673,10 +1664,9 @@ static void tegra_dsi_set_pkt_seq(struct tegra_dc *dc,
                                pkt_seq = dsi_pkt_seq_video_non_burst;
                        }
 
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
                        /* Simulator does not support EOT packet yet */
-                       pkt_seq = dsi_pkt_seq_video_non_burst_no_eot;
-#endif
+                       if (tegra_cpu_is_asim())
+                               pkt_seq = dsi_pkt_seq_video_non_burst_no_eot;
                        break;
                }
        }
@@ -2781,10 +2771,8 @@ static struct dsi_status *tegra_dsi_prepare_host_transmission(
        if (restart_dc_stream)
                init_status->dc_stream = DSI_DC_STREAM_ENABLE;
 
-#if DSI_USE_SYNC_POINTS
-       if (atomic_read(&dsi_syncpt_rst))
+       if (atomic_read(&dsi_syncpt_rst) && !tegra_cpu_is_asim())
                tegra_dsi_syncpt_reset(dsi);
-#endif
 
        return init_status;
 fail:
@@ -2837,20 +2825,20 @@ static int tegra_dsi_host_trigger(struct tegra_dc_dsi_data *dsi)
        tegra_dsi_controller_writel(dsi,
                DSI_TRIGGER_HOST_TRIGGER(TEGRA_DSI_ENABLE), DSI_TRIGGER, 0);
 
-#if DSI_USE_SYNC_POINTS
-       status = tegra_dsi_syncpt(dsi);
-       if (status < 0) {
-               dev_err(&dsi->dc->ndev->dev,
-                       "DSI syncpt for host trigger failed\n");
-               goto fail;
-       }
-#else
-       if (tegra_dsi_write_busy(dsi)) {
-               status = -EBUSY;
-               dev_err(&dsi->dc->ndev->dev,
-                       "Timeout waiting on write completion\n");
+       if (!tegra_cpu_is_asim()) {
+               status = tegra_dsi_syncpt(dsi);
+               if (status < 0) {
+                       dev_err(&dsi->dc->ndev->dev,
+                               "DSI syncpt for host trigger failed\n");
+                       goto fail;
+               }
+       } else {
+               if (tegra_dsi_write_busy(dsi)) {
+                       status = -EBUSY;
+                       dev_err(&dsi->dc->ndev->dev,
+                               "Timeout waiting on write completion\n");
+               }
        }
-#endif
 
 fail:
        return status;
@@ -3127,9 +3115,8 @@ int tegra_dsi_start_host_cmd_v_blank_dcs(struct tegra_dc_dsi_data * dsi,
        tegra_dc_io_start(dc);
        tegra_dc_dsi_hold_host(dc);
 
-#if DSI_USE_SYNC_POINTS
-       atomic_set(&dsi_syncpt_rst, 1);
-#endif
+       if (!tegra_cpu_is_asim())
+               atomic_set(&dsi_syncpt_rst, 1);
 
        err = tegra_dsi_dcs_pkt_seq_ctrl_init(dsi, cmd);
        if (err < 0) {
@@ -3168,13 +3155,11 @@ void tegra_dsi_stop_host_cmd_v_blank_dcs(struct tegra_dc_dsi_data * dsi)
        tegra_dc_io_start(dc);
        tegra_dc_dsi_hold_host(dc);
 
-#if DSI_USE_SYNC_POINTS
-       if (atomic_read(&dsi_syncpt_rst)) {
+       if (atomic_read(&dsi_syncpt_rst) && !tegra_cpu_is_asim()) {
                tegra_dsi_wait_frame_end(dc, dsi, 2);
                tegra_dsi_syncpt_reset(dsi);
                atomic_set(&dsi_syncpt_rst, 0);
        }
-#endif
 
        tegra_dsi_writel(dsi, TEGRA_DSI_DISABLE, DSI_INIT_SEQ_CONTROL);
 
@@ -3198,19 +3183,19 @@ static int tegra_dsi_bta(struct tegra_dc_dsi_data *dsi)
        val |= DSI_HOST_DSI_CONTROL_IMM_BTA(TEGRA_DSI_ENABLE);
        tegra_dsi_controller_writel(dsi, val, DSI_HOST_DSI_CONTROL, 0);
 
-#if DSI_USE_SYNC_POINTS
-       err = tegra_dsi_syncpt(dsi);
-       if (err < 0) {
-               dev_err(&dsi->dc->ndev->dev,
-                       "DSI syncpt for bta failed\n");
-       }
-#else
-       if (tegra_dsi_read_busy(dsi)) {
-               err = -EBUSY;
-               dev_err(&dsi->dc->ndev->dev,
-                       "Timeout wating on read completion\n");
+       if (!tegra_cpu_is_asim()) {
+               err = tegra_dsi_syncpt(dsi);
+               if (err < 0) {
+                       dev_err(&dsi->dc->ndev->dev,
+                                       "DSI syncpt for bta failed\n");
+               }
+       } else {
+               if (tegra_dsi_read_busy(dsi)) {
+                       err = -EBUSY;
+                       dev_err(&dsi->dc->ndev->dev,
+                                       "Timeout wating on read completion\n");
+               }
        }
-#endif
 
        return err;
 }
@@ -3497,27 +3482,25 @@ static int tegra_dsi_enter_ulpm(struct tegra_dc_dsi_data *dsi)
        if (dsi->info.ulpm_not_supported)
                return 0;
 
-#if DSI_USE_SYNC_POINTS
-       if (atomic_read(&dsi_syncpt_rst))
+       if (atomic_read(&dsi_syncpt_rst) && !tegra_cpu_is_asim())
                tegra_dsi_syncpt_reset(dsi);
-#endif
 
        val = tegra_dsi_readl(dsi, DSI_HOST_DSI_CONTROL);
        val &= ~DSI_HOST_DSI_CONTROL_ULTRA_LOW_POWER(3);
        val |= DSI_HOST_DSI_CONTROL_ULTRA_LOW_POWER(ENTER_ULPM);
        tegra_dsi_writel(dsi, val, DSI_HOST_DSI_CONTROL);
 
-#if DSI_USE_SYNC_POINTS
-       ret = tegra_dsi_syncpt(dsi);
-       if (ret < 0) {
-               dev_err(&dsi->dc->ndev->dev,
-                       "DSI syncpt for ulpm enter failed\n");
-               return ret;
+       if (!tegra_cpu_is_asim()) {
+               ret = tegra_dsi_syncpt(dsi);
+               if (ret < 0) {
+                       dev_err(&dsi->dc->ndev->dev,
+                                       "DSI syncpt for ulpm enter failed\n");
+                       return ret;
+               }
+       } else {
+               /* TODO: Find exact delay required */
+               mdelay(10);
        }
-#else
-       /* TODO: Find exact delay required */
-       mdelay(10);
-#endif
        dsi->ulpm = true;
 
        return ret;
@@ -3528,27 +3511,26 @@ static int tegra_dsi_exit_ulpm(struct tegra_dc_dsi_data *dsi)
        u32 val;
        int ret = 0;
 
-#if DSI_USE_SYNC_POINTS
-       if (atomic_read(&dsi_syncpt_rst))
+       if (atomic_read(&dsi_syncpt_rst) && !tegra_cpu_is_asim())
                tegra_dsi_syncpt_reset(dsi);
-#endif
 
        val = tegra_dsi_readl(dsi, DSI_HOST_DSI_CONTROL);
        val &= ~DSI_HOST_DSI_CONTROL_ULTRA_LOW_POWER(3);
        val |= DSI_HOST_DSI_CONTROL_ULTRA_LOW_POWER(EXIT_ULPM);
        tegra_dsi_writel(dsi, val, DSI_HOST_DSI_CONTROL);
 
-#if DSI_USE_SYNC_POINTS
-       ret = tegra_dsi_syncpt(dsi);
-       if (ret < 0) {
-               dev_err(&dsi->dc->ndev->dev,
-                       "DSI syncpt for ulpm exit failed\n");
-               return ret;
+
+       if (!tegra_cpu_is_asim()) {
+               ret = tegra_dsi_syncpt(dsi);
+               if (ret < 0) {
+                       dev_err(&dsi->dc->ndev->dev,
+                                       "DSI syncpt for ulpm exit failed\n");
+                       return ret;
+               }
+       } else {
+               /* TODO: Find exact delay required */
+               mdelay(10);
        }
-#else
-       /* TODO: Find exact delay required */
-       mdelay(10);
-#endif
        dsi->ulpm = false;
 
        val = tegra_dsi_readl(dsi, DSI_HOST_DSI_CONTROL);
index 02d4faa..12bff04 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/moduleparam.h>
 #include <linux/export.h>
 #include <mach/dc.h>
+#include <mach/hardware.h>
 #include <trace/events/display.h>
 #include <linux/fb.h>
 #include "dc_reg.h"
@@ -835,9 +836,9 @@ int tegra_dc_update_windows(struct tegra_dc_win *windows[], int n)
 
        tegra_dc_writel(dc, update_mask << 8, DC_CMD_STATE_CONTROL);
 
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
-       tegra_dc_writel(dc, FRAME_END_INT | V_BLANK_INT, DC_CMD_INT_STATUS);
-#endif
+       if (tegra_cpu_is_asim())
+               tegra_dc_writel(dc, FRAME_END_INT | V_BLANK_INT,
+                                                DC_CMD_INT_STATUS);
 
        if (!no_vsync) {
                set_bit(V_BLANK_FLIP, &dc->vblank_ref_count);
index 5f7e00f..241c554 100644 (file)
 /* Pad pitch to 256-byte boundary. */
 #define TEGRA_LINEAR_PITCH_ALIGNMENT 256
 
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
-static struct fb_videomode tmp_mode;
-#endif
-
 struct tegra_fb_info {
        struct tegra_dc_win     *win;
        struct platform_device  *ndev;
@@ -157,27 +153,8 @@ static int tegra_fb_set_par(struct fb_info *info)
                /* Load framebuffer info with new mode details*/
                old_mode = info->mode;
                old_len  = info->fix.line_length;
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
-               tmp_mode.name = NULL;
-               tmp_mode.xres = m.xres;
-               tmp_mode.yres = m.yres;
-               tmp_mode.pixclock = m.pixclock;
-               tmp_mode.hsync_len = m.hsync_len;
-               tmp_mode.vsync_len = m.vsync_len;
-               tmp_mode.left_margin = m.left_margin;
-               tmp_mode.right_margin = m.right_margin;
-               tmp_mode.upper_margin = m.upper_margin;
-               tmp_mode.lower_margin = m.lower_margin;
-               tmp_mode.sync = m.sync;
-               tmp_mode.vmode = m.vmode;
-               tmp_mode.flag = m.flag;
-               tmp_mode.refresh = m.refresh;
-               info->mode = &tmp_mode;
-#else
                memcpy(&tegra_fb->mode, &m, sizeof(tegra_fb->mode));
-
                info->mode = (struct fb_videomode *)&tegra_fb->mode;
-#endif
                if (!info->mode) {
                        dev_warn(&tegra_fb->ndev->dev, "can't match video mode\n");
                        info->mode = old_mode;