2009-08-07 17:15:50 +07:00
|
|
|
/*
|
|
|
|
* linux/drivers/video/omap2/dss/dpi.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Nokia Corporation
|
|
|
|
* Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
|
|
|
|
*
|
|
|
|
* Some code and ideas taken from drivers/video/omap/ driver
|
|
|
|
* by Imre Deak.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DSS_SUBSYS_NAME "DPI"
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
2011-07-11 00:20:26 +07:00
|
|
|
#include <linux/export.h>
|
2010-02-04 22:03:41 +07:00
|
|
|
#include <linux/err.h>
|
2009-08-07 17:15:50 +07:00
|
|
|
#include <linux/errno.h>
|
2010-02-04 22:03:41 +07:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/regulator/consumer.h>
|
2012-09-28 14:03:03 +07:00
|
|
|
#include <linux/string.h>
|
2013-12-16 20:13:24 +07:00
|
|
|
#include <linux/of.h>
|
2014-10-22 18:49:14 +07:00
|
|
|
#include <linux/clk.h>
|
2017-08-05 05:44:12 +07:00
|
|
|
#include <linux/sys_soc.h>
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-05-27 18:40:49 +07:00
|
|
|
#include "omapdss.h"
|
2009-08-07 17:15:50 +07:00
|
|
|
#include "dss.h"
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
struct dpi_data {
|
2013-03-19 16:33:52 +07:00
|
|
|
struct platform_device *pdev;
|
2017-08-05 05:43:56 +07:00
|
|
|
enum dss_model dss_model;
|
2013-03-19 16:33:52 +07:00
|
|
|
|
2010-02-04 22:03:41 +07:00
|
|
|
struct regulator *vdds_dsi_reg;
|
2016-05-17 20:08:54 +07:00
|
|
|
enum dss_clk_source clk_src;
|
2014-10-22 18:49:14 +07:00
|
|
|
struct dss_pll *pll;
|
2012-06-29 15:49:13 +07:00
|
|
|
|
2012-07-05 14:22:46 +07:00
|
|
|
struct mutex lock;
|
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
struct videomode vm;
|
2012-06-29 15:49:13 +07:00
|
|
|
struct dss_lcd_mgr_config mgr_config;
|
2012-07-06 17:00:52 +07:00
|
|
|
int data_lines;
|
2012-09-26 18:00:49 +07:00
|
|
|
|
OMAPDSS: combine omap_dss_output into omap_dss_device
We currently have omap_dss_device, which represents an external display
device, sometimes an external encoder, sometimes a panel. Then we have
omap_dss_output, which represents DSS's output encoder.
In the future with new display device model, we construct a video
pipeline from the display blocks. To accomplish this, all the blocks
need to be presented by the same entity.
Thus, this patch combines omap_dss_output into omap_dss_device. Some of
the fields in omap_dss_output are already found in omap_dss_device, but
some are not. This means we'll have DSS output specific fields in
omap_dss_device, which is not very nice. However, it is easier to just
keep those output specific fields there for now, and after transition to
new display device model is made, they can be cleaned up easier than
could be done now.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2013-04-19 19:09:34 +07:00
|
|
|
struct omap_dss_device output;
|
2013-12-16 20:13:24 +07:00
|
|
|
|
|
|
|
bool port_initialized;
|
2014-05-30 17:56:22 +07:00
|
|
|
};
|
|
|
|
|
2014-06-01 14:17:44 +07:00
|
|
|
static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
|
|
|
|
{
|
|
|
|
return container_of(dssdev, struct dpi_data, output);
|
|
|
|
}
|
|
|
|
|
2016-08-10 15:04:29 +07:00
|
|
|
static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Possible clock sources:
|
|
|
|
* LCD1: FCK/PLL1_1/HDMI_PLL
|
|
|
|
* LCD2: FCK/PLL1_3/HDMI_PLL (DRA74x: PLL2_3)
|
|
|
|
* LCD3: FCK/PLL1_3/HDMI_PLL (DRA74x: PLL2_1)
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (channel) {
|
|
|
|
case OMAP_DSS_CHANNEL_LCD:
|
|
|
|
{
|
|
|
|
if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1))
|
|
|
|
return DSS_CLK_SRC_PLL1_1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OMAP_DSS_CHANNEL_LCD2:
|
|
|
|
{
|
|
|
|
if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
|
|
|
|
return DSS_CLK_SRC_PLL1_3;
|
|
|
|
if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3))
|
|
|
|
return DSS_CLK_SRC_PLL2_3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OMAP_DSS_CHANNEL_LCD3:
|
|
|
|
{
|
|
|
|
if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_1))
|
|
|
|
return DSS_CLK_SRC_PLL2_1;
|
|
|
|
if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
|
|
|
|
return DSS_CLK_SRC_PLL1_3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DSS_CLK_SRC_FCK;
|
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
|
2011-05-12 18:56:26 +07:00
|
|
|
{
|
2017-08-05 05:43:56 +07:00
|
|
|
enum omap_channel channel = dpi->output.dispc_channel;
|
|
|
|
|
OMAPDSS: fix TV-out issue with DSI PLL
Commit 0e8276ef75f5c7811b038d1d23b2b42c16efc5ac (OMAPDSS: DPI: always
use DSI PLL if available) made dpi.c use DSI PLL for its clock. This
works fine, for DPI, but has a nasty side effect on OMAP3:
On OMAP3 the same clock is used for DISPC fclk and LCD output. Thus,
after the above patch, DSI PLL is used for DISPC and LCD output. If
TV-out is used, the TV-out needs DISPC. And if DPI is turned off, the
DSI PLL is also turned off, disabling DISPC.
For this to work, we'd need proper DSS internal clock handling, with
refcounts, which is a non-trivial project.
This patch fixes the issue for now by disabling the use of DSI PLL for
DPI on OMAP3.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2012-12-13 19:21:30 +07:00
|
|
|
/*
|
|
|
|
* XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL
|
|
|
|
* would also be used for DISPC fclk. Meaning, when the DPI output is
|
|
|
|
* disabled, DISPC clock will be disabled, and TV out will stop.
|
|
|
|
*/
|
2017-08-05 05:43:56 +07:00
|
|
|
switch (dpi->dss_model) {
|
|
|
|
case DSS_MODEL_OMAP2:
|
|
|
|
case DSS_MODEL_OMAP3:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_FCK;
|
OMAPDSS: fix TV-out issue with DSI PLL
Commit 0e8276ef75f5c7811b038d1d23b2b42c16efc5ac (OMAPDSS: DPI: always
use DSI PLL if available) made dpi.c use DSI PLL for its clock. This
works fine, for DPI, but has a nasty side effect on OMAP3:
On OMAP3 the same clock is used for DISPC fclk and LCD output. Thus,
after the above patch, DSI PLL is used for DISPC and LCD output. If
TV-out is used, the TV-out needs DISPC. And if DPI is turned off, the
DSI PLL is also turned off, disabling DISPC.
For this to work, we'd need proper DSS internal clock handling, with
refcounts, which is a non-trivial project.
This patch fixes the issue for now by disabling the use of DSI PLL for
DPI on OMAP3.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2012-12-13 19:21:30 +07:00
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_OMAP4:
|
2013-03-11 18:57:38 +07:00
|
|
|
switch (channel) {
|
|
|
|
case OMAP_DSS_CHANNEL_LCD:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_PLL1_1;
|
2013-03-11 18:57:38 +07:00
|
|
|
case OMAP_DSS_CHANNEL_LCD2:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_PLL2_1;
|
2013-03-11 18:57:38 +07:00
|
|
|
default:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_FCK;
|
2013-03-11 18:57:38 +07:00
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_OMAP5:
|
2013-03-11 18:57:38 +07:00
|
|
|
switch (channel) {
|
|
|
|
case OMAP_DSS_CHANNEL_LCD:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_PLL1_1;
|
2013-03-11 18:57:38 +07:00
|
|
|
case OMAP_DSS_CHANNEL_LCD3:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_PLL2_1;
|
|
|
|
case OMAP_DSS_CHANNEL_LCD2:
|
2013-03-11 18:57:38 +07:00
|
|
|
default:
|
2016-05-17 20:08:54 +07:00
|
|
|
return DSS_CLK_SRC_FCK;
|
2013-03-11 18:57:38 +07:00
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_DRA7:
|
2016-08-10 15:04:29 +07:00
|
|
|
return dpi_get_clk_src_dra7xx(channel);
|
2014-12-31 16:26:06 +07:00
|
|
|
|
2012-10-22 20:12:58 +07:00
|
|
|
default:
|
2016-05-17 18:01:10 +07:00
|
|
|
return DSS_CLK_SRC_FCK;
|
2012-10-22 20:12:58 +07:00
|
|
|
}
|
2011-04-12 15:22:26 +07:00
|
|
|
}
|
|
|
|
|
2013-03-05 22:07:16 +07:00
|
|
|
struct dpi_clk_calc_ctx {
|
2014-10-22 18:49:14 +07:00
|
|
|
struct dss_pll *pll;
|
2016-05-17 20:20:07 +07:00
|
|
|
unsigned clkout_idx;
|
2013-03-05 22:07:16 +07:00
|
|
|
|
|
|
|
/* inputs */
|
|
|
|
|
|
|
|
unsigned long pck_min, pck_max;
|
|
|
|
|
|
|
|
/* outputs */
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
struct dss_pll_clock_info pll_cinfo;
|
2014-01-28 13:50:47 +07:00
|
|
|
unsigned long fck;
|
2013-03-05 22:07:16 +07:00
|
|
|
struct dispc_clock_info dispc_cinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
|
|
|
|
unsigned long pck, void *data)
|
|
|
|
{
|
|
|
|
struct dpi_clk_calc_ctx *ctx = data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Odd dividers give us uneven duty cycle, causing problem when level
|
|
|
|
* shifted. So skip all odd dividers when the pixel clock is on the
|
|
|
|
* higher side.
|
|
|
|
*/
|
2013-06-12 13:44:52 +07:00
|
|
|
if (ctx->pck_min >= 100000000) {
|
2013-03-05 22:07:16 +07:00
|
|
|
if (lckd > 1 && lckd % 2 != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (pckd > 1 && pckd % 2 != 0)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->dispc_cinfo.lck_div = lckd;
|
|
|
|
ctx->dispc_cinfo.pck_div = pckd;
|
|
|
|
ctx->dispc_cinfo.lck = lck;
|
|
|
|
ctx->dispc_cinfo.pck = pck;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
|
2013-03-05 22:07:16 +07:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct dpi_clk_calc_ctx *ctx = data;
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
ctx->pll_cinfo.mX[ctx->clkout_idx] = m_dispc;
|
|
|
|
ctx->pll_cinfo.clkout[ctx->clkout_idx] = dispc;
|
2013-03-05 22:07:16 +07:00
|
|
|
|
|
|
|
return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max,
|
|
|
|
dpi_calc_dispc_cb, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
static bool dpi_calc_pll_cb(int n, int m, unsigned long fint,
|
|
|
|
unsigned long clkdco,
|
2013-03-05 22:07:16 +07:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct dpi_clk_calc_ctx *ctx = data;
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
ctx->pll_cinfo.n = n;
|
|
|
|
ctx->pll_cinfo.m = m;
|
|
|
|
ctx->pll_cinfo.fint = fint;
|
|
|
|
ctx->pll_cinfo.clkdco = clkdco;
|
2013-03-05 22:07:16 +07:00
|
|
|
|
2016-05-18 01:23:37 +07:00
|
|
|
return dss_pll_hsdiv_calc_a(ctx->pll, clkdco,
|
2017-08-05 05:44:17 +07:00
|
|
|
ctx->pck_min, dss_get_max_fck_rate(),
|
2014-10-22 18:49:14 +07:00
|
|
|
dpi_calc_hsdiv_cb, ctx);
|
2013-03-05 22:07:16 +07:00
|
|
|
}
|
|
|
|
|
2013-10-31 19:44:23 +07:00
|
|
|
static bool dpi_calc_dss_cb(unsigned long fck, void *data)
|
2013-03-05 22:07:16 +07:00
|
|
|
{
|
|
|
|
struct dpi_clk_calc_ctx *ctx = data;
|
|
|
|
|
2013-10-31 19:44:23 +07:00
|
|
|
ctx->fck = fck;
|
2013-03-05 22:07:16 +07:00
|
|
|
|
|
|
|
return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
|
|
|
|
dpi_calc_dispc_cb, ctx);
|
|
|
|
}
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck,
|
2014-05-30 17:56:22 +07:00
|
|
|
struct dpi_clk_calc_ctx *ctx)
|
2013-03-05 22:07:16 +07:00
|
|
|
{
|
|
|
|
unsigned long clkin;
|
|
|
|
|
|
|
|
memset(ctx, 0, sizeof(*ctx));
|
2014-10-22 18:49:14 +07:00
|
|
|
ctx->pll = dpi->pll;
|
2016-05-17 20:20:07 +07:00
|
|
|
ctx->clkout_idx = dss_pll_get_clkout_idx_for_src(dpi->clk_src);
|
2013-03-05 22:07:16 +07:00
|
|
|
|
2016-05-18 16:06:49 +07:00
|
|
|
clkin = clk_get_rate(dpi->pll->clkin);
|
2013-03-05 22:07:16 +07:00
|
|
|
|
2016-05-18 16:06:49 +07:00
|
|
|
if (dpi->pll->hw->type == DSS_PLL_TYPE_A) {
|
|
|
|
unsigned long pll_min, pll_max;
|
2014-10-22 18:49:14 +07:00
|
|
|
|
2016-05-18 16:06:49 +07:00
|
|
|
ctx->pck_min = pck - 1000;
|
|
|
|
ctx->pck_max = pck + 1000;
|
|
|
|
|
|
|
|
pll_min = 0;
|
|
|
|
pll_max = 0;
|
|
|
|
|
|
|
|
return dss_pll_calc_a(ctx->pll, clkin,
|
|
|
|
pll_min, pll_max,
|
|
|
|
dpi_calc_pll_cb, ctx);
|
|
|
|
} else { /* DSS_PLL_TYPE_B */
|
2016-05-18 16:22:32 +07:00
|
|
|
dss_pll_calc_b(dpi->pll, clkin, pck, &ctx->pll_cinfo);
|
2016-05-18 16:06:49 +07:00
|
|
|
|
|
|
|
ctx->dispc_cinfo.lck_div = 1;
|
|
|
|
ctx->dispc_cinfo.pck_div = 1;
|
2016-05-18 16:22:32 +07:00
|
|
|
ctx->dispc_cinfo.lck = ctx->pll_cinfo.clkout[0];
|
2016-05-18 16:06:49 +07:00
|
|
|
ctx->dispc_cinfo.pck = ctx->dispc_cinfo.lck;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-03-05 22:07:16 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DSS fck gives us very few possibilities, so finding a good pixel
|
|
|
|
* clock may not be possible. We try multiple times to find the clock,
|
|
|
|
* each time widening the pixel clock range we look for, up to
|
2013-04-10 18:54:54 +07:00
|
|
|
* +/- ~15MHz.
|
2013-03-05 22:07:16 +07:00
|
|
|
*/
|
|
|
|
|
2013-04-10 18:54:54 +07:00
|
|
|
for (i = 0; i < 25; ++i) {
|
2013-03-05 22:07:16 +07:00
|
|
|
bool ok;
|
|
|
|
|
|
|
|
memset(ctx, 0, sizeof(*ctx));
|
|
|
|
if (pck > 1000 * i * i * i)
|
|
|
|
ctx->pck_min = max(pck - 1000 * i * i * i, 0lu);
|
|
|
|
else
|
|
|
|
ctx->pck_min = 0;
|
|
|
|
ctx->pck_max = pck + 1000 * i * i * i;
|
|
|
|
|
2013-10-31 21:41:57 +07:00
|
|
|
ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx);
|
2013-03-05 22:07:16 +07:00
|
|
|
if (ok)
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
static int dpi_set_pll_clk(struct dpi_data *dpi, enum omap_channel channel,
|
2010-12-02 18:27:11 +07:00
|
|
|
unsigned long pck_req, unsigned long *fck, int *lck_div,
|
|
|
|
int *pck_div)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2013-03-05 22:07:16 +07:00
|
|
|
struct dpi_clk_calc_ctx ctx;
|
2009-08-07 17:15:50 +07:00
|
|
|
int r;
|
2013-03-05 22:07:16 +07:00
|
|
|
bool ok;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
ok = dpi_pll_clk_calc(dpi, pck_req, &ctx);
|
2013-03-05 22:07:16 +07:00
|
|
|
if (!ok)
|
|
|
|
return -EINVAL;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
r = dss_pll_set_config(dpi->pll, &ctx.pll_cinfo);
|
2009-08-07 17:15:50 +07:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2016-05-17 20:08:54 +07:00
|
|
|
dss_select_lcd_clk_source(channel, dpi->clk_src);
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->mgr_config.clock_info = ctx.dispc_cinfo;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
*fck = ctx.pll_cinfo.clkout[ctx.clkout_idx];
|
2013-03-05 22:07:16 +07:00
|
|
|
*lck_div = ctx.dispc_cinfo.lck_div;
|
|
|
|
*pck_div = ctx.dispc_cinfo.pck_div;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-04-12 15:22:26 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
|
|
|
|
unsigned long *fck, int *lck_div, int *pck_div)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2013-03-05 22:07:16 +07:00
|
|
|
struct dpi_clk_calc_ctx ctx;
|
2009-08-07 17:15:50 +07:00
|
|
|
int r;
|
2013-03-05 22:07:16 +07:00
|
|
|
bool ok;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-03-05 22:07:16 +07:00
|
|
|
ok = dpi_dss_clk_calc(pck_req, &ctx);
|
|
|
|
if (!ok)
|
|
|
|
return -EINVAL;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-10-31 19:44:23 +07:00
|
|
|
r = dss_set_fck_rate(ctx.fck);
|
2009-08-07 17:15:50 +07:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->mgr_config.clock_info = ctx.dispc_cinfo;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-10-31 19:44:23 +07:00
|
|
|
*fck = ctx.fck;
|
2013-03-05 22:07:16 +07:00
|
|
|
*lck_div = ctx.dispc_cinfo.lck_div;
|
|
|
|
*pck_div = ctx.dispc_cinfo.pck_div;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
static int dpi_set_mode(struct dpi_data *dpi)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-05-30 17:56:22 +07:00
|
|
|
struct omap_dss_device *out = &dpi->output;
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = out->dispc_channel;
|
2016-09-22 18:07:04 +07:00
|
|
|
struct videomode *vm = &dpi->vm;
|
2011-04-12 15:22:26 +07:00
|
|
|
int lck_div = 0, pck_div = 0;
|
|
|
|
unsigned long fck = 0;
|
2009-08-07 17:15:50 +07:00
|
|
|
unsigned long pck;
|
|
|
|
int r = 0;
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll)
|
2016-09-22 18:07:04 +07:00
|
|
|
r = dpi_set_pll_clk(dpi, channel, vm->pixelclock, &fck,
|
2012-06-21 11:03:55 +07:00
|
|
|
&lck_div, &pck_div);
|
2011-04-12 15:22:26 +07:00
|
|
|
else
|
2016-09-22 18:07:04 +07:00
|
|
|
r = dpi_set_dispc_clk(dpi, vm->pixelclock, &fck,
|
2012-06-21 11:03:55 +07:00
|
|
|
&lck_div, &pck_div);
|
2009-08-07 17:15:50 +07:00
|
|
|
if (r)
|
2011-05-27 14:52:19 +07:00
|
|
|
return r;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-04-10 18:12:14 +07:00
|
|
|
pck = fck / lck_div / pck_div;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
if (pck != vm->pixelclock) {
|
2016-09-22 18:07:02 +07:00
|
|
|
DSSWARN("Could not find exact pixel clock. Requested %lu Hz, got %lu Hz\n",
|
2016-09-22 18:07:04 +07:00
|
|
|
vm->pixelclock, pck);
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
vm->pixelclock = pck;
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
dss_mgr_set_timings(channel, vm);
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2011-05-27 14:52:19 +07:00
|
|
|
return 0;
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
static void dpi_config_lcd_manager(struct dpi_data *dpi)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-05-30 17:56:22 +07:00
|
|
|
struct omap_dss_device *out = &dpi->output;
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = out->dispc_channel;
|
2014-05-30 17:56:22 +07:00
|
|
|
|
|
|
|
dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
|
2011-08-22 19:11:57 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->mgr_config.stallmode = false;
|
|
|
|
dpi->mgr_config.fifohandcheck = false;
|
2012-06-29 15:49:13 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->mgr_config.video_port_width = dpi->data_lines;
|
2012-06-29 15:49:13 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->mgr_config.lcden_sig_polarity = 0;
|
2012-06-29 15:49:13 +07:00
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
dss_mgr_set_lcd_config(channel, &dpi->mgr_config);
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
|
|
|
|
2013-05-15 14:40:15 +07:00
|
|
|
static int dpi_display_enable(struct omap_dss_device *dssdev)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2014-05-30 17:56:22 +07:00
|
|
|
struct omap_dss_device *out = &dpi->output;
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = out->dispc_channel;
|
2009-08-07 17:15:50 +07:00
|
|
|
int r;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_lock(&dpi->lock);
|
2012-07-05 14:22:46 +07:00
|
|
|
|
2015-11-05 14:34:51 +07:00
|
|
|
if (!out->dispc_channel_connected) {
|
2012-09-07 19:23:38 +07:00
|
|
|
DSSERR("failed to enable display: no output/manager\n");
|
2012-07-05 14:22:46 +07:00
|
|
|
r = -ENODEV;
|
2012-09-07 19:23:38 +07:00
|
|
|
goto err_no_out_mgr;
|
2011-06-23 20:38:21 +07:00
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:49 +07:00
|
|
|
if (dpi->vdds_dsi_reg) {
|
2014-05-30 17:56:22 +07:00
|
|
|
r = regulator_enable(dpi->vdds_dsi_reg);
|
2010-02-04 22:03:41 +07:00
|
|
|
if (r)
|
2011-05-27 14:52:19 +07:00
|
|
|
goto err_reg_enable;
|
2010-02-04 22:03:41 +07:00
|
|
|
}
|
|
|
|
|
2011-05-27 14:52:19 +07:00
|
|
|
r = dispc_runtime_get();
|
2009-08-07 17:15:50 +07:00
|
|
|
if (r)
|
2011-05-27 14:52:19 +07:00
|
|
|
goto err_get_dispc;
|
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
r = dss_dpi_select_source(out->port_num, channel);
|
2012-09-21 16:09:54 +07:00
|
|
|
if (r)
|
|
|
|
goto err_src_sel;
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll) {
|
|
|
|
r = dss_pll_enable(dpi->pll);
|
2011-04-12 15:22:26 +07:00
|
|
|
if (r)
|
2016-05-18 16:22:32 +07:00
|
|
|
goto err_pll_init;
|
2011-04-12 15:22:26 +07:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
r = dpi_set_mode(dpi);
|
2009-08-07 17:15:50 +07:00
|
|
|
if (r)
|
2011-05-27 14:52:19 +07:00
|
|
|
goto err_set_mode;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi_config_lcd_manager(dpi);
|
2012-06-29 15:49:13 +07:00
|
|
|
|
2009-08-07 17:15:50 +07:00
|
|
|
mdelay(2);
|
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
r = dss_mgr_enable(channel);
|
2011-11-21 18:42:58 +07:00
|
|
|
if (r)
|
|
|
|
goto err_mgr_enable;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_unlock(&dpi->lock);
|
2012-07-05 14:22:46 +07:00
|
|
|
|
2009-08-07 17:15:50 +07:00
|
|
|
return 0;
|
|
|
|
|
2011-11-21 18:42:58 +07:00
|
|
|
err_mgr_enable:
|
2011-05-27 14:52:19 +07:00
|
|
|
err_set_mode:
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll)
|
|
|
|
dss_pll_disable(dpi->pll);
|
2016-05-18 16:22:32 +07:00
|
|
|
err_pll_init:
|
2012-09-21 16:09:54 +07:00
|
|
|
err_src_sel:
|
2011-05-27 14:52:19 +07:00
|
|
|
dispc_runtime_put();
|
|
|
|
err_get_dispc:
|
2017-08-05 05:43:49 +07:00
|
|
|
if (dpi->vdds_dsi_reg)
|
2014-05-30 17:56:22 +07:00
|
|
|
regulator_disable(dpi->vdds_dsi_reg);
|
2011-05-27 14:52:19 +07:00
|
|
|
err_reg_enable:
|
2012-09-07 19:23:38 +07:00
|
|
|
err_no_out_mgr:
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_unlock(&dpi->lock);
|
2009-08-07 17:15:50 +07:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-05-15 14:40:15 +07:00
|
|
|
static void dpi_display_disable(struct omap_dss_device *dssdev)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = dpi->output.dispc_channel;
|
2012-09-07 19:23:38 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_lock(&dpi->lock);
|
2012-07-05 14:22:46 +07:00
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
dss_mgr_disable(channel);
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll) {
|
2016-05-17 18:01:10 +07:00
|
|
|
dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
|
2014-10-22 18:49:14 +07:00
|
|
|
dss_pll_disable(dpi->pll);
|
2011-04-12 15:22:26 +07:00
|
|
|
}
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2011-05-27 14:52:19 +07:00
|
|
|
dispc_runtime_put();
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2017-08-05 05:43:49 +07:00
|
|
|
if (dpi->vdds_dsi_reg)
|
2014-05-30 17:56:22 +07:00
|
|
|
regulator_disable(dpi->vdds_dsi_reg);
|
2010-02-04 22:03:41 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_unlock(&dpi->lock);
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
|
|
|
|
2013-05-15 14:40:15 +07:00
|
|
|
static void dpi_set_timings(struct omap_dss_device *dssdev,
|
2016-09-22 18:07:04 +07:00
|
|
|
struct videomode *vm)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2014-05-30 17:56:22 +07:00
|
|
|
|
2009-08-07 17:15:50 +07:00
|
|
|
DSSDBG("dpi_set_timings\n");
|
2012-07-05 14:22:46 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_lock(&dpi->lock);
|
2012-07-05 14:22:46 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
dpi->vm = *vm;
|
2012-08-08 15:58:54 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_unlock(&dpi->lock);
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
|
|
|
|
2013-05-24 17:18:52 +07:00
|
|
|
static void dpi_get_timings(struct omap_dss_device *dssdev,
|
2016-09-22 18:07:04 +07:00
|
|
|
struct videomode *vm)
|
2013-05-24 17:18:52 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2014-05-30 17:56:22 +07:00
|
|
|
|
|
|
|
mutex_lock(&dpi->lock);
|
2013-05-24 17:18:52 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
*vm = dpi->vm;
|
2013-05-24 17:18:52 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_unlock(&dpi->lock);
|
2013-05-24 17:18:52 +07:00
|
|
|
}
|
|
|
|
|
2013-05-15 14:40:15 +07:00
|
|
|
static int dpi_check_timings(struct omap_dss_device *dssdev,
|
2016-09-22 18:07:04 +07:00
|
|
|
struct videomode *vm)
|
2009-08-07 17:15:50 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = dpi->output.dispc_channel;
|
2009-08-07 17:15:50 +07:00
|
|
|
int lck_div, pck_div;
|
|
|
|
unsigned long fck;
|
|
|
|
unsigned long pck;
|
2013-03-05 22:07:16 +07:00
|
|
|
struct dpi_clk_calc_ctx ctx;
|
|
|
|
bool ok;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
if (vm->hactive % 8 != 0)
|
2016-01-05 16:43:18 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
if (!dispc_mgr_timings_ok(channel, vm))
|
2009-08-07 17:15:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
if (vm->pixelclock == 0)
|
2009-08-07 17:15:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll) {
|
2016-09-22 18:07:04 +07:00
|
|
|
ok = dpi_pll_clk_calc(dpi, vm->pixelclock, &ctx);
|
2013-03-05 22:07:16 +07:00
|
|
|
if (!ok)
|
|
|
|
return -EINVAL;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
fck = ctx.pll_cinfo.clkout[ctx.clkout_idx];
|
2011-04-12 15:22:26 +07:00
|
|
|
} else {
|
2016-09-22 18:07:04 +07:00
|
|
|
ok = dpi_dss_clk_calc(vm->pixelclock, &ctx);
|
2013-03-05 22:07:16 +07:00
|
|
|
if (!ok)
|
|
|
|
return -EINVAL;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-10-31 19:44:23 +07:00
|
|
|
fck = ctx.fck;
|
2009-08-07 17:15:50 +07:00
|
|
|
}
|
2011-04-12 15:22:26 +07:00
|
|
|
|
2013-03-05 22:07:16 +07:00
|
|
|
lck_div = ctx.dispc_cinfo.lck_div;
|
|
|
|
pck_div = ctx.dispc_cinfo.pck_div;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2013-04-10 18:12:14 +07:00
|
|
|
pck = fck / lck_div / pck_div;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
2016-09-22 18:07:04 +07:00
|
|
|
vm->pixelclock = pck;
|
2009-08-07 17:15:50 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
static int dpi_verify_pll(struct dss_pll *pll)
|
2012-10-30 17:57:43 +07:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* do initial setup with the PLL to see if it is operational */
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
r = dss_pll_enable(pll);
|
2014-08-08 14:04:31 +07:00
|
|
|
if (r)
|
2012-10-30 17:57:43 +07:00
|
|
|
return r;
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
dss_pll_disable(pll);
|
2012-10-30 17:57:43 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-05 05:44:12 +07:00
|
|
|
static const struct soc_device_attribute dpi_soc_devices[] = {
|
|
|
|
{ .family = "OMAP3[456]*" },
|
|
|
|
{ .family = "[AD]M37*" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
static int dpi_init_regulator(struct dpi_data *dpi)
|
2013-04-19 20:52:27 +07:00
|
|
|
{
|
|
|
|
struct regulator *vdds_dsi;
|
|
|
|
|
2017-08-05 05:44:12 +07:00
|
|
|
/*
|
|
|
|
* The DPI uses the DSI VDDS on OMAP34xx, OMAP35xx, OMAP36xx, AM37xx and
|
|
|
|
* DM37xx only.
|
|
|
|
*/
|
|
|
|
if (!soc_device_match(dpi_soc_devices))
|
2013-04-19 20:52:27 +07:00
|
|
|
return 0;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
if (dpi->vdds_dsi_reg)
|
2013-04-19 20:52:27 +07:00
|
|
|
return 0;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
vdds_dsi = devm_regulator_get(&dpi->pdev->dev, "vdds_dsi");
|
2013-04-19 20:52:27 +07:00
|
|
|
if (IS_ERR(vdds_dsi)) {
|
2013-12-19 21:15:34 +07:00
|
|
|
if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
|
|
|
|
DSSERR("can't get VDDS_DSI regulator\n");
|
2013-08-29 14:06:55 +07:00
|
|
|
return PTR_ERR(vdds_dsi);
|
2013-04-19 20:52:27 +07:00
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->vdds_dsi_reg = vdds_dsi;
|
2013-04-19 20:52:27 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
static void dpi_init_pll(struct dpi_data *dpi)
|
2013-04-19 20:52:27 +07:00
|
|
|
{
|
2014-10-22 18:49:14 +07:00
|
|
|
struct dss_pll *pll;
|
2013-04-19 20:52:27 +07:00
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
if (dpi->pll)
|
2013-04-19 20:52:27 +07:00
|
|
|
return;
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
dpi->clk_src = dpi_get_clk_src(dpi);
|
2016-05-17 20:08:54 +07:00
|
|
|
|
|
|
|
pll = dss_pll_find_by_src(dpi->clk_src);
|
2014-10-22 18:49:14 +07:00
|
|
|
if (!pll)
|
2013-04-19 20:52:27 +07:00
|
|
|
return;
|
|
|
|
|
2016-05-18 16:22:32 +07:00
|
|
|
if (dpi_verify_pll(pll)) {
|
|
|
|
DSSWARN("PLL not operational\n");
|
2013-04-19 20:52:27 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:49:14 +07:00
|
|
|
dpi->pll = pll;
|
2013-04-19 20:52:27 +07:00
|
|
|
}
|
|
|
|
|
2013-02-13 16:23:54 +07:00
|
|
|
/*
|
|
|
|
* Return a hardcoded channel for the DPI output. This should work for
|
|
|
|
* current use cases, but this can be later expanded to either resolve
|
|
|
|
* the channel in some more dynamic manner, or get the channel as a user
|
|
|
|
* parameter.
|
|
|
|
*/
|
2017-08-05 05:43:56 +07:00
|
|
|
static enum omap_channel dpi_get_channel(struct dpi_data *dpi, int port_num)
|
2013-02-13 16:23:54 +07:00
|
|
|
{
|
2017-08-05 05:43:56 +07:00
|
|
|
switch (dpi->dss_model) {
|
|
|
|
case DSS_MODEL_OMAP2:
|
|
|
|
case DSS_MODEL_OMAP3:
|
2013-02-13 16:23:54 +07:00
|
|
|
return OMAP_DSS_CHANNEL_LCD;
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_DRA7:
|
2014-12-31 16:26:06 +07:00
|
|
|
switch (port_num) {
|
|
|
|
case 2:
|
|
|
|
return OMAP_DSS_CHANNEL_LCD3;
|
|
|
|
case 1:
|
|
|
|
return OMAP_DSS_CHANNEL_LCD2;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return OMAP_DSS_CHANNEL_LCD;
|
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_OMAP4:
|
2013-02-13 16:23:54 +07:00
|
|
|
return OMAP_DSS_CHANNEL_LCD2;
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
case DSS_MODEL_OMAP5:
|
2013-02-13 16:23:54 +07:00
|
|
|
return OMAP_DSS_CHANNEL_LCD3;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DSSWARN("unsupported DSS version\n");
|
|
|
|
return OMAP_DSS_CHANNEL_LCD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-24 17:18:52 +07:00
|
|
|
static int dpi_connect(struct omap_dss_device *dssdev,
|
|
|
|
struct omap_dss_device *dst)
|
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
2015-11-05 14:52:00 +07:00
|
|
|
enum omap_channel channel = dpi->output.dispc_channel;
|
2013-05-24 17:18:52 +07:00
|
|
|
int r;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
r = dpi_init_regulator(dpi);
|
2013-05-24 17:18:52 +07:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi_init_pll(dpi);
|
2013-05-24 17:18:52 +07:00
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
r = dss_mgr_connect(channel, dssdev);
|
2013-05-24 17:18:52 +07:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = omapdss_output_set_device(dssdev, dst);
|
|
|
|
if (r) {
|
|
|
|
DSSERR("failed to connect output to new device: %s\n",
|
|
|
|
dst->name);
|
2015-11-05 14:52:00 +07:00
|
|
|
dss_mgr_disconnect(channel, dssdev);
|
2013-05-24 17:18:52 +07:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dpi_disconnect(struct omap_dss_device *dssdev,
|
|
|
|
struct omap_dss_device *dst)
|
|
|
|
{
|
2015-11-05 14:52:00 +07:00
|
|
|
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
|
|
|
|
enum omap_channel channel = dpi->output.dispc_channel;
|
|
|
|
|
2013-07-24 17:06:54 +07:00
|
|
|
WARN_ON(dst != dssdev->dst);
|
2013-05-24 17:18:52 +07:00
|
|
|
|
2013-07-24 17:06:54 +07:00
|
|
|
if (dst != dssdev->dst)
|
2013-05-24 17:18:52 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
omapdss_output_unset_device(dssdev);
|
|
|
|
|
2015-11-05 14:52:00 +07:00
|
|
|
dss_mgr_disconnect(channel, dssdev);
|
2013-05-24 17:18:52 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct omapdss_dpi_ops dpi_ops = {
|
|
|
|
.connect = dpi_connect,
|
|
|
|
.disconnect = dpi_disconnect,
|
|
|
|
|
2013-05-15 14:40:15 +07:00
|
|
|
.enable = dpi_display_enable,
|
|
|
|
.disable = dpi_display_disable,
|
2013-05-24 17:18:52 +07:00
|
|
|
|
|
|
|
.check_timings = dpi_check_timings,
|
2013-05-15 14:40:15 +07:00
|
|
|
.set_timings = dpi_set_timings,
|
2013-05-24 17:18:52 +07:00
|
|
|
.get_timings = dpi_get_timings,
|
|
|
|
};
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
|
2014-06-02 15:41:51 +07:00
|
|
|
{
|
|
|
|
struct omap_dss_device *out = &dpi->output;
|
2014-05-06 18:37:39 +07:00
|
|
|
int r;
|
|
|
|
u32 port_num;
|
|
|
|
|
|
|
|
r = of_property_read_u32(port, "reg", &port_num);
|
|
|
|
if (r)
|
|
|
|
port_num = 0;
|
|
|
|
|
|
|
|
switch (port_num) {
|
|
|
|
case 2:
|
|
|
|
out->name = "dpi.2";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
out->name = "dpi.1";
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
out->name = "dpi.0";
|
|
|
|
break;
|
|
|
|
}
|
2014-06-02 15:41:51 +07:00
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
out->dev = &dpi->pdev->dev;
|
2014-06-02 15:41:51 +07:00
|
|
|
out->id = OMAP_DSS_OUTPUT_DPI;
|
|
|
|
out->output_type = OMAP_DISPLAY_TYPE_DPI;
|
2017-08-05 05:43:56 +07:00
|
|
|
out->dispc_channel = dpi_get_channel(dpi, port_num);
|
2014-05-06 18:37:39 +07:00
|
|
|
out->port_num = port_num;
|
2014-06-02 15:41:51 +07:00
|
|
|
out->ops.dpi = &dpi_ops;
|
|
|
|
out->owner = THIS_MODULE;
|
|
|
|
|
|
|
|
omapdss_register_output(out);
|
|
|
|
}
|
|
|
|
|
2015-06-04 18:12:16 +07:00
|
|
|
static void dpi_uninit_output_port(struct device_node *port)
|
2014-06-02 15:41:51 +07:00
|
|
|
{
|
|
|
|
struct dpi_data *dpi = port->data;
|
|
|
|
struct omap_dss_device *out = &dpi->output;
|
|
|
|
|
|
|
|
omapdss_unregister_output(out);
|
|
|
|
}
|
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
int dpi_init_port(struct platform_device *pdev, struct device_node *port,
|
|
|
|
enum dss_model dss_model)
|
2013-12-16 20:13:24 +07:00
|
|
|
{
|
2014-06-01 14:17:44 +07:00
|
|
|
struct dpi_data *dpi;
|
2013-12-16 20:13:24 +07:00
|
|
|
struct device_node *ep;
|
|
|
|
u32 datalines;
|
|
|
|
int r;
|
|
|
|
|
2014-06-01 14:17:44 +07:00
|
|
|
dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL);
|
|
|
|
if (!dpi)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2017-03-22 20:26:08 +07:00
|
|
|
ep = of_get_next_child(port, NULL);
|
2013-12-16 20:13:24 +07:00
|
|
|
if (!ep)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
r = of_property_read_u32(ep, "data-lines", &datalines);
|
|
|
|
if (r) {
|
|
|
|
DSSERR("failed to parse datalines\n");
|
|
|
|
goto err_datalines;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->data_lines = datalines;
|
2013-12-16 20:13:24 +07:00
|
|
|
|
|
|
|
of_node_put(ep);
|
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->pdev = pdev;
|
2017-08-05 05:43:56 +07:00
|
|
|
dpi->dss_model = dss_model;
|
2014-06-02 15:41:51 +07:00
|
|
|
port->data = dpi;
|
2013-12-16 20:13:24 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
mutex_init(&dpi->lock);
|
2013-12-16 20:13:24 +07:00
|
|
|
|
2017-08-05 05:43:56 +07:00
|
|
|
dpi_init_output_port(dpi, port);
|
2013-12-16 20:13:24 +07:00
|
|
|
|
2014-05-30 17:56:22 +07:00
|
|
|
dpi->port_initialized = true;
|
2013-12-16 20:13:24 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_datalines:
|
|
|
|
of_node_put(ep);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-06-04 18:12:16 +07:00
|
|
|
void dpi_uninit_port(struct device_node *port)
|
2013-12-16 20:13:24 +07:00
|
|
|
{
|
2014-06-02 15:41:51 +07:00
|
|
|
struct dpi_data *dpi = port->data;
|
2014-05-30 17:56:22 +07:00
|
|
|
|
|
|
|
if (!dpi->port_initialized)
|
2013-12-16 20:13:24 +07:00
|
|
|
return;
|
|
|
|
|
2014-06-02 15:41:51 +07:00
|
|
|
dpi_uninit_output_port(port);
|
2013-12-16 20:13:24 +07:00
|
|
|
}
|