Commit 9cd87829 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Tomi Valkeinen

drm/omap: dsi: introduce mipi_dsi_host

This moves from custom platform driver infrastructure to mipi_dsi_host
and mipi_dsi_device. Note, that this is a graduate step and the driver
only uses the devices types and transfer function, but not yet the new
device binding style or drm_panel.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-13-tomi.valkeinen@ti.com
parent 1ed62538
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/sched/signal.h> #include <linux/sched/signal.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
...@@ -39,13 +38,13 @@ ...@@ -39,13 +38,13 @@
#define DCS_GET_ID3 0xdc #define DCS_GET_ID3 0xdc
struct panel_drv_data { struct panel_drv_data {
struct mipi_dsi_device *dsi;
struct omap_dss_device dssdev; struct omap_dss_device dssdev;
struct omap_dss_device *src; struct omap_dss_device *src;
struct videomode vm; struct videomode vm;
struct platform_device *pdev;
struct mutex lock; struct mutex lock;
struct backlight_device *bldev; struct backlight_device *bldev;
...@@ -139,7 +138,7 @@ static void hw_guard_wait(struct panel_drv_data *ddata) ...@@ -139,7 +138,7 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
{ {
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = { const struct mipi_dsi_msg msg = {
.channel = ddata->channel, .channel = ddata->channel,
.type = MIPI_DSI_DCS_READ, .type = MIPI_DSI_DCS_READ,
...@@ -149,12 +148,12 @@ static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) ...@@ -149,12 +148,12 @@ static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
.rx_buf = data .rx_buf = data
}; };
return src->ops->dsi.transfer(src, &msg); return dsi->host->ops->transfer(dsi->host, &msg);
} }
static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
{ {
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = { const struct mipi_dsi_msg msg = {
.channel = ddata->channel, .channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE, .type = MIPI_DSI_DCS_SHORT_WRITE,
...@@ -162,12 +161,12 @@ static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) ...@@ -162,12 +161,12 @@ static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
.tx_len = 1, .tx_len = 1,
}; };
return src->ops->dsi.transfer(src, &msg); return dsi->host->ops->transfer(dsi->host, &msg);
} }
static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
{ {
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
const u8 buf[] = { dcs_cmd, param }; const u8 buf[] = { dcs_cmd, param };
const struct mipi_dsi_msg msg = { const struct mipi_dsi_msg msg = {
.channel = ddata->channel, .channel = ddata->channel,
...@@ -176,13 +175,13 @@ static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) ...@@ -176,13 +175,13 @@ static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
.tx_len = 2, .tx_len = 2,
}; };
return src->ops->dsi.transfer(src, &msg); return dsi->host->ops->transfer(dsi->host, &msg);
} }
static int dsicm_sleep_in(struct panel_drv_data *ddata) static int dsicm_sleep_in(struct panel_drv_data *ddata)
{ {
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
int r; int r;
const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE; const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
const struct mipi_dsi_msg msg = { const struct mipi_dsi_msg msg = {
...@@ -194,7 +193,7 @@ static int dsicm_sleep_in(struct panel_drv_data *ddata) ...@@ -194,7 +193,7 @@ static int dsicm_sleep_in(struct panel_drv_data *ddata)
hw_guard_wait(ddata); hw_guard_wait(ddata);
r = src->ops->dsi.transfer(src, &msg); r = dsi->host->ops->transfer(dsi->host, &msg);
if (r) if (r)
return r; return r;
...@@ -242,7 +241,7 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3) ...@@ -242,7 +241,7 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
static int dsicm_set_update_window(struct panel_drv_data *ddata, static int dsicm_set_update_window(struct panel_drv_data *ddata,
u16 x, u16 y, u16 w, u16 h) u16 x, u16 y, u16 w, u16 h)
{ {
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
int r; int r;
u16 x1 = x; u16 x1 = x;
u16 x2 = x + w - 1; u16 x2 = x + w - 1;
...@@ -279,11 +278,11 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata, ...@@ -279,11 +278,11 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
.tx_len = 5, .tx_len = 5,
}; };
r = src->ops->dsi.transfer(src, &msgX); r = dsi->host->ops->transfer(dsi->host, &msgX);
if (r) if (r)
return r; return r;
r = src->ops->dsi.transfer(src, &msgY); r = dsi->host->ops->transfer(dsi->host, &msgY);
if (r) if (r)
return r; return r;
...@@ -326,7 +325,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata) ...@@ -326,7 +325,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
return 0; return 0;
err: err:
dev_err(&ddata->pdev->dev, "enter ULPS failed"); dev_err(&ddata->dsi->dev, "enter ULPS failed");
dsicm_panel_reset(ddata); dsicm_panel_reset(ddata);
ddata->ulps_enabled = false; ddata->ulps_enabled = false;
...@@ -349,7 +348,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) ...@@ -349,7 +348,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
r = _dsicm_enable_te(ddata, true); r = _dsicm_enable_te(ddata, true);
if (r) { if (r) {
dev_err(&ddata->pdev->dev, "failed to re-enable TE"); dev_err(&ddata->dsi->dev, "failed to re-enable TE");
goto err2; goto err2;
} }
...@@ -363,7 +362,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) ...@@ -363,7 +362,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0; return 0;
err2: err2:
dev_err(&ddata->pdev->dev, "failed to exit ULPS"); dev_err(&ddata->dsi->dev, "failed to exit ULPS");
r = dsicm_panel_reset(ddata); r = dsicm_panel_reset(ddata);
if (!r) { if (!r) {
...@@ -400,7 +399,7 @@ static int dsicm_bl_update_status(struct backlight_device *dev) ...@@ -400,7 +399,7 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
else else
level = 0; level = 0;
dev_dbg(&ddata->pdev->dev, "update brightness to %d\n", level); dev_dbg(&ddata->dsi->dev, "update brightness to %d\n", level);
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
...@@ -637,7 +636,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -637,7 +636,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (ddata->vpnl) { if (ddata->vpnl) {
r = regulator_enable(ddata->vpnl); r = regulator_enable(ddata->vpnl);
if (r) { if (r) {
dev_err(&ddata->pdev->dev, dev_err(&ddata->dsi->dev,
"failed to enable VPNL: %d\n", r); "failed to enable VPNL: %d\n", r);
return r; return r;
} }
...@@ -646,7 +645,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -646,7 +645,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (ddata->vddi) { if (ddata->vddi) {
r = regulator_enable(ddata->vddi); r = regulator_enable(ddata->vddi);
if (r) { if (r) {
dev_err(&ddata->pdev->dev, dev_err(&ddata->dsi->dev,
"failed to enable VDDI: %d\n", r); "failed to enable VDDI: %d\n", r);
goto err_vpnl; goto err_vpnl;
} }
...@@ -654,7 +653,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -654,7 +653,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
r = src->ops->dsi.set_config(src, &dsi_config); r = src->ops->dsi.set_config(src, &dsi_config);
if (r) { if (r) {
dev_err(&ddata->pdev->dev, "failed to configure DSI\n"); dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
goto err_vddi; goto err_vddi;
} }
...@@ -701,7 +700,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -701,7 +700,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
ddata->enabled = true; ddata->enabled = true;
if (!ddata->intro_printed) { if (!ddata->intro_printed) {
dev_info(&ddata->pdev->dev, "panel revision %02x.%02x.%02x\n", dev_info(&ddata->dsi->dev, "panel revision %02x.%02x.%02x\n",
id1, id2, id3); id1, id2, id3);
ddata->intro_printed = true; ddata->intro_printed = true;
} }
...@@ -710,7 +709,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -710,7 +709,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
return 0; return 0;
err: err:
dev_err(&ddata->pdev->dev, "error while enabling panel, issuing HW reset\n"); dev_err(&ddata->dsi->dev, "error while enabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata); dsicm_hw_reset(ddata);
...@@ -737,7 +736,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata) ...@@ -737,7 +736,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
r = dsicm_sleep_in(ddata); r = dsicm_sleep_in(ddata);
if (r) { if (r) {
dev_err(&ddata->pdev->dev, dev_err(&ddata->dsi->dev,
"error disabling panel, issuing HW reset\n"); "error disabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata); dsicm_hw_reset(ddata);
} }
...@@ -754,7 +753,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata) ...@@ -754,7 +753,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
static int dsicm_panel_reset(struct panel_drv_data *ddata) static int dsicm_panel_reset(struct panel_drv_data *ddata)
{ {
dev_err(&ddata->pdev->dev, "performing LCD reset\n"); dev_err(&ddata->dsi->dev, "performing LCD reset\n");
dsicm_power_off(ddata); dsicm_power_off(ddata);
dsicm_hw_reset(ddata); dsicm_hw_reset(ddata);
...@@ -765,7 +764,7 @@ static int dsicm_connect(struct omap_dss_device *src, ...@@ -765,7 +764,7 @@ static int dsicm_connect(struct omap_dss_device *src,
struct omap_dss_device *dst) struct omap_dss_device *dst)
{ {
struct panel_drv_data *ddata = to_panel_data(dst); struct panel_drv_data *ddata = to_panel_data(dst);
struct device *dev = &ddata->pdev->dev; struct device *dev = &ddata->dsi->dev;
int r; int r;
r = src->ops->dsi.request_vc(src, ddata->channel); r = src->ops->dsi.request_vc(src, ddata->channel);
...@@ -810,7 +809,7 @@ static void dsicm_enable(struct omap_dss_device *dssdev) ...@@ -810,7 +809,7 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
return; return;
err: err:
dev_dbg(&ddata->pdev->dev, "enable failed (%d)\n", r); dev_dbg(&ddata->dsi->dev, "enable failed (%d)\n", r);
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
} }
...@@ -842,7 +841,7 @@ static void dsicm_framedone_cb(int err, void *data) ...@@ -842,7 +841,7 @@ static void dsicm_framedone_cb(int err, void *data)
struct panel_drv_data *ddata = data; struct panel_drv_data *ddata = data;
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
dev_dbg(&ddata->pdev->dev, "framedone, err %d\n", err); dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
} }
...@@ -866,7 +865,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data) ...@@ -866,7 +865,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
err: err:
dev_err(&ddata->pdev->dev, "start update failed\n"); dev_err(&ddata->dsi->dev, "start update failed\n");
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -877,7 +876,7 @@ static void dsicm_te_timeout_work_callback(struct work_struct *work) ...@@ -877,7 +876,7 @@ static void dsicm_te_timeout_work_callback(struct work_struct *work)
te_timeout_work.work); te_timeout_work.work);
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
dev_err(&ddata->pdev->dev, "TE not received for 250ms!\n"); dev_err(&ddata->dsi->dev, "TE not received for 250ms!\n");
atomic_set(&ddata->do_update, 0); atomic_set(&ddata->do_update, 0);
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
...@@ -890,7 +889,7 @@ static int dsicm_update(struct omap_dss_device *dssdev, ...@@ -890,7 +889,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
int r; int r;
dev_dbg(&ddata->pdev->dev, "update %d, %d, %d x %d\n", x, y, w, h); dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
src->ops->dsi.bus_lock(src); src->ops->dsi.bus_lock(src);
...@@ -935,14 +934,14 @@ static int dsicm_sync(struct omap_dss_device *dssdev) ...@@ -935,14 +934,14 @@ static int dsicm_sync(struct omap_dss_device *dssdev)
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
dev_dbg(&ddata->pdev->dev, "sync\n"); dev_dbg(&ddata->dsi->dev, "sync\n");
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
src->ops->dsi.bus_lock(src); src->ops->dsi.bus_lock(src);
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
dev_dbg(&ddata->pdev->dev, "sync done\n"); dev_dbg(&ddata->dsi->dev, "sync done\n");
return 0; return 0;
} }
...@@ -1019,7 +1018,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev, ...@@ -1019,7 +1018,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
u16 size) u16 size)
{ {
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi;
const u8 buf[] = { const u8 buf[] = {
size & 0xff, size & 0xff,
...@@ -1033,7 +1032,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev, ...@@ -1033,7 +1032,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
.tx_len = 2, .tx_len = 2,
}; };
return src->ops->dsi.transfer(src, &msg); return dsi->host->ops->transfer(dsi->host, &msg);
} }
static int dsicm_memory_read(struct omap_dss_device *dssdev, static int dsicm_memory_read(struct omap_dss_device *dssdev,
...@@ -1041,6 +1040,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, ...@@ -1041,6 +1040,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
u16 x, u16 y, u16 w, u16 h) u16 x, u16 y, u16 w, u16 h)
{ {
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct mipi_dsi_device *dsi = ddata->dsi;
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
int r; int r;
int first = 1; int first = 1;
...@@ -1092,7 +1092,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, ...@@ -1092,7 +1092,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
}; };
first = 0; first = 0;
r = src->ops->dsi.transfer(src, &msg); r = dsi->host->ops->transfer(dsi->host, &msg);
if (r < 0) { if (r < 0) {
dev_err(dssdev->dev, "read error\n"); dev_err(dssdev->dev, "read error\n");
goto err3; goto err3;
...@@ -1101,12 +1101,12 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, ...@@ -1101,12 +1101,12 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
buf_used += r; buf_used += r;
if (r < plen) { if (r < plen) {
dev_err(&ddata->pdev->dev, "short read\n"); dev_err(&ddata->dsi->dev, "short read\n");
break; break;
} }
if (signal_pending(current)) { if (signal_pending(current)) {
dev_err(&ddata->pdev->dev, "signal pending, " dev_err(&ddata->dsi->dev, "signal pending, "
"aborting memory read\n"); "aborting memory read\n");
r = -ERESTARTSYS; r = -ERESTARTSYS;
goto err3; goto err3;
...@@ -1200,28 +1200,28 @@ static const struct omap_dss_driver dsicm_dss_driver = { ...@@ -1200,28 +1200,28 @@ static const struct omap_dss_driver dsicm_dss_driver = {
.memory_read = dsicm_memory_read, .memory_read = dsicm_memory_read,
}; };
static int dsicm_probe_of(struct platform_device *pdev) static int dsicm_probe_of(struct mipi_dsi_device *dsi)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = dsi->dev.of_node;
struct backlight_device *backlight; struct backlight_device *backlight;
struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
struct display_timing timing; struct display_timing timing;
int err; int err;
ddata->channel = TCH; ddata->channel = TCH;
ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW); ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) { if (IS_ERR(ddata->reset_gpio)) {
err = PTR_ERR(ddata->reset_gpio); err = PTR_ERR(ddata->reset_gpio);
dev_err(&pdev->dev, "reset gpio request failed: %d", err); dev_err(&dsi->dev, "reset gpio request failed: %d", err);
return err; return err;
} }
ddata->ext_te_gpio = devm_gpiod_get_optional(&pdev->dev, "te", ddata->ext_te_gpio = devm_gpiod_get_optional(&dsi->dev, "te",
GPIOD_IN); GPIOD_IN);
if (IS_ERR(ddata->ext_te_gpio)) { if (IS_ERR(ddata->ext_te_gpio)) {
err = PTR_ERR(ddata->ext_te_gpio); err = PTR_ERR(ddata->ext_te_gpio);
dev_err(&pdev->dev, "TE gpio request failed: %d", err); dev_err(&dsi->dev, "TE gpio request failed: %d", err);
return err; return err;
} }
...@@ -1232,7 +1232,7 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1232,7 +1232,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
ddata->vm.pixelclock = ddata->vm.pixelclock =
ddata->vm.hactive * ddata->vm.vactive * 60; ddata->vm.hactive * ddata->vm.vactive * 60;
} else { } else {
dev_warn(&pdev->dev, dev_warn(&dsi->dev,
"failed to get video timing, using defaults\n"); "failed to get video timing, using defaults\n");
} }
...@@ -1242,7 +1242,7 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1242,7 +1242,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
ddata->height_mm = 0; ddata->height_mm = 0;
of_property_read_u32(node, "height-mm", &ddata->height_mm); of_property_read_u32(node, "height-mm", &ddata->height_mm);
ddata->vpnl = devm_regulator_get_optional(&pdev->dev, "vpnl"); ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl");
if (IS_ERR(ddata->vpnl)) { if (IS_ERR(ddata->vpnl)) {
err = PTR_ERR(ddata->vpnl); err = PTR_ERR(ddata->vpnl);
if (err == -EPROBE_DEFER) if (err == -EPROBE_DEFER)
...@@ -1250,7 +1250,7 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1250,7 +1250,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
ddata->vpnl = NULL; ddata->vpnl = NULL;
} }
ddata->vddi = devm_regulator_get_optional(&pdev->dev, "vddi"); ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi");
if (IS_ERR(ddata->vddi)) { if (IS_ERR(ddata->vddi)) {
err = PTR_ERR(ddata->vddi); err = PTR_ERR(ddata->vddi);
if (err == -EPROBE_DEFER) if (err == -EPROBE_DEFER)
...@@ -1258,7 +1258,7 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1258,7 +1258,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
ddata->vddi = NULL; ddata->vddi = NULL;
} }
backlight = devm_of_find_backlight(&pdev->dev); backlight = devm_of_find_backlight(&dsi->dev);
if (IS_ERR(backlight)) if (IS_ERR(backlight))
return PTR_ERR(backlight); return PTR_ERR(backlight);
...@@ -1273,11 +1273,11 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1273,11 +1273,11 @@ static int dsicm_probe_of(struct platform_device *pdev)
return 0; return 0;
} }
static int dsicm_probe(struct platform_device *pdev) static int dsicm_probe(struct mipi_dsi_device *dsi)
{ {
struct panel_drv_data *ddata; struct panel_drv_data *ddata;
struct backlight_device *bldev = NULL; struct backlight_device *bldev = NULL;
struct device *dev = &pdev->dev; struct device *dev = &dsi->dev;
struct omap_dss_device *dssdev; struct omap_dss_device *dssdev;
int r; int r;
...@@ -1287,14 +1287,14 @@ static int dsicm_probe(struct platform_device *pdev) ...@@ -1287,14 +1287,14 @@ static int dsicm_probe(struct platform_device *pdev)
if (!ddata) if (!ddata)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, ddata); mipi_dsi_set_drvdata(dsi, ddata);
ddata->pdev = pdev; ddata->dsi = dsi;
ddata->vm.hactive = 864; ddata->vm.hactive = 864;
ddata->vm.vactive = 480; ddata->vm.vactive = 480;
ddata->vm.pixelclock = 864 * 480 * 60; ddata->vm.pixelclock = 864 * 480 * 60;
r = dsicm_probe_of(pdev); r = dsicm_probe_of(dsi);
if (r) if (r)
return r; return r;
...@@ -1376,12 +1376,12 @@ static int dsicm_probe(struct platform_device *pdev) ...@@ -1376,12 +1376,12 @@ static int dsicm_probe(struct platform_device *pdev)
return r; return r;
} }
static int __exit dsicm_remove(struct platform_device *pdev) static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
{ {
struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
struct omap_dss_device *dssdev = &ddata->dssdev; struct omap_dss_device *dssdev = &ddata->dssdev;
dev_dbg(&pdev->dev, "remove\n"); dev_dbg(&dsi->dev, "remove\n");
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
...@@ -1389,7 +1389,7 @@ static int __exit dsicm_remove(struct platform_device *pdev) ...@@ -1389,7 +1389,7 @@ static int __exit dsicm_remove(struct platform_device *pdev)
dsicm_disable(dssdev); dsicm_disable(dssdev);
omapdss_device_disconnect(ddata->src, dssdev); omapdss_device_disconnect(ddata->src, dssdev);
sysfs_remove_group(&pdev->dev.kobj, &dsicm_attr_group); sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
if (ddata->extbldev) if (ddata->extbldev)
put_device(&ddata->extbldev->dev); put_device(&ddata->extbldev->dev);
...@@ -1410,7 +1410,7 @@ static const struct of_device_id dsicm_of_match[] = { ...@@ -1410,7 +1410,7 @@ static const struct of_device_id dsicm_of_match[] = {
MODULE_DEVICE_TABLE(of, dsicm_of_match); MODULE_DEVICE_TABLE(of, dsicm_of_match);
static struct platform_driver dsicm_driver = { static struct mipi_dsi_driver dsicm_driver = {
.probe = dsicm_probe, .probe = dsicm_probe,
.remove = __exit_p(dsicm_remove), .remove = __exit_p(dsicm_remove),
.driver = { .driver = {
...@@ -1419,8 +1419,7 @@ static struct platform_driver dsicm_driver = { ...@@ -1419,8 +1419,7 @@ static struct platform_driver dsicm_driver = {
.suppress_bind_attrs = true, .suppress_bind_attrs = true,
}, },
}; };
module_mipi_dsi_driver(dsicm_driver);
module_platform_driver(dsicm_driver);
MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>"); MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
MODULE_DESCRIPTION("Generic DSI Command Mode Panel Driver"); MODULE_DESCRIPTION("Generic DSI Command Mode Panel Driver");
......
...@@ -334,6 +334,8 @@ struct dsi_data { ...@@ -334,6 +334,8 @@ struct dsi_data {
struct regmap *syscon; struct regmap *syscon;
struct dss_device *dss; struct dss_device *dss;
struct mipi_dsi_host host;
struct dispc_clock_info user_dispc_cinfo; struct dispc_clock_info user_dispc_cinfo;
struct dss_pll_clock_info user_dsi_cinfo; struct dss_pll_clock_info user_dsi_cinfo;
...@@ -432,6 +434,11 @@ static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev) ...@@ -432,6 +434,11 @@ static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
return dev_get_drvdata(dssdev->dev); return dev_get_drvdata(dssdev->dev);
} }
static inline struct dsi_data *host_to_omap(struct mipi_dsi_host *host)
{
return container_of(host, struct dsi_data, host);
}
static inline void dsi_write_reg(struct dsi_data *dsi, static inline void dsi_write_reg(struct dsi_data *dsi,
const struct dsi_reg idx, u32 val) const struct dsi_reg idx, u32 val)
{ {
...@@ -4708,9 +4715,12 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel) ...@@ -4708,9 +4715,12 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
} }
} }
static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev, static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
const struct mipi_dsi_msg *msg) const struct mipi_dsi_msg *msg)
{ {
struct dsi_data *dsi = host_to_omap(host);
struct omap_dss_device *dssdev = &dsi->output;
switch (msg->type) { switch (msg->type) {
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
...@@ -4784,11 +4794,29 @@ static const struct omap_dss_device_ops dsi_ops = { ...@@ -4784,11 +4794,29 @@ static const struct omap_dss_device_ops dsi_ops = {
.request_vc = dsi_request_vc, .request_vc = dsi_request_vc,
.release_vc = dsi_release_vc, .release_vc = dsi_release_vc,
.transfer = omap_dsi_transfer,
}, },
}; };
static int omap_dsi_host_attach(struct mipi_dsi_host *host,
struct mipi_dsi_device *dsi)
{
/* TODO: convert driver from custom binding method to this one */
return 0;
}
static int omap_dsi_host_detach(struct mipi_dsi_host *host,
struct mipi_dsi_device *dsi)
{
/* TODO: convert driver from custom binding method to this one */
return 0;
}
static const struct mipi_dsi_host_ops omap_dsi_host_ops = {
.attach = omap_dsi_host_attach,
.detach = omap_dsi_host_detach,
.transfer = omap_dsi_host_transfer,
};
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* PLL * PLL
*/ */
...@@ -5257,15 +5285,18 @@ static int dsi_probe(struct platform_device *pdev) ...@@ -5257,15 +5285,18 @@ static int dsi_probe(struct platform_device *pdev)
dsi->num_lanes_supported = 3; dsi->num_lanes_supported = 3;
} }
r = of_platform_populate(dev->of_node, NULL, NULL, dev); dsi->host.ops = &omap_dsi_host_ops;
if (r) { dsi->host.dev = &pdev->dev;
DSSERR("Failed to populate DSI child devices: %d\n", r);
r = mipi_dsi_host_register(&dsi->host);
if (r < 0) {
dev_err(&pdev->dev, "failed to register DSI host: %d\n", r);
goto err_pm_disable; goto err_pm_disable;
} }
r = dsi_init_output(dsi); r = dsi_init_output(dsi);
if (r) if (r)
goto err_of_depopulate; goto err_dsi_host_unregister;
r = dsi_probe_of(dsi); r = dsi_probe_of(dsi);
if (r) { if (r) {
...@@ -5281,8 +5312,8 @@ static int dsi_probe(struct platform_device *pdev) ...@@ -5281,8 +5312,8 @@ static int dsi_probe(struct platform_device *pdev)
err_uninit_output: err_uninit_output:
dsi_uninit_output(dsi); dsi_uninit_output(dsi);
err_of_depopulate: err_dsi_host_unregister:
of_platform_depopulate(dev); mipi_dsi_host_unregister(&dsi->host);
err_pm_disable: err_pm_disable:
pm_runtime_disable(dev); pm_runtime_disable(dev);
return r; return r;
...@@ -5296,7 +5327,7 @@ static int dsi_remove(struct platform_device *pdev) ...@@ -5296,7 +5327,7 @@ static int dsi_remove(struct platform_device *pdev)
dsi_uninit_output(dsi); dsi_uninit_output(dsi);
of_platform_depopulate(&pdev->dev); mipi_dsi_host_unregister(&dsi->host);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
......
...@@ -307,10 +307,6 @@ struct omapdss_dsi_ops { ...@@ -307,10 +307,6 @@ struct omapdss_dsi_ops {
int (*request_vc)(struct omap_dss_device *dssdev, int channel); int (*request_vc)(struct omap_dss_device *dssdev, int channel);
void (*release_vc)(struct omap_dss_device *dssdev, int channel); void (*release_vc)(struct omap_dss_device *dssdev, int channel);
/* data transfer */
ssize_t (*transfer)(struct omap_dss_device *dssdev,
const struct mipi_dsi_msg *msg);
}; };
struct omap_dss_device_ops { struct omap_dss_device_ops {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment