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> |
Paul Gortmaker | a8a3593 | 2011-07-10 13:20:26 -0400 | [diff] [blame] | 27 | #include <linux/export.h> |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 28 | #include <linux/err.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 29 | #include <linux/errno.h> |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 30 | #include <linux/platform_device.h> |
| 31 | #include <linux/regulator/consumer.h> |
Tomi Valkeinen | 13b1ba7 | 2012-09-28 10:03:03 +0300 | [diff] [blame] | 32 | #include <linux/string.h> |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 33 | #include <linux/of.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 34 | |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 35 | #include <video/omapdss.h> |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 36 | |
| 37 | #include "dss.h" |
Chandrabhanu Mahapatra | 195e672 | 2012-08-22 11:44:06 +0530 | [diff] [blame] | 38 | #include "dss_features.h" |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 39 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 40 | struct dpi_data { |
Tomi Valkeinen | 00df43b | 2013-03-19 11:33:52 +0200 | [diff] [blame] | 41 | struct platform_device *pdev; |
| 42 | |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 43 | struct regulator *vdds_dsi_reg; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 44 | struct platform_device *dsidev; |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 45 | |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 46 | struct mutex lock; |
| 47 | |
Archit Taneja | c499144 | 2012-08-08 14:28:54 +0530 | [diff] [blame] | 48 | struct omap_video_timings timings; |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 49 | struct dss_lcd_mgr_config mgr_config; |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 50 | int data_lines; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 51 | |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 52 | struct omap_dss_device output; |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 53 | |
| 54 | bool port_initialized; |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 55 | }; |
| 56 | |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 57 | static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) |
| 58 | { |
| 59 | return container_of(dssdev, struct dpi_data, output); |
| 60 | } |
| 61 | |
| 62 | static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev) |
| 63 | { |
| 64 | return dev_get_drvdata(&pdev->dev); |
| 65 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 66 | |
Tomi Valkeinen | 0e8276e | 2012-10-22 16:12:58 +0300 | [diff] [blame] | 67 | static struct platform_device *dpi_get_dsidev(enum omap_channel channel) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 68 | { |
Tomi Valkeinen | bd0f5cc | 2012-12-13 14:21:30 +0200 | [diff] [blame] | 69 | /* |
| 70 | * XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL |
| 71 | * would also be used for DISPC fclk. Meaning, when the DPI output is |
| 72 | * disabled, DISPC clock will be disabled, and TV out will stop. |
| 73 | */ |
| 74 | switch (omapdss_get_version()) { |
| 75 | case OMAPDSS_VER_OMAP24xx: |
| 76 | case OMAPDSS_VER_OMAP34xx_ES1: |
| 77 | case OMAPDSS_VER_OMAP34xx_ES3: |
| 78 | case OMAPDSS_VER_OMAP3630: |
| 79 | case OMAPDSS_VER_AM35xx: |
Sathya Prakash M R | d6279d4 | 2014-03-24 16:31:51 +0530 | [diff] [blame] | 80 | case OMAPDSS_VER_AM43xx: |
Tomi Valkeinen | bd0f5cc | 2012-12-13 14:21:30 +0200 | [diff] [blame] | 81 | return NULL; |
Tomi Valkeinen | bd0f5cc | 2012-12-13 14:21:30 +0200 | [diff] [blame] | 82 | |
Tomi Valkeinen | f8ad984 | 2013-03-11 13:57:38 +0200 | [diff] [blame] | 83 | case OMAPDSS_VER_OMAP4430_ES1: |
| 84 | case OMAPDSS_VER_OMAP4430_ES2: |
| 85 | case OMAPDSS_VER_OMAP4: |
| 86 | switch (channel) { |
| 87 | case OMAP_DSS_CHANNEL_LCD: |
| 88 | return dsi_get_dsidev_from_id(0); |
| 89 | case OMAP_DSS_CHANNEL_LCD2: |
| 90 | return dsi_get_dsidev_from_id(1); |
| 91 | default: |
| 92 | return NULL; |
| 93 | } |
| 94 | |
| 95 | case OMAPDSS_VER_OMAP5: |
| 96 | switch (channel) { |
| 97 | case OMAP_DSS_CHANNEL_LCD: |
| 98 | return dsi_get_dsidev_from_id(0); |
| 99 | case OMAP_DSS_CHANNEL_LCD3: |
| 100 | return dsi_get_dsidev_from_id(1); |
| 101 | default: |
| 102 | return NULL; |
| 103 | } |
| 104 | |
Tomi Valkeinen | 0e8276e | 2012-10-22 16:12:58 +0300 | [diff] [blame] | 105 | default: |
| 106 | return NULL; |
| 107 | } |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 108 | } |
| 109 | |
Tomi Valkeinen | 0e8276e | 2012-10-22 16:12:58 +0300 | [diff] [blame] | 110 | static enum omap_dss_clk_source dpi_get_alt_clk_src(enum omap_channel channel) |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 111 | { |
Tomi Valkeinen | 0e8276e | 2012-10-22 16:12:58 +0300 | [diff] [blame] | 112 | switch (channel) { |
| 113 | case OMAP_DSS_CHANNEL_LCD: |
| 114 | return OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC; |
| 115 | case OMAP_DSS_CHANNEL_LCD2: |
| 116 | return OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC; |
Tomi Valkeinen | 35fd32d | 2014-04-17 13:57:21 +0300 | [diff] [blame] | 117 | case OMAP_DSS_CHANNEL_LCD3: |
| 118 | return OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC; |
Tomi Valkeinen | 0e8276e | 2012-10-22 16:12:58 +0300 | [diff] [blame] | 119 | default: |
| 120 | /* this shouldn't happen */ |
| 121 | WARN_ON(1); |
| 122 | return OMAP_DSS_CLK_SRC_FCK; |
| 123 | } |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 124 | } |
| 125 | |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 126 | struct dpi_clk_calc_ctx { |
| 127 | struct platform_device *dsidev; |
| 128 | |
| 129 | /* inputs */ |
| 130 | |
| 131 | unsigned long pck_min, pck_max; |
| 132 | |
| 133 | /* outputs */ |
| 134 | |
| 135 | struct dsi_clock_info dsi_cinfo; |
Tomi Valkeinen | c56812f | 2014-01-28 08:50:47 +0200 | [diff] [blame] | 136 | unsigned long fck; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 137 | struct dispc_clock_info dispc_cinfo; |
| 138 | }; |
| 139 | |
| 140 | static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck, |
| 141 | unsigned long pck, void *data) |
| 142 | { |
| 143 | struct dpi_clk_calc_ctx *ctx = data; |
| 144 | |
| 145 | /* |
| 146 | * Odd dividers give us uneven duty cycle, causing problem when level |
| 147 | * shifted. So skip all odd dividers when the pixel clock is on the |
| 148 | * higher side. |
| 149 | */ |
Tomi Valkeinen | 72e5512 | 2013-06-12 09:44:52 +0300 | [diff] [blame] | 150 | if (ctx->pck_min >= 100000000) { |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 151 | if (lckd > 1 && lckd % 2 != 0) |
| 152 | return false; |
| 153 | |
| 154 | if (pckd > 1 && pckd % 2 != 0) |
| 155 | return false; |
| 156 | } |
| 157 | |
| 158 | ctx->dispc_cinfo.lck_div = lckd; |
| 159 | ctx->dispc_cinfo.pck_div = pckd; |
| 160 | ctx->dispc_cinfo.lck = lck; |
| 161 | ctx->dispc_cinfo.pck = pck; |
| 162 | |
| 163 | return true; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | static bool dpi_calc_hsdiv_cb(int regm_dispc, unsigned long dispc, |
| 168 | void *data) |
| 169 | { |
| 170 | struct dpi_clk_calc_ctx *ctx = data; |
| 171 | |
| 172 | /* |
| 173 | * Odd dividers give us uneven duty cycle, causing problem when level |
| 174 | * shifted. So skip all odd dividers when the pixel clock is on the |
| 175 | * higher side. |
| 176 | */ |
Tomi Valkeinen | 72e5512 | 2013-06-12 09:44:52 +0300 | [diff] [blame] | 177 | if (regm_dispc > 1 && regm_dispc % 2 != 0 && ctx->pck_min >= 100000000) |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 178 | return false; |
| 179 | |
| 180 | ctx->dsi_cinfo.regm_dispc = regm_dispc; |
| 181 | ctx->dsi_cinfo.dsi_pll_hsdiv_dispc_clk = dispc; |
| 182 | |
| 183 | return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max, |
| 184 | dpi_calc_dispc_cb, ctx); |
| 185 | } |
| 186 | |
| 187 | |
| 188 | static bool dpi_calc_pll_cb(int regn, int regm, unsigned long fint, |
| 189 | unsigned long pll, |
| 190 | void *data) |
| 191 | { |
| 192 | struct dpi_clk_calc_ctx *ctx = data; |
| 193 | |
| 194 | ctx->dsi_cinfo.regn = regn; |
| 195 | ctx->dsi_cinfo.regm = regm; |
| 196 | ctx->dsi_cinfo.fint = fint; |
| 197 | ctx->dsi_cinfo.clkin4ddr = pll; |
| 198 | |
| 199 | return dsi_hsdiv_calc(ctx->dsidev, pll, ctx->pck_min, |
| 200 | dpi_calc_hsdiv_cb, ctx); |
| 201 | } |
| 202 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 203 | static bool dpi_calc_dss_cb(unsigned long fck, void *data) |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 204 | { |
| 205 | struct dpi_clk_calc_ctx *ctx = data; |
| 206 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 207 | ctx->fck = fck; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 208 | |
| 209 | return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max, |
| 210 | dpi_calc_dispc_cb, ctx); |
| 211 | } |
| 212 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 213 | static bool dpi_dsi_clk_calc(struct dpi_data *dpi, unsigned long pck, |
| 214 | struct dpi_clk_calc_ctx *ctx) |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 215 | { |
| 216 | unsigned long clkin; |
| 217 | unsigned long pll_min, pll_max; |
| 218 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 219 | clkin = dsi_get_pll_clkin(dpi->dsidev); |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 220 | |
| 221 | memset(ctx, 0, sizeof(*ctx)); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 222 | ctx->dsidev = dpi->dsidev; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 223 | ctx->pck_min = pck - 1000; |
| 224 | ctx->pck_max = pck + 1000; |
| 225 | ctx->dsi_cinfo.clkin = clkin; |
| 226 | |
| 227 | pll_min = 0; |
| 228 | pll_max = 0; |
| 229 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 230 | return dsi_pll_calc(dpi->dsidev, clkin, |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 231 | pll_min, pll_max, |
| 232 | dpi_calc_pll_cb, ctx); |
| 233 | } |
| 234 | |
| 235 | static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx) |
| 236 | { |
| 237 | int i; |
| 238 | |
| 239 | /* |
| 240 | * DSS fck gives us very few possibilities, so finding a good pixel |
| 241 | * clock may not be possible. We try multiple times to find the clock, |
| 242 | * each time widening the pixel clock range we look for, up to |
Tomi Valkeinen | 2c6360f | 2013-04-10 14:54:54 +0300 | [diff] [blame] | 243 | * +/- ~15MHz. |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 244 | */ |
| 245 | |
Tomi Valkeinen | 2c6360f | 2013-04-10 14:54:54 +0300 | [diff] [blame] | 246 | for (i = 0; i < 25; ++i) { |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 247 | bool ok; |
| 248 | |
| 249 | memset(ctx, 0, sizeof(*ctx)); |
| 250 | if (pck > 1000 * i * i * i) |
| 251 | ctx->pck_min = max(pck - 1000 * i * i * i, 0lu); |
| 252 | else |
| 253 | ctx->pck_min = 0; |
| 254 | ctx->pck_max = pck + 1000 * i * i * i; |
| 255 | |
Tomi Valkeinen | 688af02 | 2013-10-31 16:41:57 +0200 | [diff] [blame] | 256 | ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx); |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 257 | if (ok) |
| 258 | return ok; |
| 259 | } |
| 260 | |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | |
| 265 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 266 | static int dpi_set_dsi_clk(struct dpi_data *dpi, enum omap_channel channel, |
Sumit Semwal | ff1b2cde | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 267 | unsigned long pck_req, unsigned long *fck, int *lck_div, |
| 268 | int *pck_div) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 269 | { |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 270 | struct dpi_clk_calc_ctx ctx; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 271 | int r; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 272 | bool ok; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 273 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 274 | ok = dpi_dsi_clk_calc(dpi, pck_req, &ctx); |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 275 | if (!ok) |
| 276 | return -EINVAL; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 277 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 278 | r = dsi_pll_set_clock_div(dpi->dsidev, &ctx.dsi_cinfo); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 279 | if (r) |
| 280 | return r; |
| 281 | |
Tomi Valkeinen | 03a0d1e | 2012-11-27 16:41:16 +0200 | [diff] [blame] | 282 | dss_select_lcd_clk_source(channel, |
| 283 | dpi_get_alt_clk_src(channel)); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 284 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 285 | dpi->mgr_config.clock_info = ctx.dispc_cinfo; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 286 | |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 287 | *fck = ctx.dsi_cinfo.dsi_pll_hsdiv_dispc_clk; |
| 288 | *lck_div = ctx.dispc_cinfo.lck_div; |
| 289 | *pck_div = ctx.dispc_cinfo.pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 290 | |
| 291 | return 0; |
| 292 | } |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 293 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 294 | static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req, |
| 295 | unsigned long *fck, int *lck_div, int *pck_div) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 296 | { |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 297 | struct dpi_clk_calc_ctx ctx; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 298 | int r; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 299 | bool ok; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 300 | |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 301 | ok = dpi_dss_clk_calc(pck_req, &ctx); |
| 302 | if (!ok) |
| 303 | return -EINVAL; |
| 304 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 305 | r = dss_set_fck_rate(ctx.fck); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 306 | if (r) |
| 307 | return r; |
| 308 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 309 | dpi->mgr_config.clock_info = ctx.dispc_cinfo; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 310 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 311 | *fck = ctx.fck; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 312 | *lck_div = ctx.dispc_cinfo.lck_div; |
| 313 | *pck_div = ctx.dispc_cinfo.pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 314 | |
| 315 | return 0; |
| 316 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 317 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 318 | static int dpi_set_mode(struct dpi_data *dpi) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 319 | { |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 320 | struct omap_dss_device *out = &dpi->output; |
| 321 | struct omap_overlay_manager *mgr = out->manager; |
| 322 | struct omap_video_timings *t = &dpi->timings; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 323 | int lck_div = 0, pck_div = 0; |
| 324 | unsigned long fck = 0; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 325 | unsigned long pck; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 326 | int r = 0; |
| 327 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 328 | if (dpi->dsidev) |
| 329 | r = dpi_set_dsi_clk(dpi, mgr->id, t->pixelclock, &fck, |
Archit Taneja | 6d523e7 | 2012-06-21 09:33:55 +0530 | [diff] [blame] | 330 | &lck_div, &pck_div); |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 331 | else |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 332 | r = dpi_set_dispc_clk(dpi, t->pixelclock, &fck, |
Archit Taneja | 6d523e7 | 2012-06-21 09:33:55 +0530 | [diff] [blame] | 333 | &lck_div, &pck_div); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 334 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 335 | return r; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 336 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 337 | pck = fck / lck_div / pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 338 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 339 | if (pck != t->pixelclock) { |
| 340 | DSSWARN("Could not find exact pixel clock. Requested %d Hz, got %lu Hz\n", |
| 341 | t->pixelclock, pck); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 342 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 343 | t->pixelclock = pck; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 344 | } |
| 345 | |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 346 | dss_mgr_set_timings(mgr, t); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 347 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 348 | return 0; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 349 | } |
| 350 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 351 | static void dpi_config_lcd_manager(struct dpi_data *dpi) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 352 | { |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 353 | struct omap_dss_device *out = &dpi->output; |
| 354 | struct omap_overlay_manager *mgr = out->manager; |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 355 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 356 | dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS; |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 357 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 358 | dpi->mgr_config.stallmode = false; |
| 359 | dpi->mgr_config.fifohandcheck = false; |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 360 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 361 | dpi->mgr_config.video_port_width = dpi->data_lines; |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 362 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 363 | dpi->mgr_config.lcden_sig_polarity = 0; |
| 364 | |
| 365 | dss_mgr_set_lcd_config(mgr, &dpi->mgr_config); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 366 | } |
| 367 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 368 | static int dpi_display_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 369 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 370 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 371 | struct omap_dss_device *out = &dpi->output; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 372 | int r; |
| 373 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 374 | mutex_lock(&dpi->lock); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 375 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 376 | if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI) && !dpi->vdds_dsi_reg) { |
Russell King | 4041071 | 2012-02-07 09:44:55 +0000 | [diff] [blame] | 377 | DSSERR("no VDSS_DSI regulator\n"); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 378 | r = -ENODEV; |
| 379 | goto err_no_reg; |
Russell King | 4041071 | 2012-02-07 09:44:55 +0000 | [diff] [blame] | 380 | } |
| 381 | |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 382 | if (out == NULL || out->manager == NULL) { |
| 383 | DSSERR("failed to enable display: no output/manager\n"); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 384 | r = -ENODEV; |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 385 | goto err_no_out_mgr; |
Tomi Valkeinen | 05e1d60 | 2011-06-23 16:38:21 +0300 | [diff] [blame] | 386 | } |
| 387 | |
Chandrabhanu Mahapatra | 195e672 | 2012-08-22 11:44:06 +0530 | [diff] [blame] | 388 | if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) { |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 389 | r = regulator_enable(dpi->vdds_dsi_reg); |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 390 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 391 | goto err_reg_enable; |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 394 | r = dispc_runtime_get(); |
| 395 | if (r) |
| 396 | goto err_get_dispc; |
| 397 | |
Tomi Valkeinen | 03a0d1e | 2012-11-27 16:41:16 +0200 | [diff] [blame] | 398 | r = dss_dpi_select_source(out->manager->id); |
Tomi Valkeinen | de09e45 | 2012-09-21 12:09:54 +0300 | [diff] [blame] | 399 | if (r) |
| 400 | goto err_src_sel; |
| 401 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 402 | if (dpi->dsidev) { |
| 403 | r = dsi_runtime_get(dpi->dsidev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 404 | if (r) |
| 405 | goto err_get_dsi; |
| 406 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 407 | r = dsi_pll_init(dpi->dsidev, 0, 1); |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 408 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 409 | goto err_dsi_pll_init; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 410 | } |
| 411 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 412 | r = dpi_set_mode(dpi); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 413 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 414 | goto err_set_mode; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 415 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 416 | dpi_config_lcd_manager(dpi); |
Archit Taneja | 5cf9a26 | 2012-06-29 14:19:13 +0530 | [diff] [blame] | 417 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 418 | mdelay(2); |
| 419 | |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 420 | r = dss_mgr_enable(out->manager); |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 421 | if (r) |
| 422 | goto err_mgr_enable; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 423 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 424 | mutex_unlock(&dpi->lock); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 425 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 426 | return 0; |
| 427 | |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 428 | err_mgr_enable: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 429 | err_set_mode: |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 430 | if (dpi->dsidev) |
| 431 | dsi_pll_uninit(dpi->dsidev, true); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 432 | err_dsi_pll_init: |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 433 | if (dpi->dsidev) |
| 434 | dsi_runtime_put(dpi->dsidev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 435 | err_get_dsi: |
Tomi Valkeinen | de09e45 | 2012-09-21 12:09:54 +0300 | [diff] [blame] | 436 | err_src_sel: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 437 | dispc_runtime_put(); |
| 438 | err_get_dispc: |
Chandrabhanu Mahapatra | 195e672 | 2012-08-22 11:44:06 +0530 | [diff] [blame] | 439 | if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 440 | regulator_disable(dpi->vdds_dsi_reg); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 441 | err_reg_enable: |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 442 | err_no_out_mgr: |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 443 | err_no_reg: |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 444 | mutex_unlock(&dpi->lock); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 445 | return r; |
| 446 | } |
| 447 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 448 | static void dpi_display_disable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 449 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 450 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 451 | struct omap_overlay_manager *mgr = dpi->output.manager; |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 452 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 453 | mutex_lock(&dpi->lock); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 454 | |
Archit Taneja | 5d512fc | 2012-09-07 17:53:38 +0530 | [diff] [blame] | 455 | dss_mgr_disable(mgr); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 456 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 457 | if (dpi->dsidev) { |
Tomi Valkeinen | a5b8399 | 2012-10-22 16:58:36 +0300 | [diff] [blame] | 458 | dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 459 | dsi_pll_uninit(dpi->dsidev, true); |
| 460 | dsi_runtime_put(dpi->dsidev); |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 461 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 462 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 463 | dispc_runtime_put(); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 464 | |
Chandrabhanu Mahapatra | 195e672 | 2012-08-22 11:44:06 +0530 | [diff] [blame] | 465 | if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 466 | regulator_disable(dpi->vdds_dsi_reg); |
Tomi Valkeinen | 8a2cfea | 2010-02-04 17:03:41 +0200 | [diff] [blame] | 467 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 468 | mutex_unlock(&dpi->lock); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 469 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 470 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 471 | static void dpi_set_timings(struct omap_dss_device *dssdev, |
Archit Taneja | c499144 | 2012-08-08 14:28:54 +0530 | [diff] [blame] | 472 | struct omap_video_timings *timings) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 473 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 474 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 475 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 476 | DSSDBG("dpi_set_timings\n"); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 477 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 478 | mutex_lock(&dpi->lock); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 479 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 480 | dpi->timings = *timings; |
Archit Taneja | c499144 | 2012-08-08 14:28:54 +0530 | [diff] [blame] | 481 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 482 | mutex_unlock(&dpi->lock); |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 483 | } |
| 484 | |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 485 | static void dpi_get_timings(struct omap_dss_device *dssdev, |
| 486 | struct omap_video_timings *timings) |
| 487 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 488 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 489 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 490 | mutex_lock(&dpi->lock); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 491 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 492 | *timings = dpi->timings; |
| 493 | |
| 494 | mutex_unlock(&dpi->lock); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 495 | } |
| 496 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 497 | static int dpi_check_timings(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 498 | struct omap_video_timings *timings) |
| 499 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 500 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 501 | struct omap_overlay_manager *mgr = dpi->output.manager; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 502 | int lck_div, pck_div; |
| 503 | unsigned long fck; |
| 504 | unsigned long pck; |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 505 | struct dpi_clk_calc_ctx ctx; |
| 506 | bool ok; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 507 | |
Tomi Valkeinen | 8b09551 | 2012-10-24 13:27:02 +0300 | [diff] [blame] | 508 | if (mgr && !dispc_mgr_timings_ok(mgr->id, timings)) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 509 | return -EINVAL; |
| 510 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 511 | if (timings->pixelclock == 0) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 512 | return -EINVAL; |
| 513 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 514 | if (dpi->dsidev) { |
| 515 | ok = dpi_dsi_clk_calc(dpi, timings->pixelclock, &ctx); |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 516 | if (!ok) |
| 517 | return -EINVAL; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 518 | |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 519 | fck = ctx.dsi_cinfo.dsi_pll_hsdiv_dispc_clk; |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 520 | } else { |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 521 | ok = dpi_dss_clk_calc(timings->pixelclock, &ctx); |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 522 | if (!ok) |
| 523 | return -EINVAL; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 524 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 525 | fck = ctx.fck; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 526 | } |
Archit Taneja | 7636b3b | 2011-04-12 13:52:26 +0530 | [diff] [blame] | 527 | |
Tomi Valkeinen | 100c826 | 2013-03-05 17:07:16 +0200 | [diff] [blame] | 528 | lck_div = ctx.dispc_cinfo.lck_div; |
| 529 | pck_div = ctx.dispc_cinfo.pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 530 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 531 | pck = fck / lck_div / pck_div; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 532 | |
Tomi Valkeinen | d8d78941 | 2013-04-10 14:12:14 +0300 | [diff] [blame] | 533 | timings->pixelclock = pck; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 534 | |
| 535 | return 0; |
| 536 | } |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 537 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 538 | static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines) |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 539 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 540 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 541 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 542 | mutex_lock(&dpi->lock); |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 543 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 544 | dpi->data_lines = data_lines; |
| 545 | |
| 546 | mutex_unlock(&dpi->lock); |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 547 | } |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 548 | |
Tomi Valkeinen | 94cf394 | 2013-04-26 14:27:44 +0300 | [diff] [blame] | 549 | static int dpi_verify_dsi_pll(struct platform_device *dsidev) |
Tomi Valkeinen | 6061675 | 2012-10-30 12:57:43 +0200 | [diff] [blame] | 550 | { |
| 551 | int r; |
| 552 | |
| 553 | /* do initial setup with the PLL to see if it is operational */ |
| 554 | |
| 555 | r = dsi_runtime_get(dsidev); |
| 556 | if (r) |
| 557 | return r; |
| 558 | |
| 559 | r = dsi_pll_init(dsidev, 0, 1); |
| 560 | if (r) { |
| 561 | dsi_runtime_put(dsidev); |
| 562 | return r; |
| 563 | } |
| 564 | |
| 565 | dsi_pll_uninit(dsidev, true); |
| 566 | dsi_runtime_put(dsidev); |
| 567 | |
| 568 | return 0; |
| 569 | } |
| 570 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 571 | static int dpi_init_regulator(struct dpi_data *dpi) |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 572 | { |
| 573 | struct regulator *vdds_dsi; |
| 574 | |
| 575 | if (!dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) |
| 576 | return 0; |
| 577 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 578 | if (dpi->vdds_dsi_reg) |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 579 | return 0; |
| 580 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 581 | vdds_dsi = devm_regulator_get(&dpi->pdev->dev, "vdds_dsi"); |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 582 | if (IS_ERR(vdds_dsi)) { |
Tomi Valkeinen | 40359a9 | 2013-12-19 16:15:34 +0200 | [diff] [blame] | 583 | if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER) |
| 584 | DSSERR("can't get VDDS_DSI regulator\n"); |
Tomi Valkeinen | 4123de2 | 2013-08-29 10:06:55 +0300 | [diff] [blame] | 585 | return PTR_ERR(vdds_dsi); |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 586 | } |
| 587 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 588 | dpi->vdds_dsi_reg = vdds_dsi; |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 589 | |
| 590 | return 0; |
| 591 | } |
| 592 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 593 | static void dpi_init_pll(struct dpi_data *dpi) |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 594 | { |
| 595 | struct platform_device *dsidev; |
| 596 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 597 | if (dpi->dsidev) |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 598 | return; |
| 599 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 600 | dsidev = dpi_get_dsidev(dpi->output.dispc_channel); |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 601 | if (!dsidev) |
| 602 | return; |
| 603 | |
| 604 | if (dpi_verify_dsi_pll(dsidev)) { |
| 605 | DSSWARN("DSI PLL not operational\n"); |
| 606 | return; |
| 607 | } |
| 608 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 609 | dpi->dsidev = dsidev; |
Tomi Valkeinen | 2795f64 | 2013-04-19 16:52:27 +0300 | [diff] [blame] | 610 | } |
| 611 | |
Tomi Valkeinen | 2eea5ae | 2013-02-13 11:23:54 +0200 | [diff] [blame] | 612 | /* |
| 613 | * Return a hardcoded channel for the DPI output. This should work for |
| 614 | * current use cases, but this can be later expanded to either resolve |
| 615 | * the channel in some more dynamic manner, or get the channel as a user |
| 616 | * parameter. |
| 617 | */ |
| 618 | static enum omap_channel dpi_get_channel(void) |
| 619 | { |
| 620 | switch (omapdss_get_version()) { |
| 621 | case OMAPDSS_VER_OMAP24xx: |
| 622 | case OMAPDSS_VER_OMAP34xx_ES1: |
| 623 | case OMAPDSS_VER_OMAP34xx_ES3: |
| 624 | case OMAPDSS_VER_OMAP3630: |
| 625 | case OMAPDSS_VER_AM35xx: |
Sathya Prakash M R | d6279d4 | 2014-03-24 16:31:51 +0530 | [diff] [blame] | 626 | case OMAPDSS_VER_AM43xx: |
Tomi Valkeinen | 2eea5ae | 2013-02-13 11:23:54 +0200 | [diff] [blame] | 627 | return OMAP_DSS_CHANNEL_LCD; |
| 628 | |
| 629 | case OMAPDSS_VER_OMAP4430_ES1: |
| 630 | case OMAPDSS_VER_OMAP4430_ES2: |
| 631 | case OMAPDSS_VER_OMAP4: |
| 632 | return OMAP_DSS_CHANNEL_LCD2; |
| 633 | |
| 634 | case OMAPDSS_VER_OMAP5: |
| 635 | return OMAP_DSS_CHANNEL_LCD3; |
| 636 | |
| 637 | default: |
| 638 | DSSWARN("unsupported DSS version\n"); |
| 639 | return OMAP_DSS_CHANNEL_LCD; |
| 640 | } |
| 641 | } |
| 642 | |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 643 | static int dpi_connect(struct omap_dss_device *dssdev, |
| 644 | struct omap_dss_device *dst) |
| 645 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 646 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 647 | struct omap_overlay_manager *mgr; |
| 648 | int r; |
| 649 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 650 | r = dpi_init_regulator(dpi); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 651 | if (r) |
| 652 | return r; |
| 653 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 654 | dpi_init_pll(dpi); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 655 | |
| 656 | mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel); |
| 657 | if (!mgr) |
| 658 | return -ENODEV; |
| 659 | |
| 660 | r = dss_mgr_connect(mgr, dssdev); |
| 661 | if (r) |
| 662 | return r; |
| 663 | |
| 664 | r = omapdss_output_set_device(dssdev, dst); |
| 665 | if (r) { |
| 666 | DSSERR("failed to connect output to new device: %s\n", |
| 667 | dst->name); |
| 668 | dss_mgr_disconnect(mgr, dssdev); |
| 669 | return r; |
| 670 | } |
| 671 | |
| 672 | return 0; |
| 673 | } |
| 674 | |
| 675 | static void dpi_disconnect(struct omap_dss_device *dssdev, |
| 676 | struct omap_dss_device *dst) |
| 677 | { |
Tomi Valkeinen | 9560dc10 | 2013-07-24 13:06:54 +0300 | [diff] [blame] | 678 | WARN_ON(dst != dssdev->dst); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 679 | |
Tomi Valkeinen | 9560dc10 | 2013-07-24 13:06:54 +0300 | [diff] [blame] | 680 | if (dst != dssdev->dst) |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 681 | return; |
| 682 | |
| 683 | omapdss_output_unset_device(dssdev); |
| 684 | |
| 685 | if (dssdev->manager) |
| 686 | dss_mgr_disconnect(dssdev->manager, dssdev); |
| 687 | } |
| 688 | |
| 689 | static const struct omapdss_dpi_ops dpi_ops = { |
| 690 | .connect = dpi_connect, |
| 691 | .disconnect = dpi_disconnect, |
| 692 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 693 | .enable = dpi_display_enable, |
| 694 | .disable = dpi_display_disable, |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 695 | |
| 696 | .check_timings = dpi_check_timings, |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 697 | .set_timings = dpi_set_timings, |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 698 | .get_timings = dpi_get_timings, |
| 699 | |
Tomi Valkeinen | 86a3efe | 2013-05-15 10:40:15 +0300 | [diff] [blame] | 700 | .set_data_lines = dpi_set_data_lines, |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 701 | }; |
| 702 | |
Tomi Valkeinen | 94cf394 | 2013-04-26 14:27:44 +0300 | [diff] [blame] | 703 | static void dpi_init_output(struct platform_device *pdev) |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 704 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 705 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 706 | struct omap_dss_device *out = &dpi->output; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 707 | |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 708 | out->dev = &pdev->dev; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 709 | out->id = OMAP_DSS_OUTPUT_DPI; |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 710 | out->output_type = OMAP_DISPLAY_TYPE_DPI; |
Tomi Valkeinen | 7286a08 | 2013-02-18 13:06:01 +0200 | [diff] [blame] | 711 | out->name = "dpi.0"; |
Tomi Valkeinen | 2eea5ae | 2013-02-13 11:23:54 +0200 | [diff] [blame] | 712 | out->dispc_channel = dpi_get_channel(); |
Tomi Valkeinen | 0b24edb | 2013-05-24 13:18:52 +0300 | [diff] [blame] | 713 | out->ops.dpi = &dpi_ops; |
Tomi Valkeinen | b7328e1 | 2013-05-03 11:42:18 +0300 | [diff] [blame] | 714 | out->owner = THIS_MODULE; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 715 | |
Tomi Valkeinen | 5d47dbc | 2013-04-24 13:32:51 +0300 | [diff] [blame] | 716 | omapdss_register_output(out); |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | static void __exit dpi_uninit_output(struct platform_device *pdev) |
| 720 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 721 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 722 | struct omap_dss_device *out = &dpi->output; |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 723 | |
Tomi Valkeinen | 5d47dbc | 2013-04-24 13:32:51 +0300 | [diff] [blame] | 724 | omapdss_unregister_output(out); |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 725 | } |
| 726 | |
Tomi Valkeinen | 94cf394 | 2013-04-26 14:27:44 +0300 | [diff] [blame] | 727 | static int omap_dpi_probe(struct platform_device *pdev) |
Tomi Valkeinen | 38f3daf | 2012-05-02 14:55:12 +0300 | [diff] [blame] | 728 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 729 | struct dpi_data *dpi; |
| 730 | |
| 731 | dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); |
| 732 | if (!dpi) |
| 733 | return -ENOMEM; |
Tomi Valkeinen | 00df43b | 2013-03-19 11:33:52 +0200 | [diff] [blame] | 734 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 735 | dpi->pdev = pdev; |
| 736 | |
| 737 | dev_set_drvdata(&pdev->dev, dpi); |
| 738 | |
| 739 | mutex_init(&dpi->lock); |
Archit Taneja | c8a5e4e | 2012-07-05 12:52:46 +0530 | [diff] [blame] | 740 | |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 741 | dpi_init_output(pdev); |
| 742 | |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 743 | return 0; |
| 744 | } |
| 745 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 746 | static int __exit omap_dpi_remove(struct platform_device *pdev) |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 747 | { |
Archit Taneja | 81b87f5 | 2012-09-26 16:30:49 +0530 | [diff] [blame] | 748 | dpi_uninit_output(pdev); |
| 749 | |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 750 | return 0; |
Tomi Valkeinen | 553c48c | 2009-08-07 13:15:50 +0300 | [diff] [blame] | 751 | } |
| 752 | |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 753 | static struct platform_driver omap_dpi_driver = { |
Tomi Valkeinen | 94cf394 | 2013-04-26 14:27:44 +0300 | [diff] [blame] | 754 | .probe = omap_dpi_probe, |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 755 | .remove = __exit_p(omap_dpi_remove), |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 756 | .driver = { |
| 757 | .name = "omapdss_dpi", |
| 758 | .owner = THIS_MODULE, |
Tomi Valkeinen | 422ccbd | 2014-10-16 09:54:25 +0300 | [diff] [blame] | 759 | .suppress_bind_attrs = true, |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 760 | }, |
| 761 | }; |
| 762 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 763 | int __init dpi_init_platform_driver(void) |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 764 | { |
Tomi Valkeinen | 94cf394 | 2013-04-26 14:27:44 +0300 | [diff] [blame] | 765 | return platform_driver_register(&omap_dpi_driver); |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 766 | } |
| 767 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 768 | void __exit dpi_uninit_platform_driver(void) |
Tomi Valkeinen | a57dd4f | 2012-02-20 16:57:37 +0200 | [diff] [blame] | 769 | { |
| 770 | platform_driver_unregister(&omap_dpi_driver); |
| 771 | } |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 772 | |
| 773 | int __init dpi_init_port(struct platform_device *pdev, struct device_node *port) |
| 774 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 775 | struct dpi_data *dpi; |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 776 | struct device_node *ep; |
| 777 | u32 datalines; |
| 778 | int r; |
| 779 | |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 780 | dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); |
| 781 | if (!dpi) |
| 782 | return -ENOMEM; |
| 783 | |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 784 | ep = omapdss_of_get_next_endpoint(port, NULL); |
| 785 | if (!ep) |
| 786 | return 0; |
| 787 | |
| 788 | r = of_property_read_u32(ep, "data-lines", &datalines); |
| 789 | if (r) { |
| 790 | DSSERR("failed to parse datalines\n"); |
| 791 | goto err_datalines; |
| 792 | } |
| 793 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 794 | dpi->data_lines = datalines; |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 795 | |
| 796 | of_node_put(ep); |
| 797 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 798 | dpi->pdev = pdev; |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 799 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 800 | mutex_init(&dpi->lock); |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 801 | |
| 802 | dpi_init_output(pdev); |
| 803 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 804 | dpi->port_initialized = true; |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 805 | |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 806 | dev_set_drvdata(&pdev->dev, dpi); |
| 807 | |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 808 | return 0; |
| 809 | |
| 810 | err_datalines: |
| 811 | of_node_put(ep); |
| 812 | |
| 813 | return r; |
| 814 | } |
| 815 | |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 816 | void __exit dpi_uninit_port(struct platform_device *pdev) |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 817 | { |
Archit Taneja | 2ac6a1a | 2014-06-01 12:47:44 +0530 | [diff] [blame^] | 818 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 819 | |
| 820 | if (!dpi->port_initialized) |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 821 | return; |
| 822 | |
Archit Taneja | 630d2d0 | 2014-05-30 16:26:22 +0530 | [diff] [blame] | 823 | dpi_uninit_output(dpi->pdev); |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 824 | } |