Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/video/omap2/dss/dpi.c |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> |
| 6 | * |
| 7 | * Some code and ideas taken from drivers/video/omap/ driver |
| 8 | * by Imre Deak. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License version 2 as published by |
| 12 | * the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along with |
| 20 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | #define DSS_SUBSYS_NAME "DPI" |
| 24 | |
| 25 | #include <linux/kernel.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 26 | #include <linux/delay.h> |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 27 | #include <linux/err.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 28 | #include <linux/errno.h> |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/regulator/consumer.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 31 | |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 32 | #include <video/omapdss.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 33 | #include <plat/cpu.h> |
| 34 | |
| 35 | #include "dss.h" |
| 36 | |
| 37 | static struct { |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 38 | struct regulator *vdds_dsi_reg; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 39 | struct platform_device *dsidev; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 40 | } dpi; |
| 41 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 42 | static struct platform_device *dpi_get_dsidev(enum omap_dss_clk_source clk) |
| 43 | { |
| 44 | int dsi_module; |
| 45 | |
| 46 | dsi_module = clk == OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC ? 0 : 1; |
| 47 | |
| 48 | return dsi_get_dsidev_from_id(dsi_module); |
| 49 | } |
| 50 | |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 51 | static bool dpi_use_dsi_pll(struct omap_dss_device *dssdev) |
| 52 | { |
| 53 | if (dssdev->clocks.dispc.dispc_fclk_src == |
| 54 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC || |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 55 | dssdev->clocks.dispc.dispc_fclk_src == |
| 56 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC || |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 57 | dssdev->clocks.dispc.channel.lcd_clk_src == |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 58 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC || |
| 59 | dssdev->clocks.dispc.channel.lcd_clk_src == |
| 60 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC) |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 61 | return true; |
| 62 | else |
| 63 | return false; |
| 64 | } |
| 65 | |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 66 | static int dpi_set_dsi_clk(struct omap_dss_device *dssdev, bool is_tft, |
| 67 | unsigned long pck_req, unsigned long *fck, int *lck_div, |
| 68 | int *pck_div) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 69 | { |
| 70 | struct dsi_clock_info dsi_cinfo; |
| 71 | struct dispc_clock_info dispc_cinfo; |
| 72 | int r; |
| 73 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 74 | r = dsi_pll_calc_clock_div_pck(dpi.dsidev, is_tft, pck_req, |
| 75 | &dsi_cinfo, &dispc_cinfo); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 76 | if (r) |
| 77 | return r; |
| 78 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 79 | r = dsi_pll_set_clock_div(dpi.dsidev, &dsi_cinfo); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 80 | if (r) |
| 81 | return r; |
| 82 | |
Archit Taneja | e888166 | 2011-04-12 13:52:24 +0530 | [diff] [blame] | 83 | dss_select_dispc_clk_source(dssdev->clocks.dispc.dispc_fclk_src); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 84 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 85 | r = dispc_mgr_set_clock_div(dssdev->manager->id, &dispc_cinfo); |
Tomi Valkeinen | 5e78509 | 2011-08-10 11:25:36 +0300 | [diff] [blame] | 86 | if (r) { |
| 87 | dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 88 | return r; |
Tomi Valkeinen | 5e78509 | 2011-08-10 11:25:36 +0300 | [diff] [blame] | 89 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 90 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 91 | *fck = dsi_cinfo.dsi_pll_hsdiv_dispc_clk; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 92 | *lck_div = dispc_cinfo.lck_div; |
| 93 | *pck_div = dispc_cinfo.pck_div; |
| 94 | |
| 95 | return 0; |
| 96 | } |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 97 | |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 98 | static int dpi_set_dispc_clk(struct omap_dss_device *dssdev, bool is_tft, |
| 99 | unsigned long pck_req, unsigned long *fck, int *lck_div, |
| 100 | int *pck_div) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 101 | { |
| 102 | struct dss_clock_info dss_cinfo; |
| 103 | struct dispc_clock_info dispc_cinfo; |
| 104 | int r; |
| 105 | |
| 106 | r = dss_calc_clock_div(is_tft, pck_req, &dss_cinfo, &dispc_cinfo); |
| 107 | if (r) |
| 108 | return r; |
| 109 | |
| 110 | r = dss_set_clock_div(&dss_cinfo); |
| 111 | if (r) |
| 112 | return r; |
| 113 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 114 | r = dispc_mgr_set_clock_div(dssdev->manager->id, &dispc_cinfo); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 115 | if (r) |
| 116 | return r; |
| 117 | |
| 118 | *fck = dss_cinfo.fck; |
| 119 | *lck_div = dispc_cinfo.lck_div; |
| 120 | *pck_div = dispc_cinfo.pck_div; |
| 121 | |
| 122 | return 0; |
| 123 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 124 | |
| 125 | static int dpi_set_mode(struct omap_dss_device *dssdev) |
| 126 | { |
| 127 | struct omap_video_timings *t = &dssdev->panel.timings; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 128 | int lck_div = 0, pck_div = 0; |
| 129 | unsigned long fck = 0; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 130 | unsigned long pck; |
| 131 | bool is_tft; |
| 132 | int r = 0; |
| 133 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 134 | dispc_mgr_set_pol_freq(dssdev->manager->id, dssdev->panel.config, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 135 | dssdev->panel.acbi, dssdev->panel.acb); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 136 | |
| 137 | is_tft = (dssdev->panel.config & OMAP_DSS_LCD_TFT) != 0; |
| 138 | |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 139 | if (dpi_use_dsi_pll(dssdev)) |
| 140 | r = dpi_set_dsi_clk(dssdev, is_tft, t->pixel_clock * 1000, |
| 141 | &fck, &lck_div, &pck_div); |
| 142 | else |
| 143 | r = dpi_set_dispc_clk(dssdev, is_tft, t->pixel_clock * 1000, |
| 144 | &fck, &lck_div, &pck_div); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 145 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 146 | return r; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 147 | |
| 148 | pck = fck / lck_div / pck_div / 1000; |
| 149 | |
| 150 | if (pck != t->pixel_clock) { |
| 151 | DSSWARN("Could not find exact pixel clock. " |
| 152 | "Requested %d kHz, got %lu kHz\n", |
| 153 | t->pixel_clock, pck); |
| 154 | |
| 155 | t->pixel_clock = pck; |
| 156 | } |
| 157 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 158 | dispc_mgr_set_lcd_timings(dssdev->manager->id, t); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 159 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 160 | return 0; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 161 | } |
| 162 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 163 | static void dpi_basic_init(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 164 | { |
| 165 | bool is_tft; |
| 166 | |
| 167 | is_tft = (dssdev->panel.config & OMAP_DSS_LCD_TFT) != 0; |
| 168 | |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame^] | 169 | dispc_mgr_set_io_pad_mode(DSS_IO_PAD_MODE_BYPASS); |
| 170 | dispc_mgr_enable_stallmode(dssdev->manager->id, false); |
| 171 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 172 | dispc_mgr_set_lcd_display_type(dssdev->manager->id, is_tft ? |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 173 | OMAP_DSS_LCD_DISPLAY_TFT : OMAP_DSS_LCD_DISPLAY_STN); |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 174 | dispc_mgr_set_tft_data_lines(dssdev->manager->id, |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 175 | dssdev->phy.dpi.data_lines); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 176 | } |
| 177 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 178 | int omapdss_dpi_display_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 179 | { |
| 180 | int r; |
| 181 | |
Tomi Valkeinen | 05e1d60 | 2011-06-23 16:38:21 +0300 | [diff] [blame] | 182 | if (dssdev->manager == NULL) { |
| 183 | DSSERR("failed to enable display: no manager\n"); |
| 184 | return -ENODEV; |
| 185 | } |
| 186 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 187 | r = omap_dss_start_device(dssdev); |
| 188 | if (r) { |
| 189 | DSSERR("failed to start device\n"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 190 | goto err_start_dev; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 191 | } |
| 192 | |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 193 | if (cpu_is_omap34xx()) { |
| 194 | r = regulator_enable(dpi.vdds_dsi_reg); |
| 195 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 196 | goto err_reg_enable; |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 197 | } |
| 198 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 199 | r = dss_runtime_get(); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 200 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 201 | goto err_get_dss; |
| 202 | |
| 203 | r = dispc_runtime_get(); |
| 204 | if (r) |
| 205 | goto err_get_dispc; |
| 206 | |
| 207 | dpi_basic_init(dssdev); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 208 | |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 209 | if (dpi_use_dsi_pll(dssdev)) { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 210 | r = dsi_runtime_get(dpi.dsidev); |
| 211 | if (r) |
| 212 | goto err_get_dsi; |
| 213 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 214 | r = dsi_pll_init(dpi.dsidev, 0, 1); |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 215 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 216 | goto err_dsi_pll_init; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 217 | } |
| 218 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 219 | r = dpi_set_mode(dssdev); |
| 220 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 221 | goto err_set_mode; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 222 | |
| 223 | mdelay(2); |
| 224 | |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 225 | dssdev->manager->enable(dssdev->manager); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 226 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 227 | return 0; |
| 228 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 229 | err_set_mode: |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 230 | if (dpi_use_dsi_pll(dssdev)) |
Tomi Valkeinen | 19077a73 | 2011-05-18 11:33:44 +0300 | [diff] [blame] | 231 | dsi_pll_uninit(dpi.dsidev, true); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 232 | err_dsi_pll_init: |
| 233 | if (dpi_use_dsi_pll(dssdev)) |
| 234 | dsi_runtime_put(dpi.dsidev); |
| 235 | err_get_dsi: |
| 236 | dispc_runtime_put(); |
| 237 | err_get_dispc: |
| 238 | dss_runtime_put(); |
| 239 | err_get_dss: |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 240 | if (cpu_is_omap34xx()) |
| 241 | regulator_disable(dpi.vdds_dsi_reg); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 242 | err_reg_enable: |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 243 | omap_dss_stop_device(dssdev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 244 | err_start_dev: |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 245 | return r; |
| 246 | } |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 247 | EXPORT_SYMBOL(omapdss_dpi_display_enable); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 248 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 249 | void omapdss_dpi_display_disable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 250 | { |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 251 | dssdev->manager->disable(dssdev->manager); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 252 | |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 253 | if (dpi_use_dsi_pll(dssdev)) { |
| 254 | dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 255 | dsi_pll_uninit(dpi.dsidev, true); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 256 | dsi_runtime_put(dpi.dsidev); |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 257 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 258 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 259 | dispc_runtime_put(); |
| 260 | dss_runtime_put(); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 261 | |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 262 | if (cpu_is_omap34xx()) |
| 263 | regulator_disable(dpi.vdds_dsi_reg); |
| 264 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 265 | omap_dss_stop_device(dssdev); |
| 266 | } |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 267 | EXPORT_SYMBOL(omapdss_dpi_display_disable); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 268 | |
Tomi Valkeinen | 69b2048 | 2010-01-20 12:11:25 +0200 | [diff] [blame] | 269 | void dpi_set_timings(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 270 | struct omap_video_timings *timings) |
| 271 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 272 | int r; |
| 273 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 274 | DSSDBG("dpi_set_timings\n"); |
| 275 | dssdev->panel.timings = *timings; |
| 276 | if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 277 | r = dss_runtime_get(); |
| 278 | if (r) |
| 279 | return; |
| 280 | |
| 281 | r = dispc_runtime_get(); |
| 282 | if (r) { |
| 283 | dss_runtime_put(); |
| 284 | return; |
| 285 | } |
| 286 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 287 | dpi_set_mode(dssdev); |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 288 | dispc_mgr_go(dssdev->manager->id); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 289 | |
| 290 | dispc_runtime_put(); |
| 291 | dss_runtime_put(); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 292 | } |
| 293 | } |
Tomi Valkeinen | 69b2048 | 2010-01-20 12:11:25 +0200 | [diff] [blame] | 294 | EXPORT_SYMBOL(dpi_set_timings); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 295 | |
Tomi Valkeinen | 69b2048 | 2010-01-20 12:11:25 +0200 | [diff] [blame] | 296 | int dpi_check_timings(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 297 | struct omap_video_timings *timings) |
| 298 | { |
| 299 | bool is_tft; |
| 300 | int r; |
| 301 | int lck_div, pck_div; |
| 302 | unsigned long fck; |
| 303 | unsigned long pck; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 304 | struct dispc_clock_info dispc_cinfo; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 305 | |
| 306 | if (!dispc_lcd_timings_ok(timings)) |
| 307 | return -EINVAL; |
| 308 | |
| 309 | if (timings->pixel_clock == 0) |
| 310 | return -EINVAL; |
| 311 | |
| 312 | is_tft = (dssdev->panel.config & OMAP_DSS_LCD_TFT) != 0; |
| 313 | |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 314 | if (dpi_use_dsi_pll(dssdev)) { |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 315 | struct dsi_clock_info dsi_cinfo; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 316 | r = dsi_pll_calc_clock_div_pck(dpi.dsidev, is_tft, |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 317 | timings->pixel_clock * 1000, |
| 318 | &dsi_cinfo, &dispc_cinfo); |
| 319 | |
| 320 | if (r) |
| 321 | return r; |
| 322 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 323 | fck = dsi_cinfo.dsi_pll_hsdiv_dispc_clk; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 324 | } else { |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 325 | struct dss_clock_info dss_cinfo; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 326 | r = dss_calc_clock_div(is_tft, timings->pixel_clock * 1000, |
| 327 | &dss_cinfo, &dispc_cinfo); |
| 328 | |
| 329 | if (r) |
| 330 | return r; |
| 331 | |
| 332 | fck = dss_cinfo.fck; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 333 | } |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 334 | |
| 335 | lck_div = dispc_cinfo.lck_div; |
| 336 | pck_div = dispc_cinfo.pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 337 | |
| 338 | pck = fck / lck_div / pck_div / 1000; |
| 339 | |
| 340 | timings->pixel_clock = pck; |
| 341 | |
| 342 | return 0; |
| 343 | } |
Tomi Valkeinen | 69b2048 | 2010-01-20 12:11:25 +0200 | [diff] [blame] | 344 | EXPORT_SYMBOL(dpi_check_timings); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 345 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 346 | int dpi_init_display(struct omap_dss_device *dssdev) |
| 347 | { |
| 348 | DSSDBG("init_display\n"); |
| 349 | |
Tomi Valkeinen | 5f42f2ce | 2011-02-22 15:53:46 +0200 | [diff] [blame] | 350 | if (cpu_is_omap34xx() && dpi.vdds_dsi_reg == NULL) { |
| 351 | struct regulator *vdds_dsi; |
| 352 | |
| 353 | vdds_dsi = dss_get_vdds_dsi(); |
| 354 | |
| 355 | if (IS_ERR(vdds_dsi)) { |
| 356 | DSSERR("can't get VDDS_DSI regulator\n"); |
| 357 | return PTR_ERR(vdds_dsi); |
| 358 | } |
| 359 | |
| 360 | dpi.vdds_dsi_reg = vdds_dsi; |
| 361 | } |
| 362 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 363 | if (dpi_use_dsi_pll(dssdev)) { |
| 364 | enum omap_dss_clk_source dispc_fclk_src = |
| 365 | dssdev->clocks.dispc.dispc_fclk_src; |
| 366 | dpi.dsidev = dpi_get_dsidev(dispc_fclk_src); |
| 367 | } |
| 368 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 369 | return 0; |
| 370 | } |
| 371 | |
Tomi Valkeinen | 277b288 | 2011-03-02 12:32:48 +0200 | [diff] [blame] | 372 | int dpi_init(void) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 373 | { |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | void dpi_exit(void) |
| 378 | { |
| 379 | } |
| 380 | |