Commit 0c93a61d authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Tomi Valkeinen

drm/omap: dsi: do bus locking in host driver

This moves the bus locking into the host driver and unexports
the custom API in preparation for drm_panel support.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-27-tomi.valkeinen@ti.com
parent e9c7a0d7
...@@ -295,7 +295,6 @@ static int dsicm_wake_up(struct panel_drv_data *ddata) ...@@ -295,7 +295,6 @@ static int dsicm_wake_up(struct panel_drv_data *ddata)
static int dsicm_bl_update_status(struct backlight_device *dev) static int dsicm_bl_update_status(struct backlight_device *dev)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
struct omap_dss_device *src = ddata->src;
int r = 0; int r = 0;
int level; int level;
...@@ -310,14 +309,10 @@ static int dsicm_bl_update_status(struct backlight_device *dev) ...@@ -310,14 +309,10 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
if (ddata->enabled) { if (ddata->enabled) {
src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (!r) if (!r)
r = dsicm_dcs_write_1( r = dsicm_dcs_write_1(
ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level); ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
src->ops->dsi.bus_unlock(src);
} }
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
...@@ -343,21 +338,16 @@ static ssize_t dsicm_num_errors_show(struct device *dev, ...@@ -343,21 +338,16 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(dev); struct panel_drv_data *ddata = dev_get_drvdata(dev);
struct omap_dss_device *src = ddata->src;
u8 errors = 0; u8 errors = 0;
int r; int r;
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
if (ddata->enabled) { if (ddata->enabled) {
src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (!r) if (!r)
r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
&errors); &errors);
src->ops->dsi.bus_unlock(src);
} else { } else {
r = -ENODEV; r = -ENODEV;
} }
...@@ -374,20 +364,15 @@ static ssize_t dsicm_hw_revision_show(struct device *dev, ...@@ -374,20 +364,15 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(dev); struct panel_drv_data *ddata = dev_get_drvdata(dev);
struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3; u8 id1, id2, id3;
int r; int r;
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
if (ddata->enabled) { if (ddata->enabled) {
src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (!r) if (!r)
r = dsicm_get_id(ddata, &id1, &id2, &id3); r = dsicm_get_id(ddata, &id1, &id2, &id3);
src->ops->dsi.bus_unlock(src);
} else { } else {
r = -ENODEV; r = -ENODEV;
} }
...@@ -405,7 +390,6 @@ static ssize_t dsicm_store_ulps(struct device *dev, ...@@ -405,7 +390,6 @@ static ssize_t dsicm_store_ulps(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(dev); struct panel_drv_data *ddata = dev_get_drvdata(dev);
struct omap_dss_device *src = ddata->src;
unsigned long t; unsigned long t;
int r; int r;
...@@ -416,14 +400,10 @@ static ssize_t dsicm_store_ulps(struct device *dev, ...@@ -416,14 +400,10 @@ static ssize_t dsicm_store_ulps(struct device *dev,
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
if (ddata->enabled) { if (ddata->enabled) {
src->ops->dsi.bus_lock(src);
if (t) if (t)
r = dsicm_enter_ulps(ddata); r = dsicm_enter_ulps(ddata);
else else
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
src->ops->dsi.bus_unlock(src);
} }
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
...@@ -453,7 +433,6 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev, ...@@ -453,7 +433,6 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(dev); struct panel_drv_data *ddata = dev_get_drvdata(dev);
struct omap_dss_device *src = ddata->src;
unsigned long t; unsigned long t;
int r; int r;
...@@ -466,9 +445,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev, ...@@ -466,9 +445,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
if (ddata->enabled) { if (ddata->enabled) {
/* dsicm_wake_up will restart the timer */ /* dsicm_wake_up will restart the timer */
src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
src->ops->dsi.bus_unlock(src);
} }
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
...@@ -669,17 +646,11 @@ static void dsicm_disconnect(struct omap_dss_device *src, ...@@ -669,17 +646,11 @@ static void dsicm_disconnect(struct omap_dss_device *src,
static void dsicm_enable(struct omap_dss_device *dssdev) static void dsicm_enable(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;
int r; int r;
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
src->ops->dsi.bus_lock(src);
r = dsicm_power_on(ddata); r = dsicm_power_on(ddata);
src->ops->dsi.bus_unlock(src);
if (r) if (r)
goto err; goto err;
...@@ -696,7 +667,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev) ...@@ -696,7 +667,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
static void dsicm_disable(struct omap_dss_device *dssdev) static void dsicm_disable(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;
int r; int r;
dsicm_bl_power(ddata, false); dsicm_bl_power(ddata, false);
...@@ -705,24 +675,18 @@ static void dsicm_disable(struct omap_dss_device *dssdev) ...@@ -705,24 +675,18 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
dsicm_cancel_ulps_work(ddata); dsicm_cancel_ulps_work(ddata);
src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (!r) if (!r)
dsicm_power_off(ddata); dsicm_power_off(ddata);
src->ops->dsi.bus_unlock(src);
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
} }
static void dsicm_framedone_cb(int err, void *data) 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;
dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err); dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
src->ops->dsi.bus_unlock(src);
} }
static int dsicm_update(struct omap_dss_device *dssdev, static int dsicm_update(struct omap_dss_device *dssdev,
...@@ -735,7 +699,6 @@ static int dsicm_update(struct omap_dss_device *dssdev, ...@@ -735,7 +699,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
dev_dbg(&ddata->dsi->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);
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (r) if (r)
...@@ -757,11 +720,10 @@ static int dsicm_update(struct omap_dss_device *dssdev, ...@@ -757,11 +720,10 @@ static int dsicm_update(struct omap_dss_device *dssdev,
if (r) if (r)
goto err; goto err;
/* note: no bus_unlock here. unlock is src framedone_cb */
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
return 0; return 0;
err: err:
src->ops->dsi.bus_unlock(src);
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
return r; return r;
} }
...@@ -787,7 +749,6 @@ static void dsicm_ulps_work(struct work_struct *work) ...@@ -787,7 +749,6 @@ static void dsicm_ulps_work(struct work_struct *work)
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
ulps_work.work); ulps_work.work);
struct omap_dss_device *dssdev = &ddata->dssdev; struct omap_dss_device *dssdev = &ddata->dssdev;
struct omap_dss_device *src = ddata->src;
mutex_lock(&ddata->lock); mutex_lock(&ddata->lock);
...@@ -796,11 +757,8 @@ static void dsicm_ulps_work(struct work_struct *work) ...@@ -796,11 +757,8 @@ static void dsicm_ulps_work(struct work_struct *work)
return; return;
} }
src->ops->dsi.bus_lock(src);
dsicm_enter_ulps(ddata); dsicm_enter_ulps(ddata);
src->ops->dsi.bus_unlock(src);
mutex_unlock(&ddata->lock); mutex_unlock(&ddata->lock);
} }
......
...@@ -477,17 +477,13 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx) ...@@ -477,17 +477,13 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
return __raw_readl(base + idx.idx); return __raw_readl(base + idx.idx);
} }
static void dsi_bus_lock(struct omap_dss_device *dssdev) static void dsi_bus_lock(struct dsi_data *dsi)
{ {
struct dsi_data *dsi = to_dsi_data(dssdev);
down(&dsi->bus_lock); down(&dsi->bus_lock);
} }
static void dsi_bus_unlock(struct omap_dss_device *dssdev) static void dsi_bus_unlock(struct dsi_data *dsi)
{ {
struct dsi_data *dsi = to_dsi_data(dssdev);
up(&dsi->bus_lock); up(&dsi->bus_lock);
} }
...@@ -3800,6 +3796,8 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error) ...@@ -3800,6 +3796,8 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */ REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
} }
dsi_bus_unlock(dsi);
dsi->framedone_callback(error, dsi->framedone_data); dsi->framedone_callback(error, dsi->framedone_data);
if (!error) if (!error)
...@@ -3854,6 +3852,8 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel, ...@@ -3854,6 +3852,8 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
{ {
struct dsi_data *dsi = to_dsi_data(dssdev); struct dsi_data *dsi = to_dsi_data(dssdev);
dsi_bus_lock(dsi);
dsi->update_channel = channel; dsi->update_channel = channel;
dsi->framedone_callback = callback; dsi->framedone_callback = callback;
dsi->framedone_data = data; dsi->framedone_data = data;
...@@ -4059,7 +4059,7 @@ static void dsi_display_enable(struct omap_dss_device *dssdev) ...@@ -4059,7 +4059,7 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
DSSDBG("dsi_display_enable\n"); DSSDBG("dsi_display_enable\n");
WARN_ON(!dsi_bus_is_locked(dsi)); dsi_bus_lock(dsi);
mutex_lock(&dsi->lock); mutex_lock(&dsi->lock);
...@@ -4075,6 +4075,8 @@ static void dsi_display_enable(struct omap_dss_device *dssdev) ...@@ -4075,6 +4075,8 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
mutex_unlock(&dsi->lock); mutex_unlock(&dsi->lock);
dsi_bus_unlock(dsi);
return; return;
err_init_dsi: err_init_dsi:
...@@ -4091,7 +4093,7 @@ static void dsi_display_disable(struct omap_dss_device *dssdev, ...@@ -4091,7 +4093,7 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
DSSDBG("dsi_display_disable\n"); DSSDBG("dsi_display_disable\n");
WARN_ON(!dsi_bus_is_locked(dsi)); dsi_bus_lock(dsi);
mutex_lock(&dsi->lock); mutex_lock(&dsi->lock);
...@@ -4105,6 +4107,8 @@ static void dsi_display_disable(struct omap_dss_device *dssdev, ...@@ -4105,6 +4107,8 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
dsi_runtime_put(dsi); dsi_runtime_put(dsi);
mutex_unlock(&dsi->lock); mutex_unlock(&dsi->lock);
dsi_bus_unlock(dsi);
} }
static int dsi_enable_te(struct dsi_data *dsi, bool enable) static int dsi_enable_te(struct dsi_data *dsi, bool enable)
...@@ -4713,10 +4717,9 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi) ...@@ -4713,10 +4717,9 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
} }
} }
static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host, static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
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; struct omap_dss_device *dssdev = &dsi->output;
int r; int r;
...@@ -4765,6 +4768,19 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host, ...@@ -4765,6 +4768,19 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
return 0; return 0;
} }
static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
const struct mipi_dsi_msg *msg)
{
struct dsi_data *dsi = host_to_omap(host);
int r;
dsi_bus_lock(dsi);
r = _omap_dsi_host_transfer(dsi, msg);
dsi_bus_unlock(dsi);
return r;
}
static int dsi_get_clocks(struct dsi_data *dsi) static int dsi_get_clocks(struct dsi_data *dsi)
{ {
struct clk *clk; struct clk *clk;
...@@ -4798,9 +4814,6 @@ static const struct omap_dss_device_ops dsi_ops = { ...@@ -4798,9 +4814,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.enable = dsi_display_enable, .enable = dsi_display_enable,
.dsi = { .dsi = {
.bus_lock = dsi_bus_lock,
.bus_unlock = dsi_bus_unlock,
.disable = dsi_display_disable, .disable = dsi_display_disable,
.set_config = dsi_set_config, .set_config = dsi_set_config,
......
...@@ -294,9 +294,6 @@ struct omapdss_dsi_ops { ...@@ -294,9 +294,6 @@ struct omapdss_dsi_ops {
int (*update)(struct omap_dss_device *dssdev, int channel, int (*update)(struct omap_dss_device *dssdev, int channel,
void (*callback)(int, void *), void *data); void (*callback)(int, void *), void *data);
void (*bus_lock)(struct omap_dss_device *dssdev);
void (*bus_unlock)(struct omap_dss_device *dssdev);
int (*enable_video_output)(struct omap_dss_device *dssdev, int channel); int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
void (*disable_video_output)(struct omap_dss_device *dssdev, void (*disable_video_output)(struct omap_dss_device *dssdev,
int channel); int channel);
......
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