All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
@ 2017-10-13 14:58 Laurent Pinchart
  2017-10-13 14:58 ` [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error Laurent Pinchart
                   ` (51 more replies)
  0 siblings, 52 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:58 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

Hello,

This patch series merges the omapdrm and omapdss drivers into a single driver
called omapdrm. The split in two drivers was historical, in order to support
the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
there's no need to keep two seperate drivers.

The series starts with a few cleanups (01/48 to 03/48) and quickly proceeds to
merging the omapdss and omapdss-base modules (04/48). It then prepares the
omapdss code (05/48 to 08/48), perform a few more cleanups (09/48 to 11/48)
and prepares the omapdrm code (12/48).

Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers. All
those drivers defer probing when their video source can't be found at probe
time. This would cause endless probe deferral when merging omapdrm and omapdss
as the drivers need omapdss to be fully initialized to probe successfully, but
cause omapdrm to defer probing when they're not available.

Patch 20/48 merges the omapdrm and omapdss drivers.

The next patches are added bonuses that start removal of global variables from
the driver. The code relies heavily on global variables for objects that are
instance-specific, and should thus be dynamically allocated. Most of the
patches change internal APIs to pass objects to driver functions (21/48 to
28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a few miscellaneous
cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches 30/48 to 34/48 and 46/48
then allocate instance objects dynamically to replace global variables, and
patches 47/48 and 48/48 move global variables to existing instance objects.

The series has been tested on a Pandaboard with the DVI and HDMI output.

Laurent Pinchart (48):
  drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error
  drm: omapdrm: Pass drm_device to omap_gem_resume()
  drm: omapdrm: Remove unused omap_dss_find_device() function
  drm: omapdrm: Merge the omapdss and omapdss-base modules
  drm: omapdrm: dss: Set the DMA coherent mask
  drm: omapdrm: dss: Make dss_dump_clocks() function static
  drm: omapdrm: dpi: Remove dpi_data port_initialized field
  drm: omapdrm: venc: Return error code on OF parsing failure
  drm: omapdrm: Deconstruct the omap_drv.h header.
  drm: omapdrm: Use kernel integer types
  drm: omapdrm: Use unsigned int type
  drm: omapdrm: Split init and cleanup from probe and remove functions
  drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward
    declaration
  drm: omapdrm: displays: Remove OF node check in connector drivers
  drm: omapdrm: displays: Remove OF node check in encoder drivers
  drm: omapdrm: displays: Remove OF node check in panel drivers
  drm: omapdrm: displays: Get connector source at connect time
  drm: omapdrm: displays: Get panel source at connect time
  drm: omapdrm: displays: Get encoder source at connect time
  drm: omapdrm: Merge the omapdrm and omapdss drivers
  drm: omapdrm: dss: Support passing private data to debugfs show
    handlers
  drm: omapdrm: dss: Pass DSS private structure to runtime PM functions
  drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable()
  drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions
  drm: omapdrm: dss: Pass DSS pointer to dss_ops operations
  drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source()
  drm: omapdrm: dss: Pass DSS pointer to dss clock functions
  drm: omapdrm: dss: Pass DSS pointer to remaining dss functions
  drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function
  drm: omapdrm: dss: Allocate the DSS private data structure dynamically
  drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically
  drm: omapdrm: venc: Allocate the venc private data structure
    dynamically
  drm: omapdrm: sdi: Allocate the sdi private data structure dynamically
  drm: omapdrm: dsi: Make wait_for_bit_change() return a status
  drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions
  drm: omapdrm: dsi: Combine two commonly used inline functions
  drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function
  drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data
  drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions
  drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*()
    functions
  drm: omapdrm: dss: Remove unused functions prototypes
  drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops
  drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations
  drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API
    functions
  drm: omapdrm: dispc: Allocate the dispc private data structure
    dynamically
  drm: omapdrm: dss: Store the debugfs root directory in struct
    dss_device
  drm: omapdrm: dss: Store the registered plls array in struct
    dss_device

 drivers/gpu/drm/omapdrm/Kconfig                    |    5 +-
 drivers/gpu/drm/omapdrm/Makefile                   |   25 +
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c |   50 +-
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   |   34 +-
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |   40 +-
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |   40 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |   42 +-
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |   69 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c       |   38 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    |   38 +-
 .../omapdrm/displays/panel-lgphilips-lb035q02.c    |   38 +-
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c    |   42 +-
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |   38 +-
 .../drm/omapdrm/displays/panel-sony-acx565akm.c    |   35 +-
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c    |   49 +-
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c    |   32 +-
 drivers/gpu/drm/omapdrm/dss/Kconfig                |   16 -
 drivers/gpu/drm/omapdrm/dss/Makefile               |   18 -
 drivers/gpu/drm/omapdrm/dss/base.c                 |   20 -
 drivers/gpu/drm/omapdrm/dss/core.c                 |   14 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c                | 2191 +++++++++++---------
 drivers/gpu/drm/omapdrm/dss/display.c              |   16 -
 drivers/gpu/drm/omapdrm/dss/dpi.c                  |   98 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c                  | 1554 +++++++-------
 drivers/gpu/drm/omapdrm/dss/dss-of.c               |    2 -
 drivers/gpu/drm/omapdrm/dss/dss.c                  |  722 ++++---
 drivers/gpu/drm/omapdrm/dss/dss.h                  |  248 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi.h                 |   11 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c                |  375 ++--
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c            |    4 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4_core.h           |    4 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c                |  383 ++--
 drivers/gpu/drm/omapdrm/dss/hdmi5_core.c           |   24 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_phy.c             |    2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c             |   15 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_wp.c              |    2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h              |  166 +-
 drivers/gpu/drm/omapdrm/dss/output.c               |   61 +-
 drivers/gpu/drm/omapdrm/dss/pll.c                  |   44 +-
 drivers/gpu/drm/omapdrm/dss/sdi.c                  |  163 +-
 drivers/gpu/drm/omapdrm/dss/venc.c                 |  457 ++--
 drivers/gpu/drm/omapdrm/dss/video-pll.c            |   19 +-
 drivers/gpu/drm/omapdrm/omap_connector.h           |   37 +
 drivers/gpu/drm/omapdrm/omap_crtc.c                |   70 +-
 drivers/gpu/drm/omapdrm/omap_crtc.h                |   43 +
 drivers/gpu/drm/omapdrm/omap_dmm_priv.h            |   10 +-
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c           |   58 +-
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h           |   25 +-
 drivers/gpu/drm/omapdrm/omap_drv.c                 |  101 +-
 drivers/gpu/drm/omapdrm/omap_drv.h                 |  146 +-
 drivers/gpu/drm/omapdrm/omap_encoder.h             |   33 +
 drivers/gpu/drm/omapdrm/omap_fb.c                  |   18 +-
 drivers/gpu/drm/omapdrm/omap_fb.h                  |   46 +
 drivers/gpu/drm/omapdrm/omap_fbdev.h               |   39 +
 drivers/gpu/drm/omapdrm/omap_gem.c                 |   48 +-
 drivers/gpu/drm/omapdrm/omap_gem.h                 |   99 +
 drivers/gpu/drm/omapdrm/omap_irq.c                 |   38 +-
 drivers/gpu/drm/omapdrm/omap_irq.h                 |   39 +
 drivers/gpu/drm/omapdrm/omap_plane.c               |   16 +-
 drivers/gpu/drm/omapdrm/omap_plane.h               |   37 +
 drivers/gpu/drm/omapdrm/tcm-sita.c                 |   12 +-
 drivers/gpu/drm/omapdrm/tcm.h                      |    4 +-
 62 files changed, 4293 insertions(+), 3870 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_crtc.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_encoder.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fb.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fbdev.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_gem.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_irq.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_plane.h

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
@ 2017-10-13 14:58 ` Laurent Pinchart
  2017-10-14 12:11   ` Sebastian Reichel
  2017-10-13 14:58 ` [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume() Laurent Pinchart
                   ` (50 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:58 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

There's no need to print an error message on probe deferral, that's a
normal situation. Probe deferral debugging can be performed by enabling
the related debug messages in the drivers core.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 947295f9e30f..b8e420c7d680 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -173,7 +173,8 @@ static int tfp410_probe_of(struct platform_device *pdev)
 	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
 		ddata->pd_gpio = gpio;
 	} else {
-		dev_err(&pdev->dev, "failed to parse PD gpio\n");
+		if (gpio != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "failed to parse PD gpio\n");
 		return gpio;
 	}
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume()
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
  2017-10-13 14:58 ` [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error Laurent Pinchart
@ 2017-10-13 14:58 ` Laurent Pinchart
  2017-10-14 12:15   ` Sebastian Reichel
  2017-10-13 14:58 ` [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function Laurent Pinchart
                   ` (49 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:58 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_gem_resume() function is internal to the driver. Pass it a
drm_device pointer that the caller already has instead of looking it up
from device data.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
 drivers/gpu/drm/omapdrm/omap_drv.h | 2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c | 7 +++----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index cdf5b0601eba..2d15ea1d6c92 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -740,7 +740,7 @@ static int omap_drm_resume(struct device *dev)
 
 	drm_kms_helper_poll_enable(drm_dev);
 
-	return omap_gem_resume(dev);
+	return omap_gem_resume(drm_dev);
 }
 #endif
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 4bd1e9070b31..04f35f74f80c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -94,7 +94,7 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
 #endif
 
 #ifdef CONFIG_PM
-int omap_gem_resume(struct device *dev);
+int omap_gem_resume(struct drm_device *dev);
 #endif
 
 int omap_irq_enable_vblank(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 5c5c86ddd6f4..fd81396baaf9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -996,10 +996,9 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
 
 #ifdef CONFIG_PM
 /* re-pin objects in DMM in resume path: */
-int omap_gem_resume(struct device *dev)
+int omap_gem_resume(struct drm_device *dev)
 {
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
-	struct omap_drm_private *priv = drm_dev->dev_private;
+	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_gem_object *omap_obj;
 	int ret = 0;
 
@@ -1012,7 +1011,7 @@ int omap_gem_resume(struct device *dev)
 					omap_obj->pages, npages,
 					omap_obj->roll, true);
 			if (ret) {
-				dev_err(dev, "could not repin: %d\n", ret);
+				dev_err(dev->dev, "could not repin: %d\n", ret);
 				return ret;
 			}
 		}
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
  2017-10-13 14:58 ` [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error Laurent Pinchart
  2017-10-13 14:58 ` [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume() Laurent Pinchart
@ 2017-10-13 14:58 ` Laurent Pinchart
  2017-10-14 12:16   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules Laurent Pinchart
                   ` (48 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:58 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_dss_find_device() function is unused. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/display.c | 14 --------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ---
 2 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 42279933790e..8c77a2d20969 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -175,17 +175,3 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
 	return dssdev;
 }
 EXPORT_SYMBOL(omap_dss_get_next_device);
-
-struct omap_dss_device *omap_dss_find_device(void *data,
-		int (*match)(struct omap_dss_device *dssdev, void *data))
-{
-	struct omap_dss_device *dssdev = NULL;
-
-	while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) {
-		if (match(dssdev, data))
-			return dssdev;
-	}
-
-	return NULL;
-}
-EXPORT_SYMBOL(omap_dss_find_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 990422b35784..6f7dc8384055 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -595,9 +595,6 @@ struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
-struct omap_dss_device *omap_dss_find_device(void *data,
-		int (*match)(struct omap_dss_device *dssdev, void *data));
-
 
 int omap_dss_get_num_overlay_managers(void);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (2 preceding siblings ...)
  2017-10-13 14:58 ` [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:22   ` Sebastian Reichel
  2017-10-18  9:19   ` Tomi Valkeinen
  2017-10-13 14:59 ` [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask Laurent Pinchart
                   ` (47 subsequent siblings)
  51 siblings, 2 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

There's no need for the omapdss-base code to be part of a separate
module. Merge it with the omapdss module. This allows removing the
exports for internal symbols.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/Kconfig   |  4 ----
 drivers/gpu/drm/omapdrm/dss/Makefile  | 19 +++++++++++++------
 drivers/gpu/drm/omapdrm/dss/base.c    |  7 -------
 drivers/gpu/drm/omapdrm/dss/display.c |  2 --
 drivers/gpu/drm/omapdrm/dss/dss-of.c  |  2 --
 drivers/gpu/drm/omapdrm/dss/output.c  | 14 --------------
 6 files changed, 13 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
index f24ebf7f61dd..39a30a64448a 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,12 +1,8 @@
 config OMAP2_DSS_INIT
 	bool
 
-config OMAP_DSS_BASE
-	tristate
-
 menuconfig OMAP2_DSS
         tristate "OMAP2+ Display Subsystem support"
-	select OMAP_DSS_BASE
 	select VIDEOMODE_HELPERS
 	select OMAP2_DSS_INIT
 	select HDMI
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
index 3c5644c3fc38..531b4d8075e5 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,12 +1,19 @@
 obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-
-obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
-omapdss-base-y := base.o display.o dss-of.o output.o
-
 obj-$(CONFIG_OMAP2_DSS) += omapdss.o
+
 # Core DSS files
-omapdss-y := core.o dss.o dispc.o dispc_coefs.o \
-	pll.o video-pll.o
+omapdss-y := \
+	base.o \
+	display.o \
+	dss-of.o \
+	output.o \
+	core.o \
+	dss.o \
+	dispc.o \
+	dispc_coefs.o \
+	pll.o \
+	video-pll.o
+
 omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
 omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
 omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 13e91faaf7a6..eff427dd3297 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -20,7 +20,6 @@ void omapdss_set_is_initialized(bool set)
 {
 	dss_initialized = set;
 }
-EXPORT_SYMBOL(omapdss_set_is_initialized);
 
 bool omapdss_is_initialized(void)
 {
@@ -32,7 +31,6 @@ void dispc_set_ops(const struct dispc_ops *o)
 {
 	ops = o;
 }
-EXPORT_SYMBOL(dispc_set_ops);
 
 const struct dispc_ops *dispc_get_ops(void)
 {
@@ -108,7 +106,6 @@ void omapdss_gather_components(struct device *dev)
 		omapdss_walk_device(dev, child, true);
 	}
 }
-EXPORT_SYMBOL(omapdss_gather_components);
 
 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
 {
@@ -134,7 +131,3 @@ bool omapdss_stack_is_ready(void)
 	return true;
 }
 EXPORT_SYMBOL(omapdss_stack_is_ready);
-
-MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
-MODULE_DESCRIPTION("OMAP Display Subsystem Base");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 8c77a2d20969..a86471f73094 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -35,7 +35,6 @@ void omapdss_default_get_timings(struct omap_dss_device *dssdev,
 {
 	*vm = dssdev->panel.vm;
 }
-EXPORT_SYMBOL(omapdss_default_get_timings);
 
 static LIST_HEAD(panel_list);
 static DEFINE_MUTEX(panel_list_mutex);
@@ -104,7 +103,6 @@ bool omapdss_component_is_display(struct device_node *node)
 	mutex_unlock(&panel_list_mutex);
 	return found;
 }
-EXPORT_SYMBOL(omapdss_component_is_display);
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index c6b86f348a5c..d3a19a5dfd35 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -44,7 +44,6 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port)
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(dss_of_port_get_parent_device);
 
 u32 dss_of_port_get_port_number(struct device_node *port)
 {
@@ -57,7 +56,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
 
 	return reg;
 }
-EXPORT_SYMBOL_GPL(dss_of_port_get_port_number);
 
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 3c572b699ed3..a84ab0337a91 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -58,7 +58,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
 
 	return r;
 }
-EXPORT_SYMBOL(omapdss_output_set_device);
 
 int omapdss_output_unset_device(struct omap_dss_device *out)
 {
@@ -92,7 +91,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
 
 	return r;
 }
-EXPORT_SYMBOL(omapdss_output_unset_device);
 
 int omapdss_register_output(struct omap_dss_device *out)
 {
@@ -118,7 +116,6 @@ bool omapdss_component_is_output(struct device_node *node)
 
 	return false;
 }
-EXPORT_SYMBOL(omapdss_component_is_output);
 
 struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
 {
@@ -131,7 +128,6 @@ struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
 
 	return NULL;
 }
-EXPORT_SYMBOL(omap_dss_get_output);
 
 struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port)
 {
@@ -156,7 +152,6 @@ struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *po
 
 	return NULL;
 }
-EXPORT_SYMBOL(omap_dss_find_output_by_port_node);
 
 struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev)
 {
@@ -194,56 +189,47 @@ int dss_mgr_connect(enum omap_channel channel,
 {
 	return dss_mgr_ops->connect(channel, dst);
 }
-EXPORT_SYMBOL(dss_mgr_connect);
 
 void dss_mgr_disconnect(enum omap_channel channel,
 		struct omap_dss_device *dst)
 {
 	dss_mgr_ops->disconnect(channel, dst);
 }
-EXPORT_SYMBOL(dss_mgr_disconnect);
 
 void dss_mgr_set_timings(enum omap_channel channel, const struct videomode *vm)
 {
 	dss_mgr_ops->set_timings(channel, vm);
 }
-EXPORT_SYMBOL(dss_mgr_set_timings);
 
 void dss_mgr_set_lcd_config(enum omap_channel channel,
 		const struct dss_lcd_mgr_config *config)
 {
 	dss_mgr_ops->set_lcd_config(channel, config);
 }
-EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
 int dss_mgr_enable(enum omap_channel channel)
 {
 	return dss_mgr_ops->enable(channel);
 }
-EXPORT_SYMBOL(dss_mgr_enable);
 
 void dss_mgr_disable(enum omap_channel channel)
 {
 	dss_mgr_ops->disable(channel);
 }
-EXPORT_SYMBOL(dss_mgr_disable);
 
 void dss_mgr_start_update(enum omap_channel channel)
 {
 	dss_mgr_ops->start_update(channel);
 }
-EXPORT_SYMBOL(dss_mgr_start_update);
 
 int dss_mgr_register_framedone_handler(enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
 	return dss_mgr_ops->register_framedone_handler(channel, handler, data);
 }
-EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
 
 void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
 	dss_mgr_ops->unregister_framedone_handler(channel, handler, data);
 }
-EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (3 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:24   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static Laurent Pinchart
                   ` (46 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

When merging the omapdrm and omapdss drivers the omapdrm virtual
platform device will disappear, and the omapdss platform device will be
used for DMA memory allocation. To prepare for that, set the DMA
coherent mask for the device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index d1755f12236b..6ce26a4b93b3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -23,6 +23,7 @@
 #define DSS_SUBSYS_NAME "DSS"
 
 #include <linux/debugfs.h>
+#include <linux/dma-mapping.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -1441,6 +1442,12 @@ static int dss_probe(struct platform_device *pdev)
 
 	dss.pdev = pdev;
 
+	r = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+	if (r) {
+		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
+		return r;
+	}
+
 	/*
 	 * The various OMAP3-based SoCs can't be told apart using the compatible
 	 * string, use SoC device matching.
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (4 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:24   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field Laurent Pinchart
                   ` (45 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The function isn't used outside of its compilation unit, make it static.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 4 +++-
 drivers/gpu/drm/omapdrm/dss/dss.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6ce26a4b93b3..0d447eddf4d6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -368,7 +368,8 @@ const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
 	return dss_generic_clk_source_names[clk_src];
 }
 
-void dss_dump_clocks(struct seq_file *s)
+#if defined(CONFIG_OMAP2_DSS_DEBUGFS)
+static void dss_dump_clocks(struct seq_file *s)
 {
 	const char *fclk_name;
 	unsigned long fclk_rate;
@@ -387,6 +388,7 @@ void dss_dump_clocks(struct seq_file *s)
 
 	dss_runtime_put();
 }
+#endif
 
 static void dss_dump_regs(struct seq_file *s)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index ed465572491e..0d7f2b08b7ff 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -277,7 +277,6 @@ int dss_dpi_select_source(int port, enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
-void dss_dump_clocks(struct seq_file *s);
 
 /* DSS VIDEO PLL */
 struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (5 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:28   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure Laurent Pinchart
                   ` (44 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dpi_data structure port_initialized field is used to check in the
cleanup path whether the DPI has been initialized. This can be performed
through the associated device_node data field instead. Remove the
port_initialized field.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index daf286fc8a40..ce9b27978f48 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -52,8 +52,6 @@ struct dpi_data {
 	int data_lines;
 
 	struct omap_dss_device output;
-
-	bool port_initialized;
 };
 
 static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
@@ -786,8 +784,6 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port,
 
 	dpi_init_output_port(dpi, port);
 
-	dpi->port_initialized = true;
-
 	return 0;
 
 err_datalines:
@@ -800,7 +796,7 @@ void dpi_uninit_port(struct device_node *port)
 {
 	struct dpi_data *dpi = port->data;
 
-	if (!dpi->port_initialized)
+	if (!dpi)
 		return;
 
 	dpi_uninit_output_port(port);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (6 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:29   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header Laurent Pinchart
                   ` (43 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The venc_probe_of() function has an error cleanup path that returns
success instead of an error code. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/venc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index d58da6f32693..1b0fa952b494 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -857,10 +857,10 @@ static int venc_probe_of(struct platform_device *pdev)
 	of_node_put(ep);
 
 	return 0;
+
 err:
 	of_node_put(ep);
-
-	return 0;
+	return r;
 }
 
 /* VENC HW IP initialisation */
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header.
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (7 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 22:25   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 10/48] drm: omapdrm: Use kernel integer types Laurent Pinchart
                   ` (42 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The number of function declarations in the omap_drv.h degrades
readability. To fix it, create new header files for each part of the
driver and move the related functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_connector.h |  37 +++++++++
 drivers/gpu/drm/omapdrm/omap_crtc.h      |  43 ++++++++++
 drivers/gpu/drm/omapdrm/omap_drv.h       | 133 +++----------------------------
 drivers/gpu/drm/omapdrm/omap_encoder.h   |  33 ++++++++
 drivers/gpu/drm/omapdrm/omap_fb.h        |  46 +++++++++++
 drivers/gpu/drm/omapdrm/omap_fbdev.h     |  39 +++++++++
 drivers/gpu/drm/omapdrm/omap_gem.h       |  99 +++++++++++++++++++++++
 drivers/gpu/drm/omapdrm/omap_irq.h       |  39 +++++++++
 drivers/gpu/drm/omapdrm/omap_plane.h     |  37 +++++++++
 9 files changed, 386 insertions(+), 120 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_crtc.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_encoder.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fb.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fbdev.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_gem.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_irq.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_plane.h

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.h b/drivers/gpu/drm/omapdrm/omap_connector.h
new file mode 100644
index 000000000000..98bbc779b302
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_connector.h
@@ -0,0 +1,37 @@
+/*
+ * omap_connector.h -- OMAP DRM Connector
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_CONNECTOR_H__
+#define __OMAPDRM_CONNECTOR_H__
+
+#include <linux/types.h>
+
+struct drm_connector;
+struct drm_device;
+struct drm_encoder;
+struct omap_dss_device;
+
+struct drm_connector *omap_connector_init(struct drm_device *dev,
+		int connector_type, struct omap_dss_device *dssdev,
+		struct drm_encoder *encoder);
+struct drm_encoder *omap_connector_attached_encoder(
+		struct drm_connector *connector);
+bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
+
+#endif /* __OMAPDRM_CONNECTOR_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
new file mode 100644
index 000000000000..ad7b007c6174
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -0,0 +1,43 @@
+/*
+ * omap_crtc.h -- OMAP DRM CRTC
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_CRTC_H__
+#define __OMAPDRM_CRTC_H__
+
+#include <linux/types.h>
+
+enum omap_channel;
+
+struct drm_crtc;
+struct drm_device;
+struct drm_plane;
+struct omap_dss_device;
+struct videomode;
+
+struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
+enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
+void omap_crtc_pre_init(void);
+void omap_crtc_pre_uninit(void);
+struct drm_crtc *omap_crtc_init(struct drm_device *dev,
+		struct drm_plane *plane, struct omap_dss_device *dssdev);
+int omap_crtc_wait_pending(struct drm_crtc *crtc);
+void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_vblank_irq(struct drm_crtc *crtc);
+
+#endif /* __OMAPDRM_CRTC_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 04f35f74f80c..afb2a5a96278 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -17,8 +17,8 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __OMAP_DRV_H__
-#define __OMAP_DRV_H__
+#ifndef __OMAPDRM_DRV_H__
+#define __OMAPDRM_DRV_H__
 
 #include <linux/module.h>
 #include <linux/types.h>
@@ -31,6 +31,15 @@
 
 #include "dss/omapdss.h"
 
+#include "omap_connector.h"
+#include "omap_crtc.h"
+#include "omap_encoder.h"
+#include "omap_fb.h"
+#include "omap_fbdev.h"
+#include "omap_gem.h"
+#include "omap_irq.h"
+#include "omap_plane.h"
+
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
 
@@ -38,14 +47,6 @@
 
 struct omap_drm_usergart;
 
-/* For KMS code that needs to wait for a certain # of IRQs:
- */
-struct omap_irq_wait;
-struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev,
-		uint32_t irqmask, int count);
-int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
-		unsigned long timeout);
-
 struct omap_drm_private {
 	uint32_t omaprev;
 
@@ -86,114 +87,6 @@ struct omap_drm_private {
 };
 
 
-#ifdef CONFIG_DEBUG_FS
 int omap_debugfs_init(struct drm_minor *minor);
-void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
-void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
-void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
-#endif
-
-#ifdef CONFIG_PM
-int omap_gem_resume(struct drm_device *dev);
-#endif
-
-int omap_irq_enable_vblank(struct drm_crtc *crtc);
-void omap_irq_disable_vblank(struct drm_crtc *crtc);
-void omap_drm_irq_uninstall(struct drm_device *dev);
-int omap_drm_irq_install(struct drm_device *dev);
-
-#ifdef CONFIG_DRM_FBDEV_EMULATION
-struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
-void omap_fbdev_free(struct drm_device *dev);
-#else
-static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
-{
-	return NULL;
-}
-static inline void omap_fbdev_free(struct drm_device *dev)
-{
-}
-#endif
-
-struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
-enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
-void omap_crtc_pre_init(void);
-void omap_crtc_pre_uninit(void);
-struct drm_crtc *omap_crtc_init(struct drm_device *dev,
-		struct drm_plane *plane, struct omap_dss_device *dssdev);
-int omap_crtc_wait_pending(struct drm_crtc *crtc);
-void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
-void omap_crtc_vblank_irq(struct drm_crtc *crtc);
-
-struct drm_plane *omap_plane_init(struct drm_device *dev,
-		int idx, enum drm_plane_type type,
-		u32 possible_crtcs);
-void omap_plane_install_properties(struct drm_plane *plane,
-		struct drm_mode_object *obj);
-
-struct drm_encoder *omap_encoder_init(struct drm_device *dev,
-		struct omap_dss_device *dssdev);
-
-struct drm_connector *omap_connector_init(struct drm_device *dev,
-		int connector_type, struct omap_dss_device *dssdev,
-		struct drm_encoder *encoder);
-struct drm_encoder *omap_connector_attached_encoder(
-		struct drm_connector *connector);
-bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
-
-struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
-		struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
-struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
-		const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
-int omap_framebuffer_pin(struct drm_framebuffer *fb);
-void omap_framebuffer_unpin(struct drm_framebuffer *fb);
-void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
-		struct drm_plane_state *state, struct omap_overlay_info *info);
-struct drm_connector *omap_framebuffer_get_next_connector(
-		struct drm_framebuffer *fb, struct drm_connector *from);
-bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
-
-void omap_gem_init(struct drm_device *dev);
-void omap_gem_deinit(struct drm_device *dev);
-
-struct drm_gem_object *omap_gem_new(struct drm_device *dev,
-		union omap_gem_size gsize, uint32_t flags);
-struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
-		struct sg_table *sgt);
-int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
-		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
-void omap_gem_free_object(struct drm_gem_object *obj);
-void *omap_gem_vaddr(struct drm_gem_object *obj);
-int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-		uint32_t handle, uint64_t *offset);
-int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
-		struct drm_mode_create_dumb *args);
-int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-int omap_gem_mmap_obj(struct drm_gem_object *obj,
-		struct vm_area_struct *vma);
-int omap_gem_fault(struct vm_fault *vmf);
-int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
-void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
-void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
-		enum dma_data_direction dir);
-int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
-void omap_gem_unpin(struct drm_gem_object *obj);
-int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
-		bool remap);
-int omap_gem_put_pages(struct drm_gem_object *obj);
-uint32_t omap_gem_flags(struct drm_gem_object *obj);
-int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
-		int x, int y, dma_addr_t *dma_addr);
-uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
-size_t omap_gem_mmap_size(struct drm_gem_object *obj);
-int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
-
-struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
-		struct drm_gem_object *obj, int flags);
-struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
-		struct dma_buf *buffer);
-
-/* map crtc to vblank mask */
-struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder);
-
-#endif /* __OMAP_DRV_H__ */
+
+#endif /* __OMAPDRM_DRV_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.h b/drivers/gpu/drm/omapdrm/omap_encoder.h
new file mode 100644
index 000000000000..d2f308bec494
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.h
@@ -0,0 +1,33 @@
+/*
+ * omap_encoder.h -- OMAP DRM Encoder
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_ENCODER_H__
+#define __OMAPDRM_ENCODER_H__
+
+struct drm_device;
+struct drm_encoder;
+struct omap_dss_device;
+
+struct drm_encoder *omap_encoder_init(struct drm_device *dev,
+		struct omap_dss_device *dssdev);
+
+/* map crtc to vblank mask */
+struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder);
+
+#endif /* __OMAPDRM_ENCODER_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.h b/drivers/gpu/drm/omapdrm/omap_fb.h
new file mode 100644
index 000000000000..94ad5f9e4404
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_fb.h
@@ -0,0 +1,46 @@
+/*
+ * omap_fb.h -- OMAP DRM Framebuffer
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_FB_H__
+#define __OMAPDRM_FB_H__
+
+struct drm_connector;
+struct drm_device;
+struct drm_file;
+struct drm_framebuffer;
+struct drm_gem_object;
+struct drm_mode_fb_cmd2;
+struct drm_plane_state;
+struct omap_overlay_info;
+struct seq_file;
+
+struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
+		struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
+struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
+		const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
+int omap_framebuffer_pin(struct drm_framebuffer *fb);
+void omap_framebuffer_unpin(struct drm_framebuffer *fb);
+void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
+		struct drm_plane_state *state, struct omap_overlay_info *info);
+struct drm_connector *omap_framebuffer_get_next_connector(
+		struct drm_framebuffer *fb, struct drm_connector *from);
+bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
+void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
+
+#endif /* __OMAPDRM_FB_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.h b/drivers/gpu/drm/omapdrm/omap_fbdev.h
new file mode 100644
index 000000000000..1f5ba0996a1a
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.h
@@ -0,0 +1,39 @@
+/*
+ * omap_fbdev.h -- OMAP DRM FBDEV Compatibility
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_FBDEV_H__
+#define __OMAPDRM_FBDEV_H__
+
+struct drm_device;
+struct drm_fb_helper;
+
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
+void omap_fbdev_free(struct drm_device *dev);
+#else
+static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
+{
+	return NULL;
+}
+static inline void omap_fbdev_free(struct drm_device *dev)
+{
+}
+#endif
+
+#endif /* __OMAPDRM_FBDEV_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
new file mode 100644
index 000000000000..35fa690b3d90
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_gem.h
@@ -0,0 +1,99 @@
+/*
+ * omap_gem.h -- OMAP DRM GEM Object Management
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_GEM_H__
+#define __OMAPDRM_GEM_H__
+
+#include <linux/types.h>
+
+enum dma_data_direction;
+
+struct dma_buf;
+struct drm_device;
+struct drm_file;
+struct drm_gem_object;
+struct drm_mode_create_dumb;
+struct file;
+struct list_head;
+struct page;
+struct seq_file;
+struct vm_area_struct;
+struct vm_fault;
+
+union omap_gem_size;
+
+/* Initialization and Cleanup */
+void omap_gem_init(struct drm_device *dev);
+void omap_gem_deinit(struct drm_device *dev);
+
+#ifdef CONFIG_PM
+int omap_gem_resume(struct drm_device *dev);
+#endif
+
+#ifdef CONFIG_DEBUG_FS
+void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
+void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
+#endif
+
+/* GEM Object Creation and Deletion */
+struct drm_gem_object *omap_gem_new(struct drm_device *dev,
+		union omap_gem_size gsize, uint32_t flags);
+struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
+		struct sg_table *sgt);
+int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
+		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
+void omap_gem_free_object(struct drm_gem_object *obj);
+void *omap_gem_vaddr(struct drm_gem_object *obj);
+
+/* Dumb Buffers Interface */
+int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
+		uint32_t handle, uint64_t *offset);
+int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
+		struct drm_mode_create_dumb *args);
+
+/* mmap() Interface */
+int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
+int omap_gem_mmap_obj(struct drm_gem_object *obj,
+		struct vm_area_struct *vma);
+uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
+size_t omap_gem_mmap_size(struct drm_gem_object *obj);
+
+/* PRIME Interface */
+struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
+		struct drm_gem_object *obj, int flags);
+struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
+		struct dma_buf *buffer);
+
+int omap_gem_fault(struct vm_fault *vmf);
+int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
+void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
+void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
+		enum dma_data_direction dir);
+int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
+void omap_gem_unpin(struct drm_gem_object *obj);
+int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
+		bool remap);
+int omap_gem_put_pages(struct drm_gem_object *obj);
+
+uint32_t omap_gem_flags(struct drm_gem_object *obj);
+int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
+		int x, int y, dma_addr_t *dma_addr);
+int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
+
+#endif /* __OMAPDRM_GEM_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.h b/drivers/gpu/drm/omapdrm/omap_irq.h
new file mode 100644
index 000000000000..606c09932bc0
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_irq.h
@@ -0,0 +1,39 @@
+/*
+ * omap_irq.h -- OMAP DRM IRQ Handling
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_IRQ_H__
+#define __OMAPDRM_IRQ_H__
+
+#include <linux/types.h>
+
+struct drm_crtc;
+struct drm_device;
+struct omap_irq_wait;
+
+int omap_irq_enable_vblank(struct drm_crtc *crtc);
+void omap_irq_disable_vblank(struct drm_crtc *crtc);
+void omap_drm_irq_uninstall(struct drm_device *dev);
+int omap_drm_irq_install(struct drm_device *dev);
+
+struct omap_irq_wait *omap_irq_wait_init(struct drm_device *dev,
+		uint32_t irqmask, int count);
+int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
+		unsigned long timeout);
+
+#endif /* __OMAPDRM_IRQ_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.h b/drivers/gpu/drm/omapdrm/omap_plane.h
new file mode 100644
index 000000000000..dc5e82ad061d
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_plane.h
@@ -0,0 +1,37 @@
+/*
+ * omap_plane.h -- OMAP DRM Plane
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob@ti.com>
+ *
+ * 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/>.
+ */
+
+#ifndef __OMAPDRM_PLANE_H__
+#define __OMAPDRM_PLANE_H__
+
+#include <linux/types.h>
+
+enum drm_plane_type;
+
+struct drm_device;
+struct drm_mode_object;
+struct drm_plane;
+
+struct drm_plane *omap_plane_init(struct drm_device *dev,
+		int idx, enum drm_plane_type type,
+		u32 possible_crtcs);
+void omap_plane_install_properties(struct drm_plane *plane,
+		struct drm_mode_object *obj);
+
+#endif /* __OMAPDRM_PLANE_H__ */
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 10/48] drm: omapdrm: Use kernel integer types
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (8 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:34   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 11/48] drm: omapdrm: Use unsigned int type Laurent Pinchart
                   ` (41 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The standard kernel integer types are [us]{8,16,32}. Use them instead of
the u?int{8,16,32}_t types.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_crtc.c      | 12 ++++-----
 drivers/gpu/drm/omapdrm/omap_crtc.h      |  2 +-
 drivers/gpu/drm/omapdrm/omap_dmm_priv.h  | 10 +++----
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 46 ++++++++++++++++----------------
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h | 22 +++++++--------
 drivers/gpu/drm/omapdrm/omap_drv.h       |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c        | 18 ++++++-------
 drivers/gpu/drm/omapdrm/omap_gem.c       | 41 +++++++++++++++-------------
 drivers/gpu/drm/omapdrm/omap_gem.h       | 16 +++++------
 drivers/gpu/drm/omapdrm/omap_irq.c       |  6 ++---
 drivers/gpu/drm/omapdrm/omap_irq.h       |  2 +-
 drivers/gpu/drm/omapdrm/omap_plane.c     |  4 +--
 drivers/gpu/drm/omapdrm/tcm-sita.c       | 12 ++++-----
 drivers/gpu/drm/omapdrm/tcm.h            |  4 +--
 14 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index cc85c16cbc2a..f78eac4a8b34 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -273,7 +273,7 @@ static const struct dss_mgr_ops mgr_ops = {
  * Setup, Flush and Page Flip
  */
 
-void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus)
+void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus)
 {
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
@@ -458,7 +458,7 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,
 	struct drm_plane_state *pri_state;
 
 	if (state->color_mgmt_changed && state->gamma_lut) {
-		uint length = state->gamma_lut->length /
+		unsigned int length = state->gamma_lut->length /
 			sizeof(struct drm_color_lut);
 
 		if (length < 2)
@@ -492,7 +492,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 
 	if (crtc->state->color_mgmt_changed) {
 		struct drm_color_lut *lut = NULL;
-		uint length = 0;
+		unsigned int length = 0;
 
 		if (crtc->state->gamma_lut) {
 			lut = (struct drm_color_lut *)
@@ -523,7 +523,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
 					 struct drm_crtc_state *state,
 					 struct drm_property *property,
-					 uint64_t val)
+					 u64 val)
 {
 	struct omap_drm_private *priv = crtc->dev->dev_private;
 	struct drm_plane_state *plane_state;
@@ -551,7 +551,7 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
 static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
 					 const struct drm_crtc_state *state,
 					 struct drm_property *property,
-					 uint64_t *val)
+					 u64 *val)
 {
 	struct omap_drm_private *priv = crtc->dev->dev_private;
 	struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
@@ -697,7 +697,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 	 * gamma table is not supprted.
 	 */
 	if (priv->dispc_ops->mgr_gamma_size(channel)) {
-		uint gamma_lut_size = 256;
+		unsigned int gamma_lut_size = 256;
 
 		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
 		drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
index ad7b007c6174..7f01e730a050 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.h
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -37,7 +37,7 @@ void omap_crtc_pre_uninit(void);
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 		struct drm_plane *plane, struct omap_dss_device *dssdev);
 int omap_crtc_wait_pending(struct drm_crtc *crtc);
-void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
 
 #endif /* __OMAPDRM_CRTC_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
index 9f32a83ca507..80fc850212a3 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
@@ -102,10 +102,10 @@ struct pat_ctrl {
 };
 
 struct pat {
-	uint32_t next_pa;
+	u32 next_pa;
 	struct pat_area area;
 	struct pat_ctrl ctrl;
-	uint32_t data_pa;
+	u32 data_pa;
 };
 
 #define DMM_FIXED_RETRY_COUNT 1000
@@ -129,7 +129,7 @@ struct dmm_txn {
 	void *engine_handle;
 	struct tcm *tcm;
 
-	uint8_t *current_va;
+	u8 *current_va;
 	dma_addr_t current_pa;
 
 	struct pat *last_pat;
@@ -140,7 +140,7 @@ struct refill_engine {
 	struct dmm *dmm;
 	struct tcm *tcm;
 
-	uint8_t *refill_va;
+	u8 *refill_va;
 	dma_addr_t refill_pa;
 
 	/* only one trans per engine for now */
@@ -154,7 +154,7 @@ struct refill_engine {
 };
 
 struct dmm_platform_data {
-	uint32_t cpu_cache_flags;
+	u32 cpu_cache_flags;
 };
 
 struct dmm {
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 1dd3dafc59af..b341ebc136fe 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -59,11 +59,11 @@ static DEFINE_SPINLOCK(list_lock);
 	}
 
 static const struct {
-	uint32_t x_shft;	/* unused X-bits (as part of bpp) */
-	uint32_t y_shft;	/* unused Y-bits (as part of bpp) */
-	uint32_t cpp;		/* bytes/chars per pixel */
-	uint32_t slot_w;	/* width of each slot (in pixels) */
-	uint32_t slot_h;	/* height of each slot (in pixels) */
+	u32 x_shft;	/* unused X-bits (as part of bpp) */
+	u32 y_shft;	/* unused Y-bits (as part of bpp) */
+	u32 cpp;		/* bytes/chars per pixel */
+	u32 slot_w;	/* width of each slot (in pixels) */
+	u32 slot_h;	/* height of each slot (in pixels) */
 } geom[TILFMT_NFORMATS] = {
 	[TILFMT_8BIT]  = GEOM(0, 0, 1),
 	[TILFMT_16BIT] = GEOM(0, 1, 2),
@@ -73,7 +73,7 @@ static const struct {
 
 
 /* lookup table for registers w/ per-engine instances */
-static const uint32_t reg[][4] = {
+static const u32 reg[][4] = {
 	[PAT_STATUS] = {DMM_PAT_STATUS__0, DMM_PAT_STATUS__1,
 			DMM_PAT_STATUS__2, DMM_PAT_STATUS__3},
 	[PAT_DESCR]  = {DMM_PAT_DESCR__0, DMM_PAT_DESCR__1,
@@ -112,10 +112,10 @@ static void *alloc_dma(struct dmm_txn *txn, size_t sz, dma_addr_t *pa)
 }
 
 /* check status and spin until wait_mask comes true */
-static int wait_status(struct refill_engine *engine, uint32_t wait_mask)
+static int wait_status(struct refill_engine *engine, u32 wait_mask)
 {
 	struct dmm *dmm = engine->dmm;
-	uint32_t r = 0, err, i;
+	u32 r = 0, err, i;
 
 	i = DMM_FIXED_RETRY_COUNT;
 	while (true) {
@@ -151,7 +151,7 @@ static void release_engine(struct refill_engine *engine)
 static irqreturn_t omap_dmm_irq_handler(int irq, void *arg)
 {
 	struct dmm *dmm = arg;
-	uint32_t status = dmm_read(dmm, DMM_PAT_IRQSTATUS);
+	u32 status = dmm_read(dmm, DMM_PAT_IRQSTATUS);
 	int i;
 
 	/* ack IRQ */
@@ -214,10 +214,10 @@ static struct dmm_txn *dmm_txn_init(struct dmm *dmm, struct tcm *tcm)
  * corresponding slot is cleared (ie. dummy_pa is programmed)
  */
 static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
-		struct page **pages, uint32_t npages, uint32_t roll)
+		struct page **pages, u32 npages, u32 roll)
 {
 	dma_addr_t pat_pa = 0, data_pa = 0;
-	uint32_t *data;
+	u32 *data;
 	struct pat *pat;
 	struct refill_engine *engine = txn->engine_handle;
 	int columns = (1 + area->x1 - area->x0);
@@ -227,7 +227,7 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
 	pat = alloc_dma(txn, sizeof(*pat), &pat_pa);
 
 	if (txn->last_pat)
-		txn->last_pat->next_pa = (uint32_t)pat_pa;
+		txn->last_pat->next_pa = (u32)pat_pa;
 
 	pat->area = *area;
 
@@ -313,7 +313,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
  * DMM programming
  */
 static int fill(struct tcm_area *area, struct page **pages,
-		uint32_t npages, uint32_t roll, bool wait)
+		u32 npages, u32 roll, bool wait)
 {
 	int ret = 0;
 	struct tcm_area slice, area_s;
@@ -361,7 +361,7 @@ static int fill(struct tcm_area *area, struct page **pages,
 /* note: slots for which pages[i] == NULL are filled w/ dummy page
  */
 int tiler_pin(struct tiler_block *block, struct page **pages,
-		uint32_t npages, uint32_t roll, bool wait)
+		u32 npages, u32 roll, bool wait)
 {
 	int ret;
 
@@ -381,8 +381,8 @@ int tiler_unpin(struct tiler_block *block)
 /*
  * Reserve/release
  */
-struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w,
-		uint16_t h, uint16_t align)
+struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w,
+		u16 h, u16 align)
 {
 	struct tiler_block *block = kzalloc(sizeof(*block), GFP_KERNEL);
 	u32 min_align = 128;
@@ -525,8 +525,8 @@ dma_addr_t tiler_ssptr(struct tiler_block *block)
 			block->area.p0.y * geom[block->fmt].slot_h);
 }
 
-dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
-		uint32_t x, uint32_t y)
+dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
+		u32 x, u32 y)
 {
 	struct tcm_pt *p = &block->area.p0;
 	BUG_ON(!validfmt(block->fmt));
@@ -536,14 +536,14 @@ dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
 			(p->y * geom[block->fmt].slot_h) + y);
 }
 
-void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h)
+void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h)
 {
 	BUG_ON(!validfmt(fmt));
 	*w = round_up(*w, geom[fmt].slot_w);
 	*h = round_up(*h, geom[fmt].slot_h);
 }
 
-uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient)
+u32 tiler_stride(enum tiler_fmt fmt, u32 orient)
 {
 	BUG_ON(!validfmt(fmt));
 
@@ -553,19 +553,19 @@ uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient)
 		return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft);
 }
 
-size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h)
+size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h)
 {
 	tiler_align(fmt, &w, &h);
 	return geom[fmt].cpp * w * h;
 }
 
-size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h)
+size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h)
 {
 	BUG_ON(!validfmt(fmt));
 	return round_up(geom[fmt].cpp * w, PAGE_SIZE) * h;
 }
 
-uint32_t tiler_get_cpu_cache_flags(void)
+u32 tiler_get_cpu_cache_flags(void)
 {
 	return omap_dmm->plat_data->cpu_cache_flags;
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
index e83c78372db8..09816adfd422 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
@@ -89,30 +89,30 @@ int tiler_map_show(struct seq_file *s, void *arg);
 
 /* pin/unpin */
 int tiler_pin(struct tiler_block *block, struct page **pages,
-		uint32_t npages, uint32_t roll, bool wait);
+		u32 npages, u32 roll, bool wait);
 int tiler_unpin(struct tiler_block *block);
 
 /* reserve/release */
-struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, uint16_t h,
-				uint16_t align);
+struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h,
+				u16 align);
 struct tiler_block *tiler_reserve_1d(size_t size);
 int tiler_release(struct tiler_block *block);
 
 /* utilities */
 dma_addr_t tiler_ssptr(struct tiler_block *block);
-dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
-		uint32_t x, uint32_t y);
-uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient);
-size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
-size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
-void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
-uint32_t tiler_get_cpu_cache_flags(void);
+dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
+		u32 x, u32 y);
+u32 tiler_stride(enum tiler_fmt fmt, u32 orient);
+size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h);
+size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h);
+void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
+u32 tiler_get_cpu_cache_flags(void);
 bool dmm_is_available(void);
 
 extern struct platform_driver omap_dmm_driver;
 
 /* GEM bo flags -> tiler fmt */
-static inline enum tiler_fmt gem2fmt(uint32_t flags)
+static inline enum tiler_fmt gem2fmt(u32 flags)
 {
 	switch (flags & OMAP_BO_TILED) {
 	case OMAP_BO_TILED_8:
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index afb2a5a96278..7bf008f02a77 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -48,7 +48,7 @@
 struct omap_drm_usergart;
 
 struct omap_drm_private {
-	uint32_t omaprev;
+	u32 omaprev;
 
 	const struct dispc_ops *dispc_ops;
 
@@ -83,7 +83,7 @@ struct omap_drm_private {
 	/* irq handling: */
 	spinlock_t wait_lock;		/* protects the wait_list */
 	struct list_head wait_list;	/* list of omap_irq_wait */
-	uint32_t irq_mask;		/* enabled irqs in addition to wait_list */
+	u32 irq_mask;			/* enabled irqs in addition to wait_list */
 };
 
 
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index b1a762b70cbf..ee348a616b90 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -54,8 +54,8 @@ static const u32 formats[] = {
 /* per-plane info for the fb: */
 struct plane {
 	struct drm_gem_object *bo;
-	uint32_t pitch;
-	uint32_t offset;
+	u32 pitch;
+	u32 offset;
 	dma_addr_t dma_addr;
 };
 
@@ -102,10 +102,10 @@ static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
 	.destroy = omap_framebuffer_destroy,
 };
 
-static uint32_t get_linear_addr(struct plane *plane,
+static u32 get_linear_addr(struct plane *plane,
 		const struct drm_format_info *format, int n, int x, int y)
 {
-	uint32_t offset;
+	u32 offset;
 
 	offset = plane->offset
 	       + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
@@ -123,9 +123,9 @@ bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
 }
 
 /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
-static uint32_t drm_rotation_to_tiler(unsigned int drm_rot)
+static u32 drm_rotation_to_tiler(unsigned int drm_rot)
 {
-	uint32_t orient;
+	u32 orient;
 
 	switch (drm_rot & DRM_MODE_ROTATE_MASK) {
 	default:
@@ -160,7 +160,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
 	const struct drm_format_info *format = omap_fb->format;
 	struct plane *plane = &omap_fb->planes[0];
-	uint32_t x, y, orient = 0;
+	u32 x, y, orient = 0;
 
 	info->fourcc = fb->format->format;
 
@@ -179,8 +179,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 	y = state->src_y >> 16;
 
 	if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) {
-		uint32_t w = state->src_w >> 16;
-		uint32_t h = state->src_h >> 16;
+		u32 w = state->src_w >> 16;
+		u32 h = state->src_h >> 16;
 
 		orient = drm_rotation_to_tiler(state->rotation);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index fd81396baaf9..96fdc690183f 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -41,13 +41,13 @@ struct omap_gem_object {
 
 	struct list_head mm_list;
 
-	uint32_t flags;
+	u32 flags;
 
 	/** width/height for tiled formats (rounded up to slot boundaries) */
-	uint16_t width, height;
+	u16 width, height;
 
 	/** roll applied when mapping to DMM */
-	uint32_t roll;
+	u32 roll;
 
 	/**
 	 * dma_addr contains the buffer DMA address. It is valid for
@@ -75,7 +75,7 @@ struct omap_gem_object {
 	/**
 	 * # of users of dma_addr
 	 */
-	uint32_t dma_addr_cnt;
+	u32 dma_addr_cnt;
 
 	/**
 	 * If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag
@@ -139,7 +139,7 @@ struct omap_drm_usergart {
  */
 
 /** get mmap offset */
-static uint64_t mmap_offset(struct drm_gem_object *obj)
+static u64 mmap_offset(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
 	int ret;
@@ -333,14 +333,15 @@ static void omap_gem_detach_pages(struct drm_gem_object *obj)
 }
 
 /* get buffer flags */
-uint32_t omap_gem_flags(struct drm_gem_object *obj)
+u32 omap_gem_flags(struct drm_gem_object *obj)
 {
 	return to_omap_bo(obj)->flags;
 }
 
-uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj)
+u64 omap_gem_mmap_offset(struct drm_gem_object *obj)
 {
-	uint64_t offset;
+	u64 offset;
+
 	mutex_lock(&obj->dev->struct_mutex);
 	offset = mmap_offset(obj);
 	mutex_unlock(&obj->dev->struct_mutex);
@@ -651,7 +652,7 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
  * into user memory. We don't have to do much here at the moment.
  */
 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-		uint32_t handle, uint64_t *offset)
+		u32 handle, u64 *offset)
 {
 	struct drm_gem_object *obj;
 	int ret = 0;
@@ -677,10 +678,10 @@ int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
  *
  * Call only from non-atomic contexts.
  */
-int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll)
+int omap_gem_roll(struct drm_gem_object *obj, u32 roll)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
-	uint32_t npages = obj->size >> PAGE_SHIFT;
+	u32 npages = obj->size >> PAGE_SHIFT;
 	int ret = 0;
 
 	if (roll > npages) {
@@ -810,7 +811,7 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
 	if (!is_contiguous(omap_obj) && priv->has_dmm) {
 		if (omap_obj->dma_addr_cnt == 0) {
 			struct page **pages;
-			uint32_t npages = obj->size >> PAGE_SHIFT;
+			u32 npages = obj->size >> PAGE_SHIFT;
 			enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
 			struct tiler_block *block;
 
@@ -906,7 +907,7 @@ void omap_gem_unpin(struct drm_gem_object *obj)
  * specified orientation and x,y offset from top-left corner of buffer
  * (only valid for tiled 2d buffers)
  */
-int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
+int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
 		int x, int y, dma_addr_t *dma_addr)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
@@ -923,7 +924,7 @@ int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
 }
 
 /* Get tiler stride for the buffer (only valid for 2d tiled buffers) */
-int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient)
+int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 	int ret = -EINVAL;
@@ -1005,7 +1006,8 @@ int omap_gem_resume(struct drm_device *dev)
 	list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
 		if (omap_obj->block) {
 			struct drm_gem_object *obj = &omap_obj->base;
-			uint32_t npages = obj->size >> PAGE_SHIFT;
+			u32 npages = obj->size >> PAGE_SHIFT;
+
 			WARN_ON(!omap_obj->pages);  /* this can't happen */
 			ret = tiler_pin(omap_obj->block,
 					omap_obj->pages, npages,
@@ -1029,7 +1031,7 @@ int omap_gem_resume(struct drm_device *dev)
 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
-	uint64_t off;
+	u64 off;
 
 	off = drm_vma_node_start(&obj->vma_node);
 
@@ -1117,7 +1119,7 @@ void omap_gem_free_object(struct drm_gem_object *obj)
 
 /* GEM buffer object constructor */
 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
-		union omap_gem_size gsize, uint32_t flags)
+		union omap_gem_size gsize, u32 flags)
 {
 	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_gem_object *omap_obj;
@@ -1282,7 +1284,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 
 /* convenience method to construct a GEM buffer object, and userspace handle */
 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
-		union omap_gem_size gsize, uint32_t flags, uint32_t *handle)
+		union omap_gem_size gsize, u32 flags, u32 *handle)
 {
 	struct drm_gem_object *obj;
 	int ret;
@@ -1329,7 +1331,8 @@ void omap_gem_init(struct drm_device *dev)
 
 	/* reserve 4k aligned/wide regions for userspace mappings: */
 	for (i = 0; i < ARRAY_SIZE(fmts); i++) {
-		uint16_t h = 1, w = PAGE_SIZE >> i;
+		u16 h = 1, w = PAGE_SIZE >> i;
+
 		tiler_align(fmts[i], &w, &h);
 		/* note: since each region is 1 4kb page wide, and minimum
 		 * number of rows, the height ends up being the same as the
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
index 35fa690b3d90..a78bde05193a 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.h
+++ b/drivers/gpu/drm/omapdrm/omap_gem.h
@@ -53,17 +53,17 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
 
 /* GEM Object Creation and Deletion */
 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
-		union omap_gem_size gsize, uint32_t flags);
+		union omap_gem_size gsize, u32 flags);
 struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 		struct sg_table *sgt);
 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
-		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
+		union omap_gem_size gsize, u32 flags, u32 *handle);
 void omap_gem_free_object(struct drm_gem_object *obj);
 void *omap_gem_vaddr(struct drm_gem_object *obj);
 
 /* Dumb Buffers Interface */
 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-		uint32_t handle, uint64_t *offset);
+		u32 handle, u64 *offset);
 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 		struct drm_mode_create_dumb *args);
 
@@ -71,7 +71,7 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 int omap_gem_mmap_obj(struct drm_gem_object *obj,
 		struct vm_area_struct *vma);
-uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
+u64 omap_gem_mmap_offset(struct drm_gem_object *obj);
 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
 
 /* PRIME Interface */
@@ -81,7 +81,7 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
 		struct dma_buf *buffer);
 
 int omap_gem_fault(struct vm_fault *vmf);
-int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
+int omap_gem_roll(struct drm_gem_object *obj, u32 roll);
 void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
 void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
 		enum dma_data_direction dir);
@@ -91,9 +91,9 @@ int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
 		bool remap);
 int omap_gem_put_pages(struct drm_gem_object *obj);
 
-uint32_t omap_gem_flags(struct drm_gem_object *obj);
-int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
+u32 omap_gem_flags(struct drm_gem_object *obj);
+int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
 		int x, int y, dma_addr_t *dma_addr);
-int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
+int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient);
 
 #endif /* __OMAPDRM_GEM_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index 013b0bba712f..ef5132237100 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -22,7 +22,7 @@
 struct omap_irq_wait {
 	struct list_head node;
 	wait_queue_head_t wq;
-	uint32_t irqmask;
+	u32 irqmask;
 	int count;
 };
 
@@ -31,7 +31,7 @@ static void omap_irq_update(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_irq_wait *wait;
-	uint32_t irqmask = priv->irq_mask;
+	u32 irqmask = priv->irq_mask;
 
 	assert_spin_locked(&priv->wait_lock);
 
@@ -50,7 +50,7 @@ static void omap_irq_wait_handler(struct omap_irq_wait *wait)
 }
 
 struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev,
-		uint32_t irqmask, int count)
+		u32 irqmask, int count)
 {
 	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_irq_wait *wait = kzalloc(sizeof(*wait), GFP_KERNEL);
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.h b/drivers/gpu/drm/omapdrm/omap_irq.h
index 606c09932bc0..9d5441468eca 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.h
+++ b/drivers/gpu/drm/omapdrm/omap_irq.h
@@ -32,7 +32,7 @@ void omap_drm_irq_uninstall(struct drm_device *dev);
 int omap_drm_irq_install(struct drm_device *dev);
 
 struct omap_irq_wait *omap_irq_wait_init(struct drm_device *dev,
-		uint32_t irqmask, int count);
+		u32 irqmask, int count);
 int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
 		unsigned long timeout);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 15e5d5d325c6..903e0fa5442a 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -203,7 +203,7 @@ static void omap_plane_reset(struct drm_plane *plane)
 static int omap_plane_atomic_set_property(struct drm_plane *plane,
 					  struct drm_plane_state *state,
 					  struct drm_property *property,
-					  uint64_t val)
+					  u64 val)
 {
 	struct omap_drm_private *priv = plane->dev->dev_private;
 
@@ -218,7 +218,7 @@ static int omap_plane_atomic_set_property(struct drm_plane *plane,
 static int omap_plane_atomic_get_property(struct drm_plane *plane,
 					  const struct drm_plane_state *state,
 					  struct drm_property *property,
-					  uint64_t *val)
+					  u64 *val)
 {
 	struct omap_drm_private *priv = plane->dev->dev_private;
 
diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c b/drivers/gpu/drm/omapdrm/tcm-sita.c
index c10fdfc0930f..714d4c1d263f 100644
--- a/drivers/gpu/drm/omapdrm/tcm-sita.c
+++ b/drivers/gpu/drm/omapdrm/tcm-sita.c
@@ -35,8 +35,8 @@ static unsigned long mask[8];
  * map		ptr to bitmap
  * stride		slots in a row
  */
-static void free_slots(unsigned long pos, uint16_t w, uint16_t h,
-		unsigned long *map, uint16_t stride)
+static void free_slots(unsigned long pos, u16 w, u16 h,
+		unsigned long *map, u16 stride)
 {
 	int i;
 
@@ -50,7 +50,7 @@ static void free_slots(unsigned long pos, uint16_t w, uint16_t h,
  * map		ptr to bitmap
  * num_bits	number of bits in bitmap
  */
-static int r2l_b2t_1d(uint16_t w, unsigned long *pos, unsigned long *map,
+static int r2l_b2t_1d(u16 w, unsigned long *pos, unsigned long *map,
 		size_t num_bits)
 {
 	unsigned long search_count = 0;
@@ -86,7 +86,7 @@ static int r2l_b2t_1d(uint16_t w, unsigned long *pos, unsigned long *map,
  * num_bits = size of bitmap
  * stride = bits in one row of container
  */
-static int l2r_t2b(uint16_t w, uint16_t h, uint16_t a, int16_t offset,
+static int l2r_t2b(u16 w, u16 h, u16 a, s16 offset,
 		unsigned long *pos, unsigned long slot_bytes,
 		unsigned long *map, size_t num_bits, size_t slot_stride)
 {
@@ -181,7 +181,7 @@ static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots,
 }
 
 static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u16 align,
-				int16_t offset, uint16_t slot_bytes,
+				s16 offset, u16 slot_bytes,
 				struct tcm_area *area)
 {
 	unsigned long pos;
@@ -210,7 +210,7 @@ static void sita_deinit(struct tcm *tcm)
 static s32 sita_free(struct tcm *tcm, struct tcm_area *area)
 {
 	unsigned long pos;
-	uint16_t w, h;
+	u16 w, h;
 
 	pos = area->p0.x + area->p0.y * tcm->width;
 	if (area->is2d) {
diff --git a/drivers/gpu/drm/omapdrm/tcm.h b/drivers/gpu/drm/omapdrm/tcm.h
index ef7df7d6fc84..a6928ba33d08 100644
--- a/drivers/gpu/drm/omapdrm/tcm.h
+++ b/drivers/gpu/drm/omapdrm/tcm.h
@@ -67,7 +67,7 @@ struct tcm {
 
 	/* function table */
 	s32 (*reserve_2d)(struct tcm *tcm, u16 height, u16 width, u16 align,
-			  int16_t offset, uint16_t slot_bytes,
+			  s16 offset, u16 slot_bytes,
 			  struct tcm_area *area);
 	s32 (*reserve_1d)(struct tcm *tcm, u32 slots, struct tcm_area *area);
 	s32 (*free)(struct tcm *tcm, struct tcm_area *area);
@@ -131,7 +131,7 @@ static inline void tcm_deinit(struct tcm *tcm)
  *	    allocation.
  */
 static inline s32 tcm_reserve_2d(struct tcm *tcm, u16 width, u16 height,
-				u16 align, int16_t offset, uint16_t slot_bytes,
+				u16 align, s16 offset, u16 slot_bytes,
 				struct tcm_area *area)
 {
 	/* perform rudimentary error checking */
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 11/48] drm: omapdrm: Use unsigned int type
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (9 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 10/48] drm: omapdrm: Use kernel integer types Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:37   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions Laurent Pinchart
                   ` (40 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The kernel favours 'unsigned int' over plain 'unsigned'. Replace all
occurences of the latter by the former. This avoid lots of checkpatch
complaints in patches that touch lines where a plain 'unsigned' is used.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    |  8 +-
 .../drm/omapdrm/displays/panel-sony-acx565akm.c    |  6 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c                | 25 +++---
 drivers/gpu/drm/omapdrm/dss/dpi.c                  |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c                  | 98 +++++++++++-----------
 drivers/gpu/drm/omapdrm/dss/dss.c                  | 12 +--
 drivers/gpu/drm/omapdrm/dss/dss.h                  | 12 +--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c                |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c                |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5_core.c           | 24 +++---
 drivers/gpu/drm/omapdrm/dss/hdmi_phy.c             |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_wp.c              |  2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h              |  4 +-
 drivers/gpu/drm/omapdrm/dss/pll.c                  |  4 +-
 14 files changed, 102 insertions(+), 101 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 92c556ac22c7..bdc0e8a3832d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -78,7 +78,7 @@ struct panel_drv_data {
 	struct workqueue_struct *workqueue;
 
 	bool ulps_enabled;
-	unsigned ulps_timeout;
+	unsigned int ulps_timeout;
 	struct delayed_work ulps_work;
 };
 
@@ -483,7 +483,7 @@ static ssize_t dsicm_show_ulps(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	unsigned t;
+	unsigned int t;
 
 	mutex_lock(&ddata->lock);
 	t = ddata->ulps_enabled;
@@ -530,7 +530,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	unsigned t;
+	unsigned int t;
 
 	mutex_lock(&ddata->lock);
 	t = ddata->ulps_timeout;
@@ -1004,7 +1004,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 	int r;
 	int first = 1;
 	int plen;
-	unsigned buf_used = 0;
+	unsigned int buf_used = 0;
 
 	if (size < w * h * 3)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index 8e5bff4e5226..06d7d8362a73 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -289,7 +289,7 @@ static void enable_backlight_ctrl(struct panel_drv_data *ddata, int enable)
 	acx565akm_write(ddata, MIPID_CMD_WRITE_CTRL_DISP, (u8 *)&ctrl, 2);
 }
 
-static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode)
+static void set_cabc_mode(struct panel_drv_data *ddata, unsigned int mode)
 {
 	u16 cabc_ctrl;
 
@@ -303,12 +303,12 @@ static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode)
 	acx565akm_write(ddata, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2);
 }
 
-static unsigned get_cabc_mode(struct panel_drv_data *ddata)
+static unsigned int get_cabc_mode(struct panel_drv_data *ddata)
 {
 	return ddata->cabc_mode;
 }
 
-static unsigned get_hw_cabc_mode(struct panel_drv_data *ddata)
+static unsigned int get_hw_cabc_mode(struct panel_drv_data *ddata)
 {
 	u8 cabc_ctrl;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 0f4fdb221498..f0ae6be36a4e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -971,7 +971,7 @@ static void dispc_ovl_set_pre_mult_alpha(enum omap_plane_id plane,
 static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
 		enum omap_overlay_caps caps, u8 global_alpha)
 {
-	static const unsigned shifts[] = { 0, 8, 16, 24, };
+	static const unsigned int shifts[] = { 0, 8, 16, 24, };
 	int shift;
 
 	if ((caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
@@ -1199,7 +1199,7 @@ void dispc_wb_set_channel_in(enum dss_writeback_channel channel)
 static void dispc_ovl_set_burst_size(enum omap_plane_id plane,
 		enum omap_burst_size burst_size)
 {
-	static const unsigned shifts[] = { 6, 14, 14, 14, 14, };
+	static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
 	int shift;
 
 	shift = shifts[plane];
@@ -1287,7 +1287,7 @@ static void dispc_ovl_set_vid_color_conv(enum omap_plane_id plane,
 static void dispc_ovl_enable_replication(enum omap_plane_id plane,
 		enum omap_overlay_caps caps, bool enable)
 {
-	static const unsigned shifts[] = { 5, 10, 10, 10 };
+	static const unsigned int shifts[] = { 5, 10, 10, 10 };
 	int shift;
 
 	if ((caps & OMAP_DSS_OVL_CAP_REPLICATION) == 0)
@@ -1452,9 +1452,8 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
 	 * All sizes are in bytes. Both the buffer and burst are made of
 	 * buffer_units, and the fifo thresholds must be buffer_unit aligned.
 	 */
-
-	unsigned buf_unit = dispc.feat->buffer_size_unit;
-	unsigned ovl_fifo_size, total_fifo_size, burst_size;
+	unsigned int buf_unit = dispc.feat->buffer_size_unit;
+	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
 	int i;
 
 	burst_size = dispc_ovl_get_burst_size(plane);
@@ -2008,8 +2007,8 @@ static s32 pixinc(int pixels, u8 ps)
 }
 
 static void calc_offset(u16 screen_width, u16 width,
-		u32 fourcc, bool fieldmode,
-		unsigned int field_offset, unsigned *offset0, unsigned *offset1,
+		u32 fourcc, bool fieldmode, unsigned int field_offset,
+		unsigned int *offset0, unsigned int *offset1,
 		s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim,
 		enum omap_dss_rotation_type rotation_type, u8 rotation)
 {
@@ -2479,7 +2478,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
 	bool five_taps = true;
 	bool fieldmode = false;
 	int r, cconv = 0;
-	unsigned offset0, offset1;
+	unsigned int offset0, offset1;
 	s32 row_inc;
 	s32 pix_inc;
 	u16 frame_width, frame_height;
@@ -3042,7 +3041,7 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
 static void dispc_mgr_set_timings(enum omap_channel channel,
 			   const struct videomode *vm)
 {
-	unsigned xtot, ytot;
+	unsigned int xtot, ytot;
 	unsigned long ht, vt;
 	struct videomode t = *vm;
 
@@ -3121,7 +3120,7 @@ static unsigned long dispc_fclk_rate(void)
 		r = dss_get_dispc_clk_rate();
 	} else {
 		struct dss_pll *pll;
-		unsigned clkout_idx;
+		unsigned int clkout_idx;
 
 		pll = dss_pll_find_by_src(src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
@@ -3148,7 +3147,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 		r = dss_get_dispc_clk_rate();
 	} else {
 		struct dss_pll *pll;
-		unsigned clkout_idx;
+		unsigned int clkout_idx;
 
 		pll = dss_pll_find_by_src(src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
@@ -3489,7 +3488,7 @@ bool dispc_div_calc(unsigned long dispc_freq,
 	unsigned long pck, lck;
 	unsigned long lck_max;
 	unsigned long pckd_hw_min, pckd_hw_max;
-	unsigned min_fck_per_pck;
+	unsigned int min_fck_per_pck;
 	unsigned long fck;
 
 #ifdef CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index ce9b27978f48..c7346df60929 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -143,7 +143,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
 
 struct dpi_clk_calc_ctx {
 	struct dss_pll *pll;
-	unsigned clkout_idx;
+	unsigned int clkout_idx;
 
 	/* inputs */
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b56a05730314..6a1569149453 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -271,10 +271,10 @@ enum dsi_vc_source {
 
 struct dsi_irq_stats {
 	unsigned long last_reset;
-	unsigned irq_count;
-	unsigned dsi_irqs[32];
-	unsigned vc_irqs[4][32];
-	unsigned cio_irqs[32];
+	unsigned int irq_count;
+	unsigned int dsi_irqs[32];
+	unsigned int vc_irqs[4][32];
+	unsigned int cio_irqs[32];
 };
 
 struct dsi_isr_tables {
@@ -375,7 +375,7 @@ struct dsi_data {
 
 	int update_channel;
 #ifdef DSI_PERF_MEASURE
-	unsigned update_bytes;
+	unsigned int update_bytes;
 #endif
 
 	bool te_enabled;
@@ -408,13 +408,13 @@ struct dsi_data {
 	struct dsi_irq_stats irq_stats;
 #endif
 
-	unsigned num_lanes_supported;
-	unsigned line_buffer_size;
+	unsigned int num_lanes_supported;
+	unsigned int line_buffer_size;
 
 	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
-	unsigned num_lanes_used;
+	unsigned int num_lanes_used;
 
-	unsigned scp_clk_refcount;
+	unsigned int scp_clk_refcount;
 
 	struct dss_lcd_mgr_config mgr_config;
 	struct videomode vm;
@@ -784,7 +784,7 @@ static void dsi_handle_irq_errors(struct platform_device *dsidev, u32 irqstatus,
 }
 
 static void dsi_call_isrs(struct dsi_isr_data *isr_array,
-		unsigned isr_array_size, u32 irqstatus)
+		unsigned int isr_array_size, u32 irqstatus)
 {
 	struct dsi_isr_data *isr_data;
 	int i;
@@ -893,7 +893,7 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
 /* dsi->irq_lock has to be locked by the caller */
 static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
 		struct dsi_isr_data *isr_array,
-		unsigned isr_array_size, u32 default_mask,
+		unsigned int isr_array_size, u32 default_mask,
 		const struct dsi_reg enable_reg,
 		const struct dsi_reg status_reg)
 {
@@ -977,7 +977,7 @@ static void _dsi_initialize_irq(struct platform_device *dsidev)
 }
 
 static int _dsi_register_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
-		struct dsi_isr_data *isr_array, unsigned isr_array_size)
+		struct dsi_isr_data *isr_array, unsigned int isr_array_size)
 {
 	struct dsi_isr_data *isr_data;
 	int free_idx;
@@ -1011,7 +1011,7 @@ static int _dsi_register_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
 }
 
 static int _dsi_unregister_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
-		struct dsi_isr_data *isr_array, unsigned isr_array_size)
+		struct dsi_isr_data *isr_array, unsigned int isr_array_size)
 {
 	struct dsi_isr_data *isr_data;
 	int i;
@@ -1303,7 +1303,7 @@ static int dsi_lp_clock_calc(unsigned long dsi_fclk,
 		unsigned long lp_clk_min, unsigned long lp_clk_max,
 		struct dsi_lp_clock_info *lp_cinfo)
 {
-	unsigned lp_clk_div;
+	unsigned int lp_clk_div;
 	unsigned long lp_clk;
 
 	lp_clk_div = DIV_ROUND_UP(dsi_fclk, lp_clk_max * 2);
@@ -1322,9 +1322,9 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long dsi_fclk;
-	unsigned lp_clk_div;
+	unsigned int lp_clk_div;
 	unsigned long lp_clk;
-	unsigned lpdiv_max = dsi->data->max_pll_lpdiv;
+	unsigned int lpdiv_max = dsi->data->max_pll_lpdiv;
 
 
 	lp_clk_div = dsi->user_lp_cinfo.lp_clk_div;
@@ -1800,7 +1800,7 @@ static int dsi_cio_power(struct platform_device *dsidev,
 	return 0;
 }
 
-static unsigned dsi_get_line_buf_size(struct platform_device *dsidev)
+static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int val;
@@ -1852,9 +1852,9 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
 	r = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1);
 
 	for (i = 0; i < dsi->num_lanes_used; ++i) {
-		unsigned offset = offsets[i];
-		unsigned polarity, lane_number;
-		unsigned t;
+		unsigned int offset = offsets[i];
+		unsigned int polarity, lane_number;
+		unsigned int t;
 
 		for (t = 0; t < dsi->num_lanes_supported; ++t)
 			if (dsi->lanes[t].function == functions[i])
@@ -1872,7 +1872,7 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
 
 	/* clear the unused lanes */
 	for (; i < dsi->num_lanes_supported; ++i) {
-		unsigned offset = offsets[i];
+		unsigned int offset = offsets[i];
 
 		r = FLD_MOD(r, 0, offset + 2, offset);
 		r = FLD_MOD(r, 0, offset + 3, offset + 3);
@@ -1883,7 +1883,8 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
 	return 0;
 }
 
-static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns)
+static inline unsigned int ns2ddr(struct platform_device *dsidev,
+				  unsigned int ns)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
@@ -1892,7 +1893,8 @@ static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns)
 	return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
 }
 
-static inline unsigned ddr2ns(struct platform_device *dsidev, unsigned ddr)
+static inline unsigned int ddr2ns(struct platform_device *dsidev,
+				  unsigned int ddr)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
@@ -1980,7 +1982,7 @@ static void dsi_cio_timings(struct platform_device *dsidev)
 
 /* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
 static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
-		unsigned mask_p, unsigned mask_n)
+		unsigned int mask_p, unsigned int mask_n)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int i;
@@ -1990,7 +1992,7 @@ static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
 	l = 0;
 
 	for (i = 0; i < dsi->num_lanes_supported; ++i) {
-		unsigned p = dsi->lanes[i].polarity;
+		unsigned int p = dsi->lanes[i].polarity;
 
 		if (mask_p & (1 << i))
 			l |= 1 << (i * 2 + (p ? 0 : 1));
@@ -2077,10 +2079,10 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
 }
 
 /* return bitmask of enabled lanes, lane0 being the lsb */
-static unsigned dsi_get_lane_mask(struct platform_device *dsidev)
+static unsigned int dsi_get_lane_mask(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-	unsigned mask = 0;
+	unsigned int mask = 0;
 	int i;
 
 	for (i = 0; i < dsi->num_lanes_supported; ++i) {
@@ -2206,7 +2208,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	dsi_write_reg(dsidev, DSI_TIMING1, l);
 
 	if (dsi->ulps_enabled) {
-		unsigned mask_p;
+		unsigned int mask_p;
 		int i;
 
 		DSSDBG("manual ulps exit\n");
@@ -3225,7 +3227,7 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	int r, i;
-	unsigned mask;
+	unsigned int mask;
 
 	DSSDBG("Entering ULPS");
 
@@ -3315,7 +3317,7 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
 }
 
 static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
-		unsigned ticks, bool x4, bool x16)
+		unsigned int ticks, bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3341,8 +3343,8 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
 			(total_ticks * 1000) / (fck / 1000 / 1000));
 }
 
-static void dsi_set_ta_timeout(struct platform_device *dsidev, unsigned ticks,
-		bool x8, bool x16)
+static void dsi_set_ta_timeout(struct platform_device *dsidev,
+			       unsigned int ticks, bool x8, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3369,7 +3371,7 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev, unsigned ticks,
 }
 
 static void dsi_set_stop_state_counter(struct platform_device *dsidev,
-		unsigned ticks, bool x4, bool x16)
+				       unsigned int ticks, bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3396,7 +3398,7 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
 }
 
 static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
-		unsigned ticks, bool x4, bool x16)
+				  unsigned int ticks, bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3742,13 +3744,13 @@ static int dsi_proto_config(struct platform_device *dsidev)
 static void dsi_proto_timings(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-	unsigned tlpx, tclk_zero, tclk_prepare, tclk_trail;
-	unsigned tclk_pre, tclk_post;
-	unsigned ths_prepare, ths_prepare_ths_zero, ths_zero;
-	unsigned ths_trail, ths_exit;
-	unsigned ddr_clk_pre, ddr_clk_post;
-	unsigned enter_hs_mode_lat, exit_hs_mode_lat;
-	unsigned ths_eot;
+	unsigned int tlpx, tclk_zero, tclk_prepare, tclk_trail;
+	unsigned int tclk_pre, tclk_post;
+	unsigned int ths_prepare, ths_prepare_ths_zero, ths_zero;
+	unsigned int ths_trail, ths_exit;
+	unsigned int ddr_clk_pre, ddr_clk_post;
+	unsigned int enter_hs_mode_lat, exit_hs_mode_lat;
+	unsigned int ths_eot;
 	int ndl = dsi->num_lanes_used - 1;
 	u32 r;
 
@@ -4016,16 +4018,16 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	enum omap_channel dispc_channel = dsi->output.dispc_channel;
-	unsigned bytespp;
-	unsigned bytespl;
-	unsigned bytespf;
-	unsigned total_len;
-	unsigned packet_payload;
-	unsigned packet_len;
+	unsigned int bytespp;
+	unsigned int bytespl;
+	unsigned int bytespf;
+	unsigned int total_len;
+	unsigned int packet_payload;
+	unsigned int packet_len;
 	u32 l;
 	int r;
 	const unsigned channel = dsi->update_channel;
-	const unsigned line_buf_size = dsi->line_buffer_size;
+	const unsigned int line_buf_size = dsi->line_buffer_size;
 	u16 w = dsi->vm.hactive;
 	u16 h = dsi->vm.vactive;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 0d447eddf4d6..a27edc56a509 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -183,8 +183,8 @@ static void dss_restore_context(void)
 
 void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
 {
-	unsigned shift;
-	unsigned val;
+	unsigned int shift;
+	unsigned int val;
 
 	if (!dss.syscon_pll_ctrl)
 		return;
@@ -213,7 +213,7 @@ void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
 static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
 	enum omap_channel channel)
 {
-	unsigned shift, val;
+	unsigned int shift, val;
 
 	if (!dss.syscon_pll_ctrl)
 		return -EINVAL;
@@ -622,12 +622,12 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
 	unsigned long fck_hw_max;
 	unsigned long fckd_hw_max;
 	unsigned long prate;
-	unsigned m;
+	unsigned int m;
 
 	fck_hw_max = dss.feat->fck_freq_max;
 
 	if (dss.parent_clk == NULL) {
-		unsigned pckd;
+		unsigned int pckd;
 
 		pckd = fck_hw_max / pck;
 
@@ -696,7 +696,7 @@ static int dss_setup_default_clock(void)
 {
 	unsigned long max_dss_fck, prate;
 	unsigned long fck;
-	unsigned fck_div;
+	unsigned int fck_div;
 	int r;
 
 	max_dss_fck = dss.feat->fck_freq_max;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 0d7f2b08b7ff..db529481b364 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -169,10 +169,10 @@ struct dss_pll_ops {
 struct dss_pll_hw {
 	enum dss_pll_type type;
 
-	unsigned n_max;
-	unsigned m_min;
-	unsigned m_max;
-	unsigned mX_max;
+	unsigned int n_max;
+	unsigned int m_min;
+	unsigned int m_max;
+	unsigned int mX_max;
 
 	unsigned long fint_min, fint_max;
 	unsigned long clkdco_min, clkdco_low, clkdco_max;
@@ -412,7 +412,7 @@ void hdmi5_uninit_platform_driver(void);
 
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
+static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
 {
 	int b;
 	for (b = 0; b < 32; ++b) {
@@ -432,7 +432,7 @@ int dss_pll_register(struct dss_pll *pll);
 void dss_pll_unregister(struct dss_pll *pll);
 struct dss_pll *dss_pll_find(const char *name);
 struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
-unsigned dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
+unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
 int dss_pll_enable(struct dss_pll *pll);
 void dss_pll_disable(struct dss_pll *pll);
 int dss_pll_set_config(struct dss_pll *pll,
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index a598dfdeb585..21ca7bd13fdc 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -179,7 +179,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	enum omap_channel channel = dssdev->dispc_channel;
 	struct hdmi_wp_data *wp = &hdmi.wp;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
-	unsigned pc;
+	unsigned int pc;
 
 	r = hdmi_power_on_core(dssdev);
 	if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index b3221ca5bcd8..f6c60a6e54ae 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -175,7 +175,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	struct videomode *vm;
 	enum omap_channel channel = dssdev->dispc_channel;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
-	unsigned pc;
+	unsigned int pc;
 
 	r = hdmi_power_on_core(dssdev);
 	if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
index ab179ec133c0..f6236987e80d 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
@@ -51,14 +51,14 @@ static void hdmi_core_ddc_init(struct hdmi_core_data *core)
 {
 	void __iomem *base = core->base;
 	const unsigned long long iclk = 266000000;	/* DSS L3 ICLK */
-	const unsigned ss_scl_high = 4600;		/* ns */
-	const unsigned ss_scl_low = 5400;		/* ns */
-	const unsigned fs_scl_high = 600;		/* ns */
-	const unsigned fs_scl_low = 1300;		/* ns */
-	const unsigned sda_hold = 1000;			/* ns */
-	const unsigned sfr_div = 10;
+	const unsigned int ss_scl_high = 4600;		/* ns */
+	const unsigned int ss_scl_low = 5400;		/* ns */
+	const unsigned int fs_scl_high = 600;		/* ns */
+	const unsigned int fs_scl_low = 1300;		/* ns */
+	const unsigned int sda_hold = 1000;		/* ns */
+	const unsigned int sfr_div = 10;
 	unsigned long long sfr;
-	unsigned v;
+	unsigned int v;
 
 	sfr = iclk / sfr_div;	/* SFR_DIV */
 	sfr /= 1000;		/* SFR clock in kHz */
@@ -431,11 +431,11 @@ static void hdmi_core_write_avi_infoframe(struct hdmi_core_data *core,
 	void __iomem *base = core->base;
 	u8 data[HDMI_INFOFRAME_SIZE(AVI)];
 	u8 *ptr;
-	unsigned y, a, b, s;
-	unsigned c, m, r;
-	unsigned itc, ec, q, sc;
-	unsigned vic;
-	unsigned yq, cn, pr;
+	unsigned int y, a, b, s;
+	unsigned int c, m, r;
+	unsigned int itc, ec, q, sc;
+	unsigned int vic;
+	unsigned int yq, cn, pr;
 
 	hdmi_avi_infoframe_pack(frame, data, sizeof(data));
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
index a156292b1820..d8346d86463e 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
@@ -99,7 +99,7 @@ static void hdmi_phy_configure_lanes(struct hdmi_phy_data *phy)
 
 	u16 lane_cfg = 0;
 	int i;
-	unsigned lane_cfg_val;
+	unsigned int lane_cfg_val;
 	u16 pol_val = 0;
 
 	for (i = 0; i < 4; ++i)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
index 88034fbe0e9f..568ec61799be 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
@@ -168,7 +168,7 @@ void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp,
 {
 	u32 timing_h = 0;
 	u32 timing_v = 0;
-	unsigned hsync_len_offset = 1;
+	unsigned int hsync_len_offset = 1;
 
 	DSSDBG("Enter hdmi_wp_video_config_timing\n");
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 6f7dc8384055..3a6b33ff2990 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -198,8 +198,8 @@ enum omap_dss_dsi_trans_mode {
 struct omap_dss_dsi_videomode_timings {
 	unsigned long hsclk;
 
-	unsigned ndl;
-	unsigned bitspp;
+	unsigned int ndl;
+	unsigned int bitspp;
 
 	/* pixels */
 	u16 hact;
diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
index 9d9d9d42009b..d298cd5a927a 100644
--- a/drivers/gpu/drm/omapdrm/dss/pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/pll.c
@@ -105,7 +105,7 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
 	}
 }
 
-unsigned dss_pll_get_clkout_idx_for_src(enum dss_clk_source src)
+unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src)
 {
 	switch (src) {
 	case DSS_CLK_SRC_HDMI_PLL:
@@ -277,7 +277,7 @@ bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
 	unsigned long fint, clkdco, clkout;
 	unsigned long target_clkdco;
 	unsigned long min_dco;
-	unsigned n, m, mf, m2, sd;
+	unsigned int n, m, mf, m2, sd;
 	const struct dss_pll_hw *hw = pll->hw;
 
 	DSSDBG("clkin %lu, target clkout %lu\n", clkin, target_clkout);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (10 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 11/48] drm: omapdrm: Use unsigned int type Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:41   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration Laurent Pinchart
                   ` (39 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

When merging the omapdrm and omapdss drivers there will be not omapdrm
platform device anymore, and thus no associated probe and remove
functions. To prepare for that, split all the initialization code from
the probe function to make it usable without a platform device.
Similarly, split the cleanup code from the remove function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 83 +++++++++++++++++++++++---------------
 drivers/gpu/drm/omapdrm/omap_drv.h |  2 +
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 2d15ea1d6c92..cbca70f80d8e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -542,24 +542,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 	{ /* sentinel */ }
 };
 
-static int pdev_probe(struct platform_device *pdev)
+static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
 	const struct soc_device_attribute *soc;
-	struct omap_drm_private *priv;
 	struct drm_device *ddev;
 	unsigned int i;
 	int ret;
 
-	DBG("%s", pdev->name);
-
-	if (omapdss_is_initialized() == false)
-		return -EPROBE_DEFER;
+	DBG("%s", dev_name(dev));
 
-	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
-		return ret;
-	}
+	priv->dev = dev;
 
 	omap_crtc_pre_init();
 
@@ -567,13 +559,6 @@ static int pdev_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_crtc_uninit;
 
-	/* Allocate and initialize the driver private structure. */
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		ret = -ENOMEM;
-		goto err_disconnect_dssdevs;
-	}
-
 	priv->dispc_ops = dispc_get_ops();
 
 	soc = soc_device_match(omapdrm_soc_devices);
@@ -584,27 +569,27 @@ static int pdev_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&priv->obj_list);
 
 	/* Allocate and initialize the DRM device. */
-	ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev);
+	ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
 	if (IS_ERR(ddev)) {
 		ret = PTR_ERR(ddev);
-		goto err_free_priv;
+		goto err_destroy_wq;
 	}
 
+	priv->ddev = ddev;
 	ddev->dev_private = priv;
-	platform_set_drvdata(pdev, ddev);
 
 	omap_gem_init(ddev);
 
 	ret = omap_modeset_init(ddev);
 	if (ret) {
-		dev_err(&pdev->dev, "omap_modeset_init failed: ret=%d\n", ret);
+		dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
 		goto err_free_drm_dev;
 	}
 
 	/* Initialize vblank handling, start with all CRTCs disabled. */
 	ret = drm_vblank_init(ddev, priv->num_crtcs);
 	if (ret) {
-		dev_err(&pdev->dev, "could not init vblank\n");
+		dev_err(priv->dev, "could not init vblank\n");
 		goto err_cleanup_modeset;
 	}
 
@@ -637,20 +622,17 @@ static int pdev_probe(struct platform_device *pdev)
 err_free_drm_dev:
 	omap_gem_deinit(ddev);
 	drm_dev_unref(ddev);
-err_free_priv:
+err_destroy_wq:
 	destroy_workqueue(priv->wq);
-	kfree(priv);
-err_disconnect_dssdevs:
 	omap_disconnect_dssdevs();
 err_crtc_uninit:
 	omap_crtc_pre_uninit();
 	return ret;
 }
 
-static int pdev_remove(struct platform_device *pdev)
+static void omapdrm_cleanup(struct omap_drm_private *priv)
 {
-	struct drm_device *ddev = platform_get_drvdata(pdev);
-	struct omap_drm_private *priv = ddev->dev_private;
+	struct drm_device *ddev = priv->ddev;
 
 	DBG("");
 
@@ -672,10 +654,45 @@ static int pdev_remove(struct platform_device *pdev)
 	drm_dev_unref(ddev);
 
 	destroy_workqueue(priv->wq);
-	kfree(priv);
 
 	omap_disconnect_dssdevs();
 	omap_crtc_pre_uninit();
+}
+
+static int pdev_probe(struct platform_device *pdev)
+{
+	struct omap_drm_private *priv;
+	int ret;
+
+	if (omapdss_is_initialized() == false)
+		return -EPROBE_DEFER;
+
+	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
+		return ret;
+	}
+
+	/* Allocate and initialize the driver private structure. */
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+
+	ret = omapdrm_init(priv, &pdev->dev);
+	if (ret < 0)
+		kfree(priv);
+
+	return ret;
+}
+
+static int pdev_remove(struct platform_device *pdev)
+{
+	struct omap_drm_private *priv = platform_get_drvdata(pdev);
+
+	omapdrm_cleanup(priv);
+	kfree(priv);
 
 	return 0;
 }
@@ -719,7 +736,8 @@ static int omap_drm_resume_all_displays(void)
 
 static int omap_drm_suspend(struct device *dev)
 {
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct omap_drm_private *priv = dev_get_drvdata(dev);
+	struct drm_device *drm_dev = priv->ddev;
 
 	drm_kms_helper_poll_disable(drm_dev);
 
@@ -732,7 +750,8 @@ static int omap_drm_suspend(struct device *dev)
 
 static int omap_drm_resume(struct device *dev)
 {
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct omap_drm_private *priv = dev_get_drvdata(dev);
+	struct drm_device *drm_dev = priv->ddev;
 
 	drm_modeset_lock_all(drm_dev);
 	omap_drm_resume_all_displays();
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 7bf008f02a77..2c06533a2d0a 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -48,6 +48,8 @@
 struct omap_drm_usergart;
 
 struct omap_drm_private {
+	struct drm_device *ddev;
+	struct device *dev;
 	u32 omaprev;
 
 	const struct dispc_ops *dispc_ops;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (11 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:42   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers Laurent Pinchart
                   ` (38 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The tvc_of_match variable is never referenced before its definition.
Remove the forward declaration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 542a76503fbd..d3611233e264 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -40,8 +40,6 @@ static const struct videomode tvc_pal_vm = {
 			  DISPLAY_FLAGS_VSYNC_LOW,
 };
 
-static const struct of_device_id tvc_of_match[];
-
 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
 
 static int tvc_connect(struct omap_dss_device *dssdev)
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (12 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:43   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers Laurent Pinchart
                   ` (37 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

No connector is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c       | 3 ---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c      | 3 ---
 3 files changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index d3611233e264..44c7d9238b54 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -196,9 +196,6 @@ static int tvc_probe(struct platform_device *pdev)
 	struct omap_dss_device *dssdev;
 	int r;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
 	if (!ddata)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 05fa24a518c8..7728b5425d19 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -275,9 +275,6 @@ static int dvic_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ddata);
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = dvic_probe_of(pdev);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 4600d3841c25..b8d74fba4f45 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -336,9 +336,6 @@ static int hdmic_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ddata);
 	ddata->dev = &pdev->dev;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = hdmic_probe_of(pdev);
 	if (r)
 		return r;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (13 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:44   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers Laurent Pinchart
                   ` (36 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

No encoder is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c    | 5 -----
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c    | 3 ---
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 3 ---
 3 files changed, 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index b1f6aa09f699..b28ec62267b1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -179,11 +179,6 @@ static int opa362_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "probe\n");
 
-	if (node == NULL) {
-		dev_err(&pdev->dev, "Unable to find device tree\n");
-		return -EINVAL;
-	}
-
 	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
 	if (!ddata)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index b8e420c7d680..9e0ab4e77366 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -201,9 +201,6 @@ static int tfp410_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ddata);
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = tfp410_probe_of(pdev);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index e3d98d78fc40..6c478140a52e 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -299,9 +299,6 @@ static int tpd_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ddata);
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = tpd_probe_of(pdev);
 	if (r)
 		return r;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (14 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:45   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time Laurent Pinchart
                   ` (35 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

No panel is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c                | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c             | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c     | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c     | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c     | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c     | 3 ---
 8 files changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index e065f7e10cca..6468a765f3d1 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -231,9 +231,6 @@ static int panel_dpi_probe(struct platform_device *pdev)
 	struct omap_dss_device *dssdev;
 	int r;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
 	if (ddata == NULL)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index bdc0e8a3832d..aac14f399657 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -1168,9 +1168,6 @@ static int dsicm_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ddata);
 	ddata->pdev = pdev;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = dsicm_probe_of(pdev);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index 74d13969b9ca..b955aa615a5f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -268,9 +268,6 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
 
 	ddata->spi = spi;
 
-	if (!spi->dev.of_node)
-		return -ENODEV;
-
 	r = lb035q02_probe_of(spi);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index df8132d3b9c6..70fa5a04c00e 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
@@ -277,9 +277,6 @@ static int nec_8048_probe(struct spi_device *spi)
 
 	ddata->spi = spi;
 
-	if (!spi->dev.of_node)
-		return -ENODEV;
-
 	r = nec_8048_probe_of(spi);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
index 98d170aecaba..99048e430871 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
@@ -268,9 +268,6 @@ static int sharp_ls_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ddata);
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	r = sharp_ls_probe_of(pdev);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index 06d7d8362a73..cc5e9a68726a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -720,9 +720,6 @@ static int acx565akm_probe(struct spi_device *spi)
 
 	dev_dbg(&spi->dev, "%s\n", __func__);
 
-	if (!spi->dev.of_node)
-		return -ENODEV;
-
 	spi->mode = SPI_MODE_3;
 
 	ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
index 0a38a0e8c925..34d8f42fefbe 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
@@ -404,9 +404,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 
 	ddata->spi_dev = spi;
 
-	if (!spi->dev.of_node)
-		return -ENODEV;
-
 	r = td028ttec1_probe_of(spi);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
index ac4a6d4d134c..06fb5a995002 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
@@ -509,9 +509,6 @@ static int tpo_td043_probe(struct spi_device *spi)
 
 	ddata->spi = spi;
 
-	if (!spi->dev.of_node)
-		return -ENODEV;
-
 	r = tpo_td043_probe_of(spi);
 	if (r)
 		return r;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (15 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:51   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 18/48] drm: omapdrm: displays: Get panel " Laurent Pinchart
                   ` (34 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The connector drivers need a handle to the source they are connected to
in order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 45 ++++++++--------------
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 31 +++++++--------
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 37 ++++++++----------
 3 files changed, 46 insertions(+), 67 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 44c7d9238b54..f07546b8e8dd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -45,7 +45,7 @@ static const struct videomode tvc_pal_vm = {
 static int tvc_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	dev_dbg(ddata->dev, "connect\n");
@@ -53,10 +53,19 @@ static int tvc_connect(struct omap_dss_device *dssdev)
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(ddata->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.atv->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -71,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.atv->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int tvc_enable(struct omap_dss_device *dssdev)
@@ -173,23 +185,6 @@ static struct omap_dss_driver tvc_driver = {
 	.set_wss		= tvc_set_wss,
 };
 
-static int tvc_probe_of(struct platform_device *pdev)
-{
-	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
-
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
-	return 0;
-}
-
 static int tvc_probe(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata;
@@ -203,10 +198,6 @@ static int tvc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ddata);
 	ddata->dev = &pdev->dev;
 
-	r = tvc_probe_of(pdev);
-	if (r)
-		return r;
-
 	ddata->vm = tvc_pal_vm;
 
 	dssdev = &ddata->dssdev;
@@ -219,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit tvc_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(&ddata->dssdev);
 
 	tvc_disable(dssdev);
 	tvc_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 7728b5425d19..ad915860b7fd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -51,16 +51,25 @@ struct panel_drv_data {
 static int dvic_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dvi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -73,6 +82,9 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dvi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int dvic_enable(struct omap_dss_device *dssdev)
@@ -235,25 +247,15 @@ static int dvic_probe_of(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
 	struct device_node *adapter_node;
 	struct i2c_adapter *adapter;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0);
 	if (adapter_node) {
 		adapter = of_get_i2c_adapter_by_node(adapter_node);
 		of_node_put(adapter_node);
 		if (adapter == NULL) {
 			dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n");
-			omap_dss_put_device(ddata->in);
 			return -EPROBE_DEFER;
 		}
 
@@ -297,8 +299,6 @@ static int dvic_probe(struct platform_device *pdev)
 	return 0;
 
 err_reg:
-	omap_dss_put_device(ddata->in);
-
 	i2c_put_adapter(ddata->i2c_adapter);
 
 	return r;
@@ -308,15 +308,12 @@ static int __exit dvic_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(&ddata->dssdev);
 
 	dvic_disable(dssdev);
 	dvic_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	i2c_put_adapter(ddata->i2c_adapter);
 
 	return 0;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index b8d74fba4f45..dedf60b32dab 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -55,7 +55,7 @@ struct panel_drv_data {
 static int hdmic_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	dev_dbg(ddata->dev, "connect\n");
@@ -63,10 +63,19 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(ddata->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.hdmi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -81,6 +90,9 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.hdmi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int hdmic_enable(struct omap_dss_device *dssdev)
@@ -302,7 +314,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
 	int gpio;
 
 	/* HPD GPIO */
@@ -312,14 +323,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
 	else
 		ddata->hpd_gpio = -ENODEV;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -346,7 +349,7 @@ static int hdmic_probe(struct platform_device *pdev)
 		r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio,
 				GPIOF_DIR_IN, "hdmi_hpd");
 		if (r)
-			goto err_reg;
+			return r;
 
 		r = devm_request_threaded_irq(&pdev->dev,
 				gpio_to_irq(ddata->hpd_gpio),
@@ -355,7 +358,7 @@ static int hdmic_probe(struct platform_device *pdev)
 				IRQF_ONESHOT,
 				"hdmic hpd", ddata);
 		if (r)
-			goto err_reg;
+			return r;
 	}
 
 	ddata->vm = hdmic_default_vm;
@@ -370,28 +373,22 @@ static int hdmic_probe(struct platform_device *pdev)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit hdmic_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(&ddata->dssdev);
 
 	hdmic_disable(dssdev);
 	hdmic_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 18/48] drm: omapdrm: displays: Get panel source at connect time
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (16 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:55   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 19/48] drm: omapdrm: displays: Get encoder " Laurent Pinchart
                   ` (33 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The connector drivers need a handle to the source they are connected to
in order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c       | 35 +++++++---------
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 27 +++++++------
 .../omapdrm/displays/panel-lgphilips-lb035q02.c    | 35 +++++++---------
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c    | 39 ++++++++----------
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c | 35 +++++++---------
 .../drm/omapdrm/displays/panel-sony-acx565akm.c    | 26 ++++++------
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c    | 46 +++++++---------------
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c    | 29 +++++++-------
 8 files changed, 119 insertions(+), 153 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 6468a765f3d1..e48c4a7d5276 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -38,16 +38,25 @@ struct panel_drv_data {
 static int panel_dpi_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -60,6 +69,9 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int panel_dpi_enable(struct omap_dss_device *dssdev)
@@ -165,7 +177,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *bl_node;
-	struct omap_dss_device *in;
 	int r;
 	struct display_timing timing;
 	struct gpio_desc *gpio;
@@ -207,15 +218,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
 
 	videomode_from_timing(&timing, &ddata->vm);
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		r = PTR_ERR(in);
-		goto error_free_backlight;
-	}
-
-	ddata->in = in;
-
 	return 0;
 
 error_free_backlight:
@@ -251,29 +253,22 @@ static int panel_dpi_probe(struct platform_device *pdev)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit panel_dpi_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(dssdev);
 
 	panel_dpi_disable(dssdev);
 	panel_dpi_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	if (ddata->backlight)
 		put_device(&ddata->backlight->dev);
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index aac14f399657..1262b7b08ba2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -703,17 +703,23 @@ static int dsicm_panel_reset(struct panel_drv_data *ddata)
 static int dsicm_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
 	struct device *dev = &ddata->pdev->dev;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dsi->connect(in, dssdev);
 	if (r) {
 		dev_err(dev, "Failed to connect to video source\n");
-		return r;
+		goto err_connect;
 	}
 
 	r = in->ops.dsi->request_vc(ddata->in, &ddata->channel);
@@ -728,12 +734,15 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
 		goto err_vc_id;
 	}
 
+	ddata->in = in;
 	return 0;
 
 err_vc_id:
 	in->ops.dsi->release_vc(ddata->in, ddata->channel);
 err_req_vc:
 	in->ops.dsi->disconnect(in, dssdev);
+err_connect:
+	omap_dss_put_device(in);
 	return r;
 }
 
@@ -747,6 +756,9 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
 
 	in->ops.dsi->release_vc(in, ddata->channel);
 	in->ops.dsi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int dsicm_enable(struct omap_dss_device *dssdev)
@@ -1119,7 +1131,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	struct omap_dss_device *in;
 	int gpio;
 
 	gpio = of_get_named_gpio(node, "reset-gpios", 0);
@@ -1137,14 +1148,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
 		return gpio;
 	}
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	/* TODO: ulps, backlight */
 
 	return 0;
@@ -1298,8 +1301,6 @@ static int __exit dsicm_remove(struct platform_device *pdev)
 		backlight_device_unregister(bldev);
 	}
 
-	omap_dss_put_device(ddata->in);
-
 	dsicm_cancel_ulps_work(ddata);
 	destroy_workqueue(ddata->workqueue);
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index b955aa615a5f..bbcf18672433 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -119,18 +119,27 @@ static void init_lb035q02_panel(struct spi_device *spi)
 static int lb035q02_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
 	init_lb035q02_panel(ddata->spi);
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -143,6 +152,9 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int lb035q02_enable(struct omap_dss_device *dssdev)
@@ -230,9 +242,7 @@ static struct omap_dss_driver lb035q02_ops = {
 
 static int lb035q02_probe_of(struct spi_device *spi)
 {
-	struct device_node *node = spi->dev.of_node;
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-	struct omap_dss_device *in;
 	struct gpio_desc *gpio;
 
 	gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
@@ -243,14 +253,6 @@ static int lb035q02_probe_of(struct spi_device *spi)
 
 	ddata->enable_gpio = gpio;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&spi->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -284,29 +286,22 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&spi->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int lb035q02_panel_spi_remove(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(dssdev);
 
 	lb035q02_disable(dssdev);
 	lb035q02_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index 70fa5a04c00e..9e717cd4f194 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
@@ -115,16 +115,25 @@ static int init_nec_8048_wvga_lcd(struct spi_device *spi)
 static int nec_8048_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -137,6 +146,9 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int nec_8048_enable(struct omap_dss_device *dssdev)
@@ -226,7 +238,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
 {
 	struct device_node *node = spi->dev.of_node;
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-	struct omap_dss_device *in;
 	int gpio;
 
 	gpio = of_get_named_gpio(node, "reset-gpios", 0);
@@ -239,14 +250,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
 	/* XXX the panel spec doesn't mention any QVGA pin?? */
 	ddata->qvga_gpio = -ENOENT;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&spi->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -285,14 +288,14 @@ static int nec_8048_probe(struct spi_device *spi)
 		r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
 				GPIOF_OUT_INIT_HIGH, "lcd QVGA");
 		if (r)
-			goto err_gpio;
+			return r;
 	}
 
 	if (gpio_is_valid(ddata->res_gpio)) {
 		r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
 				GPIOF_OUT_INIT_LOW, "lcd RES");
 		if (r)
-			goto err_gpio;
+			return r;
 	}
 
 	ddata->vm = nec_8048_panel_vm;
@@ -307,22 +310,16 @@ static int nec_8048_probe(struct spi_device *spi)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&spi->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-
-err_reg:
-err_gpio:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int nec_8048_remove(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
 
@@ -331,8 +328,6 @@ static int nec_8048_remove(struct spi_device *spi)
 	nec_8048_disable(dssdev);
 	nec_8048_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
index 99048e430871..d67f09a7ba4f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
@@ -61,16 +61,25 @@ static const struct videomode sharp_ls_vm = {
 static int sharp_ls_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -83,6 +92,9 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int sharp_ls_enable(struct omap_dss_device *dssdev)
@@ -210,8 +222,6 @@ static  int sharp_ls_get_gpio_of(struct device *dev, int index, int val,
 static int sharp_ls_probe_of(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
 	int r;
 
 	ddata->vcc = devm_regulator_get(&pdev->dev, "envdd");
@@ -245,14 +255,6 @@ static int sharp_ls_probe_of(struct platform_device *pdev)
 	if (r)
 		return r;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -284,29 +286,22 @@ static int sharp_ls_probe(struct platform_device *pdev)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit sharp_ls_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_display(dssdev);
 
 	sharp_ls_disable(dssdev);
 	sharp_ls_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index cc5e9a68726a..c4bb33a247d0 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -510,16 +510,25 @@ static const struct attribute_group bldev_attr_group = {
 static int acx565akm_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.sdi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -532,6 +541,9 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.sdi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int acx565akm_panel_power_on(struct omap_dss_device *dssdev)
@@ -700,12 +712,6 @@ static int acx565akm_probe_of(struct spi_device *spi)
 
 	ddata->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
 
-	ddata->in = omapdss_of_find_source_for_first_ep(np);
-	if (IS_ERR(ddata->in)) {
-		dev_err(&spi->dev, "failed to find video source\n");
-		return PTR_ERR(ddata->in);
-	}
-
 	return 0;
 }
 
@@ -823,7 +829,6 @@ static int acx565akm_probe(struct spi_device *spi)
 err_reg_bl:
 err_detect:
 err_gpio:
-	omap_dss_put_device(ddata->in);
 	return r;
 }
 
@@ -831,7 +836,6 @@ static int acx565akm_remove(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
 
@@ -843,8 +847,6 @@ static int acx565akm_remove(struct spi_device *spi)
 	acx565akm_disable(dssdev);
 	acx565akm_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
index 34d8f42fefbe..f49127afd17a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
@@ -169,16 +169,25 @@ enum jbt_register {
 static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -191,6 +200,9 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int td028ttec1_panel_enable(struct omap_dss_device *dssdev)
@@ -362,23 +374,6 @@ static struct omap_dss_driver td028ttec1_ops = {
 	.check_timings	= td028ttec1_panel_check_timings,
 };
 
-static int td028ttec1_probe_of(struct spi_device *spi)
-{
-	struct device_node *node = spi->dev.of_node;
-	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-	struct omap_dss_device *in;
-
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&spi->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
-	return 0;
-}
-
 static int td028ttec1_panel_probe(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata;
@@ -404,10 +399,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 
 	ddata->spi_dev = spi;
 
-	r = td028ttec1_probe_of(spi);
-	if (r)
-		return r;
-
 	ddata->vm = td028ttec1_panel_vm;
 
 	dssdev = &ddata->dssdev;
@@ -420,21 +411,16 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 	r = omapdss_register_display(dssdev);
 	if (r) {
 		dev_err(&spi->dev, "Failed to register panel\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int td028ttec1_panel_remove(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	dev_dbg(&ddata->spi_dev->dev, "%s\n", __func__);
 
@@ -443,8 +429,6 @@ static int td028ttec1_panel_remove(struct spi_device *spi)
 	td028ttec1_panel_disable(dssdev);
 	td028ttec1_panel_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
index 06fb5a995002..c08e22b43447 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
@@ -340,16 +340,25 @@ static void tpo_td043_power_off(struct panel_drv_data *ddata)
 static int tpo_td043_connect(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return 0;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -362,6 +371,9 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
 		return;
 
 	in->ops.dpi->disconnect(in, dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int tpo_td043_enable(struct omap_dss_device *dssdev)
@@ -463,7 +475,6 @@ static int tpo_td043_probe_of(struct spi_device *spi)
 {
 	struct device_node *node = spi->dev.of_node;
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-	struct omap_dss_device *in;
 	int gpio;
 
 	gpio = of_get_named_gpio(node, "reset-gpios", 0);
@@ -473,14 +484,6 @@ static int tpo_td043_probe_of(struct spi_device *spi)
 	}
 	ddata->nreset_gpio = gpio;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&spi->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -561,7 +564,6 @@ static int tpo_td043_probe(struct spi_device *spi)
 err_sysfs:
 err_gpio_req:
 err_regulator:
-	omap_dss_put_device(ddata->in);
 	return r;
 }
 
@@ -569,7 +571,6 @@ static int tpo_td043_remove(struct spi_device *spi)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
 
@@ -578,8 +579,6 @@ static int tpo_td043_remove(struct spi_device *spi)
 	tpo_td043_disable(dssdev);
 	tpo_td043_disconnect(dssdev);
 
-	omap_dss_put_device(in);
-
 	sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group);
 
 	return 0;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 19/48] drm: omapdrm: displays: Get encoder source at connect time
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (17 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 18/48] drm: omapdrm: displays: Get panel " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 12:58   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers Laurent Pinchart
                   ` (32 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The encoder drivers need a handle to the source they are connected to in
order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 35 ++++++------
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 36 ++++++------
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 66 ++++++++--------------
 3 files changed, 54 insertions(+), 83 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index b28ec62267b1..b3bb64b477fa 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -36,7 +36,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	dev_dbg(dssdev->dev, "connect\n");
@@ -44,13 +44,22 @@ static int opa362_connect(struct omap_dss_device *dssdev,
 	if (omapdss_device_is_connected(dssdev))
 		return -EBUSY;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.atv->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
 	dst->src = dssdev;
 	dssdev->dst = dst;
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -74,6 +83,9 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
 	dssdev->dst = NULL;
 
 	in->ops.atv->disconnect(in, &ddata->dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int opa362_enable(struct omap_dss_device *dssdev)
@@ -171,9 +183,8 @@ static const struct omapdss_atv_ops opa362_atv_ops = {
 
 static int opa362_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct panel_drv_data *ddata;
-	struct omap_dss_device *dssdev, *in;
+	struct omap_dss_device *dssdev;
 	struct gpio_desc *gpio;
 	int r;
 
@@ -191,14 +202,6 @@ static int opa362_probe(struct platform_device *pdev)
 
 	ddata->enable_gpio = gpio;
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	dssdev = &ddata->dssdev;
 	dssdev->ops.atv = &opa362_atv_ops;
 	dssdev->dev = &pdev->dev;
@@ -209,20 +212,16 @@ static int opa362_probe(struct platform_device *pdev)
 	r = omapdss_register_output(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register output\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-err_reg:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit opa362_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_output(&ddata->dssdev);
 
@@ -234,8 +233,6 @@ static int __exit opa362_remove(struct platform_device *pdev)
 	if (omapdss_device_is_connected(dssdev))
 		opa362_disconnect(dssdev, dssdev->dst);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 9e0ab4e77366..0d640f8c0689 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -32,19 +32,28 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
 	if (omapdss_device_is_connected(dssdev))
 		return -EBUSY;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.dpi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
 	dst->src = dssdev;
 	dssdev->dst = dst;
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -66,6 +75,9 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
 	dssdev->dst = NULL;
 
 	in->ops.dpi->disconnect(in, &ddata->dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int tfp410_enable(struct omap_dss_device *dssdev)
@@ -165,7 +177,6 @@ static int tfp410_probe_of(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
 	int gpio;
 
 	gpio = of_get_named_gpio(node, "powerdown-gpios", 0);
@@ -178,14 +189,6 @@ static int tfp410_probe_of(struct platform_device *pdev)
 		return gpio;
 	}
 
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
 	return 0;
 }
 
@@ -211,7 +214,7 @@ static int tfp410_probe(struct platform_device *pdev)
 		if (r) {
 			dev_err(&pdev->dev, "Failed to request PD GPIO %d\n",
 					ddata->pd_gpio);
-			goto err_gpio;
+			return r;
 		}
 	}
 
@@ -226,21 +229,16 @@ static int tfp410_probe(struct platform_device *pdev)
 	r = omapdss_register_output(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register output\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-err_reg:
-err_gpio:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit tfp410_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_output(&ddata->dssdev);
 
@@ -252,8 +250,6 @@ static int __exit tfp410_remove(struct platform_device *pdev)
 	if (omapdss_device_is_connected(dssdev))
 		tfp410_disconnect(dssdev, dssdev->dst);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index 6c478140a52e..226fad5cdab1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -40,12 +40,20 @@ static int tpd_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *in = ddata->in;
+	struct omap_dss_device *in;
 	int r;
 
+	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	if (IS_ERR(in)) {
+		dev_err(dssdev->dev, "failed to find video source\n");
+		return PTR_ERR(in);
+	}
+
 	r = in->ops.hdmi->connect(in, dssdev);
-	if (r)
+	if (r) {
+		omap_dss_put_device(in);
 		return r;
+	}
 
 	dst->src = dssdev;
 	dssdev->dst = dst;
@@ -56,6 +64,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
 	/* DC-DC converter needs at max 300us to get to 90% of 5V */
 	udelay(300);
 
+	ddata->in = in;
 	return 0;
 }
 
@@ -77,6 +86,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
 	dssdev->dst = NULL;
 
 	in->ops.hdmi->disconnect(in, &ddata->dssdev);
+
+	omap_dss_put_device(in);
+	ddata->in = NULL;
 }
 
 static int tpd_enable(struct omap_dss_device *dssdev)
@@ -269,23 +281,6 @@ static irqreturn_t tpd_hpd_isr(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int tpd_probe_of(struct platform_device *pdev)
-{
-	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-	struct device_node *node = pdev->dev.of_node;
-	struct omap_dss_device *in;
-
-	in = omapdss_of_find_source_for_first_ep(node);
-	if (IS_ERR(in)) {
-		dev_err(&pdev->dev, "failed to find video source\n");
-		return PTR_ERR(in);
-	}
-
-	ddata->in = in;
-
-	return 0;
-}
-
 static int tpd_probe(struct platform_device *pdev)
 {
 	struct omap_dss_device *in, *dssdev;
@@ -299,34 +294,24 @@ static int tpd_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ddata);
 
-	r = tpd_probe_of(pdev);
-	if (r)
-		return r;
-
 	gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 0,
 		 GPIOD_OUT_LOW);
-	if (IS_ERR(gpio)) {
-		r = PTR_ERR(gpio);
-		goto err_gpio;
-	}
+	if (IS_ERR(gpio))
+		return PTR_ERR(gpio);
 
 	ddata->ct_cp_hpd_gpio = gpio;
 
 	gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 1,
 		 GPIOD_OUT_LOW);
-	if (IS_ERR(gpio)) {
-		r = PTR_ERR(gpio);
-		goto err_gpio;
-	}
+	if (IS_ERR(gpio))
+		return PTR_ERR(gpio);
 
 	ddata->ls_oe_gpio = gpio;
 
 	gpio = devm_gpiod_get_index(&pdev->dev, NULL, 2,
 		GPIOD_IN);
-	if (IS_ERR(gpio)) {
-		r = PTR_ERR(gpio);
-		goto err_gpio;
-	}
+	if (IS_ERR(gpio))
+		return PTR_ERR(gpio);
 
 	ddata->hpd_gpio = gpio;
 
@@ -337,7 +322,7 @@ static int tpd_probe(struct platform_device *pdev)
 		IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 		"tpd12s015 hpd", ddata);
 	if (r)
-		goto err_gpio;
+		return r;
 
 	dssdev = &ddata->dssdev;
 	dssdev->ops.hdmi = &tpd_hdmi_ops;
@@ -352,21 +337,16 @@ static int tpd_probe(struct platform_device *pdev)
 	r = omapdss_register_output(dssdev);
 	if (r) {
 		dev_err(&pdev->dev, "Failed to register output\n");
-		goto err_reg;
+		return r;
 	}
 
 	return 0;
-err_reg:
-err_gpio:
-	omap_dss_put_device(ddata->in);
-	return r;
 }
 
 static int __exit tpd_remove(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *in = ddata->in;
 
 	omapdss_unregister_output(&ddata->dssdev);
 
@@ -378,8 +358,6 @@ static int __exit tpd_remove(struct platform_device *pdev)
 	if (omapdss_device_is_connected(dssdev))
 		tpd_disconnect(dssdev, dssdev->dst);
 
-	omap_dss_put_device(in);
-
 	return 0;
 }
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (18 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 19/48] drm: omapdrm: displays: Get encoder " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-14 13:12   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
                   ` (31 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The split between the omapdss and omapdrm driver is historic and was due
to other userspace APIs (FBDEV and V4L2) being supported in addition to
DRM/KMS. Now that the drivers only supports the DRM/KMS API, there is no
need to keep them separate anymore.

Merge the two drivers and remove the now unneeded omapdrm virtual
platform device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Kconfig          |  5 +-
 drivers/gpu/drm/omapdrm/Makefile         | 25 ++++++++++
 drivers/gpu/drm/omapdrm/dss/Kconfig      | 12 -----
 drivers/gpu/drm/omapdrm/dss/Makefile     | 25 ----------
 drivers/gpu/drm/omapdrm/dss/base.c       | 13 -----
 drivers/gpu/drm/omapdrm/dss/core.c       | 14 ++----
 drivers/gpu/drm/omapdrm/dss/dss.c        | 23 ++++++++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h    |  4 --
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 12 ++++-
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  3 +-
 drivers/gpu/drm/omapdrm/omap_drv.c       | 82 ++------------------------------
 drivers/gpu/drm/omapdrm/omap_drv.h       |  4 ++
 12 files changed, 74 insertions(+), 148 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index b3d08c5f41d4..7e5080e45b16 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -2,8 +2,11 @@ config DRM_OMAP
 	tristate "OMAP DRM"
 	depends on DRM
 	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
-	select OMAP2_DSS
 	select DRM_KMS_HELPER
+	select HDMI
+	select OMAP2_DSS
+	select OMAP2_DSS_INIT
+	select VIDEOMODE_HELPERS
 	default n
 	help
 	  DRM display driver for OMAP2/3/4 based boards.
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index b391be7ecb6c..1dafa51ca00e 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -21,4 +21,29 @@ omapdrm-y := omap_drv.o \
 
 omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
 
+# Core DSS files
+omapdrm-y += \
+	dss/base.o \
+	dss/core.o \
+	dss/dispc.o \
+	dss/dispc_coefs.o \
+	dss/display.o \
+	dss/dss.o \
+	dss/dss-of.o \
+	dss/output.o \
+	dss/pll.o \
+	dss/video-pll.o
+
+omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
+omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
+omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
+omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
+omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
+	dss/hdmi_pll.o dss/hdmi_phy.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
+omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
+
+ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
+
 obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 39a30a64448a..157c5601e4be 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,16 +1,6 @@
 config OMAP2_DSS_INIT
 	bool
 
-menuconfig OMAP2_DSS
-        tristate "OMAP2+ Display Subsystem support"
-	select VIDEOMODE_HELPERS
-	select OMAP2_DSS_INIT
-	select HDMI
-        help
-	  OMAP2+ Display Subsystem support.
-
-if OMAP2_DSS
-
 config OMAP2_DSS_DEBUG
 	bool "Debug support"
 	default n
@@ -126,5 +116,3 @@ config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
 
 	  This option enables the sleep, and is enabled by default. You can
 	  disable the sleep if it doesn't cause problems on your platform.
-
-endif
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
index 531b4d8075e5..3db4bf31aeaf 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,26 +1 @@
 obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-obj-$(CONFIG_OMAP2_DSS) += omapdss.o
-
-# Core DSS files
-omapdss-y := \
-	base.o \
-	display.o \
-	dss-of.o \
-	output.o \
-	core.o \
-	dss.o \
-	dispc.o \
-	dispc_coefs.o \
-	pll.o \
-	video-pll.o
-
-omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
-omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
-omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
-omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
-omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
-	hdmi_phy.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
-omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
-ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index eff427dd3297..5729f8244bf9 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -5,7 +5,6 @@
 #include <linux/list.h>
 #include "omapdss.h"
 
-static bool dss_initialized;
 static const struct dispc_ops *ops;
 
 static struct list_head omapdss_comp_list;
@@ -16,17 +15,6 @@ struct omapdss_comp_node {
 	bool dss_core_component;
 };
 
-void omapdss_set_is_initialized(bool set)
-{
-	dss_initialized = set;
-}
-
-bool omapdss_is_initialized(void)
-{
-	return dss_initialized;
-}
-EXPORT_SYMBOL(omapdss_is_initialized);
-
 void dispc_set_ops(const struct dispc_ops *o)
 {
 	ops = o;
@@ -130,4 +118,3 @@ bool omapdss_stack_is_ready(void)
 
 	return true;
 }
-EXPORT_SYMBOL(omapdss_stack_is_ready);
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c
index 197ddbc1512b..776f43601288 100644
--- a/drivers/gpu/drm/omapdrm/dss/core.c
+++ b/drivers/gpu/drm/omapdrm/dss/core.c
@@ -24,13 +24,14 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/platform_device.h>
 
 #include "omapdss.h"
 #include "dss.h"
+#include "../omap_dmm_tiler.h"
 
 /* INIT */
 static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
+	dmm_init_platform_driver,
 	dss_init_platform_driver,
 	dispc_init_platform_driver,
 #ifdef CONFIG_OMAP2_DSS_DSI
@@ -62,10 +63,9 @@ static void (*dss_output_drv_unreg_funcs[])(void) = {
 #endif
 	dispc_uninit_platform_driver,
 	dss_uninit_platform_driver,
+	dmm_uninit_platform_driver,
 };
 
-static struct platform_device *omap_drm_device;
-
 static int __init omap_dss_init(void)
 {
 	int r;
@@ -77,12 +77,6 @@ static int __init omap_dss_init(void)
 			goto err_reg;
 	}
 
-	omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
-	if (IS_ERR(omap_drm_device)) {
-		r = PTR_ERR(omap_drm_device);
-		goto err_reg;
-	}
-
 	return 0;
 
 err_reg:
@@ -98,8 +92,6 @@ static void __exit omap_dss_exit(void)
 {
 	int i;
 
-	platform_device_unregister(omap_drm_device);
-
 	for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i)
 		dss_output_drv_unreg_funcs[i]();
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index a27edc56a509..5721f3d64bdd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -49,6 +49,7 @@
 
 #include "omapdss.h"
 #include "dss.h"
+#include "../omap_drv.h"
 
 #define DSS_SZ_REGS			SZ_512
 
@@ -94,6 +95,8 @@ struct dss_features {
 
 static struct {
 	struct platform_device *pdev;
+	struct omap_drm_private drm;
+
 	void __iomem    *base;
 	struct regmap	*syscon_pll_ctrl;
 	u32		syscon_pll_ctrl_offset;
@@ -1366,10 +1369,15 @@ static int dss_bind(struct device *dev)
 	pm_set_vt_switch(0);
 
 	omapdss_gather_components(dev);
-	omapdss_set_is_initialized(true);
+
+	r = omapdrm_init(&dss.drm, dev);
+	if (r)
+		goto err_drm_init;
 
 	return 0;
 
+err_drm_init:
+	component_unbind_all(&pdev->dev, NULL);
 err_component:
 err_runtime_get:
 	pm_runtime_disable(&pdev->dev);
@@ -1390,7 +1398,7 @@ static void dss_unbind(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 
-	omapdss_set_is_initialized(false);
+	omapdrm_cleanup(&dss.drm);
 
 	component_unbind_all(&pdev->dev, NULL);
 
@@ -1531,7 +1539,18 @@ static int dss_runtime_resume(struct device *dev)
 	return 0;
 }
 
+static int dss_suspend(struct device *dev)
+{
+	return omap_drm_suspend(&dss.drm);
+}
+
+static int dss_resume(struct device *dev)
+{
+	return omap_drm_resume(&dss.drm);
+}
+
 static const struct dev_pm_ops dss_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(dss_suspend, dss_resume)
 	.runtime_suspend = dss_runtime_suspend,
 	.runtime_resume = dss_runtime_resume,
 };
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 3a6b33ff2990..6f9b9b2d8af2 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -583,8 +583,6 @@ struct omap_dss_driver {
 		const struct hdmi_avi_infoframe *avi);
 };
 
-bool omapdss_is_initialized(void);
-
 int omap_dss_register_driver(struct omap_dss_driver *);
 void omap_dss_unregister_driver(struct omap_dss_driver *);
 
@@ -633,8 +631,6 @@ static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node);
 
-void omapdss_set_is_initialized(bool set);
-
 struct device_node *dss_of_port_get_parent_device(struct device_node *port);
 u32 dss_of_port_get_port_number(struct device_node *port);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index b341ebc136fe..dfbf361ac1e4 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -1042,7 +1042,7 @@ static const struct of_device_id dmm_of_match[] = {
 };
 #endif
 
-struct platform_driver omap_dmm_driver = {
+static struct platform_driver omap_dmm_driver = {
 	.probe = omap_dmm_probe,
 	.remove = omap_dmm_remove,
 	.driver = {
@@ -1053,6 +1053,16 @@ struct platform_driver omap_dmm_driver = {
 	},
 };
 
+int __init dmm_init_platform_driver(void)
+{
+	return platform_driver_register(&omap_dmm_driver);
+}
+
+void dmm_uninit_platform_driver(void)
+{
+	platform_driver_unregister(&omap_dmm_driver);
+}
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Andy Gross <andy.gross@ti.com>");
 MODULE_DESCRIPTION("OMAP DMM/Tiler Driver");
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
index 09816adfd422..842254d65548 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
@@ -109,7 +109,8 @@ void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
 u32 tiler_get_cpu_cache_flags(void);
 bool dmm_is_available(void);
 
-extern struct platform_driver omap_dmm_driver;
+int dmm_init_platform_driver(void) __init;
+void dmm_uninit_platform_driver(void);
 
 /* GEM bo flags -> tiler fmt */
 static inline enum tiler_fmt gem2fmt(u32 flags)
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index cbca70f80d8e..baf8e32b899b 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -542,7 +542,7 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 	{ /* sentinel */ }
 };
 
-static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
+int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
 	const struct soc_device_attribute *soc;
 	struct drm_device *ddev;
@@ -630,7 +630,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	return ret;
 }
 
-static void omapdrm_cleanup(struct omap_drm_private *priv)
+void omapdrm_cleanup(struct omap_drm_private *priv)
 {
 	struct drm_device *ddev = priv->ddev;
 
@@ -659,44 +659,6 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
 	omap_crtc_pre_uninit();
 }
 
-static int pdev_probe(struct platform_device *pdev)
-{
-	struct omap_drm_private *priv;
-	int ret;
-
-	if (omapdss_is_initialized() == false)
-		return -EPROBE_DEFER;
-
-	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
-		return ret;
-	}
-
-	/* Allocate and initialize the driver private structure. */
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	platform_set_drvdata(pdev, priv);
-
-	ret = omapdrm_init(priv, &pdev->dev);
-	if (ret < 0)
-		kfree(priv);
-
-	return ret;
-}
-
-static int pdev_remove(struct platform_device *pdev)
-{
-	struct omap_drm_private *priv = platform_get_drvdata(pdev);
-
-	omapdrm_cleanup(priv);
-	kfree(priv);
-
-	return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int omap_drm_suspend_all_displays(void)
 {
@@ -734,9 +696,8 @@ static int omap_drm_resume_all_displays(void)
 	return 0;
 }
 
-static int omap_drm_suspend(struct device *dev)
+int omap_drm_suspend(struct omap_drm_private *priv)
 {
-	struct omap_drm_private *priv = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = priv->ddev;
 
 	drm_kms_helper_poll_disable(drm_dev);
@@ -748,9 +709,8 @@ static int omap_drm_suspend(struct device *dev)
 	return 0;
 }
 
-static int omap_drm_resume(struct device *dev)
+int omap_drm_resume(struct omap_drm_private *priv)
 {
-	struct omap_drm_private *priv = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = priv->ddev;
 
 	drm_modeset_lock_all(drm_dev);
@@ -763,40 +723,6 @@ static int omap_drm_resume(struct device *dev)
 }
 #endif
 
-static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
-
-static struct platform_driver pdev = {
-	.driver = {
-		.name = "omapdrm",
-		.pm = &omapdrm_pm_ops,
-	},
-	.probe = pdev_probe,
-	.remove = pdev_remove,
-};
-
-static struct platform_driver * const drivers[] = {
-	&omap_dmm_driver,
-	&pdev,
-};
-
-static int __init omap_drm_init(void)
-{
-	DBG("init");
-
-	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
-}
-
-static void __exit omap_drm_fini(void)
-{
-	DBG("fini");
-
-	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
-}
-
-/* need late_initcall() so we load after dss_driver's are loaded */
-late_initcall(omap_drm_init);
-module_exit(omap_drm_fini);
-
 MODULE_AUTHOR("Rob Clark <rob@ti.com>");
 MODULE_DESCRIPTION("OMAP DRM Display Driver");
 MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 2c06533a2d0a..e10b9105379a 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -88,6 +88,10 @@ struct omap_drm_private {
 	u32 irq_mask;			/* enabled irqs in addition to wait_list */
 };
 
+int omapdrm_init(struct omap_drm_private *priv, struct device *dev);
+void omapdrm_cleanup(struct omap_drm_private *priv);
+int omap_drm_suspend(struct omap_drm_private *priv);
+int omap_drm_resume(struct omap_drm_private *priv);
 
 int omap_debugfs_init(struct drm_minor *minor);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (19 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-15 21:10   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
                   ` (30 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

To simplify implementation of debugfs seq_file show handlers, the driver
passes the pointer to the show function through the debugfs_create_file
data pointer. This prevents using the pointer to pass driver private
data to the show handler, and requires all handlers to use global
variables to access private data.

To prepare for the removal of global private data in the driver, rework
the debugfs infrastructure to allow passing a private data pointer to
show handlers.

The price to pay is explicit removal of debugfs files to free the
internally allocated memory. This is desirable anyway as debugfs entries
should be removed when a component driver is unbound, otherwise crashes
will occur due to access to freed memory when the components will be
dynamically allocated instead of stored in global variables.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 13 ++++--
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 40 +++++++++++-----
 drivers/gpu/drm/omapdrm/dss/dss.c   | 92 +++++++++++++++++++++++++------------
 drivers/gpu/drm/omapdrm/dss/dss.h   | 27 +++++++----
 drivers/gpu/drm/omapdrm/dss/hdmi.h  |  2 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  9 ++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  9 ++--
 drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++--
 8 files changed, 140 insertions(+), 63 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index f0ae6be36a4e..1afd2802e807 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -168,6 +168,8 @@ static struct {
 	struct platform_device *pdev;
 	void __iomem    *base;
 
+	struct dss_debugfs_entry *debugfs;
+
 	int irq;
 	irq_handler_t user_handler;
 	void *user_data;
@@ -3269,7 +3271,7 @@ void dispc_dump_clocks(struct seq_file *s)
 	dispc_runtime_put();
 }
 
-static void dispc_dump_regs(struct seq_file *s)
+static int dispc_dump_regs(struct seq_file *s, void *p)
 {
 	int i, j;
 	const char *mgr_names[] = {
@@ -3290,7 +3292,7 @@ static void dispc_dump_regs(struct seq_file *s)
 #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
 
 	if (dispc_runtime_get())
-		return;
+		return 0;
 
 	/* DISPC common registers */
 	DUMPREG(DISPC_REVISION);
@@ -3462,6 +3464,8 @@ static void dispc_dump_regs(struct seq_file *s)
 
 #undef DISPC_REG
 #undef DUMPREG
+
+	return 0;
 }
 
 /* calculate clock rates using dividers in cinfo */
@@ -4606,7 +4610,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 
 	dispc_set_ops(&dispc_ops);
 
-	dss_debugfs_create_file("dispc", dispc_dump_regs);
+	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+						&dispc);
 
 	return 0;
 
@@ -4618,6 +4623,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 static void dispc_unbind(struct device *dev, struct device *master,
 			       void *data)
 {
+	dss_debugfs_remove_file(dispc.debugfs);
+
 	dispc_set_ops(NULL);
 
 	pm_runtime_disable(dev);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6a1569149453..a64e6a39ebf1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -402,6 +402,10 @@ struct dsi_data {
 #endif
 	int debug_read;
 	int debug_write;
+	struct {
+		struct dss_debugfs_entry *irqs;
+		struct dss_debugfs_entry *regs;
+	} debugfs;
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
 	spinlock_t irq_stats_lock;
@@ -1659,18 +1663,20 @@ static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
 #undef PIS
 }
 
-static void dsi1_dump_irqs(struct seq_file *s)
+static int dsi1_dump_irqs(struct seq_file *s, void *p)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
 
 	dsi_dump_dsidev_irqs(dsidev, s);
+	return 0;
 }
 
-static void dsi2_dump_irqs(struct seq_file *s)
+static int dsi2_dump_irqs(struct seq_file *s, void *p)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
 
 	dsi_dump_dsidev_irqs(dsidev, s);
+	return 0;
 }
 #endif
 
@@ -1758,18 +1764,20 @@ static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
 #undef DUMPREG
 }
 
-static void dsi1_dump_regs(struct seq_file *s)
+static int dsi1_dump_regs(struct seq_file *s, void *p)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
 
 	dsi_dump_dsidev_regs(dsidev, s);
+	return 0;
 }
 
-static void dsi2_dump_regs(struct seq_file *s)
+static int dsi2_dump_regs(struct seq_file *s, void *p)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
 
 	dsi_dump_dsidev_regs(dsidev, s);
+	return 0;
 }
 
 enum dsi_cio_power_state {
@@ -5567,15 +5575,22 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	dsi_runtime_put(dsidev);
 
 	if (dsi->module_id == 0)
-		dss_debugfs_create_file("dsi1_regs", dsi1_dump_regs);
-	else if (dsi->module_id == 1)
-		dss_debugfs_create_file("dsi2_regs", dsi2_dump_regs);
-
+		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
+							    dsi1_dump_regs,
+							    &dsi);
+	else
+		dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
+							    dsi2_dump_regs,
+							    &dsi);
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
 	if (dsi->module_id == 0)
-		dss_debugfs_create_file("dsi1_irqs", dsi1_dump_irqs);
-	else if (dsi->module_id == 1)
-		dss_debugfs_create_file("dsi2_irqs", dsi2_dump_irqs);
+		dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
+							    dsi1_dump_irqs,
+							    &dsi);
+	else
+		dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
+							    dsi2_dump_irqs,
+							    &dsi);
 #endif
 
 	return 0;
@@ -5594,6 +5609,9 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
 	struct platform_device *dsidev = to_platform_device(dev);
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
+	dss_debugfs_remove_file(dsi->debugfs.irqs);
+	dss_debugfs_remove_file(dsi->debugfs.regs);
+
 	of_platform_depopulate(&dsidev->dev);
 
 	WARN_ON(dsi->scp_clk_refcount > 0);
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 5721f3d64bdd..b45641f6a844 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -118,6 +118,11 @@ static struct {
 
 	const struct dss_features *feat;
 
+	struct {
+		struct dss_debugfs_entry *clk;
+		struct dss_debugfs_entry *dss;
+	} debugfs;
+
 	struct dss_pll	*video1_pll;
 	struct dss_pll	*video2_pll;
 } dss;
@@ -393,12 +398,12 @@ static void dss_dump_clocks(struct seq_file *s)
 }
 #endif
 
-static void dss_dump_regs(struct seq_file *s)
+static int dss_dump_regs(struct seq_file *s, void *p)
 {
 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
 
 	if (dss_runtime_get())
-		return;
+		return 0;
 
 	DUMPREG(DSS_REVISION);
 	DUMPREG(DSS_SYSCONFIG);
@@ -413,6 +418,7 @@ static void dss_dump_regs(struct seq_file *s)
 
 	dss_runtime_put();
 #undef DUMPREG
+	return 0;
 }
 
 static int dss_get_channel_index(enum omap_channel channel)
@@ -906,35 +912,16 @@ void dss_runtime_put(void)
 
 /* DEBUGFS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
-static void dss_debug_dump_clocks(struct seq_file *s)
+static int dss_debug_dump_clocks(struct seq_file *s, void *p)
 {
 	dss_dump_clocks(s);
 	dispc_dump_clocks(s);
 #ifdef CONFIG_OMAP2_DSS_DSI
 	dsi_dump_clocks(s);
 #endif
-}
-
-static int dss_debug_show(struct seq_file *s, void *unused)
-{
-	void (*func)(struct seq_file *) = s->private;
-
-	func(s);
 	return 0;
 }
 
-static int dss_debug_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dss_debug_show, inode->i_private);
-}
-
-static const struct file_operations dss_debug_fops = {
-	.open           = dss_debug_open,
-	.read           = seq_read,
-	.llseek         = seq_lseek,
-	.release        = single_release,
-};
-
 static struct dentry *dss_debugfs_dir;
 
 static int dss_initialize_debugfs(void)
@@ -947,9 +934,6 @@ static int dss_initialize_debugfs(void)
 		return err;
 	}
 
-	debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
-			&dss_debug_dump_clocks, &dss_debug_fops);
-
 	return 0;
 }
 
@@ -959,15 +943,59 @@ static void dss_uninitialize_debugfs(void)
 		debugfs_remove_recursive(dss_debugfs_dir);
 }
 
-int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
+struct dss_debugfs_entry {
+	struct dentry *dentry;
+	int (*show_fn)(struct seq_file *s, void *data);
+	void *data;
+};
+
+static int dss_debug_open(struct inode *inode, struct file *file)
 {
+	struct dss_debugfs_entry *entry = inode->i_private;
+
+	return single_open(file, entry->show_fn, entry->data);
+}
+
+static const struct file_operations dss_debug_fops = {
+	.open		= dss_debug_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
+		int (*show_fn)(struct seq_file *s, void *data), void *data)
+{
+	struct dss_debugfs_entry *entry;
 	struct dentry *d;
 
-	d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
-			write, &dss_debug_fops);
+	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+	if (!entry)
+		return ERR_PTR(-ENOMEM);
+
+	entry->show_fn = show_fn;
+	entry->data = data;
 
-	return PTR_ERR_OR_ZERO(d);
+	d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
+				&dss_debug_fops);
+	if (IS_ERR(d)) {
+		kfree(entry);
+		return ERR_PTR(PTR_ERR(d));
+	}
+
+	entry->dentry = d;
+	return entry;
+}
+
+void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
+{
+	if (IS_ERR_OR_NULL(entry))
+		return;
+
+	debugfs_remove(entry->dentry);
+	kfree(entry);
 }
+
 #else /* CONFIG_OMAP2_DSS_DEBUGFS */
 static inline int dss_initialize_debugfs(void)
 {
@@ -1364,7 +1392,9 @@ static int dss_bind(struct device *dev)
 	if (r)
 		goto err_component;
 
-	dss_debugfs_create_file("dss", dss_dump_regs);
+	dss.debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
+						  &dss);
+	dss.debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, &dss);
 
 	pm_set_vt_switch(0);
 
@@ -1377,6 +1407,8 @@ static int dss_bind(struct device *dev)
 	return 0;
 
 err_drm_init:
+	dss_debugfs_remove_file(dss.debugfs.clk);
+	dss_debugfs_remove_file(dss.debugfs.dss);
 	component_unbind_all(&pdev->dev, NULL);
 err_component:
 err_runtime_get:
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index db529481b364..e688e937da28 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -27,6 +27,11 @@
 
 #include "omapdss.h"
 
+struct dentry;
+struct dss_debugfs_entry;
+struct platform_device;
+struct seq_file;
+
 #define MAX_DSS_LCD_MANAGERS	3
 #define MAX_NUM_DSI		2
 
@@ -234,9 +239,6 @@ struct dss_lcd_mgr_config {
 	int lcden_sig_polarity;
 };
 
-struct seq_file;
-struct platform_device;
-
 /* core */
 static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
 {
@@ -255,12 +257,20 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
 
 /* DSS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
-int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
+struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
+		int (*show_fn)(struct seq_file *s, void *data), void *data);
+void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
 #else
-static inline int dss_debugfs_create_file(const char *name,
-					  void (*write)(struct seq_file *))
+static inline struct dss_debugfs_entry *
+dss_debugfs_create_file(const char *name,
+			int (*show_fn)(struct seq_file *s, void *data),
+			void *data)
+{
+	return NULL;
+}
+
+static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
 {
-	return 0;
 }
 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
 
@@ -325,9 +335,6 @@ static inline void sdi_uninit_port(struct device_node *port)
 
 #ifdef CONFIG_OMAP2_DSS_DSI
 
-struct dentry;
-struct file_operations;
-
 int dsi_init_platform_driver(void) __init;
 void dsi_uninit_platform_driver(void);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index c2609c448ddc..a66f8ff06c24 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -358,6 +358,8 @@ struct omap_hdmi {
 	struct mutex lock;
 	struct platform_device *pdev;
 
+	struct dss_debugfs_entry *debugfs;
+
 	struct hdmi_wp_data	wp;
 	struct hdmi_pll_data	pll;
 	struct hdmi_phy_data	phy;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 21ca7bd13fdc..ada4e3a9dba7 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -302,13 +302,13 @@ static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
 	*vm = hdmi.cfg.vm;
 }
 
-static void hdmi_dump_regs(struct seq_file *s)
+static int hdmi_dump_regs(struct seq_file *s, void *p)
 {
 	mutex_lock(&hdmi.lock);
 
 	if (hdmi_runtime_get()) {
 		mutex_unlock(&hdmi.lock);
-		return;
+		return 0;
 	}
 
 	hdmi_wp_dump(&hdmi.wp, s);
@@ -318,6 +318,7 @@ static void hdmi_dump_regs(struct seq_file *s)
 
 	hdmi_runtime_put();
 	mutex_unlock(&hdmi.lock);
+	return 0;
 }
 
 static int read_edid(u8 *buf, int len)
@@ -776,7 +777,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 		return r;
 	}
 
-	dss_debugfs_create_file("hdmi", hdmi_dump_regs);
+	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
 
 	return 0;
 err:
@@ -788,6 +789,8 @@ static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 
+	dss_debugfs_remove_file(hdmi.debugfs);
+
 	if (hdmi.audio_pdev)
 		platform_device_unregister(hdmi.audio_pdev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index f6c60a6e54ae..00ea975b75f9 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -299,13 +299,13 @@ static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
 	*vm = hdmi.cfg.vm;
 }
 
-static void hdmi_dump_regs(struct seq_file *s)
+static int hdmi_dump_regs(struct seq_file *s, void *p)
 {
 	mutex_lock(&hdmi.lock);
 
 	if (hdmi_runtime_get()) {
 		mutex_unlock(&hdmi.lock);
-		return;
+		return 0;
 	}
 
 	hdmi_wp_dump(&hdmi.wp, s);
@@ -315,6 +315,7 @@ static void hdmi_dump_regs(struct seq_file *s)
 
 	hdmi_runtime_put();
 	mutex_unlock(&hdmi.lock);
+	return 0;
 }
 
 static int read_edid(u8 *buf, int len)
@@ -774,7 +775,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 		return r;
 	}
 
-	dss_debugfs_create_file("hdmi", hdmi_dump_regs);
+	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
 
 	return 0;
 err:
@@ -786,6 +787,8 @@ static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 
+	dss_debugfs_remove_file(hdmi.debugfs);
+
 	if (hdmi.audio_pdev)
 		platform_device_unregister(hdmi.audio_pdev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 1b0fa952b494..68035c1acf1f 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -328,6 +328,8 @@ static struct {
 	u32 wss_data;
 	struct regulator *vdda_dac_reg;
 
+	struct dss_debugfs_entry *debugfs;
+
 	struct clk	*tv_dac_clk;
 
 	struct videomode vm;
@@ -671,12 +673,12 @@ static int venc_init_regulator(void)
 	return 0;
 }
 
-static void venc_dump_regs(struct seq_file *s)
+static int venc_dump_regs(struct seq_file *s, void *p)
 {
 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
 
 	if (venc_runtime_get())
-		return;
+		return 0;
 
 	DUMPREG(VENC_F_CONTROL);
 	DUMPREG(VENC_VIDOUT_CTRL);
@@ -723,6 +725,7 @@ static void venc_dump_regs(struct seq_file *s)
 	venc_runtime_put();
 
 #undef DUMPREG
+	return 0;
 }
 
 static int venc_get_clocks(struct platform_device *pdev)
@@ -913,7 +916,7 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
 		goto err_probe_of;
 	}
 
-	dss_debugfs_create_file("venc", venc_dump_regs);
+	venc.debugfs = dss_debugfs_create_file("venc", venc_dump_regs, &venc);
 
 	venc_init_output(pdev);
 
@@ -929,6 +932,8 @@ static void venc_unbind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 
+	dss_debugfs_remove_file(venc.debugfs);
+
 	venc_uninit_output(pdev);
 
 	pm_runtime_disable(&pdev->dev);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (20 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  8:39   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
                   ` (29 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

To prepare for the removal of the global variable storing DSS private
data, pass its pointer to the dss_runtime_{get,put}() functions.

As this requires getting hold of the DSS private structure in the
callers, we expose the structure through an opaque pointer that can be
retrieved through a new dss_device_get() function. The function
currently returns a pointer to the global data structure, and will later
be updated to get the pointer from device driver data when the DSS
private structure will be allocated dynamically.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c       |  7 +++++--
 drivers/gpu/drm/omapdrm/dss/dss.c       | 37 ++++++++++++++++++++-------------
 drivers/gpu/drm/omapdrm/dss/dss.h       | 13 ++++++++----
 drivers/gpu/drm/omapdrm/dss/hdmi.h      |  6 ++++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c     |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c     |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  | 10 +++++----
 drivers/gpu/drm/omapdrm/dss/video-pll.c | 12 ++++++-----
 8 files changed, 58 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a64e6a39ebf1..1dab308c9bc1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5333,7 +5333,8 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
 	.has_refsel = true,
 };
 
-static int dsi_init_pll_data(struct platform_device *dsidev)
+static int dsi_init_pll_data(struct dss_device *dss,
+			     struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct dss_pll *pll = &dsi->pll;
@@ -5352,6 +5353,7 @@ static int dsi_init_pll_data(struct platform_device *dsidev)
 	pll->base = dsi->pll_base;
 	pll->hw = dsi->data->pll_hw;
 	pll->ops = &dsi_pll_ops;
+	pll->dss = dss;
 
 	r = dss_pll_register(pll);
 	if (r)
@@ -5428,6 +5430,7 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
 static int dsi_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *dsidev = to_platform_device(dev);
+	struct dss_device *dss = dss_get_device(master);
 	const struct soc_device_attribute *soc;
 	const struct dsi_module_id_data *d;
 	u32 rev;
@@ -5538,7 +5541,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		return r;
 
-	dsi_init_pll_data(dsidev);
+	dsi_init_pll_data(dss, dsidev);
 
 	pm_runtime_enable(&dsidev->dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index b45641f6a844..a83277ebe1ef 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -93,7 +93,7 @@ struct dss_features {
 	bool has_lcd_clk_src;
 };
 
-static struct {
+struct dss_device {
 	struct platform_device *pdev;
 	struct omap_drm_private drm;
 
@@ -125,7 +125,9 @@ static struct {
 
 	struct dss_pll	*video1_pll;
 	struct dss_pll	*video2_pll;
-} dss;
+};
+
+static struct dss_device dss;
 
 static const char * const dss_generic_clk_source_names[] = {
 	[DSS_CLK_SRC_FCK]	= "FCK",
@@ -382,7 +384,7 @@ static void dss_dump_clocks(struct seq_file *s)
 	const char *fclk_name;
 	unsigned long fclk_rate;
 
-	if (dss_runtime_get())
+	if (dss_runtime_get(&dss))
 		return;
 
 	seq_printf(s, "- DSS -\n");
@@ -394,7 +396,7 @@ static void dss_dump_clocks(struct seq_file *s)
 			fclk_name,
 			fclk_rate);
 
-	dss_runtime_put();
+	dss_runtime_put(&dss);
 }
 #endif
 
@@ -402,7 +404,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
 {
 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
 
-	if (dss_runtime_get())
+	if (dss_runtime_get(&dss))
 		return 0;
 
 	DUMPREG(DSS_REVISION);
@@ -416,7 +418,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
 		DUMPREG(DSS_SDI_STATUS);
 	}
 
-	dss_runtime_put();
+	dss_runtime_put(&dss);
 #undef DUMPREG
 	return 0;
 }
@@ -889,27 +891,32 @@ static void dss_put_clocks(void)
 		clk_put(dss.parent_clk);
 }
 
-int dss_runtime_get(void)
+int dss_runtime_get(struct dss_device *dss)
 {
 	int r;
 
 	DSSDBG("dss_runtime_get\n");
 
-	r = pm_runtime_get_sync(&dss.pdev->dev);
+	r = pm_runtime_get_sync(&dss->pdev->dev);
 	WARN_ON(r < 0);
 	return r < 0 ? r : 0;
 }
 
-void dss_runtime_put(void)
+void dss_runtime_put(struct dss_device *dss)
 {
 	int r;
 
 	DSSDBG("dss_runtime_put\n");
 
-	r = pm_runtime_put_sync(&dss.pdev->dev);
+	r = pm_runtime_put_sync(&dss->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS && r != -EBUSY);
 }
 
+struct dss_device *dss_get_device(struct device *dev)
+{
+	return &dss;
+}
+
 /* DEBUGFS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
 static int dss_debug_dump_clocks(struct seq_file *s, void *p)
@@ -1297,13 +1304,15 @@ static int dss_video_pll_probe(struct platform_device *pdev)
 	}
 
 	if (of_property_match_string(np, "reg-names", "pll1") >= 0) {
-		dss.video1_pll = dss_video_pll_init(pdev, 0, pll_regulator);
+		dss.video1_pll = dss_video_pll_init(&dss, pdev, 0,
+						    pll_regulator);
 		if (IS_ERR(dss.video1_pll))
 			return PTR_ERR(dss.video1_pll);
 	}
 
 	if (of_property_match_string(np, "reg-names", "pll2") >= 0) {
-		dss.video2_pll = dss_video_pll_init(pdev, 1, pll_regulator);
+		dss.video2_pll = dss_video_pll_init(&dss, pdev, 1,
+						    pll_regulator);
 		if (IS_ERR(dss.video2_pll)) {
 			dss_video_pll_uninit(dss.video1_pll);
 			return PTR_ERR(dss.video2_pll);
@@ -1361,7 +1370,7 @@ static int dss_bind(struct device *dev)
 
 	pm_runtime_enable(&pdev->dev);
 
-	r = dss_runtime_get();
+	r = dss_runtime_get(&dss);
 	if (r)
 		goto err_runtime_get;
 
@@ -1386,7 +1395,7 @@ static int dss_bind(struct device *dev)
 	rev = dss_read_reg(DSS_REVISION);
 	pr_info("OMAP DSS rev %d.%d\n", FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
-	dss_runtime_put();
+	dss_runtime_put(&dss);
 
 	r = component_bind_all(&pdev->dev, NULL);
 	if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index e688e937da28..009b7ef200cd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -29,6 +29,7 @@
 
 struct dentry;
 struct dss_debugfs_entry;
+struct dss_device;
 struct platform_device;
 struct seq_file;
 
@@ -198,6 +199,7 @@ struct dss_pll_hw {
 struct dss_pll {
 	const char *name;
 	enum dss_pll_id id;
+	struct dss_device *dss;
 
 	struct clk *clkin;
 	struct regulator *regulator;
@@ -277,8 +279,10 @@ static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
 int dss_init_platform_driver(void) __init;
 void dss_uninit_platform_driver(void);
 
-int dss_runtime_get(void);
-void dss_runtime_put(void);
+struct dss_device *dss_get_device(struct device *dev);
+
+int dss_runtime_get(struct dss_device *dss);
+void dss_runtime_put(struct dss_device *dss);
 
 unsigned long dss_get_dispc_clk_rate(void);
 unsigned long dss_get_max_fck_rate(void);
@@ -289,8 +293,9 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
 
 /* DSS VIDEO PLL */
-struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
-	struct regulator *regulator);
+struct dss_pll *dss_video_pll_init(struct dss_device *dss,
+				   struct platform_device *pdev, int id,
+				   struct regulator *regulator);
 void dss_video_pll_uninit(struct dss_pll *pll);
 
 void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index a66f8ff06c24..4dbc4f3d728c 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -29,6 +29,8 @@
 #include "omapdss.h"
 #include "dss.h"
 
+struct dss_device;
+
 /* HDMI Wrapper */
 
 #define HDMI_WP_REVISION			0x0
@@ -324,8 +326,8 @@ phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp_data *wp);
 
 /* HDMI PLL funcs */
 void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s);
-int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
-	struct hdmi_wp_data *wp);
+int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev,
+		  struct hdmi_pll_data *pll, struct hdmi_wp_data *wp);
 void hdmi_pll_uninit(struct hdmi_pll_data *hpll);
 
 /* HDMI PHY funcs */
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index ada4e3a9dba7..d84eba8440c8 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -717,6 +717,7 @@ static int hdmi_audio_register(struct device *dev)
 static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
+	struct dss_device *dss = dss_get_device(master);
 	int r;
 	int irq;
 
@@ -734,7 +735,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		return r;
 
-	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 00ea975b75f9..64cfed89c79b 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -719,6 +719,7 @@ static int hdmi_audio_register(struct device *dev)
 static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
+	struct dss_device *dss = dss_get_device(master);
 	int r;
 	int irq;
 
@@ -736,7 +737,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		return r;
 
-	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 55bee81f4dd5..9915354b66c9 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -128,7 +128,8 @@ static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = {
 	.has_refsel = true,
 };
 
-static int hdmi_init_pll_data(struct platform_device *pdev,
+static int hdmi_init_pll_data(struct dss_device *dss,
+			      struct platform_device *pdev,
 			      struct hdmi_pll_data *hpll)
 {
 	struct dss_pll *pll = &hpll->pll;
@@ -145,6 +146,7 @@ static int hdmi_init_pll_data(struct platform_device *pdev,
 	pll->id = DSS_PLL_HDMI;
 	pll->base = hpll->base;
 	pll->clkin = clk;
+	pll->dss = dss;
 
 	if (hpll->wp->version == 4)
 		pll->hw = &dss_omap4_hdmi_pll_hw;
@@ -160,8 +162,8 @@ static int hdmi_init_pll_data(struct platform_device *pdev,
 	return 0;
 }
 
-int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
-	struct hdmi_wp_data *wp)
+int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev,
+		  struct hdmi_pll_data *pll, struct hdmi_wp_data *wp)
 {
 	int r;
 	struct resource *res;
@@ -174,7 +176,7 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
 	if (IS_ERR(pll->base))
 		return PTR_ERR(pll->base);
 
-	r = hdmi_init_pll_data(pdev, pll);
+	r = hdmi_init_pll_data(dss, pdev, pll);
 	if (r) {
 		DSSERR("failed to init HDMI PLL\n");
 		return r;
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 38a239cc5e04..7ef30f61c52b 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -62,7 +62,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
 	struct dss_video_pll *vpll = container_of(pll, struct dss_video_pll, pll);
 	int r;
 
-	r = dss_runtime_get();
+	r = dss_runtime_get(pll->dss);
 	if (r)
 		return r;
 
@@ -81,7 +81,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
 err_reset:
 	dss_dpll_disable_scp_clk(vpll);
 	dss_ctrl_pll_enable(pll->id, false);
-	dss_runtime_put();
+	dss_runtime_put(pll->dss);
 
 	return r;
 }
@@ -96,7 +96,7 @@ static void dss_video_pll_disable(struct dss_pll *pll)
 
 	dss_ctrl_pll_enable(pll->id, false);
 
-	dss_runtime_put();
+	dss_runtime_put(pll->dss);
 }
 
 static const struct dss_pll_ops dss_pll_ops = {
@@ -134,8 +134,9 @@ static const struct dss_pll_hw dss_dra7_video_pll_hw = {
 	.errata_i886 = true,
 };
 
-struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
-	struct regulator *regulator)
+struct dss_pll *dss_video_pll_init(struct dss_device *dss,
+				   struct platform_device *pdev, int id,
+				   struct regulator *regulator)
 {
 	const char * const reg_name[] = { "pll1", "pll2" };
 	const char * const clkctrl_name[] = { "pll1_clkctrl", "pll2_clkctrl" };
@@ -187,6 +188,7 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
 	pll->base = pll_base;
 	pll->hw = &dss_dra7_video_pll_hw;
 	pll->ops = &dss_pll_ops;
+	pll->dss = dss;
 
 	r = dss_pll_register(pll);
 	if (r)
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable()
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (21 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  8:42   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
                   ` (28 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This will allow accessing the PLL data to get the DSS device pointer,
removing the need to access the global DSS private data.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c       | 13 +++++++------
 drivers/gpu/drm/omapdrm/dss/dss.h       |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  4 ++--
 drivers/gpu/drm/omapdrm/dss/video-pll.c |  6 +++---
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index a83277ebe1ef..7179d02e7451 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -191,17 +191,17 @@ static void dss_restore_context(void)
 #undef SR
 #undef RR
 
-void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
+void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
 {
 	unsigned int shift;
 	unsigned int val;
 
-	if (!dss.syscon_pll_ctrl)
+	if (!pll->dss->syscon_pll_ctrl)
 		return;
 
 	val = !enable;
 
-	switch (pll_id) {
+	switch (pll->id) {
 	case DSS_PLL_VIDEO1:
 		shift = 0;
 		break;
@@ -212,12 +212,13 @@ void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
 		shift = 2;
 		break;
 	default:
-		DSSERR("illegal DSS PLL ID %d\n", pll_id);
+		DSSERR("illegal DSS PLL ID %d\n", pll->id);
 		return;
 	}
 
-	regmap_update_bits(dss.syscon_pll_ctrl, dss.syscon_pll_ctrl_offset,
-		1 << shift, val << shift);
+	regmap_update_bits(pll->dss->syscon_pll_ctrl,
+			   pll->dss->syscon_pll_ctrl_offset,
+			   1 << shift, val << shift);
 }
 
 static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 009b7ef200cd..0b8facf258cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -298,7 +298,7 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
 				   struct regulator *regulator);
 void dss_video_pll_uninit(struct dss_pll *pll);
 
-void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
+void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
 
 void dss_sdi_init(int datapairs);
 int dss_sdi_enable(void);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 9915354b66c9..4da32c261c30 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -48,7 +48,7 @@ static int hdmi_pll_enable(struct dss_pll *dsspll)
 	r = pm_runtime_get_sync(&pll->pdev->dev);
 	WARN_ON(r < 0);
 
-	dss_ctrl_pll_enable(DSS_PLL_HDMI, true);
+	dss_ctrl_pll_enable(dsspll, true);
 
 	r = hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
 	if (r)
@@ -65,7 +65,7 @@ static void hdmi_pll_disable(struct dss_pll *dsspll)
 
 	hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_ALLOFF);
 
-	dss_ctrl_pll_enable(DSS_PLL_HDMI, false);
+	dss_ctrl_pll_enable(dsspll, false);
 
 	r = pm_runtime_put_sync(&pll->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 7ef30f61c52b..989a5ee4433a 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -66,7 +66,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
 	if (r)
 		return r;
 
-	dss_ctrl_pll_enable(pll->id, true);
+	dss_ctrl_pll_enable(pll, true);
 
 	dss_dpll_enable_scp_clk(vpll);
 
@@ -80,7 +80,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
 
 err_reset:
 	dss_dpll_disable_scp_clk(vpll);
-	dss_ctrl_pll_enable(pll->id, false);
+	dss_ctrl_pll_enable(pll, false);
 	dss_runtime_put(pll->dss);
 
 	return r;
@@ -94,7 +94,7 @@ static void dss_video_pll_disable(struct dss_pll *pll)
 
 	dss_dpll_disable_scp_clk(vpll);
 
-	dss_ctrl_pll_enable(pll->id, false);
+	dss_ctrl_pll_enable(pll, false);
 
 	dss_runtime_put(pll->dss);
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (22 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  8:47   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
                   ` (27 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c |  8 ++++----
 drivers/gpu/drm/omapdrm/dss/dss.h | 14 ++++++++------
 drivers/gpu/drm/omapdrm/dss/sdi.c | 13 ++++++++-----
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 7179d02e7451..f8b71e24a07d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -287,7 +287,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
 	return 0;
 }
 
-void dss_sdi_init(int datapairs)
+void dss_sdi_init(struct dss_device *dss, int datapairs)
 {
 	u32 l;
 
@@ -306,7 +306,7 @@ void dss_sdi_init(int datapairs)
 	dss_write_reg(DSS_PLL_CONTROL, l);
 }
 
-int dss_sdi_enable(void)
+int dss_sdi_enable(struct dss_device *dss)
 {
 	unsigned long timeout;
 
@@ -364,7 +364,7 @@ int dss_sdi_enable(void)
 	return -ETIMEDOUT;
 }
 
-void dss_sdi_disable(void)
+void dss_sdi_disable(struct dss_device *dss)
 {
 	dispc_lcd_enable_signal(0);
 
@@ -1226,7 +1226,7 @@ static int dss_init_ports(struct platform_device *pdev)
 			dpi_init_port(pdev, port, dss.feat->model);
 			break;
 		case OMAP_DISPLAY_TYPE_SDI:
-			sdi_init_port(pdev, port);
+			sdi_init_port(&dss, pdev, port);
 			break;
 		default:
 			break;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 0b8facf258cf..08651f101518 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -300,9 +300,9 @@ void dss_video_pll_uninit(struct dss_pll *pll);
 
 void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
 
-void dss_sdi_init(int datapairs);
-int dss_sdi_enable(void);
-void dss_sdi_disable(void);
+void dss_sdi_init(struct dss_device *dss, int datapairs);
+int dss_sdi_enable(struct dss_device *dss);
+void dss_sdi_disable(struct dss_device *dss);
 
 void dss_select_dsi_clk_source(int dsi_module,
 		enum dss_clk_source clk_src);
@@ -323,11 +323,13 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
 
 /* SDI */
 #ifdef CONFIG_OMAP2_DSS_SDI
-int sdi_init_port(struct platform_device *pdev, struct device_node *port);
+int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
+		  struct device_node *port);
 void sdi_uninit_port(struct device_node *port);
 #else
-static inline int sdi_init_port(struct platform_device *pdev,
-		struct device_node *port)
+static inline int sdi_init_port(struct dss_device *dss,
+				struct platform_device *pdev,
+				struct device_node *port)
 {
 	return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index d18ad58c5a19..39cb5c8af0dc 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -33,6 +33,7 @@
 
 static struct {
 	struct platform_device *pdev;
+	struct dss_device *dss;
 
 	bool update_enabled;
 	struct regulator *vdds_sdi_reg;
@@ -189,8 +190,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	 */
 	dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
 
-	dss_sdi_init(sdi.datapairs);
-	r = dss_sdi_enable();
+	dss_sdi_init(sdi.dss, sdi.datapairs);
+	r = dss_sdi_enable(sdi.dss);
 	if (r)
 		goto err_sdi_enable;
 	mdelay(2);
@@ -202,7 +203,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	return 0;
 
 err_mgr_enable:
-	dss_sdi_disable();
+	dss_sdi_disable(sdi.dss);
 err_sdi_enable:
 err_set_dss_clock_div:
 err_calc_clock_div:
@@ -219,7 +220,7 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
 
 	dss_mgr_disable(channel);
 
-	dss_sdi_disable();
+	dss_sdi_disable(sdi.dss);
 
 	dispc_runtime_put();
 
@@ -347,7 +348,8 @@ static void sdi_uninit_output(struct platform_device *pdev)
 	omapdss_unregister_output(out);
 }
 
-int sdi_init_port(struct platform_device *pdev, struct device_node *port)
+int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
+		  struct device_node *port)
 {
 	struct device_node *ep;
 	u32 datapairs;
@@ -364,6 +366,7 @@ int sdi_init_port(struct platform_device *pdev, struct device_node *port)
 	}
 
 	sdi.datapairs = datapairs;
+	sdi.dss = dss;
 
 	of_node_put(ep);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (23 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:05   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
                   ` (26 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 12 ++++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 18 +++++-----
 drivers/gpu/drm/omapdrm/dss/dss.c   | 68 ++++++++++++++++++++++---------------
 drivers/gpu/drm/omapdrm/dss/dss.h   | 25 ++++++++------
 drivers/gpu/drm/omapdrm/dss/hdmi.h  |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 +-
 7 files changed, 77 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index c7346df60929..38a4c037783a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -40,6 +40,7 @@
 struct dpi_data {
 	struct platform_device *pdev;
 	enum dss_model dss_model;
+	struct dss_device *dss;
 
 	struct regulator *vdds_dsi_reg;
 	enum dss_clk_source clk_src;
@@ -304,7 +305,7 @@ static int dpi_set_pll_clk(struct dpi_data *dpi, enum omap_channel channel,
 	if (r)
 		return r;
 
-	dss_select_lcd_clk_source(channel, dpi->clk_src);
+	dss_select_lcd_clk_source(dpi->dss, channel, dpi->clk_src);
 
 	dpi->mgr_config.clock_info = ctx.dispc_cinfo;
 
@@ -414,7 +415,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_get_dispc;
 
-	r = dss_dpi_select_source(out->port_num, channel);
+	r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
 	if (r)
 		goto err_src_sel;
 
@@ -466,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
 	dss_mgr_disable(channel);
 
 	if (dpi->pll) {
-		dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+		dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
 		dss_pll_disable(dpi->pll);
 	}
 
@@ -750,8 +751,8 @@ static void dpi_uninit_output_port(struct device_node *port)
 	omapdss_unregister_output(out);
 }
 
-int dpi_init_port(struct platform_device *pdev, struct device_node *port,
-		  enum dss_model dss_model)
+int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
+		  struct device_node *port, enum dss_model dss_model)
 {
 	struct dpi_data *dpi;
 	struct device_node *ep;
@@ -778,6 +779,7 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port,
 
 	dpi->pdev = pdev;
 	dpi->dss_model = dss_model;
+	dpi->dss = dss;
 	port->data = dpi;
 
 	mutex_init(&dpi->lock);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1dab308c9bc1..6d60882dfd10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -345,6 +345,7 @@ struct dsi_data {
 
 	struct clk *dss_clk;
 	struct regmap *syscon;
+	struct dss_device *dss;
 
 	struct dispc_clock_info user_dispc_cinfo;
 	struct dss_pll_clock_info user_dsi_cinfo;
@@ -4217,7 +4218,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
-	dss_select_lcd_clk_source(channel, dsi->module_id == 0 ?
+	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
 			DSS_CLK_SRC_PLL1_1 :
 			DSS_CLK_SRC_PLL2_1);
 
@@ -4271,7 +4272,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
 		dss_mgr_unregister_framedone_handler(channel,
 				dsi_framedone_irq_callback, dsidev);
 err:
-	dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
 	return r;
 }
 
@@ -4284,7 +4285,7 @@ static void dsi_display_uninit_dispc(struct platform_device *dsidev,
 		dss_mgr_unregister_framedone_handler(channel,
 				dsi_framedone_irq_callback, dsidev);
 
-	dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
 }
 
 static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
@@ -4317,9 +4318,9 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
 	if (r)
 		goto err1;
 
-	dss_select_dsi_clk_source(dsi->module_id, dsi->module_id == 0 ?
-			DSS_CLK_SRC_PLL1_2 :
-			DSS_CLK_SRC_PLL2_2);
+	dss_select_dsi_clk_source(dsi->dss, dsi->module_id,
+				  dsi->module_id == 0 ?
+				  DSS_CLK_SRC_PLL1_2 : DSS_CLK_SRC_PLL2_2);
 
 	DSSDBG("PLL OK\n");
 
@@ -4351,7 +4352,7 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
 err3:
 	dsi_cio_uninit(dsidev);
 err2:
-	dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
+	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
 err1:
 	dss_pll_disable(&dsi->pll);
 err0:
@@ -4373,7 +4374,7 @@ static void dsi_display_uninit_dsi(struct platform_device *dsidev,
 	dsi_vc_enable(dsidev, 2, 0);
 	dsi_vc_enable(dsidev, 3, 0);
 
-	dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
+	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
 	dsi_cio_uninit(dsidev);
 	dsi_pll_uninit(dsidev, disconnect_lanes);
 }
@@ -5443,6 +5444,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	if (!dsi)
 		return -ENOMEM;
 
+	dsi->dss = dss;
 	dsi->pdev = dsidev;
 	dev_set_drvdata(&dsidev->dev, dsi);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index f8b71e24a07d..bd8f7abf0450 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -74,9 +74,11 @@ struct dss_reg {
 	dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
 
 struct dss_ops {
-	int (*dpi_select_source)(int port, enum omap_channel channel);
-	int (*select_lcd_source)(enum omap_channel channel,
-		enum dss_clk_source clk_src);
+	int (*dpi_select_source)(struct dss_device *dss, int port,
+				 enum omap_channel channel);
+	int (*select_lcd_source)(struct dss_device *dss,
+				 enum omap_channel channel,
+				 enum dss_clk_source clk_src);
 };
 
 struct dss_features {
@@ -472,8 +474,8 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
 	dss.dispc_clk_source = clk_src;
 }
 
-void dss_select_dsi_clk_source(int dsi_module,
-		enum dss_clk_source clk_src)
+void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
+			       enum dss_clk_source clk_src)
 {
 	int b, pos;
 
@@ -497,11 +499,12 @@ void dss_select_dsi_clk_source(int dsi_module,
 	pos = dsi_module == 0 ? 1 : 10;
 	REG_FLD_MOD(DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
 
-	dss.dsi_clk_source[dsi_module] = clk_src;
+	dss->dsi_clk_source[dsi_module] = clk_src;
 }
 
-static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
-	enum dss_clk_source clk_src)
+static int dss_lcd_clk_mux_dra7(struct dss_device *dss,
+				enum omap_channel channel,
+				enum dss_clk_source clk_src)
 {
 	const u8 ctrl_bits[] = {
 		[OMAP_DSS_CHANNEL_LCD] = 0,
@@ -527,8 +530,9 @@ static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
 	return 0;
 }
 
-static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
-	enum dss_clk_source clk_src)
+static int dss_lcd_clk_mux_omap5(struct dss_device *dss,
+				 enum omap_channel channel,
+				 enum dss_clk_source clk_src)
 {
 	const u8 ctrl_bits[] = {
 		[OMAP_DSS_CHANNEL_LCD] = 0,
@@ -557,8 +561,9 @@ static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
 	return 0;
 }
 
-static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
-	enum dss_clk_source clk_src)
+static int dss_lcd_clk_mux_omap4(struct dss_device *dss,
+				 enum omap_channel channel,
+				 enum dss_clk_source clk_src)
 {
 	const u8 ctrl_bits[] = {
 		[OMAP_DSS_CHANNEL_LCD] = 0,
@@ -585,23 +590,24 @@ static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
 	return 0;
 }
 
-void dss_select_lcd_clk_source(enum omap_channel channel,
-		enum dss_clk_source clk_src)
+void dss_select_lcd_clk_source(struct dss_device *dss,
+			       enum omap_channel channel,
+			       enum dss_clk_source clk_src)
 {
 	int idx = dss_get_channel_index(channel);
 	int r;
 
-	if (!dss.feat->has_lcd_clk_src) {
+	if (!dss->feat->has_lcd_clk_src) {
 		dss_select_dispc_clk_source(clk_src);
-		dss.lcd_clk_source[idx] = clk_src;
+		dss->lcd_clk_source[idx] = clk_src;
 		return;
 	}
 
-	r = dss.feat->ops->select_lcd_source(channel, clk_src);
+	r = dss->feat->ops->select_lcd_source(dss, channel, clk_src);
 	if (r)
 		return;
 
-	dss.lcd_clk_source[idx] = clk_src;
+	dss->lcd_clk_source[idx] = clk_src;
 }
 
 enum dss_clk_source dss_get_dispc_clk_source(void)
@@ -750,11 +756,12 @@ void dss_set_dac_pwrdn_bgz(bool enable)
 	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
 }
 
-void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select src)
+void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
+				     enum dss_hdmi_venc_clk_source_select src)
 {
 	enum omap_dss_output_id outputs;
 
-	outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
+	outputs = dss->feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
 
 	/* Complain about invalid selections */
 	WARN_ON((src == DSS_VENC_TV_CLK) && !(outputs & OMAP_DSS_OUTPUT_VENC));
@@ -780,7 +787,8 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
 	return REG_GET(DSS_CONTROL, 15, 15);
 }
 
-static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel)
+static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
+					     enum omap_channel channel)
 {
 	if (channel != OMAP_DSS_CHANNEL_LCD)
 		return -EINVAL;
@@ -788,7 +796,8 @@ static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel
 	return 0;
 }
 
-static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
+static int dss_dpi_select_source_omap4(struct dss_device *dss, int port,
+				       enum omap_channel channel)
 {
 	int val;
 
@@ -808,7 +817,8 @@ static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
 	return 0;
 }
 
-static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
+static int dss_dpi_select_source_omap5(struct dss_device *dss, int port,
+				       enum omap_channel channel)
 {
 	int val;
 
@@ -834,11 +844,12 @@ static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
 	return 0;
 }
 
-static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
+static int dss_dpi_select_source_dra7xx(struct dss_device *dss, int port,
+					enum omap_channel channel)
 {
 	switch (port) {
 	case 0:
-		return dss_dpi_select_source_omap5(port, channel);
+		return dss_dpi_select_source_omap5(dss, port, channel);
 	case 1:
 		if (channel != OMAP_DSS_CHANNEL_LCD2)
 			return -EINVAL;
@@ -854,9 +865,10 @@ static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
 	return 0;
 }
 
-int dss_dpi_select_source(int port, enum omap_channel channel)
+int dss_dpi_select_source(struct dss_device *dss, int port,
+			  enum omap_channel channel)
 {
-	return dss.feat->ops->dpi_select_source(port, channel);
+	return dss->feat->ops->dpi_select_source(dss, port, channel);
 }
 
 static int dss_get_clocks(void)
@@ -1223,7 +1235,7 @@ static int dss_init_ports(struct platform_device *pdev)
 
 		switch (dss.feat->ports[i]) {
 		case OMAP_DISPLAY_TYPE_DPI:
-			dpi_init_port(pdev, port, dss.feat->model);
+			dpi_init_port(&dss, pdev, port, dss.feat->model);
 			break;
 		case OMAP_DISPLAY_TYPE_SDI:
 			sdi_init_port(&dss, pdev, port);
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 08651f101518..05fba6b3400b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -287,8 +287,10 @@ void dss_runtime_put(struct dss_device *dss);
 unsigned long dss_get_dispc_clk_rate(void);
 unsigned long dss_get_max_fck_rate(void);
 enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
-int dss_dpi_select_source(int port, enum omap_channel channel);
-void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
+int dss_dpi_select_source(struct dss_device *dss, int port,
+			  enum omap_channel channel);
+void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
+				     enum dss_hdmi_venc_clk_source_select src);
 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
 
@@ -304,10 +306,11 @@ void dss_sdi_init(struct dss_device *dss, int datapairs);
 int dss_sdi_enable(struct dss_device *dss);
 void dss_sdi_disable(struct dss_device *dss);
 
-void dss_select_dsi_clk_source(int dsi_module,
-		enum dss_clk_source clk_src);
-void dss_select_lcd_clk_source(enum omap_channel channel,
-		enum dss_clk_source clk_src);
+void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
+			       enum dss_clk_source clk_src);
+void dss_select_lcd_clk_source(struct dss_device *dss,
+			       enum omap_channel channel,
+			       enum dss_clk_source clk_src);
 enum dss_clk_source dss_get_dispc_clk_source(void);
 enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
 enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
@@ -353,12 +356,14 @@ void dsi_irq_handler(void);
 
 /* DPI */
 #ifdef CONFIG_OMAP2_DSS_DPI
-int dpi_init_port(struct platform_device *pdev, struct device_node *port,
-		  enum dss_model dss_model);
+int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
+		  struct device_node *port, enum dss_model dss_model);
 void dpi_uninit_port(struct device_node *port);
 #else
-static inline int dpi_init_port(struct platform_device *pdev,
-		struct device_node *port, enum dss_model dss_model)
+static inline int dpi_init_port(struct dss_device *port,
+				struct platform_device *pdev,
+				struct device_node *port,
+				enum dss_model dss_model)
 {
 	return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index 4dbc4f3d728c..fa2fbdaa427c 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -359,6 +359,7 @@ static inline bool hdmi_mode_has_audio(struct hdmi_config *cfg)
 struct omap_hdmi {
 	struct mutex lock;
 	struct platform_device *pdev;
+	struct dss_device *dss;
 
 	struct dss_debugfs_entry *debugfs;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index d84eba8440c8..5806587fd89a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -147,7 +147,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
 	hdmi4_core_powerdown_disable(&hdmi.core);
 
 	/* Make selection of HDMI in DSS */
-	dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
+	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
 
 	hdmi.core_enabled = true;
 
@@ -722,6 +722,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 	int irq;
 
 	hdmi.pdev = pdev;
+	hdmi.dss = dss;
 	dev_set_drvdata(&pdev->dev, &hdmi);
 
 	mutex_init(&hdmi.lock);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 64cfed89c79b..c28fe184a7ad 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -149,7 +149,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
 		goto err_runtime_get;
 
 	/* Make selection of HDMI in DSS */
-	dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
+	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
 
 	hdmi.core_enabled = true;
 
@@ -724,6 +724,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 	int irq;
 
 	hdmi.pdev = pdev;
+	hdmi.dss = dss;
 	dev_set_drvdata(&pdev->dev, &hdmi);
 
 	mutex_init(&hdmi.lock);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source()
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (24 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:08   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
                   ` (25 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 11 +++++++----
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 +++++---
 drivers/gpu/drm/omapdrm/dss/dss.c   | 18 ++++++++++--------
 drivers/gpu/drm/omapdrm/dss/dss.h   |  8 +++++---
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 1afd2802e807..723828f97196 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -167,6 +167,7 @@ struct dispc_features {
 static struct {
 	struct platform_device *pdev;
 	void __iomem    *base;
+	struct dss_device *dss;
 
 	struct dss_debugfs_entry *debugfs;
 
@@ -3116,7 +3117,7 @@ static unsigned long dispc_fclk_rate(void)
 	unsigned long r;
 	enum dss_clk_source src;
 
-	src = dss_get_dispc_clk_source();
+	src = dss_get_dispc_clk_source(dispc.dss);
 
 	if (src == DSS_CLK_SRC_FCK) {
 		r = dss_get_dispc_clk_rate();
@@ -3143,7 +3144,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 	if (!dss_mgr_is_lcd(channel))
 		return dispc_fclk_rate();
 
-	src = dss_get_lcd_clk_source(channel);
+	src = dss_get_lcd_clk_source(dispc.dss, channel);
 
 	if (src == DSS_CLK_SRC_FCK) {
 		r = dss_get_dispc_clk_rate();
@@ -3223,7 +3224,7 @@ static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel chan
 
 	seq_printf(s, "- %s -\n", mgr_desc[channel].name);
 
-	lcd_clk_src = dss_get_lcd_clk_source(channel);
+	lcd_clk_src = dss_get_lcd_clk_source(dispc.dss, channel);
 
 	seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
 		dss_get_clk_source_name(lcd_clk_src));
@@ -3240,7 +3241,7 @@ void dispc_dump_clocks(struct seq_file *s)
 {
 	int lcd;
 	u32 l;
-	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source();
+	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
 
 	if (dispc_runtime_get())
 		return;
@@ -4542,12 +4543,14 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	const struct soc_device_attribute *soc;
+	struct dss_device *dss = dss_get_device(master);
 	u32 rev;
 	int r = 0;
 	struct resource *dispc_mem;
 	struct device_node *np = pdev->dev.of_node;
 
 	dispc.pdev = pdev;
+	dispc.dss = dss;
 
 	spin_lock_init(&dispc.control_lock);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6d60882dfd10..7fb048023fd0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1292,8 +1292,10 @@ static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
 {
 	unsigned long r;
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	enum dss_clk_source source;
 
-	if (dss_get_dsi_clk_source(dsi->module_id) == DSS_CLK_SRC_FCK) {
+	source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id);
+	if (source == DSS_CLK_SRC_FCK) {
 		/* DSI FCLK source is DSS_CLK_FCK */
 		r = clk_get_rate(dsi->dss_clk);
 	} else {
@@ -1512,8 +1514,8 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
 	int dsi_module = dsi->module_id;
 	struct dss_pll *pll = &dsi->pll;
 
-	dispc_clk_src = dss_get_dispc_clk_source();
-	dsi_clk_src = dss_get_dsi_clk_source(dsi_module);
+	dispc_clk_src = dss_get_dispc_clk_source(dsi->dss);
+	dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
 
 	if (dsi_runtime_get(dsidev))
 		return;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index bd8f7abf0450..ba7a2bf1ec09 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -610,25 +610,27 @@ void dss_select_lcd_clk_source(struct dss_device *dss,
 	dss->lcd_clk_source[idx] = clk_src;
 }
 
-enum dss_clk_source dss_get_dispc_clk_source(void)
+enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss)
 {
-	return dss.dispc_clk_source;
+	return dss->dispc_clk_source;
 }
 
-enum dss_clk_source dss_get_dsi_clk_source(int dsi_module)
+enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
+					   int dsi_module)
 {
-	return dss.dsi_clk_source[dsi_module];
+	return dss->dsi_clk_source[dsi_module];
 }
 
-enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel)
+enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
+					   enum omap_channel channel)
 {
-	if (dss.feat->has_lcd_clk_src) {
+	if (dss->feat->has_lcd_clk_src) {
 		int idx = dss_get_channel_index(channel);
-		return dss.lcd_clk_source[idx];
+		return dss->lcd_clk_source[idx];
 	} else {
 		/* LCD_CLK source is the same as DISPC_FCLK source for
 		 * OMAP2 and OMAP3 */
-		return dss.dispc_clk_source;
+		return dss->dispc_clk_source;
 	}
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 05fba6b3400b..fdb51063c703 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -311,9 +311,11 @@ void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
 void dss_select_lcd_clk_source(struct dss_device *dss,
 			       enum omap_channel channel,
 			       enum dss_clk_source clk_src);
-enum dss_clk_source dss_get_dispc_clk_source(void);
-enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
-enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
+enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss);
+enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
+					   int dsi_module);
+enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
+					   enum omap_channel channel);
 
 void dss_set_venc_output(enum omap_dss_venc_type type);
 void dss_set_dac_pwrdn_bgz(bool enable);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (25 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:12   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
                   ` (24 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  8 ++++----
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 14 ++++++++------
 drivers/gpu/drm/omapdrm/dss/dss.c   | 37 ++++++++++++++++++-------------------
 drivers/gpu/drm/omapdrm/dss/dss.h   | 10 +++++-----
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  5 +++--
 5 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 723828f97196..7b74c8ee9372 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -3120,7 +3120,7 @@ static unsigned long dispc_fclk_rate(void)
 	src = dss_get_dispc_clk_source(dispc.dss);
 
 	if (src == DSS_CLK_SRC_FCK) {
-		r = dss_get_dispc_clk_rate();
+		r = dss_get_dispc_clk_rate(dispc.dss);
 	} else {
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
@@ -3147,7 +3147,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 	src = dss_get_lcd_clk_source(dispc.dss, channel);
 
 	if (src == DSS_CLK_SRC_FCK) {
-		r = dss_get_dispc_clk_rate();
+		r = dss_get_dispc_clk_rate(dispc.dss);
 	} else {
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
@@ -3505,7 +3505,7 @@ bool dispc_div_calc(unsigned long dispc_freq,
 	pckd_hw_min = dispc.feat->min_pcd;
 	pckd_hw_max = 255;
 
-	lck_max = dss_get_max_fck_rate();
+	lck_max = dss_get_max_fck_rate(dispc.dss);
 
 	pck_min = pck_min ? pck_min : 1;
 	pck_max = pck_max ? pck_max : ULONG_MAX;
@@ -4455,7 +4455,7 @@ static void dispc_errata_i734_wa(void)
 
 	/* Set up and enable display manager for LCD1 */
 	dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, &i734.mgri);
-	dispc_calc_clock_rates(dss_get_dispc_clk_rate(),
+	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
 			       &lcd_conf.clock_info);
 	dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, &lcd_conf);
 	dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, &i734.vm);
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 38a4c037783a..b0f890a3c8db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -209,7 +209,7 @@ static bool dpi_calc_pll_cb(int n, int m, unsigned long fint,
 	ctx->pll_cinfo.clkdco = clkdco;
 
 	return dss_pll_hsdiv_calc_a(ctx->pll, clkdco,
-		ctx->pck_min, dss_get_max_fck_rate(),
+		ctx->pck_min, dss_get_max_fck_rate(ctx->pll->dss),
 		dpi_calc_hsdiv_cb, ctx);
 }
 
@@ -258,7 +258,8 @@ static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck,
 	}
 }
 
-static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
+static bool dpi_dss_clk_calc(struct dpi_data *dpi, unsigned long pck,
+			     struct dpi_clk_calc_ctx *ctx)
 {
 	int i;
 
@@ -279,7 +280,8 @@ static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
 			ctx->pck_min = 0;
 		ctx->pck_max = pck + 1000 * i * i * i;
 
-		ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx);
+		ok = dss_div_calc(dpi->dss, pck, ctx->pck_min,
+				  dpi_calc_dss_cb, ctx);
 		if (ok)
 			return ok;
 	}
@@ -323,11 +325,11 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
 	int r;
 	bool ok;
 
-	ok = dpi_dss_clk_calc(pck_req, &ctx);
+	ok = dpi_dss_clk_calc(dpi, pck_req, &ctx);
 	if (!ok)
 		return -EINVAL;
 
-	r = dss_set_fck_rate(ctx.fck);
+	r = dss_set_fck_rate(dpi->dss, ctx.fck);
 	if (r)
 		return r;
 
@@ -532,7 +534,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
 
 		fck = ctx.pll_cinfo.clkout[ctx.clkout_idx];
 	} else {
-		ok = dpi_dss_clk_calc(vm->pixelclock, &ctx);
+		ok = dpi_dss_clk_calc(dpi, vm->pixelclock, &ctx);
 		if (!ok)
 			return -EINVAL;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index ba7a2bf1ec09..24237ed0557f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -634,8 +634,8 @@ enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
 	}
 }
 
-bool dss_div_calc(unsigned long pck, unsigned long fck_min,
-		dss_div_calc_func func, void *data)
+bool dss_div_calc(struct dss_device *dss, unsigned long pck,
+		  unsigned long fck_min, dss_div_calc_func func, void *data)
 {
 	int fckd, fckd_start, fckd_stop;
 	unsigned long fck;
@@ -644,24 +644,24 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
 	unsigned long prate;
 	unsigned int m;
 
-	fck_hw_max = dss.feat->fck_freq_max;
+	fck_hw_max = dss->feat->fck_freq_max;
 
-	if (dss.parent_clk == NULL) {
+	if (dss->parent_clk == NULL) {
 		unsigned int pckd;
 
 		pckd = fck_hw_max / pck;
 
 		fck = pck * pckd;
 
-		fck = clk_round_rate(dss.dss_clk, fck);
+		fck = clk_round_rate(dss->dss_clk, fck);
 
 		return func(fck, data);
 	}
 
-	fckd_hw_max = dss.feat->fck_div_max;
+	fckd_hw_max = dss->feat->fck_div_max;
 
-	m = dss.feat->dss_fck_multiplier;
-	prate = clk_get_rate(dss.parent_clk);
+	m = dss->feat->dss_fck_multiplier;
+	prate = clk_get_rate(dss->parent_clk);
 
 	fck_min = fck_min ? fck_min : 1;
 
@@ -678,33 +678,32 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
 	return false;
 }
 
-int dss_set_fck_rate(unsigned long rate)
+int dss_set_fck_rate(struct dss_device *dss, unsigned long rate)
 {
 	int r;
 
 	DSSDBG("set fck to %lu\n", rate);
 
-	r = clk_set_rate(dss.dss_clk, rate);
+	r = clk_set_rate(dss->dss_clk, rate);
 	if (r)
 		return r;
 
-	dss.dss_clk_rate = clk_get_rate(dss.dss_clk);
+	dss->dss_clk_rate = clk_get_rate(dss->dss_clk);
 
-	WARN_ONCE(dss.dss_clk_rate != rate,
-			"clk rate mismatch: %lu != %lu", dss.dss_clk_rate,
-			rate);
+	WARN_ONCE(dss->dss_clk_rate != rate, "clk rate mismatch: %lu != %lu",
+		  dss->dss_clk_rate, rate);
 
 	return 0;
 }
 
-unsigned long dss_get_dispc_clk_rate(void)
+unsigned long dss_get_dispc_clk_rate(struct dss_device *dss)
 {
-	return dss.dss_clk_rate;
+	return dss->dss_clk_rate;
 }
 
-unsigned long dss_get_max_fck_rate(void)
+unsigned long dss_get_max_fck_rate(struct dss_device *dss)
 {
-	return dss.feat->fck_freq_max;
+	return dss->feat->fck_freq_max;
 }
 
 enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel)
@@ -731,7 +730,7 @@ static int dss_setup_default_clock(void)
 		fck = DIV_ROUND_UP(prate, fck_div) * dss.feat->dss_fck_multiplier;
 	}
 
-	r = dss_set_fck_rate(fck);
+	r = dss_set_fck_rate(&dss, fck);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index fdb51063c703..cb257ffc8a54 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -284,8 +284,8 @@ struct dss_device *dss_get_device(struct device *dev);
 int dss_runtime_get(struct dss_device *dss);
 void dss_runtime_put(struct dss_device *dss);
 
-unsigned long dss_get_dispc_clk_rate(void);
-unsigned long dss_get_max_fck_rate(void);
+unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
+unsigned long dss_get_max_fck_rate(struct dss_device *dss);
 enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
 int dss_dpi_select_source(struct dss_device *dss, int port,
 			  enum omap_channel channel);
@@ -320,11 +320,11 @@ enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
 void dss_set_venc_output(enum omap_dss_venc_type type);
 void dss_set_dac_pwrdn_bgz(bool enable);
 
-int dss_set_fck_rate(unsigned long rate);
+int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
 
 typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
-bool dss_div_calc(unsigned long pck, unsigned long fck_min,
-		dss_div_calc_func func, void *data);
+bool dss_div_calc(struct dss_device *dss, unsigned long pck,
+		  unsigned long fck_min, dss_div_calc_func func, void *data);
 
 /* SDI */
 #ifdef CONFIG_OMAP2_DSS_SDI
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 39cb5c8af0dc..ac436826914a 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -101,7 +101,8 @@ static int sdi_calc_clock_div(unsigned long pclk,
 			ctx.pck_min = 0;
 		ctx.pck_max = pclk + 1000 * i * i * i;
 
-		ok = dss_div_calc(pclk, ctx.pck_min, dpi_calc_dss_cb, &ctx);
+		ok = dss_div_calc(sdi.dss, pclk, ctx.pck_min,
+				  dpi_calc_dss_cb, &ctx);
 		if (ok) {
 			*fck = ctx.fck;
 			*dispc_cinfo = ctx.dispc_cinfo;
@@ -171,7 +172,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 
 	dss_mgr_set_timings(channel, vm);
 
-	r = dss_set_fck_rate(fck);
+	r = dss_set_fck_rate(sdi.dss, fck);
 	if (r)
 		goto err_set_dss_clock_div;
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (26 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:15   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function Laurent Pinchart
                   ` (23 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/dss.c   |  9 +++++----
 drivers/gpu/drm/omapdrm/dss/dss.h   |  7 ++++---
 drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++++++----
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 7b74c8ee9372..912957c471ce 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2737,7 +2737,7 @@ static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
 
 static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel)
 {
-	return dss_get_supported_outputs(channel);
+	return dss_get_supported_outputs(dispc.dss, channel);
 }
 
 static void dispc_lcd_enable_signal_polarity(bool act_high)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 24237ed0557f..98a0da32f217 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -706,9 +706,10 @@ unsigned long dss_get_max_fck_rate(struct dss_device *dss)
 	return dss->feat->fck_freq_max;
 }
 
-enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel)
+enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
+						  enum omap_channel channel)
 {
-	return dss.feat->outputs[channel];
+	return dss->feat->outputs[channel];
 }
 
 static int dss_setup_default_clock(void)
@@ -737,7 +738,7 @@ static int dss_setup_default_clock(void)
 	return 0;
 }
 
-void dss_set_venc_output(enum omap_dss_venc_type type)
+void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type)
 {
 	int l = 0;
 
@@ -752,7 +753,7 @@ void dss_set_venc_output(enum omap_dss_venc_type type)
 	REG_FLD_MOD(DSS_CONTROL, l, 6, 6);
 }
 
-void dss_set_dac_pwrdn_bgz(bool enable)
+void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable)
 {
 	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index cb257ffc8a54..2641d5c6a32a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -286,7 +286,8 @@ void dss_runtime_put(struct dss_device *dss);
 
 unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
 unsigned long dss_get_max_fck_rate(struct dss_device *dss);
-enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
+enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
+						  enum omap_channel channel);
 int dss_dpi_select_source(struct dss_device *dss, int port,
 			  enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
@@ -317,8 +318,8 @@ enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
 enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
 					   enum omap_channel channel);
 
-void dss_set_venc_output(enum omap_dss_venc_type type);
-void dss_set_dac_pwrdn_bgz(bool enable);
+void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
+void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
 
 int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 68035c1acf1f..179ef73a5564 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -327,6 +327,7 @@ static struct {
 	struct mutex venc_lock;
 	u32 wss_data;
 	struct regulator *vdda_dac_reg;
+	struct dss_device *dss;
 
 	struct dss_debugfs_entry *debugfs;
 
@@ -472,8 +473,8 @@ static int venc_power_on(struct omap_dss_device *dssdev)
 	venc_reset();
 	venc_write_config(venc_timings_to_config(&venc.vm));
 
-	dss_set_venc_output(venc.type);
-	dss_set_dac_pwrdn_bgz(1);
+	dss_set_venc_output(venc.dss, venc.type);
+	dss_set_dac_pwrdn_bgz(venc.dss, 1);
 
 	l = 0;
 
@@ -503,7 +504,7 @@ static int venc_power_on(struct omap_dss_device *dssdev)
 	regulator_disable(venc.vdda_dac_reg);
 err1:
 	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-	dss_set_dac_pwrdn_bgz(0);
+	dss_set_dac_pwrdn_bgz(venc.dss, 0);
 
 	venc_runtime_put();
 err0:
@@ -515,7 +516,7 @@ static void venc_power_off(struct omap_dss_device *dssdev)
 	enum omap_channel channel = dssdev->dispc_channel;
 
 	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-	dss_set_dac_pwrdn_bgz(0);
+	dss_set_dac_pwrdn_bgz(venc.dss, 0);
 
 	dss_mgr_disable(channel);
 
@@ -876,11 +877,13 @@ static const struct soc_device_attribute venc_soc_devices[] = {
 static int venc_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
+	struct dss_device *dss = dss_get_device(master);
 	u8 rev_id;
 	struct resource *venc_mem;
 	int r;
 
 	venc.pdev = pdev;
+	venc.dss = dss;
 
 	/* The OMAP34xx, OMAP35xx and AM35xx VENC require the TV DAC clock. */
 	if (soc_device_match(venc_soc_devices))
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (27 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:16   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
                   ` (22 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The function is unused, remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 14 --------------
 drivers/gpu/drm/omapdrm/dss/dss.h |  1 -
 2 files changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 98a0da32f217..8b83bdcde6e2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -775,20 +775,6 @@ void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
 		REG_FLD_MOD(DSS_CONTROL, src, 15, 15);	/* VENC_HDMI_SWITCH */
 }
 
-enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
-{
-	enum omap_dss_output_id outputs;
-
-	outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
-	if ((outputs & OMAP_DSS_OUTPUT_HDMI) == 0)
-		return DSS_VENC_TV_CLK;
-
-	if ((outputs & OMAP_DSS_OUTPUT_VENC) == 0)
-		return DSS_HDMI_M_PCLK;
-
-	return REG_GET(DSS_CONTROL, 15, 15);
-}
-
 static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
 					     enum omap_channel channel)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 2641d5c6a32a..6950f5d61b6c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -292,7 +292,6 @@ int dss_dpi_select_source(struct dss_device *dss, int port,
 			  enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
 				     enum dss_hdmi_venc_clk_source_select src);
-enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
 
 /* DSS VIDEO PLL */
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (28 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16  9:39   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
                   ` (21 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The DSS private data structure is currently stored as a global variable.
While no platform with multiple DSS devices currently exists nor is
planned, this doesn't comply with the kernel device model and should
thus be fixed.

As a first step to the fix, allocate the DSS private data structure
dynamically for each DSS instance. The pointer still needs to be stored
in a global variable as many functions exposed outside of the dss module
don't have access to the DSS private data structure. This will be fixed
in subsequent steps.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 385 +++++++++++++++++++++-----------------
 1 file changed, 209 insertions(+), 176 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 8b83bdcde6e2..8fec9bf6f06f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -67,11 +67,12 @@ struct dss_reg {
 #define DSS_PLL_CONTROL			DSS_REG(0x0048)
 #define DSS_SDI_STATUS			DSS_REG(0x005C)
 
-#define REG_GET(idx, start, end) \
-	FLD_GET(dss_read_reg(idx), start, end)
+#define REG_GET(dss, idx, start, end) \
+	FLD_GET(dss_read_reg(dss, idx), start, end)
 
-#define REG_FLD_MOD(idx, val, start, end) \
-	dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
+#define REG_FLD_MOD(dss, idx, val, start, end) \
+	dss_write_reg(dss, idx, \
+		      FLD_MOD(dss_read_reg(dss, idx), val, start, end))
 
 struct dss_ops {
 	int (*dpi_select_source)(struct dss_device *dss, int port,
@@ -129,8 +130,6 @@ struct dss_device {
 	struct dss_pll	*video2_pll;
 };
 
-static struct dss_device dss;
-
 static const char * const dss_generic_clk_source_names[] = {
 	[DSS_CLK_SRC_FCK]	= "FCK",
 	[DSS_CLK_SRC_PLL1_1]	= "PLL1:1",
@@ -142,49 +141,50 @@ static const char * const dss_generic_clk_source_names[] = {
 	[DSS_CLK_SRC_HDMI_PLL]	= "HDMI PLL",
 };
 
-static inline void dss_write_reg(const struct dss_reg idx, u32 val)
+static inline void dss_write_reg(struct dss_device *dss,
+				 const struct dss_reg idx, u32 val)
 {
-	__raw_writel(val, dss.base + idx.idx);
+	__raw_writel(val, dss->base + idx.idx);
 }
 
-static inline u32 dss_read_reg(const struct dss_reg idx)
+static inline u32 dss_read_reg(struct dss_device *dss, const struct dss_reg idx)
 {
-	return __raw_readl(dss.base + idx.idx);
+	return __raw_readl(dss->base + idx.idx);
 }
 
-#define SR(reg) \
-	dss.ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(DSS_##reg)
-#define RR(reg) \
-	dss_write_reg(DSS_##reg, dss.ctx[(DSS_##reg).idx / sizeof(u32)])
+#define SR(dss, reg) \
+	dss->ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(dss, DSS_##reg)
+#define RR(dss, reg) \
+	dss_write_reg(dss, DSS_##reg, dss->ctx[(DSS_##reg).idx / sizeof(u32)])
 
-static void dss_save_context(void)
+static void dss_save_context(struct dss_device *dss)
 {
 	DSSDBG("dss_save_context\n");
 
-	SR(CONTROL);
+	SR(dss, CONTROL);
 
-	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
-		SR(SDI_CONTROL);
-		SR(PLL_CONTROL);
+	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
+		SR(dss, SDI_CONTROL);
+		SR(dss, PLL_CONTROL);
 	}
 
-	dss.ctx_valid = true;
+	dss->ctx_valid = true;
 
 	DSSDBG("context saved\n");
 }
 
-static void dss_restore_context(void)
+static void dss_restore_context(struct dss_device *dss)
 {
 	DSSDBG("dss_restore_context\n");
 
-	if (!dss.ctx_valid)
+	if (!dss->ctx_valid)
 		return;
 
-	RR(CONTROL);
+	RR(dss, CONTROL);
 
-	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
-		RR(SDI_CONTROL);
-		RR(PLL_CONTROL);
+	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
+		RR(dss, SDI_CONTROL);
+		RR(dss, PLL_CONTROL);
 	}
 
 	DSSDBG("context restored\n");
@@ -223,12 +223,13 @@ void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
 			   1 << shift, val << shift);
 }
 
-static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
-	enum omap_channel channel)
+static int dss_ctrl_pll_set_control_mux(struct dss_device *dss,
+					enum dss_clk_source clk_src,
+					enum omap_channel channel)
 {
 	unsigned int shift, val;
 
-	if (!dss.syscon_pll_ctrl)
+	if (!dss->syscon_pll_ctrl)
 		return -EINVAL;
 
 	switch (channel) {
@@ -283,7 +284,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
 		return -EINVAL;
 	}
 
-	regmap_update_bits(dss.syscon_pll_ctrl, dss.syscon_pll_ctrl_offset,
+	regmap_update_bits(dss->syscon_pll_ctrl, dss->syscon_pll_ctrl_offset,
 		0x3 << shift, val << shift);
 
 	return 0;
@@ -295,17 +296,17 @@ void dss_sdi_init(struct dss_device *dss, int datapairs)
 
 	BUG_ON(datapairs > 3 || datapairs < 1);
 
-	l = dss_read_reg(DSS_SDI_CONTROL);
+	l = dss_read_reg(dss, DSS_SDI_CONTROL);
 	l = FLD_MOD(l, 0xf, 19, 15);		/* SDI_PDIV */
 	l = FLD_MOD(l, datapairs-1, 3, 2);	/* SDI_PRSEL */
 	l = FLD_MOD(l, 2, 1, 0);		/* SDI_BWSEL */
-	dss_write_reg(DSS_SDI_CONTROL, l);
+	dss_write_reg(dss, DSS_SDI_CONTROL, l);
 
-	l = dss_read_reg(DSS_PLL_CONTROL);
+	l = dss_read_reg(dss, DSS_PLL_CONTROL);
 	l = FLD_MOD(l, 0x7, 25, 22);	/* SDI_PLL_FREQSEL */
 	l = FLD_MOD(l, 0xb, 16, 11);	/* SDI_PLL_REGN */
 	l = FLD_MOD(l, 0xb4, 10, 1);	/* SDI_PLL_REGM */
-	dss_write_reg(DSS_PLL_CONTROL, l);
+	dss_write_reg(dss, DSS_PLL_CONTROL, l);
 }
 
 int dss_sdi_enable(struct dss_device *dss)
@@ -315,15 +316,15 @@ int dss_sdi_enable(struct dss_device *dss)
 	dispc_pck_free_enable(1);
 
 	/* Reset SDI PLL */
-	REG_FLD_MOD(DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
+	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
 	udelay(1);	/* wait 2x PCLK */
 
 	/* Lock SDI PLL */
-	REG_FLD_MOD(DSS_PLL_CONTROL, 1, 28, 28); /* SDI_PLL_GOBIT */
+	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 28, 28); /* SDI_PLL_GOBIT */
 
 	/* Waiting for PLL lock request to complete */
 	timeout = jiffies + msecs_to_jiffies(500);
-	while (dss_read_reg(DSS_SDI_STATUS) & (1 << 6)) {
+	while (dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 6)) {
 		if (time_after_eq(jiffies, timeout)) {
 			DSSERR("PLL lock request timed out\n");
 			goto err1;
@@ -331,11 +332,11 @@ int dss_sdi_enable(struct dss_device *dss)
 	}
 
 	/* Clearing PLL_GO bit */
-	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 28, 28);
+	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 28, 28);
 
 	/* Waiting for PLL to lock */
 	timeout = jiffies + msecs_to_jiffies(500);
-	while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 5))) {
+	while (!(dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 5))) {
 		if (time_after_eq(jiffies, timeout)) {
 			DSSERR("PLL lock timed out\n");
 			goto err1;
@@ -346,7 +347,7 @@ int dss_sdi_enable(struct dss_device *dss)
 
 	/* Waiting for SDI reset to complete */
 	timeout = jiffies + msecs_to_jiffies(500);
-	while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 2))) {
+	while (!(dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 2))) {
 		if (time_after_eq(jiffies, timeout)) {
 			DSSERR("SDI reset timed out\n");
 			goto err2;
@@ -359,7 +360,7 @@ int dss_sdi_enable(struct dss_device *dss)
 	dispc_lcd_enable_signal(0);
  err1:
 	/* Reset SDI PLL */
-	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
+	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
 
 	dispc_pck_free_enable(0);
 
@@ -373,7 +374,7 @@ void dss_sdi_disable(struct dss_device *dss)
 	dispc_pck_free_enable(0);
 
 	/* Reset SDI PLL */
-	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
+	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
 }
 
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
@@ -382,46 +383,48 @@ const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
 }
 
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
-static void dss_dump_clocks(struct seq_file *s)
+static void dss_dump_clocks(struct dss_device *dss, struct seq_file *s)
 {
 	const char *fclk_name;
 	unsigned long fclk_rate;
 
-	if (dss_runtime_get(&dss))
+	if (dss_runtime_get(dss))
 		return;
 
 	seq_printf(s, "- DSS -\n");
 
 	fclk_name = dss_get_clk_source_name(DSS_CLK_SRC_FCK);
-	fclk_rate = clk_get_rate(dss.dss_clk);
+	fclk_rate = clk_get_rate(dss->dss_clk);
 
 	seq_printf(s, "%s = %lu\n",
 			fclk_name,
 			fclk_rate);
 
-	dss_runtime_put(&dss);
+	dss_runtime_put(dss);
 }
 #endif
 
 static int dss_dump_regs(struct seq_file *s, void *p)
 {
-#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
+	struct dss_device *dss = s->private;
+
+#define DUMPREG(dss, r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(dss, r))
 
-	if (dss_runtime_get(&dss))
+	if (dss_runtime_get(dss))
 		return 0;
 
-	DUMPREG(DSS_REVISION);
-	DUMPREG(DSS_SYSCONFIG);
-	DUMPREG(DSS_SYSSTATUS);
-	DUMPREG(DSS_CONTROL);
+	DUMPREG(dss, DSS_REVISION);
+	DUMPREG(dss, DSS_SYSCONFIG);
+	DUMPREG(dss, DSS_SYSSTATUS);
+	DUMPREG(dss, DSS_CONTROL);
 
-	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
-		DUMPREG(DSS_SDI_CONTROL);
-		DUMPREG(DSS_PLL_CONTROL);
-		DUMPREG(DSS_SDI_STATUS);
+	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
+		DUMPREG(dss, DSS_SDI_CONTROL);
+		DUMPREG(dss, DSS_PLL_CONTROL);
+		DUMPREG(dss, DSS_SDI_STATUS);
 	}
 
-	dss_runtime_put(&dss);
+	dss_runtime_put(dss);
 #undef DUMPREG
 	return 0;
 }
@@ -441,7 +444,8 @@ static int dss_get_channel_index(enum omap_channel channel)
 	}
 }
 
-static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
+static void dss_select_dispc_clk_source(struct dss_device *dss,
+					enum dss_clk_source clk_src)
 {
 	int b;
 
@@ -449,7 +453,7 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
 	 * We always use PRCM clock as the DISPC func clock, except on DSS3,
 	 * where we don't have separate DISPC and LCD clock sources.
 	 */
-	if (WARN_ON(dss.feat->has_lcd_clk_src && clk_src != DSS_CLK_SRC_FCK))
+	if (WARN_ON(dss->feat->has_lcd_clk_src && clk_src != DSS_CLK_SRC_FCK))
 		return;
 
 	switch (clk_src) {
@@ -467,11 +471,11 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
 		return;
 	}
 
-	REG_FLD_MOD(DSS_CONTROL, b,			/* DISPC_CLK_SWITCH */
-		    dss.feat->dispc_clk_switch.start,
-		    dss.feat->dispc_clk_switch.end);
+	REG_FLD_MOD(dss, DSS_CONTROL, b,		/* DISPC_CLK_SWITCH */
+		    dss->feat->dispc_clk_switch.start,
+		    dss->feat->dispc_clk_switch.end);
 
-	dss.dispc_clk_source = clk_src;
+	dss->dispc_clk_source = clk_src;
 }
 
 void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
@@ -497,7 +501,7 @@ void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
 	}
 
 	pos = dsi_module == 0 ? 1 : 10;
-	REG_FLD_MOD(DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
+	REG_FLD_MOD(dss, DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
 
 	dss->dsi_clk_source[dsi_module] = clk_src;
 }
@@ -517,15 +521,15 @@ static int dss_lcd_clk_mux_dra7(struct dss_device *dss,
 
 	if (clk_src == DSS_CLK_SRC_FCK) {
 		/* LCDx_CLK_SWITCH */
-		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
+		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
 		return -EINVAL;
 	}
 
-	r = dss_ctrl_pll_set_control_mux(clk_src, channel);
+	r = dss_ctrl_pll_set_control_mux(dss, clk_src, channel);
 	if (r)
 		return r;
 
-	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
+	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
 
 	return 0;
 }
@@ -549,14 +553,14 @@ static int dss_lcd_clk_mux_omap5(struct dss_device *dss,
 
 	if (clk_src == DSS_CLK_SRC_FCK) {
 		/* LCDx_CLK_SWITCH */
-		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
+		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
 		return -EINVAL;
 	}
 
 	if (WARN_ON(allowed_plls[channel] != clk_src))
 		return -EINVAL;
 
-	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
+	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
 
 	return 0;
 }
@@ -578,14 +582,14 @@ static int dss_lcd_clk_mux_omap4(struct dss_device *dss,
 
 	if (clk_src == DSS_CLK_SRC_FCK) {
 		/* LCDx_CLK_SWITCH */
-		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
+		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
 		return 0;
 	}
 
 	if (WARN_ON(allowed_plls[channel] != clk_src))
 		return -EINVAL;
 
-	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
+	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
 
 	return 0;
 }
@@ -598,7 +602,7 @@ void dss_select_lcd_clk_source(struct dss_device *dss,
 	int r;
 
 	if (!dss->feat->has_lcd_clk_src) {
-		dss_select_dispc_clk_source(clk_src);
+		dss_select_dispc_clk_source(dss, clk_src);
 		dss->lcd_clk_source[idx] = clk_src;
 		return;
 	}
@@ -712,26 +716,26 @@ enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
 	return dss->feat->outputs[channel];
 }
 
-static int dss_setup_default_clock(void)
+static int dss_setup_default_clock(struct dss_device *dss)
 {
 	unsigned long max_dss_fck, prate;
 	unsigned long fck;
 	unsigned int fck_div;
 	int r;
 
-	max_dss_fck = dss.feat->fck_freq_max;
+	max_dss_fck = dss->feat->fck_freq_max;
 
-	if (dss.parent_clk == NULL) {
-		fck = clk_round_rate(dss.dss_clk, max_dss_fck);
+	if (dss->parent_clk == NULL) {
+		fck = clk_round_rate(dss->dss_clk, max_dss_fck);
 	} else {
-		prate = clk_get_rate(dss.parent_clk);
+		prate = clk_get_rate(dss->parent_clk);
 
-		fck_div = DIV_ROUND_UP(prate * dss.feat->dss_fck_multiplier,
+		fck_div = DIV_ROUND_UP(prate * dss->feat->dss_fck_multiplier,
 				max_dss_fck);
-		fck = DIV_ROUND_UP(prate, fck_div) * dss.feat->dss_fck_multiplier;
+		fck = DIV_ROUND_UP(prate, fck_div) * dss->feat->dss_fck_multiplier;
 	}
 
-	r = dss_set_fck_rate(&dss, fck);
+	r = dss_set_fck_rate(dss, fck);
 	if (r)
 		return r;
 
@@ -750,12 +754,13 @@ void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type)
 		BUG();
 
 	/* venc out selection. 0 = comp, 1 = svideo */
-	REG_FLD_MOD(DSS_CONTROL, l, 6, 6);
+	REG_FLD_MOD(dss, DSS_CONTROL, l, 6, 6);
 }
 
 void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable)
 {
-	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
+	/* DAC Power-Down Control */
+	REG_FLD_MOD(dss, DSS_CONTROL, enable, 5, 5);
 }
 
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
@@ -772,7 +777,8 @@ void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
 	/* Select only if we have options */
 	if ((outputs & OMAP_DSS_OUTPUT_VENC) &&
 	    (outputs & OMAP_DSS_OUTPUT_HDMI))
-		REG_FLD_MOD(DSS_CONTROL, src, 15, 15);	/* VENC_HDMI_SWITCH */
+		/* VENC_HDMI_SWITCH */
+		REG_FLD_MOD(dss, DSS_CONTROL, src, 15, 15);
 }
 
 static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
@@ -800,7 +806,7 @@ static int dss_dpi_select_source_omap4(struct dss_device *dss, int port,
 		return -EINVAL;
 	}
 
-	REG_FLD_MOD(DSS_CONTROL, val, 17, 17);
+	REG_FLD_MOD(dss, DSS_CONTROL, val, 17, 17);
 
 	return 0;
 }
@@ -827,7 +833,7 @@ static int dss_dpi_select_source_omap5(struct dss_device *dss, int port,
 		return -EINVAL;
 	}
 
-	REG_FLD_MOD(DSS_CONTROL, val, 17, 16);
+	REG_FLD_MOD(dss, DSS_CONTROL, val, 17, 16);
 
 	return 0;
 }
@@ -859,37 +865,37 @@ int dss_dpi_select_source(struct dss_device *dss, int port,
 	return dss->feat->ops->dpi_select_source(dss, port, channel);
 }
 
-static int dss_get_clocks(void)
+static int dss_get_clocks(struct dss_device *dss)
 {
 	struct clk *clk;
 
-	clk = devm_clk_get(&dss.pdev->dev, "fck");
+	clk = devm_clk_get(&dss->pdev->dev, "fck");
 	if (IS_ERR(clk)) {
 		DSSERR("can't get clock fck\n");
 		return PTR_ERR(clk);
 	}
 
-	dss.dss_clk = clk;
+	dss->dss_clk = clk;
 
-	if (dss.feat->parent_clk_name) {
-		clk = clk_get(NULL, dss.feat->parent_clk_name);
+	if (dss->feat->parent_clk_name) {
+		clk = clk_get(NULL, dss->feat->parent_clk_name);
 		if (IS_ERR(clk)) {
-			DSSERR("Failed to get %s\n", dss.feat->parent_clk_name);
+			DSSERR("Failed to get %s\n", dss->feat->parent_clk_name);
 			return PTR_ERR(clk);
 		}
 	} else {
 		clk = NULL;
 	}
 
-	dss.parent_clk = clk;
+	dss->parent_clk = clk;
 
 	return 0;
 }
 
-static void dss_put_clocks(void)
+static void dss_put_clocks(struct dss_device *dss)
 {
-	if (dss.parent_clk)
-		clk_put(dss.parent_clk);
+	if (dss->parent_clk)
+		clk_put(dss->parent_clk);
 }
 
 int dss_runtime_get(struct dss_device *dss)
@@ -915,14 +921,16 @@ void dss_runtime_put(struct dss_device *dss)
 
 struct dss_device *dss_get_device(struct device *dev)
 {
-	return &dss;
+	return dev_get_drvdata(dev);
 }
 
 /* DEBUGFS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
 static int dss_debug_dump_clocks(struct seq_file *s, void *p)
 {
-	dss_dump_clocks(s);
+	struct dss_device *dss = s->private;
+
+	dss_dump_clocks(dss, s);
 	dispc_dump_clocks(s);
 #ifdef CONFIG_OMAP2_DSS_DSI
 	dsi_dump_clocks(s);
@@ -932,7 +940,7 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
 
 static struct dentry *dss_debugfs_dir;
 
-static int dss_initialize_debugfs(void)
+static int dss_initialize_debugfs(struct dss_device *dss)
 {
 	dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
 	if (IS_ERR(dss_debugfs_dir)) {
@@ -1005,7 +1013,7 @@ void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
 }
 
 #else /* CONFIG_OMAP2_DSS_DEBUGFS */
-static inline int dss_initialize_debugfs(void)
+static inline int dss_initialize_debugfs(struct dss_device *dss)
 {
 	return 0;
 }
@@ -1210,23 +1218,24 @@ static const struct dss_features dra7xx_dss_feats = {
 	.has_lcd_clk_src	=	true,
 };
 
-static int dss_init_ports(struct platform_device *pdev)
+static int dss_init_ports(struct dss_device *dss)
 {
+	struct platform_device *pdev = dss->pdev;
 	struct device_node *parent = pdev->dev.of_node;
 	struct device_node *port;
 	int i;
 
-	for (i = 0; i < dss.feat->num_ports; i++) {
+	for (i = 0; i < dss->feat->num_ports; i++) {
 		port = of_graph_get_port_by_id(parent, i);
 		if (!port)
 			continue;
 
-		switch (dss.feat->ports[i]) {
+		switch (dss->feat->ports[i]) {
 		case OMAP_DISPLAY_TYPE_DPI:
-			dpi_init_port(&dss, pdev, port, dss.feat->model);
+			dpi_init_port(dss, pdev, port, dss->feat->model);
 			break;
 		case OMAP_DISPLAY_TYPE_SDI:
-			sdi_init_port(&dss, pdev, port);
+			sdi_init_port(dss, pdev, port);
 			break;
 		default:
 			break;
@@ -1236,18 +1245,19 @@ static int dss_init_ports(struct platform_device *pdev)
 	return 0;
 }
 
-static void dss_uninit_ports(struct platform_device *pdev)
+static void dss_uninit_ports(struct dss_device *dss)
 {
+	struct platform_device *pdev = dss->pdev;
 	struct device_node *parent = pdev->dev.of_node;
 	struct device_node *port;
 	int i;
 
-	for (i = 0; i < dss.feat->num_ports; i++) {
+	for (i = 0; i < dss->feat->num_ports; i++) {
 		port = of_graph_get_port_by_id(parent, i);
 		if (!port)
 			continue;
 
-		switch (dss.feat->ports[i]) {
+		switch (dss->feat->ports[i]) {
 		case OMAP_DISPLAY_TYPE_DPI:
 			dpi_uninit_port(port);
 			break;
@@ -1260,8 +1270,9 @@ static void dss_uninit_ports(struct platform_device *pdev)
 	}
 }
 
-static int dss_video_pll_probe(struct platform_device *pdev)
+static int dss_video_pll_probe(struct dss_device *dss)
 {
+	struct platform_device *pdev = dss->pdev;
 	struct device_node *np = pdev->dev.of_node;
 	struct regulator *pll_regulator;
 	int r;
@@ -1270,16 +1281,16 @@ static int dss_video_pll_probe(struct platform_device *pdev)
 		return 0;
 
 	if (of_property_read_bool(np, "syscon-pll-ctrl")) {
-		dss.syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np,
+		dss->syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np,
 			"syscon-pll-ctrl");
-		if (IS_ERR(dss.syscon_pll_ctrl)) {
+		if (IS_ERR(dss->syscon_pll_ctrl)) {
 			dev_err(&pdev->dev,
 				"failed to get syscon-pll-ctrl regmap\n");
-			return PTR_ERR(dss.syscon_pll_ctrl);
+			return PTR_ERR(dss->syscon_pll_ctrl);
 		}
 
 		if (of_property_read_u32_index(np, "syscon-pll-ctrl", 1,
-				&dss.syscon_pll_ctrl_offset)) {
+				&dss->syscon_pll_ctrl_offset)) {
 			dev_err(&pdev->dev,
 				"failed to get syscon-pll-ctrl offset\n");
 			return -EINVAL;
@@ -1305,18 +1316,18 @@ static int dss_video_pll_probe(struct platform_device *pdev)
 	}
 
 	if (of_property_match_string(np, "reg-names", "pll1") >= 0) {
-		dss.video1_pll = dss_video_pll_init(&dss, pdev, 0,
-						    pll_regulator);
-		if (IS_ERR(dss.video1_pll))
-			return PTR_ERR(dss.video1_pll);
+		dss->video1_pll = dss_video_pll_init(dss, pdev, 0,
+						     pll_regulator);
+		if (IS_ERR(dss->video1_pll))
+			return PTR_ERR(dss->video1_pll);
 	}
 
 	if (of_property_match_string(np, "reg-names", "pll2") >= 0) {
-		dss.video2_pll = dss_video_pll_init(&dss, pdev, 1,
-						    pll_regulator);
-		if (IS_ERR(dss.video2_pll)) {
-			dss_video_pll_uninit(dss.video1_pll);
-			return PTR_ERR(dss.video2_pll);
+		dss->video2_pll = dss_video_pll_init(dss, pdev, 1,
+						     pll_regulator);
+		if (IS_ERR(dss->video2_pll)) {
+			dss_video_pll_uninit(dss->video1_pll);
+			return PTR_ERR(dss->video2_pll);
 		}
 	}
 
@@ -1344,117 +1355,119 @@ static const struct soc_device_attribute dss_soc_devices[] = {
 static int dss_bind(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
+	struct dss_device *dss = dev_get_drvdata(dev);
 	struct resource *dss_mem;
 	u32 rev;
 	int r;
 
-	dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0);
-	dss.base = devm_ioremap_resource(&pdev->dev, dss_mem);
-	if (IS_ERR(dss.base))
-		return PTR_ERR(dss.base);
+	dss_mem = platform_get_resource(dss->pdev, IORESOURCE_MEM, 0);
+	dss->base = devm_ioremap_resource(&pdev->dev, dss_mem);
+	if (IS_ERR(dss->base))
+		return PTR_ERR(dss->base);
 
-	r = dss_get_clocks();
+	r = dss_get_clocks(dss);
 	if (r)
 		return r;
 
-	r = dss_setup_default_clock();
+	r = dss_setup_default_clock(dss);
 	if (r)
 		goto err_setup_clocks;
 
-	r = dss_video_pll_probe(pdev);
+	r = dss_video_pll_probe(dss);
 	if (r)
 		goto err_pll_init;
 
-	r = dss_init_ports(pdev);
+	r = dss_init_ports(dss);
 	if (r)
 		goto err_init_ports;
 
 	pm_runtime_enable(&pdev->dev);
 
-	r = dss_runtime_get(&dss);
+	r = dss_runtime_get(dss);
 	if (r)
 		goto err_runtime_get;
 
-	dss.dss_clk_rate = clk_get_rate(dss.dss_clk);
+	dss->dss_clk_rate = clk_get_rate(dss->dss_clk);
 
 	/* Select DPLL */
-	REG_FLD_MOD(DSS_CONTROL, 0, 0, 0);
+	REG_FLD_MOD(dss, DSS_CONTROL, 0, 0, 0);
 
-	dss_select_dispc_clk_source(DSS_CLK_SRC_FCK);
+	dss_select_dispc_clk_source(dss, DSS_CLK_SRC_FCK);
 
 #ifdef CONFIG_OMAP2_DSS_VENC
-	REG_FLD_MOD(DSS_CONTROL, 1, 4, 4);	/* venc dac demen */
-	REG_FLD_MOD(DSS_CONTROL, 1, 3, 3);	/* venc clock 4x enable */
-	REG_FLD_MOD(DSS_CONTROL, 0, 2, 2);	/* venc clock mode = normal */
+	REG_FLD_MOD(dss, DSS_CONTROL, 1, 4, 4);	/* venc dac demen */
+	REG_FLD_MOD(dss, DSS_CONTROL, 1, 3, 3);	/* venc clock 4x enable */
+	REG_FLD_MOD(dss, DSS_CONTROL, 0, 2, 2);	/* venc clock mode = normal */
 #endif
-	dss.dsi_clk_source[0] = DSS_CLK_SRC_FCK;
-	dss.dsi_clk_source[1] = DSS_CLK_SRC_FCK;
-	dss.dispc_clk_source = DSS_CLK_SRC_FCK;
-	dss.lcd_clk_source[0] = DSS_CLK_SRC_FCK;
-	dss.lcd_clk_source[1] = DSS_CLK_SRC_FCK;
+	dss->dsi_clk_source[0] = DSS_CLK_SRC_FCK;
+	dss->dsi_clk_source[1] = DSS_CLK_SRC_FCK;
+	dss->dispc_clk_source = DSS_CLK_SRC_FCK;
+	dss->lcd_clk_source[0] = DSS_CLK_SRC_FCK;
+	dss->lcd_clk_source[1] = DSS_CLK_SRC_FCK;
 
-	rev = dss_read_reg(DSS_REVISION);
+	rev = dss_read_reg(dss, DSS_REVISION);
 	pr_info("OMAP DSS rev %d.%d\n", FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
-	dss_runtime_put(&dss);
+	dss_runtime_put(dss);
 
 	r = component_bind_all(&pdev->dev, NULL);
 	if (r)
 		goto err_component;
 
-	dss.debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
-						  &dss);
-	dss.debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, &dss);
+	dss->debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
+						   dss);
+	dss->debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, dss);
 
 	pm_set_vt_switch(0);
 
 	omapdss_gather_components(dev);
 
-	r = omapdrm_init(&dss.drm, dev);
+	r = omapdrm_init(&dss->drm, dev);
 	if (r)
 		goto err_drm_init;
 
 	return 0;
 
 err_drm_init:
-	dss_debugfs_remove_file(dss.debugfs.clk);
-	dss_debugfs_remove_file(dss.debugfs.dss);
+	dss_debugfs_remove_file(dss->debugfs.clk);
+	dss_debugfs_remove_file(dss->debugfs.dss);
 	component_unbind_all(&pdev->dev, NULL);
 err_component:
 err_runtime_get:
 	pm_runtime_disable(&pdev->dev);
-	dss_uninit_ports(pdev);
+	dss_uninit_ports(dss);
 err_init_ports:
-	if (dss.video1_pll)
-		dss_video_pll_uninit(dss.video1_pll);
+	if (dss->video1_pll)
+		dss_video_pll_uninit(dss->video1_pll);
 
-	if (dss.video2_pll)
-		dss_video_pll_uninit(dss.video2_pll);
+	if (dss->video2_pll)
+		dss_video_pll_uninit(dss->video2_pll);
 err_pll_init:
 err_setup_clocks:
-	dss_put_clocks();
+	dss_put_clocks(dss);
 	return r;
 }
 
 static void dss_unbind(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
+	struct dss_device *dss = dev_get_drvdata(dev);
 
-	omapdrm_cleanup(&dss.drm);
+	omapdrm_cleanup(&dss->drm);
 
 	component_unbind_all(&pdev->dev, NULL);
 
-	if (dss.video1_pll)
-		dss_video_pll_uninit(dss.video1_pll);
+	if (dss->video1_pll)
+		dss_video_pll_uninit(dss->video1_pll);
 
-	if (dss.video2_pll)
-		dss_video_pll_uninit(dss.video2_pll);
+	if (dss->video2_pll)
+		dss_video_pll_uninit(dss->video2_pll);
 
-	dss_uninit_ports(pdev);
+	dss_uninit_ports(dss);
 
 	pm_runtime_disable(&pdev->dev);
 
-	dss_put_clocks();
+	dss_put_clocks(dss);
 }
 
 static const struct component_master_ops dss_component_ops = {
@@ -1490,14 +1503,20 @@ static int dss_probe(struct platform_device *pdev)
 {
 	const struct soc_device_attribute *soc;
 	struct component_match *match = NULL;
+	struct dss_device *dss;
 	int r;
 
-	dss.pdev = pdev;
+	dss = kzalloc(sizeof(*dss), GFP_KERNEL);
+	if (!dss)
+		return -ENOMEM;
+
+	dss->pdev = pdev;
+	platform_set_drvdata(pdev, dss);
 
 	r = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
 	if (r) {
 		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
-		return r;
+		goto err_free_dss;
 	}
 
 	/*
@@ -1506,31 +1525,38 @@ static int dss_probe(struct platform_device *pdev)
 	 */
 	soc = soc_device_match(dss_soc_devices);
 	if (soc)
-		dss.feat = soc->data;
+		dss->feat = soc->data;
 	else
-		dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
+		dss->feat = of_match_device(dss_of_match, &pdev->dev)->data;
 
-	r = dss_initialize_debugfs();
+	r = dss_initialize_debugfs(dss);
 	if (r)
-		return r;
+		goto err_free_dss;
 
 	/* add all the child devices as components */
 	device_for_each_child(&pdev->dev, &match, dss_add_child_component);
 
 	r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match);
-	if (r) {
-		dss_uninitialize_debugfs();
-		return r;
-	}
+	if (r)
+		goto err_debugfs;
 
 	return 0;
+
+err_debugfs:
+	dss_uninitialize_debugfs();
+err_free_dss:
+	kfree(dss);
+	return r;
 }
 
 static int dss_remove(struct platform_device *pdev)
 {
+	struct dss_device *dss = platform_get_drvdata(pdev);
+
 	component_master_del(&pdev->dev, &dss_component_ops);
 
 	dss_uninitialize_debugfs();
+	kfree(dss);
 
 	return 0;
 }
@@ -1552,7 +1578,9 @@ static void dss_shutdown(struct platform_device *pdev)
 
 static int dss_runtime_suspend(struct device *dev)
 {
-	dss_save_context();
+	struct dss_device *dss = dev_get_drvdata(dev);
+
+	dss_save_context(dss);
 	dss_set_min_bus_tput(dev, 0);
 
 	pinctrl_pm_select_sleep_state(dev);
@@ -1562,6 +1590,7 @@ static int dss_runtime_suspend(struct device *dev)
 
 static int dss_runtime_resume(struct device *dev)
 {
+	struct dss_device *dss = dev_get_drvdata(dev);
 	int r;
 
 	pinctrl_pm_select_default_state(dev);
@@ -1577,18 +1606,22 @@ static int dss_runtime_resume(struct device *dev)
 	if (r)
 		return r;
 
-	dss_restore_context();
+	dss_restore_context(dss);
 	return 0;
 }
 
 static int dss_suspend(struct device *dev)
 {
-	return omap_drm_suspend(&dss.drm);
+	struct dss_device *dss = dev_get_drvdata(dev);
+
+	return omap_drm_suspend(&dss->drm);
 }
 
 static int dss_resume(struct device *dev)
 {
-	return omap_drm_resume(&dss.drm);
+	struct dss_device *dss = dev_get_drvdata(dev);
+
+	return omap_drm_resume(&dss->drm);
 }
 
 static const struct dev_pm_ops dss_pm_ops = {
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (29 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-16 10:19   ` Sebastian Reichel
  2017-10-16 10:27   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 32/48] drm: omapdrm: hdmi5: " Laurent Pinchart
                   ` (20 subsequent siblings)
  51 siblings, 2 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_hdmi private data structure is currently stored as a global
variable. While no platform with multiple HDMI4 encoders currently
exists nor is planned, this doesn't comply with the kernel device model
and should thus be fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/hdmi.h       |   2 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c      | 337 +++++++++++++++++--------------
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c  |   4 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4_core.h |   4 +-
 4 files changed, 188 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index fa2fbdaa427c..3aeb4cabd59f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -389,4 +389,6 @@ struct omap_hdmi {
 	bool display_enabled;
 };
 
+#define dssdev_to_hdmi(dssdev) container_of(dssdev, struct omap_hdmi, output)
+
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 5806587fd89a..f0a30b248a7d 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -44,15 +44,13 @@
 #include "dss.h"
 #include "hdmi.h"
 
-static struct omap_hdmi hdmi;
-
-static int hdmi_runtime_get(void)
+static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 {
 	int r;
 
 	DSSDBG("hdmi_runtime_get\n");
 
-	r = pm_runtime_get_sync(&hdmi.pdev->dev);
+	r = pm_runtime_get_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0);
 	if (r < 0)
 		return r;
@@ -60,13 +58,13 @@ static int hdmi_runtime_get(void)
 	return 0;
 }
 
-static void hdmi_runtime_put(void)
+static void hdmi_runtime_put(struct omap_hdmi *hdmi)
 {
 	int r;
 
 	DSSDBG("hdmi_runtime_put\n");
 
-	r = pm_runtime_put_sync(&hdmi.pdev->dev);
+	r = pm_runtime_put_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
@@ -109,14 +107,14 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int hdmi_init_regulator(void)
+static int hdmi_init_regulator(struct omap_hdmi *hdmi)
 {
 	struct regulator *reg;
 
-	if (hdmi.vdda_reg != NULL)
+	if (hdmi->vdda_reg != NULL)
 		return 0;
 
-	reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
+	reg = devm_regulator_get(&hdmi->pdev->dev, "vdda");
 
 	if (IS_ERR(reg)) {
 		if (PTR_ERR(reg) != -EPROBE_DEFER)
@@ -124,64 +122,64 @@ static int hdmi_init_regulator(void)
 		return PTR_ERR(reg);
 	}
 
-	hdmi.vdda_reg = reg;
+	hdmi->vdda_reg = reg;
 
 	return 0;
 }
 
-static int hdmi_power_on_core(struct omap_dss_device *dssdev)
+static int hdmi_power_on_core(struct omap_hdmi *hdmi)
 {
 	int r;
 
-	if (hdmi.core.core_pwr_cnt++)
+	if (hdmi->core.core_pwr_cnt++)
 		return 0;
 
-	r = regulator_enable(hdmi.vdda_reg);
+	r = regulator_enable(hdmi->vdda_reg);
 	if (r)
 		goto err_reg_enable;
 
-	r = hdmi_runtime_get();
+	r = hdmi_runtime_get(hdmi);
 	if (r)
 		goto err_runtime_get;
 
-	hdmi4_core_powerdown_disable(&hdmi.core);
+	hdmi4_core_powerdown_disable(&hdmi->core);
 
 	/* Make selection of HDMI in DSS */
-	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
+	dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
 
-	hdmi.core_enabled = true;
+	hdmi->core_enabled = true;
 
 	return 0;
 
 err_runtime_get:
-	regulator_disable(hdmi.vdda_reg);
+	regulator_disable(hdmi->vdda_reg);
 err_reg_enable:
-	hdmi.core.core_pwr_cnt--;
+	hdmi->core.core_pwr_cnt--;
 
 	return r;
 }
 
-static void hdmi_power_off_core(struct omap_dss_device *dssdev)
+static void hdmi_power_off_core(struct omap_hdmi *hdmi)
 {
-	if (--hdmi.core.core_pwr_cnt)
+	if (--hdmi->core.core_pwr_cnt)
 		return;
 
-	hdmi.core_enabled = false;
+	hdmi->core_enabled = false;
 
-	hdmi_runtime_put();
-	regulator_disable(hdmi.vdda_reg);
+	hdmi_runtime_put(hdmi);
+	regulator_disable(hdmi->vdda_reg);
 }
 
-static int hdmi_power_on_full(struct omap_dss_device *dssdev)
+static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
 	int r;
 	struct videomode *vm;
-	enum omap_channel channel = dssdev->dispc_channel;
-	struct hdmi_wp_data *wp = &hdmi.wp;
+	enum omap_channel channel = hdmi->output.dispc_channel;
+	struct hdmi_wp_data *wp = &hdmi->wp;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
 	unsigned int pc;
 
-	r = hdmi_power_on_core(dssdev);
+	r = hdmi_power_on_core(hdmi);
 	if (r)
 		return r;
 
@@ -189,7 +187,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	hdmi_wp_clear_irqenable(wp, ~HDMI_IRQ_CORE);
 	hdmi_wp_set_irqstatus(wp, ~HDMI_IRQ_CORE);
 
-	vm = &hdmi.cfg.vm;
+	vm = &hdmi->cfg.vm;
 
 	DSSDBG("hdmi_power_on hactive= %d vactive = %d\n", vm->hactive,
 	       vm->vactive);
@@ -201,22 +199,22 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	/* DSS_HDMI_TCLK is bitclk / 10 */
 	pc *= 10;
 
-	dss_pll_calc_b(&hdmi.pll.pll, clk_get_rate(hdmi.pll.pll.clkin),
+	dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
 		pc, &hdmi_cinfo);
 
-	r = dss_pll_enable(&hdmi.pll.pll);
+	r = dss_pll_enable(&hdmi->pll.pll);
 	if (r) {
 		DSSERR("Failed to enable PLL\n");
 		goto err_pll_enable;
 	}
 
-	r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo);
+	r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
 	if (r) {
 		DSSERR("Failed to configure PLL\n");
 		goto err_pll_cfg;
 	}
 
-	r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco,
+	r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
 		hdmi_cinfo.clkout[0]);
 	if (r) {
 		DSSDBG("Failed to configure PHY\n");
@@ -227,7 +225,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_phy_pwr;
 
-	hdmi4_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
+	hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
 
 	/* tv size */
 	dss_mgr_set_timings(channel, vm);
@@ -236,7 +234,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_mgr_enable;
 
-	r = hdmi_wp_video_start(&hdmi.wp);
+	r = hdmi_wp_video_start(&hdmi->wp);
 	if (r)
 		goto err_vid_enable;
 
@@ -248,31 +246,31 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 err_vid_enable:
 	dss_mgr_disable(channel);
 err_mgr_enable:
-	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
+	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
 err_phy_cfg:
 err_pll_cfg:
-	dss_pll_disable(&hdmi.pll.pll);
+	dss_pll_disable(&hdmi->pll.pll);
 err_pll_enable:
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 	return -EIO;
 }
 
-static void hdmi_power_off_full(struct omap_dss_device *dssdev)
+static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = hdmi->output.dispc_channel;
 
-	hdmi_wp_clear_irqenable(&hdmi.wp, ~HDMI_IRQ_CORE);
+	hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
 
-	hdmi_wp_video_stop(&hdmi.wp);
+	hdmi_wp_video_stop(&hdmi->wp);
 
 	dss_mgr_disable(channel);
 
-	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
+	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 
-	dss_pll_disable(&hdmi.pll.pll);
+	dss_pll_disable(&hdmi->pll.pll);
 
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 }
 
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
@@ -287,53 +285,59 @@ static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
 static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
 				    struct videomode *vm)
 {
-	mutex_lock(&hdmi.lock);
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	mutex_lock(&hdmi->lock);
 
-	hdmi.cfg.vm = *vm;
+	hdmi->cfg.vm = *vm;
 
 	dispc_set_tv_pclk(vm->pixelclock);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
 static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
 				     struct videomode *vm)
 {
-	*vm = hdmi.cfg.vm;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	*vm = hdmi->cfg.vm;
 }
 
 static int hdmi_dump_regs(struct seq_file *s, void *p)
 {
-	mutex_lock(&hdmi.lock);
+	struct omap_hdmi *hdmi = s->private;
 
-	if (hdmi_runtime_get()) {
-		mutex_unlock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
+
+	if (hdmi_runtime_get(hdmi)) {
+		mutex_unlock(&hdmi->lock);
 		return 0;
 	}
 
-	hdmi_wp_dump(&hdmi.wp, s);
-	hdmi_pll_dump(&hdmi.pll, s);
-	hdmi_phy_dump(&hdmi.phy, s);
-	hdmi4_core_dump(&hdmi.core, s);
+	hdmi_wp_dump(&hdmi->wp, s);
+	hdmi_pll_dump(&hdmi->pll, s);
+	hdmi_phy_dump(&hdmi->phy, s);
+	hdmi4_core_dump(&hdmi->core, s);
 
-	hdmi_runtime_put();
-	mutex_unlock(&hdmi.lock);
+	hdmi_runtime_put(hdmi);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 }
 
-static int read_edid(u8 *buf, int len)
+static int read_edid(struct omap_hdmi *hdmi, u8 *buf, int len)
 {
 	int r;
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	r = hdmi_runtime_get();
+	r = hdmi_runtime_get(hdmi);
 	BUG_ON(r);
 
-	r = hdmi4_read_edid(&hdmi.core,  buf, len);
+	r = hdmi4_read_edid(&hdmi->core,  buf, len);
 
-	hdmi_runtime_put();
-	mutex_unlock(&hdmi.lock);
+	hdmi_runtime_put(hdmi);
+	mutex_unlock(&hdmi->lock);
 
 	return r;
 }
@@ -352,108 +356,113 @@ static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
 
 static int hdmi_display_enable(struct omap_dss_device *dssdev)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	unsigned long flags;
 	int r = 0;
 
 	DSSDBG("ENTER hdmi_display_enable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	if (!out->dispc_channel_connected) {
+	if (!dssdev->dispc_channel_connected) {
 		DSSERR("failed to enable display: no output/manager\n");
 		r = -ENODEV;
 		goto err0;
 	}
 
-	r = hdmi_power_on_full(dssdev);
+	r = hdmi_power_on_full(hdmi);
 	if (r) {
 		DSSERR("failed to power on device\n");
 		goto err0;
 	}
 
-	if (hdmi.audio_configured) {
-		r = hdmi4_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
-				       hdmi.cfg.vm.pixelclock);
+	if (hdmi->audio_configured) {
+		r = hdmi4_audio_config(&hdmi->core, &hdmi->wp, &hdmi->audio_config,
+				       hdmi->cfg.vm.pixelclock);
 		if (r) {
 			DSSERR("Error restoring audio configuration: %d", r);
-			hdmi.audio_abort_cb(&hdmi.pdev->dev);
-			hdmi.audio_configured = false;
+			hdmi->audio_abort_cb(&hdmi->pdev->dev);
+			hdmi->audio_configured = false;
 		}
 	}
 
-	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
-	if (hdmi.audio_configured && hdmi.audio_playing)
-		hdmi_start_audio_stream(&hdmi);
-	hdmi.display_enabled = true;
-	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	if (hdmi->audio_configured && hdmi->audio_playing)
+		hdmi_start_audio_stream(hdmi);
+	hdmi->display_enabled = true;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 
 err0:
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return r;
 }
 
 static void hdmi_display_disable(struct omap_dss_device *dssdev)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	unsigned long flags;
 
 	DSSDBG("Enter hdmi_display_disable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
-	hdmi_stop_audio_stream(&hdmi);
-	hdmi.display_enabled = false;
-	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	hdmi_stop_audio_stream(hdmi);
+	hdmi->display_enabled = false;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
 
-	hdmi_power_off_full(dssdev);
+	hdmi_power_off_full(hdmi);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
-int hdmi4_core_enable(struct omap_dss_device *dssdev)
+int hdmi4_core_enable(struct hdmi_core_data *core)
 {
+	struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
 	int r = 0;
 
 	DSSDBG("ENTER omapdss_hdmi4_core_enable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	r = hdmi_power_on_core(dssdev);
+	r = hdmi_power_on_core(hdmi);
 	if (r) {
 		DSSERR("failed to power on device\n");
 		goto err0;
 	}
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 
 err0:
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return r;
 }
 
-void hdmi4_core_disable(struct omap_dss_device *dssdev)
+void hdmi4_core_disable(struct hdmi_core_data *core)
 {
+	struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
+
 	DSSDBG("Enter omapdss_hdmi4_core_disable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
 static int hdmi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
-	r = hdmi_init_regulator();
+	r = hdmi_init_regulator(hdmi);
 	if (r)
 		return r;
 
@@ -490,45 +499,52 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
 		u8 *edid, int len)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	bool need_enable;
 	int r;
 
-	need_enable = hdmi.core_enabled == false;
+	need_enable = hdmi->core_enabled == false;
 
 	if (need_enable) {
-		r = hdmi4_core_enable(dssdev);
+		r = hdmi4_core_enable(&hdmi->core);
 		if (r)
 			return r;
 	}
 
-	r = read_edid(edid, len);
+	r = read_edid(hdmi, edid, len);
 	if (r >= 256)
-		hdmi4_cec_set_phys_addr(&hdmi.core,
+		hdmi4_cec_set_phys_addr(&hdmi->core,
 					cec_get_edid_phys_addr(edid, r, NULL));
 	else
-		hdmi4_cec_set_phys_addr(&hdmi.core, CEC_PHYS_ADDR_INVALID);
+		hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
 	if (need_enable)
-		hdmi4_core_disable(dssdev);
+		hdmi4_core_disable(&hdmi->core);
 
 	return r;
 }
 
 static void hdmi_lost_hotplug(struct omap_dss_device *dssdev)
 {
-	hdmi4_cec_set_phys_addr(&hdmi.core, CEC_PHYS_ADDR_INVALID);
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
 }
 
 static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
 		const struct hdmi_avi_infoframe *avi)
 {
-	hdmi.cfg.infoframe = *avi;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	hdmi->cfg.infoframe = *avi;
 	return 0;
 }
 
 static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
 		bool hdmi_mode)
 {
-	hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
 	return 0;
 }
 
@@ -549,14 +565,14 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
 	.set_hdmi_mode		= hdmi_set_hdmi_mode,
 };
 
-static void hdmi_init_output(struct platform_device *pdev)
+static void hdmi_init_output(struct omap_hdmi *hdmi)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_dss_device *out = &hdmi->output;
 
-	out->dev = &pdev->dev;
+	out->dev = &hdmi->pdev->dev;
 	out->id = OMAP_DSS_OUTPUT_HDMI;
 	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
-	out->name = "hdmi.0";
+	out->name = "hdmi->0";
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
 	out->ops.hdmi = &hdmi_ops;
 	out->owner = THIS_MODULE;
@@ -564,15 +580,16 @@ static void hdmi_init_output(struct platform_device *pdev)
 	omapdss_register_output(out);
 }
 
-static void hdmi_uninit_output(struct platform_device *pdev)
+static void hdmi_uninit_output(struct omap_hdmi *hdmi)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_dss_device *out = &hdmi->output;
 
 	omapdss_unregister_output(out);
 }
 
-static int hdmi_probe_of(struct platform_device *pdev)
+static int hdmi_probe_of(struct omap_hdmi *hdmi)
 {
+	struct platform_device *pdev = hdmi->pdev;
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *ep;
 	int r;
@@ -581,7 +598,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
 	if (!ep)
 		return 0;
 
-	r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
+	r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
 	if (r)
 		goto err;
 
@@ -694,21 +711,21 @@ static const struct omap_hdmi_audio_ops hdmi_audio_ops = {
 	.audio_config = hdmi_audio_config,
 };
 
-static int hdmi_audio_register(struct device *dev)
+static int hdmi_audio_register(struct omap_hdmi *hdmi)
 {
 	struct omap_hdmi_audio_pdata pdata = {
-		.dev = dev,
+		.dev = &hdmi->pdev->dev,
 		.version = 4,
-		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp),
+		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
 		.ops = &hdmi_audio_ops,
 	};
 
-	hdmi.audio_pdev = platform_device_register_data(
-		dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
+	hdmi->audio_pdev = platform_device_register_data(
+		&hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
 		&pdata, sizeof(pdata));
 
-	if (IS_ERR(hdmi.audio_pdev))
-		return PTR_ERR(hdmi.audio_pdev);
+	if (IS_ERR(hdmi->audio_pdev))
+		return PTR_ERR(hdmi->audio_pdev);
 
 	return 0;
 }
@@ -718,91 +735,101 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dss_device *dss = dss_get_device(master);
+	struct omap_hdmi *hdmi;
 	int r;
 	int irq;
 
-	hdmi.pdev = pdev;
-	hdmi.dss = dss;
-	dev_set_drvdata(&pdev->dev, &hdmi);
+	hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
+	if (!hdmi)
+		return -ENOMEM;
+
+	hdmi->pdev = pdev;
+	hdmi->dss = dss;
+	dev_set_drvdata(&pdev->dev, hdmi);
 
-	mutex_init(&hdmi.lock);
-	spin_lock_init(&hdmi.audio_playing_lock);
+	mutex_init(&hdmi->lock);
+	spin_lock_init(&hdmi->audio_playing_lock);
 
-	r = hdmi_probe_of(pdev);
+	r = hdmi_probe_of(hdmi);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_wp_init(pdev, &hdmi.wp, 4);
+	r = hdmi_wp_init(pdev, &hdmi->wp, 4);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_phy_init(pdev, &hdmi.phy, 4);
+	r = hdmi_phy_init(pdev, &hdmi->phy, 4);
 	if (r)
-		goto err;
+		goto err_pll;
 
-	r = hdmi4_core_init(pdev, &hdmi.core);
+	r = hdmi4_core_init(pdev, &hdmi->core);
 	if (r)
-		goto err;
+		goto err_pll;
 
-	r = hdmi4_cec_init(pdev, &hdmi.core, &hdmi.wp);
+	r = hdmi4_cec_init(pdev, &hdmi->core, &hdmi->wp);
 	if (r)
-		goto err;
+		goto err_pll;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		DSSERR("platform_get_irq failed\n");
 		r = -ENODEV;
-		goto err;
+		goto err_pll;
 	}
 
 	r = devm_request_threaded_irq(&pdev->dev, irq,
 			NULL, hdmi_irq_handler,
-			IRQF_ONESHOT, "OMAP HDMI", &hdmi);
+			IRQF_ONESHOT, "OMAP HDMI", hdmi);
 	if (r) {
 		DSSERR("HDMI IRQ request failed\n");
-		goto err;
+		goto err_pll;
 	}
 
 	pm_runtime_enable(&pdev->dev);
 
-	hdmi_init_output(pdev);
+	hdmi_init_output(hdmi);
 
-	r = hdmi_audio_register(&pdev->dev);
+	r = hdmi_audio_register(hdmi);
 	if (r) {
 		DSSERR("Registering HDMI audio failed\n");
-		hdmi_uninit_output(pdev);
+		hdmi_uninit_output(hdmi);
 		pm_runtime_disable(&pdev->dev);
 		return r;
 	}
 
-	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
+	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
 
 	return 0;
-err:
-	hdmi_pll_uninit(&hdmi.pll);
+
+err_pll:
+	hdmi_pll_uninit(&hdmi->pll);
+err_free:
+	kfree(hdmi);
 	return r;
 }
 
 static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
 {
-	struct platform_device *pdev = to_platform_device(dev);
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+	dss_debugfs_remove_file(hdmi->debugfs);
 
-	dss_debugfs_remove_file(hdmi.debugfs);
+	if (hdmi->audio_pdev)
+		platform_device_unregister(hdmi->audio_pdev);
 
-	if (hdmi.audio_pdev)
-		platform_device_unregister(hdmi.audio_pdev);
+	hdmi_uninit_output(hdmi);
 
-	hdmi_uninit_output(pdev);
+	hdmi4_cec_uninit(&hdmi->core);
 
-	hdmi4_cec_uninit(&hdmi.core);
+	hdmi_pll_uninit(&hdmi->pll);
 
-	hdmi_pll_uninit(&hdmi.pll);
+	pm_runtime_disable(dev);
 
-	pm_runtime_disable(&pdev->dev);
+	kfree(hdmi);
 }
 
 static const struct component_ops hdmi4_component_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
index d86873f2abe6..3e2c880dbadb 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
@@ -199,10 +199,10 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
 		REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
 		hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
 		hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
-		hdmi4_core_disable(NULL);
+		hdmi4_core_disable(core);
 		return 0;
 	}
-	err = hdmi4_core_enable(NULL);
+	err = hdmi4_core_enable(core);
 	if (err)
 		return err;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
index b6ab579e44d2..337a317c1a27 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
@@ -266,8 +266,8 @@ void hdmi4_configure(struct hdmi_core_data *core, struct hdmi_wp_data *wp,
 void hdmi4_core_dump(struct hdmi_core_data *core, struct seq_file *s);
 int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core);
 
-int hdmi4_core_enable(struct omap_dss_device *dssdev);
-void hdmi4_core_disable(struct omap_dss_device *dssdev);
+int hdmi4_core_enable(struct hdmi_core_data *core);
+void hdmi4_core_disable(struct hdmi_core_data *core);
 void hdmi4_core_powerdown_disable(struct hdmi_core_data *core);
 
 int hdmi4_audio_start(struct hdmi_core_data *core, struct hdmi_wp_data *wp);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 32/48] drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (30 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 18:52   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private " Laurent Pinchart
                   ` (19 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_hdmi private data structure is currently stored as a global
variable. While no platform with multiple HDMI5 encoders currently
exists nor is planned, this doesn't comply with the kernel device model
and should thus be fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 345 +++++++++++++++++++-----------------
 1 file changed, 184 insertions(+), 161 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index c28fe184a7ad..ed8a2bd2a035 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -46,15 +46,13 @@
 #include "hdmi5_core.h"
 #include "dss.h"
 
-static struct omap_hdmi hdmi;
-
-static int hdmi_runtime_get(void)
+static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 {
 	int r;
 
 	DSSDBG("hdmi_runtime_get\n");
 
-	r = pm_runtime_get_sync(&hdmi.pdev->dev);
+	r = pm_runtime_get_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0);
 	if (r < 0)
 		return r;
@@ -62,19 +60,20 @@ static int hdmi_runtime_get(void)
 	return 0;
 }
 
-static void hdmi_runtime_put(void)
+static void hdmi_runtime_put(struct omap_hdmi *hdmi)
 {
 	int r;
 
 	DSSDBG("hdmi_runtime_put\n");
 
-	r = pm_runtime_put_sync(&hdmi.pdev->dev);
+	r = pm_runtime_put_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
 static irqreturn_t hdmi_irq_handler(int irq, void *data)
 {
-	struct hdmi_wp_data *wp = data;
+	struct omap_hdmi *hdmi = data;
+	struct hdmi_wp_data *wp = &hdmi->wp;
 	u32 irqstatus;
 
 	irqstatus = hdmi_wp_get_irqstatus(wp);
@@ -97,17 +96,17 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
 		 * setting the PHY to LDOON. To ignore those, we force the RXDET
 		 * line to 0 until the PHY power state has been changed.
 		 */
-		v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
+		v = hdmi_read_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
 		v = FLD_MOD(v, 1, 15, 15); /* FORCE_RXDET_HIGH */
 		v = FLD_MOD(v, 0, 14, 7); /* RXDET_LINE */
-		hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
+		hdmi_write_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
 
 		hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
 				HDMI_IRQ_LINK_DISCONNECT);
 
 		hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
 
-		REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
+		REG_FLD_MOD(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
 
 	} else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
 		hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
@@ -118,70 +117,70 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int hdmi_init_regulator(void)
+static int hdmi_init_regulator(struct omap_hdmi *hdmi)
 {
 	struct regulator *reg;
 
-	if (hdmi.vdda_reg != NULL)
+	if (hdmi->vdda_reg != NULL)
 		return 0;
 
-	reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
+	reg = devm_regulator_get(&hdmi->pdev->dev, "vdda");
 	if (IS_ERR(reg)) {
 		DSSERR("can't get VDDA regulator\n");
 		return PTR_ERR(reg);
 	}
 
-	hdmi.vdda_reg = reg;
+	hdmi->vdda_reg = reg;
 
 	return 0;
 }
 
-static int hdmi_power_on_core(struct omap_dss_device *dssdev)
+static int hdmi_power_on_core(struct omap_hdmi *hdmi)
 {
 	int r;
 
-	r = regulator_enable(hdmi.vdda_reg);
+	r = regulator_enable(hdmi->vdda_reg);
 	if (r)
 		return r;
 
-	r = hdmi_runtime_get();
+	r = hdmi_runtime_get(hdmi);
 	if (r)
 		goto err_runtime_get;
 
 	/* Make selection of HDMI in DSS */
-	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
+	dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
 
-	hdmi.core_enabled = true;
+	hdmi->core_enabled = true;
 
 	return 0;
 
 err_runtime_get:
-	regulator_disable(hdmi.vdda_reg);
+	regulator_disable(hdmi->vdda_reg);
 
 	return r;
 }
 
-static void hdmi_power_off_core(struct omap_dss_device *dssdev)
+static void hdmi_power_off_core(struct omap_hdmi *hdmi)
 {
-	hdmi.core_enabled = false;
+	hdmi->core_enabled = false;
 
-	hdmi_runtime_put();
-	regulator_disable(hdmi.vdda_reg);
+	hdmi_runtime_put(hdmi);
+	regulator_disable(hdmi->vdda_reg);
 }
 
-static int hdmi_power_on_full(struct omap_dss_device *dssdev)
+static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
 	int r;
 	struct videomode *vm;
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = hdmi->output.dispc_channel;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
 	unsigned int pc;
 
-	r = hdmi_power_on_core(dssdev);
+	r = hdmi_power_on_core(hdmi);
 	if (r)
 		return r;
 
-	vm = &hdmi.cfg.vm;
+	vm = &hdmi->cfg.vm;
 
 	DSSDBG("hdmi_power_on hactive= %d vactive = %d\n", vm->hactive,
 	       vm->vactive);
@@ -193,38 +192,38 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	/* DSS_HDMI_TCLK is bitclk / 10 */
 	pc *= 10;
 
-	dss_pll_calc_b(&hdmi.pll.pll, clk_get_rate(hdmi.pll.pll.clkin),
+	dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
 		pc, &hdmi_cinfo);
 
 	/* disable and clear irqs */
-	hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
-	hdmi_wp_set_irqstatus(&hdmi.wp,
-			hdmi_wp_get_irqstatus(&hdmi.wp));
+	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
+	hdmi_wp_set_irqstatus(&hdmi->wp,
+			hdmi_wp_get_irqstatus(&hdmi->wp));
 
-	r = dss_pll_enable(&hdmi.pll.pll);
+	r = dss_pll_enable(&hdmi->pll.pll);
 	if (r) {
 		DSSERR("Failed to enable PLL\n");
 		goto err_pll_enable;
 	}
 
-	r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo);
+	r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
 	if (r) {
 		DSSERR("Failed to configure PLL\n");
 		goto err_pll_cfg;
 	}
 
-	r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco,
+	r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
 		hdmi_cinfo.clkout[0]);
 	if (r) {
 		DSSDBG("Failed to start PHY\n");
 		goto err_phy_cfg;
 	}
 
-	r = hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_LDOON);
+	r = hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_LDOON);
 	if (r)
 		goto err_phy_pwr;
 
-	hdmi5_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
+	hdmi5_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
 
 	/* tv size */
 	dss_mgr_set_timings(channel, vm);
@@ -233,11 +232,11 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_mgr_enable;
 
-	r = hdmi_wp_video_start(&hdmi.wp);
+	r = hdmi_wp_video_start(&hdmi->wp);
 	if (r)
 		goto err_vid_enable;
 
-	hdmi_wp_set_irqenable(&hdmi.wp,
+	hdmi_wp_set_irqenable(&hdmi->wp,
 			HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
 
 	return 0;
@@ -245,31 +244,31 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 err_vid_enable:
 	dss_mgr_disable(channel);
 err_mgr_enable:
-	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
+	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
 err_phy_cfg:
 err_pll_cfg:
-	dss_pll_disable(&hdmi.pll.pll);
+	dss_pll_disable(&hdmi->pll.pll);
 err_pll_enable:
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 	return -EIO;
 }
 
-static void hdmi_power_off_full(struct omap_dss_device *dssdev)
+static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = hdmi->output.dispc_channel;
 
-	hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
+	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
 
-	hdmi_wp_video_stop(&hdmi.wp);
+	hdmi_wp_video_stop(&hdmi->wp);
 
 	dss_mgr_disable(channel);
 
-	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
+	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 
-	dss_pll_disable(&hdmi.pll.pll);
+	dss_pll_disable(&hdmi->pll.pll);
 
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 }
 
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
@@ -284,67 +283,73 @@ static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
 static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
 				    struct videomode *vm)
 {
-	mutex_lock(&hdmi.lock);
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 
-	hdmi.cfg.vm = *vm;
+	mutex_lock(&hdmi->lock);
+
+	hdmi->cfg.vm = *vm;
 
 	dispc_set_tv_pclk(vm->pixelclock);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
 static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
 				     struct videomode *vm)
 {
-	*vm = hdmi.cfg.vm;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	*vm = hdmi->cfg.vm;
 }
 
 static int hdmi_dump_regs(struct seq_file *s, void *p)
 {
-	mutex_lock(&hdmi.lock);
+	struct omap_hdmi *hdmi = s->private;
 
-	if (hdmi_runtime_get()) {
-		mutex_unlock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
+
+	if (hdmi_runtime_get(hdmi)) {
+		mutex_unlock(&hdmi->lock);
 		return 0;
 	}
 
-	hdmi_wp_dump(&hdmi.wp, s);
-	hdmi_pll_dump(&hdmi.pll, s);
-	hdmi_phy_dump(&hdmi.phy, s);
-	hdmi5_core_dump(&hdmi.core, s);
+	hdmi_wp_dump(&hdmi->wp, s);
+	hdmi_pll_dump(&hdmi->pll, s);
+	hdmi_phy_dump(&hdmi->phy, s);
+	hdmi5_core_dump(&hdmi->core, s);
 
-	hdmi_runtime_put();
-	mutex_unlock(&hdmi.lock);
+	hdmi_runtime_put(hdmi);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 }
 
-static int read_edid(u8 *buf, int len)
+static int read_edid(struct omap_hdmi *hdmi, u8 *buf, int len)
 {
 	int r;
 	int idlemode;
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	r = hdmi_runtime_get();
+	r = hdmi_runtime_get(hdmi);
 	BUG_ON(r);
 
-	idlemode = REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
+	idlemode = REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
 	/* No-idle mode */
-	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
+	REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
 
-	r = hdmi5_read_edid(&hdmi.core,  buf, len);
+	r = hdmi5_read_edid(&hdmi->core,  buf, len);
 
-	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
+	REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
 
-	hdmi_runtime_put();
-	mutex_unlock(&hdmi.lock);
+	hdmi_runtime_put(hdmi);
+	mutex_unlock(&hdmi->lock);
 
 	return r;
 }
 
 static void hdmi_start_audio_stream(struct omap_hdmi *hd)
 {
-	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
+	REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
 	hdmi_wp_audio_enable(&hd->wp, true);
 	hdmi_wp_audio_core_req_enable(&hd->wp, true);
 }
@@ -358,108 +363,110 @@ static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
 
 static int hdmi_display_enable(struct omap_dss_device *dssdev)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	unsigned long flags;
 	int r = 0;
 
 	DSSDBG("ENTER hdmi_display_enable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	if (!out->dispc_channel_connected) {
+	if (!dssdev->dispc_channel_connected) {
 		DSSERR("failed to enable display: no output/manager\n");
 		r = -ENODEV;
 		goto err0;
 	}
 
-	r = hdmi_power_on_full(dssdev);
+	r = hdmi_power_on_full(hdmi);
 	if (r) {
 		DSSERR("failed to power on device\n");
 		goto err0;
 	}
 
-	if (hdmi.audio_configured) {
-		r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
-				       hdmi.cfg.vm.pixelclock);
+	if (hdmi->audio_configured) {
+		r = hdmi5_audio_config(&hdmi->core, &hdmi->wp, &hdmi->audio_config,
+				       hdmi->cfg.vm.pixelclock);
 		if (r) {
 			DSSERR("Error restoring audio configuration: %d", r);
-			hdmi.audio_abort_cb(&hdmi.pdev->dev);
-			hdmi.audio_configured = false;
+			hdmi->audio_abort_cb(&hdmi->pdev->dev);
+			hdmi->audio_configured = false;
 		}
 	}
 
-	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
-	if (hdmi.audio_configured && hdmi.audio_playing)
-		hdmi_start_audio_stream(&hdmi);
-	hdmi.display_enabled = true;
-	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	if (hdmi->audio_configured && hdmi->audio_playing)
+		hdmi_start_audio_stream(hdmi);
+	hdmi->display_enabled = true;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 
 err0:
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return r;
 }
 
 static void hdmi_display_disable(struct omap_dss_device *dssdev)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	unsigned long flags;
 
 	DSSDBG("Enter hdmi_display_disable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
-	hdmi_stop_audio_stream(&hdmi);
-	hdmi.display_enabled = false;
-	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
+	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
+	hdmi_stop_audio_stream(hdmi);
+	hdmi->display_enabled = false;
+	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
 
-	hdmi_power_off_full(dssdev);
+	hdmi_power_off_full(hdmi);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
-static int hdmi_core_enable(struct omap_dss_device *dssdev)
+static int hdmi_core_enable(struct omap_hdmi *hdmi)
 {
 	int r = 0;
 
 	DSSDBG("ENTER omapdss_hdmi_core_enable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	r = hdmi_power_on_core(dssdev);
+	r = hdmi_power_on_core(hdmi);
 	if (r) {
 		DSSERR("failed to power on device\n");
 		goto err0;
 	}
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return 0;
 
 err0:
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 	return r;
 }
 
-static void hdmi_core_disable(struct omap_dss_device *dssdev)
+static void hdmi_core_disable(struct omap_hdmi *hdmi)
 {
 	DSSDBG("Enter omapdss_hdmi_core_disable\n");
 
-	mutex_lock(&hdmi.lock);
+	mutex_lock(&hdmi->lock);
 
-	hdmi_power_off_core(dssdev);
+	hdmi_power_off_core(hdmi);
 
-	mutex_unlock(&hdmi.lock);
+	mutex_unlock(&hdmi->lock);
 }
 
 static int hdmi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
-	r = hdmi_init_regulator();
+	r = hdmi_init_regulator(hdmi);
 	if (r)
 		return r;
 
@@ -496,21 +503,22 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
 		u8 *edid, int len)
 {
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 	bool need_enable;
 	int r;
 
-	need_enable = hdmi.core_enabled == false;
+	need_enable = hdmi->core_enabled == false;
 
 	if (need_enable) {
-		r = hdmi_core_enable(dssdev);
+		r = hdmi_core_enable(hdmi);
 		if (r)
 			return r;
 	}
 
-	r = read_edid(edid, len);
+	r = read_edid(hdmi, edid, len);
 
 	if (need_enable)
-		hdmi_core_disable(dssdev);
+		hdmi_core_disable(hdmi);
 
 	return r;
 }
@@ -518,14 +526,18 @@ static int hdmi_read_edid(struct omap_dss_device *dssdev,
 static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
 		const struct hdmi_avi_infoframe *avi)
 {
-	hdmi.cfg.infoframe = *avi;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	hdmi->cfg.infoframe = *avi;
 	return 0;
 }
 
 static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
 		bool hdmi_mode)
 {
-	hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
 	return 0;
 }
 
@@ -545,14 +557,14 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
 	.set_hdmi_mode		= hdmi_set_hdmi_mode,
 };
 
-static void hdmi_init_output(struct platform_device *pdev)
+static void hdmi_init_output(struct omap_hdmi *hdmi)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_dss_device *out = &hdmi->output;
 
-	out->dev = &pdev->dev;
+	out->dev = &hdmi->pdev->dev;
 	out->id = OMAP_DSS_OUTPUT_HDMI;
 	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
-	out->name = "hdmi.0";
+	out->name = "hdmi->0";
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
 	out->ops.hdmi = &hdmi_ops;
 	out->owner = THIS_MODULE;
@@ -560,15 +572,16 @@ static void hdmi_init_output(struct platform_device *pdev)
 	omapdss_register_output(out);
 }
 
-static void hdmi_uninit_output(struct platform_device *pdev)
+static void hdmi_uninit_output(struct omap_hdmi *hdmi)
 {
-	struct omap_dss_device *out = &hdmi.output;
+	struct omap_dss_device *out = &hdmi->output;
 
 	omapdss_unregister_output(out);
 }
 
-static int hdmi_probe_of(struct platform_device *pdev)
+static int hdmi_probe_of(struct omap_hdmi *hdmi)
 {
+	struct platform_device *pdev = hdmi->pdev;
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *ep;
 	int r;
@@ -577,7 +590,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
 	if (!ep)
 		return 0;
 
-	r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
+	r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
 	if (r)
 		goto err;
 
@@ -691,26 +704,26 @@ static const struct omap_hdmi_audio_ops hdmi_audio_ops = {
 	.audio_config = hdmi_audio_config,
 };
 
-static int hdmi_audio_register(struct device *dev)
+static int hdmi_audio_register(struct omap_hdmi *hdmi)
 {
 	struct omap_hdmi_audio_pdata pdata = {
-		.dev = dev,
+		.dev = &hdmi->pdev->dev,
 		.version = 5,
-		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp),
+		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
 		.ops = &hdmi_audio_ops,
 	};
 
-	hdmi.audio_pdev = platform_device_register_data(
-		dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
+	hdmi->audio_pdev = platform_device_register_data(
+		&hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
 		&pdata, sizeof(pdata));
 
-	if (IS_ERR(hdmi.audio_pdev))
-		return PTR_ERR(hdmi.audio_pdev);
+	if (IS_ERR(hdmi->audio_pdev))
+		return PTR_ERR(hdmi->audio_pdev);
 
-	hdmi_runtime_get();
-	hdmi.wp_idlemode =
-		REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
-	hdmi_runtime_put();
+	hdmi_runtime_get(hdmi);
+	hdmi->wp_idlemode =
+		REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
+	hdmi_runtime_put(hdmi);
 
 	return 0;
 }
@@ -720,85 +733,95 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dss_device *dss = dss_get_device(master);
+	struct omap_hdmi *hdmi;
 	int r;
 	int irq;
 
-	hdmi.pdev = pdev;
-	hdmi.dss = dss;
-	dev_set_drvdata(&pdev->dev, &hdmi);
+	hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
+	if (!hdmi)
+		return -ENOMEM;
 
-	mutex_init(&hdmi.lock);
-	spin_lock_init(&hdmi.audio_playing_lock);
+	hdmi->pdev = pdev;
+	hdmi->dss = dss;
+	dev_set_drvdata(&pdev->dev, hdmi);
 
-	r = hdmi_probe_of(pdev);
+	mutex_init(&hdmi->lock);
+	spin_lock_init(&hdmi->audio_playing_lock);
+
+	r = hdmi_probe_of(hdmi);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_wp_init(pdev, &hdmi.wp, 5);
+	r = hdmi_wp_init(pdev, &hdmi->wp, 5);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp);
 	if (r)
-		return r;
+		goto err_free;
 
-	r = hdmi_phy_init(pdev, &hdmi.phy, 5);
+	r = hdmi_phy_init(pdev, &hdmi->phy, 5);
 	if (r)
-		goto err;
+		goto err_pll;
 
-	r = hdmi5_core_init(pdev, &hdmi.core);
+	r = hdmi5_core_init(pdev, &hdmi->core);
 	if (r)
-		goto err;
+		goto err_pll;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		DSSERR("platform_get_irq failed\n");
 		r = -ENODEV;
-		goto err;
+		goto err_pll;
 	}
 
 	r = devm_request_threaded_irq(&pdev->dev, irq,
 			NULL, hdmi_irq_handler,
-			IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp);
+			IRQF_ONESHOT, "OMAP HDMI", hdmi);
 	if (r) {
 		DSSERR("HDMI IRQ request failed\n");
-		goto err;
+		goto err_pll;
 	}
 
 	pm_runtime_enable(&pdev->dev);
 
-	hdmi_init_output(pdev);
+	hdmi_init_output(hdmi);
 
-	r = hdmi_audio_register(&pdev->dev);
+	r = hdmi_audio_register(hdmi);
 	if (r) {
 		DSSERR("Registering HDMI audio failed %d\n", r);
-		hdmi_uninit_output(pdev);
+		hdmi_uninit_output(hdmi);
 		pm_runtime_disable(&pdev->dev);
 		return r;
 	}
 
-	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
+	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
 
 	return 0;
-err:
-	hdmi_pll_uninit(&hdmi.pll);
+
+err_pll:
+	hdmi_pll_uninit(&hdmi->pll);
+err_free:
+	kfree(hdmi);
 	return r;
 }
 
 static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
 {
-	struct platform_device *pdev = to_platform_device(dev);
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+	dss_debugfs_remove_file(hdmi->debugfs);
 
-	dss_debugfs_remove_file(hdmi.debugfs);
+	if (hdmi->audio_pdev)
+		platform_device_unregister(hdmi->audio_pdev);
 
-	if (hdmi.audio_pdev)
-		platform_device_unregister(hdmi.audio_pdev);
+	hdmi_uninit_output(hdmi);
 
-	hdmi_uninit_output(pdev);
+	hdmi_pll_uninit(&hdmi->pll);
 
-	hdmi_pll_uninit(&hdmi.pll);
+	pm_runtime_disable(dev);
 
-	pm_runtime_disable(&pdev->dev);
+	kfree(hdmi);
 }
 
 static const struct component_ops hdmi5_component_ops = {
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (31 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 32/48] drm: omapdrm: hdmi5: " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 18:52   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi " Laurent Pinchart
                   ` (18 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The venc private data structure is currently stored as a global
variable. While no platform with multiple VENC encoders currently exists
nor is planned, this doesn't comply with the kernel device model and
should thus be fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/venc.c | 425 ++++++++++++++++++++-----------------
 1 file changed, 228 insertions(+), 197 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 179ef73a5564..7acdbfefe397 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -321,7 +321,7 @@ static enum venc_videomode venc_get_videomode(const struct videomode *vm)
 	return VENC_MODE_UNKNOWN;
 }
 
-static struct {
+struct venc_device {
 	struct platform_device *pdev;
 	void __iomem *base;
 	struct mutex venc_lock;
@@ -339,81 +339,87 @@ static struct {
 	bool requires_tv_dac_clk;
 
 	struct omap_dss_device output;
-} venc;
+};
+
+#define dssdev_to_venc(dssdev) container_of(dssdev, struct venc_device, output)
 
-static inline void venc_write_reg(int idx, u32 val)
+static inline void venc_write_reg(struct venc_device *venc, int idx, u32 val)
 {
-	__raw_writel(val, venc.base + idx);
+	__raw_writel(val, venc->base + idx);
 }
 
-static inline u32 venc_read_reg(int idx)
+static inline u32 venc_read_reg(struct venc_device *venc, int idx)
 {
-	u32 l = __raw_readl(venc.base + idx);
+	u32 l = __raw_readl(venc->base + idx);
 	return l;
 }
 
-static void venc_write_config(const struct venc_config *config)
+static void venc_write_config(struct venc_device *venc,
+			      const struct venc_config *config)
 {
 	DSSDBG("write venc conf\n");
 
-	venc_write_reg(VENC_LLEN, config->llen);
-	venc_write_reg(VENC_FLENS, config->flens);
-	venc_write_reg(VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
-	venc_write_reg(VENC_C_PHASE, config->c_phase);
-	venc_write_reg(VENC_GAIN_U, config->gain_u);
-	venc_write_reg(VENC_GAIN_V, config->gain_v);
-	venc_write_reg(VENC_GAIN_Y, config->gain_y);
-	venc_write_reg(VENC_BLACK_LEVEL, config->black_level);
-	venc_write_reg(VENC_BLANK_LEVEL, config->blank_level);
-	venc_write_reg(VENC_M_CONTROL, config->m_control);
-	venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
-			venc.wss_data);
-	venc_write_reg(VENC_S_CARR, config->s_carr);
-	venc_write_reg(VENC_L21__WC_CTL, config->l21__wc_ctl);
-	venc_write_reg(VENC_SAVID__EAVID, config->savid__eavid);
-	venc_write_reg(VENC_FLEN__FAL, config->flen__fal);
-	venc_write_reg(VENC_LAL__PHASE_RESET, config->lal__phase_reset);
-	venc_write_reg(VENC_HS_INT_START_STOP_X, config->hs_int_start_stop_x);
-	venc_write_reg(VENC_HS_EXT_START_STOP_X, config->hs_ext_start_stop_x);
-	venc_write_reg(VENC_VS_INT_START_X, config->vs_int_start_x);
-	venc_write_reg(VENC_VS_INT_STOP_X__VS_INT_START_Y,
+	venc_write_reg(venc, VENC_LLEN, config->llen);
+	venc_write_reg(venc, VENC_FLENS, config->flens);
+	venc_write_reg(venc, VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
+	venc_write_reg(venc, VENC_C_PHASE, config->c_phase);
+	venc_write_reg(venc, VENC_GAIN_U, config->gain_u);
+	venc_write_reg(venc, VENC_GAIN_V, config->gain_v);
+	venc_write_reg(venc, VENC_GAIN_Y, config->gain_y);
+	venc_write_reg(venc, VENC_BLACK_LEVEL, config->black_level);
+	venc_write_reg(venc, VENC_BLANK_LEVEL, config->blank_level);
+	venc_write_reg(venc, VENC_M_CONTROL, config->m_control);
+	venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
+		       venc->wss_data);
+	venc_write_reg(venc, VENC_S_CARR, config->s_carr);
+	venc_write_reg(venc, VENC_L21__WC_CTL, config->l21__wc_ctl);
+	venc_write_reg(venc, VENC_SAVID__EAVID, config->savid__eavid);
+	venc_write_reg(venc, VENC_FLEN__FAL, config->flen__fal);
+	venc_write_reg(venc, VENC_LAL__PHASE_RESET, config->lal__phase_reset);
+	venc_write_reg(venc, VENC_HS_INT_START_STOP_X,
+		       config->hs_int_start_stop_x);
+	venc_write_reg(venc, VENC_HS_EXT_START_STOP_X,
+		       config->hs_ext_start_stop_x);
+	venc_write_reg(venc, VENC_VS_INT_START_X, config->vs_int_start_x);
+	venc_write_reg(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y,
 		       config->vs_int_stop_x__vs_int_start_y);
-	venc_write_reg(VENC_VS_INT_STOP_Y__VS_EXT_START_X,
+	venc_write_reg(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X,
 		       config->vs_int_stop_y__vs_ext_start_x);
-	venc_write_reg(VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
+	venc_write_reg(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
 		       config->vs_ext_stop_x__vs_ext_start_y);
-	venc_write_reg(VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y);
-	venc_write_reg(VENC_AVID_START_STOP_X, config->avid_start_stop_x);
-	venc_write_reg(VENC_AVID_START_STOP_Y, config->avid_start_stop_y);
-	venc_write_reg(VENC_FID_INT_START_X__FID_INT_START_Y,
+	venc_write_reg(venc, VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y);
+	venc_write_reg(venc, VENC_AVID_START_STOP_X, config->avid_start_stop_x);
+	venc_write_reg(venc, VENC_AVID_START_STOP_Y, config->avid_start_stop_y);
+	venc_write_reg(venc, VENC_FID_INT_START_X__FID_INT_START_Y,
 		       config->fid_int_start_x__fid_int_start_y);
-	venc_write_reg(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X,
+	venc_write_reg(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X,
 		       config->fid_int_offset_y__fid_ext_start_x);
-	venc_write_reg(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y,
+	venc_write_reg(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y,
 		       config->fid_ext_start_y__fid_ext_offset_y);
 
-	venc_write_reg(VENC_DAC_B__DAC_C,  venc_read_reg(VENC_DAC_B__DAC_C));
-	venc_write_reg(VENC_VIDOUT_CTRL, config->vidout_ctrl);
-	venc_write_reg(VENC_HFLTR_CTRL, config->hfltr_ctrl);
-	venc_write_reg(VENC_X_COLOR, config->x_color);
-	venc_write_reg(VENC_LINE21, config->line21);
-	venc_write_reg(VENC_LN_SEL, config->ln_sel);
-	venc_write_reg(VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger);
-	venc_write_reg(VENC_TVDETGP_INT_START_STOP_X,
+	venc_write_reg(venc, VENC_DAC_B__DAC_C,
+		       venc_read_reg(venc, VENC_DAC_B__DAC_C));
+	venc_write_reg(venc, VENC_VIDOUT_CTRL, config->vidout_ctrl);
+	venc_write_reg(venc, VENC_HFLTR_CTRL, config->hfltr_ctrl);
+	venc_write_reg(venc, VENC_X_COLOR, config->x_color);
+	venc_write_reg(venc, VENC_LINE21, config->line21);
+	venc_write_reg(venc, VENC_LN_SEL, config->ln_sel);
+	venc_write_reg(venc, VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger);
+	venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_X,
 		       config->tvdetgp_int_start_stop_x);
-	venc_write_reg(VENC_TVDETGP_INT_START_STOP_Y,
+	venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_Y,
 		       config->tvdetgp_int_start_stop_y);
-	venc_write_reg(VENC_GEN_CTRL, config->gen_ctrl);
-	venc_write_reg(VENC_F_CONTROL, config->f_control);
-	venc_write_reg(VENC_SYNC_CTRL, config->sync_ctrl);
+	venc_write_reg(venc, VENC_GEN_CTRL, config->gen_ctrl);
+	venc_write_reg(venc, VENC_F_CONTROL, config->f_control);
+	venc_write_reg(venc, VENC_SYNC_CTRL, config->sync_ctrl);
 }
 
-static void venc_reset(void)
+static void venc_reset(struct venc_device *venc)
 {
 	int t = 1000;
 
-	venc_write_reg(VENC_F_CONTROL, 1<<8);
-	while (venc_read_reg(VENC_F_CONTROL) & (1<<8)) {
+	venc_write_reg(venc, VENC_F_CONTROL, 1<<8);
+	while (venc_read_reg(venc, VENC_F_CONTROL) & (1<<8)) {
 		if (--t == 0) {
 			DSSERR("Failed to reset venc\n");
 			return;
@@ -427,24 +433,24 @@ static void venc_reset(void)
 #endif
 }
 
-static int venc_runtime_get(void)
+static int venc_runtime_get(struct venc_device *venc)
 {
 	int r;
 
 	DSSDBG("venc_runtime_get\n");
 
-	r = pm_runtime_get_sync(&venc.pdev->dev);
+	r = pm_runtime_get_sync(&venc->pdev->dev);
 	WARN_ON(r < 0);
 	return r < 0 ? r : 0;
 }
 
-static void venc_runtime_put(void)
+static void venc_runtime_put(struct venc_device *venc)
 {
 	int r;
 
 	DSSDBG("venc_runtime_put\n");
 
-	r = pm_runtime_put_sync(&venc.pdev->dev);
+	r = pm_runtime_put_sync(&venc->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
@@ -460,37 +466,37 @@ static const struct venc_config *venc_timings_to_config(struct videomode *vm)
 	}
 }
 
-static int venc_power_on(struct omap_dss_device *dssdev)
+static int venc_power_on(struct venc_device *venc)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = venc->output.dispc_channel;
 	u32 l;
 	int r;
 
-	r = venc_runtime_get();
+	r = venc_runtime_get(venc);
 	if (r)
 		goto err0;
 
-	venc_reset();
-	venc_write_config(venc_timings_to_config(&venc.vm));
+	venc_reset(venc);
+	venc_write_config(venc, venc_timings_to_config(&venc->vm));
 
-	dss_set_venc_output(venc.dss, venc.type);
-	dss_set_dac_pwrdn_bgz(venc.dss, 1);
+	dss_set_venc_output(venc->dss, venc->type);
+	dss_set_dac_pwrdn_bgz(venc->dss, 1);
 
 	l = 0;
 
-	if (venc.type == OMAP_DSS_VENC_TYPE_COMPOSITE)
+	if (venc->type == OMAP_DSS_VENC_TYPE_COMPOSITE)
 		l |= 1 << 1;
 	else /* S-Video */
 		l |= (1 << 0) | (1 << 2);
 
-	if (venc.invert_polarity == false)
+	if (venc->invert_polarity == false)
 		l |= 1 << 3;
 
-	venc_write_reg(VENC_OUTPUT_CONTROL, l);
+	venc_write_reg(venc, VENC_OUTPUT_CONTROL, l);
 
-	dss_mgr_set_timings(channel, &venc.vm);
+	dss_mgr_set_timings(channel, &venc->vm);
 
-	r = regulator_enable(venc.vdda_dac_reg);
+	r = regulator_enable(venc->vdda_dac_reg);
 	if (r)
 		goto err1;
 
@@ -501,78 +507,81 @@ static int venc_power_on(struct omap_dss_device *dssdev)
 	return 0;
 
 err2:
-	regulator_disable(venc.vdda_dac_reg);
+	regulator_disable(venc->vdda_dac_reg);
 err1:
-	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-	dss_set_dac_pwrdn_bgz(venc.dss, 0);
+	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
+	dss_set_dac_pwrdn_bgz(venc->dss, 0);
 
-	venc_runtime_put();
+	venc_runtime_put(venc);
 err0:
 	return r;
 }
 
-static void venc_power_off(struct omap_dss_device *dssdev)
+static void venc_power_off(struct venc_device *venc)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = venc->output.dispc_channel;
 
-	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-	dss_set_dac_pwrdn_bgz(venc.dss, 0);
+	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
+	dss_set_dac_pwrdn_bgz(venc->dss, 0);
 
 	dss_mgr_disable(channel);
 
-	regulator_disable(venc.vdda_dac_reg);
+	regulator_disable(venc->vdda_dac_reg);
 
-	venc_runtime_put();
+	venc_runtime_put(venc);
 }
 
 static int venc_display_enable(struct omap_dss_device *dssdev)
 {
-	struct omap_dss_device *out = &venc.output;
+	struct venc_device *venc = dssdev_to_venc(dssdev);
 	int r;
 
 	DSSDBG("venc_display_enable\n");
 
-	mutex_lock(&venc.venc_lock);
+	mutex_lock(&venc->venc_lock);
 
-	if (!out->dispc_channel_connected) {
+	if (!dssdev->dispc_channel_connected) {
 		DSSERR("Failed to enable display: no output/manager\n");
 		r = -ENODEV;
 		goto err0;
 	}
 
-	r = venc_power_on(dssdev);
+	r = venc_power_on(venc);
 	if (r)
 		goto err0;
 
-	venc.wss_data = 0;
+	venc->wss_data = 0;
 
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 
 	return 0;
 err0:
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 	return r;
 }
 
 static void venc_display_disable(struct omap_dss_device *dssdev)
 {
+	struct venc_device *venc = dssdev_to_venc(dssdev);
+
 	DSSDBG("venc_display_disable\n");
 
-	mutex_lock(&venc.venc_lock);
+	mutex_lock(&venc->venc_lock);
 
-	venc_power_off(dssdev);
+	venc_power_off(venc);
 
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 }
 
 static void venc_set_timings(struct omap_dss_device *dssdev,
 			     struct videomode *vm)
 {
+	struct venc_device *venc = dssdev_to_venc(dssdev);
 	struct videomode actual_vm;
 
 	DSSDBG("venc_set_timings\n");
 
-	mutex_lock(&venc.venc_lock);
+	mutex_lock(&venc->venc_lock);
 
 	switch (venc_get_videomode(vm)) {
 	default:
@@ -586,14 +595,14 @@ static void venc_set_timings(struct omap_dss_device *dssdev,
 	}
 
 	/* Reset WSS data when the TV standard changes. */
-	if (memcmp(&venc.vm, &actual_vm, sizeof(actual_vm)))
-		venc.wss_data = 0;
+	if (memcmp(&venc->vm, &actual_vm, sizeof(actual_vm)))
+		venc->wss_data = 0;
 
-	venc.vm = actual_vm;
+	venc->vm = actual_vm;
 
 	dispc_set_tv_pclk(13500000);
 
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 }
 
 static int venc_check_timings(struct omap_dss_device *dssdev,
@@ -613,128 +622,135 @@ static int venc_check_timings(struct omap_dss_device *dssdev,
 static void venc_get_timings(struct omap_dss_device *dssdev,
 			     struct videomode *vm)
 {
-	mutex_lock(&venc.venc_lock);
+	struct venc_device *venc = dssdev_to_venc(dssdev);
+
+	mutex_lock(&venc->venc_lock);
 
-	*vm = venc.vm;
+	*vm = venc->vm;
 
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 }
 
 static u32 venc_get_wss(struct omap_dss_device *dssdev)
 {
+	struct venc_device *venc = dssdev_to_venc(dssdev);
+
 	/* Invert due to VENC_L21_WC_CTL:INV=1 */
-	return (venc.wss_data >> 8) ^ 0xfffff;
+	return (venc->wss_data >> 8) ^ 0xfffff;
 }
 
 static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss)
 {
+	struct venc_device *venc = dssdev_to_venc(dssdev);
 	const struct venc_config *config;
 	int r;
 
 	DSSDBG("venc_set_wss\n");
 
-	mutex_lock(&venc.venc_lock);
+	mutex_lock(&venc->venc_lock);
 
-	config = venc_timings_to_config(&venc.vm);
+	config = venc_timings_to_config(&venc->vm);
 
 	/* Invert due to VENC_L21_WC_CTL:INV=1 */
-	venc.wss_data = (wss ^ 0xfffff) << 8;
+	venc->wss_data = (wss ^ 0xfffff) << 8;
 
-	r = venc_runtime_get();
+	r = venc_runtime_get(venc);
 	if (r)
 		goto err;
 
-	venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
-			venc.wss_data);
+	venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
+		       venc->wss_data);
 
-	venc_runtime_put();
+	venc_runtime_put(venc);
 
 err:
-	mutex_unlock(&venc.venc_lock);
+	mutex_unlock(&venc->venc_lock);
 
 	return r;
 }
 
-static int venc_init_regulator(void)
+static int venc_init_regulator(struct venc_device *venc)
 {
 	struct regulator *vdda_dac;
 
-	if (venc.vdda_dac_reg != NULL)
+	if (venc->vdda_dac_reg != NULL)
 		return 0;
 
-	vdda_dac = devm_regulator_get(&venc.pdev->dev, "vdda");
+	vdda_dac = devm_regulator_get(&venc->pdev->dev, "vdda");
 	if (IS_ERR(vdda_dac)) {
 		if (PTR_ERR(vdda_dac) != -EPROBE_DEFER)
 			DSSERR("can't get VDDA_DAC regulator\n");
 		return PTR_ERR(vdda_dac);
 	}
 
-	venc.vdda_dac_reg = vdda_dac;
+	venc->vdda_dac_reg = vdda_dac;
 
 	return 0;
 }
 
 static int venc_dump_regs(struct seq_file *s, void *p)
 {
-#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
+	struct venc_device *venc = s->private;
+
+#define DUMPREG(venc, r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(venc, r))
 
-	if (venc_runtime_get())
+	if (venc_runtime_get(venc))
 		return 0;
 
-	DUMPREG(VENC_F_CONTROL);
-	DUMPREG(VENC_VIDOUT_CTRL);
-	DUMPREG(VENC_SYNC_CTRL);
-	DUMPREG(VENC_LLEN);
-	DUMPREG(VENC_FLENS);
-	DUMPREG(VENC_HFLTR_CTRL);
-	DUMPREG(VENC_CC_CARR_WSS_CARR);
-	DUMPREG(VENC_C_PHASE);
-	DUMPREG(VENC_GAIN_U);
-	DUMPREG(VENC_GAIN_V);
-	DUMPREG(VENC_GAIN_Y);
-	DUMPREG(VENC_BLACK_LEVEL);
-	DUMPREG(VENC_BLANK_LEVEL);
-	DUMPREG(VENC_X_COLOR);
-	DUMPREG(VENC_M_CONTROL);
-	DUMPREG(VENC_BSTAMP_WSS_DATA);
-	DUMPREG(VENC_S_CARR);
-	DUMPREG(VENC_LINE21);
-	DUMPREG(VENC_LN_SEL);
-	DUMPREG(VENC_L21__WC_CTL);
-	DUMPREG(VENC_HTRIGGER_VTRIGGER);
-	DUMPREG(VENC_SAVID__EAVID);
-	DUMPREG(VENC_FLEN__FAL);
-	DUMPREG(VENC_LAL__PHASE_RESET);
-	DUMPREG(VENC_HS_INT_START_STOP_X);
-	DUMPREG(VENC_HS_EXT_START_STOP_X);
-	DUMPREG(VENC_VS_INT_START_X);
-	DUMPREG(VENC_VS_INT_STOP_X__VS_INT_START_Y);
-	DUMPREG(VENC_VS_INT_STOP_Y__VS_EXT_START_X);
-	DUMPREG(VENC_VS_EXT_STOP_X__VS_EXT_START_Y);
-	DUMPREG(VENC_VS_EXT_STOP_Y);
-	DUMPREG(VENC_AVID_START_STOP_X);
-	DUMPREG(VENC_AVID_START_STOP_Y);
-	DUMPREG(VENC_FID_INT_START_X__FID_INT_START_Y);
-	DUMPREG(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X);
-	DUMPREG(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y);
-	DUMPREG(VENC_TVDETGP_INT_START_STOP_X);
-	DUMPREG(VENC_TVDETGP_INT_START_STOP_Y);
-	DUMPREG(VENC_GEN_CTRL);
-	DUMPREG(VENC_OUTPUT_CONTROL);
-	DUMPREG(VENC_OUTPUT_TEST);
-
-	venc_runtime_put();
+	DUMPREG(venc, VENC_F_CONTROL);
+	DUMPREG(venc, VENC_VIDOUT_CTRL);
+	DUMPREG(venc, VENC_SYNC_CTRL);
+	DUMPREG(venc, VENC_LLEN);
+	DUMPREG(venc, VENC_FLENS);
+	DUMPREG(venc, VENC_HFLTR_CTRL);
+	DUMPREG(venc, VENC_CC_CARR_WSS_CARR);
+	DUMPREG(venc, VENC_C_PHASE);
+	DUMPREG(venc, VENC_GAIN_U);
+	DUMPREG(venc, VENC_GAIN_V);
+	DUMPREG(venc, VENC_GAIN_Y);
+	DUMPREG(venc, VENC_BLACK_LEVEL);
+	DUMPREG(venc, VENC_BLANK_LEVEL);
+	DUMPREG(venc, VENC_X_COLOR);
+	DUMPREG(venc, VENC_M_CONTROL);
+	DUMPREG(venc, VENC_BSTAMP_WSS_DATA);
+	DUMPREG(venc, VENC_S_CARR);
+	DUMPREG(venc, VENC_LINE21);
+	DUMPREG(venc, VENC_LN_SEL);
+	DUMPREG(venc, VENC_L21__WC_CTL);
+	DUMPREG(venc, VENC_HTRIGGER_VTRIGGER);
+	DUMPREG(venc, VENC_SAVID__EAVID);
+	DUMPREG(venc, VENC_FLEN__FAL);
+	DUMPREG(venc, VENC_LAL__PHASE_RESET);
+	DUMPREG(venc, VENC_HS_INT_START_STOP_X);
+	DUMPREG(venc, VENC_HS_EXT_START_STOP_X);
+	DUMPREG(venc, VENC_VS_INT_START_X);
+	DUMPREG(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y);
+	DUMPREG(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X);
+	DUMPREG(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y);
+	DUMPREG(venc, VENC_VS_EXT_STOP_Y);
+	DUMPREG(venc, VENC_AVID_START_STOP_X);
+	DUMPREG(venc, VENC_AVID_START_STOP_Y);
+	DUMPREG(venc, VENC_FID_INT_START_X__FID_INT_START_Y);
+	DUMPREG(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X);
+	DUMPREG(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y);
+	DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_X);
+	DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_Y);
+	DUMPREG(venc, VENC_GEN_CTRL);
+	DUMPREG(venc, VENC_OUTPUT_CONTROL);
+	DUMPREG(venc, VENC_OUTPUT_TEST);
+
+	venc_runtime_put(venc);
 
 #undef DUMPREG
 	return 0;
 }
 
-static int venc_get_clocks(struct platform_device *pdev)
+static int venc_get_clocks(struct venc_device *venc)
 {
 	struct clk *clk;
 
-	if (venc.requires_tv_dac_clk) {
-		clk = devm_clk_get(&pdev->dev, "tv_dac_clk");
+	if (venc->requires_tv_dac_clk) {
+		clk = devm_clk_get(&venc->pdev->dev, "tv_dac_clk");
 		if (IS_ERR(clk)) {
 			DSSERR("can't get tv_dac_clk\n");
 			return PTR_ERR(clk);
@@ -743,7 +759,7 @@ static int venc_get_clocks(struct platform_device *pdev)
 		clk = NULL;
 	}
 
-	venc.tv_dac_clk = clk;
+	venc->tv_dac_clk = clk;
 
 	return 0;
 }
@@ -751,10 +767,11 @@ static int venc_get_clocks(struct platform_device *pdev)
 static int venc_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
+	struct venc_device *venc = dssdev_to_venc(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
-	r = venc_init_regulator();
+	r = venc_init_regulator(venc);
 	if (r)
 		return r;
 
@@ -803,11 +820,11 @@ static const struct omapdss_atv_ops venc_ops = {
 	.get_wss = venc_get_wss,
 };
 
-static void venc_init_output(struct platform_device *pdev)
+static void venc_init_output(struct venc_device *venc)
 {
-	struct omap_dss_device *out = &venc.output;
+	struct omap_dss_device *out = &venc->output;
 
-	out->dev = &pdev->dev;
+	out->dev = &venc->pdev->dev;
 	out->id = OMAP_DSS_OUTPUT_VENC;
 	out->output_type = OMAP_DISPLAY_TYPE_VENC;
 	out->name = "venc.0";
@@ -818,16 +835,14 @@ static void venc_init_output(struct platform_device *pdev)
 	omapdss_register_output(out);
 }
 
-static void venc_uninit_output(struct platform_device *pdev)
+static void venc_uninit_output(struct venc_device *venc)
 {
-	struct omap_dss_device *out = &venc.output;
-
-	omapdss_unregister_output(out);
+	omapdss_unregister_output(&venc->output);
 }
 
-static int venc_probe_of(struct platform_device *pdev)
+static int venc_probe_of(struct venc_device *venc)
 {
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = venc->pdev->dev.of_node;
 	struct device_node *ep;
 	u32 channels;
 	int r;
@@ -836,24 +851,25 @@ static int venc_probe_of(struct platform_device *pdev)
 	if (!ep)
 		return 0;
 
-	venc.invert_polarity = of_property_read_bool(ep, "ti,invert-polarity");
+	venc->invert_polarity = of_property_read_bool(ep, "ti,invert-polarity");
 
 	r = of_property_read_u32(ep, "ti,channels", &channels);
 	if (r) {
-		dev_err(&pdev->dev,
+		dev_err(&venc->pdev->dev,
 			"failed to read property 'ti,channels': %d\n", r);
 		goto err;
 	}
 
 	switch (channels) {
 	case 1:
-		venc.type = OMAP_DSS_VENC_TYPE_COMPOSITE;
+		venc->type = OMAP_DSS_VENC_TYPE_COMPOSITE;
 		break;
 	case 2:
-		venc.type = OMAP_DSS_VENC_TYPE_SVIDEO;
+		venc->type = OMAP_DSS_VENC_TYPE_SVIDEO;
 		break;
 	default:
-		dev_err(&pdev->dev, "bad channel propert '%d'\n", channels);
+		dev_err(&venc->pdev->dev, "bad channel propert '%d'\n",
+			channels);
 		r = -EINVAL;
 		goto err;
 	}
@@ -878,68 +894,80 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dss_device *dss = dss_get_device(master);
+	struct venc_device *venc;
 	u8 rev_id;
 	struct resource *venc_mem;
 	int r;
 
-	venc.pdev = pdev;
-	venc.dss = dss;
+	venc = kzalloc(sizeof(*venc), GFP_KERNEL);
+	if (!venc)
+		return -ENOMEM;
+
+	venc->pdev = pdev;
+	venc->dss = dss;
+	dev_set_drvdata(dev, venc);
 
 	/* The OMAP34xx, OMAP35xx and AM35xx VENC require the TV DAC clock. */
 	if (soc_device_match(venc_soc_devices))
-		venc.requires_tv_dac_clk = true;
+		venc->requires_tv_dac_clk = true;
 
-	mutex_init(&venc.venc_lock);
+	mutex_init(&venc->venc_lock);
 
-	venc.wss_data = 0;
+	venc->wss_data = 0;
 
-	venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0);
-	venc.base = devm_ioremap_resource(&pdev->dev, venc_mem);
-	if (IS_ERR(venc.base))
-		return PTR_ERR(venc.base);
+	venc_mem = platform_get_resource(venc->pdev, IORESOURCE_MEM, 0);
+	venc->base = devm_ioremap_resource(&pdev->dev, venc_mem);
+	if (IS_ERR(venc->base)) {
+		r = PTR_ERR(venc->base);
+		goto err_free;
+	}
 
-	r = venc_get_clocks(pdev);
+	r = venc_get_clocks(venc);
 	if (r)
-		return r;
+		goto err_free;
 
 	pm_runtime_enable(&pdev->dev);
 
-	r = venc_runtime_get();
+	r = venc_runtime_get(venc);
 	if (r)
 		goto err_runtime_get;
 
-	rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
+	rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff);
 	dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id);
 
-	venc_runtime_put();
+	venc_runtime_put(venc);
 
-	r = venc_probe_of(pdev);
+	r = venc_probe_of(venc);
 	if (r) {
 		DSSERR("Invalid DT data\n");
 		goto err_probe_of;
 	}
 
-	venc.debugfs = dss_debugfs_create_file("venc", venc_dump_regs, &venc);
+	venc->debugfs = dss_debugfs_create_file("venc", venc_dump_regs, venc);
 
-	venc_init_output(pdev);
+	venc_init_output(venc);
 
 	return 0;
 
 err_probe_of:
 err_runtime_get:
 	pm_runtime_disable(&pdev->dev);
+err_free:
+	kfree(venc);
 	return r;
 }
 
 static void venc_unbind(struct device *dev, struct device *master, void *data)
 {
-	struct platform_device *pdev = to_platform_device(dev);
+	struct venc_device *venc = dev_get_drvdata(dev);
 
-	dss_debugfs_remove_file(venc.debugfs);
+	dss_debugfs_remove_file(venc->debugfs);
 
-	venc_uninit_output(pdev);
+	venc_uninit_output(venc);
 
-	pm_runtime_disable(&pdev->dev);
+	pm_runtime_disable(dev);
+
+	kfree(venc);
 }
 
 static const struct component_ops venc_component_ops = {
@@ -960,8 +988,10 @@ static int venc_remove(struct platform_device *pdev)
 
 static int venc_runtime_suspend(struct device *dev)
 {
-	if (venc.tv_dac_clk)
-		clk_disable_unprepare(venc.tv_dac_clk);
+	struct venc_device *venc = dev_get_drvdata(dev);
+
+	if (venc->tv_dac_clk)
+		clk_disable_unprepare(venc->tv_dac_clk);
 
 	dispc_runtime_put();
 
@@ -970,14 +1000,15 @@ static int venc_runtime_suspend(struct device *dev)
 
 static int venc_runtime_resume(struct device *dev)
 {
+	struct venc_device *venc = dev_get_drvdata(dev);
 	int r;
 
 	r = dispc_runtime_get();
 	if (r < 0)
 		return r;
 
-	if (venc.tv_dac_clk)
-		clk_prepare_enable(venc.tv_dac_clk);
+	if (venc->tv_dac_clk)
+		clk_prepare_enable(venc->tv_dac_clk);
 
 	return 0;
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi private data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (32 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 19:09   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status Laurent Pinchart
                   ` (17 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The sdi private data structure is currently stored as a global
variable. While no platform with multiple SDI encoders currently exists
nor is planned, this doesn't comply with the kernel device model and
should thus be fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/sdi.c | 122 +++++++++++++++++++++-----------------
 1 file changed, 69 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index ac436826914a..a35dc51c5a6a 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -31,7 +31,7 @@
 #include "omapdss.h"
 #include "dss.h"
 
-static struct {
+struct sdi_device {
 	struct platform_device *pdev;
 	struct dss_device *dss;
 
@@ -43,9 +43,9 @@ static struct {
 	int datapairs;
 
 	struct omap_dss_device output;
+};
 
-	bool port_initialized;
-} sdi;
+#define dssdev_to_sdi(dssdev) container_of(dssdev, struct sdi_device, output)
 
 struct sdi_clk_calc_ctx {
 	unsigned long pck_min, pck_max;
@@ -77,9 +77,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
 			dpi_calc_dispc_cb, ctx);
 }
 
-static int sdi_calc_clock_div(unsigned long pclk,
-		unsigned long *fck,
-		struct dispc_clock_info *dispc_cinfo)
+static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
+			      unsigned long *fck,
+			      struct dispc_clock_info *dispc_cinfo)
 {
 	int i;
 	struct sdi_clk_calc_ctx ctx;
@@ -101,7 +101,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
 			ctx.pck_min = 0;
 		ctx.pck_max = pclk + 1000 * i * i * i;
 
-		ok = dss_div_calc(sdi.dss, pclk, ctx.pck_min,
+		ok = dss_div_calc(sdi->dss, pclk, ctx.pck_min,
 				  dpi_calc_dss_cb, &ctx);
 		if (ok) {
 			*fck = ctx.fck;
@@ -113,26 +113,27 @@ static int sdi_calc_clock_div(unsigned long pclk,
 	return -EINVAL;
 }
 
-static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
+static void sdi_config_lcd_manager(struct sdi_device *sdi)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	enum omap_channel channel = sdi->output.dispc_channel;
 
-	sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
+	sdi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
-	sdi.mgr_config.stallmode = false;
-	sdi.mgr_config.fifohandcheck = false;
+	sdi->mgr_config.stallmode = false;
+	sdi->mgr_config.fifohandcheck = false;
 
-	sdi.mgr_config.video_port_width = 24;
-	sdi.mgr_config.lcden_sig_polarity = 1;
+	sdi->mgr_config.video_port_width = 24;
+	sdi->mgr_config.lcden_sig_polarity = 1;
 
-	dss_mgr_set_lcd_config(channel, &sdi.mgr_config);
+	dss_mgr_set_lcd_config(channel, &sdi->mgr_config);
 }
 
 static int sdi_display_enable(struct omap_dss_device *dssdev)
 {
-	struct omap_dss_device *out = &sdi.output;
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
+	struct omap_dss_device *out = &sdi->output;
 	enum omap_channel channel = dssdev->dispc_channel;
-	struct videomode *vm = &sdi.vm;
+	struct videomode *vm = &sdi->vm;
 	unsigned long fck;
 	struct dispc_clock_info dispc_cinfo;
 	unsigned long pck;
@@ -143,7 +144,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 		return -ENODEV;
 	}
 
-	r = regulator_enable(sdi.vdds_sdi_reg);
+	r = regulator_enable(sdi->vdds_sdi_reg);
 	if (r)
 		goto err_reg_enable;
 
@@ -154,11 +155,11 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	/* 15.5.9.1.2 */
 	vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_SYNC_POSEDGE;
 
-	r = sdi_calc_clock_div(vm->pixelclock, &fck, &dispc_cinfo);
+	r = sdi_calc_clock_div(sdi, vm->pixelclock, &fck, &dispc_cinfo);
 	if (r)
 		goto err_calc_clock_div;
 
-	sdi.mgr_config.clock_info = dispc_cinfo;
+	sdi->mgr_config.clock_info = dispc_cinfo;
 
 	pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div;
 
@@ -172,11 +173,11 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 
 	dss_mgr_set_timings(channel, vm);
 
-	r = dss_set_fck_rate(sdi.dss, fck);
+	r = dss_set_fck_rate(sdi->dss, fck);
 	if (r)
 		goto err_set_dss_clock_div;
 
-	sdi_config_lcd_manager(dssdev);
+	sdi_config_lcd_manager(sdi);
 
 	/*
 	 * LCLK and PCLK divisors are located in shadow registers, and we
@@ -189,10 +190,10 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	 * need to care about the shadow register mechanism for pck-free. The
 	 * exact reason for this is unknown.
 	 */
-	dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
+	dispc_mgr_set_clock_div(channel, &sdi->mgr_config.clock_info);
 
-	dss_sdi_init(sdi.dss, sdi.datapairs);
-	r = dss_sdi_enable(sdi.dss);
+	dss_sdi_init(sdi->dss, sdi->datapairs);
+	r = dss_sdi_enable(sdi->dss);
 	if (r)
 		goto err_sdi_enable;
 	mdelay(2);
@@ -204,40 +205,45 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	return 0;
 
 err_mgr_enable:
-	dss_sdi_disable(sdi.dss);
+	dss_sdi_disable(sdi->dss);
 err_sdi_enable:
 err_set_dss_clock_div:
 err_calc_clock_div:
 	dispc_runtime_put();
 err_get_dispc:
-	regulator_disable(sdi.vdds_sdi_reg);
+	regulator_disable(sdi->vdds_sdi_reg);
 err_reg_enable:
 	return r;
 }
 
 static void sdi_display_disable(struct omap_dss_device *dssdev)
 {
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 
 	dss_mgr_disable(channel);
 
-	dss_sdi_disable(sdi.dss);
+	dss_sdi_disable(sdi->dss);
 
 	dispc_runtime_put();
 
-	regulator_disable(sdi.vdds_sdi_reg);
+	regulator_disable(sdi->vdds_sdi_reg);
 }
 
 static void sdi_set_timings(struct omap_dss_device *dssdev,
 			    struct videomode *vm)
 {
-	sdi.vm = *vm;
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
+
+	sdi->vm = *vm;
 }
 
 static void sdi_get_timings(struct omap_dss_device *dssdev,
 			    struct videomode *vm)
 {
-	*vm = sdi.vm;
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
+
+	*vm = sdi->vm;
 }
 
 static int sdi_check_timings(struct omap_dss_device *dssdev,
@@ -254,21 +260,21 @@ static int sdi_check_timings(struct omap_dss_device *dssdev,
 	return 0;
 }
 
-static int sdi_init_regulator(void)
+static int sdi_init_regulator(struct sdi_device *sdi)
 {
 	struct regulator *vdds_sdi;
 
-	if (sdi.vdds_sdi_reg)
+	if (sdi->vdds_sdi_reg)
 		return 0;
 
-	vdds_sdi = devm_regulator_get(&sdi.pdev->dev, "vdds_sdi");
+	vdds_sdi = devm_regulator_get(&sdi->pdev->dev, "vdds_sdi");
 	if (IS_ERR(vdds_sdi)) {
 		if (PTR_ERR(vdds_sdi) != -EPROBE_DEFER)
 			DSSERR("can't get VDDS_SDI regulator\n");
 		return PTR_ERR(vdds_sdi);
 	}
 
-	sdi.vdds_sdi_reg = vdds_sdi;
+	sdi->vdds_sdi_reg = vdds_sdi;
 
 	return 0;
 }
@@ -276,10 +282,11 @@ static int sdi_init_regulator(void)
 static int sdi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
-	r = sdi_init_regulator();
+	r = sdi_init_regulator(sdi);
 	if (r)
 		return r;
 
@@ -325,11 +332,11 @@ static const struct omapdss_sdi_ops sdi_ops = {
 	.get_timings = sdi_get_timings,
 };
 
-static void sdi_init_output(struct platform_device *pdev)
+static void sdi_init_output(struct sdi_device *sdi)
 {
-	struct omap_dss_device *out = &sdi.output;
+	struct omap_dss_device *out = &sdi->output;
 
-	out->dev = &pdev->dev;
+	out->dev = &sdi->pdev->dev;
 	out->id = OMAP_DSS_OUTPUT_SDI;
 	out->output_type = OMAP_DISPLAY_TYPE_SDI;
 	out->name = "sdi.0";
@@ -342,23 +349,28 @@ static void sdi_init_output(struct platform_device *pdev)
 	omapdss_register_output(out);
 }
 
-static void sdi_uninit_output(struct platform_device *pdev)
+static void sdi_uninit_output(struct sdi_device *sdi)
 {
-	struct omap_dss_device *out = &sdi.output;
-
-	omapdss_unregister_output(out);
+	omapdss_unregister_output(&sdi->output);
 }
 
 int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
 		  struct device_node *port)
 {
+	struct sdi_device *sdi;
 	struct device_node *ep;
 	u32 datapairs;
 	int r;
 
+	sdi = kzalloc(sizeof(*sdi), GFP_KERNEL);
+	if (!sdi)
+		return -ENOMEM;
+
 	ep = of_get_next_child(port, NULL);
-	if (!ep)
-		return 0;
+	if (!ep) {
+		r = 0;
+		goto err_free;
+	}
 
 	r = of_property_read_u32(ep, "datapairs", &datapairs);
 	if (r) {
@@ -366,29 +378,33 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
 		goto err_datapairs;
 	}
 
-	sdi.datapairs = datapairs;
-	sdi.dss = dss;
+	sdi->datapairs = datapairs;
+	sdi->dss = dss;
 
 	of_node_put(ep);
 
-	sdi.pdev = pdev;
+	sdi->pdev = pdev;
+	port->data = sdi;
 
-	sdi_init_output(pdev);
-
-	sdi.port_initialized = true;
+	sdi_init_output(sdi);
 
 	return 0;
 
 err_datapairs:
 	of_node_put(ep);
+err_free:
+	kfree(sdi);
 
 	return r;
 }
 
 void sdi_uninit_port(struct device_node *port)
 {
-	if (!sdi.port_initialized)
+	struct sdi_device *sdi = port->data;
+
+	if (!sdi)
 		return;
 
-	sdi_uninit_output(sdi.pdev);
+	sdi_uninit_output(sdi);
+	kfree(sdi);
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (33 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi " Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 19:12   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
                   ` (16 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The wait_for_bit_change() function returns the value of the bit it
polls. This requires the caller to compare the return value to the
expected bit value. As all the existing callers need is to check whether
the bit has reached the expected value, it's easier to return a boolean
status from the function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7fb048023fd0..c94bb6404a69 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -531,7 +531,7 @@ static void dsi_completion_handler(void *data, u32 mask)
 	complete((struct completion *)data);
 }
 
-static inline int wait_for_bit_change(struct platform_device *dsidev,
+static inline bool wait_for_bit_change(struct platform_device *dsidev,
 		const struct dsi_reg idx, int bitnum, int value)
 {
 	unsigned long timeout;
@@ -542,21 +542,21 @@ static inline int wait_for_bit_change(struct platform_device *dsidev,
 	t = 100;
 	while (t-- > 0) {
 		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-			return value;
+			return true;
 	}
 
 	/* then loop for 500ms, sleeping for 1ms in between */
 	timeout = jiffies + msecs_to_jiffies(500);
 	while (time_before(jiffies, timeout)) {
 		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-			return value;
+			return true;
 
 		wait = ns_to_ktime(1000 * 1000);
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_hrtimeout(&wait, HRTIMER_MODE_REL);
 	}
 
-	return !value;
+	return false;
 }
 
 static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
@@ -1259,9 +1259,9 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
 	enable = enable ? 1 : 0;
 	REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
 
-	if (wait_for_bit_change(dsidev, DSI_CTRL, 0, enable) != enable) {
-			DSSERR("Failed to set dsi_if_enable to %d\n", enable);
-			return -EIO;
+	if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
+		DSSERR("Failed to set dsi_if_enable to %d\n", enable);
+		return -EIO;
 	}
 
 	return 0;
@@ -1450,7 +1450,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
 	/* XXX PLL does not come out of reset without this... */
 	dispc_pck_free_enable(1);
 
-	if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
 		DSSERR("PLL not coming out of reset.\n");
 		r = -ENODEV;
 		dispc_pck_free_enable(0);
@@ -2200,7 +2200,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	 * I/O. */
 	dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
 
-	if (wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
 		DSSERR("CIO SCP Clock domain not coming out of reset.\n");
 		r = -EIO;
 		goto err_scp_clk_dom;
@@ -2248,7 +2248,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	if (r)
 		goto err_cio_pwr;
 
-	if (wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
 		DSSERR("CIO PWR clock domain not coming out of reset.\n");
 		r = -ENODEV;
 		goto err_cio_pwr_dom;
@@ -2389,7 +2389,7 @@ static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
 	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
 	dsi_write_reg(dsidev, DSI_TIMING1, r);
 
-	if (wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0) != 0) {
+	if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
 		DSSERR("TX_STOP bit not going down\n");
 		return -EIO;
 	}
@@ -2531,10 +2531,9 @@ static int dsi_vc_enable(struct platform_device *dsidev, int channel,
 
 	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
 
-	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel),
-		0, enable) != enable) {
-			DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
-			return -EIO;
+	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
+		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
+		return -EIO;
 	}
 
 	return 0;
@@ -2586,7 +2585,7 @@ static int dsi_vc_config_source(struct platform_device *dsidev, int channel,
 	dsi_vc_enable(dsidev, channel, 0);
 
 	/* VC_BUSY */
-	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0) != 0) {
+	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0)) {
 		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
 		return -EIO;
 	}
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (34 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:02   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
                   ` (15 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

Internal dsi functions take a pointer to the DSI platform_device and
then cast it to a dsi_data pointer. That's pointless as the caller
already has the dsi_data pointer. Pass it directly instead of the
platform_device pointer.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 1228 +++++++++++++++++--------------------
 1 file changed, 564 insertions(+), 664 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c94bb6404a69..312804104ad3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -121,11 +121,11 @@ struct dsi_reg { u16 module; u16 idx; };
 #define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
 #define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
 
-#define REG_GET(dsidev, idx, start, end) \
-	FLD_GET(dsi_read_reg(dsidev, idx), start, end)
+#define REG_GET(dsi, idx, start, end) \
+	FLD_GET(dsi_read_reg(dsi, idx), start, end)
 
-#define REG_FLD_MOD(dsidev, idx, val, start, end) \
-	dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end))
+#define REG_FLD_MOD(dsi, idx, val, start, end) \
+	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
 
 /* Global interrupts */
 #define DSI_IRQ_VC0		(1 << 0)
@@ -215,13 +215,14 @@ struct dsi_reg { u16 module; u16 idx; };
 	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
 
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
+struct dsi_data;
 
-static int dsi_display_init_dispc(struct platform_device *dsidev,
+static int dsi_display_init_dispc(struct dsi_data *dsi,
 	enum omap_channel channel);
-static void dsi_display_uninit_dispc(struct platform_device *dsidev,
+static void dsi_display_uninit_dispc(struct dsi_data *dsi,
 	enum omap_channel channel);
 
-static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
+static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC	0
@@ -284,7 +285,7 @@ struct dsi_isr_tables {
 };
 
 struct dsi_clk_calc_ctx {
-	struct platform_device *dsidev;
+	struct dsi_data *dsi;
 	struct dss_pll *pll;
 
 	/* inputs */
@@ -431,7 +432,7 @@ struct dsi_data {
 };
 
 struct dsi_packet_sent_handler_data {
-	struct platform_device *dsidev;
+	struct dsi_data *dsi;
 	struct completion *completion;
 };
 
@@ -450,7 +451,7 @@ static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss
 	return to_platform_device(dssdev->dev);
 }
 
-static struct platform_device *dsi_get_dsidev_from_id(int module)
+static struct dsi_data *dsi_get_dsi_from_id(int module)
 {
 	struct omap_dss_device *out;
 	enum omap_dss_output_id	id;
@@ -468,13 +469,12 @@ static struct platform_device *dsi_get_dsidev_from_id(int module)
 
 	out = omap_dss_get_output(id);
 
-	return out ? to_platform_device(out->dev) : NULL;
+	return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
 }
 
-static inline void dsi_write_reg(struct platform_device *dsidev,
-		const struct dsi_reg idx, u32 val)
+static inline void dsi_write_reg(struct dsi_data *dsi,
+				 const struct dsi_reg idx, u32 val)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	void __iomem *base;
 
 	switch(idx.module) {
@@ -487,10 +487,8 @@ static inline void dsi_write_reg(struct platform_device *dsidev,
 	__raw_writel(val, base + idx.idx);
 }
 
-static inline u32 dsi_read_reg(struct platform_device *dsidev,
-		const struct dsi_reg idx)
+static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	void __iomem *base;
 
 	switch(idx.module) {
@@ -519,10 +517,8 @@ static void dsi_bus_unlock(struct omap_dss_device *dssdev)
 	up(&dsi->bus_lock);
 }
 
-static bool dsi_bus_is_locked(struct platform_device *dsidev)
+static bool dsi_bus_is_locked(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	return dsi->bus_lock.count == 0;
 }
 
@@ -531,8 +527,9 @@ static void dsi_completion_handler(void *data, u32 mask)
 	complete((struct completion *)data);
 }
 
-static inline bool wait_for_bit_change(struct platform_device *dsidev,
-		const struct dsi_reg idx, int bitnum, int value)
+static inline bool wait_for_bit_change(struct dsi_data *dsi,
+				       const struct dsi_reg idx,
+				       int bitnum, int value)
 {
 	unsigned long timeout;
 	ktime_t wait;
@@ -541,14 +538,14 @@ static inline bool wait_for_bit_change(struct platform_device *dsidev,
 	/* first busyloop to see if the bit changes right away */
 	t = 100;
 	while (t-- > 0) {
-		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
+		if (REG_GET(dsi, idx, bitnum, bitnum) == value)
 			return true;
 	}
 
 	/* then loop for 500ms, sleeping for 1ms in between */
 	timeout = jiffies + msecs_to_jiffies(500);
 	while (time_before(jiffies, timeout)) {
-		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
+		if (REG_GET(dsi, idx, bitnum, bitnum) == value)
 			return true;
 
 		wait = ns_to_ktime(1000 * 1000);
@@ -576,21 +573,18 @@ static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
 }
 
 #ifdef DSI_PERF_MEASURE
-static void dsi_perf_mark_setup(struct platform_device *dsidev)
+static void dsi_perf_mark_setup(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	dsi->perf_setup_time = ktime_get();
 }
 
-static void dsi_perf_mark_start(struct platform_device *dsidev)
+static void dsi_perf_mark_start(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	dsi->perf_start_time = ktime_get();
 }
 
-static void dsi_perf_show(struct platform_device *dsidev, const char *name)
+static void dsi_perf_show(struct dsi_data *dsi, const char *name)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	ktime_t t, setup_time, trans_time;
 	u32 total_bytes;
 	u32 setup_us, trans_us, total_us;
@@ -624,16 +618,15 @@ static void dsi_perf_show(struct platform_device *dsidev, const char *name)
 		total_bytes * 1000 / total_us);
 }
 #else
-static inline void dsi_perf_mark_setup(struct platform_device *dsidev)
+static inline void dsi_perf_mark_setup(struct dsi_data *dsi)
 {
 }
 
-static inline void dsi_perf_mark_start(struct platform_device *dsidev)
+static inline void dsi_perf_mark_start(struct dsi_data *dsi)
 {
 }
 
-static inline void dsi_perf_show(struct platform_device *dsidev,
-		const char *name)
+static inline void dsi_perf_show(struct dsi_data *dsi, const char *name)
 {
 }
 #endif
@@ -730,10 +723,9 @@ static void print_irq_status_cio(u32 status)
 }
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-static void dsi_collect_irq_stats(struct platform_device *dsidev, u32 irqstatus,
-		u32 *vcstatus, u32 ciostatus)
+static void dsi_collect_irq_stats(struct dsi_data *dsi, u32 irqstatus,
+				  u32 *vcstatus, u32 ciostatus)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int i;
 
 	spin_lock(&dsi->irq_stats_lock);
@@ -749,15 +741,14 @@ static void dsi_collect_irq_stats(struct platform_device *dsidev, u32 irqstatus,
 	spin_unlock(&dsi->irq_stats_lock);
 }
 #else
-#define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus)
+#define dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus)
 #endif
 
 static int debug_irq;
 
-static void dsi_handle_irq_errors(struct platform_device *dsidev, u32 irqstatus,
-		u32 *vcstatus, u32 ciostatus)
+static void dsi_handle_irq_errors(struct dsi_data *dsi, u32 irqstatus,
+				  u32 *vcstatus, u32 ciostatus)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int i;
 
 	if (irqstatus & DSI_IRQ_ERROR_MASK) {
@@ -826,20 +817,16 @@ static void dsi_handle_isrs(struct dsi_isr_tables *isr_tables,
 
 static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
 {
-	struct platform_device *dsidev;
-	struct dsi_data *dsi;
+	struct dsi_data *dsi = arg;
 	u32 irqstatus, vcstatus[4], ciostatus;
 	int i;
 
-	dsidev = (struct platform_device *) arg;
-	dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (!dsi->is_enabled)
 		return IRQ_NONE;
 
 	spin_lock(&dsi->irq_lock);
 
-	irqstatus = dsi_read_reg(dsidev, DSI_IRQSTATUS);
+	irqstatus = dsi_read_reg(dsi, DSI_IRQSTATUS);
 
 	/* IRQ is not for us */
 	if (!irqstatus) {
@@ -847,9 +834,9 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 	}
 
-	dsi_write_reg(dsidev, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK);
+	dsi_write_reg(dsi, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK);
 	/* flush posted write */
-	dsi_read_reg(dsidev, DSI_IRQSTATUS);
+	dsi_read_reg(dsi, DSI_IRQSTATUS);
 
 	for (i = 0; i < 4; ++i) {
 		if ((irqstatus & (1 << i)) == 0) {
@@ -857,19 +844,19 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
 			continue;
 		}
 
-		vcstatus[i] = dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i));
+		vcstatus[i] = dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i));
 
-		dsi_write_reg(dsidev, DSI_VC_IRQSTATUS(i), vcstatus[i]);
+		dsi_write_reg(dsi, DSI_VC_IRQSTATUS(i), vcstatus[i]);
 		/* flush posted write */
-		dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i));
+		dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i));
 	}
 
 	if (irqstatus & DSI_IRQ_COMPLEXIO_ERR) {
-		ciostatus = dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS);
+		ciostatus = dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS);
 
-		dsi_write_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS, ciostatus);
+		dsi_write_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS, ciostatus);
 		/* flush posted write */
-		dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS);
+		dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS);
 	} else {
 		ciostatus = 0;
 	}
@@ -888,19 +875,20 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
 
 	dsi_handle_isrs(&dsi->isr_tables_copy, irqstatus, vcstatus, ciostatus);
 
-	dsi_handle_irq_errors(dsidev, irqstatus, vcstatus, ciostatus);
+	dsi_handle_irq_errors(dsi, irqstatus, vcstatus, ciostatus);
 
-	dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus);
+	dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus);
 
 	return IRQ_HANDLED;
 }
 
 /* dsi->irq_lock has to be locked by the caller */
-static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
-		struct dsi_isr_data *isr_array,
-		unsigned int isr_array_size, u32 default_mask,
-		const struct dsi_reg enable_reg,
-		const struct dsi_reg status_reg)
+static void _omap_dsi_configure_irqs(struct dsi_data *dsi,
+				     struct dsi_isr_data *isr_array,
+				     unsigned int isr_array_size,
+				     u32 default_mask,
+				     const struct dsi_reg enable_reg,
+				     const struct dsi_reg status_reg)
 {
 	struct dsi_isr_data *isr_data;
 	u32 mask;
@@ -918,54 +906,48 @@ static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
 		mask |= isr_data->mask;
 	}
 
-	old_mask = dsi_read_reg(dsidev, enable_reg);
+	old_mask = dsi_read_reg(dsi, enable_reg);
 	/* clear the irqstatus for newly enabled irqs */
-	dsi_write_reg(dsidev, status_reg, (mask ^ old_mask) & mask);
-	dsi_write_reg(dsidev, enable_reg, mask);
+	dsi_write_reg(dsi, status_reg, (mask ^ old_mask) & mask);
+	dsi_write_reg(dsi, enable_reg, mask);
 
 	/* flush posted writes */
-	dsi_read_reg(dsidev, enable_reg);
-	dsi_read_reg(dsidev, status_reg);
+	dsi_read_reg(dsi, enable_reg);
+	dsi_read_reg(dsi, status_reg);
 }
 
 /* dsi->irq_lock has to be locked by the caller */
-static void _omap_dsi_set_irqs(struct platform_device *dsidev)
+static void _omap_dsi_set_irqs(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 mask = DSI_IRQ_ERROR_MASK;
 #ifdef DSI_CATCH_MISSING_TE
 	mask |= DSI_IRQ_TE_TRIGGER;
 #endif
-	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table,
+	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table,
 			ARRAY_SIZE(dsi->isr_tables.isr_table), mask,
 			DSI_IRQENABLE, DSI_IRQSTATUS);
 }
 
 /* dsi->irq_lock has to be locked by the caller */
-static void _omap_dsi_set_irqs_vc(struct platform_device *dsidev, int vc)
+static void _omap_dsi_set_irqs_vc(struct dsi_data *dsi, int vc)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
-	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_vc[vc],
+	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_vc[vc],
 			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]),
 			DSI_VC_IRQ_ERROR_MASK,
 			DSI_VC_IRQENABLE(vc), DSI_VC_IRQSTATUS(vc));
 }
 
 /* dsi->irq_lock has to be locked by the caller */
-static void _omap_dsi_set_irqs_cio(struct platform_device *dsidev)
+static void _omap_dsi_set_irqs_cio(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
-	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_cio,
+	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_cio,
 			ARRAY_SIZE(dsi->isr_tables.isr_table_cio),
 			DSI_CIO_IRQ_ERROR_MASK,
 			DSI_COMPLEXIO_IRQ_ENABLE, DSI_COMPLEXIO_IRQ_STATUS);
 }
 
-static void _dsi_initialize_irq(struct platform_device *dsidev)
+static void _dsi_initialize_irq(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int vc;
 
@@ -973,10 +955,10 @@ static void _dsi_initialize_irq(struct platform_device *dsidev)
 
 	memset(&dsi->isr_tables, 0, sizeof(dsi->isr_tables));
 
-	_omap_dsi_set_irqs(dsidev);
+	_omap_dsi_set_irqs(dsi);
 	for (vc = 0; vc < 4; ++vc)
-		_omap_dsi_set_irqs_vc(dsidev, vc);
-	_omap_dsi_set_irqs_cio(dsidev);
+		_omap_dsi_set_irqs_vc(dsi, vc);
+	_omap_dsi_set_irqs_cio(dsi);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 }
@@ -1037,10 +1019,9 @@ static int _dsi_unregister_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
 	return -EINVAL;
 }
 
-static int dsi_register_isr(struct platform_device *dsidev, omap_dsi_isr_t isr,
-		void *arg, u32 mask)
+static int dsi_register_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
+			    void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1050,17 +1031,16 @@ static int dsi_register_isr(struct platform_device *dsidev, omap_dsi_isr_t isr,
 			ARRAY_SIZE(dsi->isr_tables.isr_table));
 
 	if (r == 0)
-		_omap_dsi_set_irqs(dsidev);
+		_omap_dsi_set_irqs(dsi);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_unregister_isr(struct platform_device *dsidev,
-		omap_dsi_isr_t isr, void *arg, u32 mask)
+static int dsi_unregister_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
+			      void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1070,17 +1050,16 @@ static int dsi_unregister_isr(struct platform_device *dsidev,
 			ARRAY_SIZE(dsi->isr_tables.isr_table));
 
 	if (r == 0)
-		_omap_dsi_set_irqs(dsidev);
+		_omap_dsi_set_irqs(dsi);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_register_isr_vc(struct platform_device *dsidev, int channel,
-		omap_dsi_isr_t isr, void *arg, u32 mask)
+static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
+			       omap_dsi_isr_t isr, void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1091,17 +1070,16 @@ static int dsi_register_isr_vc(struct platform_device *dsidev, int channel,
 			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_vc(dsidev, channel);
+		_omap_dsi_set_irqs_vc(dsi, channel);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_unregister_isr_vc(struct platform_device *dsidev, int channel,
-		omap_dsi_isr_t isr, void *arg, u32 mask)
+static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
+				 omap_dsi_isr_t isr, void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1112,17 +1090,16 @@ static int dsi_unregister_isr_vc(struct platform_device *dsidev, int channel,
 			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_vc(dsidev, channel);
+		_omap_dsi_set_irqs_vc(dsi, channel);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_register_isr_cio(struct platform_device *dsidev,
-		omap_dsi_isr_t isr, void *arg, u32 mask)
+static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
+				void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1132,17 +1109,16 @@ static int dsi_register_isr_cio(struct platform_device *dsidev,
 			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_cio(dsidev);
+		_omap_dsi_set_irqs_cio(dsi);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_unregister_isr_cio(struct platform_device *dsidev,
-		omap_dsi_isr_t isr, void *arg, u32 mask)
+static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
+				  void *arg, u32 mask)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	int r;
 
@@ -1152,18 +1128,18 @@ static int dsi_unregister_isr_cio(struct platform_device *dsidev,
 			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_cio(dsidev);
+		_omap_dsi_set_irqs_cio(dsi);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static u32 dsi_get_errors(struct platform_device *dsidev)
+static u32 dsi_get_errors(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	u32 e;
+
 	spin_lock_irqsave(&dsi->errors_lock, flags);
 	e = dsi->errors;
 	dsi->errors = 0;
@@ -1171,10 +1147,9 @@ static u32 dsi_get_errors(struct platform_device *dsidev)
 	return e;
 }
 
-static int dsi_runtime_get(struct platform_device *dsidev)
+static int dsi_runtime_get(struct dsi_data *dsi)
 {
 	int r;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
 	DSSDBG("dsi_runtime_get\n");
 
@@ -1183,9 +1158,8 @@ static int dsi_runtime_get(struct platform_device *dsidev)
 	return r < 0 ? r : 0;
 }
 
-static void dsi_runtime_put(struct platform_device *dsidev)
+static void dsi_runtime_put(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
 	DSSDBG("dsi_runtime_put\n");
@@ -1194,9 +1168,8 @@ static void dsi_runtime_put(struct platform_device *dsidev)
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
-static int dsi_regulator_init(struct platform_device *dsidev)
+static int dsi_regulator_init(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct regulator *vdds_dsi;
 
 	if (dsi->vdds_dsi_reg != NULL)
@@ -1215,16 +1188,15 @@ static int dsi_regulator_init(struct platform_device *dsidev)
 	return 0;
 }
 
-static void _dsi_print_reset_status(struct platform_device *dsidev)
+static void _dsi_print_reset_status(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 l;
 	int b0, b1, b2;
 
 	/* A dummy read using the SCP interface to any DSIPHY register is
 	 * required after DSIPHY reset to complete the reset of the DSI complex
 	 * I/O. */
-	l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
+	l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
 
 	if (dsi->data->quirks & DSI_QUIRK_REVERSE_TXCLKESC) {
 		b0 = 28;
@@ -1237,7 +1209,7 @@ static void _dsi_print_reset_status(struct platform_device *dsidev)
 	}
 
 #define DSI_FLD_GET(fld, start, end)\
-	FLD_GET(dsi_read_reg(dsidev, DSI_##fld), start, end)
+	FLD_GET(dsi_read_reg(dsi, DSI_##fld), start, end)
 
 	pr_debug("DSI resets: PLL (%d) CIO (%d) PHY (%x%x%x, %d, %d, %d)\n",
 		DSI_FLD_GET(PLL_STATUS, 0, 0),
@@ -1252,14 +1224,14 @@ static void _dsi_print_reset_status(struct platform_device *dsidev)
 #undef DSI_FLD_GET
 }
 
-static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
+static inline int dsi_if_enable(struct dsi_data *dsi, bool enable)
 {
 	DSSDBG("dsi_if_enable(%d)\n", enable);
 
 	enable = enable ? 1 : 0;
-	REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
+	REG_FLD_MOD(dsi, DSI_CTRL, enable, 0, 0); /* IF_EN */
 
-	if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
+	if (!wait_for_bit_change(dsi, DSI_CTRL, 0, enable)) {
 		DSSERR("Failed to set dsi_if_enable to %d\n", enable);
 		return -EIO;
 	}
@@ -1267,31 +1239,24 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
 	return 0;
 }
 
-static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
+static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	return dsi->pll.cinfo.clkout[HSDIV_DISPC];
 }
 
-static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device *dsidev)
+static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	return dsi->pll.cinfo.clkout[HSDIV_DSI];
 }
 
-static unsigned long dsi_get_txbyteclkhs(struct platform_device *dsidev)
+static unsigned long dsi_get_txbyteclkhs(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	return dsi->pll.cinfo.clkdco / 16;
 }
 
-static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
+static unsigned long dsi_fclk_rate(struct dsi_data *dsi)
 {
 	unsigned long r;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	enum dss_clk_source source;
 
 	source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id);
@@ -1300,7 +1265,7 @@ static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
 		r = clk_get_rate(dsi->dss_clk);
 	} else {
 		/* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */
-		r = dsi_get_pll_hsdiv_dsi_rate(dsidev);
+		r = dsi_get_pll_hsdiv_dsi_rate(dsi);
 	}
 
 	return r;
@@ -1325,9 +1290,8 @@ static int dsi_lp_clock_calc(unsigned long dsi_fclk,
 	return 0;
 }
 
-static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
+static int dsi_set_lp_clk_divisor(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long dsi_fclk;
 	unsigned int lp_clk_div;
 	unsigned long lp_clk;
@@ -1339,7 +1303,7 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
 	if (lp_clk_div == 0 || lp_clk_div > lpdiv_max)
 		return -EINVAL;
 
-	dsi_fclk = dsi_fclk_rate(dsidev);
+	dsi_fclk = dsi_fclk_rate(dsi);
 
 	lp_clk = dsi_fclk / 2 / lp_clk_div;
 
@@ -1348,29 +1312,25 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
 	dsi->current_lp_cinfo.lp_clk_div = lp_clk_div;
 
 	/* LP_CLK_DIVISOR */
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, lp_clk_div, 12, 0);
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, lp_clk_div, 12, 0);
 
 	/* LP_RX_SYNCHRO_ENABLE */
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21);
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21);
 
 	return 0;
 }
 
-static void dsi_enable_scp_clk(struct platform_device *dsidev)
+static void dsi_enable_scp_clk(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (dsi->scp_clk_refcount++ == 0)
-		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */
+		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */
 }
 
-static void dsi_disable_scp_clk(struct platform_device *dsidev)
+static void dsi_disable_scp_clk(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	WARN_ON(dsi->scp_clk_refcount == 0);
 	if (--dsi->scp_clk_refcount == 0)
-		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */
+		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */
 }
 
 enum dsi_pll_power_state {
@@ -1380,10 +1340,8 @@ enum dsi_pll_power_state {
 	DSI_PLL_POWER_ON_DIV	= 0x3,
 };
 
-static int dsi_pll_power(struct platform_device *dsidev,
-		enum dsi_pll_power_state state)
+static int dsi_pll_power(struct dsi_data *dsi, enum dsi_pll_power_state state)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int t = 0;
 
 	/* DSI-PLL power command 0x3 is not working */
@@ -1392,10 +1350,10 @@ static int dsi_pll_power(struct platform_device *dsidev,
 		state = DSI_PLL_POWER_ON_ALL;
 
 	/* PLL_PWR_CMD */
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, state, 31, 30);
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, state, 31, 30);
 
 	/* PLL_PWR_STATUS */
-	while (FLD_GET(dsi_read_reg(dsidev, DSI_CLK_CTRL), 29, 28) != state) {
+	while (FLD_GET(dsi_read_reg(dsi, DSI_CLK_CTRL), 29, 28) != state) {
 		if (++t > 1000) {
 			DSSERR("Failed to set DSI PLL power mode to %d\n",
 					state);
@@ -1422,23 +1380,22 @@ static void dsi_pll_calc_dsi_fck(struct dsi_data *dsi,
 static int dsi_pll_enable(struct dss_pll *pll)
 {
 	struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
-	struct platform_device *dsidev = dsi->pdev;
 	int r = 0;
 
 	DSSDBG("PLL init\n");
 
-	r = dsi_regulator_init(dsidev);
+	r = dsi_regulator_init(dsi);
 	if (r)
 		return r;
 
-	r = dsi_runtime_get(dsidev);
+	r = dsi_runtime_get(dsi);
 	if (r)
 		return r;
 
 	/*
 	 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4.
 	 */
-	dsi_enable_scp_clk(dsidev);
+	dsi_enable_scp_clk(dsi);
 
 	if (!dsi->vdds_dsi_enabled) {
 		r = regulator_enable(dsi->vdds_dsi_reg);
@@ -1450,7 +1407,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
 	/* XXX PLL does not come out of reset without this... */
 	dispc_pck_free_enable(1);
 
-	if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
+	if (!wait_for_bit_change(dsi, DSI_PLL_STATUS, 0, 1)) {
 		DSSERR("PLL not coming out of reset.\n");
 		r = -ENODEV;
 		dispc_pck_free_enable(0);
@@ -1461,7 +1418,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
 	 * fill the whole display. No idea about this */
 	dispc_pck_free_enable(0);
 
-	r = dsi_pll_power(dsidev, DSI_PLL_POWER_ON_ALL);
+	r = dsi_pll_power(dsi, DSI_PLL_POWER_ON_ALL);
 
 	if (r)
 		goto err1;
@@ -1475,24 +1432,22 @@ static int dsi_pll_enable(struct dss_pll *pll)
 		dsi->vdds_dsi_enabled = false;
 	}
 err0:
-	dsi_disable_scp_clk(dsidev);
-	dsi_runtime_put(dsidev);
+	dsi_disable_scp_clk(dsi);
+	dsi_runtime_put(dsi);
 	return r;
 }
 
-static void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes)
+static void dsi_pll_uninit(struct dsi_data *dsi, bool disconnect_lanes)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
-	dsi_pll_power(dsidev, DSI_PLL_POWER_OFF);
+	dsi_pll_power(dsi, DSI_PLL_POWER_OFF);
 	if (disconnect_lanes) {
 		WARN_ON(!dsi->vdds_dsi_enabled);
 		regulator_disable(dsi->vdds_dsi_reg);
 		dsi->vdds_dsi_enabled = false;
 	}
 
-	dsi_disable_scp_clk(dsidev);
-	dsi_runtime_put(dsidev);
+	dsi_disable_scp_clk(dsi);
+	dsi_runtime_put(dsi);
 
 	DSSDBG("PLL uninit done\n");
 }
@@ -1500,15 +1455,12 @@ static void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes
 static void dsi_pll_disable(struct dss_pll *pll)
 {
 	struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
-	struct platform_device *dsidev = dsi->pdev;
 
-	dsi_pll_uninit(dsidev, true);
+	dsi_pll_uninit(dsi, true);
 }
 
-static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
-		struct seq_file *s)
+static void dsi_dump_dsi_clocks(struct dsi_data *dsi, struct seq_file *s)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct dss_pll_clock_info *cinfo = &dsi->pll.cinfo;
 	enum dss_clk_source dispc_clk_src, dsi_clk_src;
 	int dsi_module = dsi->module_id;
@@ -1517,7 +1469,7 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
 	dispc_clk_src = dss_get_dispc_clk_source(dsi->dss);
 	dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
 
-	if (dsi_runtime_get(dsidev))
+	if (dsi_runtime_get(dsi))
 		return;
 
 	seq_printf(s,	"- DSI%d PLL -\n", dsi_module + 1);
@@ -1552,35 +1504,33 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
 	seq_printf(s,	"dsi fclk source = %s\n",
 			dss_get_clk_source_name(dsi_clk_src));
 
-	seq_printf(s,	"DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev));
+	seq_printf(s,	"DSI_FCLK\t%lu\n", dsi_fclk_rate(dsi));
 
 	seq_printf(s,	"DDR_CLK\t\t%lu\n",
 			cinfo->clkdco / 4);
 
-	seq_printf(s,	"TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev));
+	seq_printf(s,	"TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsi));
 
 	seq_printf(s,	"LP_CLK\t\t%lu\n", dsi->current_lp_cinfo.lp_clk);
 
-	dsi_runtime_put(dsidev);
+	dsi_runtime_put(dsi);
 }
 
 void dsi_dump_clocks(struct seq_file *s)
 {
-	struct platform_device *dsidev;
+	struct dsi_data *dsi;
 	int i;
 
 	for  (i = 0; i < MAX_NUM_DSI; i++) {
-		dsidev = dsi_get_dsidev_from_id(i);
-		if (dsidev)
-			dsi_dump_dsidev_clocks(dsidev, s);
+		dsi = dsi_get_dsi_from_id(i);
+		if (dsi)
+			dsi_dump_dsi_clocks(dsi, s);
 	}
 }
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
-		struct seq_file *s)
+static void dsi_dump_dsi_irqs(struct dsi_data *dsi, struct seq_file *s)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned long flags;
 	struct dsi_irq_stats stats;
 
@@ -1668,29 +1618,28 @@ static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
 
 static int dsi1_dump_irqs(struct seq_file *s, void *p)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
+	struct dsi_data *dsi = dsi_get_dsi_from_id(0);
 
-	dsi_dump_dsidev_irqs(dsidev, s);
+	dsi_dump_dsi_irqs(dsi, s);
 	return 0;
 }
 
 static int dsi2_dump_irqs(struct seq_file *s, void *p)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
+	struct dsi_data *dsi = dsi_get_dsi_from_id(1);
 
-	dsi_dump_dsidev_irqs(dsidev, s);
+	dsi_dump_dsi_irqs(dsi, s);
 	return 0;
 }
 #endif
 
-static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
-		struct seq_file *s)
+static void dsi_dump_dsi_regs(struct dsi_data *dsi, struct seq_file *s)
 {
-#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r))
+#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsi, r))
 
-	if (dsi_runtime_get(dsidev))
+	if (dsi_runtime_get(dsi))
 		return;
-	dsi_enable_scp_clk(dsidev);
+	dsi_enable_scp_clk(dsi);
 
 	DUMPREG(DSI_REVISION);
 	DUMPREG(DSI_SYSCONFIG);
@@ -1762,24 +1711,24 @@ static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
 	DUMPREG(DSI_PLL_CONFIGURATION1);
 	DUMPREG(DSI_PLL_CONFIGURATION2);
 
-	dsi_disable_scp_clk(dsidev);
-	dsi_runtime_put(dsidev);
+	dsi_disable_scp_clk(dsi);
+	dsi_runtime_put(dsi);
 #undef DUMPREG
 }
 
 static int dsi1_dump_regs(struct seq_file *s, void *p)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
+	struct dsi_data *dsi = dsi_get_dsi_from_id(0);
 
-	dsi_dump_dsidev_regs(dsidev, s);
+	dsi_dump_dsi_regs(dsi, s);
 	return 0;
 }
 
 static int dsi2_dump_regs(struct seq_file *s, void *p)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
+	struct dsi_data *dsi = dsi_get_dsi_from_id(1);
 
-	dsi_dump_dsidev_regs(dsidev, s);
+	dsi_dump_dsi_regs(dsi, s);
 	return 0;
 }
 
@@ -1789,16 +1738,15 @@ enum dsi_cio_power_state {
 	DSI_COMPLEXIO_POWER_ULPS	= 0x2,
 };
 
-static int dsi_cio_power(struct platform_device *dsidev,
-		enum dsi_cio_power_state state)
+static int dsi_cio_power(struct dsi_data *dsi, enum dsi_cio_power_state state)
 {
 	int t = 0;
 
 	/* PWR_CMD */
-	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG1, state, 28, 27);
+	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG1, state, 28, 27);
 
 	/* PWR_STATUS */
-	while (FLD_GET(dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1),
+	while (FLD_GET(dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1),
 			26, 25) != state) {
 		if (++t > 1000) {
 			DSSERR("failed to set complexio power state to "
@@ -1811,9 +1759,8 @@ static int dsi_cio_power(struct platform_device *dsidev,
 	return 0;
 }
 
-static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
+static unsigned int dsi_get_line_buf_size(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int val;
 
 	/* line buffer on OMAP3 is 1024 x 24bits */
@@ -1823,7 +1770,7 @@ static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
 	if (!(dsi->data->quirks & DSI_QUIRK_GNQ))
 		return 1023 * 3;
 
-	val = REG_GET(dsidev, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */
+	val = REG_GET(dsi, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */
 
 	switch (val) {
 	case 1:
@@ -1846,9 +1793,8 @@ static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
 	}
 }
 
-static int dsi_set_lane_config(struct platform_device *dsidev)
+static int dsi_set_lane_config(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	static const u8 offsets[] = { 0, 4, 8, 12, 16 };
 	static const enum dsi_lane_function functions[] = {
 		DSI_LANE_CLK,
@@ -1860,7 +1806,7 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
 	u32 r;
 	int i;
 
-	r = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1);
+	r = dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1);
 
 	for (i = 0; i < dsi->num_lanes_used; ++i) {
 		unsigned int offset = offsets[i];
@@ -1889,33 +1835,28 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
 		r = FLD_MOD(r, 0, offset + 3, offset + 3);
 	}
 
-	dsi_write_reg(dsidev, DSI_COMPLEXIO_CFG1, r);
+	dsi_write_reg(dsi, DSI_COMPLEXIO_CFG1, r);
 
 	return 0;
 }
 
-static inline unsigned int ns2ddr(struct platform_device *dsidev,
-				  unsigned int ns)
+static inline unsigned int ns2ddr(struct dsi_data *dsi, unsigned int ns)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	/* convert time in ns to ddr ticks, rounding up */
 	unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
+
 	return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
 }
 
-static inline unsigned int ddr2ns(struct platform_device *dsidev,
-				  unsigned int ddr)
+static inline unsigned int ddr2ns(struct dsi_data *dsi, unsigned int ddr)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
+
 	return ddr * 1000 * 1000 / (ddr_clk / 1000);
 }
 
-static void dsi_cio_timings(struct platform_device *dsidev)
+static void dsi_cio_timings(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r;
 	u32 ths_prepare, ths_prepare_ths_zero, ths_trail, ths_exit;
 	u32 tlpx_half, tclk_trail, tclk_zero;
@@ -1926,54 +1867,54 @@ static void dsi_cio_timings(struct platform_device *dsidev)
 	/* 1 * DDR_CLK = 2 * UI */
 
 	/* min 40ns + 4*UI	max 85ns + 6*UI */
-	ths_prepare = ns2ddr(dsidev, 70) + 2;
+	ths_prepare = ns2ddr(dsi, 70) + 2;
 
 	/* min 145ns + 10*UI */
-	ths_prepare_ths_zero = ns2ddr(dsidev, 175) + 2;
+	ths_prepare_ths_zero = ns2ddr(dsi, 175) + 2;
 
 	/* min max(8*UI, 60ns+4*UI) */
-	ths_trail = ns2ddr(dsidev, 60) + 5;
+	ths_trail = ns2ddr(dsi, 60) + 5;
 
 	/* min 100ns */
-	ths_exit = ns2ddr(dsidev, 145);
+	ths_exit = ns2ddr(dsi, 145);
 
 	/* tlpx min 50n */
-	tlpx_half = ns2ddr(dsidev, 25);
+	tlpx_half = ns2ddr(dsi, 25);
 
 	/* min 60ns */
-	tclk_trail = ns2ddr(dsidev, 60) + 2;
+	tclk_trail = ns2ddr(dsi, 60) + 2;
 
 	/* min 38ns, max 95ns */
-	tclk_prepare = ns2ddr(dsidev, 65);
+	tclk_prepare = ns2ddr(dsi, 65);
 
 	/* min tclk-prepare + tclk-zero = 300ns */
-	tclk_zero = ns2ddr(dsidev, 260);
+	tclk_zero = ns2ddr(dsi, 260);
 
 	DSSDBG("ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n",
-		ths_prepare, ddr2ns(dsidev, ths_prepare),
-		ths_prepare_ths_zero, ddr2ns(dsidev, ths_prepare_ths_zero));
+		ths_prepare, ddr2ns(dsi, ths_prepare),
+		ths_prepare_ths_zero, ddr2ns(dsi, ths_prepare_ths_zero));
 	DSSDBG("ths_trail %u (%uns), ths_exit %u (%uns)\n",
-			ths_trail, ddr2ns(dsidev, ths_trail),
-			ths_exit, ddr2ns(dsidev, ths_exit));
+			ths_trail, ddr2ns(dsi, ths_trail),
+			ths_exit, ddr2ns(dsi, ths_exit));
 
 	DSSDBG("tlpx_half %u (%uns), tclk_trail %u (%uns), "
 			"tclk_zero %u (%uns)\n",
-			tlpx_half, ddr2ns(dsidev, tlpx_half),
-			tclk_trail, ddr2ns(dsidev, tclk_trail),
-			tclk_zero, ddr2ns(dsidev, tclk_zero));
+			tlpx_half, ddr2ns(dsi, tlpx_half),
+			tclk_trail, ddr2ns(dsi, tclk_trail),
+			tclk_zero, ddr2ns(dsi, tclk_zero));
 	DSSDBG("tclk_prepare %u (%uns)\n",
-			tclk_prepare, ddr2ns(dsidev, tclk_prepare));
+			tclk_prepare, ddr2ns(dsi, tclk_prepare));
 
 	/* program timings */
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
 	r = FLD_MOD(r, ths_prepare, 31, 24);
 	r = FLD_MOD(r, ths_prepare_ths_zero, 23, 16);
 	r = FLD_MOD(r, ths_trail, 15, 8);
 	r = FLD_MOD(r, ths_exit, 7, 0);
-	dsi_write_reg(dsidev, DSI_DSIPHY_CFG0, r);
+	dsi_write_reg(dsi, DSI_DSIPHY_CFG0, r);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
 	r = FLD_MOD(r, tlpx_half, 20, 16);
 	r = FLD_MOD(r, tclk_trail, 15, 8);
 	r = FLD_MOD(r, tclk_zero, 7, 0);
@@ -1984,18 +1925,18 @@ static void dsi_cio_timings(struct platform_device *dsidev)
 		r = FLD_MOD(r, 1, 23, 23);	/* CLKINP_SEL = enable */
 	}
 
-	dsi_write_reg(dsidev, DSI_DSIPHY_CFG1, r);
+	dsi_write_reg(dsi, DSI_DSIPHY_CFG1, r);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2);
 	r = FLD_MOD(r, tclk_prepare, 7, 0);
-	dsi_write_reg(dsidev, DSI_DSIPHY_CFG2, r);
+	dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r);
 }
 
 /* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
-static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
-		unsigned int mask_p, unsigned int mask_n)
+static void dsi_cio_enable_lane_override(struct dsi_data *dsi,
+					 unsigned int mask_p,
+					 unsigned int mask_n)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int i;
 	u32 l;
 	u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26;
@@ -2024,26 +1965,25 @@ static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
 	/* Set the lane override configuration */
 
 	/* REGLPTXSCPDAT4TO0DXDY */
-	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
+	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
 
 	/* Enable lane override */
 
 	/* ENLPTXSCPDAT */
-	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 1, 27, 27);
+	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27);
 }
 
-static void dsi_cio_disable_lane_override(struct platform_device *dsidev)
+static void dsi_cio_disable_lane_override(struct dsi_data *dsi)
 {
 	/* Disable lane override */
-	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
+	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
 	/* Reset the lane override configuration */
 	/* REGLPTXSCPDAT4TO0DXDY */
-	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 22, 17);
+	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17);
 }
 
-static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
+static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int t, i;
 	bool in_use[DSI_MAX_NR_LANES];
 	static const u8 offsets_old[] = { 28, 27, 26 };
@@ -2063,7 +2003,7 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
 		u32 l;
 		int ok;
 
-		l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
+		l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
 
 		ok = 0;
 		for (i = 0; i < dsi->num_lanes_supported; ++i) {
@@ -2090,9 +2030,8 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
 }
 
 /* return bitmask of enabled lanes, lane0 being the lsb */
-static unsigned int dsi_get_lane_mask(struct platform_device *dsidev)
+static unsigned int dsi_get_lane_mask(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned int mask = 0;
 	int i;
 
@@ -2181,42 +2120,41 @@ static void dsi_disable_pads(struct dsi_data *dsi)
 		dsi_omap5_mux_pads(dsi, 0);
 }
 
-static int dsi_cio_init(struct platform_device *dsidev)
+static int dsi_cio_init(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 	u32 l;
 
 	DSSDBG("DSI CIO init starts");
 
-	r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev));
+	r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsi));
 	if (r)
 		return r;
 
-	dsi_enable_scp_clk(dsidev);
+	dsi_enable_scp_clk(dsi);
 
 	/* A dummy read using the SCP interface to any DSIPHY register is
 	 * required after DSIPHY reset to complete the reset of the DSI complex
 	 * I/O. */
-	dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
+	dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
 
-	if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
+	if (!wait_for_bit_change(dsi, DSI_DSIPHY_CFG5, 30, 1)) {
 		DSSERR("CIO SCP Clock domain not coming out of reset.\n");
 		r = -EIO;
 		goto err_scp_clk_dom;
 	}
 
-	r = dsi_set_lane_config(dsidev);
+	r = dsi_set_lane_config(dsi);
 	if (r)
 		goto err_scp_clk_dom;
 
 	/* set TX STOP MODE timer to maximum for this operation */
-	l = dsi_read_reg(dsidev, DSI_TIMING1);
+	l = dsi_read_reg(dsi, DSI_TIMING1);
 	l = FLD_MOD(l, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
 	l = FLD_MOD(l, 1, 14, 14);	/* STOP_STATE_X16_IO */
 	l = FLD_MOD(l, 1, 13, 13);	/* STOP_STATE_X4_IO */
 	l = FLD_MOD(l, 0x1fff, 12, 0);	/* STOP_STATE_COUNTER_IO */
-	dsi_write_reg(dsidev, DSI_TIMING1, l);
+	dsi_write_reg(dsi, DSI_TIMING1, l);
 
 	if (dsi->ulps_enabled) {
 		unsigned int mask_p;
@@ -2241,24 +2179,24 @@ static int dsi_cio_init(struct platform_device *dsidev)
 			mask_p |= 1 << i;
 		}
 
-		dsi_cio_enable_lane_override(dsidev, mask_p, 0);
+		dsi_cio_enable_lane_override(dsi, mask_p, 0);
 	}
 
-	r = dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ON);
+	r = dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ON);
 	if (r)
 		goto err_cio_pwr;
 
-	if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
+	if (!wait_for_bit_change(dsi, DSI_COMPLEXIO_CFG1, 29, 1)) {
 		DSSERR("CIO PWR clock domain not coming out of reset.\n");
 		r = -ENODEV;
 		goto err_cio_pwr_dom;
 	}
 
-	dsi_if_enable(dsidev, true);
-	dsi_if_enable(dsidev, false);
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */
+	dsi_if_enable(dsi, true);
+	dsi_if_enable(dsi, false);
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */
 
-	r = dsi_cio_wait_tx_clk_esc_reset(dsidev);
+	r = dsi_cio_wait_tx_clk_esc_reset(dsi);
 	if (r)
 		goto err_tx_clk_esc_rst;
 
@@ -2270,17 +2208,17 @@ static int dsi_cio_init(struct platform_device *dsidev)
 
 		/* Disable the override. The lanes should be set to Mark-11
 		 * state by the HW */
-		dsi_cio_disable_lane_override(dsidev);
+		dsi_cio_disable_lane_override(dsi);
 	}
 
 	/* FORCE_TX_STOP_MODE_IO */
-	REG_FLD_MOD(dsidev, DSI_TIMING1, 0, 15, 15);
+	REG_FLD_MOD(dsi, DSI_TIMING1, 0, 15, 15);
 
-	dsi_cio_timings(dsidev);
+	dsi_cio_timings(dsi);
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		/* DDR_CLK_ALWAYS_ON */
-		REG_FLD_MOD(dsidev, DSI_CLK_CTRL,
+		REG_FLD_MOD(dsi, DSI_CLK_CTRL,
 			dsi->vm_timings.ddr_clk_always_on, 13, 13);
 	}
 
@@ -2291,35 +2229,32 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	return 0;
 
 err_tx_clk_esc_rst:
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */
 err_cio_pwr_dom:
-	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF);
+	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
 err_cio_pwr:
 	if (dsi->ulps_enabled)
-		dsi_cio_disable_lane_override(dsidev);
+		dsi_cio_disable_lane_override(dsi);
 err_scp_clk_dom:
-	dsi_disable_scp_clk(dsidev);
+	dsi_disable_scp_clk(dsi);
 	dsi_disable_pads(dsi);
 	return r;
 }
 
-static void dsi_cio_uninit(struct platform_device *dsidev)
+static void dsi_cio_uninit(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	/* DDR_CLK_ALWAYS_ON */
-	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13);
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
 
-	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF);
-	dsi_disable_scp_clk(dsidev);
+	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
+	dsi_disable_scp_clk(dsi);
 	dsi_disable_pads(dsi);
 }
 
-static void dsi_config_tx_fifo(struct platform_device *dsidev,
-		enum fifo_size size1, enum fifo_size size2,
-		enum fifo_size size3, enum fifo_size size4)
+static void dsi_config_tx_fifo(struct dsi_data *dsi,
+			       enum fifo_size size1, enum fifo_size size2,
+			       enum fifo_size size3, enum fifo_size size4)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r = 0;
 	int add = 0;
 	int i;
@@ -2345,14 +2280,13 @@ static void dsi_config_tx_fifo(struct platform_device *dsidev,
 		add += size;
 	}
 
-	dsi_write_reg(dsidev, DSI_TX_FIFO_VC_SIZE, r);
+	dsi_write_reg(dsi, DSI_TX_FIFO_VC_SIZE, r);
 }
 
-static void dsi_config_rx_fifo(struct platform_device *dsidev,
+static void dsi_config_rx_fifo(struct dsi_data *dsi,
 		enum fifo_size size1, enum fifo_size size2,
 		enum fifo_size size3, enum fifo_size size4)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r = 0;
 	int add = 0;
 	int i;
@@ -2378,18 +2312,18 @@ static void dsi_config_rx_fifo(struct platform_device *dsidev,
 		add += size;
 	}
 
-	dsi_write_reg(dsidev, DSI_RX_FIFO_VC_SIZE, r);
+	dsi_write_reg(dsi, DSI_RX_FIFO_VC_SIZE, r);
 }
 
-static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
+static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi)
 {
 	u32 r;
 
-	r = dsi_read_reg(dsidev, DSI_TIMING1);
+	r = dsi_read_reg(dsi, DSI_TIMING1);
 	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
-	dsi_write_reg(dsidev, DSI_TIMING1, r);
+	dsi_write_reg(dsi, DSI_TIMING1, r);
 
-	if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
+	if (!wait_for_bit_change(dsi, DSI_TIMING1, 15, 0)) {
 		DSSERR("TX_STOP bit not going down\n");
 		return -EIO;
 	}
@@ -2397,29 +2331,28 @@ static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
 	return 0;
 }
 
-static bool dsi_vc_is_enabled(struct platform_device *dsidev, int channel)
+static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel)
 {
-	return REG_GET(dsidev, DSI_VC_CTRL(channel), 0, 0);
+	return REG_GET(dsi, DSI_VC_CTRL(channel), 0, 0);
 }
 
 static void dsi_packet_sent_handler_vp(void *data, u32 mask)
 {
 	struct dsi_packet_sent_handler_data *vp_data =
 		(struct dsi_packet_sent_handler_data *) data;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(vp_data->dsidev);
+	struct dsi_data *dsi = vp_data->dsi;
 	const int channel = dsi->update_channel;
 	u8 bit = dsi->te_enabled ? 30 : 31;
 
-	if (REG_GET(vp_data->dsidev, DSI_VC_TE(channel), bit, bit) == 0)
+	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit) == 0)
 		complete(vp_data->completion);
 }
 
-static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
+static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	struct dsi_packet_sent_handler_data vp_data = {
-		.dsidev = dsidev,
+		.dsi = dsi,
 		.completion = &completion
 	};
 	int r = 0;
@@ -2427,13 +2360,13 @@ static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
 
 	bit = dsi->te_enabled ? 30 : 31;
 
-	r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
+	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 	if (r)
 		goto err0;
 
 	/* Wait for completion only if TE_EN/TE_START is still set */
-	if (REG_GET(dsidev, DSI_VC_TE(channel), bit, bit)) {
+	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit)) {
 		if (wait_for_completion_timeout(&completion,
 				msecs_to_jiffies(10)) == 0) {
 			DSSERR("Failed to complete previous frame transfer\n");
@@ -2442,12 +2375,12 @@ static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
 		}
 	}
 
-	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
+	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 
 	return 0;
 err1:
-	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
+	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 err0:
 	return r;
@@ -2457,29 +2390,29 @@ static void dsi_packet_sent_handler_l4(void *data, u32 mask)
 {
 	struct dsi_packet_sent_handler_data *l4_data =
 		(struct dsi_packet_sent_handler_data *) data;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(l4_data->dsidev);
+	struct dsi_data *dsi = l4_data->dsi;
 	const int channel = dsi->update_channel;
 
-	if (REG_GET(l4_data->dsidev, DSI_VC_CTRL(channel), 5, 5) == 0)
+	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5) == 0)
 		complete(l4_data->completion);
 }
 
-static int dsi_sync_vc_l4(struct platform_device *dsidev, int channel)
+static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
 {
 	DECLARE_COMPLETION_ONSTACK(completion);
 	struct dsi_packet_sent_handler_data l4_data = {
-		.dsidev = dsidev,
+		.dsi = dsi,
 		.completion = &completion
 	};
 	int r = 0;
 
-	r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
+	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 	if (r)
 		goto err0;
 
 	/* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
-	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 5, 5)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5)) {
 		if (wait_for_completion_timeout(&completion,
 				msecs_to_jiffies(10)) == 0) {
 			DSSERR("Failed to complete previous l4 transfer\n");
@@ -2488,50 +2421,47 @@ static int dsi_sync_vc_l4(struct platform_device *dsidev, int channel)
 		}
 	}
 
-	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
+	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 
 	return 0;
 err1:
-	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
+	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 err0:
 	return r;
 }
 
-static int dsi_sync_vc(struct platform_device *dsidev, int channel)
+static int dsi_sync_vc(struct dsi_data *dsi, int channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	WARN_ON(in_interrupt());
 
-	if (!dsi_vc_is_enabled(dsidev, channel))
+	if (!dsi_vc_is_enabled(dsi, channel))
 		return 0;
 
 	switch (dsi->vc[channel].source) {
 	case DSI_VC_SOURCE_VP:
-		return dsi_sync_vc_vp(dsidev, channel);
+		return dsi_sync_vc_vp(dsi, channel);
 	case DSI_VC_SOURCE_L4:
-		return dsi_sync_vc_l4(dsidev, channel);
+		return dsi_sync_vc_l4(dsi, channel);
 	default:
 		BUG();
 		return -EINVAL;
 	}
 }
 
-static int dsi_vc_enable(struct platform_device *dsidev, int channel,
-		bool enable)
+static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
 {
 	DSSDBG("dsi_vc_enable channel %d, enable %d\n",
 			channel, enable);
 
 	enable = enable ? 1 : 0;
 
-	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 0, 0);
 
-	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
+	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 0, enable)) {
 		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
 		return -EIO;
 	}
@@ -2539,14 +2469,13 @@ static int dsi_vc_enable(struct platform_device *dsidev, int channel,
 	return 0;
 }
 
-static void dsi_vc_initial_config(struct platform_device *dsidev, int channel)
+static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r;
 
 	DSSDBG("Initial config of virtual channel %d", channel);
 
-	r = dsi_read_reg(dsidev, DSI_VC_CTRL(channel));
+	r = dsi_read_reg(dsi, DSI_VC_CTRL(channel));
 
 	if (FLD_GET(r, 15, 15)) /* VC_BUSY */
 		DSSERR("VC(%d) busy when trying to configure it!\n",
@@ -2565,41 +2494,39 @@ static void dsi_vc_initial_config(struct platform_device *dsidev, int channel)
 	r = FLD_MOD(r, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
 	r = FLD_MOD(r, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
 
-	dsi_write_reg(dsidev, DSI_VC_CTRL(channel), r);
+	dsi_write_reg(dsi, DSI_VC_CTRL(channel), r);
 
 	dsi->vc[channel].source = DSI_VC_SOURCE_L4;
 }
 
-static int dsi_vc_config_source(struct platform_device *dsidev, int channel,
-		enum dsi_vc_source source)
+static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
+				enum dsi_vc_source source)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (dsi->vc[channel].source == source)
 		return 0;
 
 	DSSDBG("Source config of virtual channel %d", channel);
 
-	dsi_sync_vc(dsidev, channel);
+	dsi_sync_vc(dsi, channel);
 
-	dsi_vc_enable(dsidev, channel, 0);
+	dsi_vc_enable(dsi, channel, 0);
 
 	/* VC_BUSY */
-	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0)) {
+	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 15, 0)) {
 		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
 		return -EIO;
 	}
 
 	/* SOURCE, 0 = L4, 1 = video port */
-	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), source, 1, 1);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), source, 1, 1);
 
 	/* DCS_CMD_ENABLE */
 	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
 		bool enable = source == DSI_VC_SOURCE_VP;
-		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 30, 30);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 30, 30);
 	}
 
-	dsi_vc_enable(dsidev, channel, 1);
+	dsi_vc_enable(dsi, channel, 1);
 
 	dsi->vc[channel].source = source;
 
@@ -2614,28 +2541,28 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
 
 	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
-	dsi_vc_enable(dsidev, channel, 0);
-	dsi_if_enable(dsidev, 0);
+	dsi_vc_enable(dsi, channel, 0);
+	dsi_if_enable(dsi, 0);
 
-	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 9, 9);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 9, 9);
 
-	dsi_vc_enable(dsidev, channel, 1);
-	dsi_if_enable(dsidev, 1);
+	dsi_vc_enable(dsi, channel, 1);
+	dsi_if_enable(dsi, 1);
 
-	dsi_force_tx_stop_mode_io(dsidev);
+	dsi_force_tx_stop_mode_io(dsi);
 
 	/* start the DDR clock by sending a NULL packet */
 	if (dsi->vm_timings.ddr_clk_always_on && enable)
-		dsi_vc_send_null(dssdev, channel);
+		dsi_vc_send_null(dsi, channel);
 }
 
-static void dsi_vc_flush_long_data(struct platform_device *dsidev, int channel)
+static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
 {
-	while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
+	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
 		u32 val;
-		val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
+		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
 		DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
 				(val >> 0) & 0xff,
 				(val >> 8) & 0xff,
@@ -2681,14 +2608,13 @@ static void dsi_show_rx_ack_with_err(u16 err)
 		DSSERR("\t\tDSI Protocol Violation\n");
 }
 
-static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
-		int channel)
+static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
 {
 	/* RX_FIFO_NOT_EMPTY */
-	while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
+	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
 		u32 val;
 		u8 dt;
-		val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
+		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
 		DSSERR("\trawval %#08x\n", val);
 		dt = FLD_GET(val, 5, 0);
 		if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) {
@@ -2703,7 +2629,7 @@ static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
 		} else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) {
 			DSSERR("\tDCS long response, len %d\n",
 					FLD_GET(val, 23, 8));
-			dsi_vc_flush_long_data(dsidev, channel);
+			dsi_vc_flush_long_data(dsi, channel);
 		} else {
 			DSSERR("\tunknown datatype 0x%02x\n", dt);
 		}
@@ -2711,25 +2637,23 @@ static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
 	return 0;
 }
 
-static int dsi_vc_send_bta(struct platform_device *dsidev, int channel)
+static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (dsi->debug_write || dsi->debug_read)
 		DSSDBG("dsi_vc_send_bta %d\n", channel);
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
 		DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
-		dsi_vc_flush_receive_data(dsidev, channel);
+		dsi_vc_flush_receive_data(dsi, channel);
 	}
 
-	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
 
 	/* flush posted write */
-	dsi_read_reg(dsidev, DSI_VC_CTRL(channel));
+	dsi_read_reg(dsi, DSI_VC_CTRL(channel));
 
 	return 0;
 }
@@ -2737,21 +2661,22 @@ static int dsi_vc_send_bta(struct platform_device *dsidev, int channel)
 static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	int r = 0;
 	u32 err;
 
-	r = dsi_register_isr_vc(dsidev, channel, dsi_completion_handler,
+	r = dsi_register_isr_vc(dsi, channel, dsi_completion_handler,
 			&completion, DSI_VC_IRQ_BTA);
 	if (r)
 		goto err0;
 
-	r = dsi_register_isr(dsidev, dsi_completion_handler, &completion,
+	r = dsi_register_isr(dsi, dsi_completion_handler, &completion,
 			DSI_IRQ_ERROR_MASK);
 	if (r)
 		goto err1;
 
-	r = dsi_vc_send_bta(dsidev, channel);
+	r = dsi_vc_send_bta(dsi, channel);
 	if (r)
 		goto err2;
 
@@ -2762,41 +2687,40 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 		goto err2;
 	}
 
-	err = dsi_get_errors(dsidev);
+	err = dsi_get_errors(dsi);
 	if (err) {
 		DSSERR("Error while sending BTA: %x\n", err);
 		r = -EIO;
 		goto err2;
 	}
 err2:
-	dsi_unregister_isr(dsidev, dsi_completion_handler, &completion,
+	dsi_unregister_isr(dsi, dsi_completion_handler, &completion,
 			DSI_IRQ_ERROR_MASK);
 err1:
-	dsi_unregister_isr_vc(dsidev, channel, dsi_completion_handler,
+	dsi_unregister_isr_vc(dsi, channel, dsi_completion_handler,
 			&completion, DSI_VC_IRQ_BTA);
 err0:
 	return r;
 }
 
-static inline void dsi_vc_write_long_header(struct platform_device *dsidev,
-		int channel, u8 data_type, u16 len, u8 ecc)
+static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
+					    u8 data_type, u16 len, u8 ecc)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 val;
 	u8 data_id;
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	data_id = data_type | dsi->vc[channel].vc_id << 6;
 
 	val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
 		FLD_VAL(ecc, 31, 24);
 
-	dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_HEADER(channel), val);
+	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(channel), val);
 }
 
-static inline void dsi_vc_write_long_payload(struct platform_device *dsidev,
-		int channel, u8 b1, u8 b2, u8 b3, u8 b4)
+static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
+					     u8 b1, u8 b2, u8 b3, u8 b4)
 {
 	u32 val;
 
@@ -2805,14 +2729,13 @@ static inline void dsi_vc_write_long_payload(struct platform_device *dsidev,
 /*	DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
 			b1, b2, b3, b4, val); */
 
-	dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
+	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
 }
 
-static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
-		u8 data_type, u8 *data, u16 len, u8 ecc)
+static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
+			    u8 *data, u16 len, u8 ecc)
 {
 	/*u32 val; */
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int i;
 	u8 *p;
 	int r = 0;
@@ -2827,9 +2750,9 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
 		return -EINVAL;
 	}
 
-	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
 
-	dsi_vc_write_long_header(dsidev, channel, data_type, len, ecc);
+	dsi_vc_write_long_header(dsi, channel, data_type, len, ecc);
 
 	p = data;
 	for (i = 0; i < len >> 2; i++) {
@@ -2841,7 +2764,7 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
 		b3 = *p++;
 		b4 = *p++;
 
-		dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, b4);
+		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4);
 	}
 
 	i = len % 4;
@@ -2866,29 +2789,28 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
 			break;
 		}
 
-		dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, 0);
+		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0);
 	}
 
 	return r;
 }
 
-static int dsi_vc_send_short(struct platform_device *dsidev, int channel,
-		u8 data_type, u16 data, u8 ecc)
+static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
+			     u16 data, u8 ecc)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r;
 	u8 data_id;
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	if (dsi->debug_write)
 		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
 				channel,
 				data_type, data & 0xff, (data >> 8) & 0xff);
 
-	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
 
-	if (FLD_GET(dsi_read_reg(dsidev, DSI_VC_CTRL(channel)), 16, 16)) {
+	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) {
 		DSSERR("ERROR FIFO FULL, aborting transfer\n");
 		return -EINVAL;
 	}
@@ -2897,41 +2819,39 @@ static int dsi_vc_send_short(struct platform_device *dsidev, int channel,
 
 	r = (data_id << 0) | (data << 8) | (ecc << 24);
 
-	dsi_write_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel), r);
+	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r);
 
 	return 0;
 }
 
-static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel)
+static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-
-	return dsi_vc_send_long(dsidev, channel, MIPI_DSI_NULL_PACKET, NULL,
-		0, 0);
+	return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
 }
 
-static int dsi_vc_write_nosync_common(struct platform_device *dsidev,
-		int channel, u8 *data, int len, enum dss_dsi_content_type type)
+static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
+				      u8 *data, int len,
+				      enum dss_dsi_content_type type)
 {
 	int r;
 
 	if (len == 0) {
 		BUG_ON(type == DSS_DSI_CONTENT_DCS);
-		r = dsi_vc_send_short(dsidev, channel,
+		r = dsi_vc_send_short(dsi, channel,
 				MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0);
 	} else if (len == 1) {
-		r = dsi_vc_send_short(dsidev, channel,
+		r = dsi_vc_send_short(dsi, channel,
 				type == DSS_DSI_CONTENT_GENERIC ?
 				MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
 				MIPI_DSI_DCS_SHORT_WRITE, data[0], 0);
 	} else if (len == 2) {
-		r = dsi_vc_send_short(dsidev, channel,
+		r = dsi_vc_send_short(dsi, channel,
 				type == DSS_DSI_CONTENT_GENERIC ?
 				MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
 				MIPI_DSI_DCS_SHORT_WRITE_PARAM,
 				data[0] | (data[1] << 8), 0);
 	} else {
-		r = dsi_vc_send_long(dsidev, channel,
+		r = dsi_vc_send_long(dsi, channel,
 				type == DSS_DSI_CONTENT_GENERIC ?
 				MIPI_DSI_GENERIC_LONG_WRITE :
 				MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
@@ -2944,8 +2864,9 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
 		u8 *data, int len)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
-	return dsi_vc_write_nosync_common(dsidev, channel, data, len,
+	return dsi_vc_write_nosync_common(dsi, channel, data, len,
 			DSS_DSI_CONTENT_DCS);
 }
 
@@ -2953,18 +2874,21 @@ static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int chann
 		u8 *data, int len)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
-	return dsi_vc_write_nosync_common(dsidev, channel, data, len,
+	return dsi_vc_write_nosync_common(dsi, channel, data, len,
 			DSS_DSI_CONTENT_GENERIC);
 }
 
-static int dsi_vc_write_common(struct omap_dss_device *dssdev, int channel,
-		u8 *data, int len, enum dss_dsi_content_type type)
+static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+			       int channel, u8 *data, int len,
+			       enum dss_dsi_content_type type)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
-	r = dsi_vc_write_nosync_common(dsidev, channel, data, len, type);
+	r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
 	if (r)
 		goto err;
 
@@ -2973,9 +2897,9 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev, int channel,
 		goto err;
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
 		DSSERR("rx fifo not empty after write, dumping data:\n");
-		dsi_vc_flush_receive_data(dsidev, channel);
+		dsi_vc_flush_receive_data(dsi, channel);
 		r = -EIO;
 		goto err;
 	}
@@ -3001,17 +2925,16 @@ static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8
 			DSS_DSI_CONTENT_GENERIC);
 }
 
-static int dsi_vc_dcs_send_read_request(struct platform_device *dsidev,
-		int channel, u8 dcs_cmd)
+static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
+					u8 dcs_cmd)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
 	if (dsi->debug_read)
 		DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
 			channel, dcs_cmd);
 
-	r = dsi_vc_send_short(dsidev, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
+	r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
 	if (r) {
 		DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
 			" failed\n", channel, dcs_cmd);
@@ -3021,10 +2944,9 @@ static int dsi_vc_dcs_send_read_request(struct platform_device *dsidev,
 	return 0;
 }
 
-static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
-		int channel, u8 *reqdata, int reqlen)
+static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
+					    u8 *reqdata, int reqlen)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u16 data;
 	u8 data_type;
 	int r;
@@ -3047,7 +2969,7 @@ static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
 		return -EINVAL;
 	}
 
-	r = dsi_vc_send_short(dsidev, channel, data_type, data, 0);
+	r = dsi_vc_send_short(dsi, channel, data_type, data, 0);
 	if (r) {
 		DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
 			" failed\n", channel, reqlen);
@@ -3057,22 +2979,21 @@ static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
 	return 0;
 }
 
-static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel,
-		u8 *buf, int buflen, enum dss_dsi_content_type type)
+static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
+			       int buflen, enum dss_dsi_content_type type)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 val;
 	u8 dt;
 	int r;
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20) == 0) {
+	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20) == 0) {
 		DSSERR("RX fifo empty when trying to read.\n");
 		r = -EIO;
 		goto err;
 	}
 
-	val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
+	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
 	if (dsi->debug_read)
 		DSSDBG("\theader: %08x\n", val);
 	dt = FLD_GET(val, 5, 0);
@@ -3135,7 +3056,7 @@ static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel,
 		/* two byte checksum ends the packet, not included in len */
 		for (w = 0; w < len + 2;) {
 			int b;
-			val = dsi_read_reg(dsidev,
+			val = dsi_read_reg(dsi,
 				DSI_VC_SHORT_PACKET_HEADER(channel));
 			if (dsi->debug_read)
 				DSSDBG("\t\t%02x %02x %02x %02x\n",
@@ -3170,9 +3091,10 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
 		u8 *buf, int buflen)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
-	r = dsi_vc_dcs_send_read_request(dsidev, channel, dcs_cmd);
+	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
 	if (r)
 		goto err;
 
@@ -3180,7 +3102,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
 	if (r)
 		goto err;
 
-	r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
+	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
 		DSS_DSI_CONTENT_DCS);
 	if (r < 0)
 		goto err;
@@ -3200,9 +3122,10 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
 		u8 *reqdata, int reqlen, u8 *buf, int buflen)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
-	r = dsi_vc_generic_send_read_request(dsidev, channel, reqdata, reqlen);
+	r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
 	if (r)
 		return r;
 
@@ -3210,7 +3133,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
 	if (r)
 		return r;
 
-	r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
+	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
 		DSS_DSI_CONTENT_GENERIC);
 	if (r < 0)
 		return r;
@@ -3227,21 +3150,21 @@ static int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int cha
 		u16 len)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
-	return dsi_vc_send_short(dsidev, channel,
+	return dsi_vc_send_short(dsi, channel,
 			MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
 }
 
-static int dsi_enter_ulps(struct platform_device *dsidev)
+static int dsi_enter_ulps(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	int r, i;
 	unsigned int mask;
 
 	DSSDBG("Entering ULPS");
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	WARN_ON(dsi->ulps_enabled);
 
@@ -3249,35 +3172,35 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
 		return 0;
 
 	/* DDR_CLK_ALWAYS_ON */
-	if (REG_GET(dsidev, DSI_CLK_CTRL, 13, 13)) {
-		dsi_if_enable(dsidev, 0);
-		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13);
-		dsi_if_enable(dsidev, 1);
+	if (REG_GET(dsi, DSI_CLK_CTRL, 13, 13)) {
+		dsi_if_enable(dsi, 0);
+		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
+		dsi_if_enable(dsi, 1);
 	}
 
-	dsi_sync_vc(dsidev, 0);
-	dsi_sync_vc(dsidev, 1);
-	dsi_sync_vc(dsidev, 2);
-	dsi_sync_vc(dsidev, 3);
+	dsi_sync_vc(dsi, 0);
+	dsi_sync_vc(dsi, 1);
+	dsi_sync_vc(dsi, 2);
+	dsi_sync_vc(dsi, 3);
 
-	dsi_force_tx_stop_mode_io(dsidev);
+	dsi_force_tx_stop_mode_io(dsi);
 
-	dsi_vc_enable(dsidev, 0, false);
-	dsi_vc_enable(dsidev, 1, false);
-	dsi_vc_enable(dsidev, 2, false);
-	dsi_vc_enable(dsidev, 3, false);
+	dsi_vc_enable(dsi, 0, false);
+	dsi_vc_enable(dsi, 1, false);
+	dsi_vc_enable(dsi, 2, false);
+	dsi_vc_enable(dsi, 3, false);
 
-	if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
+	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
 		DSSERR("HS busy when enabling ULPS\n");
 		return -EIO;
 	}
 
-	if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
+	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
 		DSSERR("LP busy when enabling ULPS\n");
 		return -EIO;
 	}
 
-	r = dsi_register_isr_cio(dsidev, dsi_completion_handler, &completion,
+	r = dsi_register_isr_cio(dsi, dsi_completion_handler, &completion,
 			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
 	if (r)
 		return r;
@@ -3291,10 +3214,10 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
 	}
 	/* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
 	/* LANEx_ULPS_SIG2 */
-	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, mask, 9, 5);
+	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, mask, 9, 5);
 
 	/* flush posted write and wait for SCP interface to finish the write */
-	dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2);
+	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
 
 	if (wait_for_completion_timeout(&completion,
 				msecs_to_jiffies(1000)) == 0) {
@@ -3303,31 +3226,31 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
 		goto err;
 	}
 
-	dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion,
+	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
 			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
 
 	/* Reset LANEx_ULPS_SIG2 */
-	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, 0, 9, 5);
+	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, 0, 9, 5);
 
 	/* flush posted write and wait for SCP interface to finish the write */
-	dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2);
+	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
 
-	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ULPS);
+	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ULPS);
 
-	dsi_if_enable(dsidev, false);
+	dsi_if_enable(dsi, false);
 
 	dsi->ulps_enabled = true;
 
 	return 0;
 
 err:
-	dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion,
+	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
 			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
 	return r;
 }
 
-static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
-		unsigned int ticks, bool x4, bool x16)
+static void dsi_set_lp_rx_timeout(struct dsi_data *dsi, unsigned int ticks,
+				  bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3336,14 +3259,14 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
 	BUG_ON(ticks > 0x1fff);
 
 	/* ticks in DSI_FCK */
-	fck = dsi_fclk_rate(dsidev);
+	fck = dsi_fclk_rate(dsi);
 
-	r = dsi_read_reg(dsidev, DSI_TIMING2);
+	r = dsi_read_reg(dsi, DSI_TIMING2);
 	r = FLD_MOD(r, 1, 15, 15);	/* LP_RX_TO */
 	r = FLD_MOD(r, x16 ? 1 : 0, 14, 14);	/* LP_RX_TO_X16 */
 	r = FLD_MOD(r, x4 ? 1 : 0, 13, 13);	/* LP_RX_TO_X4 */
 	r = FLD_MOD(r, ticks, 12, 0);	/* LP_RX_COUNTER */
-	dsi_write_reg(dsidev, DSI_TIMING2, r);
+	dsi_write_reg(dsi, DSI_TIMING2, r);
 
 	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
 
@@ -3353,8 +3276,8 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
 			(total_ticks * 1000) / (fck / 1000 / 1000));
 }
 
-static void dsi_set_ta_timeout(struct platform_device *dsidev,
-			       unsigned int ticks, bool x8, bool x16)
+static void dsi_set_ta_timeout(struct dsi_data *dsi, unsigned int ticks,
+			       bool x8, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3363,14 +3286,14 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev,
 	BUG_ON(ticks > 0x1fff);
 
 	/* ticks in DSI_FCK */
-	fck = dsi_fclk_rate(dsidev);
+	fck = dsi_fclk_rate(dsi);
 
-	r = dsi_read_reg(dsidev, DSI_TIMING1);
+	r = dsi_read_reg(dsi, DSI_TIMING1);
 	r = FLD_MOD(r, 1, 31, 31);	/* TA_TO */
 	r = FLD_MOD(r, x16 ? 1 : 0, 30, 30);	/* TA_TO_X16 */
 	r = FLD_MOD(r, x8 ? 1 : 0, 29, 29);	/* TA_TO_X8 */
 	r = FLD_MOD(r, ticks, 28, 16);	/* TA_TO_COUNTER */
-	dsi_write_reg(dsidev, DSI_TIMING1, r);
+	dsi_write_reg(dsi, DSI_TIMING1, r);
 
 	total_ticks = ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1);
 
@@ -3380,8 +3303,8 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev,
 			(total_ticks * 1000) / (fck / 1000 / 1000));
 }
 
-static void dsi_set_stop_state_counter(struct platform_device *dsidev,
-				       unsigned int ticks, bool x4, bool x16)
+static void dsi_set_stop_state_counter(struct dsi_data *dsi, unsigned int ticks,
+				       bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3390,14 +3313,14 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
 	BUG_ON(ticks > 0x1fff);
 
 	/* ticks in DSI_FCK */
-	fck = dsi_fclk_rate(dsidev);
+	fck = dsi_fclk_rate(dsi);
 
-	r = dsi_read_reg(dsidev, DSI_TIMING1);
+	r = dsi_read_reg(dsi, DSI_TIMING1);
 	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
 	r = FLD_MOD(r, x16 ? 1 : 0, 14, 14);	/* STOP_STATE_X16_IO */
 	r = FLD_MOD(r, x4 ? 1 : 0, 13, 13);	/* STOP_STATE_X4_IO */
 	r = FLD_MOD(r, ticks, 12, 0);	/* STOP_STATE_COUNTER_IO */
-	dsi_write_reg(dsidev, DSI_TIMING1, r);
+	dsi_write_reg(dsi, DSI_TIMING1, r);
 
 	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
 
@@ -3407,8 +3330,8 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
 			(total_ticks * 1000) / (fck / 1000 / 1000));
 }
 
-static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
-				  unsigned int ticks, bool x4, bool x16)
+static void dsi_set_hs_tx_timeout(struct dsi_data *dsi, unsigned int ticks,
+				  bool x4, bool x16)
 {
 	unsigned long fck;
 	unsigned long total_ticks;
@@ -3417,14 +3340,14 @@ static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
 	BUG_ON(ticks > 0x1fff);
 
 	/* ticks in TxByteClkHS */
-	fck = dsi_get_txbyteclkhs(dsidev);
+	fck = dsi_get_txbyteclkhs(dsi);
 
-	r = dsi_read_reg(dsidev, DSI_TIMING2);
+	r = dsi_read_reg(dsi, DSI_TIMING2);
 	r = FLD_MOD(r, 1, 31, 31);	/* HS_TX_TO */
 	r = FLD_MOD(r, x16 ? 1 : 0, 30, 30);	/* HS_TX_TO_X16 */
 	r = FLD_MOD(r, x4 ? 1 : 0, 29, 29);	/* HS_TX_TO_X8 (4 really) */
 	r = FLD_MOD(r, ticks, 28, 16);	/* HS_TX_TO_COUNTER */
-	dsi_write_reg(dsidev, DSI_TIMING2, r);
+	dsi_write_reg(dsi, DSI_TIMING2, r);
 
 	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
 
@@ -3434,9 +3357,8 @@ static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
 			(total_ticks * 1000) / (fck / 1000 / 1000));
 }
 
-static void dsi_config_vp_num_line_buffers(struct platform_device *dsidev)
+static void dsi_config_vp_num_line_buffers(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int num_line_buffers;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
@@ -3456,12 +3378,11 @@ static void dsi_config_vp_num_line_buffers(struct platform_device *dsidev)
 	}
 
 	/* LINE_BUFFER */
-	REG_FLD_MOD(dsidev, DSI_CTRL, num_line_buffers, 13, 12);
+	REG_FLD_MOD(dsi, DSI_CTRL, num_line_buffers, 13, 12);
 }
 
-static void dsi_config_vp_sync_events(struct platform_device *dsidev)
+static void dsi_config_vp_sync_events(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	bool sync_end;
 	u32 r;
 
@@ -3470,7 +3391,7 @@ static void dsi_config_vp_sync_events(struct platform_device *dsidev)
 	else
 		sync_end = false;
 
-	r = dsi_read_reg(dsidev, DSI_CTRL);
+	r = dsi_read_reg(dsi, DSI_CTRL);
 	r = FLD_MOD(r, 1, 9, 9);		/* VP_DE_POL */
 	r = FLD_MOD(r, 1, 10, 10);		/* VP_HSYNC_POL */
 	r = FLD_MOD(r, 1, 11, 11);		/* VP_VSYNC_POL */
@@ -3478,12 +3399,11 @@ static void dsi_config_vp_sync_events(struct platform_device *dsidev)
 	r = FLD_MOD(r, sync_end, 16, 16);	/* VP_VSYNC_END */
 	r = FLD_MOD(r, 1, 17, 17);		/* VP_HSYNC_START */
 	r = FLD_MOD(r, sync_end, 18, 18);	/* VP_HSYNC_END */
-	dsi_write_reg(dsidev, DSI_CTRL, r);
+	dsi_write_reg(dsi, DSI_CTRL, r);
 }
 
-static void dsi_config_blanking_modes(struct platform_device *dsidev)
+static void dsi_config_blanking_modes(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int blanking_mode = dsi->vm_timings.blanking_mode;
 	int hfp_blanking_mode = dsi->vm_timings.hfp_blanking_mode;
 	int hbp_blanking_mode = dsi->vm_timings.hbp_blanking_mode;
@@ -3494,12 +3414,12 @@ static void dsi_config_blanking_modes(struct platform_device *dsidev)
 	 * 0 = TX FIFO packets sent or LPS in corresponding blanking periods
 	 * 1 = Long blanking packets are sent in corresponding blanking periods
 	 */
-	r = dsi_read_reg(dsidev, DSI_CTRL);
+	r = dsi_read_reg(dsi, DSI_CTRL);
 	r = FLD_MOD(r, blanking_mode, 20, 20);		/* BLANKING_MODE */
 	r = FLD_MOD(r, hfp_blanking_mode, 21, 21);	/* HFP_BLANKING */
 	r = FLD_MOD(r, hbp_blanking_mode, 22, 22);	/* HBP_BLANKING */
 	r = FLD_MOD(r, hsa_blanking_mode, 23, 23);	/* HSA_BLANKING */
-	dsi_write_reg(dsidev, DSI_CTRL, r);
+	dsi_write_reg(dsi, DSI_CTRL, r);
 }
 
 /*
@@ -3564,9 +3484,8 @@ static int dsi_compute_interleave_lp(int blank, int enter_hs, int exit_hs,
 	return max(lp_inter, 0);
 }
 
-static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
+static void dsi_config_cmd_mode_interleaving(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int blanking_mode;
 	int hfp_blanking_mode, hbp_blanking_mode, hsa_blanking_mode;
 	int hsa, hfp, hbp, width_bytes, bllp, lp_clk_div;
@@ -3583,33 +3502,33 @@ static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
 	int bl_interleave_hs = 0, bl_interleave_lp = 0;
 	u32 r;
 
-	r = dsi_read_reg(dsidev, DSI_CTRL);
+	r = dsi_read_reg(dsi, DSI_CTRL);
 	blanking_mode = FLD_GET(r, 20, 20);
 	hfp_blanking_mode = FLD_GET(r, 21, 21);
 	hbp_blanking_mode = FLD_GET(r, 22, 22);
 	hsa_blanking_mode = FLD_GET(r, 23, 23);
 
-	r = dsi_read_reg(dsidev, DSI_VM_TIMING1);
+	r = dsi_read_reg(dsi, DSI_VM_TIMING1);
 	hbp = FLD_GET(r, 11, 0);
 	hfp = FLD_GET(r, 23, 12);
 	hsa = FLD_GET(r, 31, 24);
 
-	r = dsi_read_reg(dsidev, DSI_CLK_TIMING);
+	r = dsi_read_reg(dsi, DSI_CLK_TIMING);
 	ddr_clk_post = FLD_GET(r, 7, 0);
 	ddr_clk_pre = FLD_GET(r, 15, 8);
 
-	r = dsi_read_reg(dsidev, DSI_VM_TIMING7);
+	r = dsi_read_reg(dsi, DSI_VM_TIMING7);
 	exit_hs_mode_lat = FLD_GET(r, 15, 0);
 	enter_hs_mode_lat = FLD_GET(r, 31, 16);
 
-	r = dsi_read_reg(dsidev, DSI_CLK_CTRL);
+	r = dsi_read_reg(dsi, DSI_CLK_CTRL);
 	lp_clk_div = FLD_GET(r, 12, 0);
 	ddr_alwon = FLD_GET(r, 13, 13);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
 	ths_exit = FLD_GET(r, 7, 0);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
 	tclk_trail = FLD_GET(r, 15, 8);
 
 	exiths_clk = ths_exit + tclk_trail;
@@ -3663,45 +3582,44 @@ static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
 		hsa_interleave_lp, hfp_interleave_lp, hbp_interleave_lp,
 		bl_interleave_lp);
 
-	r = dsi_read_reg(dsidev, DSI_VM_TIMING4);
+	r = dsi_read_reg(dsi, DSI_VM_TIMING4);
 	r = FLD_MOD(r, hsa_interleave_hs, 23, 16);
 	r = FLD_MOD(r, hfp_interleave_hs, 15, 8);
 	r = FLD_MOD(r, hbp_interleave_hs, 7, 0);
-	dsi_write_reg(dsidev, DSI_VM_TIMING4, r);
+	dsi_write_reg(dsi, DSI_VM_TIMING4, r);
 
-	r = dsi_read_reg(dsidev, DSI_VM_TIMING5);
+	r = dsi_read_reg(dsi, DSI_VM_TIMING5);
 	r = FLD_MOD(r, hsa_interleave_lp, 23, 16);
 	r = FLD_MOD(r, hfp_interleave_lp, 15, 8);
 	r = FLD_MOD(r, hbp_interleave_lp, 7, 0);
-	dsi_write_reg(dsidev, DSI_VM_TIMING5, r);
+	dsi_write_reg(dsi, DSI_VM_TIMING5, r);
 
-	r = dsi_read_reg(dsidev, DSI_VM_TIMING6);
+	r = dsi_read_reg(dsi, DSI_VM_TIMING6);
 	r = FLD_MOD(r, bl_interleave_hs, 31, 15);
 	r = FLD_MOD(r, bl_interleave_lp, 16, 0);
-	dsi_write_reg(dsidev, DSI_VM_TIMING6, r);
+	dsi_write_reg(dsi, DSI_VM_TIMING6, r);
 }
 
-static int dsi_proto_config(struct platform_device *dsidev)
+static int dsi_proto_config(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u32 r;
 	int buswidth = 0;
 
-	dsi_config_tx_fifo(dsidev, DSI_FIFO_SIZE_32,
+	dsi_config_tx_fifo(dsi, DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32);
 
-	dsi_config_rx_fifo(dsidev, DSI_FIFO_SIZE_32,
+	dsi_config_rx_fifo(dsi, DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32,
 			DSI_FIFO_SIZE_32);
 
 	/* XXX what values for the timeouts? */
-	dsi_set_stop_state_counter(dsidev, 0x1000, false, false);
-	dsi_set_ta_timeout(dsidev, 0x1fff, true, true);
-	dsi_set_lp_rx_timeout(dsidev, 0x1fff, true, true);
-	dsi_set_hs_tx_timeout(dsidev, 0x1fff, true, true);
+	dsi_set_stop_state_counter(dsi, 0x1000, false, false);
+	dsi_set_ta_timeout(dsi, 0x1fff, true, true);
+	dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true);
+	dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true);
 
 	switch (dsi_get_pixel_size(dsi->pix_fmt)) {
 	case 16:
@@ -3718,7 +3636,7 @@ static int dsi_proto_config(struct platform_device *dsidev)
 		return -EINVAL;
 	}
 
-	r = dsi_read_reg(dsidev, DSI_CTRL);
+	r = dsi_read_reg(dsi, DSI_CTRL);
 	r = FLD_MOD(r, 1, 1, 1);	/* CS_RX_EN */
 	r = FLD_MOD(r, 1, 2, 2);	/* ECC_RX_EN */
 	r = FLD_MOD(r, 1, 3, 3);	/* TX_FIFO_ARBITRATION */
@@ -3733,27 +3651,26 @@ static int dsi_proto_config(struct platform_device *dsidev)
 		r = FLD_MOD(r, 0, 25, 25);
 	}
 
-	dsi_write_reg(dsidev, DSI_CTRL, r);
+	dsi_write_reg(dsi, DSI_CTRL, r);
 
-	dsi_config_vp_num_line_buffers(dsidev);
+	dsi_config_vp_num_line_buffers(dsi);
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		dsi_config_vp_sync_events(dsidev);
-		dsi_config_blanking_modes(dsidev);
-		dsi_config_cmd_mode_interleaving(dsidev);
+		dsi_config_vp_sync_events(dsi);
+		dsi_config_blanking_modes(dsi);
+		dsi_config_cmd_mode_interleaving(dsi);
 	}
 
-	dsi_vc_initial_config(dsidev, 0);
-	dsi_vc_initial_config(dsidev, 1);
-	dsi_vc_initial_config(dsidev, 2);
-	dsi_vc_initial_config(dsidev, 3);
+	dsi_vc_initial_config(dsi, 0);
+	dsi_vc_initial_config(dsi, 1);
+	dsi_vc_initial_config(dsi, 2);
+	dsi_vc_initial_config(dsi, 3);
 
 	return 0;
 }
 
-static void dsi_proto_timings(struct platform_device *dsidev)
+static void dsi_proto_timings(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	unsigned int tlpx, tclk_zero, tclk_prepare, tclk_trail;
 	unsigned int tclk_pre, tclk_post;
 	unsigned int ths_prepare, ths_prepare_ths_zero, ths_zero;
@@ -3764,25 +3681,25 @@ static void dsi_proto_timings(struct platform_device *dsidev)
 	int ndl = dsi->num_lanes_used - 1;
 	u32 r;
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
 	ths_prepare = FLD_GET(r, 31, 24);
 	ths_prepare_ths_zero = FLD_GET(r, 23, 16);
 	ths_zero = ths_prepare_ths_zero - ths_prepare;
 	ths_trail = FLD_GET(r, 15, 8);
 	ths_exit = FLD_GET(r, 7, 0);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
 	tlpx = FLD_GET(r, 20, 16) * 2;
 	tclk_trail = FLD_GET(r, 15, 8);
 	tclk_zero = FLD_GET(r, 7, 0);
 
-	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2);
+	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2);
 	tclk_prepare = FLD_GET(r, 7, 0);
 
 	/* min 8*UI */
 	tclk_pre = 20;
 	/* min 60ns + 52*UI */
-	tclk_post = ns2ddr(dsidev, 60) + 26;
+	tclk_post = ns2ddr(dsi, 60) + 26;
 
 	ths_eot = DIV_ROUND_UP(4, ndl);
 
@@ -3793,10 +3710,10 @@ static void dsi_proto_timings(struct platform_device *dsidev)
 	BUG_ON(ddr_clk_pre == 0 || ddr_clk_pre > 255);
 	BUG_ON(ddr_clk_post == 0 || ddr_clk_post > 255);
 
-	r = dsi_read_reg(dsidev, DSI_CLK_TIMING);
+	r = dsi_read_reg(dsi, DSI_CLK_TIMING);
 	r = FLD_MOD(r, ddr_clk_pre, 15, 8);
 	r = FLD_MOD(r, ddr_clk_post, 7, 0);
-	dsi_write_reg(dsidev, DSI_CLK_TIMING, r);
+	dsi_write_reg(dsi, DSI_CLK_TIMING, r);
 
 	DSSDBG("ddr_clk_pre %u, ddr_clk_post %u\n",
 			ddr_clk_pre,
@@ -3810,7 +3727,7 @@ static void dsi_proto_timings(struct platform_device *dsidev)
 
 	r = FLD_VAL(enter_hs_mode_lat, 31, 16) |
 		FLD_VAL(exit_hs_mode_lat, 15, 0);
-	dsi_write_reg(dsidev, DSI_VM_TIMING7, r);
+	dsi_write_reg(dsi, DSI_VM_TIMING7, r);
 
 	DSSDBG("enter_hs_mode_lat %u, exit_hs_mode_lat %u\n",
 			enter_hs_mode_lat, exit_hs_mode_lat);
@@ -3844,23 +3761,23 @@ static void dsi_proto_timings(struct platform_device *dsidev)
 		DSSDBG("VBP: %d, VFP: %d, VSA: %d, VACT: %d lines\n", vbp, vfp,
 			vsa, vm->vactive);
 
-		r = dsi_read_reg(dsidev, DSI_VM_TIMING1);
+		r = dsi_read_reg(dsi, DSI_VM_TIMING1);
 		r = FLD_MOD(r, hbp, 11, 0);	/* HBP */
 		r = FLD_MOD(r, hfp, 23, 12);	/* HFP */
 		r = FLD_MOD(r, hsync_end ? hsa : 0, 31, 24);	/* HSA */
-		dsi_write_reg(dsidev, DSI_VM_TIMING1, r);
+		dsi_write_reg(dsi, DSI_VM_TIMING1, r);
 
-		r = dsi_read_reg(dsidev, DSI_VM_TIMING2);
+		r = dsi_read_reg(dsi, DSI_VM_TIMING2);
 		r = FLD_MOD(r, vbp, 7, 0);	/* VBP */
 		r = FLD_MOD(r, vfp, 15, 8);	/* VFP */
 		r = FLD_MOD(r, vsa, 23, 16);	/* VSA */
 		r = FLD_MOD(r, window_sync, 27, 24);	/* WINDOW_SYNC */
-		dsi_write_reg(dsidev, DSI_VM_TIMING2, r);
+		dsi_write_reg(dsi, DSI_VM_TIMING2, r);
 
-		r = dsi_read_reg(dsidev, DSI_VM_TIMING3);
+		r = dsi_read_reg(dsi, DSI_VM_TIMING3);
 		r = FLD_MOD(r, vm->vactive, 14, 0);	/* VACT */
 		r = FLD_MOD(r, tl, 31, 16);		/* TL */
-		dsi_write_reg(dsidev, DSI_VM_TIMING3, r);
+		dsi_write_reg(dsi, DSI_VM_TIMING3, r);
 	}
 }
 
@@ -3947,7 +3864,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 		return -ENODEV;
 	}
 
-	r = dsi_display_init_dispc(dsidev, dispc_channel);
+	r = dsi_display_init_dispc(dsi, dispc_channel);
 	if (r)
 		goto err_init_dispc;
 
@@ -3970,19 +3887,19 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 			goto err_pix_fmt;
 		}
 
-		dsi_if_enable(dsidev, false);
-		dsi_vc_enable(dsidev, channel, false);
+		dsi_if_enable(dsi, false);
+		dsi_vc_enable(dsi, channel, false);
 
 		/* MODE, 1 = video mode */
-		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 4, 4);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 4, 4);
 
 		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
 
-		dsi_vc_write_long_header(dsidev, channel, data_type,
+		dsi_vc_write_long_header(dsi, channel, data_type,
 				word_count, 0);
 
-		dsi_vc_enable(dsidev, channel, true);
-		dsi_if_enable(dsidev, true);
+		dsi_vc_enable(dsi, channel, true);
+		dsi_if_enable(dsi, true);
 	}
 
 	r = dss_mgr_enable(dispc_channel);
@@ -3993,11 +3910,11 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 
 err_mgr_enable:
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		dsi_if_enable(dsidev, false);
-		dsi_vc_enable(dsidev, channel, false);
+		dsi_if_enable(dsi, false);
+		dsi_vc_enable(dsi, channel, false);
 	}
 err_pix_fmt:
-	dsi_display_uninit_dispc(dsidev, dispc_channel);
+	dsi_display_uninit_dispc(dsi, dispc_channel);
 err_init_dispc:
 	return r;
 }
@@ -4009,24 +3926,23 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 	enum omap_channel dispc_channel = dssdev->dispc_channel;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		dsi_if_enable(dsidev, false);
-		dsi_vc_enable(dsidev, channel, false);
+		dsi_if_enable(dsi, false);
+		dsi_vc_enable(dsi, channel, false);
 
 		/* MODE, 0 = command mode */
-		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 0, 4, 4);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 0, 4, 4);
 
-		dsi_vc_enable(dsidev, channel, true);
-		dsi_if_enable(dsidev, true);
+		dsi_vc_enable(dsi, channel, true);
+		dsi_if_enable(dsi, true);
 	}
 
 	dss_mgr_disable(dispc_channel);
 
-	dsi_display_uninit_dispc(dsidev, dispc_channel);
+	dsi_display_uninit_dispc(dsi, dispc_channel);
 }
 
-static void dsi_update_screen_dispc(struct platform_device *dsidev)
+static void dsi_update_screen_dispc(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 	unsigned int bytespp;
 	unsigned int bytespl;
@@ -4043,7 +3959,7 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
 
 	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
 
-	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_VP);
+	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP);
 
 	bytespp	= dsi_get_pixel_size(dsi->pix_fmt) / 8;
 	bytespl = w * bytespp;
@@ -4064,16 +3980,16 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
 		total_len += (bytespf % packet_payload) + 1;
 
 	l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */
-	dsi_write_reg(dsidev, DSI_VC_TE(channel), l);
+	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
 
-	dsi_vc_write_long_header(dsidev, channel, MIPI_DSI_DCS_LONG_WRITE,
+	dsi_vc_write_long_header(dsi, channel, MIPI_DSI_DCS_LONG_WRITE,
 		packet_len, 0);
 
 	if (dsi->te_enabled)
 		l = FLD_MOD(l, 1, 30, 30); /* TE_EN */
 	else
 		l = FLD_MOD(l, 1, 31, 31); /* TE_START */
-	dsi_write_reg(dsidev, DSI_VC_TE(channel), l);
+	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
 
 	/* We put SIDLEMODE to no-idle for the duration of the transfer,
 	 * because DSS interrupts are not capable of waking up the CPU and the
@@ -4083,7 +3999,7 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
 	 */
 	dispc_disable_sidle();
 
-	dsi_perf_mark_start(dsidev);
+	dsi_perf_mark_start(dsi);
 
 	r = schedule_delayed_work(&dsi->framedone_timeout_work,
 		msecs_to_jiffies(250));
@@ -4096,9 +4012,9 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
 	if (dsi->te_enabled) {
 		/* disable LP_RX_TO, so that we can receive TE.  Time to wait
 		 * for TE is longer than the timer allows */
-		REG_FLD_MOD(dsidev, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
+		REG_FLD_MOD(dsi, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
 
-		dsi_vc_send_bta(dsidev, channel);
+		dsi_vc_send_bta(dsi, channel);
 
 #ifdef DSI_CATCH_MISSING_TE
 		mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250));
@@ -4113,22 +4029,20 @@ static void dsi_te_timeout(unsigned long arg)
 }
 #endif
 
-static void dsi_handle_framedone(struct platform_device *dsidev, int error)
+static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	/* SIDLEMODE back to smart-idle */
 	dispc_enable_sidle();
 
 	if (dsi->te_enabled) {
 		/* enable LP_RX_TO again after the TE */
-		REG_FLD_MOD(dsidev, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
+		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
 	}
 
 	dsi->framedone_callback(error, dsi->framedone_data);
 
 	if (!error)
-		dsi_perf_show(dsidev, "DISPC");
+		dsi_perf_show(dsi, "DISPC");
 }
 
 static void dsi_framedone_timeout_work_callback(struct work_struct *work)
@@ -4144,13 +4058,12 @@ static void dsi_framedone_timeout_work_callback(struct work_struct *work)
 
 	DSSERR("Framedone not received for 250ms!\n");
 
-	dsi_handle_framedone(dsi->pdev, -ETIMEDOUT);
+	dsi_handle_framedone(dsi, -ETIMEDOUT);
 }
 
 static void dsi_framedone_irq_callback(void *data)
 {
-	struct platform_device *dsidev = (struct platform_device *) data;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = data;
 
 	/* Note: We get FRAMEDONE when DISPC has finished sending pixels and
 	 * turns itself off. However, DSI still has the pixels in its buffers,
@@ -4159,7 +4072,7 @@ static void dsi_framedone_irq_callback(void *data)
 
 	cancel_delayed_work(&dsi->framedone_timeout_work);
 
-	dsi_handle_framedone(dsidev, 0);
+	dsi_handle_framedone(dsi, 0);
 }
 
 static int dsi_update(struct omap_dss_device *dssdev, int channel,
@@ -4169,7 +4082,7 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	u16 dw, dh;
 
-	dsi_perf_mark_setup(dsidev);
+	dsi_perf_mark_setup(dsi);
 
 	dsi->update_channel = channel;
 
@@ -4183,21 +4096,20 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 	dsi->update_bytes = dw * dh *
 		dsi_get_pixel_size(dsi->pix_fmt) / 8;
 #endif
-	dsi_update_screen_dispc(dsidev);
+	dsi_update_screen_dispc(dsi);
 
 	return 0;
 }
 
 /* Display funcs */
 
-static int dsi_configure_dispc_clocks(struct platform_device *dsidev)
+static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct dispc_clock_info dispc_cinfo;
 	int r;
 	unsigned long fck;
 
-	fck = dsi_get_pll_hsdiv_dispc_rate(dsidev);
+	fck = dsi_get_pll_hsdiv_dispc_rate(dsi);
 
 	dispc_cinfo.lck_div = dsi->user_dispc_cinfo.lck_div;
 	dispc_cinfo.pck_div = dsi->user_dispc_cinfo.pck_div;
@@ -4213,10 +4125,9 @@ static int dsi_configure_dispc_clocks(struct platform_device *dsidev)
 	return 0;
 }
 
-static int dsi_display_init_dispc(struct platform_device *dsidev,
-		enum omap_channel channel)
+static int dsi_display_init_dispc(struct dsi_data *dsi,
+				  enum omap_channel channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
 	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
@@ -4225,7 +4136,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
 
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) {
 		r = dss_mgr_register_framedone_handler(channel,
-				dsi_framedone_irq_callback, dsidev);
+				dsi_framedone_irq_callback, dsi);
 		if (r) {
 			DSSERR("can't register FRAMEDONE handler\n");
 			goto err;
@@ -4256,7 +4167,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
 
 	dss_mgr_set_timings(channel, &dsi->vm);
 
-	r = dsi_configure_dispc_clocks(dsidev);
+	r = dsi_configure_dispc_clocks(dsi);
 	if (r)
 		goto err1;
 
@@ -4271,27 +4182,24 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
 err1:
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
 		dss_mgr_unregister_framedone_handler(channel,
-				dsi_framedone_irq_callback, dsidev);
+				dsi_framedone_irq_callback, dsi);
 err:
 	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
 	return r;
 }
 
-static void dsi_display_uninit_dispc(struct platform_device *dsidev,
-		enum omap_channel channel)
+static void dsi_display_uninit_dispc(struct dsi_data *dsi,
+				     enum omap_channel channel)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
 		dss_mgr_unregister_framedone_handler(channel,
-				dsi_framedone_irq_callback, dsidev);
+				dsi_framedone_irq_callback, dsi);
 
 	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
 }
 
-static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
+static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct dss_pll_clock_info cinfo;
 	int r;
 
@@ -4306,16 +4214,15 @@ static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
 	return 0;
 }
 
-static int dsi_display_init_dsi(struct platform_device *dsidev)
+static int dsi_display_init_dsi(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	int r;
 
 	r = dss_pll_enable(&dsi->pll);
 	if (r)
 		goto err0;
 
-	r = dsi_configure_dsi_clocks(dsidev);
+	r = dsi_configure_dsi_clocks(dsi);
 	if (r)
 		goto err1;
 
@@ -4325,33 +4232,33 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
 
 	DSSDBG("PLL OK\n");
 
-	r = dsi_cio_init(dsidev);
+	r = dsi_cio_init(dsi);
 	if (r)
 		goto err2;
 
-	_dsi_print_reset_status(dsidev);
+	_dsi_print_reset_status(dsi);
 
-	dsi_proto_timings(dsidev);
-	dsi_set_lp_clk_divisor(dsidev);
+	dsi_proto_timings(dsi);
+	dsi_set_lp_clk_divisor(dsi);
 
 	if (1)
-		_dsi_print_reset_status(dsidev);
+		_dsi_print_reset_status(dsi);
 
-	r = dsi_proto_config(dsidev);
+	r = dsi_proto_config(dsi);
 	if (r)
 		goto err3;
 
 	/* enable interface */
-	dsi_vc_enable(dsidev, 0, 1);
-	dsi_vc_enable(dsidev, 1, 1);
-	dsi_vc_enable(dsidev, 2, 1);
-	dsi_vc_enable(dsidev, 3, 1);
-	dsi_if_enable(dsidev, 1);
-	dsi_force_tx_stop_mode_io(dsidev);
+	dsi_vc_enable(dsi, 0, 1);
+	dsi_vc_enable(dsi, 1, 1);
+	dsi_vc_enable(dsi, 2, 1);
+	dsi_vc_enable(dsi, 3, 1);
+	dsi_if_enable(dsi, 1);
+	dsi_force_tx_stop_mode_io(dsi);
 
 	return 0;
 err3:
-	dsi_cio_uninit(dsidev);
+	dsi_cio_uninit(dsi);
 err2:
 	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
 err1:
@@ -4360,24 +4267,22 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
 	return r;
 }
 
-static void dsi_display_uninit_dsi(struct platform_device *dsidev,
-		bool disconnect_lanes, bool enter_ulps)
+static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
+				   bool enter_ulps)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
 	if (enter_ulps && !dsi->ulps_enabled)
-		dsi_enter_ulps(dsidev);
+		dsi_enter_ulps(dsi);
 
 	/* disable interface */
-	dsi_if_enable(dsidev, 0);
-	dsi_vc_enable(dsidev, 0, 0);
-	dsi_vc_enable(dsidev, 1, 0);
-	dsi_vc_enable(dsidev, 2, 0);
-	dsi_vc_enable(dsidev, 3, 0);
+	dsi_if_enable(dsi, 0);
+	dsi_vc_enable(dsi, 0, 0);
+	dsi_vc_enable(dsi, 1, 0);
+	dsi_vc_enable(dsi, 2, 0);
+	dsi_vc_enable(dsi, 3, 0);
 
 	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
-	dsi_cio_uninit(dsidev);
-	dsi_pll_uninit(dsidev, disconnect_lanes);
+	dsi_cio_uninit(dsi);
+	dsi_pll_uninit(dsi, disconnect_lanes);
 }
 
 static int dsi_display_enable(struct omap_dss_device *dssdev)
@@ -4388,17 +4293,17 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
 
 	DSSDBG("dsi_display_enable\n");
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
 
-	r = dsi_runtime_get(dsidev);
+	r = dsi_runtime_get(dsi);
 	if (r)
 		goto err_get_dsi;
 
-	_dsi_initialize_irq(dsidev);
+	_dsi_initialize_irq(dsi);
 
-	r = dsi_display_init_dsi(dsidev);
+	r = dsi_display_init_dsi(dsi);
 	if (r)
 		goto err_init_dsi;
 
@@ -4407,7 +4312,7 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
 	return 0;
 
 err_init_dsi:
-	dsi_runtime_put(dsidev);
+	dsi_runtime_put(dsi);
 err_get_dsi:
 	mutex_unlock(&dsi->lock);
 	DSSDBG("dsi_display_enable FAILED\n");
@@ -4422,18 +4327,18 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 
 	DSSDBG("dsi_display_disable\n");
 
-	WARN_ON(!dsi_bus_is_locked(dsidev));
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
 
-	dsi_sync_vc(dsidev, 0);
-	dsi_sync_vc(dsidev, 1);
-	dsi_sync_vc(dsidev, 2);
-	dsi_sync_vc(dsidev, 3);
+	dsi_sync_vc(dsi, 0);
+	dsi_sync_vc(dsi, 1);
+	dsi_sync_vc(dsi, 2);
+	dsi_sync_vc(dsi, 3);
 
-	dsi_display_uninit_dsi(dsidev, disconnect_lanes, enter_ulps);
+	dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
 
-	dsi_runtime_put(dsidev);
+	dsi_runtime_put(dsi);
 
 	mutex_unlock(&dsi->lock);
 }
@@ -4570,7 +4475,7 @@ static bool dsi_cm_calc_pll_cb(int n, int m, unsigned long fint,
 		unsigned long clkdco, void *data)
 {
 	struct dsi_clk_calc_ctx *ctx = data;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
+	struct dsi_data *dsi = ctx->dsi;
 
 	ctx->dsi_cinfo.n = n;
 	ctx->dsi_cinfo.m = m;
@@ -4606,7 +4511,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
 	txbyteclk = pck * bitspp / 8 / ndl;
 
 	memset(ctx, 0, sizeof(*ctx));
-	ctx->dsidev = dsi->pdev;
+	ctx->dsi = dsi;
 	ctx->pll = &dsi->pll;
 	ctx->config = cfg;
 	ctx->req_pck_min = pck;
@@ -4623,7 +4528,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
 
 static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx *ctx)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
+	struct dsi_data *dsi = ctx->dsi;
 	const struct omap_dss_dsi_config *cfg = ctx->config;
 	int bitspp = dsi_get_pixel_size(cfg->pixel_format);
 	int ndl = dsi->num_lanes_used - 1;
@@ -4870,7 +4775,7 @@ static bool dsi_vm_calc_pll_cb(int n, int m, unsigned long fint,
 		unsigned long clkdco, void *data)
 {
 	struct dsi_clk_calc_ctx *ctx = data;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
+	struct dsi_data *dsi = ctx->dsi;
 
 	ctx->dsi_cinfo.n = n;
 	ctx->dsi_cinfo.m = m;
@@ -4897,7 +4802,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
 	clkin = clk_get_rate(dsi->pll.clkin);
 
 	memset(ctx, 0, sizeof(*ctx));
-	ctx->dsidev = dsi->pdev;
+	ctx->dsi = dsi;
 	ctx->pll = &dsi->pll;
 	ctx->config = cfg;
 
@@ -5070,12 +4975,11 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 }
 
 
-static int dsi_get_clocks(struct platform_device *dsidev)
+static int dsi_get_clocks(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct clk *clk;
 
-	clk = devm_clk_get(&dsidev->dev, "fck");
+	clk = devm_clk_get(&dsi->pdev->dev, "fck");
 	if (IS_ERR(clk)) {
 		DSSERR("can't get fck\n");
 		return PTR_ERR(clk);
@@ -5090,10 +4994,11 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	enum omap_channel dispc_channel = dssdev->dispc_channel;
 	int r;
 
-	r = dsi_regulator_init(dsidev);
+	r = dsi_regulator_init(dsi);
 	if (r)
 		return r;
 
@@ -5166,12 +5071,11 @@ static const struct omapdss_dsi_ops dsi_ops = {
 	.set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
 };
 
-static void dsi_init_output(struct platform_device *dsidev)
+static void dsi_init_output(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct omap_dss_device *out = &dsi->output;
 
-	out->dev = &dsidev->dev;
+	out->dev = &dsi->pdev->dev;
 	out->id = dsi->module_id == 0 ?
 			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
 
@@ -5184,18 +5088,16 @@ static void dsi_init_output(struct platform_device *dsidev)
 	omapdss_register_output(out);
 }
 
-static void dsi_uninit_output(struct platform_device *dsidev)
+static void dsi_uninit_output(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct omap_dss_device *out = &dsi->output;
 
 	omapdss_unregister_output(out);
 }
 
-static int dsi_probe_of(struct platform_device *pdev)
+static int dsi_probe_of(struct dsi_data *dsi)
 {
-	struct device_node *node = pdev->dev.of_node;
-	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
+	struct device_node *node = dsi->pdev->dev.of_node;
 	struct property *prop;
 	u32 lane_arr[10];
 	int len, num_pins;
@@ -5209,7 +5111,7 @@ static int dsi_probe_of(struct platform_device *pdev)
 
 	prop = of_find_property(ep, "lanes", &len);
 	if (prop == NULL) {
-		dev_err(&pdev->dev, "failed to find lane data\n");
+		dev_err(&dsi->pdev->dev, "failed to find lane data\n");
 		r = -EINVAL;
 		goto err;
 	}
@@ -5218,14 +5120,14 @@ static int dsi_probe_of(struct platform_device *pdev)
 
 	if (num_pins < 4 || num_pins % 2 != 0 ||
 		num_pins > dsi->num_lanes_supported * 2) {
-		dev_err(&pdev->dev, "bad number of lanes\n");
+		dev_err(&dsi->pdev->dev, "bad number of lanes\n");
 		r = -EINVAL;
 		goto err;
 	}
 
 	r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
 	if (r) {
-		dev_err(&pdev->dev, "failed to read lane data\n");
+		dev_err(&dsi->pdev->dev, "failed to read lane data\n");
 		goto err;
 	}
 
@@ -5235,7 +5137,7 @@ static int dsi_probe_of(struct platform_device *pdev)
 
 	r = dsi_configure_pins(&dsi->output, &pin_cfg);
 	if (r) {
-		dev_err(&pdev->dev, "failed to configure pins");
+		dev_err(&dsi->pdev->dev, "failed to configure pins");
 		goto err;
 	}
 
@@ -5335,15 +5237,13 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
 	.has_refsel = true,
 };
 
-static int dsi_init_pll_data(struct dss_device *dss,
-			     struct platform_device *dsidev)
+static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 	struct dss_pll *pll = &dsi->pll;
 	struct clk *clk;
 	int r;
 
-	clk = devm_clk_get(&dsidev->dev, "sys_clk");
+	clk = devm_clk_get(&dsi->pdev->dev, "sys_clk");
 	if (IS_ERR(clk)) {
 		DSSERR("can't get sys_clk\n");
 		return PTR_ERR(clk);
@@ -5492,7 +5392,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	}
 
 	r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
-			     IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev);
+			     IRQF_SHARED, dev_name(&dsidev->dev), dsi);
 	if (r < 0) {
 		DSSERR("request_irq failed\n");
 		return r;
@@ -5540,19 +5440,19 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 		dsi->vc[i].vc_id = 0;
 	}
 
-	r = dsi_get_clocks(dsidev);
+	r = dsi_get_clocks(dsi);
 	if (r)
 		return r;
 
-	dsi_init_pll_data(dss, dsidev);
+	dsi_init_pll_data(dss, dsi);
 
 	pm_runtime_enable(&dsidev->dev);
 
-	r = dsi_runtime_get(dsidev);
+	r = dsi_runtime_get(dsi);
 	if (r)
 		goto err_runtime_get;
 
-	rev = dsi_read_reg(dsidev, DSI_REVISION);
+	rev = dsi_read_reg(dsi, DSI_REVISION);
 	dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
 	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
@@ -5560,15 +5460,15 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	 * of data to 3 by default */
 	if (dsi->data->quirks & DSI_QUIRK_GNQ)
 		/* NB_DATA_LANES */
-		dsi->num_lanes_supported = 1 + REG_GET(dsidev, DSI_GNQ, 11, 9);
+		dsi->num_lanes_supported = 1 + REG_GET(dsi, DSI_GNQ, 11, 9);
 	else
 		dsi->num_lanes_supported = 3;
 
-	dsi->line_buffer_size = dsi_get_line_buf_size(dsidev);
+	dsi->line_buffer_size = dsi_get_line_buf_size(dsi);
 
-	dsi_init_output(dsidev);
+	dsi_init_output(dsi);
 
-	r = dsi_probe_of(dsidev);
+	r = dsi_probe_of(dsi);
 	if (r) {
 		DSSERR("Invalid DSI DT data\n");
 		goto err_probe_of;
@@ -5578,7 +5478,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		DSSERR("Failed to populate DSI child devices: %d\n", r);
 
-	dsi_runtime_put(dsidev);
+	dsi_runtime_put(dsi);
 
 	if (dsi->module_id == 0)
 		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
@@ -5602,8 +5502,8 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	return 0;
 
 err_probe_of:
-	dsi_uninit_output(dsidev);
-	dsi_runtime_put(dsidev);
+	dsi_uninit_output(dsi);
+	dsi_runtime_put(dsi);
 
 err_runtime_get:
 	pm_runtime_disable(&dsidev->dev);
@@ -5624,7 +5524,7 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
 
 	dss_pll_unregister(&dsi->pll);
 
-	dsi_uninit_output(dsidev);
+	dsi_uninit_output(dsi);
 
 	pm_runtime_disable(&dsidev->dev);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (35 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:06   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
                   ` (14 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dsi_get_dsidrv_data() and dsi_get_dsidev_from_dssdev() inline
functions convert a struct omap_dss_device pointer to the corresponding
struct platform_device, and a struct platform_device pointer to the
corresponding struct dsi_data. They are nearly always called together
without any use of the intermediate platform_device, so combine them
into a single function.

In the three locations where only dsi_get_dsidrv_data() is used, call
dev_get_drvdata() directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 90 +++++++++++++--------------------------
 1 file changed, 30 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 312804104ad3..a763ab7ed657 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -441,14 +441,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
-static inline struct dsi_data *dsi_get_dsidrv_data(struct platform_device *dsidev)
+static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
 {
-	return dev_get_drvdata(&dsidev->dev);
-}
-
-static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss_device *dssdev)
-{
-	return to_platform_device(dssdev->dev);
+	return dev_get_drvdata(dssdev->dev);
 }
 
 static struct dsi_data *dsi_get_dsi_from_id(int module)
@@ -469,7 +464,7 @@ static struct dsi_data *dsi_get_dsi_from_id(int module)
 
 	out = omap_dss_get_output(id);
 
-	return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
+	return out ? to_dsi_data(out) : NULL;
 }
 
 static inline void dsi_write_reg(struct dsi_data *dsi,
@@ -503,16 +498,14 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
 
 static void dsi_bus_lock(struct omap_dss_device *dssdev)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	down(&dsi->bus_lock);
 }
 
 static void dsi_bus_unlock(struct omap_dss_device *dssdev)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	up(&dsi->bus_lock);
 }
@@ -2536,8 +2529,7 @@ static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
 static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
 		bool enable)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
 
@@ -2660,8 +2652,7 @@ static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
 
 static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	int r = 0;
 	u32 err;
@@ -2863,8 +2854,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
 static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
 		u8 *data, int len)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	return dsi_vc_write_nosync_common(dsi, channel, data, len,
 			DSS_DSI_CONTENT_DCS);
@@ -2873,8 +2863,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
 static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
 		u8 *data, int len)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	return dsi_vc_write_nosync_common(dsi, channel, data, len,
 			DSS_DSI_CONTENT_GENERIC);
@@ -2884,8 +2873,7 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
 			       int channel, u8 *data, int len,
 			       enum dss_dsi_content_type type)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
 	r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
@@ -3090,8 +3078,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
 		u8 *buf, int buflen)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
 	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
@@ -3121,8 +3108,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
 static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
 		u8 *reqdata, int reqlen, u8 *buf, int buflen)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
 	r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
@@ -3149,8 +3135,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
 static int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
 		u16 len)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	return dsi_vc_send_short(dsi, channel,
 			MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
@@ -3784,8 +3769,7 @@ static void dsi_proto_timings(struct dsi_data *dsi)
 static int dsi_configure_pins(struct omap_dss_device *dssdev,
 		const struct omap_dsi_pin_config *pin_cfg)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int num_pins;
 	const int *pins;
 	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
@@ -3850,8 +3834,7 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 
 static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	enum omap_channel dispc_channel = dssdev->dispc_channel;
 	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
 	struct omap_dss_device *out = &dsi->output;
@@ -3921,8 +3904,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 
 static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	enum omap_channel dispc_channel = dssdev->dispc_channel;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
@@ -4078,8 +4060,7 @@ static void dsi_framedone_irq_callback(void *data)
 static int dsi_update(struct omap_dss_device *dssdev, int channel,
 		void (*callback)(int, void *), void *data)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	u16 dw, dh;
 
 	dsi_perf_mark_setup(dsi);
@@ -4287,8 +4268,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 
 static int dsi_display_enable(struct omap_dss_device *dssdev)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r = 0;
 
 	DSSDBG("dsi_display_enable\n");
@@ -4322,8 +4302,7 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
 static void dsi_display_disable(struct omap_dss_device *dssdev,
 		bool disconnect_lanes, bool enter_ulps)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	DSSDBG("dsi_display_disable\n");
 
@@ -4345,8 +4324,7 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 
 static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	dsi->te_enabled = enable;
 	return 0;
@@ -4832,8 +4810,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
 static int dsi_set_config(struct omap_dss_device *dssdev,
 		const struct omap_dss_dsi_config *config)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	struct dsi_clk_calc_ctx ctx;
 	bool ok;
 	int r;
@@ -4920,8 +4897,7 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
 
 static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
@@ -4938,8 +4914,7 @@ static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
 
 static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	if (vc_id < 0 || vc_id > 3) {
 		DSSERR("VC ID out of range\n");
@@ -4964,8 +4939,7 @@ static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id)
 
 static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	if ((channel >= 0 && channel <= 3) &&
 		dsi->vc[channel].dssdev == dssdev) {
@@ -4993,8 +4967,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 static int dsi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	enum omap_channel dispc_channel = dssdev->dispc_channel;
 	int r;
 
@@ -5512,13 +5485,12 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 
 static void dsi_unbind(struct device *dev, struct device *master, void *data)
 {
-	struct platform_device *dsidev = to_platform_device(dev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+	struct dsi_data *dsi = dev_get_drvdata(dev);
 
 	dss_debugfs_remove_file(dsi->debugfs.irqs);
 	dss_debugfs_remove_file(dsi->debugfs.regs);
 
-	of_platform_depopulate(&dsidev->dev);
+	of_platform_depopulate(dev);
 
 	WARN_ON(dsi->scp_clk_refcount > 0);
 
@@ -5526,7 +5498,7 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
 
 	dsi_uninit_output(dsi);
 
-	pm_runtime_disable(&dsidev->dev);
+	pm_runtime_disable(dev);
 
 	if (dsi->vdds_dsi_reg != NULL && dsi->vdds_dsi_enabled) {
 		regulator_disable(dsi->vdds_dsi_reg);
@@ -5552,8 +5524,7 @@ static int dsi_remove(struct platform_device *pdev)
 
 static int dsi_runtime_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
+	struct dsi_data *dsi = dev_get_drvdata(dev);
 
 	dsi->is_enabled = false;
 	/* ensure the irq handler sees the is_enabled value */
@@ -5568,8 +5539,7 @@ static int dsi_runtime_suspend(struct device *dev)
 
 static int dsi_runtime_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
+	struct dsi_data *dsi = dev_get_drvdata(dev);
 	int r;
 
 	r = dispc_runtime_get();
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (36 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:08   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
                   ` (13 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dsi_bind() function receives a pointer to a struct device that it
casts to a struct platform_device, only to use the platform device's dev
field through the code. Use the dev pointer directly.

While at it rename the struct platform_device pointer dsidev to pdev to
make it more explicit.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a763ab7ed657..4f67dd70f279 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5302,9 +5302,10 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
 	{ .machine = "AM35*",		.data = &dsi_of_data_omap34xx },
 	{ /* sentinel */ }
 };
+
 static int dsi_bind(struct device *dev, struct device *master, void *data)
 {
-	struct platform_device *dsidev = to_platform_device(dev);
+	struct platform_device *pdev = to_platform_device(dev);
 	struct dss_device *dss = dss_get_device(master);
 	const struct soc_device_attribute *soc;
 	const struct dsi_module_id_data *d;
@@ -5314,13 +5315,13 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	struct resource *dsi_mem;
 	struct resource *res;
 
-	dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL);
+	dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
 	if (!dsi)
 		return -ENOMEM;
 
 	dsi->dss = dss;
-	dsi->pdev = dsidev;
-	dev_set_drvdata(&dsidev->dev, dsi);
+	dsi->pdev = pdev;
+	dev_set_drvdata(dev, dsi);
 
 	spin_lock_init(&dsi->irq_lock);
 	spin_lock_init(&dsi->errors_lock);
@@ -5343,29 +5344,29 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	dsi->te_timer.data = 0;
 #endif
 
-	dsi_mem = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "proto");
-	dsi->proto_base = devm_ioremap_resource(&dsidev->dev, dsi_mem);
+	dsi_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "proto");
+	dsi->proto_base = devm_ioremap_resource(dev, dsi_mem);
 	if (IS_ERR(dsi->proto_base))
 		return PTR_ERR(dsi->proto_base);
 
-	res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy");
-	dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res);
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy");
+	dsi->phy_base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(dsi->phy_base))
 		return PTR_ERR(dsi->phy_base);
 
-	res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll");
-	dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res);
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll");
+	dsi->pll_base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(dsi->pll_base))
 		return PTR_ERR(dsi->pll_base);
 
-	dsi->irq = platform_get_irq(dsi->pdev, 0);
+	dsi->irq = platform_get_irq(pdev, 0);
 	if (dsi->irq < 0) {
 		DSSERR("platform_get_irq failed\n");
 		return -ENODEV;
 	}
 
-	r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
-			     IRQF_SHARED, dev_name(&dsidev->dev), dsi);
+	r = devm_request_irq(dev, dsi->irq, omap_dsi_irq_handler,
+			     IRQF_SHARED, dev_name(dev), dsi);
 	if (r < 0) {
 		DSSERR("request_irq failed\n");
 		return r;
@@ -5419,14 +5420,14 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 
 	dsi_init_pll_data(dss, dsi);
 
-	pm_runtime_enable(&dsidev->dev);
+	pm_runtime_enable(dev);
 
 	r = dsi_runtime_get(dsi);
 	if (r)
 		goto err_runtime_get;
 
 	rev = dsi_read_reg(dsi, DSI_REVISION);
-	dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
+	dev_dbg(dev, "OMAP DSI rev %d.%d\n",
 	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
 	/* DSI on OMAP3 doesn't have register DSI_GNQ, set number
@@ -5447,7 +5448,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 		goto err_probe_of;
 	}
 
-	r = of_platform_populate(dsidev->dev.of_node, NULL, NULL, &dsidev->dev);
+	r = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (r)
 		DSSERR("Failed to populate DSI child devices: %d\n", r);
 
@@ -5479,7 +5480,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	dsi_runtime_put(dsi);
 
 err_runtime_get:
-	pm_runtime_disable(&dsidev->dev);
+	pm_runtime_disable(dev);
 	return r;
 }
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (37 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:11   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
                   ` (12 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dsi_data structure stores a pointer to a struct platform_device. The
driver only uses the dev member of the platform device structure. Store
the struct device pointer instead and use it directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4f67dd70f279..9be26eb262f3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -332,7 +332,7 @@ struct dsi_of_data {
 };
 
 struct dsi_data {
-	struct platform_device *pdev;
+	struct device *dev;
 	void __iomem *proto_base;
 	void __iomem *phy_base;
 	void __iomem *pll_base;
@@ -1146,7 +1146,7 @@ static int dsi_runtime_get(struct dsi_data *dsi)
 
 	DSSDBG("dsi_runtime_get\n");
 
-	r = pm_runtime_get_sync(&dsi->pdev->dev);
+	r = pm_runtime_get_sync(dsi->dev);
 	WARN_ON(r < 0);
 	return r < 0 ? r : 0;
 }
@@ -1157,7 +1157,7 @@ static void dsi_runtime_put(struct dsi_data *dsi)
 
 	DSSDBG("dsi_runtime_put\n");
 
-	r = pm_runtime_put_sync(&dsi->pdev->dev);
+	r = pm_runtime_put_sync(dsi->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
@@ -1168,7 +1168,7 @@ static int dsi_regulator_init(struct dsi_data *dsi)
 	if (dsi->vdds_dsi_reg != NULL)
 		return 0;
 
-	vdds_dsi = devm_regulator_get(&dsi->pdev->dev, "vdd");
+	vdds_dsi = devm_regulator_get(dsi->dev, "vdd");
 
 	if (IS_ERR(vdds_dsi)) {
 		if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
@@ -4953,7 +4953,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 {
 	struct clk *clk;
 
-	clk = devm_clk_get(&dsi->pdev->dev, "fck");
+	clk = devm_clk_get(dsi->dev, "fck");
 	if (IS_ERR(clk)) {
 		DSSERR("can't get fck\n");
 		return PTR_ERR(clk);
@@ -5048,7 +5048,7 @@ static void dsi_init_output(struct dsi_data *dsi)
 {
 	struct omap_dss_device *out = &dsi->output;
 
-	out->dev = &dsi->pdev->dev;
+	out->dev = dsi->dev;
 	out->id = dsi->module_id == 0 ?
 			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
 
@@ -5070,7 +5070,7 @@ static void dsi_uninit_output(struct dsi_data *dsi)
 
 static int dsi_probe_of(struct dsi_data *dsi)
 {
-	struct device_node *node = dsi->pdev->dev.of_node;
+	struct device_node *node = dsi->dev->of_node;
 	struct property *prop;
 	u32 lane_arr[10];
 	int len, num_pins;
@@ -5084,7 +5084,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
 	prop = of_find_property(ep, "lanes", &len);
 	if (prop == NULL) {
-		dev_err(&dsi->pdev->dev, "failed to find lane data\n");
+		dev_err(dsi->dev, "failed to find lane data\n");
 		r = -EINVAL;
 		goto err;
 	}
@@ -5093,14 +5093,14 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
 	if (num_pins < 4 || num_pins % 2 != 0 ||
 		num_pins > dsi->num_lanes_supported * 2) {
-		dev_err(&dsi->pdev->dev, "bad number of lanes\n");
+		dev_err(dsi->dev, "bad number of lanes\n");
 		r = -EINVAL;
 		goto err;
 	}
 
 	r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
 	if (r) {
-		dev_err(&dsi->pdev->dev, "failed to read lane data\n");
+		dev_err(dsi->dev, "failed to read lane data\n");
 		goto err;
 	}
 
@@ -5110,7 +5110,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
 	r = dsi_configure_pins(&dsi->output, &pin_cfg);
 	if (r) {
-		dev_err(&dsi->pdev->dev, "failed to configure pins");
+		dev_err(dsi->dev, "failed to configure pins");
 		goto err;
 	}
 
@@ -5216,7 +5216,7 @@ static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
 	struct clk *clk;
 	int r;
 
-	clk = devm_clk_get(&dsi->pdev->dev, "sys_clk");
+	clk = devm_clk_get(dsi->dev, "sys_clk");
 	if (IS_ERR(clk)) {
 		DSSERR("can't get sys_clk\n");
 		return PTR_ERR(clk);
@@ -5320,7 +5320,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 		return -ENOMEM;
 
 	dsi->dss = dss;
-	dsi->pdev = pdev;
+	dsi->dev = dev;
 	dev_set_drvdata(dev, dsi);
 
 	spin_lock_init(&dsi->irq_lock);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (38 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:13   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
                   ` (11 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dsi_display_init_dispc() and dsi_display_uninit_dispc() functions
take a channel argument that is reduntant as it is always identical to
the dsi->output.dispc_channel. Remove the argument and use the field
directly in the functions to avoid misuse.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9be26eb262f3..d1cc036ed280 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -217,10 +217,8 @@ struct dsi_reg { u16 module; u16 idx; };
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
 struct dsi_data;
 
-static int dsi_display_init_dispc(struct dsi_data *dsi,
-	enum omap_channel channel);
-static void dsi_display_uninit_dispc(struct dsi_data *dsi,
-	enum omap_channel channel);
+static int dsi_display_init_dispc(struct dsi_data *dsi);
+static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
@@ -3847,7 +3845,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 		return -ENODEV;
 	}
 
-	r = dsi_display_init_dispc(dsi, dispc_channel);
+	r = dsi_display_init_dispc(dsi);
 	if (r)
 		goto err_init_dispc;
 
@@ -3897,7 +3895,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 		dsi_vc_enable(dsi, channel, false);
 	}
 err_pix_fmt:
-	dsi_display_uninit_dispc(dsi, dispc_channel);
+	dsi_display_uninit_dispc(dsi);
 err_init_dispc:
 	return r;
 }
@@ -3920,7 +3918,7 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 
 	dss_mgr_disable(dispc_channel);
 
-	dsi_display_uninit_dispc(dsi, dispc_channel);
+	dsi_display_uninit_dispc(dsi);
 }
 
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
@@ -4106,9 +4104,9 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
-static int dsi_display_init_dispc(struct dsi_data *dsi,
-				  enum omap_channel channel)
+static int dsi_display_init_dispc(struct dsi_data *dsi)
 {
+	enum omap_channel channel = dsi->output.dispc_channel;
 	int r;
 
 	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
@@ -4169,9 +4167,10 @@ static int dsi_display_init_dispc(struct dsi_data *dsi,
 	return r;
 }
 
-static void dsi_display_uninit_dispc(struct dsi_data *dsi,
-				     enum omap_channel channel)
+static void dsi_display_uninit_dispc(struct dsi_data *dsi)
 {
+	enum omap_channel channel = dsi->output.dispc_channel;
+
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
 		dss_mgr_unregister_framedone_handler(channel,
 				dsi_framedone_irq_callback, dsi);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (39 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:31   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes Laurent Pinchart
                   ` (10 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dss_mgr_*() functions take a channel argument to identify the
channel they operate on. This prevents the functions from accessing
driver data structures without resorting to global variables. In an
effort to remove global variables, pass the omap_dss_device pointer
associated with the channel instead. This will be used to look up the
omap_drm_private data structure to pass to the dss_mgr_ops.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dpi.c     | 32 ++++++++++----------------
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 30 +++++++++++--------------
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 20 +++++++----------
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 20 +++++++----------
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 22 +++++++++---------
 drivers/gpu/drm/omapdrm/dss/output.c  | 42 ++++++++++++++++++-----------------
 drivers/gpu/drm/omapdrm/dss/sdi.c     | 27 +++++++++-------------
 drivers/gpu/drm/omapdrm/dss/venc.c    | 18 ++++++---------
 8 files changed, 92 insertions(+), 119 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index b0f890a3c8db..3894e53ff58d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -344,8 +344,6 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
 
 static int dpi_set_mode(struct dpi_data *dpi)
 {
-	struct omap_dss_device *out = &dpi->output;
-	enum omap_channel channel = out->dispc_channel;
 	struct videomode *vm = &dpi->vm;
 	int lck_div = 0, pck_div = 0;
 	unsigned long fck = 0;
@@ -353,8 +351,8 @@ static int dpi_set_mode(struct dpi_data *dpi)
 	int r = 0;
 
 	if (dpi->pll)
-		r = dpi_set_pll_clk(dpi, channel, vm->pixelclock, &fck,
-				&lck_div, &pck_div);
+		r = dpi_set_pll_clk(dpi, dpi->output.dispc_channel,
+				    vm->pixelclock, &fck, &lck_div, &pck_div);
 	else
 		r = dpi_set_dispc_clk(dpi, vm->pixelclock, &fck,
 				&lck_div, &pck_div);
@@ -370,16 +368,13 @@ static int dpi_set_mode(struct dpi_data *dpi)
 		vm->pixelclock = pck;
 	}
 
-	dss_mgr_set_timings(channel, vm);
+	dss_mgr_set_timings(&dpi->output, vm);
 
 	return 0;
 }
 
 static void dpi_config_lcd_manager(struct dpi_data *dpi)
 {
-	struct omap_dss_device *out = &dpi->output;
-	enum omap_channel channel = out->dispc_channel;
-
 	dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
 	dpi->mgr_config.stallmode = false;
@@ -389,14 +384,13 @@ static void dpi_config_lcd_manager(struct dpi_data *dpi)
 
 	dpi->mgr_config.lcden_sig_polarity = 0;
 
-	dss_mgr_set_lcd_config(channel, &dpi->mgr_config);
+	dss_mgr_set_lcd_config(&dpi->output, &dpi->mgr_config);
 }
 
 static int dpi_display_enable(struct omap_dss_device *dssdev)
 {
 	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
 	struct omap_dss_device *out = &dpi->output;
-	enum omap_channel channel = out->dispc_channel;
 	int r;
 
 	mutex_lock(&dpi->lock);
@@ -417,7 +411,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_get_dispc;
 
-	r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
+	r = dss_dpi_select_source(dpi->dss, out->port_num, out->dispc_channel);
 	if (r)
 		goto err_src_sel;
 
@@ -435,7 +429,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 
 	mdelay(2);
 
-	r = dss_mgr_enable(channel);
+	r = dss_mgr_enable(&dpi->output);
 	if (r)
 		goto err_mgr_enable;
 
@@ -462,14 +456,14 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 static void dpi_display_disable(struct omap_dss_device *dssdev)
 {
 	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-	enum omap_channel channel = dpi->output.dispc_channel;
 
 	mutex_lock(&dpi->lock);
 
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&dpi->output);
 
 	if (dpi->pll) {
-		dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
+		dss_select_lcd_clk_source(dpi->dss, dpi->output.dispc_channel,
+					  DSS_CLK_SRC_FCK);
 		dss_pll_disable(dpi->pll);
 	}
 
@@ -659,7 +653,6 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-	enum omap_channel channel = dpi->output.dispc_channel;
 	int r;
 
 	r = dpi_init_regulator(dpi);
@@ -668,7 +661,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 
 	dpi_init_pll(dpi);
 
-	r = dss_mgr_connect(channel, dssdev);
+	r = dss_mgr_connect(&dpi->output, dssdev);
 	if (r)
 		return r;
 
@@ -676,7 +669,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dst->name);
-		dss_mgr_disconnect(channel, dssdev);
+		dss_mgr_disconnect(&dpi->output, dssdev);
 		return r;
 	}
 
@@ -687,7 +680,6 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-	enum omap_channel channel = dpi->output.dispc_channel;
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -696,7 +688,7 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(channel, dssdev);
+	dss_mgr_disconnect(&dpi->output, dssdev);
 }
 
 static const struct omapdss_dpi_ops dpi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d1cc036ed280..512625ed03e2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3833,7 +3833,6 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	enum omap_channel dispc_channel = dssdev->dispc_channel;
 	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
 	struct omap_dss_device *out = &dsi->output;
 	u8 data_type;
@@ -3883,7 +3882,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 		dsi_if_enable(dsi, true);
 	}
 
-	r = dss_mgr_enable(dispc_channel);
+	r = dss_mgr_enable(&dsi->output);
 	if (r)
 		goto err_mgr_enable;
 
@@ -3903,7 +3902,6 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	enum omap_channel dispc_channel = dssdev->dispc_channel;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		dsi_if_enable(dsi, false);
@@ -3916,14 +3914,13 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 		dsi_if_enable(dsi, true);
 	}
 
-	dss_mgr_disable(dispc_channel);
+	dss_mgr_disable(&dsi->output);
 
 	dsi_display_uninit_dispc(dsi);
 }
 
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
 {
-	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 	unsigned int bytespp;
 	unsigned int bytespl;
 	unsigned int bytespf;
@@ -3985,9 +3982,9 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 		msecs_to_jiffies(250));
 	BUG_ON(r == 0);
 
-	dss_mgr_set_timings(dispc_channel, &dsi->vm);
+	dss_mgr_set_timings(&dsi->output, &dsi->vm);
 
-	dss_mgr_start_update(dispc_channel);
+	dss_mgr_start_update(&dsi->output);
 
 	if (dsi->te_enabled) {
 		/* disable LP_RX_TO, so that we can receive TE.  Time to wait
@@ -4114,7 +4111,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 			DSS_CLK_SRC_PLL2_1);
 
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) {
-		r = dss_mgr_register_framedone_handler(channel,
+		r = dss_mgr_register_framedone_handler(&dsi->output,
 				dsi_framedone_irq_callback, dsi);
 		if (r) {
 			DSSERR("can't register FRAMEDONE handler\n");
@@ -4144,7 +4141,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 	dsi->vm.flags &= ~DISPLAY_FLAGS_SYNC_POSEDGE;
 	dsi->vm.flags |= DISPLAY_FLAGS_SYNC_NEGEDGE;
 
-	dss_mgr_set_timings(channel, &dsi->vm);
+	dss_mgr_set_timings(&dsi->output, &dsi->vm);
 
 	r = dsi_configure_dispc_clocks(dsi);
 	if (r)
@@ -4155,12 +4152,12 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 			dsi_get_pixel_size(dsi->pix_fmt);
 	dsi->mgr_config.lcden_sig_polarity = 0;
 
-	dss_mgr_set_lcd_config(channel, &dsi->mgr_config);
+	dss_mgr_set_lcd_config(&dsi->output, &dsi->mgr_config);
 
 	return 0;
 err1:
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
-		dss_mgr_unregister_framedone_handler(channel,
+		dss_mgr_unregister_framedone_handler(&dsi->output,
 				dsi_framedone_irq_callback, dsi);
 err:
 	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
@@ -4172,7 +4169,7 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi)
 	enum omap_channel channel = dsi->output.dispc_channel;
 
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
-		dss_mgr_unregister_framedone_handler(channel,
+		dss_mgr_unregister_framedone_handler(&dsi->output,
 				dsi_framedone_irq_callback, dsi);
 
 	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
@@ -4967,14 +4964,13 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	enum omap_channel dispc_channel = dssdev->dispc_channel;
 	int r;
 
 	r = dsi_regulator_init(dsi);
 	if (r)
 		return r;
 
-	r = dss_mgr_connect(dispc_channel, dssdev);
+	r = dss_mgr_connect(&dsi->output, dssdev);
 	if (r)
 		return r;
 
@@ -4982,7 +4978,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dssdev->name);
-		dss_mgr_disconnect(dispc_channel, dssdev);
+		dss_mgr_disconnect(&dsi->output, dssdev);
 		return r;
 	}
 
@@ -4992,7 +4988,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 static void dsi_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	enum omap_channel dispc_channel = dssdev->dispc_channel;
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -5001,7 +4997,7 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(dispc_channel, dssdev);
+	dss_mgr_disconnect(&dsi->output, dssdev);
 }
 
 static const struct omapdss_dsi_ops dsi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index f0a30b248a7d..56de3c75b0a0 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -174,7 +174,6 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
 	int r;
 	struct videomode *vm;
-	enum omap_channel channel = hdmi->output.dispc_channel;
 	struct hdmi_wp_data *wp = &hdmi->wp;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
 	unsigned int pc;
@@ -228,9 +227,9 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 	hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
 
 	/* tv size */
-	dss_mgr_set_timings(channel, vm);
+	dss_mgr_set_timings(&hdmi->output, vm);
 
-	r = dss_mgr_enable(channel);
+	r = dss_mgr_enable(&hdmi->output);
 	if (r)
 		goto err_mgr_enable;
 
@@ -244,7 +243,7 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 	return 0;
 
 err_vid_enable:
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&hdmi->output);
 err_mgr_enable:
 	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
@@ -258,13 +257,11 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 
 static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 {
-	enum omap_channel channel = hdmi->output.dispc_channel;
-
 	hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
 
 	hdmi_wp_video_stop(&hdmi->wp);
 
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&hdmi->output);
 
 	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 
@@ -459,14 +456,13 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
 	r = hdmi_init_regulator(hdmi);
 	if (r)
 		return r;
 
-	r = dss_mgr_connect(channel, dssdev);
+	r = dss_mgr_connect(&hdmi->output, dssdev);
 	if (r)
 		return r;
 
@@ -474,7 +470,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dst->name);
-		dss_mgr_disconnect(channel, dssdev);
+		dss_mgr_disconnect(&hdmi->output, dssdev);
 		return r;
 	}
 
@@ -484,7 +480,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 static void hdmi_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -493,7 +489,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(channel, dssdev);
+	dss_mgr_disconnect(&hdmi->output, dssdev);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index ed8a2bd2a035..1e839af800e7 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -172,7 +172,6 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
 	int r;
 	struct videomode *vm;
-	enum omap_channel channel = hdmi->output.dispc_channel;
 	struct dss_pll_clock_info hdmi_cinfo = { 0 };
 	unsigned int pc;
 
@@ -226,9 +225,9 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 	hdmi5_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
 
 	/* tv size */
-	dss_mgr_set_timings(channel, vm);
+	dss_mgr_set_timings(&hdmi->output, vm);
 
-	r = dss_mgr_enable(channel);
+	r = dss_mgr_enable(&hdmi->output);
 	if (r)
 		goto err_mgr_enable;
 
@@ -242,7 +241,7 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 	return 0;
 
 err_vid_enable:
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&hdmi->output);
 err_mgr_enable:
 	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
@@ -256,13 +255,11 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 
 static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 {
-	enum omap_channel channel = hdmi->output.dispc_channel;
-
 	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
 
 	hdmi_wp_video_stop(&hdmi->wp);
 
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&hdmi->output);
 
 	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
 
@@ -463,14 +460,13 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
 	r = hdmi_init_regulator(hdmi);
 	if (r)
 		return r;
 
-	r = dss_mgr_connect(channel, dssdev);
+	r = dss_mgr_connect(&hdmi->output, dssdev);
 	if (r)
 		return r;
 
@@ -478,7 +474,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dst->name);
-		dss_mgr_disconnect(channel, dssdev);
+		dss_mgr_disconnect(&hdmi->output, dssdev);
 		return r;
 	}
 
@@ -488,7 +484,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 static void hdmi_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -497,7 +493,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(channel, dssdev);
+	dss_mgr_disconnect(&hdmi->output, dssdev);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 6f9b9b2d8af2..8024680e8d57 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -656,20 +656,20 @@ struct dss_mgr_ops {
 int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
 void dss_uninstall_mgr_ops(void);
 
-int dss_mgr_connect(enum omap_channel channel,
-		struct omap_dss_device *dst);
-void dss_mgr_disconnect(enum omap_channel channel,
-		struct omap_dss_device *dst);
-void dss_mgr_set_timings(enum omap_channel channel,
+int dss_mgr_connect(struct omap_dss_device *dssdev,
+		    struct omap_dss_device *dst);
+void dss_mgr_disconnect(struct omap_dss_device *dssdev,
+			struct omap_dss_device *dst);
+void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 		const struct videomode *vm);
-void dss_mgr_set_lcd_config(enum omap_channel channel,
+void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 		const struct dss_lcd_mgr_config *config);
-int dss_mgr_enable(enum omap_channel channel);
-void dss_mgr_disable(enum omap_channel channel);
-void dss_mgr_start_update(enum omap_channel channel);
-int dss_mgr_register_framedone_handler(enum omap_channel channel,
+int dss_mgr_enable(struct omap_dss_device *dssdev);
+void dss_mgr_disable(struct omap_dss_device *dssdev);
+void dss_mgr_start_update(struct omap_dss_device *dssdev);
+int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data);
-void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
+void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data);
 
 /* dispc ops */
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index a84ab0337a91..0573b5099f8f 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -184,52 +184,54 @@ void dss_uninstall_mgr_ops(void)
 }
 EXPORT_SYMBOL(dss_uninstall_mgr_ops);
 
-int dss_mgr_connect(enum omap_channel channel,
-		struct omap_dss_device *dst)
+int dss_mgr_connect(struct omap_dss_device *dssdev, struct omap_dss_device *dst)
 {
-	return dss_mgr_ops->connect(channel, dst);
+	return dss_mgr_ops->connect(dssdev->dispc_channel, dst);
 }
 
-void dss_mgr_disconnect(enum omap_channel channel,
-		struct omap_dss_device *dst)
+void dss_mgr_disconnect(struct omap_dss_device *dssdev,
+			struct omap_dss_device *dst)
 {
-	dss_mgr_ops->disconnect(channel, dst);
+	dss_mgr_ops->disconnect(dssdev->dispc_channel, dst);
 }
 
-void dss_mgr_set_timings(enum omap_channel channel, const struct videomode *vm)
+void dss_mgr_set_timings(struct omap_dss_device *dssdev,
+			 const struct videomode *vm)
 {
-	dss_mgr_ops->set_timings(channel, vm);
+	dss_mgr_ops->set_timings(dssdev->dispc_channel, vm);
 }
 
-void dss_mgr_set_lcd_config(enum omap_channel channel,
+void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 		const struct dss_lcd_mgr_config *config)
 {
-	dss_mgr_ops->set_lcd_config(channel, config);
+	dss_mgr_ops->set_lcd_config(dssdev->dispc_channel, config);
 }
 
-int dss_mgr_enable(enum omap_channel channel)
+int dss_mgr_enable(struct omap_dss_device *dssdev)
 {
-	return dss_mgr_ops->enable(channel);
+	return dss_mgr_ops->enable(dssdev->dispc_channel);
 }
 
-void dss_mgr_disable(enum omap_channel channel)
+void dss_mgr_disable(struct omap_dss_device *dssdev)
 {
-	dss_mgr_ops->disable(channel);
+	dss_mgr_ops->disable(dssdev->dispc_channel);
 }
 
-void dss_mgr_start_update(enum omap_channel channel)
+void dss_mgr_start_update(struct omap_dss_device *dssdev)
 {
-	dss_mgr_ops->start_update(channel);
+	dss_mgr_ops->start_update(dssdev->dispc_channel);
 }
 
-int dss_mgr_register_framedone_handler(enum omap_channel channel,
+int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
 {
-	return dss_mgr_ops->register_framedone_handler(channel, handler, data);
+	return dss_mgr_ops->register_framedone_handler(dssdev->dispc_channel,
+						       handler, data);
 }
 
-void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
+void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
 {
-	dss_mgr_ops->unregister_framedone_handler(channel, handler, data);
+	dss_mgr_ops->unregister_framedone_handler(dssdev->dispc_channel,
+						  handler, data);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index a35dc51c5a6a..681a3653dd8c 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -115,8 +115,6 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
 
 static void sdi_config_lcd_manager(struct sdi_device *sdi)
 {
-	enum omap_channel channel = sdi->output.dispc_channel;
-
 	sdi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
 	sdi->mgr_config.stallmode = false;
@@ -125,21 +123,19 @@ static void sdi_config_lcd_manager(struct sdi_device *sdi)
 	sdi->mgr_config.video_port_width = 24;
 	sdi->mgr_config.lcden_sig_polarity = 1;
 
-	dss_mgr_set_lcd_config(channel, &sdi->mgr_config);
+	dss_mgr_set_lcd_config(&sdi->output, &sdi->mgr_config);
 }
 
 static int sdi_display_enable(struct omap_dss_device *dssdev)
 {
 	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
-	struct omap_dss_device *out = &sdi->output;
-	enum omap_channel channel = dssdev->dispc_channel;
 	struct videomode *vm = &sdi->vm;
 	unsigned long fck;
 	struct dispc_clock_info dispc_cinfo;
 	unsigned long pck;
 	int r;
 
-	if (!out->dispc_channel_connected) {
+	if (!sdi->output.dispc_channel_connected) {
 		DSSERR("failed to enable display: no output/manager\n");
 		return -ENODEV;
 	}
@@ -171,7 +167,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	}
 
 
-	dss_mgr_set_timings(channel, vm);
+	dss_mgr_set_timings(&sdi->output, vm);
 
 	r = dss_set_fck_rate(sdi->dss, fck);
 	if (r)
@@ -190,7 +186,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	 * need to care about the shadow register mechanism for pck-free. The
 	 * exact reason for this is unknown.
 	 */
-	dispc_mgr_set_clock_div(channel, &sdi->mgr_config.clock_info);
+	dispc_mgr_set_clock_div(sdi->output.dispc_channel,
+				&sdi->mgr_config.clock_info);
 
 	dss_sdi_init(sdi->dss, sdi->datapairs);
 	r = dss_sdi_enable(sdi->dss);
@@ -198,7 +195,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 		goto err_sdi_enable;
 	mdelay(2);
 
-	r = dss_mgr_enable(channel);
+	r = dss_mgr_enable(&sdi->output);
 	if (r)
 		goto err_mgr_enable;
 
@@ -219,9 +216,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 static void sdi_display_disable(struct omap_dss_device *dssdev)
 {
 	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
-	enum omap_channel channel = dssdev->dispc_channel;
 
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&sdi->output);
 
 	dss_sdi_disable(sdi->dss);
 
@@ -283,14 +279,13 @@ static int sdi_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
-	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
 	r = sdi_init_regulator(sdi);
 	if (r)
 		return r;
 
-	r = dss_mgr_connect(channel, dssdev);
+	r = dss_mgr_connect(&sdi->output, dssdev);
 	if (r)
 		return r;
 
@@ -298,7 +293,7 @@ static int sdi_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dst->name);
-		dss_mgr_disconnect(channel, dssdev);
+		dss_mgr_disconnect(&sdi->output, dssdev);
 		return r;
 	}
 
@@ -308,7 +303,7 @@ static int sdi_connect(struct omap_dss_device *dssdev,
 static void sdi_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -317,7 +312,7 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(channel, dssdev);
+	dss_mgr_disconnect(&sdi->output, dssdev);
 }
 
 static const struct omapdss_sdi_ops sdi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 7acdbfefe397..d82645e84db7 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -468,7 +468,6 @@ static const struct venc_config *venc_timings_to_config(struct videomode *vm)
 
 static int venc_power_on(struct venc_device *venc)
 {
-	enum omap_channel channel = venc->output.dispc_channel;
 	u32 l;
 	int r;
 
@@ -494,13 +493,13 @@ static int venc_power_on(struct venc_device *venc)
 
 	venc_write_reg(venc, VENC_OUTPUT_CONTROL, l);
 
-	dss_mgr_set_timings(channel, &venc->vm);
+	dss_mgr_set_timings(&venc->output, &venc->vm);
 
 	r = regulator_enable(venc->vdda_dac_reg);
 	if (r)
 		goto err1;
 
-	r = dss_mgr_enable(channel);
+	r = dss_mgr_enable(&venc->output);
 	if (r)
 		goto err2;
 
@@ -519,12 +518,10 @@ static int venc_power_on(struct venc_device *venc)
 
 static void venc_power_off(struct venc_device *venc)
 {
-	enum omap_channel channel = venc->output.dispc_channel;
-
 	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
 	dss_set_dac_pwrdn_bgz(venc->dss, 0);
 
-	dss_mgr_disable(channel);
+	dss_mgr_disable(&venc->output);
 
 	regulator_disable(venc->vdda_dac_reg);
 
@@ -768,14 +765,13 @@ static int venc_connect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
 	struct venc_device *venc = dssdev_to_venc(dssdev);
-	enum omap_channel channel = dssdev->dispc_channel;
 	int r;
 
 	r = venc_init_regulator(venc);
 	if (r)
 		return r;
 
-	r = dss_mgr_connect(channel, dssdev);
+	r = dss_mgr_connect(&venc->output, dssdev);
 	if (r)
 		return r;
 
@@ -783,7 +779,7 @@ static int venc_connect(struct omap_dss_device *dssdev,
 	if (r) {
 		DSSERR("failed to connect output to new device: %s\n",
 				dst->name);
-		dss_mgr_disconnect(channel, dssdev);
+		dss_mgr_disconnect(&venc->output, dssdev);
 		return r;
 	}
 
@@ -793,7 +789,7 @@ static int venc_connect(struct omap_dss_device *dssdev,
 static void venc_disconnect(struct omap_dss_device *dssdev,
 		struct omap_dss_device *dst)
 {
-	enum omap_channel channel = dssdev->dispc_channel;
+	struct venc_device *venc = dssdev_to_venc(dssdev);
 
 	WARN_ON(dst != dssdev->dst);
 
@@ -802,7 +798,7 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
 
 	omapdss_output_unset_device(dssdev);
 
-	dss_mgr_disconnect(channel, dssdev);
+	dss_mgr_disconnect(&venc->output, dssdev);
 }
 
 static const struct omapdss_atv_ops venc_ops = {
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (40 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 20:37   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
                   ` (9 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_dss_register_driver(), omap_dss_unregister_driver() and
dispc_enable_gamma_table() functions don't exist anymore, remove their
prototypes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.h     | 1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 6950f5d61b6c..5d6f8afca49d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -388,7 +388,6 @@ void dispc_disable_sidle(void);
 void dispc_lcd_enable_signal(bool enable);
 void dispc_pck_free_enable(bool enable);
 void dispc_enable_fifomerge(bool enable);
-void dispc_enable_gamma_table(bool enable);
 
 typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
 		unsigned long pck, void *data);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8024680e8d57..32c5944b0bea 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -583,9 +583,6 @@ struct omap_dss_driver {
 		const struct hdmi_avi_infoframe *avi);
 };
 
-int omap_dss_register_driver(struct omap_dss_driver *);
-void omap_dss_unregister_driver(struct omap_dss_driver *);
-
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (41 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 21:23   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
                   ` (8 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dss_mgr_ops operations implemented by the omapdrm side have to look
up the omap_crtc objects from global variables as they are only passed a
channel number. In order to remove global variables pass the
omap_drm_private pointer to the dss_mgr_ops. This requires storing a
pointer to the dss_device in the omap_dss_device structure to allow
looking up the omap_drm_private in the dss_mgr_*() functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dpi.c     |  1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c     |  1 +
 drivers/gpu/drm/omapdrm/dss/dss.c     | 37 ---------------------------------
 drivers/gpu/drm/omapdrm/dss/dss.h     | 37 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 39 ++++++++++++++++++++++-------------
 drivers/gpu/drm/omapdrm/dss/output.c  | 23 +++++++++++++--------
 drivers/gpu/drm/omapdrm/dss/sdi.c     |  1 +
 drivers/gpu/drm/omapdrm/dss/venc.c    |  1 +
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 27 ++++++++++++++----------
 11 files changed, 98 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 3894e53ff58d..ae43ba81eb96 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -727,6 +727,7 @@ static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
 	}
 
 	out->dev = &dpi->pdev->dev;
+	out->dss = dpi->dss;
 	out->id = OMAP_DSS_OUTPUT_DPI;
 	out->output_type = OMAP_DISPLAY_TYPE_DPI;
 	out->dispc_channel = dpi_get_channel(dpi, port_num);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 512625ed03e2..eafea72998dd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5044,6 +5044,7 @@ static void dsi_init_output(struct dsi_data *dsi)
 	struct omap_dss_device *out = &dsi->output;
 
 	out->dev = dsi->dev;
+	out->dss = dsi->dss;
 	out->id = dsi->module_id == 0 ?
 			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 8fec9bf6f06f..0e8c70591308 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -49,9 +49,6 @@
 
 #include "omapdss.h"
 #include "dss.h"
-#include "../omap_drv.h"
-
-#define DSS_SZ_REGS			SZ_512
 
 struct dss_reg {
 	u16 idx;
@@ -96,40 +93,6 @@ struct dss_features {
 	bool has_lcd_clk_src;
 };
 
-struct dss_device {
-	struct platform_device *pdev;
-	struct omap_drm_private drm;
-
-	void __iomem    *base;
-	struct regmap	*syscon_pll_ctrl;
-	u32		syscon_pll_ctrl_offset;
-
-	struct clk	*parent_clk;
-	struct clk	*dss_clk;
-	unsigned long	dss_clk_rate;
-
-	unsigned long	cache_req_pck;
-	unsigned long	cache_prate;
-	struct dispc_clock_info cache_dispc_cinfo;
-
-	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
-	enum dss_clk_source dispc_clk_source;
-	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
-
-	bool		ctx_valid;
-	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
-
-	const struct dss_features *feat;
-
-	struct {
-		struct dss_debugfs_entry *clk;
-		struct dss_debugfs_entry *dss;
-	} debugfs;
-
-	struct dss_pll	*video1_pll;
-	struct dss_pll	*video2_pll;
-};
-
 static const char * const dss_generic_clk_source_names[] = {
 	[DSS_CLK_SRC_FCK]	= "FCK",
 	[DSS_CLK_SRC_PLL1_1]	= "PLL1:1",
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 5d6f8afca49d..cda2cbd888f0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 
 #include "omapdss.h"
+#include "../omap_drv.h"
 
 struct dentry;
 struct dss_debugfs_entry;
@@ -241,6 +242,42 @@ struct dss_lcd_mgr_config {
 	int lcden_sig_polarity;
 };
 
+#define DSS_SZ_REGS			SZ_512
+
+struct dss_device {
+	struct platform_device *pdev;
+	struct omap_drm_private drm;
+
+	void __iomem    *base;
+	struct regmap	*syscon_pll_ctrl;
+	u32		syscon_pll_ctrl_offset;
+
+	struct clk	*parent_clk;
+	struct clk	*dss_clk;
+	unsigned long	dss_clk_rate;
+
+	unsigned long	cache_req_pck;
+	unsigned long	cache_prate;
+	struct dispc_clock_info cache_dispc_cinfo;
+
+	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
+	enum dss_clk_source dispc_clk_source;
+	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
+
+	bool		ctx_valid;
+	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
+
+	const struct dss_features *feat;
+
+	struct {
+		struct dss_debugfs_entry *clk;
+		struct dss_debugfs_entry *dss;
+	} debugfs;
+
+	struct dss_pll	*video1_pll;
+	struct dss_pll	*video2_pll;
+};
+
 /* core */
 static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 56de3c75b0a0..501813f03466 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -566,6 +566,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
 	struct omap_dss_device *out = &hdmi->output;
 
 	out->dev = &hdmi->pdev->dev;
+	out->dss = hdmi->dss;
 	out->id = OMAP_DSS_OUTPUT_HDMI;
 	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
 	out->name = "hdmi->0";
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 1e839af800e7..44954bdea6ce 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -558,6 +558,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
 	struct omap_dss_device *out = &hdmi->output;
 
 	out->dev = &hdmi->pdev->dev;
+	out->dss = hdmi->dss;
 	out->id = OMAP_DSS_OUTPUT_HDMI;
 	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
 	out->name = "hdmi->0";
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 32c5944b0bea..76ce94376454 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -59,6 +59,7 @@
 #define DISPC_IRQ_ACBIAS_COUNT_STAT3	(1 << 29)
 #define DISPC_IRQ_FRAMEDONE3		(1 << 30)
 
+struct omap_drm_private;
 struct omap_dss_device;
 struct dss_lcd_mgr_config;
 struct snd_aes_iec958;
@@ -471,6 +472,7 @@ struct omapdss_dsi_ops {
 struct omap_dss_device {
 	struct kobject kobj;
 	struct device *dev;
+	struct dss_device *dss; /* valid for DSS outputs only */
 
 	struct module *owner;
 
@@ -632,21 +634,30 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port);
 u32 dss_of_port_get_port_number(struct device_node *port);
 
 struct dss_mgr_ops {
-	int (*connect)(enum omap_channel channel,
-		struct omap_dss_device *dst);
-	void (*disconnect)(enum omap_channel channel,
-		struct omap_dss_device *dst);
-
-	void (*start_update)(enum omap_channel channel);
-	int (*enable)(enum omap_channel channel);
-	void (*disable)(enum omap_channel channel);
-	void (*set_timings)(enum omap_channel channel,
-			const struct videomode *vm);
-	void (*set_lcd_config)(enum omap_channel channel,
-			const struct dss_lcd_mgr_config *config);
-	int (*register_framedone_handler)(enum omap_channel channel,
+	int (*connect)(struct omap_drm_private *priv,
+		       enum omap_channel channel,
+		       struct omap_dss_device *dst);
+	void (*disconnect)(struct omap_drm_private *priv,
+			   enum omap_channel channel,
+			   struct omap_dss_device *dst);
+
+	void (*start_update)(struct omap_drm_private *priv,
+			     enum omap_channel channel);
+	int (*enable)(struct omap_drm_private *priv,
+		      enum omap_channel channel);
+	void (*disable)(struct omap_drm_private *priv,
+			enum omap_channel channel);
+	void (*set_timings)(struct omap_drm_private *priv,
+			    enum omap_channel channel,
+			    const struct videomode *vm);
+	void (*set_lcd_config)(struct omap_drm_private *priv,
+			       enum omap_channel channel,
+			       const struct dss_lcd_mgr_config *config);
+	int (*register_framedone_handler)(struct omap_drm_private *priv,
+			enum omap_channel channel,
 			void (*handler)(void *), void *data);
-	void (*unregister_framedone_handler)(enum omap_channel channel,
+	void (*unregister_framedone_handler)(struct omap_drm_private *priv,
+			enum omap_channel channel,
 			void (*handler)(void *), void *data);
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 0573b5099f8f..4a6ccad7e970 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -21,6 +21,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 
+#include "dss.h"
 #include "omapdss.h"
 
 static LIST_HEAD(output_list);
@@ -186,52 +187,56 @@ EXPORT_SYMBOL(dss_uninstall_mgr_ops);
 
 int dss_mgr_connect(struct omap_dss_device *dssdev, struct omap_dss_device *dst)
 {
-	return dss_mgr_ops->connect(dssdev->dispc_channel, dst);
+	return dss_mgr_ops->connect(&dssdev->dss->drm,
+				    dssdev->dispc_channel, dst);
 }
 
 void dss_mgr_disconnect(struct omap_dss_device *dssdev,
 			struct omap_dss_device *dst)
 {
-	dss_mgr_ops->disconnect(dssdev->dispc_channel, dst);
+	dss_mgr_ops->disconnect(&dssdev->dss->drm, dssdev->dispc_channel, dst);
 }
 
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 			 const struct videomode *vm)
 {
-	dss_mgr_ops->set_timings(dssdev->dispc_channel, vm);
+	dss_mgr_ops->set_timings(&dssdev->dss->drm, dssdev->dispc_channel, vm);
 }
 
 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 		const struct dss_lcd_mgr_config *config)
 {
-	dss_mgr_ops->set_lcd_config(dssdev->dispc_channel, config);
+	dss_mgr_ops->set_lcd_config(&dssdev->dss->drm,
+				    dssdev->dispc_channel, config);
 }
 
 int dss_mgr_enable(struct omap_dss_device *dssdev)
 {
-	return dss_mgr_ops->enable(dssdev->dispc_channel);
+	return dss_mgr_ops->enable(&dssdev->dss->drm, dssdev->dispc_channel);
 }
 
 void dss_mgr_disable(struct omap_dss_device *dssdev)
 {
-	dss_mgr_ops->disable(dssdev->dispc_channel);
+	dss_mgr_ops->disable(&dssdev->dss->drm, dssdev->dispc_channel);
 }
 
 void dss_mgr_start_update(struct omap_dss_device *dssdev)
 {
-	dss_mgr_ops->start_update(dssdev->dispc_channel);
+	dss_mgr_ops->start_update(&dssdev->dss->drm, dssdev->dispc_channel);
 }
 
 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
 {
-	return dss_mgr_ops->register_framedone_handler(dssdev->dispc_channel,
+	return dss_mgr_ops->register_framedone_handler(&dssdev->dss->drm,
+						       dssdev->dispc_channel,
 						       handler, data);
 }
 
 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
 {
-	dss_mgr_ops->unregister_framedone_handler(dssdev->dispc_channel,
+	dss_mgr_ops->unregister_framedone_handler(&dssdev->dss->drm,
+						  dssdev->dispc_channel,
 						  handler, data);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 681a3653dd8c..c41bf0d7dd18 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -332,6 +332,7 @@ static void sdi_init_output(struct sdi_device *sdi)
 	struct omap_dss_device *out = &sdi->output;
 
 	out->dev = &sdi->pdev->dev;
+	out->dss = sdi->dss;
 	out->id = OMAP_DSS_OUTPUT_SDI;
 	out->output_type = OMAP_DISPLAY_TYPE_SDI;
 	out->name = "sdi.0";
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index d82645e84db7..f120d2910d0d 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -821,6 +821,7 @@ static void venc_init_output(struct venc_device *venc)
 	struct omap_dss_device *out = &venc->output;
 
 	out->dev = &venc->pdev->dev;
+	out->dss = venc->dss;
 	out->id = OMAP_DSS_OUTPUT_VENC;
 	out->output_type = OMAP_DISPLAY_TYPE_VENC;
 	out->name = "venc.0";
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index f78eac4a8b34..90a61a8199b4 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -114,7 +114,8 @@ static struct omap_crtc *omap_crtcs[8];
 static struct omap_dss_device *omap_crtc_output[8];
 
 /* we can probably ignore these until we support command-mode panels: */
-static int omap_crtc_dss_connect(enum omap_channel channel,
+static int omap_crtc_dss_connect(struct omap_drm_private *priv,
+		enum omap_channel channel,
 		struct omap_dss_device *dst)
 {
 	const struct dispc_ops *dispc_ops = dispc_get_ops();
@@ -131,14 +132,16 @@ static int omap_crtc_dss_connect(enum omap_channel channel,
 	return 0;
 }
 
-static void omap_crtc_dss_disconnect(enum omap_channel channel,
+static void omap_crtc_dss_disconnect(struct omap_drm_private *priv,
+		enum omap_channel channel,
 		struct omap_dss_device *dst)
 {
 	omap_crtc_output[channel] = NULL;
 	dst->dispc_channel_connected = false;
 }
 
-static void omap_crtc_dss_start_update(enum omap_channel channel)
+static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
+				       enum omap_channel channel)
 {
 }
 
@@ -208,10 +211,10 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 }
 
 
-static int omap_crtc_dss_enable(enum omap_channel channel)
+static int omap_crtc_dss_enable(struct omap_drm_private *priv,
+				enum omap_channel channel)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
-	struct omap_drm_private *priv = omap_crtc->base.dev->dev_private;
 
 	priv->dispc_ops->mgr_set_timings(omap_crtc->channel, &omap_crtc->vm);
 	omap_crtc_set_enabled(&omap_crtc->base, true);
@@ -219,14 +222,16 @@ static int omap_crtc_dss_enable(enum omap_channel channel)
 	return 0;
 }
 
-static void omap_crtc_dss_disable(enum omap_channel channel)
+static void omap_crtc_dss_disable(struct omap_drm_private *priv,
+				  enum omap_channel channel)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
 
 	omap_crtc_set_enabled(&omap_crtc->base, false);
 }
 
-static void omap_crtc_dss_set_timings(enum omap_channel channel,
+static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
+		enum omap_channel channel,
 		const struct videomode *vm)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
@@ -234,25 +239,25 @@ static void omap_crtc_dss_set_timings(enum omap_channel channel,
 	omap_crtc->vm = *vm;
 }
 
-static void omap_crtc_dss_set_lcd_config(enum omap_channel channel,
+static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
+		enum omap_channel channel,
 		const struct dss_lcd_mgr_config *config)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
-	struct omap_drm_private *priv = omap_crtc->base.dev->dev_private;
 
 	DBG("%s", omap_crtc->name);
 	priv->dispc_ops->mgr_set_lcd_config(omap_crtc->channel, config);
 }
 
 static int omap_crtc_dss_register_framedone(
-		enum omap_channel channel,
+		struct omap_drm_private *priv, enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
 	return 0;
 }
 
 static void omap_crtc_dss_unregister_framedone(
-		enum omap_channel channel,
+		struct omap_drm_private *priv, enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (42 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 21:23   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
                   ` (7 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DISPC private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DISPC private data dynamically).

In order to allow the omapdrm side to call the dispc_ops with a DISPC
pointer, we also introduce a new function dss_get_dispc() to retrieve
the DISPC corresponding to the DSS.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 221 +++++++++++++++++++---------------
 drivers/gpu/drm/omapdrm/dss/dpi.c     |   6 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c     |   4 +-
 drivers/gpu/drm/omapdrm/dss/dss.c     |   7 +-
 drivers/gpu/drm/omapdrm/dss/dss.h     |   7 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |   7 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |   7 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  91 ++++++++------
 drivers/gpu/drm/omapdrm/dss/sdi.c     |   6 +-
 drivers/gpu/drm/omapdrm/dss/venc.c    |   4 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  31 +++--
 drivers/gpu/drm/omapdrm/omap_drv.c    |  18 +--
 drivers/gpu/drm/omapdrm/omap_drv.h    |   5 +-
 drivers/gpu/drm/omapdrm/omap_irq.c    |  32 ++---
 drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +-
 15 files changed, 261 insertions(+), 197 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 912957c471ce..1bca5785b8a8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -164,7 +164,7 @@ struct dispc_features {
 #define DISPC_MAX_NR_FIFOS 5
 #define DISPC_MAX_CHANNEL_GAMMA 4
 
-static struct {
+struct dispc_device {
 	struct platform_device *pdev;
 	void __iomem    *base;
 	struct dss_device *dss;
@@ -196,7 +196,9 @@ static struct {
 
 	/* DISPC_CONTROL & DISPC_CONFIG lock*/
 	spinlock_t control_lock;
-} dispc;
+};
+
+static struct dispc_device dispc;
 
 enum omap_color_component {
 	/* used for all color formats for OMAP3 and earlier
@@ -363,9 +365,7 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
 static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane);
 static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane);
 
-static void dispc_clear_irqstatus(u32 mask);
-static bool dispc_mgr_is_enabled(enum omap_channel channel);
-static void dispc_clear_irqstatus(u32 mask);
+static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
 
 static inline void dispc_write_reg(const u16 idx, u32 val)
 {
@@ -398,14 +398,14 @@ static void mgr_fld_write(enum omap_channel channel,
 		spin_unlock_irqrestore(&dispc.control_lock, flags);
 }
 
-static int dispc_get_num_ovls(void)
+static int dispc_get_num_ovls(struct dispc_device *dispc)
 {
-	return dispc.feat->num_ovls;
+	return dispc->feat->num_ovls;
 }
 
-static int dispc_get_num_mgrs(void)
+static int dispc_get_num_mgrs(struct dispc_device *dispc)
 {
-	return dispc.feat->num_mgrs;
+	return dispc->feat->num_mgrs;
 }
 
 static void dispc_get_reg_field(enum dispc_feat_reg_field id,
@@ -457,7 +457,7 @@ static void dispc_save_context(void)
 		SR(CONFIG3);
 	}
 
-	for (i = 0; i < dispc_get_num_mgrs(); i++) {
+	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
 		SR(DEFAULT_COLOR(i));
 		SR(TRANS_COLOR(i));
 		SR(SIZE_MGR(i));
@@ -479,7 +479,7 @@ static void dispc_save_context(void)
 		}
 	}
 
-	for (i = 0; i < dispc_get_num_ovls(); i++) {
+	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
 		SR(OVL_BA0(i));
 		SR(OVL_BA1(i));
 		SR(OVL_POSITION(i));
@@ -563,7 +563,7 @@ static void dispc_restore_context(void)
 	if (dispc_has_feature(FEAT_MGR_LCD3))
 		RR(CONFIG3);
 
-	for (i = 0; i < dispc_get_num_mgrs(); i++) {
+	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
 		RR(DEFAULT_COLOR(i));
 		RR(TRANS_COLOR(i));
 		RR(SIZE_MGR(i));
@@ -585,7 +585,7 @@ static void dispc_restore_context(void)
 		}
 	}
 
-	for (i = 0; i < dispc_get_num_ovls(); i++) {
+	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
 		RR(OVL_BA0(i));
 		RR(OVL_BA1(i));
 		RR(OVL_POSITION(i));
@@ -650,7 +650,7 @@ static void dispc_restore_context(void)
 	if (dispc_has_feature(FEAT_MGR_LCD3))
 		RR(CONTROL3);
 	/* clear spurious SYNC_LOST_DIGIT interrupts */
-	dispc_clear_irqstatus(DISPC_IRQ_SYNC_LOST_DIGIT);
+	dispc_clear_irqstatus(&dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
 
 	/*
 	 * enable last so IRQs won't trigger before
@@ -664,41 +664,44 @@ static void dispc_restore_context(void)
 #undef SR
 #undef RR
 
-int dispc_runtime_get(void)
+int dispc_runtime_get(struct dispc_device *dispc)
 {
 	int r;
 
 	DSSDBG("dispc_runtime_get\n");
 
-	r = pm_runtime_get_sync(&dispc.pdev->dev);
+	r = pm_runtime_get_sync(&dispc->pdev->dev);
 	WARN_ON(r < 0);
 	return r < 0 ? r : 0;
 }
 
-void dispc_runtime_put(void)
+void dispc_runtime_put(struct dispc_device *dispc)
 {
 	int r;
 
 	DSSDBG("dispc_runtime_put\n");
 
-	r = pm_runtime_put_sync(&dispc.pdev->dev);
+	r = pm_runtime_put_sync(&dispc->pdev->dev);
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
-static u32 dispc_mgr_get_vsync_irq(enum omap_channel channel)
+static u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
+				   enum omap_channel channel)
 {
 	return mgr_desc[channel].vsync_irq;
 }
 
-static u32 dispc_mgr_get_framedone_irq(enum omap_channel channel)
+static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
+				       enum omap_channel channel)
 {
-	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc.feat->no_framedone_tv)
+	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
 		return 0;
 
 	return mgr_desc[channel].framedone_irq;
 }
 
-static u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel)
+static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
+				       enum omap_channel channel)
 {
 	return mgr_desc[channel].sync_lost_irq;
 }
@@ -708,27 +711,30 @@ u32 dispc_wb_get_framedone_irq(void)
 	return DISPC_IRQ_FRAMEDONEWB;
 }
 
-static void dispc_mgr_enable(enum omap_channel channel, bool enable)
+static void dispc_mgr_enable(struct dispc_device *dispc,
+			     enum omap_channel channel, bool enable)
 {
 	mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable);
 	/* flush posted write */
 	mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
 }
 
-static bool dispc_mgr_is_enabled(enum omap_channel channel)
+static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
+				 enum omap_channel channel)
 {
 	return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
 }
 
-static bool dispc_mgr_go_busy(enum omap_channel channel)
+static bool dispc_mgr_go_busy(struct dispc_device *dispc,
+			      enum omap_channel channel)
 {
 	return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1;
 }
 
-static void dispc_mgr_go(enum omap_channel channel)
+static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 {
-	WARN_ON(!dispc_mgr_is_enabled(channel));
-	WARN_ON(dispc_mgr_go_busy(channel));
+	WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
+	WARN_ON(dispc_mgr_go_busy(dispc, channel));
 
 	DSSDBG("GO %s\n", mgr_desc[channel].name);
 
@@ -866,7 +872,7 @@ static void dispc_ovl_write_color_conv_coef(enum omap_plane_id plane,
 static void dispc_setup_color_conv_coef(void)
 {
 	int i;
-	int num_ovl = dispc_get_num_ovls();
+	int num_ovl = dispc_get_num_ovls(&dispc);
 	const struct color_conv_coef ctbl_bt601_5_ovl = {
 		/* YUV -> RGB */
 		298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
@@ -958,7 +964,7 @@ static void dispc_ovl_enable_zorder_planes(void)
 	if (!dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
 		return;
 
-	for (i = 0; i < dispc_get_num_ovls(); i++)
+	for (i = 0; i < dispc_get_num_ovls(&dispc); i++)
 		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
 }
 
@@ -1215,7 +1221,7 @@ static void dispc_configure_burst_sizes(void)
 	const int burst_size = BURST_SIZE_X8;
 
 	/* Configure burst size always to maximum size */
-	for (i = 0; i < dispc_get_num_ovls(); ++i)
+	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
 		dispc_ovl_set_burst_size(i, burst_size);
 	if (dispc.feat->has_writeback)
 		dispc_ovl_set_burst_size(OMAP_DSS_WB, burst_size);
@@ -1242,9 +1248,10 @@ static bool dispc_ovl_color_mode_supported(enum omap_plane_id plane, u32 fourcc)
 	return false;
 }
 
-static const u32 *dispc_ovl_get_color_modes(enum omap_plane_id plane)
+static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
+					    enum omap_plane_id plane)
 {
-	return dispc.feat->supported_color_modes[plane];
+	return dispc->feat->supported_color_modes[plane];
 }
 
 static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable)
@@ -1361,7 +1368,7 @@ static void dispc_init_fifos(void)
 	/*
 	 * Setup default fifo thresholds.
 	 */
-	for (i = 0; i < dispc_get_num_ovls(); ++i) {
+	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
 		u32 low, high;
 		const bool use_fifomerge = false;
 		const bool manual_update = false;
@@ -1464,7 +1471,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
 
 	if (use_fifomerge) {
 		total_fifo_size = 0;
-		for (i = 0; i < dispc_get_num_ovls(); ++i)
+		for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
 			total_fifo_size += dispc_ovl_get_fifo_size(i);
 	} else {
 		total_fifo_size = ovl_fifo_size;
@@ -1530,7 +1537,7 @@ static void dispc_init_mflag(void)
 		(1 << 0) |	/* MFLAG_CTRL = force always on */
 		(0 << 2));	/* MFLAG_START = disable */
 
-	for (i = 0; i < dispc_get_num_ovls(); ++i) {
+	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
 		u32 size = dispc_ovl_get_fifo_size(i);
 		u32 unit = dispc.feat->buffer_size_unit;
 		u32 low, high;
@@ -2633,13 +2640,14 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
 	return 0;
 }
 
-static int dispc_ovl_setup(enum omap_plane_id plane,
-		const struct omap_overlay_info *oi,
-		const struct videomode *vm, bool mem_to_mem,
-		enum omap_channel channel)
+static int dispc_ovl_setup(struct dispc_device *dispc,
+			   enum omap_plane_id plane,
+			   const struct omap_overlay_info *oi,
+			   const struct videomode *vm, bool mem_to_mem,
+			   enum omap_channel channel)
 {
 	int r;
-	enum omap_overlay_caps caps = dispc.feat->overlay_caps[plane];
+	enum omap_overlay_caps caps = dispc->feat->overlay_caps[plane];
 	const bool replication = true;
 
 	DSSDBG("dispc_ovl_setup %d, pa %pad, pa_uv %pad, sw %d, %d,%d, %dx%d ->"
@@ -2726,7 +2734,8 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
 	return r;
 }
 
-static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
+static int dispc_ovl_enable(struct dispc_device *dispc,
+			    enum omap_plane_id plane, bool enable)
 {
 	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
 
@@ -2735,9 +2744,11 @@ static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
 	return 0;
 }
 
-static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel)
+static enum omap_dss_output_id
+dispc_mgr_get_supported_outputs(struct dispc_device *dispc,
+				enum omap_channel channel)
 {
-	return dss_get_supported_outputs(dispc.dss, channel);
+	return dss_get_supported_outputs(dispc->dss, channel);
 }
 
 static void dispc_lcd_enable_signal_polarity(bool act_high)
@@ -2812,8 +2823,9 @@ static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch,
 		REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
 }
 
-static void dispc_mgr_setup(enum omap_channel channel,
-		const struct omap_overlay_manager_info *info)
+static void dispc_mgr_setup(struct dispc_device *dispc,
+			    enum omap_channel channel,
+			    const struct omap_overlay_manager_info *info)
 {
 	dispc_mgr_set_default_color(channel, info->default_color);
 	dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key);
@@ -2885,8 +2897,9 @@ static void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable)
 	mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable);
 }
 
-static void dispc_mgr_set_lcd_config(enum omap_channel channel,
-		const struct dss_lcd_mgr_config *config)
+static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
+				     enum omap_channel channel,
+				     const struct dss_lcd_mgr_config *config)
 {
 	dispc_mgr_set_io_pad_mode(config->io_pad_mode);
 
@@ -3041,8 +3054,9 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
 }
 
 /* change name to mode? */
-static void dispc_mgr_set_timings(enum omap_channel channel,
-			   const struct videomode *vm)
+static void dispc_mgr_set_timings(struct dispc_device *dispc,
+				  enum omap_channel channel,
+				  const struct videomode *vm)
 {
 	unsigned int xtot, ytot;
 	unsigned long ht, vt;
@@ -3080,7 +3094,7 @@ static void dispc_mgr_set_timings(enum omap_channel channel,
 		if (t.flags & DISPLAY_FLAGS_INTERLACED)
 			t.vactive /= 2;
 
-		if (dispc.feat->supports_double_pixel)
+		if (dispc->feat->supports_double_pixel)
 			REG_FLD_MOD(DISPC_CONTROL,
 				    !!(t.flags & DISPLAY_FLAGS_DOUBLECLK),
 				    19, 17);
@@ -3243,7 +3257,7 @@ void dispc_dump_clocks(struct seq_file *s)
 	u32 l;
 	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
 
-	if (dispc_runtime_get())
+	if (dispc_runtime_get(&dispc))
 		return;
 
 	seq_printf(s, "- DISPC -\n");
@@ -3269,7 +3283,7 @@ void dispc_dump_clocks(struct seq_file *s)
 	if (dispc_has_feature(FEAT_MGR_LCD3))
 		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
 
-	dispc_runtime_put();
+	dispc_runtime_put(&dispc);
 }
 
 static int dispc_dump_regs(struct seq_file *s, void *p)
@@ -3292,7 +3306,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 
 #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
 
-	if (dispc_runtime_get())
+	if (dispc_runtime_get(&dispc))
 		return 0;
 
 	/* DISPC common registers */
@@ -3330,7 +3344,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 	p_names = mgr_names;
 
 	/* DISPC channel specific registers */
-	for (i = 0; i < dispc_get_num_mgrs(); i++) {
+	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
 		DUMPREG(i, DISPC_DEFAULT_COLOR);
 		DUMPREG(i, DISPC_TRANS_COLOR);
 		DUMPREG(i, DISPC_SIZE_MGR);
@@ -3356,7 +3370,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 
 	p_names = ovl_names;
 
-	for (i = 0; i < dispc_get_num_ovls(); i++) {
+	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
 		DUMPREG(i, DISPC_OVL_BA0);
 		DUMPREG(i, DISPC_OVL_BA1);
 		DUMPREG(i, DISPC_OVL_POSITION);
@@ -3434,7 +3448,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 	/* Video pipeline coefficient registers */
 
 	/* start from OMAP_DSS_VIDEO1 */
-	for (i = 1; i < dispc_get_num_ovls(); i++) {
+	for (i = 1; i < dispc_get_num_ovls(&dispc); i++) {
 		for (j = 0; j < 8; j++)
 			DUMPREG(i, DISPC_OVL_FIR_COEF_H, j);
 
@@ -3461,7 +3475,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 		}
 	}
 
-	dispc_runtime_put();
+	dispc_runtime_put(&dispc);
 
 #undef DISPC_REG
 #undef DUMPREG
@@ -3569,22 +3583,22 @@ int dispc_mgr_get_clock_div(enum omap_channel channel,
 	return 0;
 }
 
-static u32 dispc_read_irqstatus(void)
+static u32 dispc_read_irqstatus(struct dispc_device *dispc)
 {
 	return dispc_read_reg(DISPC_IRQSTATUS);
 }
 
-static void dispc_clear_irqstatus(u32 mask)
+static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
 {
 	dispc_write_reg(DISPC_IRQSTATUS, mask);
 }
 
-static void dispc_write_irqenable(u32 mask)
+static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
 {
 	u32 old_mask = dispc_read_reg(DISPC_IRQENABLE);
 
 	/* clear the irqstatus for newly enabled irqs */
-	dispc_clear_irqstatus((mask ^ old_mask) & mask);
+	dispc_clear_irqstatus(dispc, (mask ^ old_mask) & mask);
 
 	dispc_write_reg(DISPC_IRQENABLE, mask);
 
@@ -3602,11 +3616,12 @@ void dispc_disable_sidle(void)
 	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
 }
 
-static u32 dispc_mgr_gamma_size(enum omap_channel channel)
+static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
+				enum omap_channel channel)
 {
 	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
 
-	if (!dispc.feat->has_gamma_table)
+	if (!dispc->feat->has_gamma_table)
 		return 0;
 
 	return gdesc->len;
@@ -3655,18 +3670,19 @@ static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
 	{ .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, },
 };
 
-static void dispc_mgr_set_gamma(enum omap_channel channel,
-			 const struct drm_color_lut *lut,
-			 unsigned int length)
+static void dispc_mgr_set_gamma(struct dispc_device *dispc,
+				enum omap_channel channel,
+				const struct drm_color_lut *lut,
+				unsigned int length)
 {
 	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
-	u32 *table = dispc.gamma_table[channel];
+	u32 *table = dispc->gamma_table[channel];
 	uint i;
 
 	DSSDBG("%s: channel %d, lut len %u, hw len %u\n", __func__,
 	       channel, length, gdesc->len);
 
-	if (!dispc.feat->has_gamma_table)
+	if (!dispc->feat->has_gamma_table)
 		return;
 
 	if (lut == NULL || length < 2) {
@@ -3698,7 +3714,7 @@ static void dispc_mgr_set_gamma(enum omap_channel channel,
 		}
 	}
 
-	if (dispc.is_enabled)
+	if (dispc->is_enabled)
 		dispc_mgr_write_gamma_table(channel);
 }
 
@@ -3728,7 +3744,7 @@ static int dispc_init_gamma_tables(void)
 
 		dispc.gamma_table[channel] = gt;
 
-		dispc_mgr_set_gamma(channel, NULL, 0);
+		dispc_mgr_set_gamma(&dispc, channel, NULL, 0);
 	}
 	return 0;
 }
@@ -4298,35 +4314,36 @@ static irqreturn_t dispc_irq_handler(int irq, void *arg)
 	return dispc.user_handler(irq, dispc.user_data);
 }
 
-static int dispc_request_irq(irq_handler_t handler, void *dev_id)
+static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
+			     void *dev_id)
 {
 	int r;
 
-	if (dispc.user_handler != NULL)
+	if (dispc->user_handler != NULL)
 		return -EBUSY;
 
-	dispc.user_handler = handler;
-	dispc.user_data = dev_id;
+	dispc->user_handler = handler;
+	dispc->user_data = dev_id;
 
 	/* ensure the dispc_irq_handler sees the values above */
 	smp_wmb();
 
-	r = devm_request_irq(&dispc.pdev->dev, dispc.irq, dispc_irq_handler,
-			     IRQF_SHARED, "OMAP DISPC", &dispc);
+	r = devm_request_irq(&dispc->pdev->dev, dispc->irq, dispc_irq_handler,
+			     IRQF_SHARED, "OMAP DISPC", dispc);
 	if (r) {
-		dispc.user_handler = NULL;
-		dispc.user_data = NULL;
+		dispc->user_handler = NULL;
+		dispc->user_data = NULL;
 	}
 
 	return r;
 }
 
-static void dispc_free_irq(void *dev_id)
+static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
 {
-	devm_free_irq(&dispc.pdev->dev, dispc.irq, &dispc);
+	devm_free_irq(&dispc->pdev->dev, dispc->irq, dispc);
 
-	dispc.user_handler = NULL;
-	dispc.user_data = NULL;
+	dispc->user_handler = NULL;
+	dispc->user_data = NULL;
 }
 
 /*
@@ -4430,7 +4447,8 @@ static void dispc_errata_i734_wa_fini(void)
 
 static void dispc_errata_i734_wa(void)
 {
-	u32 framedone_irq = dispc_mgr_get_framedone_irq(OMAP_DSS_CHANNEL_LCD);
+	u32 framedone_irq = dispc_mgr_get_framedone_irq(&dispc,
+							OMAP_DSS_CHANNEL_LCD);
 	struct omap_overlay_info ovli;
 	struct dss_lcd_mgr_config lcd_conf;
 	u32 gatestate;
@@ -4449,39 +4467,39 @@ static void dispc_errata_i734_wa(void)
 	REG_FLD_MOD(DISPC_CONFIG, 0x1f, 8, 4);
 
 	/* Setup and enable GFX plane */
-	dispc_ovl_setup(OMAP_DSS_GFX, &ovli, &i734.vm, false,
-		OMAP_DSS_CHANNEL_LCD);
-	dispc_ovl_enable(OMAP_DSS_GFX, true);
+	dispc_ovl_setup(&dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
+			OMAP_DSS_CHANNEL_LCD);
+	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, true);
 
 	/* Set up and enable display manager for LCD1 */
-	dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, &i734.mgri);
+	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
 	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
 			       &lcd_conf.clock_info);
-	dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, &lcd_conf);
-	dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, &i734.vm);
+	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
+	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
 
-	dispc_clear_irqstatus(framedone_irq);
+	dispc_clear_irqstatus(&dispc, framedone_irq);
 
 	/* Enable and shut the channel to produce just one frame */
-	dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, true);
-	dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, false);
+	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, true);
+	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, false);
 
 	/* Busy wait for framedone. We can't fiddle with irq handlers
 	 * in PM resume. Typically the loop runs less than 5 times and
 	 * waits less than a micro second.
 	 */
 	count = 0;
-	while (!(dispc_read_irqstatus() & framedone_irq)) {
+	while (!(dispc_read_irqstatus(&dispc) & framedone_irq)) {
 		if (count++ > 10000) {
 			dev_err(&dispc.pdev->dev, "%s: framedone timeout\n",
 				__func__);
 			break;
 		}
 	}
-	dispc_ovl_enable(OMAP_DSS_GFX, false);
+	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, false);
 
 	/* Clear all irq bits before continuing */
-	dispc_clear_irqstatus(0xffffffff);
+	dispc_clear_irqstatus(&dispc, 0xffffffff);
 
 	/* Restore the original state to LCD1 output gates */
 	REG_FLD_MOD(DISPC_CONFIG, gatestate, 8, 4);
@@ -4599,7 +4617,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 
 	pm_runtime_enable(&pdev->dev);
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(&dispc);
 	if (r)
 		goto err_runtime_get;
 
@@ -4609,9 +4627,10 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
 	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
-	dispc_runtime_put();
+	dispc_runtime_put(&dispc);
 
 	dispc_set_ops(&dispc_ops);
+	dss->dispc = &dispc;
 
 	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
 						&dispc);
@@ -4623,12 +4642,14 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	return r;
 }
 
-static void dispc_unbind(struct device *dev, struct device *master,
-			       void *data)
+static void dispc_unbind(struct device *dev, struct device *master, void *data)
 {
+	struct dss_device *dss = dispc.dss;
+
 	dss_debugfs_remove_file(dispc.debugfs);
 
 	dispc_set_ops(NULL);
+	dss->dispc = NULL;
 
 	pm_runtime_disable(dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index ae43ba81eb96..aa10db453fd0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -407,7 +407,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 			goto err_reg_enable;
 	}
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(dpi->dss->dispc);
 	if (r)
 		goto err_get_dispc;
 
@@ -443,7 +443,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 		dss_pll_disable(dpi->pll);
 err_pll_init:
 err_src_sel:
-	dispc_runtime_put();
+	dispc_runtime_put(dpi->dss->dispc);
 err_get_dispc:
 	if (dpi->vdds_dsi_reg)
 		regulator_disable(dpi->vdds_dsi_reg);
@@ -467,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
 		dss_pll_disable(dpi->pll);
 	}
 
-	dispc_runtime_put();
+	dispc_runtime_put(dpi->dss->dispc);
 
 	if (dpi->vdds_dsi_reg)
 		regulator_disable(dpi->vdds_dsi_reg);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index eafea72998dd..1cac221e499a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5529,7 +5529,7 @@ static int dsi_runtime_suspend(struct device *dev)
 	/* wait for current handler to finish before turning the DSI off */
 	synchronize_irq(dsi->irq);
 
-	dispc_runtime_put();
+	dispc_runtime_put(dsi->dss->dispc);
 
 	return 0;
 }
@@ -5539,7 +5539,7 @@ static int dsi_runtime_resume(struct device *dev)
 	struct dsi_data *dsi = dev_get_drvdata(dev);
 	int r;
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(dsi->dss->dispc);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 0e8c70591308..fcdd7d00caa8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -887,6 +887,11 @@ struct dss_device *dss_get_device(struct device *dev)
 	return dev_get_drvdata(dev);
 }
 
+struct dispc_device *dss_get_dispc(struct dss_device *dss)
+{
+	return dss->dispc;
+}
+
 /* DEBUGFS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
 static int dss_debug_dump_clocks(struct seq_file *s, void *p)
@@ -1385,7 +1390,7 @@ static int dss_bind(struct device *dev)
 
 	omapdss_gather_components(dev);
 
-	r = omapdrm_init(&dss->drm, dev);
+	r = omapdrm_init(dss, &dss->drm, dev);
 	if (r)
 		goto err_drm_init;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index cda2cbd888f0..5f3e26bec402 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -29,6 +29,7 @@
 #include "../omap_drv.h"
 
 struct dentry;
+struct dispc_device;
 struct dss_debugfs_entry;
 struct dss_device;
 struct platform_device;
@@ -276,6 +277,8 @@ struct dss_device {
 
 	struct dss_pll	*video1_pll;
 	struct dss_pll	*video2_pll;
+
+	struct dispc_device *dispc;
 };
 
 /* core */
@@ -416,8 +419,8 @@ int dispc_init_platform_driver(void) __init;
 void dispc_uninit_platform_driver(void);
 void dispc_dump_clocks(struct seq_file *s);
 
-int dispc_runtime_get(void);
-void dispc_runtime_put(void);
+int dispc_runtime_get(struct dispc_device *dispc);
+void dispc_runtime_put(struct dispc_device *dispc);
 
 void dispc_enable_sidle(void);
 void dispc_disable_sidle(void);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 501813f03466..cf4b2c9bbcbd 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -847,16 +847,19 @@ static int hdmi4_remove(struct platform_device *pdev)
 
 static int hdmi_runtime_suspend(struct device *dev)
 {
-	dispc_runtime_put();
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+	dispc_runtime_put(hdmi->dss->dispc);
 
 	return 0;
 }
 
 static int hdmi_runtime_resume(struct device *dev)
 {
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
 	int r;
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(hdmi->dss->dispc);
 	if (r < 0)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 44954bdea6ce..66b603c5b2fc 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -839,16 +839,19 @@ static int hdmi5_remove(struct platform_device *pdev)
 
 static int hdmi_runtime_suspend(struct device *dev)
 {
-	dispc_runtime_put();
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+	dispc_runtime_put(hdmi->dss->dispc);
 
 	return 0;
 }
 
 static int hdmi_runtime_resume(struct device *dev)
 {
+	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
 	int r;
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(hdmi->dss->dispc);
 	if (r < 0)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 76ce94376454..9ebd695de075 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -61,6 +61,8 @@
 
 struct omap_drm_private;
 struct omap_dss_device;
+struct dispc_device;
+struct dss_device;
 struct dss_lcd_mgr_config;
 struct snd_aes_iec958;
 struct snd_cea_861_aud_if;
@@ -683,49 +685,64 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 /* dispc ops */
 
 struct dispc_ops {
-	u32 (*read_irqstatus)(void);
-	void (*clear_irqstatus)(u32 mask);
-	void (*write_irqenable)(u32 mask);
-
-	int (*request_irq)(irq_handler_t handler, void *dev_id);
-	void (*free_irq)(void *dev_id);
-
-	int (*runtime_get)(void);
-	void (*runtime_put)(void);
-
-	int (*get_num_ovls)(void);
-	int (*get_num_mgrs)(void);
-
-	void (*mgr_enable)(enum omap_channel channel, bool enable);
-	bool (*mgr_is_enabled)(enum omap_channel channel);
-	u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
-	u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
-	u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
-	bool (*mgr_go_busy)(enum omap_channel channel);
-	void (*mgr_go)(enum omap_channel channel);
-	void (*mgr_set_lcd_config)(enum omap_channel channel,
-			const struct dss_lcd_mgr_config *config);
-	void (*mgr_set_timings)(enum omap_channel channel,
-			const struct videomode *vm);
-	void (*mgr_setup)(enum omap_channel channel,
-			const struct omap_overlay_manager_info *info);
-	enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
-	u32 (*mgr_gamma_size)(enum omap_channel channel);
-	void (*mgr_set_gamma)(enum omap_channel channel,
-		const struct drm_color_lut *lut,
-		unsigned int length);
-
-	int (*ovl_enable)(enum omap_plane_id plane, bool enable);
-	int (*ovl_setup)(enum omap_plane_id plane,
+	u32 (*read_irqstatus)(struct dispc_device *dispc);
+	void (*clear_irqstatus)(struct dispc_device *dispc, u32 mask);
+	void (*write_irqenable)(struct dispc_device *dispc, u32 mask);
+
+	int (*request_irq)(struct dispc_device *dispc, irq_handler_t handler,
+			   void *dev_id);
+	void (*free_irq)(struct dispc_device *dispc, void *dev_id);
+
+	int (*runtime_get)(struct dispc_device *dispc);
+	void (*runtime_put)(struct dispc_device *dispc);
+
+	int (*get_num_ovls)(struct dispc_device *dispc);
+	int (*get_num_mgrs)(struct dispc_device *dispc);
+
+	void (*mgr_enable)(struct dispc_device *dispc,
+			   enum omap_channel channel, bool enable);
+	bool (*mgr_is_enabled)(struct dispc_device *dispc,
+			       enum omap_channel channel);
+	u32 (*mgr_get_vsync_irq)(struct dispc_device *dispc,
+				 enum omap_channel channel);
+	u32 (*mgr_get_framedone_irq)(struct dispc_device *dispc,
+				     enum omap_channel channel);
+	u32 (*mgr_get_sync_lost_irq)(struct dispc_device *dispc,
+				     enum omap_channel channel);
+	bool (*mgr_go_busy)(struct dispc_device *dispc,
+			    enum omap_channel channel);
+	void (*mgr_go)(struct dispc_device *dispc, enum omap_channel channel);
+	void (*mgr_set_lcd_config)(struct dispc_device *dispc,
+				   enum omap_channel channel,
+				   const struct dss_lcd_mgr_config *config);
+	void (*mgr_set_timings)(struct dispc_device *dispc,
+				enum omap_channel channel,
+				const struct videomode *vm);
+	void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
+			  const struct omap_overlay_manager_info *info);
+	enum omap_dss_output_id (*mgr_get_supported_outputs)(
+			struct dispc_device *dispc, enum omap_channel channel);
+	u32 (*mgr_gamma_size)(struct dispc_device *dispc,
+			      enum omap_channel channel);
+	void (*mgr_set_gamma)(struct dispc_device *dispc,
+			      enum omap_channel channel,
+			      const struct drm_color_lut *lut,
+			      unsigned int length);
+
+	int (*ovl_enable)(struct dispc_device *dispc, enum omap_plane_id plane,
+			  bool enable);
+	int (*ovl_setup)(struct dispc_device *dispc, enum omap_plane_id plane,
 			 const struct omap_overlay_info *oi,
-			const struct videomode *vm, bool mem_to_mem,
-			enum omap_channel channel);
+			 const struct videomode *vm, bool mem_to_mem,
+			 enum omap_channel channel);
 
-	const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane);
+	const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
+					  enum omap_plane_id plane);
 };
 
 void dispc_set_ops(const struct dispc_ops *o);
 const struct dispc_ops *dispc_get_ops(void);
+struct dispc_device *dss_get_dispc(struct dss_device *dss);
 
 bool omapdss_component_is_display(struct device_node *node);
 bool omapdss_component_is_output(struct device_node *node);
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index c41bf0d7dd18..efa73cfabce6 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -144,7 +144,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	if (r)
 		goto err_reg_enable;
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(sdi->dss->dispc);
 	if (r)
 		goto err_get_dispc;
 
@@ -206,7 +206,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 err_sdi_enable:
 err_set_dss_clock_div:
 err_calc_clock_div:
-	dispc_runtime_put();
+	dispc_runtime_put(sdi->dss->dispc);
 err_get_dispc:
 	regulator_disable(sdi->vdds_sdi_reg);
 err_reg_enable:
@@ -221,7 +221,7 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
 
 	dss_sdi_disable(sdi->dss);
 
-	dispc_runtime_put();
+	dispc_runtime_put(sdi->dss->dispc);
 
 	regulator_disable(sdi->vdds_sdi_reg);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index f120d2910d0d..13ed7426ea09 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -990,7 +990,7 @@ static int venc_runtime_suspend(struct device *dev)
 	if (venc->tv_dac_clk)
 		clk_disable_unprepare(venc->tv_dac_clk);
 
-	dispc_runtime_put();
+	dispc_runtime_put(venc->dss->dispc);
 
 	return 0;
 }
@@ -1000,7 +1000,7 @@ static int venc_runtime_resume(struct device *dev)
 	struct venc_device *venc = dev_get_drvdata(dev);
 	int r;
 
-	r = dispc_runtime_get();
+	r = dispc_runtime_get(venc->dss->dispc);
 	if (r < 0)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 90a61a8199b4..494d10cd3233 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -118,12 +118,13 @@ static int omap_crtc_dss_connect(struct omap_drm_private *priv,
 		enum omap_channel channel,
 		struct omap_dss_device *dst)
 {
-	const struct dispc_ops *dispc_ops = dispc_get_ops();
+	const struct dispc_ops *dispc_ops = priv->dispc_ops;
+	struct dispc_device *dispc = priv->dispc;
 
 	if (omap_crtc_output[channel])
 		return -EINVAL;
 
-	if ((dispc_ops->mgr_get_supported_outputs(channel) & dst->id) == 0)
+	if (!(dispc_ops->mgr_get_supported_outputs(dispc, channel) & dst->id))
 		return -EINVAL;
 
 	omap_crtc_output[channel] = dst;
@@ -160,7 +161,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 		return;
 
 	if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
-		priv->dispc_ops->mgr_enable(channel, enable);
+		priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
 		omap_crtc->enabled = enable;
 		return;
 	}
@@ -173,8 +174,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 		omap_crtc->ignore_digit_sync_lost = true;
 	}
 
-	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(channel);
-	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(channel);
+	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(priv->dispc,
+							       channel);
+	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel);
 
 	if (enable) {
 		wait = omap_irq_wait_init(dev, vsync_irq, 1);
@@ -194,7 +196,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 			wait = omap_irq_wait_init(dev, vsync_irq, 2);
 	}
 
-	priv->dispc_ops->mgr_enable(channel, enable);
+	priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
 	omap_crtc->enabled = enable;
 
 	ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
@@ -216,7 +218,8 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
 
-	priv->dispc_ops->mgr_set_timings(omap_crtc->channel, &omap_crtc->vm);
+	priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
+					 &omap_crtc->vm);
 	omap_crtc_set_enabled(&omap_crtc->base, true);
 
 	return 0;
@@ -246,7 +249,8 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
 	struct omap_crtc *omap_crtc = omap_crtcs[channel];
 
 	DBG("%s", omap_crtc->name);
-	priv->dispc_ops->mgr_set_lcd_config(omap_crtc->channel, config);
+	priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
+					    config);
 }
 
 static int omap_crtc_dss_register_framedone(
@@ -303,7 +307,7 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
 	 * If the dispc is busy we're racing the flush operation. Try again on
 	 * the next vblank interrupt.
 	 */
-	if (priv->dispc_ops->mgr_go_busy(omap_crtc->channel)) {
+	if (priv->dispc_ops->mgr_go_busy(priv->dispc, omap_crtc->channel)) {
 		spin_unlock(&crtc->dev->event_lock);
 		return;
 	}
@@ -340,7 +344,7 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
 	info.partial_alpha_enabled = false;
 	info.cpr_enable = false;
 
-	priv->dispc_ops->mgr_setup(omap_crtc->channel, &info);
+	priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
 }
 
 /* -----------------------------------------------------------------------------
@@ -505,7 +509,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 			length = crtc->state->gamma_lut->length /
 				sizeof(*lut);
 		}
-		priv->dispc_ops->mgr_set_gamma(omap_crtc->channel, lut, length);
+		priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
+					       lut, length);
 	}
 
 	omap_crtc_write_crtc_properties(crtc);
@@ -520,7 +525,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 	WARN_ON(ret != 0);
 
 	spin_lock_irq(&crtc->dev->event_lock);
-	priv->dispc_ops->mgr_go(omap_crtc->channel);
+	priv->dispc_ops->mgr_go(priv->dispc, omap_crtc->channel);
 	omap_crtc_arm_event(crtc);
 	spin_unlock_irq(&crtc->dev->event_lock);
 }
@@ -701,7 +706,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 	 * extracted with dispc_mgr_gamma_size(). If it returns 0
 	 * gamma table is not supprted.
 	 */
-	if (priv->dispc_ops->mgr_gamma_size(channel)) {
+	if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
 		unsigned int gamma_lut_size = 256;
 
 		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index baf8e32b899b..36b2d89f60db 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -79,7 +79,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
 	struct drm_device *dev = old_state->dev;
 	struct omap_drm_private *priv = dev->dev_private;
 
-	priv->dispc_ops->runtime_get();
+	priv->dispc_ops->runtime_get(priv->dispc);
 
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
@@ -123,7 +123,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_cleanup_planes(dev, old_state);
 
-	priv->dispc_ops->runtime_put();
+	priv->dispc_ops->runtime_put(priv->dispc);
 }
 
 static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = {
@@ -201,7 +201,7 @@ static int omap_connect_dssdevs(void)
 static int omap_modeset_init_properties(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_planes = priv->dispc_ops->get_num_ovls();
+	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
 
 	priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
 						      num_planes - 1);
@@ -215,8 +215,8 @@ static int omap_modeset_init(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_dss_device *dssdev = NULL;
-	int num_ovls = priv->dispc_ops->get_num_ovls();
-	int num_mgrs = priv->dispc_ops->get_num_mgrs();
+	int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
+	int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
 	int num_crtcs, crtc_idx, plane_idx;
 	int ret;
 	u32 plane_crtc_mask;
@@ -542,7 +542,8 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 	{ /* sentinel */ }
 };
 
-int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
+int omapdrm_init(struct dss_device *dss, struct omap_drm_private *priv,
+		 struct device *dev)
 {
 	const struct soc_device_attribute *soc;
 	struct drm_device *ddev;
@@ -553,14 +554,15 @@ int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 
 	priv->dev = dev;
 
+	priv->dispc = dss_get_dispc(dss);
+	priv->dispc_ops = dispc_get_ops();
+
 	omap_crtc_pre_init();
 
 	ret = omap_connect_dssdevs();
 	if (ret)
 		goto err_crtc_uninit;
 
-	priv->dispc_ops = dispc_get_ops();
-
 	soc = soc_device_match(omapdrm_soc_devices);
 	priv->omaprev = soc ? (unsigned int)soc->data : 0;
 	priv->wq = alloc_ordered_workqueue("omapdrm", 0);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index e10b9105379a..3ccc1b289201 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -45,6 +45,7 @@
 
 #define MODULE_NAME     "omapdrm"
 
+struct dss_device;
 struct omap_drm_usergart;
 
 struct omap_drm_private {
@@ -52,6 +53,7 @@ struct omap_drm_private {
 	struct device *dev;
 	u32 omaprev;
 
+	struct dispc_device *dispc;
 	const struct dispc_ops *dispc_ops;
 
 	unsigned int num_crtcs;
@@ -88,7 +90,8 @@ struct omap_drm_private {
 	u32 irq_mask;			/* enabled irqs in addition to wait_list */
 };
 
-int omapdrm_init(struct omap_drm_private *priv, struct device *dev);
+int omapdrm_init(struct dss_device *dss, struct omap_drm_private *priv,
+		 struct device *dev);
 void omapdrm_cleanup(struct omap_drm_private *priv);
 int omap_drm_suspend(struct omap_drm_private *priv);
 int omap_drm_resume(struct omap_drm_private *priv);
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index ef5132237100..dd2180b641e0 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -40,7 +40,7 @@ static void omap_irq_update(struct drm_device *dev)
 
 	DBG("irqmask=%08x", irqmask);
 
-	priv->dispc_ops->write_irqenable(irqmask);
+	priv->dispc_ops->write_irqenable(priv->dispc, irqmask);
 }
 
 static void omap_irq_wait_handler(struct omap_irq_wait *wait)
@@ -110,7 +110,8 @@ int omap_irq_enable_vblank(struct drm_crtc *crtc)
 	DBG("dev=%p, crtc=%u", dev, channel);
 
 	spin_lock_irqsave(&priv->wait_lock, flags);
-	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(channel);
+	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
+							     channel);
 	omap_irq_update(dev);
 	spin_unlock_irqrestore(&priv->wait_lock, flags);
 
@@ -136,7 +137,8 @@ void omap_irq_disable_vblank(struct drm_crtc *crtc)
 	DBG("dev=%p, crtc=%u", dev, channel);
 
 	spin_lock_irqsave(&priv->wait_lock, flags);
-	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(channel);
+	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
+							      channel);
 	omap_irq_update(dev);
 	spin_unlock_irqrestore(&priv->wait_lock, flags);
 }
@@ -200,9 +202,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 	unsigned int id;
 	u32 irqstatus;
 
-	irqstatus = priv->dispc_ops->read_irqstatus();
-	priv->dispc_ops->clear_irqstatus(irqstatus);
-	priv->dispc_ops->read_irqstatus();        /* flush posted write */
+	irqstatus = priv->dispc_ops->read_irqstatus(priv->dispc);
+	priv->dispc_ops->clear_irqstatus(priv->dispc, irqstatus);
+	priv->dispc_ops->read_irqstatus(priv->dispc);	/* flush posted write */
 
 	VERB("irqs: %08x", irqstatus);
 
@@ -210,12 +212,12 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 		struct drm_crtc *crtc = priv->crtcs[id];
 		enum omap_channel channel = omap_crtc_channel(crtc);
 
-		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(channel)) {
+		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel)) {
 			drm_handle_vblank(dev, id);
 			omap_crtc_vblank_irq(crtc);
 		}
 
-		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(channel))
+		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, channel))
 			omap_crtc_error_irq(crtc, irqstatus);
 	}
 
@@ -249,7 +251,7 @@ static const u32 omap_underflow_irqs[] = {
 int omap_drm_irq_install(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs();
+	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
 	unsigned int max_planes;
 	unsigned int i;
 	int ret;
@@ -267,13 +269,13 @@ int omap_drm_irq_install(struct drm_device *dev)
 	}
 
 	for (i = 0; i < num_mgrs; ++i)
-		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(i);
+		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, i);
 
-	priv->dispc_ops->runtime_get();
-	priv->dispc_ops->clear_irqstatus(0xffffffff);
-	priv->dispc_ops->runtime_put();
+	priv->dispc_ops->runtime_get(priv->dispc);
+	priv->dispc_ops->clear_irqstatus(priv->dispc, 0xffffffff);
+	priv->dispc_ops->runtime_put(priv->dispc);
 
-	ret = priv->dispc_ops->request_irq(omap_irq_handler, dev);
+	ret = priv->dispc_ops->request_irq(priv->dispc, omap_irq_handler, dev);
 	if (ret < 0)
 		return ret;
 
@@ -291,5 +293,5 @@ void omap_drm_irq_uninstall(struct drm_device *dev)
 
 	dev->irq_enabled = false;
 
-	priv->dispc_ops->free_irq(dev);
+	priv->dispc_ops->free_irq(priv->dispc, dev);
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 903e0fa5442a..26b32b04c17b 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -79,17 +79,17 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
 			&info.paddr, &info.p_uv_addr);
 
 	/* and finally, update omapdss: */
-	ret = priv->dispc_ops->ovl_setup(omap_plane->id, &info,
+	ret = priv->dispc_ops->ovl_setup(priv->dispc, omap_plane->id, &info,
 			      omap_crtc_timings(state->crtc), false,
 			      omap_crtc_channel(state->crtc));
 	if (ret) {
 		dev_err(plane->dev->dev, "Failed to setup plane %s\n",
 			omap_plane->name);
-		priv->dispc_ops->ovl_enable(omap_plane->id, false);
+		priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
 		return;
 	}
 
-	priv->dispc_ops->ovl_enable(omap_plane->id, true);
+	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, true);
 }
 
 static void omap_plane_atomic_disable(struct drm_plane *plane,
@@ -102,7 +102,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
 	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
 			   ? 0 : omap_plane->id;
 
-	priv->dispc_ops->ovl_enable(omap_plane->id, false);
+	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
 }
 
 static int omap_plane_atomic_check(struct drm_plane *plane,
@@ -261,7 +261,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 		u32 possible_crtcs)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_planes = priv->dispc_ops->get_num_ovls();
+	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
 	struct drm_plane *plane;
 	struct omap_plane *omap_plane;
 	enum omap_plane_id id;
@@ -280,7 +280,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 	if (!omap_plane)
 		return ERR_PTR(-ENOMEM);
 
-	formats = priv->dispc_ops->ovl_get_color_modes(id);
+	formats = priv->dispc_ops->ovl_get_color_modes(priv->dispc, id);
 	for (nformats = 0; formats[nformats]; ++nformats)
 		;
 	omap_plane->id = id;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (43 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 21:24   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
                   ` (6 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This removes the need to access the global DISPC private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DISPC private data dynamically).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 101 ++++++++++++++++++++----------------
 drivers/gpu/drm/omapdrm/dss/dpi.c   |  12 +++--
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  22 ++++----
 drivers/gpu/drm/omapdrm/dss/dss.c   |  14 ++---
 drivers/gpu/drm/omapdrm/dss/dss.h   |  74 ++++++++++++++------------
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |   6 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |   6 ++-
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  13 +++--
 drivers/gpu/drm/omapdrm/dss/venc.c  |   2 +-
 9 files changed, 139 insertions(+), 111 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 1bca5785b8a8..180ad55bbdec 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -706,7 +706,7 @@ static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
 	return mgr_desc[channel].sync_lost_irq;
 }
 
-u32 dispc_wb_get_framedone_irq(void)
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
 {
 	return DISPC_IRQ_FRAMEDONEWB;
 }
@@ -741,12 +741,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 	mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1);
 }
 
-bool dispc_wb_go_busy(void)
+bool dispc_wb_go_busy(struct dispc_device *dispc)
 {
 	return REG_GET(DISPC_CONTROL2, 6, 6) == 1;
 }
 
-void dispc_wb_go(void)
+void dispc_wb_go(struct dispc_device *dispc)
 {
 	enum omap_plane_id plane = OMAP_DSS_WB;
 	bool enable, go;
@@ -1198,7 +1198,8 @@ static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
 	}
 }
 
-void dispc_wb_set_channel_in(enum dss_writeback_channel channel)
+void dispc_wb_set_channel_in(struct dispc_device *dispc,
+			     enum dss_writeback_channel channel)
 {
 	enum omap_plane_id plane = OMAP_DSS_WB;
 
@@ -1373,10 +1374,10 @@ static void dispc_init_fifos(void)
 		const bool use_fifomerge = false;
 		const bool manual_update = false;
 
-		dispc_ovl_compute_fifo_thresholds(i, &low, &high,
+		dispc_ovl_compute_fifo_thresholds(&dispc, i, &low, &high,
 			use_fifomerge, manual_update);
 
-		dispc_ovl_set_fifo_threshold(i, low, high);
+		dispc_ovl_set_fifo_threshold(&dispc, i, low, high);
 	}
 
 	if (dispc.feat->has_writeback) {
@@ -1384,10 +1385,11 @@ static void dispc_init_fifos(void)
 		const bool use_fifomerge = false;
 		const bool manual_update = false;
 
-		dispc_ovl_compute_fifo_thresholds(OMAP_DSS_WB, &low, &high,
-			use_fifomerge, manual_update);
+		dispc_ovl_compute_fifo_thresholds(&dispc, OMAP_DSS_WB,
+						  &low, &high,
+						  use_fifomerge, manual_update);
 
-		dispc_ovl_set_fifo_threshold(OMAP_DSS_WB, low, high);
+		dispc_ovl_set_fifo_threshold(&dispc, OMAP_DSS_WB, low, high);
 	}
 }
 
@@ -1404,13 +1406,14 @@ static u32 dispc_ovl_get_fifo_size(enum omap_plane_id plane)
 	return size;
 }
 
-void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
-				  u32 high)
+void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
+				  enum omap_plane_id plane,
+				  u32 low, u32 high)
 {
 	u8 hi_start, hi_end, lo_start, lo_end;
 	u32 unit;
 
-	unit = dispc.feat->buffer_size_unit;
+	unit = dispc->feat->buffer_size_unit;
 
 	WARN_ON(low % unit != 0);
 	WARN_ON(high % unit != 0);
@@ -1438,12 +1441,12 @@ void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
 	 * large for the preload field, set the threshold to the maximum value
 	 * that can be held by the preload register
 	 */
-	if (dispc_has_feature(FEAT_PRELOAD) && dispc.feat->set_max_preload &&
+	if (dispc_has_feature(FEAT_PRELOAD) && dispc->feat->set_max_preload &&
 			plane != OMAP_DSS_WB)
 		dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
 }
 
-void dispc_enable_fifomerge(bool enable)
+void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
 {
 	if (!dispc_has_feature(FEAT_FIFO_MERGE)) {
 		WARN_ON(enable);
@@ -1454,15 +1457,16 @@ void dispc_enable_fifomerge(bool enable)
 	REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
 }
 
-void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
-		u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
-		bool manual_update)
+void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
+				       enum omap_plane_id plane,
+				       u32 *fifo_low, u32 *fifo_high,
+				       bool use_fifomerge, bool manual_update)
 {
 	/*
 	 * All sizes are in bytes. Both the buffer and burst are made of
 	 * buffer_units, and the fifo thresholds must be buffer_unit aligned.
 	 */
-	unsigned int buf_unit = dispc.feat->buffer_size_unit;
+	unsigned int buf_unit = dispc->feat->buffer_size_unit;
 	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
 	int i;
 
@@ -1471,7 +1475,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
 
 	if (use_fifomerge) {
 		total_fifo_size = 0;
-		for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
+		for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
 			total_fifo_size += dispc_ovl_get_fifo_size(i);
 	} else {
 		total_fifo_size = ovl_fifo_size;
@@ -2667,8 +2671,9 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
 	return r;
 }
 
-int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
-		bool mem_to_mem, const struct videomode *vm)
+int dispc_wb_setup(struct dispc_device *dispc,
+		   const struct omap_dss_writeback_info *wi,
+		   bool mem_to_mem, const struct videomode *vm)
 {
 	int r;
 	u32 l;
@@ -2759,7 +2764,7 @@ static void dispc_lcd_enable_signal_polarity(bool act_high)
 	REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
 }
 
-void dispc_lcd_enable_signal(bool enable)
+void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable)
 {
 	if (!dispc_has_feature(FEAT_LCDENABLESIGNAL))
 		return;
@@ -2767,7 +2772,7 @@ void dispc_lcd_enable_signal(bool enable)
 	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
 }
 
-void dispc_pck_free_enable(bool enable)
+void dispc_pck_free_enable(struct dispc_device *dispc, bool enable)
 {
 	if (!dispc_has_feature(FEAT_PCKFREEENABLE))
 		return;
@@ -2906,7 +2911,7 @@ static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
 	dispc_mgr_enable_stallmode(channel, config->stallmode);
 	dispc_mgr_enable_fifohandcheck(channel, config->fifohandcheck);
 
-	dispc_mgr_set_clock_div(channel, &config->clock_info);
+	dispc_mgr_set_clock_div(dispc, channel, &config->clock_info);
 
 	dispc_mgr_set_tft_data_lines(channel, config->video_port_width);
 
@@ -2943,7 +2948,8 @@ static bool _dispc_mgr_pclk_ok(enum omap_channel channel,
 		return pclk <= dispc.feat->max_tv_pclk;
 }
 
-bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm)
+bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
+			  const struct videomode *vm)
 {
 	if (!_dispc_mgr_size_ok(vm->hactive, vm->vactive))
 		return false;
@@ -3064,7 +3070,7 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
 
 	DSSDBG("channel %d xres %u yres %u\n", channel, t.hactive, t.vactive);
 
-	if (!dispc_mgr_timings_ok(channel, &t)) {
+	if (!dispc_mgr_timings_ok(dispc, channel, &t)) {
 		BUG();
 		return;
 	}
@@ -3197,9 +3203,9 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
 	}
 }
 
-void dispc_set_tv_pclk(unsigned long pclk)
+void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk)
 {
-	dispc.tv_pclk_rate = pclk;
+	dispc->tv_pclk_rate = pclk;
 }
 
 static unsigned long dispc_core_clk_rate(void)
@@ -3251,13 +3257,13 @@ static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel chan
 		dispc_mgr_pclk_rate(channel), pcd);
 }
 
-void dispc_dump_clocks(struct seq_file *s)
+void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
 {
 	int lcd;
 	u32 l;
-	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
+	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc->dss);
 
-	if (dispc_runtime_get(&dispc))
+	if (dispc_runtime_get(dispc))
 		return;
 
 	seq_printf(s, "- DISPC -\n");
@@ -3283,7 +3289,7 @@ void dispc_dump_clocks(struct seq_file *s)
 	if (dispc_has_feature(FEAT_MGR_LCD3))
 		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
 
-	dispc_runtime_put(&dispc);
+	dispc_runtime_put(dispc);
 }
 
 static int dispc_dump_regs(struct seq_file *s, void *p)
@@ -3484,8 +3490,9 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 }
 
 /* calculate clock rates using dividers in cinfo */
-int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
-		struct dispc_clock_info *cinfo)
+int dispc_calc_clock_rates(struct dispc_device *dispc,
+			   unsigned long dispc_fclk_rate,
+			   struct dispc_clock_info *cinfo)
 {
 	if (cinfo->lck_div > 255 || cinfo->lck_div == 0)
 		return -EINVAL;
@@ -3498,9 +3505,9 @@ int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
 	return 0;
 }
 
-bool dispc_div_calc(unsigned long dispc_freq,
-		unsigned long pck_min, unsigned long pck_max,
-		dispc_div_calc_func func, void *data)
+bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
+		    unsigned long pck_min, unsigned long pck_max,
+		    dispc_div_calc_func func, void *data)
 {
 	int lckd, lckd_start, lckd_stop;
 	int pckd, pckd_start, pckd_stop;
@@ -3516,10 +3523,10 @@ bool dispc_div_calc(unsigned long dispc_freq,
 	min_fck_per_pck = 0;
 #endif
 
-	pckd_hw_min = dispc.feat->min_pcd;
+	pckd_hw_min = dispc->feat->min_pcd;
 	pckd_hw_max = 255;
 
-	lck_max = dss_get_max_fck_rate(dispc.dss);
+	lck_max = dss_get_max_fck_rate(dispc->dss);
 
 	pck_min = pck_min ? pck_min : 1;
 	pck_max = pck_max ? pck_max : ULONG_MAX;
@@ -3558,8 +3565,9 @@ bool dispc_div_calc(unsigned long dispc_freq,
 	return false;
 }
 
-void dispc_mgr_set_clock_div(enum omap_channel channel,
-		const struct dispc_clock_info *cinfo)
+void dispc_mgr_set_clock_div(struct dispc_device *dispc,
+			     enum omap_channel channel,
+			     const struct dispc_clock_info *cinfo)
 {
 	DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
 	DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
@@ -3567,8 +3575,9 @@ void dispc_mgr_set_clock_div(enum omap_channel channel,
 	dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div);
 }
 
-int dispc_mgr_get_clock_div(enum omap_channel channel,
-		struct dispc_clock_info *cinfo)
+int dispc_mgr_get_clock_div(struct dispc_device *dispc,
+			    enum omap_channel channel,
+			    struct dispc_clock_info *cinfo)
 {
 	unsigned long fck;
 
@@ -3606,12 +3615,12 @@ static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
 	dispc_read_reg(DISPC_IRQENABLE);
 }
 
-void dispc_enable_sidle(void)
+void dispc_enable_sidle(struct dispc_device *dispc)
 {
 	REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3);	/* SIDLEMODE: smart idle */
 }
 
-void dispc_disable_sidle(void)
+void dispc_disable_sidle(struct dispc_device *dispc)
 {
 	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
 }
@@ -4473,7 +4482,7 @@ static void dispc_errata_i734_wa(void)
 
 	/* Set up and enable display manager for LCD1 */
 	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
-	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
+	dispc_calc_clock_rates(&dispc, dss_get_dispc_clk_rate(dispc.dss),
 			       &lcd_conf.clock_info);
 	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
 	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index aa10db453fd0..66183fc77bb2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -192,8 +192,9 @@ static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
 	ctx->pll_cinfo.mX[ctx->clkout_idx] = m_dispc;
 	ctx->pll_cinfo.clkout[ctx->clkout_idx] = dispc;
 
-	return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max,
-			dpi_calc_dispc_cb, ctx);
+	return dispc_div_calc(ctx->pll->dss->dispc, dispc,
+			      ctx->pck_min, ctx->pck_max,
+			      dpi_calc_dispc_cb, ctx);
 }
 
 
@@ -219,8 +220,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
 
 	ctx->fck = fck;
 
-	return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
-			dpi_calc_dispc_cb, ctx);
+	return dispc_div_calc(ctx->pll->dss->dispc, fck,
+			      ctx->pck_min, ctx->pck_max,
+			      dpi_calc_dispc_cb, ctx);
 }
 
 static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck,
@@ -515,7 +517,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
 	if (vm->hactive % 8 != 0)
 		return -EINVAL;
 
-	if (!dispc_mgr_timings_ok(channel, vm))
+	if (!dispc_mgr_timings_ok(dpi->dss->dispc, channel, vm))
 		return -EINVAL;
 
 	if (vm->pixelclock == 0)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1cac221e499a..c7700dfccc08 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1396,18 +1396,18 @@ static int dsi_pll_enable(struct dss_pll *pll)
 	}
 
 	/* XXX PLL does not come out of reset without this... */
-	dispc_pck_free_enable(1);
+	dispc_pck_free_enable(dsi->dss->dispc, 1);
 
 	if (!wait_for_bit_change(dsi, DSI_PLL_STATUS, 0, 1)) {
 		DSSERR("PLL not coming out of reset.\n");
 		r = -ENODEV;
-		dispc_pck_free_enable(0);
+		dispc_pck_free_enable(dsi->dss->dispc, 0);
 		goto err1;
 	}
 
 	/* XXX ... but if left on, we get problems when planes do not
 	 * fill the whole display. No idea about this */
-	dispc_pck_free_enable(0);
+	dispc_pck_free_enable(dsi->dss->dispc, 0);
 
 	r = dsi_pll_power(dsi, DSI_PLL_POWER_ON_ALL);
 
@@ -3974,7 +3974,7 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 	 * the same goes for any DSS interrupts, but for some reason I have not
 	 * seen the problem anywhere else than here.
 	 */
-	dispc_disable_sidle();
+	dispc_disable_sidle(dsi->dss->dispc);
 
 	dsi_perf_mark_start(dsi);
 
@@ -4009,7 +4009,7 @@ static void dsi_te_timeout(unsigned long arg)
 static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 {
 	/* SIDLEMODE back to smart-idle */
-	dispc_enable_sidle();
+	dispc_enable_sidle(dsi->dss->dispc);
 
 	if (dsi->te_enabled) {
 		/* enable LP_RX_TO again after the TE */
@@ -4090,7 +4090,7 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
 	dispc_cinfo.lck_div = dsi->user_dispc_cinfo.lck_div;
 	dispc_cinfo.pck_div = dsi->user_dispc_cinfo.pck_div;
 
-	r = dispc_calc_clock_rates(fck, &dispc_cinfo);
+	r = dispc_calc_clock_rates(dsi->dss->dispc, fck, &dispc_cinfo);
 	if (r) {
 		DSSERR("Failed to calc dispc clocks\n");
 		return r;
@@ -4441,8 +4441,9 @@ static bool dsi_cm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
 	ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc;
 	ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc;
 
-	return dispc_div_calc(dispc, ctx->req_pck_min, ctx->req_pck_max,
-			dsi_cm_calc_dispc_cb, ctx);
+	return dispc_div_calc(ctx->dsi->dss->dispc, dispc,
+			      ctx->req_pck_min, ctx->req_pck_max,
+			      dsi_cm_calc_dispc_cb, ctx);
 }
 
 static bool dsi_cm_calc_pll_cb(int n, int m, unsigned long fint,
@@ -4741,8 +4742,9 @@ static bool dsi_vm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
 	else
 		pck_max = ctx->req_pck_max;
 
-	return dispc_div_calc(dispc, ctx->req_pck_min, pck_max,
-			dsi_vm_calc_dispc_cb, ctx);
+	return dispc_div_calc(ctx->dsi->dss->dispc, dispc,
+			      ctx->req_pck_min, pck_max,
+			      dsi_vm_calc_dispc_cb, ctx);
 }
 
 static bool dsi_vm_calc_pll_cb(int n, int m, unsigned long fint,
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index fcdd7d00caa8..5d927dfe0a7f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -276,7 +276,7 @@ int dss_sdi_enable(struct dss_device *dss)
 {
 	unsigned long timeout;
 
-	dispc_pck_free_enable(1);
+	dispc_pck_free_enable(dss->dispc, 1);
 
 	/* Reset SDI PLL */
 	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
@@ -306,7 +306,7 @@ int dss_sdi_enable(struct dss_device *dss)
 		}
 	}
 
-	dispc_lcd_enable_signal(1);
+	dispc_lcd_enable_signal(dss->dispc, 1);
 
 	/* Waiting for SDI reset to complete */
 	timeout = jiffies + msecs_to_jiffies(500);
@@ -320,21 +320,21 @@ int dss_sdi_enable(struct dss_device *dss)
 	return 0;
 
  err2:
-	dispc_lcd_enable_signal(0);
+	dispc_lcd_enable_signal(dss->dispc, 0);
  err1:
 	/* Reset SDI PLL */
 	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
 
-	dispc_pck_free_enable(0);
+	dispc_pck_free_enable(dss->dispc, 0);
 
 	return -ETIMEDOUT;
 }
 
 void dss_sdi_disable(struct dss_device *dss)
 {
-	dispc_lcd_enable_signal(0);
+	dispc_lcd_enable_signal(dss->dispc, 0);
 
-	dispc_pck_free_enable(0);
+	dispc_pck_free_enable(dss->dispc, 0);
 
 	/* Reset SDI PLL */
 	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
@@ -899,7 +899,7 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
 	struct dss_device *dss = s->private;
 
 	dss_dump_clocks(dss, s);
-	dispc_dump_clocks(s);
+	dispc_dump_clocks(dss->dispc, s);
 #ifdef CONFIG_OMAP2_DSS_DSI
 	dsi_dump_clocks(s);
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 5f3e26bec402..ceba8441c7cc 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -417,47 +417,55 @@ static inline void dpi_uninit_port(struct device_node *port)
 /* DISPC */
 int dispc_init_platform_driver(void) __init;
 void dispc_uninit_platform_driver(void);
-void dispc_dump_clocks(struct seq_file *s);
+void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s);
 
 int dispc_runtime_get(struct dispc_device *dispc);
 void dispc_runtime_put(struct dispc_device *dispc);
 
-void dispc_enable_sidle(void);
-void dispc_disable_sidle(void);
+void dispc_enable_sidle(struct dispc_device *dispc);
+void dispc_disable_sidle(struct dispc_device *dispc);
 
-void dispc_lcd_enable_signal(bool enable);
-void dispc_pck_free_enable(bool enable);
-void dispc_enable_fifomerge(bool enable);
+void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable);
+void dispc_pck_free_enable(struct dispc_device *dispc, bool enable);
+void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable);
 
 typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
 		unsigned long pck, void *data);
-bool dispc_div_calc(unsigned long dispc,
-		unsigned long pck_min, unsigned long pck_max,
-		dispc_div_calc_func func, void *data);
-
-bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm);
-int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
-		struct dispc_clock_info *cinfo);
-
-
-void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
-				  u32 high);
-void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
-		u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
-		bool manual_update);
-
-void dispc_mgr_set_clock_div(enum omap_channel channel,
-		const struct dispc_clock_info *cinfo);
-int dispc_mgr_get_clock_div(enum omap_channel channel,
-		struct dispc_clock_info *cinfo);
-void dispc_set_tv_pclk(unsigned long pclk);
-
-u32 dispc_wb_get_framedone_irq(void);
-bool dispc_wb_go_busy(void);
-void dispc_wb_go(void);
-void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
-int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
-		bool mem_to_mem, const struct videomode *vm);
+bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
+		    unsigned long pck_min, unsigned long pck_max,
+		    dispc_div_calc_func func, void *data);
+
+bool dispc_mgr_timings_ok(struct dispc_device *dispc,
+			  enum omap_channel channel,
+			  const struct videomode *vm);
+int dispc_calc_clock_rates(struct dispc_device *dispc,
+			   unsigned long dispc_fclk_rate,
+			   struct dispc_clock_info *cinfo);
+
+
+void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
+				  enum omap_plane_id plane, u32 low, u32 high);
+void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
+				       enum omap_plane_id plane,
+				       u32 *fifo_low, u32 *fifo_high,
+				       bool use_fifomerge, bool manual_update);
+
+void dispc_mgr_set_clock_div(struct dispc_device *dispc,
+			     enum omap_channel channel,
+			     const struct dispc_clock_info *cinfo);
+int dispc_mgr_get_clock_div(struct dispc_device *dispc,
+			    enum omap_channel channel,
+			    struct dispc_clock_info *cinfo);
+void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk);
+
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc);
+bool dispc_wb_go_busy(struct dispc_device *dispc);
+void dispc_wb_go(struct dispc_device *dispc);
+void dispc_wb_set_channel_in(struct dispc_device *dispc,
+			     enum dss_writeback_channel channel);
+int dispc_wb_setup(struct dispc_device *dispc,
+		   const struct omap_dss_writeback_info *wi,
+		   bool mem_to_mem, const struct videomode *vm);
 
 /* VENC */
 int venc_init_platform_driver(void) __init;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index cf4b2c9bbcbd..2050601fef0a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -273,7 +273,9 @@ static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
 				     struct videomode *vm)
 {
-	if (!dispc_mgr_timings_ok(dssdev->dispc_channel, vm))
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	if (!dispc_mgr_timings_ok(hdmi->dss->dispc, dssdev->dispc_channel, vm))
 		return -EINVAL;
 
 	return 0;
@@ -288,7 +290,7 @@ static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
 
 	hdmi->cfg.vm = *vm;
 
-	dispc_set_tv_pclk(vm->pixelclock);
+	dispc_set_tv_pclk(hdmi->dss->dispc, vm->pixelclock);
 
 	mutex_unlock(&hdmi->lock);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 66b603c5b2fc..ec3b044925d0 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -271,7 +271,9 @@ static void hdmi_power_off_full(struct omap_hdmi *hdmi)
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
 				     struct videomode *vm)
 {
-	if (!dispc_mgr_timings_ok(dssdev->dispc_channel, vm))
+	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
+
+	if (!dispc_mgr_timings_ok(hdmi->dss->dispc, dssdev->dispc_channel, vm))
 		return -EINVAL;
 
 	return 0;
@@ -286,7 +288,7 @@ static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
 
 	hdmi->cfg.vm = *vm;
 
-	dispc_set_tv_pclk(vm->pixelclock);
+	dispc_set_tv_pclk(hdmi->dss->dispc, vm->pixelclock);
 
 	mutex_unlock(&hdmi->lock);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index efa73cfabce6..b0ef2395e8a1 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -48,6 +48,7 @@ struct sdi_device {
 #define dssdev_to_sdi(dssdev) container_of(dssdev, struct sdi_device, output)
 
 struct sdi_clk_calc_ctx {
+	struct sdi_device *sdi;
 	unsigned long pck_min, pck_max;
 
 	unsigned long fck;
@@ -73,8 +74,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
 
 	ctx->fck = fck;
 
-	return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
-			dpi_calc_dispc_cb, ctx);
+	return dispc_div_calc(ctx->sdi->dss->dispc, fck,
+			      ctx->pck_min, ctx->pck_max,
+			      dpi_calc_dispc_cb, ctx);
 }
 
 static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
@@ -82,7 +84,7 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
 			      struct dispc_clock_info *dispc_cinfo)
 {
 	int i;
-	struct sdi_clk_calc_ctx ctx;
+	struct sdi_clk_calc_ctx ctx = { .sdi = sdi };
 
 	/*
 	 * DSS fclk gives us very few possibilities, so finding a good pixel
@@ -186,7 +188,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 	 * need to care about the shadow register mechanism for pck-free. The
 	 * exact reason for this is unknown.
 	 */
-	dispc_mgr_set_clock_div(sdi->output.dispc_channel,
+	dispc_mgr_set_clock_div(sdi->dss->dispc, sdi->output.dispc_channel,
 				&sdi->mgr_config.clock_info);
 
 	dss_sdi_init(sdi->dss, sdi->datapairs);
@@ -245,9 +247,10 @@ static void sdi_get_timings(struct omap_dss_device *dssdev,
 static int sdi_check_timings(struct omap_dss_device *dssdev,
 			     struct videomode *vm)
 {
+	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
 	enum omap_channel channel = dssdev->dispc_channel;
 
-	if (!dispc_mgr_timings_ok(channel, vm))
+	if (!dispc_mgr_timings_ok(sdi->dss->dispc, channel, vm))
 		return -EINVAL;
 
 	if (vm->pixelclock == 0)
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 13ed7426ea09..449a82b84d03 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -597,7 +597,7 @@ static void venc_set_timings(struct omap_dss_device *dssdev,
 
 	venc->vm = actual_vm;
 
-	dispc_set_tv_pclk(13500000);
+	dispc_set_tv_pclk(venc->dss->dispc, 13500000);
 
 	mutex_unlock(&venc->venc_lock);
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (44 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 22:09   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Laurent Pinchart
                   ` (5 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The dispc private data structure is currently stored as a global
variable. While no platform with multiple DISPC currently exists
nor is planned, this doesn't comply with the kernel device model and
should thus be fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 1924 +++++++++++++++++++----------------
 1 file changed, 1032 insertions(+), 892 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 180ad55bbdec..aaf7396f0273 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -49,6 +49,8 @@
 #include "dss.h"
 #include "dispc.h"
 
+struct dispc_device;
+
 /* DISPC */
 #define DISPC_SZ_REGS			SZ_4K
 
@@ -58,11 +60,12 @@ enum omap_burst_size {
 	BURST_SIZE_X8 = 2,
 };
 
-#define REG_GET(idx, start, end) \
-	FLD_GET(dispc_read_reg(idx), start, end)
+#define REG_GET(dispc, idx, start, end) \
+	FLD_GET(dispc_read_reg(dispc, idx), start, end)
 
-#define REG_FLD_MOD(idx, val, start, end)				\
-	dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end))
+#define REG_FLD_MOD(dispc, idx, val, start, end)			\
+	dispc_write_reg(dispc, idx, \
+			FLD_MOD(dispc_read_reg(dispc, idx), val, start, end))
 
 /* DISPC has feature id */
 enum dispc_feature_id {
@@ -107,7 +110,8 @@ struct dispc_features {
 	unsigned int max_downscale;
 	unsigned int max_line_width;
 	unsigned int min_pcd;
-	int (*calc_scaling) (unsigned long pclk, unsigned long lclk,
+	int (*calc_scaling)(struct dispc_device *dispc,
+		unsigned long pclk, unsigned long lclk,
 		const struct videomode *vm,
 		u16 width, u16 height, u16 out_width, u16 out_height,
 		u32 fourcc, bool *five_taps,
@@ -198,8 +202,6 @@ struct dispc_device {
 	spinlock_t control_lock;
 };
 
-static struct dispc_device dispc;
-
 enum omap_color_component {
 	/* used for all color formats for OMAP3 and earlier
 	 * and for RGB and Y color component on OMAP4
@@ -357,45 +359,52 @@ struct color_conv_coef {
 	int full_range;
 };
 
-static unsigned long dispc_fclk_rate(void);
-static unsigned long dispc_core_clk_rate(void);
-static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
-static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
+static unsigned long dispc_fclk_rate(struct dispc_device *dispc);
+static unsigned long dispc_core_clk_rate(struct dispc_device *dispc);
+static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
+					 enum omap_channel channel);
+static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
+					 enum omap_channel channel);
 
-static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane);
-static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane);
+static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
+					   enum omap_plane_id plane);
+static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
+					   enum omap_plane_id plane);
 
 static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
 
-static inline void dispc_write_reg(const u16 idx, u32 val)
+static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 val)
 {
-	__raw_writel(val, dispc.base + idx);
+	__raw_writel(val, dispc->base + idx);
 }
 
-static inline u32 dispc_read_reg(const u16 idx)
+static inline u32 dispc_read_reg(struct dispc_device *dispc, u16 idx)
 {
-	return __raw_readl(dispc.base + idx);
+	return __raw_readl(dispc->base + idx);
 }
 
-static u32 mgr_fld_read(enum omap_channel channel, enum mgr_reg_fields regfld)
+static u32 mgr_fld_read(struct dispc_device *dispc, enum omap_channel channel,
+			enum mgr_reg_fields regfld)
 {
 	const struct dispc_reg_field rfld = mgr_desc[channel].reg_desc[regfld];
-	return REG_GET(rfld.reg, rfld.high, rfld.low);
+
+	return REG_GET(dispc, rfld.reg, rfld.high, rfld.low);
 }
 
-static void mgr_fld_write(enum omap_channel channel,
-					enum mgr_reg_fields regfld, int val) {
+static void mgr_fld_write(struct dispc_device *dispc, enum omap_channel channel,
+			  enum mgr_reg_fields regfld, int val)
+{
 	const struct dispc_reg_field rfld = mgr_desc[channel].reg_desc[regfld];
 	const bool need_lock = rfld.reg == DISPC_CONTROL || rfld.reg == DISPC_CONFIG;
 	unsigned long flags;
 
 	if (need_lock)
-		spin_lock_irqsave(&dispc.control_lock, flags);
+		spin_lock_irqsave(&dispc->control_lock, flags);
 
-	REG_FLD_MOD(rfld.reg, val, rfld.high, rfld.low);
+	REG_FLD_MOD(dispc, rfld.reg, val, rfld.high, rfld.low);
 
 	if (need_lock)
-		spin_unlock_irqrestore(&dispc.control_lock, flags);
+		spin_unlock_irqrestore(&dispc->control_lock, flags);
 }
 
 static int dispc_get_num_ovls(struct dispc_device *dispc)
@@ -408,255 +417,257 @@ static int dispc_get_num_mgrs(struct dispc_device *dispc)
 	return dispc->feat->num_mgrs;
 }
 
-static void dispc_get_reg_field(enum dispc_feat_reg_field id,
+static void dispc_get_reg_field(struct dispc_device *dispc,
+				enum dispc_feat_reg_field id,
 				u8 *start, u8 *end)
 {
-	if (id >= dispc.feat->num_reg_fields)
+	if (id >= dispc->feat->num_reg_fields)
 		BUG();
 
-	*start = dispc.feat->reg_fields[id].start;
-	*end = dispc.feat->reg_fields[id].end;
+	*start = dispc->feat->reg_fields[id].start;
+	*end = dispc->feat->reg_fields[id].end;
 }
 
-static bool dispc_has_feature(enum dispc_feature_id id)
+static bool dispc_has_feature(struct dispc_device *dispc,
+			      enum dispc_feature_id id)
 {
 	unsigned int i;
 
-	for (i = 0; i < dispc.feat->num_features; i++) {
-		if (dispc.feat->features[i] == id)
+	for (i = 0; i < dispc->feat->num_features; i++) {
+		if (dispc->feat->features[i] == id)
 			return true;
 	}
 
 	return false;
 }
 
-#define SR(reg) \
-	dispc.ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(DISPC_##reg)
-#define RR(reg) \
-	dispc_write_reg(DISPC_##reg, dispc.ctx[DISPC_##reg / sizeof(u32)])
+#define SR(dispc, reg) \
+	dispc->ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(dispc, DISPC_##reg)
+#define RR(dispc, reg) \
+	dispc_write_reg(dispc, DISPC_##reg, dispc->ctx[DISPC_##reg / sizeof(u32)])
 
-static void dispc_save_context(void)
+static void dispc_save_context(struct dispc_device *dispc)
 {
 	int i, j;
 
 	DSSDBG("dispc_save_context\n");
 
-	SR(IRQENABLE);
-	SR(CONTROL);
-	SR(CONFIG);
-	SR(LINE_NUMBER);
-	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
-			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
-		SR(GLOBAL_ALPHA);
-	if (dispc_has_feature(FEAT_MGR_LCD2)) {
-		SR(CONTROL2);
-		SR(CONFIG2);
+	SR(dispc, IRQENABLE);
+	SR(dispc, CONTROL);
+	SR(dispc, CONFIG);
+	SR(dispc, LINE_NUMBER);
+	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
+			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
+		SR(dispc, GLOBAL_ALPHA);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
+		SR(dispc, CONTROL2);
+		SR(dispc, CONFIG2);
 	}
-	if (dispc_has_feature(FEAT_MGR_LCD3)) {
-		SR(CONTROL3);
-		SR(CONFIG3);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
+		SR(dispc, CONTROL3);
+		SR(dispc, CONFIG3);
 	}
 
-	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
-		SR(DEFAULT_COLOR(i));
-		SR(TRANS_COLOR(i));
-		SR(SIZE_MGR(i));
+	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
+		SR(dispc, DEFAULT_COLOR(i));
+		SR(dispc, TRANS_COLOR(i));
+		SR(dispc, SIZE_MGR(i));
 		if (i == OMAP_DSS_CHANNEL_DIGIT)
 			continue;
-		SR(TIMING_H(i));
-		SR(TIMING_V(i));
-		SR(POL_FREQ(i));
-		SR(DIVISORo(i));
-
-		SR(DATA_CYCLE1(i));
-		SR(DATA_CYCLE2(i));
-		SR(DATA_CYCLE3(i));
-
-		if (dispc_has_feature(FEAT_CPR)) {
-			SR(CPR_COEF_R(i));
-			SR(CPR_COEF_G(i));
-			SR(CPR_COEF_B(i));
+		SR(dispc, TIMING_H(i));
+		SR(dispc, TIMING_V(i));
+		SR(dispc, POL_FREQ(i));
+		SR(dispc, DIVISORo(i));
+
+		SR(dispc, DATA_CYCLE1(i));
+		SR(dispc, DATA_CYCLE2(i));
+		SR(dispc, DATA_CYCLE3(i));
+
+		if (dispc_has_feature(dispc, FEAT_CPR)) {
+			SR(dispc, CPR_COEF_R(i));
+			SR(dispc, CPR_COEF_G(i));
+			SR(dispc, CPR_COEF_B(i));
 		}
 	}
 
-	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
-		SR(OVL_BA0(i));
-		SR(OVL_BA1(i));
-		SR(OVL_POSITION(i));
-		SR(OVL_SIZE(i));
-		SR(OVL_ATTRIBUTES(i));
-		SR(OVL_FIFO_THRESHOLD(i));
-		SR(OVL_ROW_INC(i));
-		SR(OVL_PIXEL_INC(i));
-		if (dispc_has_feature(FEAT_PRELOAD))
-			SR(OVL_PRELOAD(i));
+	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
+		SR(dispc, OVL_BA0(i));
+		SR(dispc, OVL_BA1(i));
+		SR(dispc, OVL_POSITION(i));
+		SR(dispc, OVL_SIZE(i));
+		SR(dispc, OVL_ATTRIBUTES(i));
+		SR(dispc, OVL_FIFO_THRESHOLD(i));
+		SR(dispc, OVL_ROW_INC(i));
+		SR(dispc, OVL_PIXEL_INC(i));
+		if (dispc_has_feature(dispc, FEAT_PRELOAD))
+			SR(dispc, OVL_PRELOAD(i));
 		if (i == OMAP_DSS_GFX) {
-			SR(OVL_WINDOW_SKIP(i));
-			SR(OVL_TABLE_BA(i));
+			SR(dispc, OVL_WINDOW_SKIP(i));
+			SR(dispc, OVL_TABLE_BA(i));
 			continue;
 		}
-		SR(OVL_FIR(i));
-		SR(OVL_PICTURE_SIZE(i));
-		SR(OVL_ACCU0(i));
-		SR(OVL_ACCU1(i));
+		SR(dispc, OVL_FIR(i));
+		SR(dispc, OVL_PICTURE_SIZE(i));
+		SR(dispc, OVL_ACCU0(i));
+		SR(dispc, OVL_ACCU1(i));
 
 		for (j = 0; j < 8; j++)
-			SR(OVL_FIR_COEF_H(i, j));
+			SR(dispc, OVL_FIR_COEF_H(i, j));
 
 		for (j = 0; j < 8; j++)
-			SR(OVL_FIR_COEF_HV(i, j));
+			SR(dispc, OVL_FIR_COEF_HV(i, j));
 
 		for (j = 0; j < 5; j++)
-			SR(OVL_CONV_COEF(i, j));
+			SR(dispc, OVL_CONV_COEF(i, j));
 
-		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
+		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
 			for (j = 0; j < 8; j++)
-				SR(OVL_FIR_COEF_V(i, j));
+				SR(dispc, OVL_FIR_COEF_V(i, j));
 		}
 
-		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
-			SR(OVL_BA0_UV(i));
-			SR(OVL_BA1_UV(i));
-			SR(OVL_FIR2(i));
-			SR(OVL_ACCU2_0(i));
-			SR(OVL_ACCU2_1(i));
+		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
+			SR(dispc, OVL_BA0_UV(i));
+			SR(dispc, OVL_BA1_UV(i));
+			SR(dispc, OVL_FIR2(i));
+			SR(dispc, OVL_ACCU2_0(i));
+			SR(dispc, OVL_ACCU2_1(i));
 
 			for (j = 0; j < 8; j++)
-				SR(OVL_FIR_COEF_H2(i, j));
+				SR(dispc, OVL_FIR_COEF_H2(i, j));
 
 			for (j = 0; j < 8; j++)
-				SR(OVL_FIR_COEF_HV2(i, j));
+				SR(dispc, OVL_FIR_COEF_HV2(i, j));
 
 			for (j = 0; j < 8; j++)
-				SR(OVL_FIR_COEF_V2(i, j));
+				SR(dispc, OVL_FIR_COEF_V2(i, j));
 		}
-		if (dispc_has_feature(FEAT_ATTR2))
-			SR(OVL_ATTRIBUTES2(i));
+		if (dispc_has_feature(dispc, FEAT_ATTR2))
+			SR(dispc, OVL_ATTRIBUTES2(i));
 	}
 
-	if (dispc_has_feature(FEAT_CORE_CLK_DIV))
-		SR(DIVISOR);
+	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
+		SR(dispc, DIVISOR);
 
-	dispc.ctx_valid = true;
+	dispc->ctx_valid = true;
 
 	DSSDBG("context saved\n");
 }
 
-static void dispc_restore_context(void)
+static void dispc_restore_context(struct dispc_device *dispc)
 {
 	int i, j;
 
 	DSSDBG("dispc_restore_context\n");
 
-	if (!dispc.ctx_valid)
+	if (!dispc->ctx_valid)
 		return;
 
-	/*RR(IRQENABLE);*/
-	/*RR(CONTROL);*/
-	RR(CONFIG);
-	RR(LINE_NUMBER);
-	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
-			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
-		RR(GLOBAL_ALPHA);
-	if (dispc_has_feature(FEAT_MGR_LCD2))
-		RR(CONFIG2);
-	if (dispc_has_feature(FEAT_MGR_LCD3))
-		RR(CONFIG3);
-
-	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
-		RR(DEFAULT_COLOR(i));
-		RR(TRANS_COLOR(i));
-		RR(SIZE_MGR(i));
+	/*RR(dispc, IRQENABLE);*/
+	/*RR(dispc, CONTROL);*/
+	RR(dispc, CONFIG);
+	RR(dispc, LINE_NUMBER);
+	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
+			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
+		RR(dispc, GLOBAL_ALPHA);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
+		RR(dispc, CONFIG2);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
+		RR(dispc, CONFIG3);
+
+	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
+		RR(dispc, DEFAULT_COLOR(i));
+		RR(dispc, TRANS_COLOR(i));
+		RR(dispc, SIZE_MGR(i));
 		if (i == OMAP_DSS_CHANNEL_DIGIT)
 			continue;
-		RR(TIMING_H(i));
-		RR(TIMING_V(i));
-		RR(POL_FREQ(i));
-		RR(DIVISORo(i));
-
-		RR(DATA_CYCLE1(i));
-		RR(DATA_CYCLE2(i));
-		RR(DATA_CYCLE3(i));
-
-		if (dispc_has_feature(FEAT_CPR)) {
-			RR(CPR_COEF_R(i));
-			RR(CPR_COEF_G(i));
-			RR(CPR_COEF_B(i));
+		RR(dispc, TIMING_H(i));
+		RR(dispc, TIMING_V(i));
+		RR(dispc, POL_FREQ(i));
+		RR(dispc, DIVISORo(i));
+
+		RR(dispc, DATA_CYCLE1(i));
+		RR(dispc, DATA_CYCLE2(i));
+		RR(dispc, DATA_CYCLE3(i));
+
+		if (dispc_has_feature(dispc, FEAT_CPR)) {
+			RR(dispc, CPR_COEF_R(i));
+			RR(dispc, CPR_COEF_G(i));
+			RR(dispc, CPR_COEF_B(i));
 		}
 	}
 
-	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
-		RR(OVL_BA0(i));
-		RR(OVL_BA1(i));
-		RR(OVL_POSITION(i));
-		RR(OVL_SIZE(i));
-		RR(OVL_ATTRIBUTES(i));
-		RR(OVL_FIFO_THRESHOLD(i));
-		RR(OVL_ROW_INC(i));
-		RR(OVL_PIXEL_INC(i));
-		if (dispc_has_feature(FEAT_PRELOAD))
-			RR(OVL_PRELOAD(i));
+	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
+		RR(dispc, OVL_BA0(i));
+		RR(dispc, OVL_BA1(i));
+		RR(dispc, OVL_POSITION(i));
+		RR(dispc, OVL_SIZE(i));
+		RR(dispc, OVL_ATTRIBUTES(i));
+		RR(dispc, OVL_FIFO_THRESHOLD(i));
+		RR(dispc, OVL_ROW_INC(i));
+		RR(dispc, OVL_PIXEL_INC(i));
+		if (dispc_has_feature(dispc, FEAT_PRELOAD))
+			RR(dispc, OVL_PRELOAD(i));
 		if (i == OMAP_DSS_GFX) {
-			RR(OVL_WINDOW_SKIP(i));
-			RR(OVL_TABLE_BA(i));
+			RR(dispc, OVL_WINDOW_SKIP(i));
+			RR(dispc, OVL_TABLE_BA(i));
 			continue;
 		}
-		RR(OVL_FIR(i));
-		RR(OVL_PICTURE_SIZE(i));
-		RR(OVL_ACCU0(i));
-		RR(OVL_ACCU1(i));
+		RR(dispc, OVL_FIR(i));
+		RR(dispc, OVL_PICTURE_SIZE(i));
+		RR(dispc, OVL_ACCU0(i));
+		RR(dispc, OVL_ACCU1(i));
 
 		for (j = 0; j < 8; j++)
-			RR(OVL_FIR_COEF_H(i, j));
+			RR(dispc, OVL_FIR_COEF_H(i, j));
 
 		for (j = 0; j < 8; j++)
-			RR(OVL_FIR_COEF_HV(i, j));
+			RR(dispc, OVL_FIR_COEF_HV(i, j));
 
 		for (j = 0; j < 5; j++)
-			RR(OVL_CONV_COEF(i, j));
+			RR(dispc, OVL_CONV_COEF(i, j));
 
-		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
+		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
 			for (j = 0; j < 8; j++)
-				RR(OVL_FIR_COEF_V(i, j));
+				RR(dispc, OVL_FIR_COEF_V(i, j));
 		}
 
-		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
-			RR(OVL_BA0_UV(i));
-			RR(OVL_BA1_UV(i));
-			RR(OVL_FIR2(i));
-			RR(OVL_ACCU2_0(i));
-			RR(OVL_ACCU2_1(i));
+		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
+			RR(dispc, OVL_BA0_UV(i));
+			RR(dispc, OVL_BA1_UV(i));
+			RR(dispc, OVL_FIR2(i));
+			RR(dispc, OVL_ACCU2_0(i));
+			RR(dispc, OVL_ACCU2_1(i));
 
 			for (j = 0; j < 8; j++)
-				RR(OVL_FIR_COEF_H2(i, j));
+				RR(dispc, OVL_FIR_COEF_H2(i, j));
 
 			for (j = 0; j < 8; j++)
-				RR(OVL_FIR_COEF_HV2(i, j));
+				RR(dispc, OVL_FIR_COEF_HV2(i, j));
 
 			for (j = 0; j < 8; j++)
-				RR(OVL_FIR_COEF_V2(i, j));
+				RR(dispc, OVL_FIR_COEF_V2(i, j));
 		}
-		if (dispc_has_feature(FEAT_ATTR2))
-			RR(OVL_ATTRIBUTES2(i));
+		if (dispc_has_feature(dispc, FEAT_ATTR2))
+			RR(dispc, OVL_ATTRIBUTES2(i));
 	}
 
-	if (dispc_has_feature(FEAT_CORE_CLK_DIV))
-		RR(DIVISOR);
+	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
+		RR(dispc, DIVISOR);
 
 	/* enable last, because LCD & DIGIT enable are here */
-	RR(CONTROL);
-	if (dispc_has_feature(FEAT_MGR_LCD2))
-		RR(CONTROL2);
-	if (dispc_has_feature(FEAT_MGR_LCD3))
-		RR(CONTROL3);
+	RR(dispc, CONTROL);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
+		RR(dispc, CONTROL2);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
+		RR(dispc, CONTROL3);
 	/* clear spurious SYNC_LOST_DIGIT interrupts */
-	dispc_clear_irqstatus(&dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
+	dispc_clear_irqstatus(dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
 
 	/*
 	 * enable last so IRQs won't trigger before
 	 * the context is fully restored
 	 */
-	RR(IRQENABLE);
+	RR(dispc, IRQENABLE);
 
 	DSSDBG("context restored\n");
 }
@@ -714,21 +725,21 @@ u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
 static void dispc_mgr_enable(struct dispc_device *dispc,
 			     enum omap_channel channel, bool enable)
 {
-	mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
 	/* flush posted write */
-	mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
+	mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
 }
 
 static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
 				 enum omap_channel channel)
 {
-	return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
+	return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
 }
 
 static bool dispc_mgr_go_busy(struct dispc_device *dispc,
 			      enum omap_channel channel)
 {
-	return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1;
+	return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
 }
 
 static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
@@ -738,12 +749,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 
 	DSSDBG("GO %s\n", mgr_desc[channel].name);
 
-	mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
 }
 
 bool dispc_wb_go_busy(struct dispc_device *dispc)
 {
-	return REG_GET(DISPC_CONTROL2, 6, 6) == 1;
+	return REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
 }
 
 void dispc_wb_go(struct dispc_device *dispc)
@@ -751,65 +762,72 @@ void dispc_wb_go(struct dispc_device *dispc)
 	enum omap_plane_id plane = OMAP_DSS_WB;
 	bool enable, go;
 
-	enable = REG_GET(DISPC_OVL_ATTRIBUTES(plane), 0, 0) == 1;
+	enable = REG_GET(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 0) == 1;
 
 	if (!enable)
 		return;
 
-	go = REG_GET(DISPC_CONTROL2, 6, 6) == 1;
+	go = REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
 	if (go) {
 		DSSERR("GO bit not down for WB\n");
 		return;
 	}
 
-	REG_FLD_MOD(DISPC_CONTROL2, 1, 6, 6);
+	REG_FLD_MOD(dispc, DISPC_CONTROL2, 1, 6, 6);
 }
 
-static void dispc_ovl_write_firh_reg(enum omap_plane_id plane, int reg,
+static void dispc_ovl_write_firh_reg(struct dispc_device *dispc,
+				     enum omap_plane_id plane, int reg,
 				     u32 value)
 {
-	dispc_write_reg(DISPC_OVL_FIR_COEF_H(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H(plane, reg), value);
 }
 
-static void dispc_ovl_write_firhv_reg(enum omap_plane_id plane, int reg,
+static void dispc_ovl_write_firhv_reg(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int reg,
 				      u32 value)
 {
-	dispc_write_reg(DISPC_OVL_FIR_COEF_HV(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV(plane, reg), value);
 }
 
-static void dispc_ovl_write_firv_reg(enum omap_plane_id plane, int reg,
+static void dispc_ovl_write_firv_reg(struct dispc_device *dispc,
+				     enum omap_plane_id plane, int reg,
 				     u32 value)
 {
-	dispc_write_reg(DISPC_OVL_FIR_COEF_V(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V(plane, reg), value);
 }
 
-static void dispc_ovl_write_firh2_reg(enum omap_plane_id plane, int reg,
+static void dispc_ovl_write_firh2_reg(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int reg,
 				      u32 value)
 {
 	BUG_ON(plane == OMAP_DSS_GFX);
 
-	dispc_write_reg(DISPC_OVL_FIR_COEF_H2(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H2(plane, reg), value);
 }
 
-static void dispc_ovl_write_firhv2_reg(enum omap_plane_id plane, int reg,
-		u32 value)
+static void dispc_ovl_write_firhv2_reg(struct dispc_device *dispc,
+				       enum omap_plane_id plane, int reg,
+				       u32 value)
 {
 	BUG_ON(plane == OMAP_DSS_GFX);
 
-	dispc_write_reg(DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
 }
 
-static void dispc_ovl_write_firv2_reg(enum omap_plane_id plane, int reg,
+static void dispc_ovl_write_firv2_reg(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int reg,
 				      u32 value)
 {
 	BUG_ON(plane == OMAP_DSS_GFX);
 
-	dispc_write_reg(DISPC_OVL_FIR_COEF_V2(plane, reg), value);
+	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V2(plane, reg), value);
 }
 
-static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
-				int fir_vinc, int five_taps,
-				enum omap_color_component color_comp)
+static void dispc_ovl_set_scale_coef(struct dispc_device *dispc,
+				     enum omap_plane_id plane, int fir_hinc,
+				     int fir_vinc, int five_taps,
+				     enum omap_color_component color_comp)
 {
 	const struct dispc_coef *h_coef, *v_coef;
 	int i;
@@ -830,11 +848,11 @@ static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
 			| FLD_VAL(v_coef[i].hc3_vc2, 31, 24);
 
 		if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
-			dispc_ovl_write_firh_reg(plane, i, h);
-			dispc_ovl_write_firhv_reg(plane, i, hv);
+			dispc_ovl_write_firh_reg(dispc, plane, i, h);
+			dispc_ovl_write_firhv_reg(dispc, plane, i, hv);
 		} else {
-			dispc_ovl_write_firh2_reg(plane, i, h);
-			dispc_ovl_write_firhv2_reg(plane, i, hv);
+			dispc_ovl_write_firh2_reg(dispc, plane, i, h);
+			dispc_ovl_write_firhv2_reg(dispc, plane, i, hv);
 		}
 
 	}
@@ -845,34 +863,35 @@ static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
 			v = FLD_VAL(v_coef[i].hc0_vc00, 7, 0)
 				| FLD_VAL(v_coef[i].hc4_vc22, 15, 8);
 			if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y)
-				dispc_ovl_write_firv_reg(plane, i, v);
+				dispc_ovl_write_firv_reg(dispc, plane, i, v);
 			else
-				dispc_ovl_write_firv2_reg(plane, i, v);
+				dispc_ovl_write_firv2_reg(dispc, plane, i, v);
 		}
 	}
 }
 
 
-static void dispc_ovl_write_color_conv_coef(enum omap_plane_id plane,
-		const struct color_conv_coef *ct)
+static void dispc_ovl_write_color_conv_coef(struct dispc_device *dispc,
+					    enum omap_plane_id plane,
+					    const struct color_conv_coef *ct)
 {
 #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
 
-	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->rcr, ct->ry));
-	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->gy,  ct->rcb));
-	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->gcb, ct->gcr));
-	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->bcr, ct->by));
-	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->bcb));
+	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->rcr, ct->ry));
+	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->gy,  ct->rcb));
+	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->gcb, ct->gcr));
+	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->bcr, ct->by));
+	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->bcb));
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
 
 #undef CVAL
 }
 
-static void dispc_setup_color_conv_coef(void)
+static void dispc_setup_color_conv_coef(struct dispc_device *dispc)
 {
 	int i;
-	int num_ovl = dispc_get_num_ovls(&dispc);
+	int num_ovl = dispc_get_num_ovls(dispc);
 	const struct color_conv_coef ctbl_bt601_5_ovl = {
 		/* YUV -> RGB */
 		298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
@@ -883,34 +902,40 @@ static void dispc_setup_color_conv_coef(void)
 	};
 
 	for (i = 1; i < num_ovl; i++)
-		dispc_ovl_write_color_conv_coef(i, &ctbl_bt601_5_ovl);
+		dispc_ovl_write_color_conv_coef(dispc, i, &ctbl_bt601_5_ovl);
 
-	if (dispc.feat->has_writeback)
-		dispc_ovl_write_color_conv_coef(OMAP_DSS_WB, &ctbl_bt601_5_wb);
+	if (dispc->feat->has_writeback)
+		dispc_ovl_write_color_conv_coef(dispc, OMAP_DSS_WB,
+						&ctbl_bt601_5_wb);
 }
 
-static void dispc_ovl_set_ba0(enum omap_plane_id plane, u32 paddr)
+static void dispc_ovl_set_ba0(struct dispc_device *dispc,
+			      enum omap_plane_id plane, u32 paddr)
 {
-	dispc_write_reg(DISPC_OVL_BA0(plane), paddr);
+	dispc_write_reg(dispc, DISPC_OVL_BA0(plane), paddr);
 }
 
-static void dispc_ovl_set_ba1(enum omap_plane_id plane, u32 paddr)
+static void dispc_ovl_set_ba1(struct dispc_device *dispc,
+			      enum omap_plane_id plane, u32 paddr)
 {
-	dispc_write_reg(DISPC_OVL_BA1(plane), paddr);
+	dispc_write_reg(dispc, DISPC_OVL_BA1(plane), paddr);
 }
 
-static void dispc_ovl_set_ba0_uv(enum omap_plane_id plane, u32 paddr)
+static void dispc_ovl_set_ba0_uv(struct dispc_device *dispc,
+				 enum omap_plane_id plane, u32 paddr)
 {
-	dispc_write_reg(DISPC_OVL_BA0_UV(plane), paddr);
+	dispc_write_reg(dispc, DISPC_OVL_BA0_UV(plane), paddr);
 }
 
-static void dispc_ovl_set_ba1_uv(enum omap_plane_id plane, u32 paddr)
+static void dispc_ovl_set_ba1_uv(struct dispc_device *dispc,
+				 enum omap_plane_id plane, u32 paddr)
 {
-	dispc_write_reg(DISPC_OVL_BA1_UV(plane), paddr);
+	dispc_write_reg(dispc, DISPC_OVL_BA1_UV(plane), paddr);
 }
 
-static void dispc_ovl_set_pos(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, int x, int y)
+static void dispc_ovl_set_pos(struct dispc_device *dispc,
+			      enum omap_plane_id plane,
+			      enum omap_overlay_caps caps, int x, int y)
 {
 	u32 val;
 
@@ -919,22 +944,24 @@ static void dispc_ovl_set_pos(enum omap_plane_id plane,
 
 	val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0);
 
-	dispc_write_reg(DISPC_OVL_POSITION(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_POSITION(plane), val);
 }
 
-static void dispc_ovl_set_input_size(enum omap_plane_id plane, int width,
-		int height)
+static void dispc_ovl_set_input_size(struct dispc_device *dispc,
+				     enum omap_plane_id plane, int width,
+				     int height)
 {
 	u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
 
 	if (plane == OMAP_DSS_GFX || plane == OMAP_DSS_WB)
-		dispc_write_reg(DISPC_OVL_SIZE(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
 	else
-		dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
 }
 
-static void dispc_ovl_set_output_size(enum omap_plane_id plane, int width,
-		int height)
+static void dispc_ovl_set_output_size(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int width,
+				      int height)
 {
 	u32 val;
 
@@ -943,42 +970,47 @@ static void dispc_ovl_set_output_size(enum omap_plane_id plane, int width,
 	val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
 
 	if (plane == OMAP_DSS_WB)
-		dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
 	else
-		dispc_write_reg(DISPC_OVL_SIZE(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
 }
 
-static void dispc_ovl_set_zorder(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, u8 zorder)
+static void dispc_ovl_set_zorder(struct dispc_device *dispc,
+				 enum omap_plane_id plane,
+				 enum omap_overlay_caps caps, u8 zorder)
 {
 	if ((caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
 		return;
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
 }
 
-static void dispc_ovl_enable_zorder_planes(void)
+static void dispc_ovl_enable_zorder_planes(struct dispc_device *dispc)
 {
 	int i;
 
-	if (!dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
+	if (!dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
 		return;
 
-	for (i = 0; i < dispc_get_num_ovls(&dispc); i++)
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
+	for (i = 0; i < dispc_get_num_ovls(dispc); i++)
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
 }
 
-static void dispc_ovl_set_pre_mult_alpha(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, bool enable)
+static void dispc_ovl_set_pre_mult_alpha(struct dispc_device *dispc,
+					 enum omap_plane_id plane,
+					 enum omap_overlay_caps caps,
+					 bool enable)
 {
 	if ((caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
 		return;
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
 }
 
-static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, u8 global_alpha)
+static void dispc_ovl_setup_global_alpha(struct dispc_device *dispc,
+					 enum omap_plane_id plane,
+					 enum omap_overlay_caps caps,
+					 u8 global_alpha)
 {
 	static const unsigned int shifts[] = { 0, 8, 16, 24, };
 	int shift;
@@ -987,20 +1019,23 @@ static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
 		return;
 
 	shift = shifts[plane];
-	REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
+	REG_FLD_MOD(dispc, DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
 }
 
-static void dispc_ovl_set_pix_inc(enum omap_plane_id plane, s32 inc)
+static void dispc_ovl_set_pix_inc(struct dispc_device *dispc,
+				  enum omap_plane_id plane, s32 inc)
 {
-	dispc_write_reg(DISPC_OVL_PIXEL_INC(plane), inc);
+	dispc_write_reg(dispc, DISPC_OVL_PIXEL_INC(plane), inc);
 }
 
-static void dispc_ovl_set_row_inc(enum omap_plane_id plane, s32 inc)
+static void dispc_ovl_set_row_inc(struct dispc_device *dispc,
+				  enum omap_plane_id plane, s32 inc)
 {
-	dispc_write_reg(DISPC_OVL_ROW_INC(plane), inc);
+	dispc_write_reg(dispc, DISPC_OVL_ROW_INC(plane), inc);
 }
 
-static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 fourcc)
+static void dispc_ovl_set_color_mode(struct dispc_device *dispc,
+				     enum omap_plane_id plane, u32 fourcc)
 {
 	u32 m = 0;
 	if (plane != OMAP_DSS_GFX) {
@@ -1069,7 +1104,7 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 fourcc)
 		}
 	}
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
 }
 
 static bool format_is_yuv(u32 fourcc)
@@ -1084,19 +1119,21 @@ static bool format_is_yuv(u32 fourcc)
 	}
 }
 
-static void dispc_ovl_configure_burst_type(enum omap_plane_id plane,
-		enum omap_dss_rotation_type rotation_type)
+static void dispc_ovl_configure_burst_type(struct dispc_device *dispc,
+					   enum omap_plane_id plane,
+					   enum omap_dss_rotation_type rotation)
 {
-	if (dispc_has_feature(FEAT_BURST_2D) == 0)
+	if (dispc_has_feature(dispc, FEAT_BURST_2D) == 0)
 		return;
 
-	if (rotation_type == OMAP_DSS_ROT_TILER)
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29);
+	if (rotation == OMAP_DSS_ROT_TILER)
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29);
 	else
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29);
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29);
 }
 
-static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
+static void dispc_ovl_set_channel_out(struct dispc_device *dispc,
+				      enum omap_plane_id plane,
 				      enum omap_channel channel)
 {
 	int shift;
@@ -1117,8 +1154,8 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
 		return;
 	}
 
-	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
-	if (dispc_has_feature(FEAT_MGR_LCD2)) {
+	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
 		switch (channel) {
 		case OMAP_DSS_CHANNEL_LCD:
 			chan = 0;
@@ -1133,7 +1170,7 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
 			chan2 = 1;
 			break;
 		case OMAP_DSS_CHANNEL_LCD3:
-			if (dispc_has_feature(FEAT_MGR_LCD3)) {
+			if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
 				chan = 0;
 				chan2 = 2;
 			} else {
@@ -1155,10 +1192,11 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
 	} else {
 		val = FLD_MOD(val, channel, shift, shift);
 	}
-	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
 }
 
-static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
+static enum omap_channel dispc_ovl_get_channel_out(struct dispc_device *dispc,
+						   enum omap_plane_id plane)
 {
 	int shift;
 	u32 val;
@@ -1177,12 +1215,12 @@ static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
 		return 0;
 	}
 
-	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
+	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
 
 	if (FLD_GET(val, shift, shift) == 1)
 		return OMAP_DSS_CHANNEL_DIGIT;
 
-	if (!dispc_has_feature(FEAT_MGR_LCD2))
+	if (!dispc_has_feature(dispc, FEAT_MGR_LCD2))
 		return OMAP_DSS_CHANNEL_LCD;
 
 	switch (FLD_GET(val, 31, 30)) {
@@ -1203,43 +1241,47 @@ void dispc_wb_set_channel_in(struct dispc_device *dispc,
 {
 	enum omap_plane_id plane = OMAP_DSS_WB;
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), channel, 18, 16);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), channel, 18, 16);
 }
 
-static void dispc_ovl_set_burst_size(enum omap_plane_id plane,
-		enum omap_burst_size burst_size)
+static void dispc_ovl_set_burst_size(struct dispc_device *dispc,
+				     enum omap_plane_id plane,
+				     enum omap_burst_size burst_size)
 {
 	static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
 	int shift;
 
 	shift = shifts[plane];
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), burst_size,
+		    shift + 1, shift);
 }
 
-static void dispc_configure_burst_sizes(void)
+static void dispc_configure_burst_sizes(struct dispc_device *dispc)
 {
 	int i;
 	const int burst_size = BURST_SIZE_X8;
 
 	/* Configure burst size always to maximum size */
-	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
-		dispc_ovl_set_burst_size(i, burst_size);
-	if (dispc.feat->has_writeback)
-		dispc_ovl_set_burst_size(OMAP_DSS_WB, burst_size);
+	for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
+		dispc_ovl_set_burst_size(dispc, i, burst_size);
+	if (dispc->feat->has_writeback)
+		dispc_ovl_set_burst_size(dispc, OMAP_DSS_WB, burst_size);
 }
 
-static u32 dispc_ovl_get_burst_size(enum omap_plane_id plane)
+static u32 dispc_ovl_get_burst_size(struct dispc_device *dispc,
+				    enum omap_plane_id plane)
 {
 	/* burst multiplier is always x8 (see dispc_configure_burst_sizes()) */
-	return dispc.feat->burst_size_unit * 8;
+	return dispc->feat->burst_size_unit * 8;
 }
 
-static bool dispc_ovl_color_mode_supported(enum omap_plane_id plane, u32 fourcc)
+static bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
+					   enum omap_plane_id plane, u32 fourcc)
 {
 	const u32 *modes;
 	unsigned int i;
 
-	modes = dispc.feat->supported_color_modes[plane];
+	modes = dispc->feat->supported_color_modes[plane];
 
 	for (i = 0; modes[i]; ++i) {
 		if (modes[i] == fourcc)
@@ -1255,16 +1297,18 @@ static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
 	return dispc->feat->supported_color_modes[plane];
 }
 
-static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable)
+static void dispc_mgr_enable_cpr(struct dispc_device *dispc,
+				 enum omap_channel channel, bool enable)
 {
 	if (channel == OMAP_DSS_CHANNEL_DIGIT)
 		return;
 
-	mgr_fld_write(channel, DISPC_MGR_FLD_CPR, enable);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_CPR, enable);
 }
 
-static void dispc_mgr_set_cpr_coef(enum omap_channel channel,
-		const struct omap_dss_cpr_coefs *coefs)
+static void dispc_mgr_set_cpr_coef(struct dispc_device *dispc,
+				   enum omap_channel channel,
+				   const struct omap_dss_cpr_coefs *coefs)
 {
 	u32 coef_r, coef_g, coef_b;
 
@@ -1278,25 +1322,27 @@ static void dispc_mgr_set_cpr_coef(enum omap_channel channel,
 	coef_b = FLD_VAL(coefs->br, 31, 22) | FLD_VAL(coefs->bg, 20, 11) |
 		FLD_VAL(coefs->bb, 9, 0);
 
-	dispc_write_reg(DISPC_CPR_COEF_R(channel), coef_r);
-	dispc_write_reg(DISPC_CPR_COEF_G(channel), coef_g);
-	dispc_write_reg(DISPC_CPR_COEF_B(channel), coef_b);
+	dispc_write_reg(dispc, DISPC_CPR_COEF_R(channel), coef_r);
+	dispc_write_reg(dispc, DISPC_CPR_COEF_G(channel), coef_g);
+	dispc_write_reg(dispc, DISPC_CPR_COEF_B(channel), coef_b);
 }
 
-static void dispc_ovl_set_vid_color_conv(enum omap_plane_id plane,
-					 bool enable)
+static void dispc_ovl_set_vid_color_conv(struct dispc_device *dispc,
+					 enum omap_plane_id plane, bool enable)
 {
 	u32 val;
 
 	BUG_ON(plane == OMAP_DSS_GFX);
 
-	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
+	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
 	val = FLD_MOD(val, enable, 9, 9);
-	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
 }
 
-static void dispc_ovl_enable_replication(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, bool enable)
+static void dispc_ovl_enable_replication(struct dispc_device *dispc,
+					 enum omap_plane_id plane,
+					 enum omap_overlay_caps caps,
+					 bool enable)
 {
 	static const unsigned int shifts[] = { 5, 10, 10, 10 };
 	int shift;
@@ -1305,21 +1351,21 @@ static void dispc_ovl_enable_replication(enum omap_plane_id plane,
 		return;
 
 	shift = shifts[plane];
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
 }
 
-static void dispc_mgr_set_size(enum omap_channel channel, u16 width,
-		u16 height)
+static void dispc_mgr_set_size(struct dispc_device *dispc,
+			       enum omap_channel channel, u16 width, u16 height)
 {
 	u32 val;
 
-	val = FLD_VAL(height - 1, dispc.feat->mgr_height_start, 16) |
-		FLD_VAL(width - 1, dispc.feat->mgr_width_start, 0);
+	val = FLD_VAL(height - 1, dispc->feat->mgr_height_start, 16) |
+		FLD_VAL(width - 1, dispc->feat->mgr_width_start, 0);
 
-	dispc_write_reg(DISPC_SIZE_MGR(channel), val);
+	dispc_write_reg(dispc, DISPC_SIZE_MGR(channel), val);
 }
 
-static void dispc_init_fifos(void)
+static void dispc_init_fifos(struct dispc_device *dispc)
 {
 	u32 size;
 	int fifo;
@@ -1327,20 +1373,21 @@ static void dispc_init_fifos(void)
 	u32 unit;
 	int i;
 
-	unit = dispc.feat->buffer_size_unit;
+	unit = dispc->feat->buffer_size_unit;
 
-	dispc_get_reg_field(FEAT_REG_FIFOSIZE, &start, &end);
+	dispc_get_reg_field(dispc, FEAT_REG_FIFOSIZE, &start, &end);
 
-	for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
-		size = REG_GET(DISPC_OVL_FIFO_SIZE_STATUS(fifo), start, end);
+	for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
+		size = REG_GET(dispc, DISPC_OVL_FIFO_SIZE_STATUS(fifo),
+			       start, end);
 		size *= unit;
-		dispc.fifo_size[fifo] = size;
+		dispc->fifo_size[fifo] = size;
 
 		/*
 		 * By default fifos are mapped directly to overlays, fifo 0 to
 		 * ovl 0, fifo 1 to ovl 1, etc.
 		 */
-		dispc.fifo_assignment[fifo] = fifo;
+		dispc->fifo_assignment[fifo] = fifo;
 	}
 
 	/*
@@ -1350,57 +1397,58 @@ static void dispc_init_fifos(void)
 	 * giving GFX plane a larger fifo. WB but should work fine with a
 	 * smaller fifo.
 	 */
-	if (dispc.feat->gfx_fifo_workaround) {
+	if (dispc->feat->gfx_fifo_workaround) {
 		u32 v;
 
-		v = dispc_read_reg(DISPC_GLOBAL_BUFFER);
+		v = dispc_read_reg(dispc, DISPC_GLOBAL_BUFFER);
 
 		v = FLD_MOD(v, 4, 2, 0); /* GFX BUF top to WB */
 		v = FLD_MOD(v, 4, 5, 3); /* GFX BUF bottom to WB */
 		v = FLD_MOD(v, 0, 26, 24); /* WB BUF top to GFX */
 		v = FLD_MOD(v, 0, 29, 27); /* WB BUF bottom to GFX */
 
-		dispc_write_reg(DISPC_GLOBAL_BUFFER, v);
+		dispc_write_reg(dispc, DISPC_GLOBAL_BUFFER, v);
 
-		dispc.fifo_assignment[OMAP_DSS_GFX] = OMAP_DSS_WB;
-		dispc.fifo_assignment[OMAP_DSS_WB] = OMAP_DSS_GFX;
+		dispc->fifo_assignment[OMAP_DSS_GFX] = OMAP_DSS_WB;
+		dispc->fifo_assignment[OMAP_DSS_WB] = OMAP_DSS_GFX;
 	}
 
 	/*
 	 * Setup default fifo thresholds.
 	 */
-	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
+	for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
 		u32 low, high;
 		const bool use_fifomerge = false;
 		const bool manual_update = false;
 
-		dispc_ovl_compute_fifo_thresholds(&dispc, i, &low, &high,
-			use_fifomerge, manual_update);
+		dispc_ovl_compute_fifo_thresholds(dispc, i, &low, &high,
+						  use_fifomerge, manual_update);
 
-		dispc_ovl_set_fifo_threshold(&dispc, i, low, high);
+		dispc_ovl_set_fifo_threshold(dispc, i, low, high);
 	}
 
-	if (dispc.feat->has_writeback) {
+	if (dispc->feat->has_writeback) {
 		u32 low, high;
 		const bool use_fifomerge = false;
 		const bool manual_update = false;
 
-		dispc_ovl_compute_fifo_thresholds(&dispc, OMAP_DSS_WB,
-						  &low, &high,
-						  use_fifomerge, manual_update);
+		dispc_ovl_compute_fifo_thresholds(dispc, OMAP_DSS_WB,
+						  &low, &high, use_fifomerge,
+						  manual_update);
 
-		dispc_ovl_set_fifo_threshold(&dispc, OMAP_DSS_WB, low, high);
+		dispc_ovl_set_fifo_threshold(dispc, OMAP_DSS_WB, low, high);
 	}
 }
 
-static u32 dispc_ovl_get_fifo_size(enum omap_plane_id plane)
+static u32 dispc_ovl_get_fifo_size(struct dispc_device *dispc,
+				   enum omap_plane_id plane)
 {
 	int fifo;
 	u32 size = 0;
 
-	for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
-		if (dispc.fifo_assignment[fifo] == plane)
-			size += dispc.fifo_size[fifo];
+	for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
+		if (dispc->fifo_assignment[fifo] == plane)
+			size += dispc->fifo_size[fifo];
 	}
 
 	return size;
@@ -1421,18 +1469,20 @@ void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
 	low /= unit;
 	high /= unit;
 
-	dispc_get_reg_field(FEAT_REG_FIFOHIGHTHRESHOLD, &hi_start, &hi_end);
-	dispc_get_reg_field(FEAT_REG_FIFOLOWTHRESHOLD, &lo_start, &lo_end);
+	dispc_get_reg_field(dispc, FEAT_REG_FIFOHIGHTHRESHOLD,
+			    &hi_start, &hi_end);
+	dispc_get_reg_field(dispc, FEAT_REG_FIFOLOWTHRESHOLD,
+			    &lo_start, &lo_end);
 
 	DSSDBG("fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n",
 			plane,
-			REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
+			REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
 				lo_start, lo_end) * unit,
-			REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
+			REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
 				hi_start, hi_end) * unit,
 			low * unit, high * unit);
 
-	dispc_write_reg(DISPC_OVL_FIFO_THRESHOLD(plane),
+	dispc_write_reg(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
 			FLD_VAL(high, hi_start, hi_end) |
 			FLD_VAL(low, lo_start, lo_end));
 
@@ -1441,20 +1491,20 @@ void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
 	 * large for the preload field, set the threshold to the maximum value
 	 * that can be held by the preload register
 	 */
-	if (dispc_has_feature(FEAT_PRELOAD) && dispc->feat->set_max_preload &&
-			plane != OMAP_DSS_WB)
-		dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
+	if (dispc_has_feature(dispc, FEAT_PRELOAD) &&
+	    dispc->feat->set_max_preload && plane != OMAP_DSS_WB)
+		dispc_write_reg(dispc, DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
 }
 
 void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
 {
-	if (!dispc_has_feature(FEAT_FIFO_MERGE)) {
+	if (!dispc_has_feature(dispc, FEAT_FIFO_MERGE)) {
 		WARN_ON(enable);
 		return;
 	}
 
 	DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
-	REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
+	REG_FLD_MOD(dispc, DISPC_CONFIG, enable ? 1 : 0, 14, 14);
 }
 
 void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
@@ -1470,13 +1520,13 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
 	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
 	int i;
 
-	burst_size = dispc_ovl_get_burst_size(plane);
-	ovl_fifo_size = dispc_ovl_get_fifo_size(plane);
+	burst_size = dispc_ovl_get_burst_size(dispc, plane);
+	ovl_fifo_size = dispc_ovl_get_fifo_size(dispc, plane);
 
 	if (use_fifomerge) {
 		total_fifo_size = 0;
 		for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
-			total_fifo_size += dispc_ovl_get_fifo_size(i);
+			total_fifo_size += dispc_ovl_get_fifo_size(dispc, i);
 	} else {
 		total_fifo_size = ovl_fifo_size;
 	}
@@ -1487,7 +1537,7 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
 	 * combined fifo size
 	 */
 
-	if (manual_update && dispc_has_feature(FEAT_OMAP3_DSI_FIFO_BUG)) {
+	if (manual_update && dispc_has_feature(dispc, FEAT_OMAP3_DSI_FIFO_BUG)) {
 		*fifo_low = ovl_fifo_size - burst_size * 2;
 		*fifo_high = total_fifo_size - burst_size;
 	} else if (plane == OMAP_DSS_WB) {
@@ -1504,7 +1554,8 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
 	}
 }
 
-static void dispc_ovl_set_mflag(enum omap_plane_id plane, bool enable)
+static void dispc_ovl_set_mflag(struct dispc_device *dispc,
+				enum omap_plane_id plane, bool enable)
 {
 	int bit;
 
@@ -1513,17 +1564,18 @@ static void dispc_ovl_set_mflag(enum omap_plane_id plane, bool enable)
 	else
 		bit = 23;
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit);
 }
 
-static void dispc_ovl_set_mflag_threshold(enum omap_plane_id plane,
-	int low, int high)
+static void dispc_ovl_set_mflag_threshold(struct dispc_device *dispc,
+					  enum omap_plane_id plane,
+					  int low, int high)
 {
-	dispc_write_reg(DISPC_OVL_MFLAG_THRESHOLD(plane),
+	dispc_write_reg(dispc, DISPC_OVL_MFLAG_THRESHOLD(plane),
 		FLD_VAL(high, 31, 16) |	FLD_VAL(low, 15, 0));
 }
 
-static void dispc_init_mflag(void)
+static void dispc_init_mflag(struct dispc_device *dispc)
 {
 	int i;
 
@@ -1537,16 +1589,16 @@ static void dispc_init_mflag(void)
 	 *
 	 * As a work-around, set force MFLAG to always on.
 	 */
-	dispc_write_reg(DISPC_GLOBAL_MFLAG_ATTRIBUTE,
+	dispc_write_reg(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE,
 		(1 << 0) |	/* MFLAG_CTRL = force always on */
 		(0 << 2));	/* MFLAG_START = disable */
 
-	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
-		u32 size = dispc_ovl_get_fifo_size(i);
-		u32 unit = dispc.feat->buffer_size_unit;
+	for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
+		u32 size = dispc_ovl_get_fifo_size(dispc, i);
+		u32 unit = dispc->feat->buffer_size_unit;
 		u32 low, high;
 
-		dispc_ovl_set_mflag(i, true);
+		dispc_ovl_set_mflag(dispc, i, true);
 
 		/*
 		 * Simulation team suggests below thesholds:
@@ -1557,15 +1609,15 @@ static void dispc_init_mflag(void)
 		low = size * 4 / 8 / unit;
 		high = size * 5 / 8 / unit;
 
-		dispc_ovl_set_mflag_threshold(i, low, high);
+		dispc_ovl_set_mflag_threshold(dispc, i, low, high);
 	}
 
-	if (dispc.feat->has_writeback) {
-		u32 size = dispc_ovl_get_fifo_size(OMAP_DSS_WB);
-		u32 unit = dispc.feat->buffer_size_unit;
+	if (dispc->feat->has_writeback) {
+		u32 size = dispc_ovl_get_fifo_size(dispc, OMAP_DSS_WB);
+		u32 unit = dispc->feat->buffer_size_unit;
 		u32 low, high;
 
-		dispc_ovl_set_mflag(OMAP_DSS_WB, true);
+		dispc_ovl_set_mflag(dispc, OMAP_DSS_WB, true);
 
 		/*
 		 * Simulation team suggests below thesholds:
@@ -1576,98 +1628,112 @@ static void dispc_init_mflag(void)
 		low = size * 4 / 8 / unit;
 		high = size * 5 / 8 / unit;
 
-		dispc_ovl_set_mflag_threshold(OMAP_DSS_WB, low, high);
+		dispc_ovl_set_mflag_threshold(dispc, OMAP_DSS_WB, low, high);
 	}
 }
 
-static void dispc_ovl_set_fir(enum omap_plane_id plane,
-				int hinc, int vinc,
-				enum omap_color_component color_comp)
+static void dispc_ovl_set_fir(struct dispc_device *dispc,
+			      enum omap_plane_id plane,
+			      int hinc, int vinc,
+			      enum omap_color_component color_comp)
 {
 	u32 val;
 
 	if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
 		u8 hinc_start, hinc_end, vinc_start, vinc_end;
 
-		dispc_get_reg_field(FEAT_REG_FIRHINC, &hinc_start, &hinc_end);
-		dispc_get_reg_field(FEAT_REG_FIRVINC, &vinc_start, &vinc_end);
+		dispc_get_reg_field(dispc, FEAT_REG_FIRHINC,
+				    &hinc_start, &hinc_end);
+		dispc_get_reg_field(dispc, FEAT_REG_FIRVINC,
+				    &vinc_start, &vinc_end);
 		val = FLD_VAL(vinc, vinc_start, vinc_end) |
 				FLD_VAL(hinc, hinc_start, hinc_end);
 
-		dispc_write_reg(DISPC_OVL_FIR(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_FIR(plane), val);
 	} else {
 		val = FLD_VAL(vinc, 28, 16) | FLD_VAL(hinc, 12, 0);
-		dispc_write_reg(DISPC_OVL_FIR2(plane), val);
+		dispc_write_reg(dispc, DISPC_OVL_FIR2(plane), val);
 	}
 }
 
-static void dispc_ovl_set_vid_accu0(enum omap_plane_id plane, int haccu,
+static void dispc_ovl_set_vid_accu0(struct dispc_device *dispc,
+				    enum omap_plane_id plane, int haccu,
 				    int vaccu)
 {
 	u32 val;
 	u8 hor_start, hor_end, vert_start, vert_end;
 
-	dispc_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
-	dispc_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
+	dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
+			    &hor_start, &hor_end);
+	dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
+			    &vert_start, &vert_end);
 
 	val = FLD_VAL(vaccu, vert_start, vert_end) |
 			FLD_VAL(haccu, hor_start, hor_end);
 
-	dispc_write_reg(DISPC_OVL_ACCU0(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ACCU0(plane), val);
 }
 
-static void dispc_ovl_set_vid_accu1(enum omap_plane_id plane, int haccu,
+static void dispc_ovl_set_vid_accu1(struct dispc_device *dispc,
+				    enum omap_plane_id plane, int haccu,
 				    int vaccu)
 {
 	u32 val;
 	u8 hor_start, hor_end, vert_start, vert_end;
 
-	dispc_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
-	dispc_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
+	dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
+			    &hor_start, &hor_end);
+	dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
+			    &vert_start, &vert_end);
 
 	val = FLD_VAL(vaccu, vert_start, vert_end) |
 			FLD_VAL(haccu, hor_start, hor_end);
 
-	dispc_write_reg(DISPC_OVL_ACCU1(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ACCU1(plane), val);
 }
 
-static void dispc_ovl_set_vid_accu2_0(enum omap_plane_id plane, int haccu,
-		int vaccu)
+static void dispc_ovl_set_vid_accu2_0(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int haccu,
+				      int vaccu)
 {
 	u32 val;
 
 	val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
-	dispc_write_reg(DISPC_OVL_ACCU2_0(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ACCU2_0(plane), val);
 }
 
-static void dispc_ovl_set_vid_accu2_1(enum omap_plane_id plane, int haccu,
-		int vaccu)
+static void dispc_ovl_set_vid_accu2_1(struct dispc_device *dispc,
+				      enum omap_plane_id plane, int haccu,
+				      int vaccu)
 {
 	u32 val;
 
 	val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
-	dispc_write_reg(DISPC_OVL_ACCU2_1(plane), val);
+	dispc_write_reg(dispc, DISPC_OVL_ACCU2_1(plane), val);
 }
 
-static void dispc_ovl_set_scale_param(enum omap_plane_id plane,
-		u16 orig_width, u16 orig_height,
-		u16 out_width, u16 out_height,
-		bool five_taps, u8 rotation,
-		enum omap_color_component color_comp)
+static void dispc_ovl_set_scale_param(struct dispc_device *dispc,
+				      enum omap_plane_id plane,
+				      u16 orig_width, u16 orig_height,
+				      u16 out_width, u16 out_height,
+				      bool five_taps, u8 rotation,
+				      enum omap_color_component color_comp)
 {
 	int fir_hinc, fir_vinc;
 
 	fir_hinc = 1024 * orig_width / out_width;
 	fir_vinc = 1024 * orig_height / out_height;
 
-	dispc_ovl_set_scale_coef(plane, fir_hinc, fir_vinc, five_taps,
-				color_comp);
-	dispc_ovl_set_fir(plane, fir_hinc, fir_vinc, color_comp);
+	dispc_ovl_set_scale_coef(dispc, plane, fir_hinc, fir_vinc, five_taps,
+				 color_comp);
+	dispc_ovl_set_fir(dispc, plane, fir_hinc, fir_vinc, color_comp);
 }
 
-static void dispc_ovl_set_accu_uv(enum omap_plane_id plane,
-		u16 orig_width,	u16 orig_height, u16 out_width, u16 out_height,
-		bool ilace, u32 fourcc, u8 rotation)
+static void dispc_ovl_set_accu_uv(struct dispc_device *dispc,
+				  enum omap_plane_id plane,
+				  u16 orig_width, u16 orig_height,
+				  u16 out_width, u16 out_height,
+				  bool ilace, u32 fourcc, u8 rotation)
 {
 	int h_accu2_0, h_accu2_1;
 	int v_accu2_0, v_accu2_1;
@@ -1748,25 +1814,26 @@ static void dispc_ovl_set_accu_uv(enum omap_plane_id plane,
 	v_accu2_0 = (accu_val->v0_m * chroma_vinc / accu_val->v0_n) % 1024;
 	v_accu2_1 = (accu_val->v1_m * chroma_vinc / accu_val->v1_n) % 1024;
 
-	dispc_ovl_set_vid_accu2_0(plane, h_accu2_0, v_accu2_0);
-	dispc_ovl_set_vid_accu2_1(plane, h_accu2_1, v_accu2_1);
+	dispc_ovl_set_vid_accu2_0(dispc, plane, h_accu2_0, v_accu2_0);
+	dispc_ovl_set_vid_accu2_1(dispc, plane, h_accu2_1, v_accu2_1);
 }
 
-static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
-		u16 orig_width, u16 orig_height,
-		u16 out_width, u16 out_height,
-		bool ilace, bool five_taps,
-		bool fieldmode, u32 fourcc,
-		u8 rotation)
+static void dispc_ovl_set_scaling_common(struct dispc_device *dispc,
+					 enum omap_plane_id plane,
+					 u16 orig_width, u16 orig_height,
+					 u16 out_width, u16 out_height,
+					 bool ilace, bool five_taps,
+					 bool fieldmode, u32 fourcc,
+					 u8 rotation)
 {
 	int accu0 = 0;
 	int accu1 = 0;
 	u32 l;
 
-	dispc_ovl_set_scale_param(plane, orig_width, orig_height,
-				out_width, out_height, five_taps,
-				rotation, DISPC_COLOR_COMPONENT_RGB_Y);
-	l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
+	dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
+				  out_width, out_height, five_taps,
+				  rotation, DISPC_COLOR_COMPONENT_RGB_Y);
+	l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
 
 	/* RESIZEENABLE and VERTICALTAPS */
 	l &= ~((0x3 << 5) | (0x1 << 21));
@@ -1775,19 +1842,19 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
 	l |= five_taps ? (1 << 21) : 0;
 
 	/* VRESIZECONF and HRESIZECONF */
-	if (dispc_has_feature(FEAT_RESIZECONF)) {
+	if (dispc_has_feature(dispc, FEAT_RESIZECONF)) {
 		l &= ~(0x3 << 7);
 		l |= (orig_width <= out_width) ? 0 : (1 << 7);
 		l |= (orig_height <= out_height) ? 0 : (1 << 8);
 	}
 
 	/* LINEBUFFERSPLIT */
-	if (dispc_has_feature(FEAT_LINEBUFFERSPLIT)) {
+	if (dispc_has_feature(dispc, FEAT_LINEBUFFERSPLIT)) {
 		l &= ~(0x1 << 22);
 		l |= five_taps ? (1 << 22) : 0;
 	}
 
-	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l);
+	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
 
 	/*
 	 * field 0 = even field = bottom field
@@ -1802,33 +1869,35 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
 		}
 	}
 
-	dispc_ovl_set_vid_accu0(plane, 0, accu0);
-	dispc_ovl_set_vid_accu1(plane, 0, accu1);
+	dispc_ovl_set_vid_accu0(dispc, plane, 0, accu0);
+	dispc_ovl_set_vid_accu1(dispc, plane, 0, accu1);
 }
 
-static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane,
-		u16 orig_width, u16 orig_height,
-		u16 out_width, u16 out_height,
-		bool ilace, bool five_taps,
-		bool fieldmode, u32 fourcc,
-		u8 rotation)
+static void dispc_ovl_set_scaling_uv(struct dispc_device *dispc,
+				     enum omap_plane_id plane,
+				     u16 orig_width, u16 orig_height,
+				     u16 out_width, u16 out_height,
+				     bool ilace, bool five_taps,
+				     bool fieldmode, u32 fourcc,
+				     u8 rotation)
 {
 	int scale_x = out_width != orig_width;
 	int scale_y = out_height != orig_height;
 	bool chroma_upscale = plane != OMAP_DSS_WB;
 
-	if (!dispc_has_feature(FEAT_HANDLE_UV_SEPARATE))
+	if (!dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE))
 		return;
 
 	if (!format_is_yuv(fourcc)) {
 		/* reset chroma resampling for RGB formats  */
 		if (plane != OMAP_DSS_WB)
-			REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 8, 8);
+			REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
+				    0, 8, 8);
 		return;
 	}
 
-	dispc_ovl_set_accu_uv(plane, orig_width, orig_height, out_width,
-			out_height, ilace, fourcc, rotation);
+	dispc_ovl_set_accu_uv(dispc, plane, orig_width, orig_height, out_width,
+			      out_height, ilace, fourcc, rotation);
 
 	switch (fourcc) {
 	case DRM_FORMAT_NV12:
@@ -1870,46 +1939,43 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane,
 	if (out_height != orig_height)
 		scale_y = true;
 
-	dispc_ovl_set_scale_param(plane, orig_width, orig_height,
-			out_width, out_height, five_taps,
-				rotation, DISPC_COLOR_COMPONENT_UV);
+	dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
+				  out_width, out_height, five_taps,
+				  rotation, DISPC_COLOR_COMPONENT_UV);
 
 	if (plane != OMAP_DSS_WB)
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane),
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
 			(scale_x || scale_y) ? 1 : 0, 8, 8);
 
 	/* set H scaling */
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
 	/* set V scaling */
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
 }
 
-static void dispc_ovl_set_scaling(enum omap_plane_id plane,
-		u16 orig_width, u16 orig_height,
-		u16 out_width, u16 out_height,
-		bool ilace, bool five_taps,
-		bool fieldmode, u32 fourcc,
-		u8 rotation)
+static void dispc_ovl_set_scaling(struct dispc_device *dispc,
+				  enum omap_plane_id plane,
+				  u16 orig_width, u16 orig_height,
+				  u16 out_width, u16 out_height,
+				  bool ilace, bool five_taps,
+				  bool fieldmode, u32 fourcc,
+				  u8 rotation)
 {
 	BUG_ON(plane == OMAP_DSS_GFX);
 
-	dispc_ovl_set_scaling_common(plane,
-			orig_width, orig_height,
-			out_width, out_height,
-			ilace, five_taps,
-			fieldmode, fourcc,
-			rotation);
+	dispc_ovl_set_scaling_common(dispc, plane, orig_width, orig_height,
+				     out_width, out_height, ilace, five_taps,
+				     fieldmode, fourcc, rotation);
 
-	dispc_ovl_set_scaling_uv(plane,
-		orig_width, orig_height,
-		out_width, out_height,
-		ilace, five_taps,
-		fieldmode, fourcc,
-		rotation);
+	dispc_ovl_set_scaling_uv(dispc, plane, orig_width, orig_height,
+				 out_width, out_height, ilace, five_taps,
+				 fieldmode, fourcc, rotation);
 }
 
-static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation,
-		enum omap_dss_rotation_type rotation_type, u32 fourcc)
+static void dispc_ovl_set_rotation_attrs(struct dispc_device *dispc,
+					 enum omap_plane_id plane, u8 rotation,
+					 enum omap_dss_rotation_type rotation_type,
+					 u32 fourcc)
 {
 	bool row_repeat = false;
 	int vidrot = 0;
@@ -1963,19 +2029,19 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation,
 	if (fourcc == DRM_FORMAT_NV12 && rotation_type != OMAP_DSS_ROT_TILER)
 		vidrot = 1;
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
-	if (dispc_has_feature(FEAT_ROWREPEATENABLE))
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane),
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
+	if (dispc_has_feature(dispc, FEAT_ROWREPEATENABLE))
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane),
 			row_repeat ? 1 : 0, 18, 18);
 
-	if (dispc_ovl_color_mode_supported(plane, DRM_FORMAT_NV12)) {
+	if (dispc_ovl_color_mode_supported(dispc, plane, DRM_FORMAT_NV12)) {
 		bool doublestride =
 			fourcc == DRM_FORMAT_NV12 &&
 			rotation_type == OMAP_DSS_ROT_TILER &&
 			!drm_rotation_90_or_270(rotation);
 
 		/* DOUBLESTRIDE */
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), doublestride, 22, 22);
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), doublestride, 22, 22);
 	}
 }
 
@@ -2212,27 +2278,31 @@ static unsigned long calc_core_clk_44xx(unsigned long pclk, u16 width,
 		return pclk;
 }
 
-static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk,
-		const struct videomode *vm,
-		u16 width, u16 height, u16 out_width, u16 out_height,
-		u32 fourcc, bool *five_taps,
-		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
-		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
+static int dispc_ovl_calc_scaling_24xx(struct dispc_device *dispc,
+				       unsigned long pclk, unsigned long lclk,
+				       const struct videomode *vm,
+				       u16 width, u16 height,
+				       u16 out_width, u16 out_height,
+				       u32 fourcc, bool *five_taps,
+				       int *x_predecim, int *y_predecim,
+				       int *decim_x, int *decim_y,
+				       u16 pos_x, unsigned long *core_clk,
+				       bool mem_to_mem)
 {
 	int error;
 	u16 in_width, in_height;
 	int min_factor = min(*decim_x, *decim_y);
-	const int maxsinglelinewidth = dispc.feat->max_line_width;
+	const int maxsinglelinewidth = dispc->feat->max_line_width;
 
 	*five_taps = false;
 
 	do {
 		in_height = height / *decim_y;
 		in_width = width / *decim_x;
-		*core_clk = dispc.feat->calc_core_clk(pclk, in_width,
+		*core_clk = dispc->feat->calc_core_clk(pclk, in_width,
 				in_height, out_width, out_height, mem_to_mem);
 		error = (in_width > maxsinglelinewidth || !*core_clk ||
-			*core_clk > dispc_core_clk_rate());
+			*core_clk > dispc_core_clk_rate(dispc));
 		if (error) {
 			if (*decim_x == *decim_y) {
 				*decim_x = min_factor;
@@ -2257,16 +2327,20 @@ static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk,
 	return 0;
 }
 
-static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
-		const struct videomode *vm,
-		u16 width, u16 height, u16 out_width, u16 out_height,
-		u32 fourcc, bool *five_taps,
-		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
-		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
+static int dispc_ovl_calc_scaling_34xx(struct dispc_device *dispc,
+				       unsigned long pclk, unsigned long lclk,
+				       const struct videomode *vm,
+				       u16 width, u16 height,
+				       u16 out_width, u16 out_height,
+				       u32 fourcc, bool *five_taps,
+				       int *x_predecim, int *y_predecim,
+				       int *decim_x, int *decim_y,
+				       u16 pos_x, unsigned long *core_clk,
+				       bool mem_to_mem)
 {
 	int error;
 	u16 in_width, in_height;
-	const int maxsinglelinewidth = dispc.feat->max_line_width;
+	const int maxsinglelinewidth = dispc->feat->max_line_width;
 
 	do {
 		in_height = height / *decim_y;
@@ -2283,7 +2357,7 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
 						in_width, in_height, out_width,
 						out_height, fourcc);
 		else
-			*core_clk = dispc.feat->calc_core_clk(pclk, in_width,
+			*core_clk = dispc->feat->calc_core_clk(pclk, in_width,
 					in_height, out_width, out_height,
 					mem_to_mem);
 
@@ -2297,7 +2371,7 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
 
 		error = (error || in_width > maxsinglelinewidth * 2 ||
 			(in_width > maxsinglelinewidth && *five_taps) ||
-			!*core_clk || *core_clk > dispc_core_clk_rate());
+			!*core_clk || *core_clk > dispc_core_clk_rate(dispc));
 
 		if (!error) {
 			/* verify that we're inside the limits of scaler */
@@ -2341,24 +2415,28 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
 	return 0;
 }
 
-static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
-		const struct videomode *vm,
-		u16 width, u16 height, u16 out_width, u16 out_height,
-		u32 fourcc, bool *five_taps,
-		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
-		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
+static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc,
+				       unsigned long pclk, unsigned long lclk,
+				       const struct videomode *vm,
+				       u16 width, u16 height,
+				       u16 out_width, u16 out_height,
+				       u32 fourcc, bool *five_taps,
+				       int *x_predecim, int *y_predecim,
+				       int *decim_x, int *decim_y,
+				       u16 pos_x, unsigned long *core_clk,
+				       bool mem_to_mem)
 {
 	u16 in_width, in_width_max;
 	int decim_x_min = *decim_x;
 	u16 in_height = height / *decim_y;
-	const int maxsinglelinewidth = dispc.feat->max_line_width;
-	const int maxdownscale = dispc.feat->max_downscale;
+	const int maxsinglelinewidth = dispc->feat->max_line_width;
+	const int maxdownscale = dispc->feat->max_downscale;
 
 	if (mem_to_mem) {
 		in_width_max = out_width * maxdownscale;
 	} else {
-		in_width_max = dispc_core_clk_rate() /
-					DIV_ROUND_UP(pclk, out_width);
+		in_width_max = dispc_core_clk_rate(dispc)
+			     / DIV_ROUND_UP(pclk, out_width);
 	}
 
 	*decim_x = DIV_ROUND_UP(width, in_width_max);
@@ -2396,7 +2474,7 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
 		return -EINVAL;
 	}
 
-	*core_clk = dispc.feat->calc_core_clk(pclk, in_width, in_height,
+	*core_clk = dispc->feat->calc_core_clk(pclk, in_width, in_height,
 				out_width, out_height, mem_to_mem);
 	return 0;
 }
@@ -2404,15 +2482,18 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
 #define DIV_FRAC(dividend, divisor) \
 	((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
 
-static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
-		enum omap_overlay_caps caps,
-		const struct videomode *vm,
-		u16 width, u16 height, u16 out_width, u16 out_height,
-		u32 fourcc, bool *five_taps,
-		int *x_predecim, int *y_predecim, u16 pos_x,
-		enum omap_dss_rotation_type rotation_type, bool mem_to_mem)
-{
-	const int maxdownscale = dispc.feat->max_downscale;
+static int dispc_ovl_calc_scaling(struct dispc_device *dispc,
+				  unsigned long pclk, unsigned long lclk,
+				  enum omap_overlay_caps caps,
+				  const struct videomode *vm,
+				  u16 width, u16 height,
+				  u16 out_width, u16 out_height,
+				  u32 fourcc, bool *five_taps,
+				  int *x_predecim, int *y_predecim, u16 pos_x,
+				  enum omap_dss_rotation_type rotation_type,
+				  bool mem_to_mem)
+{
+	const int maxdownscale = dispc->feat->max_downscale;
 	const int max_decim_limit = 16;
 	unsigned long core_clk = 0;
 	int decim_x, decim_y, ret;
@@ -2433,7 +2514,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 	} else {
 		*x_predecim = max_decim_limit;
 		*y_predecim = (rotation_type == OMAP_DSS_ROT_TILER &&
-				dispc_has_feature(FEAT_BURST_2D)) ?
+				dispc_has_feature(dispc, FEAT_BURST_2D)) ?
 				2 : max_decim_limit;
 	}
 
@@ -2446,10 +2527,11 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 	if (decim_y > *y_predecim || out_height > height * 8)
 		return -EINVAL;
 
-	ret = dispc.feat->calc_scaling(pclk, lclk, vm, width, height,
-		out_width, out_height, fourcc, five_taps,
-		x_predecim, y_predecim, &decim_x, &decim_y, pos_x, &core_clk,
-		mem_to_mem);
+	ret = dispc->feat->calc_scaling(dispc, pclk, lclk, vm, width, height,
+					out_width, out_height, fourcc,
+					five_taps, x_predecim, y_predecim,
+					&decim_x, &decim_y, pos_x, &core_clk,
+					mem_to_mem);
 	if (ret)
 		return ret;
 
@@ -2465,13 +2547,13 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 		out_height / (height / decim_y), DIV_FRAC(out_height, height / decim_y),
 
 		*five_taps ? 5 : 3,
-		core_clk, dispc_core_clk_rate());
+		core_clk, dispc_core_clk_rate(dispc));
 
-	if (!core_clk || core_clk > dispc_core_clk_rate()) {
+	if (!core_clk || core_clk > dispc_core_clk_rate(dispc)) {
 		DSSERR("failed to set up scaling, "
 			"required core clk rate = %lu Hz, "
 			"current core clk rate = %lu Hz\n",
-			core_clk, dispc_core_clk_rate());
+			core_clk, dispc_core_clk_rate(dispc));
 		return -EINVAL;
 	}
 
@@ -2480,14 +2562,18 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 	return 0;
 }
 
-static int dispc_ovl_setup_common(enum omap_plane_id plane,
-		enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr,
-		u16 screen_width, int pos_x, int pos_y, u16 width, u16 height,
-		u16 out_width, u16 out_height, u32 fourcc,
-		u8 rotation, u8 zorder, u8 pre_mult_alpha,
-		u8 global_alpha, enum omap_dss_rotation_type rotation_type,
-		bool replication, const struct videomode *vm,
-		bool mem_to_mem)
+static int dispc_ovl_setup_common(struct dispc_device *dispc,
+				  enum omap_plane_id plane,
+				  enum omap_overlay_caps caps,
+				  u32 paddr, u32 p_uv_addr,
+				  u16 screen_width, int pos_x, int pos_y,
+				  u16 width, u16 height,
+				  u16 out_width, u16 out_height,
+				  u32 fourcc, u8 rotation, u8 zorder,
+				  u8 pre_mult_alpha, u8 global_alpha,
+				  enum omap_dss_rotation_type rotation_type,
+				  bool replication, const struct videomode *vm,
+				  bool mem_to_mem)
 {
 	bool five_taps = true;
 	bool fieldmode = false;
@@ -2501,8 +2587,8 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
 	u16 in_width = width;
 	int x_predecim = 1, y_predecim = 1;
 	bool ilace = !!(vm->flags & DISPLAY_FLAGS_INTERLACED);
-	unsigned long pclk = dispc_plane_pclk_rate(plane);
-	unsigned long lclk = dispc_plane_lclk_rate(plane);
+	unsigned long pclk = dispc_plane_pclk_rate(dispc, plane);
+	unsigned long lclk = dispc_plane_lclk_rate(dispc, plane);
 
 	if (paddr == 0 && rotation_type != OMAP_DSS_ROT_TILER)
 		return -EINVAL;
@@ -2529,13 +2615,13 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
 			out_height);
 	}
 
-	if (!dispc_ovl_color_mode_supported(plane, fourcc))
+	if (!dispc_ovl_color_mode_supported(dispc, plane, fourcc))
 		return -EINVAL;
 
-	r = dispc_ovl_calc_scaling(pclk, lclk, caps, vm, in_width,
-			in_height, out_width, out_height, fourcc,
-			&five_taps, &x_predecim, &y_predecim, pos_x,
-			rotation_type, mem_to_mem);
+	r = dispc_ovl_calc_scaling(dispc, pclk, lclk, caps, vm, in_width,
+				   in_height, out_width, out_height, fourcc,
+				   &five_taps, &x_predecim, &y_predecim, pos_x,
+				   rotation_type, mem_to_mem);
 	if (r)
 		return r;
 
@@ -2597,49 +2683,50 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
 	DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
 			offset0, offset1, row_inc, pix_inc);
 
-	dispc_ovl_set_color_mode(plane, fourcc);
+	dispc_ovl_set_color_mode(dispc, plane, fourcc);
 
-	dispc_ovl_configure_burst_type(plane, rotation_type);
+	dispc_ovl_configure_burst_type(dispc, plane, rotation_type);
 
-	if (dispc.feat->reverse_ilace_field_order)
+	if (dispc->feat->reverse_ilace_field_order)
 		swap(offset0, offset1);
 
-	dispc_ovl_set_ba0(plane, paddr + offset0);
-	dispc_ovl_set_ba1(plane, paddr + offset1);
+	dispc_ovl_set_ba0(dispc, plane, paddr + offset0);
+	dispc_ovl_set_ba1(dispc, plane, paddr + offset1);
 
 	if (fourcc == DRM_FORMAT_NV12) {
-		dispc_ovl_set_ba0_uv(plane, p_uv_addr + offset0);
-		dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1);
+		dispc_ovl_set_ba0_uv(dispc, plane, p_uv_addr + offset0);
+		dispc_ovl_set_ba1_uv(dispc, plane, p_uv_addr + offset1);
 	}
 
-	if (dispc.feat->last_pixel_inc_missing)
+	if (dispc->feat->last_pixel_inc_missing)
 		row_inc += pix_inc - 1;
 
-	dispc_ovl_set_row_inc(plane, row_inc);
-	dispc_ovl_set_pix_inc(plane, pix_inc);
+	dispc_ovl_set_row_inc(dispc, plane, row_inc);
+	dispc_ovl_set_pix_inc(dispc, plane, pix_inc);
 
 	DSSDBG("%d,%d %dx%d -> %dx%d\n", pos_x, pos_y, in_width,
 			in_height, out_width, out_height);
 
-	dispc_ovl_set_pos(plane, caps, pos_x, pos_y);
+	dispc_ovl_set_pos(dispc, plane, caps, pos_x, pos_y);
 
-	dispc_ovl_set_input_size(plane, in_width, in_height);
+	dispc_ovl_set_input_size(dispc, plane, in_width, in_height);
 
 	if (caps & OMAP_DSS_OVL_CAP_SCALE) {
-		dispc_ovl_set_scaling(plane, in_width, in_height, out_width,
-				   out_height, ilace, five_taps, fieldmode,
-				   fourcc, rotation);
-		dispc_ovl_set_output_size(plane, out_width, out_height);
-		dispc_ovl_set_vid_color_conv(plane, cconv);
+		dispc_ovl_set_scaling(dispc, plane, in_width, in_height,
+				      out_width, out_height, ilace, five_taps,
+				      fieldmode, fourcc, rotation);
+		dispc_ovl_set_output_size(dispc, plane, out_width, out_height);
+		dispc_ovl_set_vid_color_conv(dispc, plane, cconv);
 	}
 
-	dispc_ovl_set_rotation_attrs(plane, rotation, rotation_type, fourcc);
+	dispc_ovl_set_rotation_attrs(dispc, plane, rotation, rotation_type,
+				     fourcc);
 
-	dispc_ovl_set_zorder(plane, caps, zorder);
-	dispc_ovl_set_pre_mult_alpha(plane, caps, pre_mult_alpha);
-	dispc_ovl_setup_global_alpha(plane, caps, global_alpha);
+	dispc_ovl_set_zorder(dispc, plane, caps, zorder);
+	dispc_ovl_set_pre_mult_alpha(dispc, plane, caps, pre_mult_alpha);
+	dispc_ovl_setup_global_alpha(dispc, plane, caps, global_alpha);
 
-	dispc_ovl_enable_replication(plane, caps, replication);
+	dispc_ovl_enable_replication(dispc, plane, caps, replication);
 
 	return 0;
 }
@@ -2660,9 +2747,9 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
 		oi->pos_y, oi->width, oi->height, oi->out_width, oi->out_height,
 		oi->fourcc, oi->rotation, channel, replication);
 
-	dispc_ovl_set_channel_out(plane, channel);
+	dispc_ovl_set_channel_out(dispc, plane, channel);
 
-	r = dispc_ovl_setup_common(plane, caps, oi->paddr, oi->p_uv_addr,
+	r = dispc_ovl_setup_common(dispc, plane, caps, oi->paddr, oi->p_uv_addr,
 		oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height,
 		oi->out_width, oi->out_height, oi->fourcc, oi->rotation,
 		oi->zorder, oi->pre_mult_alpha, oi->global_alpha,
@@ -2691,7 +2778,7 @@ int dispc_wb_setup(struct dispc_device *dispc,
 		"rot %d\n", wi->paddr, wi->p_uv_addr, in_width,
 		in_height, wi->width, wi->height, wi->fourcc, wi->rotation);
 
-	r = dispc_ovl_setup_common(plane, caps, wi->paddr, wi->p_uv_addr,
+	r = dispc_ovl_setup_common(dispc, plane, caps, wi->paddr, wi->p_uv_addr,
 		wi->buf_width, pos_x, pos_y, in_width, in_height, wi->width,
 		wi->height, wi->fourcc, wi->rotation, zorder,
 		wi->pre_mult_alpha, global_alpha, wi->rotation_type,
@@ -2714,18 +2801,18 @@ int dispc_wb_setup(struct dispc_device *dispc,
 	}
 
 	/* setup extra DISPC_WB_ATTRIBUTES */
-	l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
+	l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
 	l = FLD_MOD(l, truncation, 10, 10);	/* TRUNCATIONENABLE */
 	l = FLD_MOD(l, mem_to_mem, 19, 19);	/* WRITEBACKMODE */
 	if (mem_to_mem)
 		l = FLD_MOD(l, 1, 26, 24);	/* CAPTUREMODE */
 	else
 		l = FLD_MOD(l, 0, 26, 24);	/* CAPTUREMODE */
-	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l);
+	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
 
 	if (mem_to_mem) {
 		/* WBDELAYCOUNT */
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 7, 0);
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), 0, 7, 0);
 	} else {
 		int wbdelay;
 
@@ -2733,7 +2820,7 @@ int dispc_wb_setup(struct dispc_device *dispc,
 			      vm->vsync_len + vm->vback_porch, (u32)255);
 
 		/* WBDELAYCOUNT */
-		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), wbdelay, 7, 0);
+		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), wbdelay, 7, 0);
 	}
 
 	return r;
@@ -2744,7 +2831,7 @@ static int dispc_ovl_enable(struct dispc_device *dispc,
 {
 	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
 
-	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
+	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
 
 	return 0;
 }
@@ -2756,94 +2843,106 @@ dispc_mgr_get_supported_outputs(struct dispc_device *dispc,
 	return dss_get_supported_outputs(dispc->dss, channel);
 }
 
-static void dispc_lcd_enable_signal_polarity(bool act_high)
+static void dispc_lcd_enable_signal_polarity(struct dispc_device *dispc,
+					     bool act_high)
 {
-	if (!dispc_has_feature(FEAT_LCDENABLEPOL))
+	if (!dispc_has_feature(dispc, FEAT_LCDENABLEPOL))
 		return;
 
-	REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
+	REG_FLD_MOD(dispc, DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
 }
 
 void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable)
 {
-	if (!dispc_has_feature(FEAT_LCDENABLESIGNAL))
+	if (!dispc_has_feature(dispc, FEAT_LCDENABLESIGNAL))
 		return;
 
-	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
+	REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 28, 28);
 }
 
 void dispc_pck_free_enable(struct dispc_device *dispc, bool enable)
 {
-	if (!dispc_has_feature(FEAT_PCKFREEENABLE))
+	if (!dispc_has_feature(dispc, FEAT_PCKFREEENABLE))
 		return;
 
-	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27);
+	REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 27, 27);
 }
 
-static void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable)
+static void dispc_mgr_enable_fifohandcheck(struct dispc_device *dispc,
+					   enum omap_channel channel,
+					   bool enable)
 {
-	mgr_fld_write(channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable);
 }
 
 
-static void dispc_mgr_set_lcd_type_tft(enum omap_channel channel)
+static void dispc_mgr_set_lcd_type_tft(struct dispc_device *dispc,
+				       enum omap_channel channel)
 {
-	mgr_fld_write(channel, DISPC_MGR_FLD_STNTFT, 1);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STNTFT, 1);
 }
 
-static void dispc_set_loadmode(enum omap_dss_load_mode mode)
+static void dispc_set_loadmode(struct dispc_device *dispc,
+			       enum omap_dss_load_mode mode)
 {
-	REG_FLD_MOD(DISPC_CONFIG, mode, 2, 1);
+	REG_FLD_MOD(dispc, DISPC_CONFIG, mode, 2, 1);
 }
 
 
-static void dispc_mgr_set_default_color(enum omap_channel channel, u32 color)
+static void dispc_mgr_set_default_color(struct dispc_device *dispc,
+					enum omap_channel channel, u32 color)
 {
-	dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color);
+	dispc_write_reg(dispc, DISPC_DEFAULT_COLOR(channel), color);
 }
 
-static void dispc_mgr_set_trans_key(enum omap_channel ch,
-		enum omap_dss_trans_key_type type,
-		u32 trans_key)
+static void dispc_mgr_set_trans_key(struct dispc_device *dispc,
+				    enum omap_channel ch,
+				    enum omap_dss_trans_key_type type,
+				    u32 trans_key)
 {
-	mgr_fld_write(ch, DISPC_MGR_FLD_TCKSELECTION, type);
+	mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKSELECTION, type);
 
-	dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key);
+	dispc_write_reg(dispc, DISPC_TRANS_COLOR(ch), trans_key);
 }
 
-static void dispc_mgr_enable_trans_key(enum omap_channel ch, bool enable)
+static void dispc_mgr_enable_trans_key(struct dispc_device *dispc,
+				       enum omap_channel ch, bool enable)
 {
-	mgr_fld_write(ch, DISPC_MGR_FLD_TCKENABLE, enable);
+	mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKENABLE, enable);
 }
 
-static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch,
-		bool enable)
+static void dispc_mgr_enable_alpha_fixed_zorder(struct dispc_device *dispc,
+						enum omap_channel ch,
+						bool enable)
 {
-	if (!dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER))
+	if (!dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER))
 		return;
 
 	if (ch == OMAP_DSS_CHANNEL_LCD)
-		REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18);
+		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 18, 18);
 	else if (ch == OMAP_DSS_CHANNEL_DIGIT)
-		REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
+		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 19, 19);
 }
 
 static void dispc_mgr_setup(struct dispc_device *dispc,
 			    enum omap_channel channel,
 			    const struct omap_overlay_manager_info *info)
 {
-	dispc_mgr_set_default_color(channel, info->default_color);
-	dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key);
-	dispc_mgr_enable_trans_key(channel, info->trans_enabled);
-	dispc_mgr_enable_alpha_fixed_zorder(channel,
+	dispc_mgr_set_default_color(dispc, channel, info->default_color);
+	dispc_mgr_set_trans_key(dispc, channel, info->trans_key_type,
+				info->trans_key);
+	dispc_mgr_enable_trans_key(dispc, channel, info->trans_enabled);
+	dispc_mgr_enable_alpha_fixed_zorder(dispc, channel,
 			info->partial_alpha_enabled);
-	if (dispc_has_feature(FEAT_CPR)) {
-		dispc_mgr_enable_cpr(channel, info->cpr_enable);
-		dispc_mgr_set_cpr_coef(channel, &info->cpr_coefs);
+	if (dispc_has_feature(dispc, FEAT_CPR)) {
+		dispc_mgr_enable_cpr(dispc, channel, info->cpr_enable);
+		dispc_mgr_set_cpr_coef(dispc, channel, &info->cpr_coefs);
 	}
 }
 
-static void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_lines)
+static void dispc_mgr_set_tft_data_lines(struct dispc_device *dispc,
+					 enum omap_channel channel,
+					 u8 data_lines)
 {
 	int code;
 
@@ -2865,10 +2964,11 @@ static void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_line
 		return;
 	}
 
-	mgr_fld_write(channel, DISPC_MGR_FLD_TFTDATALINES, code);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_TFTDATALINES, code);
 }
 
-static void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode)
+static void dispc_mgr_set_io_pad_mode(struct dispc_device *dispc,
+				      enum dss_io_pad_mode mode)
 {
 	u32 l;
 	int gpout0, gpout1;
@@ -2891,70 +2991,74 @@ static void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode)
 		return;
 	}
 
-	l = dispc_read_reg(DISPC_CONTROL);
+	l = dispc_read_reg(dispc, DISPC_CONTROL);
 	l = FLD_MOD(l, gpout0, 15, 15);
 	l = FLD_MOD(l, gpout1, 16, 16);
-	dispc_write_reg(DISPC_CONTROL, l);
+	dispc_write_reg(dispc, DISPC_CONTROL, l);
 }
 
-static void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable)
+static void dispc_mgr_enable_stallmode(struct dispc_device *dispc,
+				       enum omap_channel channel, bool enable)
 {
-	mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable);
+	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STALLMODE, enable);
 }
 
 static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
 				     enum omap_channel channel,
 				     const struct dss_lcd_mgr_config *config)
 {
-	dispc_mgr_set_io_pad_mode(config->io_pad_mode);
+	dispc_mgr_set_io_pad_mode(dispc, config->io_pad_mode);
 
-	dispc_mgr_enable_stallmode(channel, config->stallmode);
-	dispc_mgr_enable_fifohandcheck(channel, config->fifohandcheck);
+	dispc_mgr_enable_stallmode(dispc, channel, config->stallmode);
+	dispc_mgr_enable_fifohandcheck(dispc, channel, config->fifohandcheck);
 
 	dispc_mgr_set_clock_div(dispc, channel, &config->clock_info);
 
-	dispc_mgr_set_tft_data_lines(channel, config->video_port_width);
+	dispc_mgr_set_tft_data_lines(dispc, channel, config->video_port_width);
 
-	dispc_lcd_enable_signal_polarity(config->lcden_sig_polarity);
+	dispc_lcd_enable_signal_polarity(dispc, config->lcden_sig_polarity);
 
-	dispc_mgr_set_lcd_type_tft(channel);
+	dispc_mgr_set_lcd_type_tft(dispc, channel);
 }
 
-static bool _dispc_mgr_size_ok(u16 width, u16 height)
+static bool _dispc_mgr_size_ok(struct dispc_device *dispc,
+			       u16 width, u16 height)
 {
-	return width <= dispc.feat->mgr_width_max &&
-		height <= dispc.feat->mgr_height_max;
+	return width <= dispc->feat->mgr_width_max &&
+		height <= dispc->feat->mgr_height_max;
 }
 
-static bool _dispc_lcd_timings_ok(int hsync_len, int hfp, int hbp,
-		int vsw, int vfp, int vbp)
+static bool _dispc_lcd_timings_ok(struct dispc_device *dispc,
+				  int hsync_len, int hfp, int hbp,
+				  int vsw, int vfp, int vbp)
 {
-	if (hsync_len < 1 || hsync_len > dispc.feat->sw_max ||
-			hfp < 1 || hfp > dispc.feat->hp_max ||
-			hbp < 1 || hbp > dispc.feat->hp_max ||
-			vsw < 1 || vsw > dispc.feat->sw_max ||
-			vfp < 0 || vfp > dispc.feat->vp_max ||
-			vbp < 0 || vbp > dispc.feat->vp_max)
+	if (hsync_len < 1 || hsync_len > dispc->feat->sw_max ||
+	    hfp < 1 || hfp > dispc->feat->hp_max ||
+	    hbp < 1 || hbp > dispc->feat->hp_max ||
+	    vsw < 1 || vsw > dispc->feat->sw_max ||
+	    vfp < 0 || vfp > dispc->feat->vp_max ||
+	    vbp < 0 || vbp > dispc->feat->vp_max)
 		return false;
 	return true;
 }
 
-static bool _dispc_mgr_pclk_ok(enum omap_channel channel,
-		unsigned long pclk)
+static bool _dispc_mgr_pclk_ok(struct dispc_device *dispc,
+			       enum omap_channel channel,
+			       unsigned long pclk)
 {
 	if (dss_mgr_is_lcd(channel))
-		return pclk <= dispc.feat->max_lcd_pclk;
+		return pclk <= dispc->feat->max_lcd_pclk;
 	else
-		return pclk <= dispc.feat->max_tv_pclk;
+		return pclk <= dispc->feat->max_tv_pclk;
 }
 
 bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
 			  const struct videomode *vm)
 {
-	if (!_dispc_mgr_size_ok(vm->hactive, vm->vactive))
+	if (!_dispc_mgr_size_ok(dispc, vm->hactive, vm->vactive))
 		return false;
 
-	if (!_dispc_mgr_pclk_ok(channel, vm->pixelclock))
+	if (!_dispc_mgr_pclk_ok(dispc, channel, vm->pixelclock))
 		return false;
 
 	if (dss_mgr_is_lcd(channel)) {
@@ -2962,7 +3066,7 @@ bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
 		if (vm->flags & DISPLAY_FLAGS_INTERLACED)
 			return false;
 
-		if (!_dispc_lcd_timings_ok(vm->hsync_len,
+		if (!_dispc_lcd_timings_ok(dispc, vm->hsync_len,
 				vm->hfront_porch, vm->hback_porch,
 				vm->vsync_len, vm->vfront_porch,
 				vm->vback_porch))
@@ -2972,21 +3076,22 @@ bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
 	return true;
 }
 
-static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
+static void _dispc_mgr_set_lcd_timings(struct dispc_device *dispc,
+				       enum omap_channel channel,
 				       const struct videomode *vm)
 {
 	u32 timing_h, timing_v, l;
 	bool onoff, rf, ipc, vs, hs, de;
 
-	timing_h = FLD_VAL(vm->hsync_len - 1, dispc.feat->sw_start, 0) |
-		   FLD_VAL(vm->hfront_porch - 1, dispc.feat->fp_start, 8) |
-		   FLD_VAL(vm->hback_porch - 1, dispc.feat->bp_start, 20);
-	timing_v = FLD_VAL(vm->vsync_len - 1, dispc.feat->sw_start, 0) |
-		   FLD_VAL(vm->vfront_porch, dispc.feat->fp_start, 8) |
-		   FLD_VAL(vm->vback_porch, dispc.feat->bp_start, 20);
+	timing_h = FLD_VAL(vm->hsync_len - 1, dispc->feat->sw_start, 0) |
+		   FLD_VAL(vm->hfront_porch - 1, dispc->feat->fp_start, 8) |
+		   FLD_VAL(vm->hback_porch - 1, dispc->feat->bp_start, 20);
+	timing_v = FLD_VAL(vm->vsync_len - 1, dispc->feat->sw_start, 0) |
+		   FLD_VAL(vm->vfront_porch, dispc->feat->fp_start, 8) |
+		   FLD_VAL(vm->vback_porch, dispc->feat->bp_start, 20);
 
-	dispc_write_reg(DISPC_TIMING_H(channel), timing_h);
-	dispc_write_reg(DISPC_TIMING_V(channel), timing_v);
+	dispc_write_reg(dispc, DISPC_TIMING_H(channel), timing_h);
+	dispc_write_reg(dispc, DISPC_TIMING_V(channel), timing_v);
 
 	if (vm->flags & DISPLAY_FLAGS_VSYNC_HIGH)
 		vs = false;
@@ -3024,12 +3129,12 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
 		FLD_VAL(vs, 12, 12);
 
 	/* always set ALIGN bit when available */
-	if (dispc.feat->supports_sync_align)
+	if (dispc->feat->supports_sync_align)
 		l |= (1 << 18);
 
-	dispc_write_reg(DISPC_POL_FREQ(channel), l);
+	dispc_write_reg(dispc, DISPC_POL_FREQ(channel), l);
 
-	if (dispc.syscon_pol) {
+	if (dispc->syscon_pol) {
 		const int shifts[] = {
 			[OMAP_DSS_CHANNEL_LCD] = 0,
 			[OMAP_DSS_CHANNEL_LCD2] = 1,
@@ -3044,8 +3149,8 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
 		mask <<= 16 + shifts[channel];
 		val <<= 16 + shifts[channel];
 
-		regmap_update_bits(dispc.syscon_pol, dispc.syscon_pol_offset,
-			mask, val);
+		regmap_update_bits(dispc->syscon_pol, dispc->syscon_pol_offset,
+				   mask, val);
 	}
 }
 
@@ -3076,7 +3181,7 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
 	}
 
 	if (dss_mgr_is_lcd(channel)) {
-		_dispc_mgr_set_lcd_timings(channel, &t);
+		_dispc_mgr_set_lcd_timings(dispc, channel, &t);
 
 		xtot = t.hactive + t.hfront_porch + t.hsync_len + t.hback_porch;
 		ytot = t.vactive + t.vfront_porch + t.vsync_len + t.vback_porch;
@@ -3101,46 +3206,48 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
 			t.vactive /= 2;
 
 		if (dispc->feat->supports_double_pixel)
-			REG_FLD_MOD(DISPC_CONTROL,
+			REG_FLD_MOD(dispc, DISPC_CONTROL,
 				    !!(t.flags & DISPLAY_FLAGS_DOUBLECLK),
 				    19, 17);
 	}
 
-	dispc_mgr_set_size(channel, t.hactive, t.vactive);
+	dispc_mgr_set_size(dispc, channel, t.hactive, t.vactive);
 }
 
-static void dispc_mgr_set_lcd_divisor(enum omap_channel channel, u16 lck_div,
-		u16 pck_div)
+static void dispc_mgr_set_lcd_divisor(struct dispc_device *dispc,
+				      enum omap_channel channel, u16 lck_div,
+				      u16 pck_div)
 {
 	BUG_ON(lck_div < 1);
 	BUG_ON(pck_div < 1);
 
-	dispc_write_reg(DISPC_DIVISORo(channel),
+	dispc_write_reg(dispc, DISPC_DIVISORo(channel),
 			FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0));
 
-	if (!dispc_has_feature(FEAT_CORE_CLK_DIV) &&
+	if (!dispc_has_feature(dispc, FEAT_CORE_CLK_DIV) &&
 			channel == OMAP_DSS_CHANNEL_LCD)
-		dispc.core_clk_rate = dispc_fclk_rate() / lck_div;
+		dispc->core_clk_rate = dispc_fclk_rate(dispc) / lck_div;
 }
 
-static void dispc_mgr_get_lcd_divisor(enum omap_channel channel, int *lck_div,
-		int *pck_div)
+static void dispc_mgr_get_lcd_divisor(struct dispc_device *dispc,
+				      enum omap_channel channel, int *lck_div,
+				      int *pck_div)
 {
 	u32 l;
-	l = dispc_read_reg(DISPC_DIVISORo(channel));
+	l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
 	*lck_div = FLD_GET(l, 23, 16);
 	*pck_div = FLD_GET(l, 7, 0);
 }
 
-static unsigned long dispc_fclk_rate(void)
+static unsigned long dispc_fclk_rate(struct dispc_device *dispc)
 {
 	unsigned long r;
 	enum dss_clk_source src;
 
-	src = dss_get_dispc_clk_source(dispc.dss);
+	src = dss_get_dispc_clk_source(dispc->dss);
 
 	if (src == DSS_CLK_SRC_FCK) {
-		r = dss_get_dispc_clk_rate(dispc.dss);
+		r = dss_get_dispc_clk_rate(dispc->dss);
 	} else {
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
@@ -3154,7 +3261,8 @@ static unsigned long dispc_fclk_rate(void)
 	return r;
 }
 
-static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
+static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
+					 enum omap_channel channel)
 {
 	int lcd;
 	unsigned long r;
@@ -3162,12 +3270,12 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 
 	/* for TV, LCLK rate is the FCLK rate */
 	if (!dss_mgr_is_lcd(channel))
-		return dispc_fclk_rate();
+		return dispc_fclk_rate(dispc);
 
-	src = dss_get_lcd_clk_source(dispc.dss, channel);
+	src = dss_get_lcd_clk_source(dispc->dss, channel);
 
 	if (src == DSS_CLK_SRC_FCK) {
-		r = dss_get_dispc_clk_rate(dispc.dss);
+		r = dss_get_dispc_clk_rate(dispc->dss);
 	} else {
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
@@ -3178,12 +3286,13 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 		r = pll->cinfo.clkout[clkout_idx];
 	}
 
-	lcd = REG_GET(DISPC_DIVISORo(channel), 23, 16);
+	lcd = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
 
 	return r / lcd;
 }
 
-static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
+static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
+					 enum omap_channel channel)
 {
 	unsigned long r;
 
@@ -3191,15 +3300,15 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
 		int pcd;
 		u32 l;
 
-		l = dispc_read_reg(DISPC_DIVISORo(channel));
+		l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
 
 		pcd = FLD_GET(l, 7, 0);
 
-		r = dispc_mgr_lclk_rate(channel);
+		r = dispc_mgr_lclk_rate(dispc, channel);
 
 		return r / pcd;
 	} else {
-		return dispc.tv_pclk_rate;
+		return dispc->tv_pclk_rate;
 	}
 }
 
@@ -3208,53 +3317,57 @@ void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk)
 	dispc->tv_pclk_rate = pclk;
 }
 
-static unsigned long dispc_core_clk_rate(void)
+static unsigned long dispc_core_clk_rate(struct dispc_device *dispc)
 {
-	return dispc.core_clk_rate;
+	return dispc->core_clk_rate;
 }
 
-static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane)
+static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
+					   enum omap_plane_id plane)
 {
 	enum omap_channel channel;
 
 	if (plane == OMAP_DSS_WB)
 		return 0;
 
-	channel = dispc_ovl_get_channel_out(plane);
+	channel = dispc_ovl_get_channel_out(dispc, plane);
 
-	return dispc_mgr_pclk_rate(channel);
+	return dispc_mgr_pclk_rate(dispc, channel);
 }
 
-static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane)
+static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
+					   enum omap_plane_id plane)
 {
 	enum omap_channel channel;
 
 	if (plane == OMAP_DSS_WB)
 		return 0;
 
-	channel	= dispc_ovl_get_channel_out(plane);
+	channel	= dispc_ovl_get_channel_out(dispc, plane);
 
-	return dispc_mgr_lclk_rate(channel);
+	return dispc_mgr_lclk_rate(dispc, channel);
 }
 
-static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel channel)
+static void dispc_dump_clocks_channel(struct dispc_device *dispc,
+				      struct seq_file *s,
+				      enum omap_channel channel)
 {
 	int lcd, pcd;
 	enum dss_clk_source lcd_clk_src;
 
 	seq_printf(s, "- %s -\n", mgr_desc[channel].name);
 
-	lcd_clk_src = dss_get_lcd_clk_source(dispc.dss, channel);
+	lcd_clk_src = dss_get_lcd_clk_source(dispc->dss, channel);
 
 	seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
 		dss_get_clk_source_name(lcd_clk_src));
 
-	dispc_mgr_get_lcd_divisor(channel, &lcd, &pcd);
+	dispc_mgr_get_lcd_divisor(dispc, channel, &lcd, &pcd);
 
 	seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
-		dispc_mgr_lclk_rate(channel), lcd);
+		dispc_mgr_lclk_rate(dispc, channel), lcd);
 	seq_printf(s, "pck\t\t%-16lupck div\t%u\n",
-		dispc_mgr_pclk_rate(channel), pcd);
+		dispc_mgr_pclk_rate(dispc, channel), pcd);
 }
 
 void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
@@ -3271,29 +3384,30 @@ void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
 	seq_printf(s, "dispc fclk source = %s\n",
 			dss_get_clk_source_name(dispc_clk_src));
 
-	seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate());
+	seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate(dispc));
 
-	if (dispc_has_feature(FEAT_CORE_CLK_DIV)) {
+	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
 		seq_printf(s, "- DISPC-CORE-CLK -\n");
-		l = dispc_read_reg(DISPC_DIVISOR);
+		l = dispc_read_reg(dispc, DISPC_DIVISOR);
 		lcd = FLD_GET(l, 23, 16);
 
 		seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
-				(dispc_fclk_rate()/lcd), lcd);
+				(dispc_fclk_rate(dispc)/lcd), lcd);
 	}
 
-	dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD);
+	dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD);
 
-	if (dispc_has_feature(FEAT_MGR_LCD2))
-		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD2);
-	if (dispc_has_feature(FEAT_MGR_LCD3))
-		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
+		dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD2);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
+		dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD3);
 
 	dispc_runtime_put(dispc);
 }
 
 static int dispc_dump_regs(struct seq_file *s, void *p)
 {
+	struct dispc_device *dispc = s->private;
 	int i, j;
 	const char *mgr_names[] = {
 		[OMAP_DSS_CHANNEL_LCD]		= "LCD",
@@ -3310,178 +3424,179 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
 	};
 	const char **p_names;
 
-#define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
+#define DUMPREG(dispc, r) \
+	seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(dispc, r))
 
-	if (dispc_runtime_get(&dispc))
+	if (dispc_runtime_get(dispc))
 		return 0;
 
 	/* DISPC common registers */
-	DUMPREG(DISPC_REVISION);
-	DUMPREG(DISPC_SYSCONFIG);
-	DUMPREG(DISPC_SYSSTATUS);
-	DUMPREG(DISPC_IRQSTATUS);
-	DUMPREG(DISPC_IRQENABLE);
-	DUMPREG(DISPC_CONTROL);
-	DUMPREG(DISPC_CONFIG);
-	DUMPREG(DISPC_CAPABLE);
-	DUMPREG(DISPC_LINE_STATUS);
-	DUMPREG(DISPC_LINE_NUMBER);
-	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
-			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
-		DUMPREG(DISPC_GLOBAL_ALPHA);
-	if (dispc_has_feature(FEAT_MGR_LCD2)) {
-		DUMPREG(DISPC_CONTROL2);
-		DUMPREG(DISPC_CONFIG2);
+	DUMPREG(dispc, DISPC_REVISION);
+	DUMPREG(dispc, DISPC_SYSCONFIG);
+	DUMPREG(dispc, DISPC_SYSSTATUS);
+	DUMPREG(dispc, DISPC_IRQSTATUS);
+	DUMPREG(dispc, DISPC_IRQENABLE);
+	DUMPREG(dispc, DISPC_CONTROL);
+	DUMPREG(dispc, DISPC_CONFIG);
+	DUMPREG(dispc, DISPC_CAPABLE);
+	DUMPREG(dispc, DISPC_LINE_STATUS);
+	DUMPREG(dispc, DISPC_LINE_NUMBER);
+	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
+			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
+		DUMPREG(dispc, DISPC_GLOBAL_ALPHA);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
+		DUMPREG(dispc, DISPC_CONTROL2);
+		DUMPREG(dispc, DISPC_CONFIG2);
 	}
-	if (dispc_has_feature(FEAT_MGR_LCD3)) {
-		DUMPREG(DISPC_CONTROL3);
-		DUMPREG(DISPC_CONFIG3);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
+		DUMPREG(dispc, DISPC_CONTROL3);
+		DUMPREG(dispc, DISPC_CONFIG3);
 	}
-	if (dispc_has_feature(FEAT_MFLAG))
-		DUMPREG(DISPC_GLOBAL_MFLAG_ATTRIBUTE);
+	if (dispc_has_feature(dispc, FEAT_MFLAG))
+		DUMPREG(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE);
 
 #undef DUMPREG
 
 #define DISPC_REG(i, name) name(i)
-#define DUMPREG(i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
+#define DUMPREG(dispc, i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
 	(int)(48 - strlen(#r) - strlen(p_names[i])), " ", \
-	dispc_read_reg(DISPC_REG(i, r)))
+	dispc_read_reg(dispc, DISPC_REG(i, r)))
 
 	p_names = mgr_names;
 
 	/* DISPC channel specific registers */
-	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
-		DUMPREG(i, DISPC_DEFAULT_COLOR);
-		DUMPREG(i, DISPC_TRANS_COLOR);
-		DUMPREG(i, DISPC_SIZE_MGR);
+	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
+		DUMPREG(dispc, i, DISPC_DEFAULT_COLOR);
+		DUMPREG(dispc, i, DISPC_TRANS_COLOR);
+		DUMPREG(dispc, i, DISPC_SIZE_MGR);
 
 		if (i == OMAP_DSS_CHANNEL_DIGIT)
 			continue;
 
-		DUMPREG(i, DISPC_TIMING_H);
-		DUMPREG(i, DISPC_TIMING_V);
-		DUMPREG(i, DISPC_POL_FREQ);
-		DUMPREG(i, DISPC_DIVISORo);
+		DUMPREG(dispc, i, DISPC_TIMING_H);
+		DUMPREG(dispc, i, DISPC_TIMING_V);
+		DUMPREG(dispc, i, DISPC_POL_FREQ);
+		DUMPREG(dispc, i, DISPC_DIVISORo);
 
-		DUMPREG(i, DISPC_DATA_CYCLE1);
-		DUMPREG(i, DISPC_DATA_CYCLE2);
-		DUMPREG(i, DISPC_DATA_CYCLE3);
+		DUMPREG(dispc, i, DISPC_DATA_CYCLE1);
+		DUMPREG(dispc, i, DISPC_DATA_CYCLE2);
+		DUMPREG(dispc, i, DISPC_DATA_CYCLE3);
 
-		if (dispc_has_feature(FEAT_CPR)) {
-			DUMPREG(i, DISPC_CPR_COEF_R);
-			DUMPREG(i, DISPC_CPR_COEF_G);
-			DUMPREG(i, DISPC_CPR_COEF_B);
+		if (dispc_has_feature(dispc, FEAT_CPR)) {
+			DUMPREG(dispc, i, DISPC_CPR_COEF_R);
+			DUMPREG(dispc, i, DISPC_CPR_COEF_G);
+			DUMPREG(dispc, i, DISPC_CPR_COEF_B);
 		}
 	}
 
 	p_names = ovl_names;
 
-	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
-		DUMPREG(i, DISPC_OVL_BA0);
-		DUMPREG(i, DISPC_OVL_BA1);
-		DUMPREG(i, DISPC_OVL_POSITION);
-		DUMPREG(i, DISPC_OVL_SIZE);
-		DUMPREG(i, DISPC_OVL_ATTRIBUTES);
-		DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD);
-		DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
-		DUMPREG(i, DISPC_OVL_ROW_INC);
-		DUMPREG(i, DISPC_OVL_PIXEL_INC);
-
-		if (dispc_has_feature(FEAT_PRELOAD))
-			DUMPREG(i, DISPC_OVL_PRELOAD);
-		if (dispc_has_feature(FEAT_MFLAG))
-			DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
+	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
+		DUMPREG(dispc, i, DISPC_OVL_BA0);
+		DUMPREG(dispc, i, DISPC_OVL_BA1);
+		DUMPREG(dispc, i, DISPC_OVL_POSITION);
+		DUMPREG(dispc, i, DISPC_OVL_SIZE);
+		DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
+		DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
+		DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
+		DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
+		DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
+
+		if (dispc_has_feature(dispc, FEAT_PRELOAD))
+			DUMPREG(dispc, i, DISPC_OVL_PRELOAD);
+		if (dispc_has_feature(dispc, FEAT_MFLAG))
+			DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
 
 		if (i == OMAP_DSS_GFX) {
-			DUMPREG(i, DISPC_OVL_WINDOW_SKIP);
-			DUMPREG(i, DISPC_OVL_TABLE_BA);
+			DUMPREG(dispc, i, DISPC_OVL_WINDOW_SKIP);
+			DUMPREG(dispc, i, DISPC_OVL_TABLE_BA);
 			continue;
 		}
 
-		DUMPREG(i, DISPC_OVL_FIR);
-		DUMPREG(i, DISPC_OVL_PICTURE_SIZE);
-		DUMPREG(i, DISPC_OVL_ACCU0);
-		DUMPREG(i, DISPC_OVL_ACCU1);
-		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
-			DUMPREG(i, DISPC_OVL_BA0_UV);
-			DUMPREG(i, DISPC_OVL_BA1_UV);
-			DUMPREG(i, DISPC_OVL_FIR2);
-			DUMPREG(i, DISPC_OVL_ACCU2_0);
-			DUMPREG(i, DISPC_OVL_ACCU2_1);
+		DUMPREG(dispc, i, DISPC_OVL_FIR);
+		DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
+		DUMPREG(dispc, i, DISPC_OVL_ACCU0);
+		DUMPREG(dispc, i, DISPC_OVL_ACCU1);
+		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
+			DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
+			DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
+			DUMPREG(dispc, i, DISPC_OVL_FIR2);
+			DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
+			DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
 		}
-		if (dispc_has_feature(FEAT_ATTR2))
-			DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
+		if (dispc_has_feature(dispc, FEAT_ATTR2))
+			DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
 	}
 
-	if (dispc.feat->has_writeback) {
+	if (dispc->feat->has_writeback) {
 		i = OMAP_DSS_WB;
-		DUMPREG(i, DISPC_OVL_BA0);
-		DUMPREG(i, DISPC_OVL_BA1);
-		DUMPREG(i, DISPC_OVL_SIZE);
-		DUMPREG(i, DISPC_OVL_ATTRIBUTES);
-		DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD);
-		DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
-		DUMPREG(i, DISPC_OVL_ROW_INC);
-		DUMPREG(i, DISPC_OVL_PIXEL_INC);
-
-		if (dispc_has_feature(FEAT_MFLAG))
-			DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
-
-		DUMPREG(i, DISPC_OVL_FIR);
-		DUMPREG(i, DISPC_OVL_PICTURE_SIZE);
-		DUMPREG(i, DISPC_OVL_ACCU0);
-		DUMPREG(i, DISPC_OVL_ACCU1);
-		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
-			DUMPREG(i, DISPC_OVL_BA0_UV);
-			DUMPREG(i, DISPC_OVL_BA1_UV);
-			DUMPREG(i, DISPC_OVL_FIR2);
-			DUMPREG(i, DISPC_OVL_ACCU2_0);
-			DUMPREG(i, DISPC_OVL_ACCU2_1);
+		DUMPREG(dispc, i, DISPC_OVL_BA0);
+		DUMPREG(dispc, i, DISPC_OVL_BA1);
+		DUMPREG(dispc, i, DISPC_OVL_SIZE);
+		DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
+		DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
+		DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
+		DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
+		DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
+
+		if (dispc_has_feature(dispc, FEAT_MFLAG))
+			DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
+
+		DUMPREG(dispc, i, DISPC_OVL_FIR);
+		DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
+		DUMPREG(dispc, i, DISPC_OVL_ACCU0);
+		DUMPREG(dispc, i, DISPC_OVL_ACCU1);
+		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
+			DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
+			DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
+			DUMPREG(dispc, i, DISPC_OVL_FIR2);
+			DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
+			DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
 		}
-		if (dispc_has_feature(FEAT_ATTR2))
-			DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
+		if (dispc_has_feature(dispc, FEAT_ATTR2))
+			DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
 	}
 
 #undef DISPC_REG
 #undef DUMPREG
 
 #define DISPC_REG(plane, name, i) name(plane, i)
-#define DUMPREG(plane, name, i) \
+#define DUMPREG(dispc, plane, name, i) \
 	seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \
 	(int)(46 - strlen(#name) - strlen(p_names[plane])), " ", \
-	dispc_read_reg(DISPC_REG(plane, name, i)))
+	dispc_read_reg(dispc, DISPC_REG(plane, name, i)))
 
 	/* Video pipeline coefficient registers */
 
 	/* start from OMAP_DSS_VIDEO1 */
-	for (i = 1; i < dispc_get_num_ovls(&dispc); i++) {
+	for (i = 1; i < dispc_get_num_ovls(dispc); i++) {
 		for (j = 0; j < 8; j++)
-			DUMPREG(i, DISPC_OVL_FIR_COEF_H, j);
+			DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H, j);
 
 		for (j = 0; j < 8; j++)
-			DUMPREG(i, DISPC_OVL_FIR_COEF_HV, j);
+			DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV, j);
 
 		for (j = 0; j < 5; j++)
-			DUMPREG(i, DISPC_OVL_CONV_COEF, j);
+			DUMPREG(dispc, i, DISPC_OVL_CONV_COEF, j);
 
-		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
+		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
 			for (j = 0; j < 8; j++)
-				DUMPREG(i, DISPC_OVL_FIR_COEF_V, j);
+				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V, j);
 		}
 
-		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
+		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
 			for (j = 0; j < 8; j++)
-				DUMPREG(i, DISPC_OVL_FIR_COEF_H2, j);
+				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H2, j);
 
 			for (j = 0; j < 8; j++)
-				DUMPREG(i, DISPC_OVL_FIR_COEF_HV2, j);
+				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV2, j);
 
 			for (j = 0; j < 8; j++)
-				DUMPREG(i, DISPC_OVL_FIR_COEF_V2, j);
+				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V2, j);
 		}
 	}
 
-	dispc_runtime_put(&dispc);
+	dispc_runtime_put(dispc);
 
 #undef DISPC_REG
 #undef DUMPREG
@@ -3549,8 +3664,8 @@ bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
 			 * also. Thus we need to use the calculated lck. For
 			 * OMAP4+ the DISPC fclk is a separate clock.
 			 */
-			if (dispc_has_feature(FEAT_CORE_CLK_DIV))
-				fck = dispc_core_clk_rate();
+			if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
+				fck = dispc_core_clk_rate(dispc);
 			else
 				fck = lck;
 
@@ -3572,7 +3687,7 @@ void dispc_mgr_set_clock_div(struct dispc_device *dispc,
 	DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
 	DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
 
-	dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div);
+	dispc_mgr_set_lcd_divisor(dispc, channel, cinfo->lck_div, cinfo->pck_div);
 }
 
 int dispc_mgr_get_clock_div(struct dispc_device *dispc,
@@ -3581,10 +3696,10 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
 {
 	unsigned long fck;
 
-	fck = dispc_fclk_rate();
+	fck = dispc_fclk_rate(dispc);
 
-	cinfo->lck_div = REG_GET(DISPC_DIVISORo(channel), 23, 16);
-	cinfo->pck_div = REG_GET(DISPC_DIVISORo(channel), 7, 0);
+	cinfo->lck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
+	cinfo->pck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 7, 0);
 
 	cinfo->lck = fck / cinfo->lck_div;
 	cinfo->pck = cinfo->lck / cinfo->pck_div;
@@ -3594,35 +3709,36 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
 
 static u32 dispc_read_irqstatus(struct dispc_device *dispc)
 {
-	return dispc_read_reg(DISPC_IRQSTATUS);
+	return dispc_read_reg(dispc, DISPC_IRQSTATUS);
 }
 
 static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
 {
-	dispc_write_reg(DISPC_IRQSTATUS, mask);
+	dispc_write_reg(dispc, DISPC_IRQSTATUS, mask);
 }
 
 static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
 {
-	u32 old_mask = dispc_read_reg(DISPC_IRQENABLE);
+	u32 old_mask = dispc_read_reg(dispc, DISPC_IRQENABLE);
 
 	/* clear the irqstatus for newly enabled irqs */
 	dispc_clear_irqstatus(dispc, (mask ^ old_mask) & mask);
 
-	dispc_write_reg(DISPC_IRQENABLE, mask);
+	dispc_write_reg(dispc, DISPC_IRQENABLE, mask);
 
 	/* flush posted write */
-	dispc_read_reg(DISPC_IRQENABLE);
+	dispc_read_reg(dispc, DISPC_IRQENABLE);
 }
 
 void dispc_enable_sidle(struct dispc_device *dispc)
 {
-	REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3);	/* SIDLEMODE: smart idle */
+	/* SIDLEMODE: smart idle */
+	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 2, 4, 3);
 }
 
 void dispc_disable_sidle(struct dispc_device *dispc)
 {
-	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
+	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
 }
 
 static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
@@ -3636,10 +3752,11 @@ static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
 	return gdesc->len;
 }
 
-static void dispc_mgr_write_gamma_table(enum omap_channel channel)
+static void dispc_mgr_write_gamma_table(struct dispc_device *dispc,
+					enum omap_channel channel)
 {
 	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
-	u32 *table = dispc.gamma_table[channel];
+	u32 *table = dispc->gamma_table[channel];
 	unsigned int i;
 
 	DSSDBG("%s: channel %d\n", __func__, channel);
@@ -3652,26 +3769,26 @@ static void dispc_mgr_write_gamma_table(enum omap_channel channel)
 		else if (i == 0)
 			v |= 1 << 31;
 
-		dispc_write_reg(gdesc->reg, v);
+		dispc_write_reg(dispc, gdesc->reg, v);
 	}
 }
 
-static void dispc_restore_gamma_tables(void)
+static void dispc_restore_gamma_tables(struct dispc_device *dispc)
 {
 	DSSDBG("%s()\n", __func__);
 
-	if (!dispc.feat->has_gamma_table)
+	if (!dispc->feat->has_gamma_table)
 		return;
 
-	dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD);
+	dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD);
 
-	dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_DIGIT);
+	dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_DIGIT);
 
-	if (dispc_has_feature(FEAT_MGR_LCD2))
-		dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD2);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
+		dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD2);
 
-	if (dispc_has_feature(FEAT_MGR_LCD3))
-		dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD3);
+	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
+		dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD3);
 }
 
 static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
@@ -3724,81 +3841,82 @@ static void dispc_mgr_set_gamma(struct dispc_device *dispc,
 	}
 
 	if (dispc->is_enabled)
-		dispc_mgr_write_gamma_table(channel);
+		dispc_mgr_write_gamma_table(dispc, channel);
 }
 
-static int dispc_init_gamma_tables(void)
+static int dispc_init_gamma_tables(struct dispc_device *dispc)
 {
 	int channel;
 
-	if (!dispc.feat->has_gamma_table)
+	if (!dispc->feat->has_gamma_table)
 		return 0;
 
-	for (channel = 0; channel < ARRAY_SIZE(dispc.gamma_table); channel++) {
+	for (channel = 0; channel < ARRAY_SIZE(dispc->gamma_table); channel++) {
 		const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
 		u32 *gt;
 
 		if (channel == OMAP_DSS_CHANNEL_LCD2 &&
-		    !dispc_has_feature(FEAT_MGR_LCD2))
+		    !dispc_has_feature(dispc, FEAT_MGR_LCD2))
 			continue;
 
 		if (channel == OMAP_DSS_CHANNEL_LCD3 &&
-		    !dispc_has_feature(FEAT_MGR_LCD3))
+		    !dispc_has_feature(dispc, FEAT_MGR_LCD3))
 			continue;
 
-		gt = devm_kmalloc_array(&dispc.pdev->dev, gdesc->len,
-					   sizeof(u32), GFP_KERNEL);
+		gt = devm_kmalloc_array(&dispc->pdev->dev, gdesc->len,
+					sizeof(u32), GFP_KERNEL);
 		if (!gt)
 			return -ENOMEM;
 
-		dispc.gamma_table[channel] = gt;
+		dispc->gamma_table[channel] = gt;
 
-		dispc_mgr_set_gamma(&dispc, channel, NULL, 0);
+		dispc_mgr_set_gamma(dispc, channel, NULL, 0);
 	}
 	return 0;
 }
 
-static void _omap_dispc_initial_config(void)
+static void _omap_dispc_initial_config(struct dispc_device *dispc)
 {
 	u32 l;
 
 	/* Exclusively enable DISPC_CORE_CLK and set divider to 1 */
-	if (dispc_has_feature(FEAT_CORE_CLK_DIV)) {
-		l = dispc_read_reg(DISPC_DIVISOR);
+	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
+		l = dispc_read_reg(dispc, DISPC_DIVISOR);
 		/* Use DISPC_DIVISOR.LCD, instead of DISPC_DIVISOR1.LCD */
 		l = FLD_MOD(l, 1, 0, 0);
 		l = FLD_MOD(l, 1, 23, 16);
-		dispc_write_reg(DISPC_DIVISOR, l);
+		dispc_write_reg(dispc, DISPC_DIVISOR, l);
 
-		dispc.core_clk_rate = dispc_fclk_rate();
+		dispc->core_clk_rate = dispc_fclk_rate(dispc);
 	}
 
 	/* Use gamma table mode, instead of palette mode */
-	if (dispc.feat->has_gamma_table)
-		REG_FLD_MOD(DISPC_CONFIG, 1, 3, 3);
+	if (dispc->feat->has_gamma_table)
+		REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 3, 3);
 
 	/* For older DSS versions (FEAT_FUNCGATED) this enables
 	 * func-clock auto-gating. For newer versions
-	 * (dispc.feat->has_gamma_table) this enables tv-out gamma tables.
+	 * (dispc->feat->has_gamma_table) this enables tv-out gamma tables.
 	 */
-	if (dispc_has_feature(FEAT_FUNCGATED) || dispc.feat->has_gamma_table)
-		REG_FLD_MOD(DISPC_CONFIG, 1, 9, 9);
+	if (dispc_has_feature(dispc, FEAT_FUNCGATED) ||
+	    dispc->feat->has_gamma_table)
+		REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 9, 9);
 
-	dispc_setup_color_conv_coef();
+	dispc_setup_color_conv_coef(dispc);
 
-	dispc_set_loadmode(OMAP_DSS_LOAD_FRAME_ONLY);
+	dispc_set_loadmode(dispc, OMAP_DSS_LOAD_FRAME_ONLY);
 
-	dispc_init_fifos();
+	dispc_init_fifos(dispc);
 
-	dispc_configure_burst_sizes();
+	dispc_configure_burst_sizes(dispc);
 
-	dispc_ovl_enable_zorder_planes();
+	dispc_ovl_enable_zorder_planes(dispc);
 
-	if (dispc.feat->mstandby_workaround)
-		REG_FLD_MOD(DISPC_MSTANDBY_CTRL, 1, 0, 0);
+	if (dispc->feat->mstandby_workaround)
+		REG_FLD_MOD(dispc, DISPC_MSTANDBY_CTRL, 1, 0, 0);
 
-	if (dispc_has_feature(FEAT_MFLAG))
-		dispc_init_mflag();
+	if (dispc_has_feature(dispc, FEAT_MFLAG))
+		dispc_init_mflag(dispc);
 }
 
 static const enum dispc_feature_id omap2_dispc_features_list[] = {
@@ -4317,10 +4435,12 @@ static const struct dispc_features omap54xx_dispc_feats = {
 
 static irqreturn_t dispc_irq_handler(int irq, void *arg)
 {
-	if (!dispc.is_enabled)
+	struct dispc_device *dispc = arg;
+
+	if (!dispc->is_enabled)
 		return IRQ_NONE;
 
-	return dispc.user_handler(irq, dispc.user_data);
+	return dispc->user_handler(irq, dispc->user_data);
 }
 
 static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
@@ -4426,18 +4546,18 @@ static struct i734_buf {
 	void *vaddr;
 } i734_buf;
 
-static int dispc_errata_i734_wa_init(void)
+static int dispc_errata_i734_wa_init(struct dispc_device *dispc)
 {
-	if (!dispc.feat->has_gamma_i734_bug)
+	if (!dispc->feat->has_gamma_i734_bug)
 		return 0;
 
 	i734_buf.size = i734.ovli.width * i734.ovli.height *
 		color_mode_to_bpp(i734.ovli.fourcc) / 8;
 
-	i734_buf.vaddr = dma_alloc_writecombine(&dispc.pdev->dev, i734_buf.size,
+	i734_buf.vaddr = dma_alloc_writecombine(&dispc->pdev->dev, i734_buf.size,
 						&i734_buf.paddr, GFP_KERNEL);
 	if (!i734_buf.vaddr) {
-		dev_err(&dispc.pdev->dev, "%s: dma_alloc_writecombine failed",
+		dev_err(&dispc->pdev->dev, "%s: dma_alloc_writecombine failed",
 			__func__);
 		return -ENOMEM;
 	}
@@ -4445,73 +4565,73 @@ static int dispc_errata_i734_wa_init(void)
 	return 0;
 }
 
-static void dispc_errata_i734_wa_fini(void)
+static void dispc_errata_i734_wa_fini(struct dispc_device *dispc)
 {
-	if (!dispc.feat->has_gamma_i734_bug)
+	if (!dispc->feat->has_gamma_i734_bug)
 		return;
 
-	dma_free_writecombine(&dispc.pdev->dev, i734_buf.size, i734_buf.vaddr,
+	dma_free_writecombine(&dispc->pdev->dev, i734_buf.size, i734_buf.vaddr,
 			      i734_buf.paddr);
 }
 
-static void dispc_errata_i734_wa(void)
+static void dispc_errata_i734_wa(struct dispc_device *dispc)
 {
-	u32 framedone_irq = dispc_mgr_get_framedone_irq(&dispc,
+	u32 framedone_irq = dispc_mgr_get_framedone_irq(dispc,
 							OMAP_DSS_CHANNEL_LCD);
 	struct omap_overlay_info ovli;
 	struct dss_lcd_mgr_config lcd_conf;
 	u32 gatestate;
 	unsigned int count;
 
-	if (!dispc.feat->has_gamma_i734_bug)
+	if (!dispc->feat->has_gamma_i734_bug)
 		return;
 
-	gatestate = REG_GET(DISPC_CONFIG, 8, 4);
+	gatestate = REG_GET(dispc, DISPC_CONFIG, 8, 4);
 
 	ovli = i734.ovli;
 	ovli.paddr = i734_buf.paddr;
 	lcd_conf = i734.lcd_conf;
 
 	/* Gate all LCD1 outputs */
-	REG_FLD_MOD(DISPC_CONFIG, 0x1f, 8, 4);
+	REG_FLD_MOD(dispc, DISPC_CONFIG, 0x1f, 8, 4);
 
 	/* Setup and enable GFX plane */
-	dispc_ovl_setup(&dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
+	dispc_ovl_setup(dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
 			OMAP_DSS_CHANNEL_LCD);
-	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, true);
+	dispc_ovl_enable(dispc, OMAP_DSS_GFX, true);
 
 	/* Set up and enable display manager for LCD1 */
-	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
-	dispc_calc_clock_rates(&dispc, dss_get_dispc_clk_rate(dispc.dss),
+	dispc_mgr_setup(dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
+	dispc_calc_clock_rates(dispc, dss_get_dispc_clk_rate(dispc->dss),
 			       &lcd_conf.clock_info);
-	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
-	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
+	dispc_mgr_set_lcd_config(dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
+	dispc_mgr_set_timings(dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
 
-	dispc_clear_irqstatus(&dispc, framedone_irq);
+	dispc_clear_irqstatus(dispc, framedone_irq);
 
 	/* Enable and shut the channel to produce just one frame */
-	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, true);
-	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, false);
+	dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, true);
+	dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, false);
 
 	/* Busy wait for framedone. We can't fiddle with irq handlers
 	 * in PM resume. Typically the loop runs less than 5 times and
 	 * waits less than a micro second.
 	 */
 	count = 0;
-	while (!(dispc_read_irqstatus(&dispc) & framedone_irq)) {
+	while (!(dispc_read_irqstatus(dispc) & framedone_irq)) {
 		if (count++ > 10000) {
-			dev_err(&dispc.pdev->dev, "%s: framedone timeout\n",
+			dev_err(&dispc->pdev->dev, "%s: framedone timeout\n",
 				__func__);
 			break;
 		}
 	}
-	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, false);
+	dispc_ovl_enable(dispc, OMAP_DSS_GFX, false);
 
 	/* Clear all irq bits before continuing */
-	dispc_clear_irqstatus(&dispc, 0xffffffff);
+	dispc_clear_irqstatus(dispc, 0xffffffff);
 
 	/* Restore the original state to LCD1 output gates */
-	REG_FLD_MOD(DISPC_CONFIG, gatestate, 8, 4);
+	REG_FLD_MOD(dispc, DISPC_CONFIG, gatestate, 8, 4);
 }
 
 static const struct dispc_ops dispc_ops = {
@@ -4571,15 +4691,21 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	struct platform_device *pdev = to_platform_device(dev);
 	const struct soc_device_attribute *soc;
 	struct dss_device *dss = dss_get_device(master);
+	struct dispc_device *dispc;
 	u32 rev;
 	int r = 0;
 	struct resource *dispc_mem;
 	struct device_node *np = pdev->dev.of_node;
 
-	dispc.pdev = pdev;
-	dispc.dss = dss;
+	dispc = kzalloc(sizeof(*dispc), GFP_KERNEL);
+	if (!dispc)
+		return -ENOMEM;
+
+	dispc->pdev = pdev;
+	platform_set_drvdata(pdev, dispc);
+	dispc->dss = dss;
 
-	spin_lock_init(&dispc.control_lock);
+	spin_lock_init(&dispc->control_lock);
 
 	/*
 	 * The OMAP3-based models can't be told apart using the compatible
@@ -4587,82 +4713,92 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	 */
 	soc = soc_device_match(dispc_soc_devices);
 	if (soc)
-		dispc.feat = soc->data;
+		dispc->feat = soc->data;
 	else
-		dispc.feat = of_match_device(dispc_of_match, &pdev->dev)->data;
+		dispc->feat = of_match_device(dispc_of_match, &pdev->dev)->data;
 
-	r = dispc_errata_i734_wa_init();
+	r = dispc_errata_i734_wa_init(dispc);
 	if (r)
-		return r;
+		goto err_free;
 
-	dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
-	dispc.base = devm_ioremap_resource(&pdev->dev, dispc_mem);
-	if (IS_ERR(dispc.base))
-		return PTR_ERR(dispc.base);
+	dispc_mem = platform_get_resource(dispc->pdev, IORESOURCE_MEM, 0);
+	dispc->base = devm_ioremap_resource(&pdev->dev, dispc_mem);
+	if (IS_ERR(dispc->base)) {
+		r = PTR_ERR(dispc->base);
+		goto err_free;
+	}
 
-	dispc.irq = platform_get_irq(dispc.pdev, 0);
-	if (dispc.irq < 0) {
+	dispc->irq = platform_get_irq(dispc->pdev, 0);
+	if (dispc->irq < 0) {
 		DSSERR("platform_get_irq failed\n");
-		return -ENODEV;
+		r = -ENODEV;
+		goto err_free;
 	}
 
 	if (np && of_property_read_bool(np, "syscon-pol")) {
-		dispc.syscon_pol = syscon_regmap_lookup_by_phandle(np, "syscon-pol");
-		if (IS_ERR(dispc.syscon_pol)) {
+		dispc->syscon_pol = syscon_regmap_lookup_by_phandle(np, "syscon-pol");
+		if (IS_ERR(dispc->syscon_pol)) {
 			dev_err(&pdev->dev, "failed to get syscon-pol regmap\n");
-			return PTR_ERR(dispc.syscon_pol);
+			r = PTR_ERR(dispc->syscon_pol);
+			goto err_free;
 		}
 
 		if (of_property_read_u32_index(np, "syscon-pol", 1,
-				&dispc.syscon_pol_offset)) {
+				&dispc->syscon_pol_offset)) {
 			dev_err(&pdev->dev, "failed to get syscon-pol offset\n");
-			return -EINVAL;
+			r = -EINVAL;
+			goto err_free;
 		}
 	}
 
-	r = dispc_init_gamma_tables();
+	r = dispc_init_gamma_tables(dispc);
 	if (r)
-		return r;
+		goto err_free;
 
 	pm_runtime_enable(&pdev->dev);
 
-	r = dispc_runtime_get(&dispc);
+	r = dispc_runtime_get(dispc);
 	if (r)
 		goto err_runtime_get;
 
-	_omap_dispc_initial_config();
+	_omap_dispc_initial_config(dispc);
 
-	rev = dispc_read_reg(DISPC_REVISION);
+	rev = dispc_read_reg(dispc, DISPC_REVISION);
 	dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
 	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
-	dispc_runtime_put(&dispc);
+	dispc_runtime_put(dispc);
 
 	dispc_set_ops(&dispc_ops);
-	dss->dispc = &dispc;
+	dss->dispc = dispc;
 
-	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
-						&dispc);
+	dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+						 dispc);
 
 	return 0;
 
 err_runtime_get:
 	pm_runtime_disable(&pdev->dev);
+err_free:
+	kfree(dispc);
 	return r;
 }
 
 static void dispc_unbind(struct device *dev, struct device *master, void *data)
 {
-	struct dss_device *dss = dispc.dss;
+	struct dispc_device *dispc = dev_get_drvdata(dev);
+	struct dss_device *dss = dispc->dss;
 
-	dss_debugfs_remove_file(dispc.debugfs);
+	dss_debugfs_remove_file(dispc->debugfs);
 
 	dispc_set_ops(NULL);
 	dss->dispc = NULL;
 
 	pm_runtime_disable(dev);
 
-	dispc_errata_i734_wa_fini();
+	dispc_errata_i734_wa_fini(dispc);
+
+	kfree(dispc);
 }
 
 static const struct component_ops dispc_component_ops = {
@@ -4683,36 +4819,40 @@ static int dispc_remove(struct platform_device *pdev)
 
 static int dispc_runtime_suspend(struct device *dev)
 {
-	dispc.is_enabled = false;
+	struct dispc_device *dispc = dev_get_drvdata(dev);
+
+	dispc->is_enabled = false;
 	/* ensure the dispc_irq_handler sees the is_enabled value */
 	smp_wmb();
 	/* wait for current handler to finish before turning the DISPC off */
-	synchronize_irq(dispc.irq);
+	synchronize_irq(dispc->irq);
 
-	dispc_save_context();
+	dispc_save_context(dispc);
 
 	return 0;
 }
 
 static int dispc_runtime_resume(struct device *dev)
 {
+	struct dispc_device *dispc = dev_get_drvdata(dev);
+
 	/*
 	 * The reset value for load mode is 0 (OMAP_DSS_LOAD_CLUT_AND_FRAME)
 	 * but we always initialize it to 2 (OMAP_DSS_LOAD_FRAME_ONLY) in
 	 * _omap_dispc_initial_config(). We can thus use it to detect if
 	 * we have lost register context.
 	 */
-	if (REG_GET(DISPC_CONFIG, 2, 1) != OMAP_DSS_LOAD_FRAME_ONLY) {
-		_omap_dispc_initial_config();
+	if (REG_GET(dispc, DISPC_CONFIG, 2, 1) != OMAP_DSS_LOAD_FRAME_ONLY) {
+		_omap_dispc_initial_config(dispc);
 
-		dispc_errata_i734_wa();
+		dispc_errata_i734_wa(dispc);
 
-		dispc_restore_context();
+		dispc_restore_context(dispc);
 
-		dispc_restore_gamma_tables();
+		dispc_restore_gamma_tables(dispc);
 	}
 
-	dispc.is_enabled = true;
+	dispc->is_enabled = true;
 	/* ensure the dispc_irq_handler sees the is_enabled value */
 	smp_wmb();
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (45 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 22:16   ` Sebastian Reichel
  2017-10-13 14:59 ` [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array " Laurent Pinchart
                   ` (4 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

As part of an effort to remove the usage of global variables in the
driver, store the debugfs root directory in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 ++++----
 drivers/gpu/drm/omapdrm/dss/dss.c   | 39 +++++++++++++++++++------------------
 drivers/gpu/drm/omapdrm/dss/dss.h   |  9 ++++++---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/venc.c  |  3 ++-
 7 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index aaf7396f0273..5eacf4cdac54 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -4772,7 +4772,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	dispc_set_ops(&dispc_ops);
 	dss->dispc = dispc;
 
-	dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+	dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
 						 dispc);
 
 	return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c7700dfccc08..48ea5285cf20 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5453,20 +5453,20 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 	dsi_runtime_put(dsi);
 
 	if (dsi->module_id == 0)
-		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
+		dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi1_regs",
 							    dsi1_dump_regs,
 							    &dsi);
 	else
-		dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
+		dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi2_regs",
 							    dsi2_dump_regs,
 							    &dsi);
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
 	if (dsi->module_id == 0)
-		dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
+		dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi1_irqs",
 							    dsi1_dump_irqs,
 							    &dsi);
 	else
-		dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
+		dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi2_irqs",
 							    dsi2_dump_irqs,
 							    &dsi);
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 5d927dfe0a7f..f4e15850cc9d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -906,25 +906,23 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
 	return 0;
 }
 
-static struct dentry *dss_debugfs_dir;
-
 static int dss_initialize_debugfs(struct dss_device *dss)
 {
-	dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
-	if (IS_ERR(dss_debugfs_dir)) {
-		int err = PTR_ERR(dss_debugfs_dir);
+	static struct dentry *dir;
 
-		dss_debugfs_dir = NULL;
-		return err;
-	}
+	dir = debugfs_create_dir("omapdss", NULL);
+	if (IS_ERR(dir))
+		return PTR_ERR(dir);
+
+	dss->debugfs.root = dir;
 
 	return 0;
 }
 
-static void dss_uninitialize_debugfs(void)
+static void dss_uninitialize_debugfs(struct dss_device *dss)
 {
-	if (dss_debugfs_dir)
-		debugfs_remove_recursive(dss_debugfs_dir);
+	if (dss->debugfs.root)
+		debugfs_remove_recursive(dss->debugfs.root);
 }
 
 struct dss_debugfs_entry {
@@ -947,8 +945,10 @@ static const struct file_operations dss_debug_fops = {
 	.release	= single_release,
 };
 
-struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
-		int (*show_fn)(struct seq_file *s, void *data), void *data)
+struct dss_debugfs_entry *
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
+			int (*show_fn)(struct seq_file *s, void *data),
+			void *data)
 {
 	struct dss_debugfs_entry *entry;
 	struct dentry *d;
@@ -960,7 +960,7 @@ struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
 	entry->show_fn = show_fn;
 	entry->data = data;
 
-	d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
+	d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
 				&dss_debug_fops);
 	if (IS_ERR(d)) {
 		kfree(entry);
@@ -985,7 +985,7 @@ static inline int dss_initialize_debugfs(struct dss_device *dss)
 {
 	return 0;
 }
-static inline void dss_uninitialize_debugfs(void)
+static inline void dss_uninitialize_debugfs(struct dss_device *dss)
 {
 }
 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
@@ -1382,9 +1382,10 @@ static int dss_bind(struct device *dev)
 	if (r)
 		goto err_component;
 
-	dss->debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
+	dss->debugfs.clk = dss_debugfs_create_file(dss, "clk",
+						   dss_debug_dump_clocks, dss);
+	dss->debugfs.dss = dss_debugfs_create_file(dss, "dss", dss_dump_regs,
 						   dss);
-	dss->debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, dss);
 
 	pm_set_vt_switch(0);
 
@@ -1511,7 +1512,7 @@ static int dss_probe(struct platform_device *pdev)
 	return 0;
 
 err_debugfs:
-	dss_uninitialize_debugfs();
+	dss_uninitialize_debugfs(dss);
 err_free_dss:
 	kfree(dss);
 	return r;
@@ -1523,7 +1524,7 @@ static int dss_remove(struct platform_device *pdev)
 
 	component_master_del(&pdev->dev, &dss_component_ops);
 
-	dss_uninitialize_debugfs();
+	dss_uninitialize_debugfs(dss);
 	kfree(dss);
 
 	return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index ceba8441c7cc..76a2561dfd22 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -271,6 +271,7 @@ struct dss_device {
 	const struct dss_features *feat;
 
 	struct {
+		struct dentry *root;
 		struct dss_debugfs_entry *clk;
 		struct dss_debugfs_entry *dss;
 	} debugfs;
@@ -299,12 +300,14 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
 
 /* DSS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
-struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
-		int (*show_fn)(struct seq_file *s, void *data), void *data);
+struct dss_debugfs_entry *
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
+			int (*show_fn)(struct seq_file *s, void *data),
+			void *data);
 void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
 #else
 static inline struct dss_debugfs_entry *
-dss_debugfs_create_file(const char *name,
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
 			int (*show_fn)(struct seq_file *s, void *data),
 			void *data)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 2050601fef0a..f523b426420f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -800,7 +800,8 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 		return r;
 	}
 
-	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
+	hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+						hdmi);
 
 	return 0;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index ec3b044925d0..9017d78a9756 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -794,7 +794,8 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 		return r;
 	}
 
-	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
+	hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+						hdmi);
 
 	return 0;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 449a82b84d03..5e475cafb7a4 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -940,7 +940,8 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
 		goto err_probe_of;
 	}
 
-	venc->debugfs = dss_debugfs_create_file("venc", venc_dump_regs, venc);
+	venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs,
+						venc);
 
 	venc_init_output(venc);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array in struct dss_device
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (46 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Laurent Pinchart
@ 2017-10-13 14:59 ` Laurent Pinchart
  2017-10-17 22:21   ` Sebastian Reichel
  2017-10-17 22:29 ` [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Sebastian Reichel
                   ` (3 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-13 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

As part of an effort to remove the usage of global variables in the
driver, store the registered plls array in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c     |  4 ++--
 drivers/gpu/drm/omapdrm/dss/dpi.c       | 17 +++++++-------
 drivers/gpu/drm/omapdrm/dss/dsi.c       |  3 +--
 drivers/gpu/drm/omapdrm/dss/dss.h       | 12 +++++-----
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  3 +--
 drivers/gpu/drm/omapdrm/dss/pll.c       | 40 +++++++++++++++++----------------
 drivers/gpu/drm/omapdrm/dss/video-pll.c |  3 +--
 7 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 5eacf4cdac54..181a8ea072b1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -3252,7 +3252,7 @@ static unsigned long dispc_fclk_rate(struct dispc_device *dispc)
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
 
-		pll = dss_pll_find_by_src(src);
+		pll = dss_pll_find_by_src(dispc->dss, src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
 		r = pll->cinfo.clkout[clkout_idx];
@@ -3280,7 +3280,7 @@ static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
 
-		pll = dss_pll_find_by_src(src);
+		pll = dss_pll_find_by_src(dispc->dss, src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
 		r = pll->cinfo.clkout[clkout_idx];
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 66183fc77bb2..2fb9406d2059 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -60,7 +60,8 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
 	return container_of(dssdev, struct dpi_data, output);
 }
 
-static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
+static enum dss_clk_source dpi_get_clk_src_dra7xx(struct dpi_data *dpi,
+						  enum omap_channel channel)
 {
 	/*
 	 * Possible clock sources:
@@ -72,23 +73,23 @@ static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
 	switch (channel) {
 	case OMAP_DSS_CHANNEL_LCD:
 	{
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1))
+		if (dss_pll_find_by_src(dpi->dss, 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))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
 			return DSS_CLK_SRC_PLL1_3;
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3))
+		if (dss_pll_find_by_src(dpi->dss, 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))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_1))
 			return DSS_CLK_SRC_PLL2_1;
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
 			return DSS_CLK_SRC_PLL1_3;
 		break;
 	}
@@ -135,7 +136,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
 		}
 
 	case DSS_MODEL_DRA7:
-		return dpi_get_clk_src_dra7xx(channel);
+		return dpi_get_clk_src_dra7xx(dpi, channel);
 
 	default:
 		return DSS_CLK_SRC_FCK;
@@ -603,7 +604,7 @@ static void dpi_init_pll(struct dpi_data *dpi)
 
 	dpi->clk_src = dpi_get_clk_src(dpi);
 
-	pll = dss_pll_find_by_src(dpi->clk_src);
+	pll = dss_pll_find_by_src(dpi->dss, dpi->clk_src);
 	if (!pll)
 		return;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 48ea5285cf20..bc9d6b7ce6a9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5226,9 +5226,8 @@ static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
 	pll->base = dsi->pll_base;
 	pll->hw = dsi->data->pll_hw;
 	pll->ops = &dsi_pll_ops;
-	pll->dss = dss;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 76a2561dfd22..9ca4391624cc 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -276,8 +276,9 @@ struct dss_device {
 		struct dss_debugfs_entry *dss;
 	} debugfs;
 
-	struct dss_pll	*video1_pll;
-	struct dss_pll	*video2_pll;
+	struct dss_pll *plls[4];
+	struct dss_pll *video1_pll;
+	struct dss_pll *video2_pll;
 
 	struct dispc_device *dispc;
 };
@@ -499,10 +500,11 @@ typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
 typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
 		void *data);
 
-int dss_pll_register(struct dss_pll *pll);
+int dss_pll_register(struct dss_device *dss, struct dss_pll *pll);
 void dss_pll_unregister(struct dss_pll *pll);
-struct dss_pll *dss_pll_find(const char *name);
-struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
+struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name);
+struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
+				    enum dss_clk_source src);
 unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
 int dss_pll_enable(struct dss_pll *pll);
 void dss_pll_disable(struct dss_pll *pll);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 4da32c261c30..d1116757182e 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -146,7 +146,6 @@ static int hdmi_init_pll_data(struct dss_device *dss,
 	pll->id = DSS_PLL_HDMI;
 	pll->base = hpll->base;
 	pll->clkin = clk;
-	pll->dss = dss;
 
 	if (hpll->wp->version == 4)
 		pll->hw = &dss_omap4_hdmi_pll_hw;
@@ -155,7 +154,7 @@ static int hdmi_init_pll_data(struct dss_device *dss,
 
 	pll->ops = &hdmi_pll_ops;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
index d298cd5a927a..56fc2fccd0e0 100644
--- a/drivers/gpu/drm/omapdrm/dss/pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/pll.c
@@ -35,15 +35,14 @@
 #define PLL_SSC_CONFIGURATION2		0x001C
 #define PLL_CONFIGURATION4		0x0020
 
-static struct dss_pll *dss_plls[4];
-
-int dss_pll_register(struct dss_pll *pll)
+int dss_pll_register(struct dss_device *dss, struct dss_pll *pll)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (!dss_plls[i]) {
-			dss_plls[i] = pll;
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (!dss->plls[i]) {
+			dss->plls[i] = pll;
+			pll->dss = dss;
 			return 0;
 		}
 	}
@@ -53,29 +52,32 @@ int dss_pll_register(struct dss_pll *pll)
 
 void dss_pll_unregister(struct dss_pll *pll)
 {
+	struct dss_device *dss = pll->dss;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (dss_plls[i] == pll) {
-			dss_plls[i] = NULL;
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (dss->plls[i] == pll) {
+			dss->plls[i] = NULL;
+			pll->dss = NULL;
 			return;
 		}
 	}
 }
 
-struct dss_pll *dss_pll_find(const char *name)
+struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (dss_plls[i] && strcmp(dss_plls[i]->name, name) == 0)
-			return dss_plls[i];
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (dss->plls[i] && strcmp(dss->plls[i]->name, name) == 0)
+			return dss->plls[i];
 	}
 
 	return NULL;
 }
 
-struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
+struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
+				    enum dss_clk_source src)
 {
 	struct dss_pll *pll;
 
@@ -85,22 +87,22 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
 		return NULL;
 
 	case DSS_CLK_SRC_HDMI_PLL:
-		return dss_pll_find("hdmi");
+		return dss_pll_find(dss, "hdmi");
 
 	case DSS_CLK_SRC_PLL1_1:
 	case DSS_CLK_SRC_PLL1_2:
 	case DSS_CLK_SRC_PLL1_3:
-		pll = dss_pll_find("dsi0");
+		pll = dss_pll_find(dss, "dsi0");
 		if (!pll)
-			pll = dss_pll_find("video0");
+			pll = dss_pll_find(dss, "video0");
 		return pll;
 
 	case DSS_CLK_SRC_PLL2_1:
 	case DSS_CLK_SRC_PLL2_2:
 	case DSS_CLK_SRC_PLL2_3:
-		pll = dss_pll_find("dsi1");
+		pll = dss_pll_find(dss, "dsi1");
 		if (!pll)
-			pll = dss_pll_find("video1");
+			pll = dss_pll_find(dss, "video1");
 		return pll;
 	}
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 989a5ee4433a..2ea50cbe53ab 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -188,9 +188,8 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
 	pll->base = pll_base;
 	pll->hw = &dss_dra7_video_pll_hw;
 	pll->ops = &dss_pll_ops;
-	pll->dss = dss;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return ERR_PTR(r);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* Re: [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error
  2017-10-13 14:58 ` [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error Laurent Pinchart
@ 2017-10-14 12:11   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:11 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1183 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:58:57PM +0300, Laurent Pinchart wrote:
> There's no need to print an error message on probe deferral, that's a
> normal situation. Probe deferral debugging can be performed by enabling
> the related debug messages in the drivers core.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> index 947295f9e30f..b8e420c7d680 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> @@ -173,7 +173,8 @@ static int tfp410_probe_of(struct platform_device *pdev)
>  	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
>  		ddata->pd_gpio = gpio;
>  	} else {
> -		dev_err(&pdev->dev, "failed to parse PD gpio\n");
> +		if (gpio != -EPROBE_DEFER)
> +			dev_err(&pdev->dev, "failed to parse PD gpio\n");
>  		return gpio;
>  	}

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume()
  2017-10-13 14:58 ` [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume() Laurent Pinchart
@ 2017-10-14 12:15   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:15 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2774 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:58:58PM +0300, Laurent Pinchart wrote:
> The omap_gem_resume() function is internal to the driver. Pass it a
> drm_device pointer that the caller already has instead of looking it up
> from device data.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
>  drivers/gpu/drm/omapdrm/omap_drv.h | 2 +-
>  drivers/gpu/drm/omapdrm/omap_gem.c | 7 +++----
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index cdf5b0601eba..2d15ea1d6c92 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -740,7 +740,7 @@ static int omap_drm_resume(struct device *dev)
>  
>  	drm_kms_helper_poll_enable(drm_dev);
>  
> -	return omap_gem_resume(dev);
> +	return omap_gem_resume(drm_dev);
>  }
>  #endif
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 4bd1e9070b31..04f35f74f80c 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -94,7 +94,7 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
>  #endif
>  
>  #ifdef CONFIG_PM
> -int omap_gem_resume(struct device *dev);
> +int omap_gem_resume(struct drm_device *dev);
>  #endif
>  
>  int omap_irq_enable_vblank(struct drm_crtc *crtc);
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
> index 5c5c86ddd6f4..fd81396baaf9 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> @@ -996,10 +996,9 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
>  
>  #ifdef CONFIG_PM
>  /* re-pin objects in DMM in resume path: */
> -int omap_gem_resume(struct device *dev)
> +int omap_gem_resume(struct drm_device *dev)
>  {
> -	struct drm_device *drm_dev = dev_get_drvdata(dev);
> -	struct omap_drm_private *priv = drm_dev->dev_private;
> +	struct omap_drm_private *priv = dev->dev_private;
>  	struct omap_gem_object *omap_obj;
>  	int ret = 0;
>  
> @@ -1012,7 +1011,7 @@ int omap_gem_resume(struct device *dev)
>  					omap_obj->pages, npages,
>  					omap_obj->roll, true);
>  			if (ret) {
> -				dev_err(dev, "could not repin: %d\n", ret);
> +				dev_err(dev->dev, "could not repin: %d\n", ret);
>  				return ret;
>  			}
>  		}
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function
  2017-10-13 14:58 ` [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function Laurent Pinchart
@ 2017-10-14 12:16   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:16 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2214 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:58:59PM +0300, Laurent Pinchart wrote:
> The omap_dss_find_device() function is unused. Remove it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/gpu/drm/omapdrm/dss/display.c | 14 --------------
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ---
>  2 files changed, 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
> index 42279933790e..8c77a2d20969 100644
> --- a/drivers/gpu/drm/omapdrm/dss/display.c
> +++ b/drivers/gpu/drm/omapdrm/dss/display.c
> @@ -175,17 +175,3 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
>  	return dssdev;
>  }
>  EXPORT_SYMBOL(omap_dss_get_next_device);
> -
> -struct omap_dss_device *omap_dss_find_device(void *data,
> -		int (*match)(struct omap_dss_device *dssdev, void *data))
> -{
> -	struct omap_dss_device *dssdev = NULL;
> -
> -	while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) {
> -		if (match(dssdev, data))
> -			return dssdev;
> -	}
> -
> -	return NULL;
> -}
> -EXPORT_SYMBOL(omap_dss_find_device);
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 990422b35784..6f7dc8384055 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -595,9 +595,6 @@ struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
>  void omap_dss_put_device(struct omap_dss_device *dssdev);
>  #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
>  struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
> -struct omap_dss_device *omap_dss_find_device(void *data,
> -		int (*match)(struct omap_dss_device *dssdev, void *data));
> -
>  
>  int omap_dss_get_num_overlay_managers(void);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules
  2017-10-13 14:59 ` [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules Laurent Pinchart
@ 2017-10-14 12:22   ` Sebastian Reichel
  2017-10-16  9:04     ` Laurent Pinchart
  2017-10-18  9:19   ` Tomi Valkeinen
  1 sibling, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:22 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 8354 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:00PM +0300, Laurent Pinchart wrote:
> There's no need for the omapdss-base code to be part of a separate
> module. Merge it with the omapdss module. This allows removing the
> exports for internal symbols.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/Kconfig   |  4 ----
>  drivers/gpu/drm/omapdrm/dss/Makefile  | 19 +++++++++++++------
>  drivers/gpu/drm/omapdrm/dss/base.c    |  7 -------
>  drivers/gpu/drm/omapdrm/dss/display.c |  2 --
>  drivers/gpu/drm/omapdrm/dss/dss-of.c  |  2 --
>  drivers/gpu/drm/omapdrm/dss/output.c  | 14 --------------
>  6 files changed, 13 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
> index f24ebf7f61dd..39a30a64448a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
> @@ -1,12 +1,8 @@
>  config OMAP2_DSS_INIT
>  	bool
>  
> -config OMAP_DSS_BASE
> -	tristate
> -
>  menuconfig OMAP2_DSS
>          tristate "OMAP2+ Display Subsystem support"
> -	select OMAP_DSS_BASE
>  	select VIDEOMODE_HELPERS
>  	select OMAP2_DSS_INIT
>  	select HDMI
> diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
> index 3c5644c3fc38..531b4d8075e5 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> +++ b/drivers/gpu/drm/omapdrm/dss/Makefile
> @@ -1,12 +1,19 @@
>  obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
> -
> -obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
> -omapdss-base-y := base.o display.o dss-of.o output.o
> -
>  obj-$(CONFIG_OMAP2_DSS) += omapdss.o
> +
>  # Core DSS files
> -omapdss-y := core.o dss.o dispc.o dispc_coefs.o \
> -	pll.o video-pll.o
> +omapdss-y := \
> +	base.o \
> +	display.o \
> +	dss-of.o \
> +	output.o \
> +	core.o \
> +	dss.o \
> +	dispc.o \
> +	dispc_coefs.o \
> +	pll.o \
> +	video-pll.o
> +

I guess it makes sense to sort this alphabetically, otherwise:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
>  omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
>  omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index 13e91faaf7a6..eff427dd3297 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -20,7 +20,6 @@ void omapdss_set_is_initialized(bool set)
>  {
>  	dss_initialized = set;
>  }
> -EXPORT_SYMBOL(omapdss_set_is_initialized);
>  
>  bool omapdss_is_initialized(void)
>  {
> @@ -32,7 +31,6 @@ void dispc_set_ops(const struct dispc_ops *o)
>  {
>  	ops = o;
>  }
> -EXPORT_SYMBOL(dispc_set_ops);
>  
>  const struct dispc_ops *dispc_get_ops(void)
>  {
> @@ -108,7 +106,6 @@ void omapdss_gather_components(struct device *dev)
>  		omapdss_walk_device(dev, child, true);
>  	}
>  }
> -EXPORT_SYMBOL(omapdss_gather_components);
>  
>  static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
>  {
> @@ -134,7 +131,3 @@ bool omapdss_stack_is_ready(void)
>  	return true;
>  }
>  EXPORT_SYMBOL(omapdss_stack_is_ready);
> -
> -MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
> -MODULE_DESCRIPTION("OMAP Display Subsystem Base");
> -MODULE_LICENSE("GPL v2");
> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
> index 8c77a2d20969..a86471f73094 100644
> --- a/drivers/gpu/drm/omapdrm/dss/display.c
> +++ b/drivers/gpu/drm/omapdrm/dss/display.c
> @@ -35,7 +35,6 @@ void omapdss_default_get_timings(struct omap_dss_device *dssdev,
>  {
>  	*vm = dssdev->panel.vm;
>  }
> -EXPORT_SYMBOL(omapdss_default_get_timings);
>  
>  static LIST_HEAD(panel_list);
>  static DEFINE_MUTEX(panel_list_mutex);
> @@ -104,7 +103,6 @@ bool omapdss_component_is_display(struct device_node *node)
>  	mutex_unlock(&panel_list_mutex);
>  	return found;
>  }
> -EXPORT_SYMBOL(omapdss_component_is_display);
>  
>  struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
>  {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> index c6b86f348a5c..d3a19a5dfd35 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> @@ -44,7 +44,6 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port)
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL_GPL(dss_of_port_get_parent_device);
>  
>  u32 dss_of_port_get_port_number(struct device_node *port)
>  {
> @@ -57,7 +56,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
>  
>  	return reg;
>  }
> -EXPORT_SYMBOL_GPL(dss_of_port_get_port_number);
>  
>  struct omap_dss_device *
>  omapdss_of_find_source_for_first_ep(struct device_node *node)
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 3c572b699ed3..a84ab0337a91 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -58,7 +58,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
>  
>  	return r;
>  }
> -EXPORT_SYMBOL(omapdss_output_set_device);
>  
>  int omapdss_output_unset_device(struct omap_dss_device *out)
>  {
> @@ -92,7 +91,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
>  
>  	return r;
>  }
> -EXPORT_SYMBOL(omapdss_output_unset_device);
>  
>  int omapdss_register_output(struct omap_dss_device *out)
>  {
> @@ -118,7 +116,6 @@ bool omapdss_component_is_output(struct device_node *node)
>  
>  	return false;
>  }
> -EXPORT_SYMBOL(omapdss_component_is_output);
>  
>  struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
>  {
> @@ -131,7 +128,6 @@ struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL(omap_dss_get_output);
>  
>  struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port)
>  {
> @@ -156,7 +152,6 @@ struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *po
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL(omap_dss_find_output_by_port_node);
>  
>  struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev)
>  {
> @@ -194,56 +189,47 @@ int dss_mgr_connect(enum omap_channel channel,
>  {
>  	return dss_mgr_ops->connect(channel, dst);
>  }
> -EXPORT_SYMBOL(dss_mgr_connect);
>  
>  void dss_mgr_disconnect(enum omap_channel channel,
>  		struct omap_dss_device *dst)
>  {
>  	dss_mgr_ops->disconnect(channel, dst);
>  }
> -EXPORT_SYMBOL(dss_mgr_disconnect);
>  
>  void dss_mgr_set_timings(enum omap_channel channel, const struct videomode *vm)
>  {
>  	dss_mgr_ops->set_timings(channel, vm);
>  }
> -EXPORT_SYMBOL(dss_mgr_set_timings);
>  
>  void dss_mgr_set_lcd_config(enum omap_channel channel,
>  		const struct dss_lcd_mgr_config *config)
>  {
>  	dss_mgr_ops->set_lcd_config(channel, config);
>  }
> -EXPORT_SYMBOL(dss_mgr_set_lcd_config);
>  
>  int dss_mgr_enable(enum omap_channel channel)
>  {
>  	return dss_mgr_ops->enable(channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_enable);
>  
>  void dss_mgr_disable(enum omap_channel channel)
>  {
>  	dss_mgr_ops->disable(channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_disable);
>  
>  void dss_mgr_start_update(enum omap_channel channel)
>  {
>  	dss_mgr_ops->start_update(channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_start_update);
>  
>  int dss_mgr_register_framedone_handler(enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
>  	return dss_mgr_ops->register_framedone_handler(channel, handler, data);
>  }
> -EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
>  
>  void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
>  	dss_mgr_ops->unregister_framedone_handler(channel, handler, data);
>  }
> -EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask
  2017-10-13 14:59 ` [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask Laurent Pinchart
@ 2017-10-14 12:24   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:24 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1623 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:01PM +0300, Laurent Pinchart wrote:
> When merging the omapdrm and omapdss drivers the omapdrm virtual
> platform device will disappear, and the omapdss platform device will be
> used for DMA memory allocation. To prepare for that, set the DMA
> coherent mask for the device.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/gpu/drm/omapdrm/dss/dss.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index d1755f12236b..6ce26a4b93b3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -23,6 +23,7 @@
>  #define DSS_SUBSYS_NAME "DSS"
>  
>  #include <linux/debugfs.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/io.h>
> @@ -1441,6 +1442,12 @@ static int dss_probe(struct platform_device *pdev)
>  
>  	dss.pdev = pdev;
>  
> +	r = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> +	if (r) {
> +		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> +		return r;
> +	}
> +
>  	/*
>  	 * The various OMAP3-based SoCs can't be told apart using the compatible
>  	 * string, use SoC device matching.
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static
  2017-10-13 14:59 ` [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static Laurent Pinchart
@ 2017-10-14 12:24   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:24 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2107 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:02PM +0300, Laurent Pinchart wrote:
> The function isn't used outside of its compilation unit, make it static.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/gpu/drm/omapdrm/dss/dss.c | 4 +++-
>  drivers/gpu/drm/omapdrm/dss/dss.h | 1 -
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 6ce26a4b93b3..0d447eddf4d6 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -368,7 +368,8 @@ const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
>  	return dss_generic_clk_source_names[clk_src];
>  }
>  
> -void dss_dump_clocks(struct seq_file *s)
> +#if defined(CONFIG_OMAP2_DSS_DEBUGFS)
> +static void dss_dump_clocks(struct seq_file *s)
>  {
>  	const char *fclk_name;
>  	unsigned long fclk_rate;
> @@ -387,6 +388,7 @@ void dss_dump_clocks(struct seq_file *s)
>  
>  	dss_runtime_put();
>  }
> +#endif
>  
>  static void dss_dump_regs(struct seq_file *s)
>  {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index ed465572491e..0d7f2b08b7ff 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -277,7 +277,6 @@ int dss_dpi_select_source(int port, enum omap_channel channel);
>  void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
>  enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
>  const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
> -void dss_dump_clocks(struct seq_file *s);
>  
>  /* DSS VIDEO PLL */
>  struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field
  2017-10-13 14:59 ` [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field Laurent Pinchart
@ 2017-10-14 12:28   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:28 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1705 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:03PM +0300, Laurent Pinchart wrote:
> The dpi_data structure port_initialized field is used to check in the
> cleanup path whether the DPI has been initialized. This can be performed
> through the associated device_node data field instead. Remove the
> port_initialized field.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index daf286fc8a40..ce9b27978f48 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -52,8 +52,6 @@ struct dpi_data {
>  	int data_lines;
>  
>  	struct omap_dss_device output;
> -
> -	bool port_initialized;
>  };
>  
>  static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
> @@ -786,8 +784,6 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port,
>  
>  	dpi_init_output_port(dpi, port);
>  
> -	dpi->port_initialized = true;
> -
>  	return 0;
>  
>  err_datalines:
> @@ -800,7 +796,7 @@ void dpi_uninit_port(struct device_node *port)
>  {
>  	struct dpi_data *dpi = port->data;
>  
> -	if (!dpi->port_initialized)
> +	if (!dpi)
>  		return;
>  
>  	dpi_uninit_output_port(port);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure
  2017-10-13 14:59 ` [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure Laurent Pinchart
@ 2017-10-14 12:29   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:29 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1197 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:04PM +0300, Laurent Pinchart wrote:
> The venc_probe_of() function has an error cleanup path that returns
> success instead of an error code. Fix it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Maybe this should be tagged for stable backporting?

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/venc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index d58da6f32693..1b0fa952b494 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -857,10 +857,10 @@ static int venc_probe_of(struct platform_device *pdev)
>  	of_node_put(ep);
>  
>  	return 0;
> +
>  err:
>  	of_node_put(ep);
> -
> -	return 0;
> +	return r;
>  }
>  
>  /* VENC HW IP initialisation */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 10/48] drm: omapdrm: Use kernel integer types
  2017-10-13 14:59 ` [PATCH 10/48] drm: omapdrm: Use kernel integer types Laurent Pinchart
@ 2017-10-14 12:34   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:34 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 30523 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:06PM +0300, Laurent Pinchart wrote:
> The standard kernel integer types are [us]{8,16,32}. Use them instead of
> the u?int{8,16,32}_t types.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/omap_crtc.c      | 12 ++++-----
>  drivers/gpu/drm/omapdrm/omap_crtc.h      |  2 +-
>  drivers/gpu/drm/omapdrm/omap_dmm_priv.h  | 10 +++----
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 46 ++++++++++++++++----------------
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.h | 22 +++++++--------
>  drivers/gpu/drm/omapdrm/omap_drv.h       |  4 +--
>  drivers/gpu/drm/omapdrm/omap_fb.c        | 18 ++++++-------
>  drivers/gpu/drm/omapdrm/omap_gem.c       | 41 +++++++++++++++-------------
>  drivers/gpu/drm/omapdrm/omap_gem.h       | 16 +++++------
>  drivers/gpu/drm/omapdrm/omap_irq.c       |  6 ++---
>  drivers/gpu/drm/omapdrm/omap_irq.h       |  2 +-
>  drivers/gpu/drm/omapdrm/omap_plane.c     |  4 +--
>  drivers/gpu/drm/omapdrm/tcm-sita.c       | 12 ++++-----
>  drivers/gpu/drm/omapdrm/tcm.h            |  4 +--
>  14 files changed, 101 insertions(+), 98 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index cc85c16cbc2a..f78eac4a8b34 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -273,7 +273,7 @@ static const struct dss_mgr_ops mgr_ops = {
>   * Setup, Flush and Page Flip
>   */
>  
> -void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus)
> +void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus)
>  {
>  	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
>  
> @@ -458,7 +458,7 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,
>  	struct drm_plane_state *pri_state;
>  
>  	if (state->color_mgmt_changed && state->gamma_lut) {
> -		uint length = state->gamma_lut->length /
> +		unsigned int length = state->gamma_lut->length /
>  			sizeof(struct drm_color_lut);
>  
>  		if (length < 2)
> @@ -492,7 +492,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  
>  	if (crtc->state->color_mgmt_changed) {
>  		struct drm_color_lut *lut = NULL;
> -		uint length = 0;
> +		unsigned int length = 0;
>  
>  		if (crtc->state->gamma_lut) {
>  			lut = (struct drm_color_lut *)
> @@ -523,7 +523,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
>  					 struct drm_crtc_state *state,
>  					 struct drm_property *property,
> -					 uint64_t val)
> +					 u64 val)
>  {
>  	struct omap_drm_private *priv = crtc->dev->dev_private;
>  	struct drm_plane_state *plane_state;
> @@ -551,7 +551,7 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
>  static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
>  					 const struct drm_crtc_state *state,
>  					 struct drm_property *property,
> -					 uint64_t *val)
> +					 u64 *val)
>  {
>  	struct omap_drm_private *priv = crtc->dev->dev_private;
>  	struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
> @@ -697,7 +697,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  	 * gamma table is not supprted.
>  	 */
>  	if (priv->dispc_ops->mgr_gamma_size(channel)) {
> -		uint gamma_lut_size = 256;
> +		unsigned int gamma_lut_size = 256;
>  
>  		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
>  		drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
> index ad7b007c6174..7f01e730a050 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.h
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
> @@ -37,7 +37,7 @@ void omap_crtc_pre_uninit(void);
>  struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  		struct drm_plane *plane, struct omap_dss_device *dssdev);
>  int omap_crtc_wait_pending(struct drm_crtc *crtc);
> -void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
> +void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus);
>  void omap_crtc_vblank_irq(struct drm_crtc *crtc);
>  
>  #endif /* __OMAPDRM_CRTC_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
> index 9f32a83ca507..80fc850212a3 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
> @@ -102,10 +102,10 @@ struct pat_ctrl {
>  };
>  
>  struct pat {
> -	uint32_t next_pa;
> +	u32 next_pa;
>  	struct pat_area area;
>  	struct pat_ctrl ctrl;
> -	uint32_t data_pa;
> +	u32 data_pa;
>  };
>  
>  #define DMM_FIXED_RETRY_COUNT 1000
> @@ -129,7 +129,7 @@ struct dmm_txn {
>  	void *engine_handle;
>  	struct tcm *tcm;
>  
> -	uint8_t *current_va;
> +	u8 *current_va;
>  	dma_addr_t current_pa;
>  
>  	struct pat *last_pat;
> @@ -140,7 +140,7 @@ struct refill_engine {
>  	struct dmm *dmm;
>  	struct tcm *tcm;
>  
> -	uint8_t *refill_va;
> +	u8 *refill_va;
>  	dma_addr_t refill_pa;
>  
>  	/* only one trans per engine for now */
> @@ -154,7 +154,7 @@ struct refill_engine {
>  };
>  
>  struct dmm_platform_data {
> -	uint32_t cpu_cache_flags;
> +	u32 cpu_cache_flags;
>  };
>  
>  struct dmm {
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> index 1dd3dafc59af..b341ebc136fe 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> @@ -59,11 +59,11 @@ static DEFINE_SPINLOCK(list_lock);
>  	}
>  
>  static const struct {
> -	uint32_t x_shft;	/* unused X-bits (as part of bpp) */
> -	uint32_t y_shft;	/* unused Y-bits (as part of bpp) */
> -	uint32_t cpp;		/* bytes/chars per pixel */
> -	uint32_t slot_w;	/* width of each slot (in pixels) */
> -	uint32_t slot_h;	/* height of each slot (in pixels) */
> +	u32 x_shft;	/* unused X-bits (as part of bpp) */
> +	u32 y_shft;	/* unused Y-bits (as part of bpp) */
> +	u32 cpp;		/* bytes/chars per pixel */
> +	u32 slot_w;	/* width of each slot (in pixels) */
> +	u32 slot_h;	/* height of each slot (in pixels) */
>  } geom[TILFMT_NFORMATS] = {
>  	[TILFMT_8BIT]  = GEOM(0, 0, 1),
>  	[TILFMT_16BIT] = GEOM(0, 1, 2),
> @@ -73,7 +73,7 @@ static const struct {
>  
>  
>  /* lookup table for registers w/ per-engine instances */
> -static const uint32_t reg[][4] = {
> +static const u32 reg[][4] = {
>  	[PAT_STATUS] = {DMM_PAT_STATUS__0, DMM_PAT_STATUS__1,
>  			DMM_PAT_STATUS__2, DMM_PAT_STATUS__3},
>  	[PAT_DESCR]  = {DMM_PAT_DESCR__0, DMM_PAT_DESCR__1,
> @@ -112,10 +112,10 @@ static void *alloc_dma(struct dmm_txn *txn, size_t sz, dma_addr_t *pa)
>  }
>  
>  /* check status and spin until wait_mask comes true */
> -static int wait_status(struct refill_engine *engine, uint32_t wait_mask)
> +static int wait_status(struct refill_engine *engine, u32 wait_mask)
>  {
>  	struct dmm *dmm = engine->dmm;
> -	uint32_t r = 0, err, i;
> +	u32 r = 0, err, i;
>  
>  	i = DMM_FIXED_RETRY_COUNT;
>  	while (true) {
> @@ -151,7 +151,7 @@ static void release_engine(struct refill_engine *engine)
>  static irqreturn_t omap_dmm_irq_handler(int irq, void *arg)
>  {
>  	struct dmm *dmm = arg;
> -	uint32_t status = dmm_read(dmm, DMM_PAT_IRQSTATUS);
> +	u32 status = dmm_read(dmm, DMM_PAT_IRQSTATUS);
>  	int i;
>  
>  	/* ack IRQ */
> @@ -214,10 +214,10 @@ static struct dmm_txn *dmm_txn_init(struct dmm *dmm, struct tcm *tcm)
>   * corresponding slot is cleared (ie. dummy_pa is programmed)
>   */
>  static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
> -		struct page **pages, uint32_t npages, uint32_t roll)
> +		struct page **pages, u32 npages, u32 roll)
>  {
>  	dma_addr_t pat_pa = 0, data_pa = 0;
> -	uint32_t *data;
> +	u32 *data;
>  	struct pat *pat;
>  	struct refill_engine *engine = txn->engine_handle;
>  	int columns = (1 + area->x1 - area->x0);
> @@ -227,7 +227,7 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
>  	pat = alloc_dma(txn, sizeof(*pat), &pat_pa);
>  
>  	if (txn->last_pat)
> -		txn->last_pat->next_pa = (uint32_t)pat_pa;
> +		txn->last_pat->next_pa = (u32)pat_pa;
>  
>  	pat->area = *area;
>  
> @@ -313,7 +313,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
>   * DMM programming
>   */
>  static int fill(struct tcm_area *area, struct page **pages,
> -		uint32_t npages, uint32_t roll, bool wait)
> +		u32 npages, u32 roll, bool wait)
>  {
>  	int ret = 0;
>  	struct tcm_area slice, area_s;
> @@ -361,7 +361,7 @@ static int fill(struct tcm_area *area, struct page **pages,
>  /* note: slots for which pages[i] == NULL are filled w/ dummy page
>   */
>  int tiler_pin(struct tiler_block *block, struct page **pages,
> -		uint32_t npages, uint32_t roll, bool wait)
> +		u32 npages, u32 roll, bool wait)
>  {
>  	int ret;
>  
> @@ -381,8 +381,8 @@ int tiler_unpin(struct tiler_block *block)
>  /*
>   * Reserve/release
>   */
> -struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w,
> -		uint16_t h, uint16_t align)
> +struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w,
> +		u16 h, u16 align)
>  {
>  	struct tiler_block *block = kzalloc(sizeof(*block), GFP_KERNEL);
>  	u32 min_align = 128;
> @@ -525,8 +525,8 @@ dma_addr_t tiler_ssptr(struct tiler_block *block)
>  			block->area.p0.y * geom[block->fmt].slot_h);
>  }
>  
> -dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
> -		uint32_t x, uint32_t y)
> +dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
> +		u32 x, u32 y)
>  {
>  	struct tcm_pt *p = &block->area.p0;
>  	BUG_ON(!validfmt(block->fmt));
> @@ -536,14 +536,14 @@ dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
>  			(p->y * geom[block->fmt].slot_h) + y);
>  }
>  
> -void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h)
> +void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h)
>  {
>  	BUG_ON(!validfmt(fmt));
>  	*w = round_up(*w, geom[fmt].slot_w);
>  	*h = round_up(*h, geom[fmt].slot_h);
>  }
>  
> -uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient)
> +u32 tiler_stride(enum tiler_fmt fmt, u32 orient)
>  {
>  	BUG_ON(!validfmt(fmt));
>  
> @@ -553,19 +553,19 @@ uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient)
>  		return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft);
>  }
>  
> -size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h)
> +size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h)
>  {
>  	tiler_align(fmt, &w, &h);
>  	return geom[fmt].cpp * w * h;
>  }
>  
> -size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h)
> +size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h)
>  {
>  	BUG_ON(!validfmt(fmt));
>  	return round_up(geom[fmt].cpp * w, PAGE_SIZE) * h;
>  }
>  
> -uint32_t tiler_get_cpu_cache_flags(void)
> +u32 tiler_get_cpu_cache_flags(void)
>  {
>  	return omap_dmm->plat_data->cpu_cache_flags;
>  }
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> index e83c78372db8..09816adfd422 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> @@ -89,30 +89,30 @@ int tiler_map_show(struct seq_file *s, void *arg);
>  
>  /* pin/unpin */
>  int tiler_pin(struct tiler_block *block, struct page **pages,
> -		uint32_t npages, uint32_t roll, bool wait);
> +		u32 npages, u32 roll, bool wait);
>  int tiler_unpin(struct tiler_block *block);
>  
>  /* reserve/release */
> -struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, uint16_t h,
> -				uint16_t align);
> +struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h,
> +				u16 align);
>  struct tiler_block *tiler_reserve_1d(size_t size);
>  int tiler_release(struct tiler_block *block);
>  
>  /* utilities */
>  dma_addr_t tiler_ssptr(struct tiler_block *block);
> -dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
> -		uint32_t x, uint32_t y);
> -uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient);
> -size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
> -size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
> -void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
> -uint32_t tiler_get_cpu_cache_flags(void);
> +dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
> +		u32 x, u32 y);
> +u32 tiler_stride(enum tiler_fmt fmt, u32 orient);
> +size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h);
> +size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h);
> +void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
> +u32 tiler_get_cpu_cache_flags(void);
>  bool dmm_is_available(void);
>  
>  extern struct platform_driver omap_dmm_driver;
>  
>  /* GEM bo flags -> tiler fmt */
> -static inline enum tiler_fmt gem2fmt(uint32_t flags)
> +static inline enum tiler_fmt gem2fmt(u32 flags)
>  {
>  	switch (flags & OMAP_BO_TILED) {
>  	case OMAP_BO_TILED_8:
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index afb2a5a96278..7bf008f02a77 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -48,7 +48,7 @@
>  struct omap_drm_usergart;
>  
>  struct omap_drm_private {
> -	uint32_t omaprev;
> +	u32 omaprev;
>  
>  	const struct dispc_ops *dispc_ops;
>  
> @@ -83,7 +83,7 @@ struct omap_drm_private {
>  	/* irq handling: */
>  	spinlock_t wait_lock;		/* protects the wait_list */
>  	struct list_head wait_list;	/* list of omap_irq_wait */
> -	uint32_t irq_mask;		/* enabled irqs in addition to wait_list */
> +	u32 irq_mask;			/* enabled irqs in addition to wait_list */
>  };
>  
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
> index b1a762b70cbf..ee348a616b90 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -54,8 +54,8 @@ static const u32 formats[] = {
>  /* per-plane info for the fb: */
>  struct plane {
>  	struct drm_gem_object *bo;
> -	uint32_t pitch;
> -	uint32_t offset;
> +	u32 pitch;
> +	u32 offset;
>  	dma_addr_t dma_addr;
>  };
>  
> @@ -102,10 +102,10 @@ static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
>  	.destroy = omap_framebuffer_destroy,
>  };
>  
> -static uint32_t get_linear_addr(struct plane *plane,
> +static u32 get_linear_addr(struct plane *plane,
>  		const struct drm_format_info *format, int n, int x, int y)
>  {
> -	uint32_t offset;
> +	u32 offset;
>  
>  	offset = plane->offset
>  	       + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
> @@ -123,9 +123,9 @@ bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
>  }
>  
>  /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
> -static uint32_t drm_rotation_to_tiler(unsigned int drm_rot)
> +static u32 drm_rotation_to_tiler(unsigned int drm_rot)
>  {
> -	uint32_t orient;
> +	u32 orient;
>  
>  	switch (drm_rot & DRM_MODE_ROTATE_MASK) {
>  	default:
> @@ -160,7 +160,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
>  	const struct drm_format_info *format = omap_fb->format;
>  	struct plane *plane = &omap_fb->planes[0];
> -	uint32_t x, y, orient = 0;
> +	u32 x, y, orient = 0;
>  
>  	info->fourcc = fb->format->format;
>  
> @@ -179,8 +179,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  	y = state->src_y >> 16;
>  
>  	if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) {
> -		uint32_t w = state->src_w >> 16;
> -		uint32_t h = state->src_h >> 16;
> +		u32 w = state->src_w >> 16;
> +		u32 h = state->src_h >> 16;
>  
>  		orient = drm_rotation_to_tiler(state->rotation);
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
> index fd81396baaf9..96fdc690183f 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> @@ -41,13 +41,13 @@ struct omap_gem_object {
>  
>  	struct list_head mm_list;
>  
> -	uint32_t flags;
> +	u32 flags;
>  
>  	/** width/height for tiled formats (rounded up to slot boundaries) */
> -	uint16_t width, height;
> +	u16 width, height;
>  
>  	/** roll applied when mapping to DMM */
> -	uint32_t roll;
> +	u32 roll;
>  
>  	/**
>  	 * dma_addr contains the buffer DMA address. It is valid for
> @@ -75,7 +75,7 @@ struct omap_gem_object {
>  	/**
>  	 * # of users of dma_addr
>  	 */
> -	uint32_t dma_addr_cnt;
> +	u32 dma_addr_cnt;
>  
>  	/**
>  	 * If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag
> @@ -139,7 +139,7 @@ struct omap_drm_usergart {
>   */
>  
>  /** get mmap offset */
> -static uint64_t mmap_offset(struct drm_gem_object *obj)
> +static u64 mmap_offset(struct drm_gem_object *obj)
>  {
>  	struct drm_device *dev = obj->dev;
>  	int ret;
> @@ -333,14 +333,15 @@ static void omap_gem_detach_pages(struct drm_gem_object *obj)
>  }
>  
>  /* get buffer flags */
> -uint32_t omap_gem_flags(struct drm_gem_object *obj)
> +u32 omap_gem_flags(struct drm_gem_object *obj)
>  {
>  	return to_omap_bo(obj)->flags;
>  }
>  
> -uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj)
> +u64 omap_gem_mmap_offset(struct drm_gem_object *obj)
>  {
> -	uint64_t offset;
> +	u64 offset;
> +
>  	mutex_lock(&obj->dev->struct_mutex);
>  	offset = mmap_offset(obj);
>  	mutex_unlock(&obj->dev->struct_mutex);
> @@ -651,7 +652,7 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
>   * into user memory. We don't have to do much here at the moment.
>   */
>  int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> -		uint32_t handle, uint64_t *offset)
> +		u32 handle, u64 *offset)
>  {
>  	struct drm_gem_object *obj;
>  	int ret = 0;
> @@ -677,10 +678,10 @@ int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
>   *
>   * Call only from non-atomic contexts.
>   */
> -int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll)
> +int omap_gem_roll(struct drm_gem_object *obj, u32 roll)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> -	uint32_t npages = obj->size >> PAGE_SHIFT;
> +	u32 npages = obj->size >> PAGE_SHIFT;
>  	int ret = 0;
>  
>  	if (roll > npages) {
> @@ -810,7 +811,7 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
>  	if (!is_contiguous(omap_obj) && priv->has_dmm) {
>  		if (omap_obj->dma_addr_cnt == 0) {
>  			struct page **pages;
> -			uint32_t npages = obj->size >> PAGE_SHIFT;
> +			u32 npages = obj->size >> PAGE_SHIFT;
>  			enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
>  			struct tiler_block *block;
>  
> @@ -906,7 +907,7 @@ void omap_gem_unpin(struct drm_gem_object *obj)
>   * specified orientation and x,y offset from top-left corner of buffer
>   * (only valid for tiled 2d buffers)
>   */
> -int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
> +int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
>  		int x, int y, dma_addr_t *dma_addr)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> @@ -923,7 +924,7 @@ int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
>  }
>  
>  /* Get tiler stride for the buffer (only valid for 2d tiled buffers) */
> -int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient)
> +int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
>  	int ret = -EINVAL;
> @@ -1005,7 +1006,8 @@ int omap_gem_resume(struct drm_device *dev)
>  	list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
>  		if (omap_obj->block) {
>  			struct drm_gem_object *obj = &omap_obj->base;
> -			uint32_t npages = obj->size >> PAGE_SHIFT;
> +			u32 npages = obj->size >> PAGE_SHIFT;
> +
>  			WARN_ON(!omap_obj->pages);  /* this can't happen */
>  			ret = tiler_pin(omap_obj->block,
>  					omap_obj->pages, npages,
> @@ -1029,7 +1031,7 @@ int omap_gem_resume(struct drm_device *dev)
>  void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> -	uint64_t off;
> +	u64 off;
>  
>  	off = drm_vma_node_start(&obj->vma_node);
>  
> @@ -1117,7 +1119,7 @@ void omap_gem_free_object(struct drm_gem_object *obj)
>  
>  /* GEM buffer object constructor */
>  struct drm_gem_object *omap_gem_new(struct drm_device *dev,
> -		union omap_gem_size gsize, uint32_t flags)
> +		union omap_gem_size gsize, u32 flags)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
>  	struct omap_gem_object *omap_obj;
> @@ -1282,7 +1284,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
>  
>  /* convenience method to construct a GEM buffer object, and userspace handle */
>  int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> -		union omap_gem_size gsize, uint32_t flags, uint32_t *handle)
> +		union omap_gem_size gsize, u32 flags, u32 *handle)
>  {
>  	struct drm_gem_object *obj;
>  	int ret;
> @@ -1329,7 +1331,8 @@ void omap_gem_init(struct drm_device *dev)
>  
>  	/* reserve 4k aligned/wide regions for userspace mappings: */
>  	for (i = 0; i < ARRAY_SIZE(fmts); i++) {
> -		uint16_t h = 1, w = PAGE_SIZE >> i;
> +		u16 h = 1, w = PAGE_SIZE >> i;
> +
>  		tiler_align(fmts[i], &w, &h);
>  		/* note: since each region is 1 4kb page wide, and minimum
>  		 * number of rows, the height ends up being the same as the
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
> index 35fa690b3d90..a78bde05193a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.h
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.h
> @@ -53,17 +53,17 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
>  
>  /* GEM Object Creation and Deletion */
>  struct drm_gem_object *omap_gem_new(struct drm_device *dev,
> -		union omap_gem_size gsize, uint32_t flags);
> +		union omap_gem_size gsize, u32 flags);
>  struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
>  		struct sg_table *sgt);
>  int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> -		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
> +		union omap_gem_size gsize, u32 flags, u32 *handle);
>  void omap_gem_free_object(struct drm_gem_object *obj);
>  void *omap_gem_vaddr(struct drm_gem_object *obj);
>  
>  /* Dumb Buffers Interface */
>  int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> -		uint32_t handle, uint64_t *offset);
> +		u32 handle, u64 *offset);
>  int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
>  		struct drm_mode_create_dumb *args);
>  
> @@ -71,7 +71,7 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
>  int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>  int omap_gem_mmap_obj(struct drm_gem_object *obj,
>  		struct vm_area_struct *vma);
> -uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
> +u64 omap_gem_mmap_offset(struct drm_gem_object *obj);
>  size_t omap_gem_mmap_size(struct drm_gem_object *obj);
>  
>  /* PRIME Interface */
> @@ -81,7 +81,7 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
>  		struct dma_buf *buffer);
>  
>  int omap_gem_fault(struct vm_fault *vmf);
> -int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
> +int omap_gem_roll(struct drm_gem_object *obj, u32 roll);
>  void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
>  void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
>  		enum dma_data_direction dir);
> @@ -91,9 +91,9 @@ int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
>  		bool remap);
>  int omap_gem_put_pages(struct drm_gem_object *obj);
>  
> -uint32_t omap_gem_flags(struct drm_gem_object *obj);
> -int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
> +u32 omap_gem_flags(struct drm_gem_object *obj);
> +int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
>  		int x, int y, dma_addr_t *dma_addr);
> -int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
> +int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient);
>  
>  #endif /* __OMAPDRM_GEM_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
> index 013b0bba712f..ef5132237100 100644
> --- a/drivers/gpu/drm/omapdrm/omap_irq.c
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.c
> @@ -22,7 +22,7 @@
>  struct omap_irq_wait {
>  	struct list_head node;
>  	wait_queue_head_t wq;
> -	uint32_t irqmask;
> +	u32 irqmask;
>  	int count;
>  };
>  
> @@ -31,7 +31,7 @@ static void omap_irq_update(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
>  	struct omap_irq_wait *wait;
> -	uint32_t irqmask = priv->irq_mask;
> +	u32 irqmask = priv->irq_mask;
>  
>  	assert_spin_locked(&priv->wait_lock);
>  
> @@ -50,7 +50,7 @@ static void omap_irq_wait_handler(struct omap_irq_wait *wait)
>  }
>  
>  struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev,
> -		uint32_t irqmask, int count)
> +		u32 irqmask, int count)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
>  	struct omap_irq_wait *wait = kzalloc(sizeof(*wait), GFP_KERNEL);
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.h b/drivers/gpu/drm/omapdrm/omap_irq.h
> index 606c09932bc0..9d5441468eca 100644
> --- a/drivers/gpu/drm/omapdrm/omap_irq.h
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.h
> @@ -32,7 +32,7 @@ void omap_drm_irq_uninstall(struct drm_device *dev);
>  int omap_drm_irq_install(struct drm_device *dev);
>  
>  struct omap_irq_wait *omap_irq_wait_init(struct drm_device *dev,
> -		uint32_t irqmask, int count);
> +		u32 irqmask, int count);
>  int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
>  		unsigned long timeout);
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 15e5d5d325c6..903e0fa5442a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -203,7 +203,7 @@ static void omap_plane_reset(struct drm_plane *plane)
>  static int omap_plane_atomic_set_property(struct drm_plane *plane,
>  					  struct drm_plane_state *state,
>  					  struct drm_property *property,
> -					  uint64_t val)
> +					  u64 val)
>  {
>  	struct omap_drm_private *priv = plane->dev->dev_private;
>  
> @@ -218,7 +218,7 @@ static int omap_plane_atomic_set_property(struct drm_plane *plane,
>  static int omap_plane_atomic_get_property(struct drm_plane *plane,
>  					  const struct drm_plane_state *state,
>  					  struct drm_property *property,
> -					  uint64_t *val)
> +					  u64 *val)
>  {
>  	struct omap_drm_private *priv = plane->dev->dev_private;
>  
> diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c b/drivers/gpu/drm/omapdrm/tcm-sita.c
> index c10fdfc0930f..714d4c1d263f 100644
> --- a/drivers/gpu/drm/omapdrm/tcm-sita.c
> +++ b/drivers/gpu/drm/omapdrm/tcm-sita.c
> @@ -35,8 +35,8 @@ static unsigned long mask[8];
>   * map		ptr to bitmap
>   * stride		slots in a row
>   */
> -static void free_slots(unsigned long pos, uint16_t w, uint16_t h,
> -		unsigned long *map, uint16_t stride)
> +static void free_slots(unsigned long pos, u16 w, u16 h,
> +		unsigned long *map, u16 stride)
>  {
>  	int i;
>  
> @@ -50,7 +50,7 @@ static void free_slots(unsigned long pos, uint16_t w, uint16_t h,
>   * map		ptr to bitmap
>   * num_bits	number of bits in bitmap
>   */
> -static int r2l_b2t_1d(uint16_t w, unsigned long *pos, unsigned long *map,
> +static int r2l_b2t_1d(u16 w, unsigned long *pos, unsigned long *map,
>  		size_t num_bits)
>  {
>  	unsigned long search_count = 0;
> @@ -86,7 +86,7 @@ static int r2l_b2t_1d(uint16_t w, unsigned long *pos, unsigned long *map,
>   * num_bits = size of bitmap
>   * stride = bits in one row of container
>   */
> -static int l2r_t2b(uint16_t w, uint16_t h, uint16_t a, int16_t offset,
> +static int l2r_t2b(u16 w, u16 h, u16 a, s16 offset,
>  		unsigned long *pos, unsigned long slot_bytes,
>  		unsigned long *map, size_t num_bits, size_t slot_stride)
>  {
> @@ -181,7 +181,7 @@ static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots,
>  }
>  
>  static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u16 align,
> -				int16_t offset, uint16_t slot_bytes,
> +				s16 offset, u16 slot_bytes,
>  				struct tcm_area *area)
>  {
>  	unsigned long pos;
> @@ -210,7 +210,7 @@ static void sita_deinit(struct tcm *tcm)
>  static s32 sita_free(struct tcm *tcm, struct tcm_area *area)
>  {
>  	unsigned long pos;
> -	uint16_t w, h;
> +	u16 w, h;
>  
>  	pos = area->p0.x + area->p0.y * tcm->width;
>  	if (area->is2d) {
> diff --git a/drivers/gpu/drm/omapdrm/tcm.h b/drivers/gpu/drm/omapdrm/tcm.h
> index ef7df7d6fc84..a6928ba33d08 100644
> --- a/drivers/gpu/drm/omapdrm/tcm.h
> +++ b/drivers/gpu/drm/omapdrm/tcm.h
> @@ -67,7 +67,7 @@ struct tcm {
>  
>  	/* function table */
>  	s32 (*reserve_2d)(struct tcm *tcm, u16 height, u16 width, u16 align,
> -			  int16_t offset, uint16_t slot_bytes,
> +			  s16 offset, u16 slot_bytes,
>  			  struct tcm_area *area);
>  	s32 (*reserve_1d)(struct tcm *tcm, u32 slots, struct tcm_area *area);
>  	s32 (*free)(struct tcm *tcm, struct tcm_area *area);
> @@ -131,7 +131,7 @@ static inline void tcm_deinit(struct tcm *tcm)
>   *	    allocation.
>   */
>  static inline s32 tcm_reserve_2d(struct tcm *tcm, u16 width, u16 height,
> -				u16 align, int16_t offset, uint16_t slot_bytes,
> +				u16 align, s16 offset, u16 slot_bytes,
>  				struct tcm_area *area)
>  {
>  	/* perform rudimentary error checking */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 11/48] drm: omapdrm: Use unsigned int type
  2017-10-13 14:59 ` [PATCH 11/48] drm: omapdrm: Use unsigned int type Laurent Pinchart
@ 2017-10-14 12:37   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:37 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 27190 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:07PM +0300, Laurent Pinchart wrote:
> The kernel favours 'unsigned int' over plain 'unsigned'. Replace all
> occurences of the latter by the former. This avoid lots of checkpatch
> complaints in patches that touch lines where a plain 'unsigned' is used.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    |  8 +-
>  .../drm/omapdrm/displays/panel-sony-acx565akm.c    |  6 +-
>  drivers/gpu/drm/omapdrm/dss/dispc.c                | 25 +++---
>  drivers/gpu/drm/omapdrm/dss/dpi.c                  |  2 +-
>  drivers/gpu/drm/omapdrm/dss/dsi.c                  | 98 +++++++++++-----------
>  drivers/gpu/drm/omapdrm/dss/dss.c                  | 12 +--
>  drivers/gpu/drm/omapdrm/dss/dss.h                  | 12 +--
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c                |  2 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c                |  2 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi5_core.c           | 24 +++---
>  drivers/gpu/drm/omapdrm/dss/hdmi_phy.c             |  2 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi_wp.c              |  2 +-
>  drivers/gpu/drm/omapdrm/dss/omapdss.h              |  4 +-
>  drivers/gpu/drm/omapdrm/dss/pll.c                  |  4 +-
>  14 files changed, 102 insertions(+), 101 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> index 92c556ac22c7..bdc0e8a3832d 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> @@ -78,7 +78,7 @@ struct panel_drv_data {
>  	struct workqueue_struct *workqueue;
>  
>  	bool ulps_enabled;
> -	unsigned ulps_timeout;
> +	unsigned int ulps_timeout;
>  	struct delayed_work ulps_work;
>  };
>  
> @@ -483,7 +483,7 @@ static ssize_t dsicm_show_ulps(struct device *dev,
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	unsigned t;
> +	unsigned int t;
>  
>  	mutex_lock(&ddata->lock);
>  	t = ddata->ulps_enabled;
> @@ -530,7 +530,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev,
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	unsigned t;
> +	unsigned int t;
>  
>  	mutex_lock(&ddata->lock);
>  	t = ddata->ulps_timeout;
> @@ -1004,7 +1004,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
>  	int r;
>  	int first = 1;
>  	int plen;
> -	unsigned buf_used = 0;
> +	unsigned int buf_used = 0;
>  
>  	if (size < w * h * 3)
>  		return -ENOMEM;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> index 8e5bff4e5226..06d7d8362a73 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> @@ -289,7 +289,7 @@ static void enable_backlight_ctrl(struct panel_drv_data *ddata, int enable)
>  	acx565akm_write(ddata, MIPID_CMD_WRITE_CTRL_DISP, (u8 *)&ctrl, 2);
>  }
>  
> -static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode)
> +static void set_cabc_mode(struct panel_drv_data *ddata, unsigned int mode)
>  {
>  	u16 cabc_ctrl;
>  
> @@ -303,12 +303,12 @@ static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode)
>  	acx565akm_write(ddata, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2);
>  }
>  
> -static unsigned get_cabc_mode(struct panel_drv_data *ddata)
> +static unsigned int get_cabc_mode(struct panel_drv_data *ddata)
>  {
>  	return ddata->cabc_mode;
>  }
>  
> -static unsigned get_hw_cabc_mode(struct panel_drv_data *ddata)
> +static unsigned int get_hw_cabc_mode(struct panel_drv_data *ddata)
>  {
>  	u8 cabc_ctrl;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 0f4fdb221498..f0ae6be36a4e 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -971,7 +971,7 @@ static void dispc_ovl_set_pre_mult_alpha(enum omap_plane_id plane,
>  static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
>  		enum omap_overlay_caps caps, u8 global_alpha)
>  {
> -	static const unsigned shifts[] = { 0, 8, 16, 24, };
> +	static const unsigned int shifts[] = { 0, 8, 16, 24, };
>  	int shift;
>  
>  	if ((caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
> @@ -1199,7 +1199,7 @@ void dispc_wb_set_channel_in(enum dss_writeback_channel channel)
>  static void dispc_ovl_set_burst_size(enum omap_plane_id plane,
>  		enum omap_burst_size burst_size)
>  {
> -	static const unsigned shifts[] = { 6, 14, 14, 14, 14, };
> +	static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
>  	int shift;
>  
>  	shift = shifts[plane];
> @@ -1287,7 +1287,7 @@ static void dispc_ovl_set_vid_color_conv(enum omap_plane_id plane,
>  static void dispc_ovl_enable_replication(enum omap_plane_id plane,
>  		enum omap_overlay_caps caps, bool enable)
>  {
> -	static const unsigned shifts[] = { 5, 10, 10, 10 };
> +	static const unsigned int shifts[] = { 5, 10, 10, 10 };
>  	int shift;
>  
>  	if ((caps & OMAP_DSS_OVL_CAP_REPLICATION) == 0)
> @@ -1452,9 +1452,8 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
>  	 * All sizes are in bytes. Both the buffer and burst are made of
>  	 * buffer_units, and the fifo thresholds must be buffer_unit aligned.
>  	 */
> -
> -	unsigned buf_unit = dispc.feat->buffer_size_unit;
> -	unsigned ovl_fifo_size, total_fifo_size, burst_size;
> +	unsigned int buf_unit = dispc.feat->buffer_size_unit;
> +	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
>  	int i;
>  
>  	burst_size = dispc_ovl_get_burst_size(plane);
> @@ -2008,8 +2007,8 @@ static s32 pixinc(int pixels, u8 ps)
>  }
>  
>  static void calc_offset(u16 screen_width, u16 width,
> -		u32 fourcc, bool fieldmode,
> -		unsigned int field_offset, unsigned *offset0, unsigned *offset1,
> +		u32 fourcc, bool fieldmode, unsigned int field_offset,
> +		unsigned int *offset0, unsigned int *offset1,
>  		s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim,
>  		enum omap_dss_rotation_type rotation_type, u8 rotation)
>  {
> @@ -2479,7 +2478,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
>  	bool five_taps = true;
>  	bool fieldmode = false;
>  	int r, cconv = 0;
> -	unsigned offset0, offset1;
> +	unsigned int offset0, offset1;
>  	s32 row_inc;
>  	s32 pix_inc;
>  	u16 frame_width, frame_height;
> @@ -3042,7 +3041,7 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
>  static void dispc_mgr_set_timings(enum omap_channel channel,
>  			   const struct videomode *vm)
>  {
> -	unsigned xtot, ytot;
> +	unsigned int xtot, ytot;
>  	unsigned long ht, vt;
>  	struct videomode t = *vm;
>  
> @@ -3121,7 +3120,7 @@ static unsigned long dispc_fclk_rate(void)
>  		r = dss_get_dispc_clk_rate();
>  	} else {
>  		struct dss_pll *pll;
> -		unsigned clkout_idx;
> +		unsigned int clkout_idx;
>  
>  		pll = dss_pll_find_by_src(src);
>  		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
> @@ -3148,7 +3147,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
>  		r = dss_get_dispc_clk_rate();
>  	} else {
>  		struct dss_pll *pll;
> -		unsigned clkout_idx;
> +		unsigned int clkout_idx;
>  
>  		pll = dss_pll_find_by_src(src);
>  		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
> @@ -3489,7 +3488,7 @@ bool dispc_div_calc(unsigned long dispc_freq,
>  	unsigned long pck, lck;
>  	unsigned long lck_max;
>  	unsigned long pckd_hw_min, pckd_hw_max;
> -	unsigned min_fck_per_pck;
> +	unsigned int min_fck_per_pck;
>  	unsigned long fck;
>  
>  #ifdef CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index ce9b27978f48..c7346df60929 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -143,7 +143,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
>  
>  struct dpi_clk_calc_ctx {
>  	struct dss_pll *pll;
> -	unsigned clkout_idx;
> +	unsigned int clkout_idx;
>  
>  	/* inputs */
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index b56a05730314..6a1569149453 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -271,10 +271,10 @@ enum dsi_vc_source {
>  
>  struct dsi_irq_stats {
>  	unsigned long last_reset;
> -	unsigned irq_count;
> -	unsigned dsi_irqs[32];
> -	unsigned vc_irqs[4][32];
> -	unsigned cio_irqs[32];
> +	unsigned int irq_count;
> +	unsigned int dsi_irqs[32];
> +	unsigned int vc_irqs[4][32];
> +	unsigned int cio_irqs[32];
>  };
>  
>  struct dsi_isr_tables {
> @@ -375,7 +375,7 @@ struct dsi_data {
>  
>  	int update_channel;
>  #ifdef DSI_PERF_MEASURE
> -	unsigned update_bytes;
> +	unsigned int update_bytes;
>  #endif
>  
>  	bool te_enabled;
> @@ -408,13 +408,13 @@ struct dsi_data {
>  	struct dsi_irq_stats irq_stats;
>  #endif
>  
> -	unsigned num_lanes_supported;
> -	unsigned line_buffer_size;
> +	unsigned int num_lanes_supported;
> +	unsigned int line_buffer_size;
>  
>  	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
> -	unsigned num_lanes_used;
> +	unsigned int num_lanes_used;
>  
> -	unsigned scp_clk_refcount;
> +	unsigned int scp_clk_refcount;
>  
>  	struct dss_lcd_mgr_config mgr_config;
>  	struct videomode vm;
> @@ -784,7 +784,7 @@ static void dsi_handle_irq_errors(struct platform_device *dsidev, u32 irqstatus,
>  }
>  
>  static void dsi_call_isrs(struct dsi_isr_data *isr_array,
> -		unsigned isr_array_size, u32 irqstatus)
> +		unsigned int isr_array_size, u32 irqstatus)
>  {
>  	struct dsi_isr_data *isr_data;
>  	int i;
> @@ -893,7 +893,7 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
>  /* dsi->irq_lock has to be locked by the caller */
>  static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
>  		struct dsi_isr_data *isr_array,
> -		unsigned isr_array_size, u32 default_mask,
> +		unsigned int isr_array_size, u32 default_mask,
>  		const struct dsi_reg enable_reg,
>  		const struct dsi_reg status_reg)
>  {
> @@ -977,7 +977,7 @@ static void _dsi_initialize_irq(struct platform_device *dsidev)
>  }
>  
>  static int _dsi_register_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
> -		struct dsi_isr_data *isr_array, unsigned isr_array_size)
> +		struct dsi_isr_data *isr_array, unsigned int isr_array_size)
>  {
>  	struct dsi_isr_data *isr_data;
>  	int free_idx;
> @@ -1011,7 +1011,7 @@ static int _dsi_register_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
>  }
>  
>  static int _dsi_unregister_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
> -		struct dsi_isr_data *isr_array, unsigned isr_array_size)
> +		struct dsi_isr_data *isr_array, unsigned int isr_array_size)
>  {
>  	struct dsi_isr_data *isr_data;
>  	int i;
> @@ -1303,7 +1303,7 @@ static int dsi_lp_clock_calc(unsigned long dsi_fclk,
>  		unsigned long lp_clk_min, unsigned long lp_clk_max,
>  		struct dsi_lp_clock_info *lp_cinfo)
>  {
> -	unsigned lp_clk_div;
> +	unsigned int lp_clk_div;
>  	unsigned long lp_clk;
>  
>  	lp_clk_div = DIV_ROUND_UP(dsi_fclk, lp_clk_max * 2);
> @@ -1322,9 +1322,9 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long dsi_fclk;
> -	unsigned lp_clk_div;
> +	unsigned int lp_clk_div;
>  	unsigned long lp_clk;
> -	unsigned lpdiv_max = dsi->data->max_pll_lpdiv;
> +	unsigned int lpdiv_max = dsi->data->max_pll_lpdiv;
>  
>  
>  	lp_clk_div = dsi->user_lp_cinfo.lp_clk_div;
> @@ -1800,7 +1800,7 @@ static int dsi_cio_power(struct platform_device *dsidev,
>  	return 0;
>  }
>  
> -static unsigned dsi_get_line_buf_size(struct platform_device *dsidev)
> +static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int val;
> @@ -1852,9 +1852,9 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
>  	r = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1);
>  
>  	for (i = 0; i < dsi->num_lanes_used; ++i) {
> -		unsigned offset = offsets[i];
> -		unsigned polarity, lane_number;
> -		unsigned t;
> +		unsigned int offset = offsets[i];
> +		unsigned int polarity, lane_number;
> +		unsigned int t;
>  
>  		for (t = 0; t < dsi->num_lanes_supported; ++t)
>  			if (dsi->lanes[t].function == functions[i])
> @@ -1872,7 +1872,7 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
>  
>  	/* clear the unused lanes */
>  	for (; i < dsi->num_lanes_supported; ++i) {
> -		unsigned offset = offsets[i];
> +		unsigned int offset = offsets[i];
>  
>  		r = FLD_MOD(r, 0, offset + 2, offset);
>  		r = FLD_MOD(r, 0, offset + 3, offset + 3);
> @@ -1883,7 +1883,8 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
>  	return 0;
>  }
>  
> -static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns)
> +static inline unsigned int ns2ddr(struct platform_device *dsidev,
> +				  unsigned int ns)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> @@ -1892,7 +1893,8 @@ static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns)
>  	return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
>  }
>  
> -static inline unsigned ddr2ns(struct platform_device *dsidev, unsigned ddr)
> +static inline unsigned int ddr2ns(struct platform_device *dsidev,
> +				  unsigned int ddr)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> @@ -1980,7 +1982,7 @@ static void dsi_cio_timings(struct platform_device *dsidev)
>  
>  /* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
>  static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
> -		unsigned mask_p, unsigned mask_n)
> +		unsigned int mask_p, unsigned int mask_n)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int i;
> @@ -1990,7 +1992,7 @@ static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
>  	l = 0;
>  
>  	for (i = 0; i < dsi->num_lanes_supported; ++i) {
> -		unsigned p = dsi->lanes[i].polarity;
> +		unsigned int p = dsi->lanes[i].polarity;
>  
>  		if (mask_p & (1 << i))
>  			l |= 1 << (i * 2 + (p ? 0 : 1));
> @@ -2077,10 +2079,10 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
>  }
>  
>  /* return bitmask of enabled lanes, lane0 being the lsb */
> -static unsigned dsi_get_lane_mask(struct platform_device *dsidev)
> +static unsigned int dsi_get_lane_mask(struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -	unsigned mask = 0;
> +	unsigned int mask = 0;
>  	int i;
>  
>  	for (i = 0; i < dsi->num_lanes_supported; ++i) {
> @@ -2206,7 +2208,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  	dsi_write_reg(dsidev, DSI_TIMING1, l);
>  
>  	if (dsi->ulps_enabled) {
> -		unsigned mask_p;
> +		unsigned int mask_p;
>  		int i;
>  
>  		DSSDBG("manual ulps exit\n");
> @@ -3225,7 +3227,7 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	int r, i;
> -	unsigned mask;
> +	unsigned int mask;
>  
>  	DSSDBG("Entering ULPS");
>  
> @@ -3315,7 +3317,7 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
>  }
>  
>  static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
> -		unsigned ticks, bool x4, bool x16)
> +		unsigned int ticks, bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3341,8 +3343,8 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
>  			(total_ticks * 1000) / (fck / 1000 / 1000));
>  }
>  
> -static void dsi_set_ta_timeout(struct platform_device *dsidev, unsigned ticks,
> -		bool x8, bool x16)
> +static void dsi_set_ta_timeout(struct platform_device *dsidev,
> +			       unsigned int ticks, bool x8, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3369,7 +3371,7 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev, unsigned ticks,
>  }
>  
>  static void dsi_set_stop_state_counter(struct platform_device *dsidev,
> -		unsigned ticks, bool x4, bool x16)
> +				       unsigned int ticks, bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3396,7 +3398,7 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
>  }
>  
>  static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
> -		unsigned ticks, bool x4, bool x16)
> +				  unsigned int ticks, bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3742,13 +3744,13 @@ static int dsi_proto_config(struct platform_device *dsidev)
>  static void dsi_proto_timings(struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -	unsigned tlpx, tclk_zero, tclk_prepare, tclk_trail;
> -	unsigned tclk_pre, tclk_post;
> -	unsigned ths_prepare, ths_prepare_ths_zero, ths_zero;
> -	unsigned ths_trail, ths_exit;
> -	unsigned ddr_clk_pre, ddr_clk_post;
> -	unsigned enter_hs_mode_lat, exit_hs_mode_lat;
> -	unsigned ths_eot;
> +	unsigned int tlpx, tclk_zero, tclk_prepare, tclk_trail;
> +	unsigned int tclk_pre, tclk_post;
> +	unsigned int ths_prepare, ths_prepare_ths_zero, ths_zero;
> +	unsigned int ths_trail, ths_exit;
> +	unsigned int ddr_clk_pre, ddr_clk_post;
> +	unsigned int enter_hs_mode_lat, exit_hs_mode_lat;
> +	unsigned int ths_eot;
>  	int ndl = dsi->num_lanes_used - 1;
>  	u32 r;
>  
> @@ -4016,16 +4018,16 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	enum omap_channel dispc_channel = dsi->output.dispc_channel;
> -	unsigned bytespp;
> -	unsigned bytespl;
> -	unsigned bytespf;
> -	unsigned total_len;
> -	unsigned packet_payload;
> -	unsigned packet_len;
> +	unsigned int bytespp;
> +	unsigned int bytespl;
> +	unsigned int bytespf;
> +	unsigned int total_len;
> +	unsigned int packet_payload;
> +	unsigned int packet_len;
>  	u32 l;
>  	int r;
>  	const unsigned channel = dsi->update_channel;
> -	const unsigned line_buf_size = dsi->line_buffer_size;
> +	const unsigned int line_buf_size = dsi->line_buffer_size;
>  	u16 w = dsi->vm.hactive;
>  	u16 h = dsi->vm.vactive;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 0d447eddf4d6..a27edc56a509 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -183,8 +183,8 @@ static void dss_restore_context(void)
>  
>  void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
>  {
> -	unsigned shift;
> -	unsigned val;
> +	unsigned int shift;
> +	unsigned int val;
>  
>  	if (!dss.syscon_pll_ctrl)
>  		return;
> @@ -213,7 +213,7 @@ void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
>  static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
>  	enum omap_channel channel)
>  {
> -	unsigned shift, val;
> +	unsigned int shift, val;
>  
>  	if (!dss.syscon_pll_ctrl)
>  		return -EINVAL;
> @@ -622,12 +622,12 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
>  	unsigned long fck_hw_max;
>  	unsigned long fckd_hw_max;
>  	unsigned long prate;
> -	unsigned m;
> +	unsigned int m;
>  
>  	fck_hw_max = dss.feat->fck_freq_max;
>  
>  	if (dss.parent_clk == NULL) {
> -		unsigned pckd;
> +		unsigned int pckd;
>  
>  		pckd = fck_hw_max / pck;
>  
> @@ -696,7 +696,7 @@ static int dss_setup_default_clock(void)
>  {
>  	unsigned long max_dss_fck, prate;
>  	unsigned long fck;
> -	unsigned fck_div;
> +	unsigned int fck_div;
>  	int r;
>  
>  	max_dss_fck = dss.feat->fck_freq_max;
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 0d7f2b08b7ff..db529481b364 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -169,10 +169,10 @@ struct dss_pll_ops {
>  struct dss_pll_hw {
>  	enum dss_pll_type type;
>  
> -	unsigned n_max;
> -	unsigned m_min;
> -	unsigned m_max;
> -	unsigned mX_max;
> +	unsigned int n_max;
> +	unsigned int m_min;
> +	unsigned int m_max;
> +	unsigned int mX_max;
>  
>  	unsigned long fint_min, fint_max;
>  	unsigned long clkdco_min, clkdco_low, clkdco_max;
> @@ -412,7 +412,7 @@ void hdmi5_uninit_platform_driver(void);
>  
>  
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
> -static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
> +static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
>  {
>  	int b;
>  	for (b = 0; b < 32; ++b) {
> @@ -432,7 +432,7 @@ int dss_pll_register(struct dss_pll *pll);
>  void dss_pll_unregister(struct dss_pll *pll);
>  struct dss_pll *dss_pll_find(const char *name);
>  struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
> -unsigned dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
> +unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
>  int dss_pll_enable(struct dss_pll *pll);
>  void dss_pll_disable(struct dss_pll *pll);
>  int dss_pll_set_config(struct dss_pll *pll,
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index a598dfdeb585..21ca7bd13fdc 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -179,7 +179,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	struct hdmi_wp_data *wp = &hdmi.wp;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
> -	unsigned pc;
> +	unsigned int pc;
>  
>  	r = hdmi_power_on_core(dssdev);
>  	if (r)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index b3221ca5bcd8..f6c60a6e54ae 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -175,7 +175,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	struct videomode *vm;
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
> -	unsigned pc;
> +	unsigned int pc;
>  
>  	r = hdmi_power_on_core(dssdev);
>  	if (r)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
> index ab179ec133c0..f6236987e80d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
> @@ -51,14 +51,14 @@ static void hdmi_core_ddc_init(struct hdmi_core_data *core)
>  {
>  	void __iomem *base = core->base;
>  	const unsigned long long iclk = 266000000;	/* DSS L3 ICLK */
> -	const unsigned ss_scl_high = 4600;		/* ns */
> -	const unsigned ss_scl_low = 5400;		/* ns */
> -	const unsigned fs_scl_high = 600;		/* ns */
> -	const unsigned fs_scl_low = 1300;		/* ns */
> -	const unsigned sda_hold = 1000;			/* ns */
> -	const unsigned sfr_div = 10;
> +	const unsigned int ss_scl_high = 4600;		/* ns */
> +	const unsigned int ss_scl_low = 5400;		/* ns */
> +	const unsigned int fs_scl_high = 600;		/* ns */
> +	const unsigned int fs_scl_low = 1300;		/* ns */
> +	const unsigned int sda_hold = 1000;		/* ns */
> +	const unsigned int sfr_div = 10;
>  	unsigned long long sfr;
> -	unsigned v;
> +	unsigned int v;
>  
>  	sfr = iclk / sfr_div;	/* SFR_DIV */
>  	sfr /= 1000;		/* SFR clock in kHz */
> @@ -431,11 +431,11 @@ static void hdmi_core_write_avi_infoframe(struct hdmi_core_data *core,
>  	void __iomem *base = core->base;
>  	u8 data[HDMI_INFOFRAME_SIZE(AVI)];
>  	u8 *ptr;
> -	unsigned y, a, b, s;
> -	unsigned c, m, r;
> -	unsigned itc, ec, q, sc;
> -	unsigned vic;
> -	unsigned yq, cn, pr;
> +	unsigned int y, a, b, s;
> +	unsigned int c, m, r;
> +	unsigned int itc, ec, q, sc;
> +	unsigned int vic;
> +	unsigned int yq, cn, pr;
>  
>  	hdmi_avi_infoframe_pack(frame, data, sizeof(data));
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
> index a156292b1820..d8346d86463e 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
> @@ -99,7 +99,7 @@ static void hdmi_phy_configure_lanes(struct hdmi_phy_data *phy)
>  
>  	u16 lane_cfg = 0;
>  	int i;
> -	unsigned lane_cfg_val;
> +	unsigned int lane_cfg_val;
>  	u16 pol_val = 0;
>  
>  	for (i = 0; i < 4; ++i)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
> index 88034fbe0e9f..568ec61799be 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
> @@ -168,7 +168,7 @@ void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp,
>  {
>  	u32 timing_h = 0;
>  	u32 timing_v = 0;
> -	unsigned hsync_len_offset = 1;
> +	unsigned int hsync_len_offset = 1;
>  
>  	DSSDBG("Enter hdmi_wp_video_config_timing\n");
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 6f7dc8384055..3a6b33ff2990 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -198,8 +198,8 @@ enum omap_dss_dsi_trans_mode {
>  struct omap_dss_dsi_videomode_timings {
>  	unsigned long hsclk;
>  
> -	unsigned ndl;
> -	unsigned bitspp;
> +	unsigned int ndl;
> +	unsigned int bitspp;
>  
>  	/* pixels */
>  	u16 hact;
> diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
> index 9d9d9d42009b..d298cd5a927a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/pll.c
> @@ -105,7 +105,7 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
>  	}
>  }
>  
> -unsigned dss_pll_get_clkout_idx_for_src(enum dss_clk_source src)
> +unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src)
>  {
>  	switch (src) {
>  	case DSS_CLK_SRC_HDMI_PLL:
> @@ -277,7 +277,7 @@ bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
>  	unsigned long fint, clkdco, clkout;
>  	unsigned long target_clkdco;
>  	unsigned long min_dco;
> -	unsigned n, m, mf, m2, sd;
> +	unsigned int n, m, mf, m2, sd;
>  	const struct dss_pll_hw *hw = pll->hw;
>  
>  	DSSDBG("clkin %lu, target clkout %lu\n", clkin, target_clkout);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions
  2017-10-13 14:59 ` [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions Laurent Pinchart
@ 2017-10-14 12:41   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:41 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 6418 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:08PM +0300, Laurent Pinchart wrote:
> When merging the omapdrm and omapdss drivers there will be not omapdrm
> platform device anymore, and thus no associated probe and remove
> functions. To prepare for that, split all the initialization code from
> the probe function to make it usable without a platform device.
> Similarly, split the cleanup code from the remove function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/omap_drv.c | 83 +++++++++++++++++++++++---------------
>  drivers/gpu/drm/omapdrm/omap_drv.h |  2 +
>  2 files changed, 53 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 2d15ea1d6c92..cbca70f80d8e 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -542,24 +542,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
>  	{ /* sentinel */ }
>  };
>  
> -static int pdev_probe(struct platform_device *pdev)
> +static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  {
>  	const struct soc_device_attribute *soc;
> -	struct omap_drm_private *priv;
>  	struct drm_device *ddev;
>  	unsigned int i;
>  	int ret;
>  
> -	DBG("%s", pdev->name);
> -
> -	if (omapdss_is_initialized() == false)
> -		return -EPROBE_DEFER;
> +	DBG("%s", dev_name(dev));
>  
> -	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> -		return ret;
> -	}
> +	priv->dev = dev;
>  
>  	omap_crtc_pre_init();
>  
> @@ -567,13 +559,6 @@ static int pdev_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto err_crtc_uninit;
>  
> -	/* Allocate and initialize the driver private structure. */
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv) {
> -		ret = -ENOMEM;
> -		goto err_disconnect_dssdevs;
> -	}
> -
>  	priv->dispc_ops = dispc_get_ops();
>  
>  	soc = soc_device_match(omapdrm_soc_devices);
> @@ -584,27 +569,27 @@ static int pdev_probe(struct platform_device *pdev)
>  	INIT_LIST_HEAD(&priv->obj_list);
>  
>  	/* Allocate and initialize the DRM device. */
> -	ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev);
> +	ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
>  	if (IS_ERR(ddev)) {
>  		ret = PTR_ERR(ddev);
> -		goto err_free_priv;
> +		goto err_destroy_wq;
>  	}
>  
> +	priv->ddev = ddev;
>  	ddev->dev_private = priv;
> -	platform_set_drvdata(pdev, ddev);
>  
>  	omap_gem_init(ddev);
>  
>  	ret = omap_modeset_init(ddev);
>  	if (ret) {
> -		dev_err(&pdev->dev, "omap_modeset_init failed: ret=%d\n", ret);
> +		dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
>  		goto err_free_drm_dev;
>  	}
>  
>  	/* Initialize vblank handling, start with all CRTCs disabled. */
>  	ret = drm_vblank_init(ddev, priv->num_crtcs);
>  	if (ret) {
> -		dev_err(&pdev->dev, "could not init vblank\n");
> +		dev_err(priv->dev, "could not init vblank\n");
>  		goto err_cleanup_modeset;
>  	}
>  
> @@ -637,20 +622,17 @@ static int pdev_probe(struct platform_device *pdev)
>  err_free_drm_dev:
>  	omap_gem_deinit(ddev);
>  	drm_dev_unref(ddev);
> -err_free_priv:
> +err_destroy_wq:
>  	destroy_workqueue(priv->wq);
> -	kfree(priv);
> -err_disconnect_dssdevs:
>  	omap_disconnect_dssdevs();
>  err_crtc_uninit:
>  	omap_crtc_pre_uninit();
>  	return ret;
>  }
>  
> -static int pdev_remove(struct platform_device *pdev)
> +static void omapdrm_cleanup(struct omap_drm_private *priv)
>  {
> -	struct drm_device *ddev = platform_get_drvdata(pdev);
> -	struct omap_drm_private *priv = ddev->dev_private;
> +	struct drm_device *ddev = priv->ddev;
>  
>  	DBG("");
>  
> @@ -672,10 +654,45 @@ static int pdev_remove(struct platform_device *pdev)
>  	drm_dev_unref(ddev);
>  
>  	destroy_workqueue(priv->wq);
> -	kfree(priv);
>  
>  	omap_disconnect_dssdevs();
>  	omap_crtc_pre_uninit();
> +}
> +
> +static int pdev_probe(struct platform_device *pdev)
> +{
> +	struct omap_drm_private *priv;
> +	int ret;
> +
> +	if (omapdss_is_initialized() == false)
> +		return -EPROBE_DEFER;
> +
> +	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> +	if (ret) {
> +		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> +		return ret;
> +	}
> +
> +	/* Allocate and initialize the driver private structure. */
> +	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, priv);
> +
> +	ret = omapdrm_init(priv, &pdev->dev);
> +	if (ret < 0)
> +		kfree(priv);
> +
> +	return ret;
> +}
> +
> +static int pdev_remove(struct platform_device *pdev)
> +{
> +	struct omap_drm_private *priv = platform_get_drvdata(pdev);
> +
> +	omapdrm_cleanup(priv);
> +	kfree(priv);
>  
>  	return 0;
>  }
> @@ -719,7 +736,8 @@ static int omap_drm_resume_all_displays(void)
>  
>  static int omap_drm_suspend(struct device *dev)
>  {
> -	struct drm_device *drm_dev = dev_get_drvdata(dev);
> +	struct omap_drm_private *priv = dev_get_drvdata(dev);
> +	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_kms_helper_poll_disable(drm_dev);
>  
> @@ -732,7 +750,8 @@ static int omap_drm_suspend(struct device *dev)
>  
>  static int omap_drm_resume(struct device *dev)
>  {
> -	struct drm_device *drm_dev = dev_get_drvdata(dev);
> +	struct omap_drm_private *priv = dev_get_drvdata(dev);
> +	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_modeset_lock_all(drm_dev);
>  	omap_drm_resume_all_displays();
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 7bf008f02a77..2c06533a2d0a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -48,6 +48,8 @@
>  struct omap_drm_usergart;
>  
>  struct omap_drm_private {
> +	struct drm_device *ddev;
> +	struct device *dev;
>  	u32 omaprev;
>  
>  	const struct dispc_ops *dispc_ops;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration
  2017-10-13 14:59 ` [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration Laurent Pinchart
@ 2017-10-14 12:42   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:42 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1284 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:09PM +0300, Laurent Pinchart wrote:
> The tvc_of_match variable is never referenced before its definition.
> Remove the forward declaration.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> index 542a76503fbd..d3611233e264 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> @@ -40,8 +40,6 @@ static const struct videomode tvc_pal_vm = {
>  			  DISPLAY_FLAGS_VSYNC_LOW,
>  };
>  
> -static const struct of_device_id tvc_of_match[];
> -
>  #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
>  
>  static int tvc_connect(struct omap_dss_device *dssdev)
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers
  2017-10-13 14:59 ` [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers Laurent Pinchart
@ 2017-10-14 12:43   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:43 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2466 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:10PM +0300, Laurent Pinchart wrote:
> No connector is instantiated through platform data anymore, there is no
> need to check for OF node presence.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 3 ---
>  drivers/gpu/drm/omapdrm/displays/connector-dvi.c       | 3 ---
>  drivers/gpu/drm/omapdrm/displays/connector-hdmi.c      | 3 ---
>  3 files changed, 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> index d3611233e264..44c7d9238b54 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> @@ -196,9 +196,6 @@ static int tvc_probe(struct platform_device *pdev)
>  	struct omap_dss_device *dssdev;
>  	int r;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
>  	if (!ddata)
>  		return -ENOMEM;
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> index 05fa24a518c8..7728b5425d19 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> @@ -275,9 +275,6 @@ static int dvic_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ddata);
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = dvic_probe_of(pdev);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> index 4600d3841c25..b8d74fba4f45 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> @@ -336,9 +336,6 @@ static int hdmic_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, ddata);
>  	ddata->dev = &pdev->dev;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = hdmic_probe_of(pdev);
>  	if (r)
>  		return r;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers
  2017-10-13 14:59 ` [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers Laurent Pinchart
@ 2017-10-14 12:44   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:44 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2491 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:11PM +0300, Laurent Pinchart wrote:
> No encoder is instantiated through platform data anymore, there is no
> need to check for OF node presence.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/encoder-opa362.c    | 5 -----
>  drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c    | 3 ---
>  drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 3 ---
>  3 files changed, 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> index b1f6aa09f699..b28ec62267b1 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> @@ -179,11 +179,6 @@ static int opa362_probe(struct platform_device *pdev)
>  
>  	dev_dbg(&pdev->dev, "probe\n");
>  
> -	if (node == NULL) {
> -		dev_err(&pdev->dev, "Unable to find device tree\n");
> -		return -EINVAL;
> -	}
> -
>  	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
>  	if (!ddata)
>  		return -ENOMEM;
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> index b8e420c7d680..9e0ab4e77366 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> @@ -201,9 +201,6 @@ static int tfp410_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ddata);
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = tfp410_probe_of(pdev);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> index e3d98d78fc40..6c478140a52e 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> @@ -299,9 +299,6 @@ static int tpd_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ddata);
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = tpd_probe_of(pdev);
>  	if (r)
>  		return r;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers
  2017-10-13 14:59 ` [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers Laurent Pinchart
@ 2017-10-14 12:45   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:45 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 5575 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:12PM +0300, Laurent Pinchart wrote:
> No panel is instantiated through platform data anymore, there is no
> need to check for OF node presence.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/panel-dpi.c                | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c             | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c     | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c     | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c     | 3 ---
>  drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c     | 3 ---
>  8 files changed, 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> index e065f7e10cca..6468a765f3d1 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> @@ -231,9 +231,6 @@ static int panel_dpi_probe(struct platform_device *pdev)
>  	struct omap_dss_device *dssdev;
>  	int r;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
>  	if (ddata == NULL)
>  		return -ENOMEM;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> index bdc0e8a3832d..aac14f399657 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> @@ -1168,9 +1168,6 @@ static int dsicm_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, ddata);
>  	ddata->pdev = pdev;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = dsicm_probe_of(pdev);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> index 74d13969b9ca..b955aa615a5f 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> @@ -268,9 +268,6 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
>  
>  	ddata->spi = spi;
>  
> -	if (!spi->dev.of_node)
> -		return -ENODEV;
> -
>  	r = lb035q02_probe_of(spi);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> index df8132d3b9c6..70fa5a04c00e 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> @@ -277,9 +277,6 @@ static int nec_8048_probe(struct spi_device *spi)
>  
>  	ddata->spi = spi;
>  
> -	if (!spi->dev.of_node)
> -		return -ENODEV;
> -
>  	r = nec_8048_probe_of(spi);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> index 98d170aecaba..99048e430871 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> @@ -268,9 +268,6 @@ static int sharp_ls_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ddata);
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	r = sharp_ls_probe_of(pdev);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> index 06d7d8362a73..cc5e9a68726a 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> @@ -720,9 +720,6 @@ static int acx565akm_probe(struct spi_device *spi)
>  
>  	dev_dbg(&spi->dev, "%s\n", __func__);
>  
> -	if (!spi->dev.of_node)
> -		return -ENODEV;
> -
>  	spi->mode = SPI_MODE_3;
>  
>  	ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL);
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> index 0a38a0e8c925..34d8f42fefbe 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> @@ -404,9 +404,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
>  
>  	ddata->spi_dev = spi;
>  
> -	if (!spi->dev.of_node)
> -		return -ENODEV;
> -
>  	r = td028ttec1_probe_of(spi);
>  	if (r)
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> index ac4a6d4d134c..06fb5a995002 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> @@ -509,9 +509,6 @@ static int tpo_td043_probe(struct spi_device *spi)
>  
>  	ddata->spi = spi;
>  
> -	if (!spi->dev.of_node)
> -		return -ENODEV;
> -
>  	r = tpo_td043_probe_of(spi);
>  	if (r)
>  		return r;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time
  2017-10-13 14:59 ` [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time Laurent Pinchart
@ 2017-10-14 12:51   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:51 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 10304 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:13PM +0300, Laurent Pinchart wrote:
> The connector drivers need a handle to the source they are connected to
> in order to control the source.
> 
> All drivers get that handle at probe time, resulting in probe deferral
> when the source hasn't been probed yet. However they don't need the
> handle until their connect handler is called.
> 
> Move retrieval of the source handle to the connect handler to avoid
> probe deferrals.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 45 ++++++++--------------
>  drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 31 +++++++--------
>  drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 37 ++++++++----------
>  3 files changed, 46 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> index 44c7d9238b54..f07546b8e8dd 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
> @@ -45,7 +45,7 @@ static const struct videomode tvc_pal_vm = {
>  static int tvc_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	dev_dbg(ddata->dev, "connect\n");
> @@ -53,10 +53,19 @@ static int tvc_connect(struct omap_dss_device *dssdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(ddata->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.atv->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -71,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.atv->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int tvc_enable(struct omap_dss_device *dssdev)
> @@ -173,23 +185,6 @@ static struct omap_dss_driver tvc_driver = {
>  	.set_wss		= tvc_set_wss,
>  };
>  
> -static int tvc_probe_of(struct platform_device *pdev)
> -{
> -	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
> -
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
> -	return 0;
> -}
> -
>  static int tvc_probe(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata;
> @@ -203,10 +198,6 @@ static int tvc_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, ddata);
>  	ddata->dev = &pdev->dev;
>  
> -	r = tvc_probe_of(pdev);
> -	if (r)
> -		return r;
> -
>  	ddata->vm = tvc_pal_vm;
>  
>  	dssdev = &ddata->dssdev;
> @@ -219,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit tvc_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	tvc_disable(dssdev);
>  	tvc_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> index 7728b5425d19..ad915860b7fd 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> @@ -51,16 +51,25 @@ struct panel_drv_data {
>  static int dvic_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dvi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -73,6 +82,9 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dvi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int dvic_enable(struct omap_dss_device *dssdev)
> @@ -235,25 +247,15 @@ static int dvic_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	struct device_node *adapter_node;
>  	struct i2c_adapter *adapter;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0);
>  	if (adapter_node) {
>  		adapter = of_get_i2c_adapter_by_node(adapter_node);
>  		of_node_put(adapter_node);
>  		if (adapter == NULL) {
>  			dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n");
> -			omap_dss_put_device(ddata->in);
>  			return -EPROBE_DEFER;
>  		}
>  
> @@ -297,8 +299,6 @@ static int dvic_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_reg:
> -	omap_dss_put_device(ddata->in);
> -
>  	i2c_put_adapter(ddata->i2c_adapter);
>  
>  	return r;
> @@ -308,15 +308,12 @@ static int __exit dvic_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	dvic_disable(dssdev);
>  	dvic_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	i2c_put_adapter(ddata->i2c_adapter);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> index b8d74fba4f45..dedf60b32dab 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> @@ -55,7 +55,7 @@ struct panel_drv_data {
>  static int hdmic_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	dev_dbg(ddata->dev, "connect\n");
> @@ -63,10 +63,19 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(ddata->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.hdmi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -81,6 +90,9 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.hdmi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int hdmic_enable(struct omap_dss_device *dssdev)
> @@ -302,7 +314,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	/* HPD GPIO */
> @@ -312,14 +323,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
>  	else
>  		ddata->hpd_gpio = -ENODEV;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -346,7 +349,7 @@ static int hdmic_probe(struct platform_device *pdev)
>  		r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio,
>  				GPIOF_DIR_IN, "hdmi_hpd");
>  		if (r)
> -			goto err_reg;
> +			return r;
>  
>  		r = devm_request_threaded_irq(&pdev->dev,
>  				gpio_to_irq(ddata->hpd_gpio),
> @@ -355,7 +358,7 @@ static int hdmic_probe(struct platform_device *pdev)
>  				IRQF_ONESHOT,
>  				"hdmic hpd", ddata);
>  		if (r)
> -			goto err_reg;
> +			return r;
>  	}
>  
>  	ddata->vm = hdmic_default_vm;
> @@ -370,28 +373,22 @@ static int hdmic_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit hdmic_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	hdmic_disable(dssdev);
>  	hdmic_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 18/48] drm: omapdrm: displays: Get panel source at connect time
  2017-10-13 14:59 ` [PATCH 18/48] drm: omapdrm: displays: Get panel " Laurent Pinchart
@ 2017-10-14 12:55   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:55 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 24356 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:14PM +0300, Laurent Pinchart wrote:
> The connector drivers need a handle to the source they are connected to
> in order to control the source.
> 
> All drivers get that handle at probe time, resulting in probe deferral
> when the source hasn't been probed yet. However they don't need the
> handle until their connect handler is called.
> 
> Move retrieval of the source handle to the connect handler to avoid
> probe deferrals.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/panel-dpi.c       | 35 +++++++---------
>  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 27 +++++++------
>  .../omapdrm/displays/panel-lgphilips-lb035q02.c    | 35 +++++++---------
>  .../drm/omapdrm/displays/panel-nec-nl8048hl11.c    | 39 ++++++++----------
>  .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c | 35 +++++++---------
>  .../drm/omapdrm/displays/panel-sony-acx565akm.c    | 26 ++++++------
>  .../drm/omapdrm/displays/panel-tpo-td028ttec1.c    | 46 +++++++---------------
>  .../drm/omapdrm/displays/panel-tpo-td043mtea1.c    | 29 +++++++-------
>  8 files changed, 119 insertions(+), 153 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> index 6468a765f3d1..e48c4a7d5276 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
> @@ -38,16 +38,25 @@ struct panel_drv_data {
>  static int panel_dpi_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -60,6 +69,9 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int panel_dpi_enable(struct omap_dss_device *dssdev)
> @@ -165,7 +177,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
>  	struct device_node *bl_node;
> -	struct omap_dss_device *in;
>  	int r;
>  	struct display_timing timing;
>  	struct gpio_desc *gpio;
> @@ -207,15 +218,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
>  
>  	videomode_from_timing(&timing, &ddata->vm);
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		r = PTR_ERR(in);
> -		goto error_free_backlight;
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  
>  error_free_backlight:
> @@ -251,29 +253,22 @@ static int panel_dpi_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit panel_dpi_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(dssdev);
>  
>  	panel_dpi_disable(dssdev);
>  	panel_dpi_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	if (ddata->backlight)
>  		put_device(&ddata->backlight->dev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> index aac14f399657..1262b7b08ba2 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> @@ -703,17 +703,23 @@ static int dsicm_panel_reset(struct panel_drv_data *ddata)
>  static int dsicm_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
>  	struct device *dev = &ddata->pdev->dev;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dsi->connect(in, dssdev);
>  	if (r) {
>  		dev_err(dev, "Failed to connect to video source\n");
> -		return r;
> +		goto err_connect;
>  	}
>  
>  	r = in->ops.dsi->request_vc(ddata->in, &ddata->channel);
> @@ -728,12 +734,15 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
>  		goto err_vc_id;
>  	}
>  
> +	ddata->in = in;
>  	return 0;
>  
>  err_vc_id:
>  	in->ops.dsi->release_vc(ddata->in, ddata->channel);
>  err_req_vc:
>  	in->ops.dsi->disconnect(in, dssdev);
> +err_connect:
> +	omap_dss_put_device(in);
>  	return r;
>  }
>  
> @@ -747,6 +756,9 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
>  
>  	in->ops.dsi->release_vc(in, ddata->channel);
>  	in->ops.dsi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int dsicm_enable(struct omap_dss_device *dssdev)
> @@ -1119,7 +1131,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
>  {
>  	struct device_node *node = pdev->dev.of_node;
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	gpio = of_get_named_gpio(node, "reset-gpios", 0);
> @@ -1137,14 +1148,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
>  		return gpio;
>  	}
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	/* TODO: ulps, backlight */
>  
>  	return 0;
> @@ -1298,8 +1301,6 @@ static int __exit dsicm_remove(struct platform_device *pdev)
>  		backlight_device_unregister(bldev);
>  	}
>  
> -	omap_dss_put_device(ddata->in);
> -
>  	dsicm_cancel_ulps_work(ddata);
>  	destroy_workqueue(ddata->workqueue);
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> index b955aa615a5f..bbcf18672433 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
> @@ -119,18 +119,27 @@ static void init_lb035q02_panel(struct spi_device *spi)
>  static int lb035q02_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
>  	init_lb035q02_panel(ddata->spi);
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -143,6 +152,9 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int lb035q02_enable(struct omap_dss_device *dssdev)
> @@ -230,9 +242,7 @@ static struct omap_dss_driver lb035q02_ops = {
>  
>  static int lb035q02_probe_of(struct spi_device *spi)
>  {
> -	struct device_node *node = spi->dev.of_node;
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
> -	struct omap_dss_device *in;
>  	struct gpio_desc *gpio;
>  
>  	gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
> @@ -243,14 +253,6 @@ static int lb035q02_probe_of(struct spi_device *spi)
>  
>  	ddata->enable_gpio = gpio;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&spi->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -284,29 +286,22 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&spi->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int lb035q02_panel_spi_remove(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(dssdev);
>  
>  	lb035q02_disable(dssdev);
>  	lb035q02_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> index 70fa5a04c00e..9e717cd4f194 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> @@ -115,16 +115,25 @@ static int init_nec_8048_wvga_lcd(struct spi_device *spi)
>  static int nec_8048_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -137,6 +146,9 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int nec_8048_enable(struct omap_dss_device *dssdev)
> @@ -226,7 +238,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
>  {
>  	struct device_node *node = spi->dev.of_node;
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	gpio = of_get_named_gpio(node, "reset-gpios", 0);
> @@ -239,14 +250,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
>  	/* XXX the panel spec doesn't mention any QVGA pin?? */
>  	ddata->qvga_gpio = -ENOENT;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&spi->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -285,14 +288,14 @@ static int nec_8048_probe(struct spi_device *spi)
>  		r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
>  				GPIOF_OUT_INIT_HIGH, "lcd QVGA");
>  		if (r)
> -			goto err_gpio;
> +			return r;
>  	}
>  
>  	if (gpio_is_valid(ddata->res_gpio)) {
>  		r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
>  				GPIOF_OUT_INIT_LOW, "lcd RES");
>  		if (r)
> -			goto err_gpio;
> +			return r;
>  	}
>  
>  	ddata->vm = nec_8048_panel_vm;
> @@ -307,22 +310,16 @@ static int nec_8048_probe(struct spi_device *spi)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&spi->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -
> -err_reg:
> -err_gpio:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int nec_8048_remove(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
>  
> @@ -331,8 +328,6 @@ static int nec_8048_remove(struct spi_device *spi)
>  	nec_8048_disable(dssdev);
>  	nec_8048_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> index 99048e430871..d67f09a7ba4f 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
> @@ -61,16 +61,25 @@ static const struct videomode sharp_ls_vm = {
>  static int sharp_ls_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -83,6 +92,9 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int sharp_ls_enable(struct omap_dss_device *dssdev)
> @@ -210,8 +222,6 @@ static  int sharp_ls_get_gpio_of(struct device *dev, int index, int val,
>  static int sharp_ls_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	int r;
>  
>  	ddata->vcc = devm_regulator_get(&pdev->dev, "envdd");
> @@ -245,14 +255,6 @@ static int sharp_ls_probe_of(struct platform_device *pdev)
>  	if (r)
>  		return r;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -284,29 +286,22 @@ static int sharp_ls_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit sharp_ls_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(dssdev);
>  
>  	sharp_ls_disable(dssdev);
>  	sharp_ls_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> index cc5e9a68726a..c4bb33a247d0 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
> @@ -510,16 +510,25 @@ static const struct attribute_group bldev_attr_group = {
>  static int acx565akm_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.sdi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -532,6 +541,9 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.sdi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int acx565akm_panel_power_on(struct omap_dss_device *dssdev)
> @@ -700,12 +712,6 @@ static int acx565akm_probe_of(struct spi_device *spi)
>  
>  	ddata->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
>  
> -	ddata->in = omapdss_of_find_source_for_first_ep(np);
> -	if (IS_ERR(ddata->in)) {
> -		dev_err(&spi->dev, "failed to find video source\n");
> -		return PTR_ERR(ddata->in);
> -	}
> -
>  	return 0;
>  }
>  
> @@ -823,7 +829,6 @@ static int acx565akm_probe(struct spi_device *spi)
>  err_reg_bl:
>  err_detect:
>  err_gpio:
> -	omap_dss_put_device(ddata->in);
>  	return r;
>  }
>  
> @@ -831,7 +836,6 @@ static int acx565akm_remove(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
>  
> @@ -843,8 +847,6 @@ static int acx565akm_remove(struct spi_device *spi)
>  	acx565akm_disable(dssdev);
>  	acx565akm_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> index 34d8f42fefbe..f49127afd17a 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
> @@ -169,16 +169,25 @@ enum jbt_register {
>  static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -191,6 +200,9 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int td028ttec1_panel_enable(struct omap_dss_device *dssdev)
> @@ -362,23 +374,6 @@ static struct omap_dss_driver td028ttec1_ops = {
>  	.check_timings	= td028ttec1_panel_check_timings,
>  };
>  
> -static int td028ttec1_probe_of(struct spi_device *spi)
> -{
> -	struct device_node *node = spi->dev.of_node;
> -	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
> -	struct omap_dss_device *in;
> -
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&spi->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
> -	return 0;
> -}
> -
>  static int td028ttec1_panel_probe(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata;
> @@ -404,10 +399,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
>  
>  	ddata->spi_dev = spi;
>  
> -	r = td028ttec1_probe_of(spi);
> -	if (r)
> -		return r;
> -
>  	ddata->vm = td028ttec1_panel_vm;
>  
>  	dssdev = &ddata->dssdev;
> @@ -420,21 +411,16 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&spi->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int td028ttec1_panel_remove(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	dev_dbg(&ddata->spi_dev->dev, "%s\n", __func__);
>  
> @@ -443,8 +429,6 @@ static int td028ttec1_panel_remove(struct spi_device *spi)
>  	td028ttec1_panel_disable(dssdev);
>  	td028ttec1_panel_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> index 06fb5a995002..c08e22b43447 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
> @@ -340,16 +340,25 @@ static void tpo_td043_power_off(struct panel_drv_data *ddata)
>  static int tpo_td043_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -362,6 +371,9 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dpi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int tpo_td043_enable(struct omap_dss_device *dssdev)
> @@ -463,7 +475,6 @@ static int tpo_td043_probe_of(struct spi_device *spi)
>  {
>  	struct device_node *node = spi->dev.of_node;
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	gpio = of_get_named_gpio(node, "reset-gpios", 0);
> @@ -473,14 +484,6 @@ static int tpo_td043_probe_of(struct spi_device *spi)
>  	}
>  	ddata->nreset_gpio = gpio;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&spi->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -561,7 +564,6 @@ static int tpo_td043_probe(struct spi_device *spi)
>  err_sysfs:
>  err_gpio_req:
>  err_regulator:
> -	omap_dss_put_device(ddata->in);
>  	return r;
>  }
>  
> @@ -569,7 +571,6 @@ static int tpo_td043_remove(struct spi_device *spi)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	dev_dbg(&ddata->spi->dev, "%s\n", __func__);
>  
> @@ -578,8 +579,6 @@ static int tpo_td043_remove(struct spi_device *spi)
>  	tpo_td043_disable(dssdev);
>  	tpo_td043_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group);
>  
>  	return 0;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 19/48] drm: omapdrm: displays: Get encoder source at connect time
  2017-10-13 14:59 ` [PATCH 19/48] drm: omapdrm: displays: Get encoder " Laurent Pinchart
@ 2017-10-14 12:58   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 12:58 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 11563 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:15PM +0300, Laurent Pinchart wrote:
> The encoder drivers need a handle to the source they are connected to in
> order to control the source.
> 
> All drivers get that handle at probe time, resulting in probe deferral
> when the source hasn't been probed yet. However they don't need the
> handle until their connect handler is called.
> 
> Move retrieval of the source handle to the connect handler to avoid
> probe deferrals.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 35 ++++++------
>  drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 36 ++++++------
>  .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 66 ++++++++--------------
>  3 files changed, 54 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> index b28ec62267b1..b3bb64b477fa 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> @@ -36,7 +36,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	dev_dbg(dssdev->dev, "connect\n");
> @@ -44,13 +44,22 @@ static int opa362_connect(struct omap_dss_device *dssdev,
>  	if (omapdss_device_is_connected(dssdev))
>  		return -EBUSY;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.atv->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
>  	dst->src = dssdev;
>  	dssdev->dst = dst;
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -74,6 +83,9 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
>  	dssdev->dst = NULL;
>  
>  	in->ops.atv->disconnect(in, &ddata->dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int opa362_enable(struct omap_dss_device *dssdev)
> @@ -171,9 +183,8 @@ static const struct omapdss_atv_ops opa362_atv_ops = {
>  
>  static int opa362_probe(struct platform_device *pdev)
>  {
> -	struct device_node *node = pdev->dev.of_node;
>  	struct panel_drv_data *ddata;
> -	struct omap_dss_device *dssdev, *in;
> +	struct omap_dss_device *dssdev;
>  	struct gpio_desc *gpio;
>  	int r;
>  
> @@ -191,14 +202,6 @@ static int opa362_probe(struct platform_device *pdev)
>  
>  	ddata->enable_gpio = gpio;
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	dssdev = &ddata->dssdev;
>  	dssdev->ops.atv = &opa362_atv_ops;
>  	dssdev->dev = &pdev->dev;
> @@ -209,20 +212,16 @@ static int opa362_probe(struct platform_device *pdev)
>  	r = omapdss_register_output(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register output\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit opa362_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_output(&ddata->dssdev);
>  
> @@ -234,8 +233,6 @@ static int __exit opa362_remove(struct platform_device *pdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		opa362_disconnect(dssdev, dssdev->dst);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> index 9e0ab4e77366..0d640f8c0689 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> @@ -32,19 +32,28 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return -EBUSY;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.dpi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
>  	dst->src = dssdev;
>  	dssdev->dst = dst;
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -66,6 +75,9 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
>  	dssdev->dst = NULL;
>  
>  	in->ops.dpi->disconnect(in, &ddata->dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int tfp410_enable(struct omap_dss_device *dssdev)
> @@ -165,7 +177,6 @@ static int tfp410_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	gpio = of_get_named_gpio(node, "powerdown-gpios", 0);
> @@ -178,14 +189,6 @@ static int tfp410_probe_of(struct platform_device *pdev)
>  		return gpio;
>  	}
>  
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
>  	return 0;
>  }
>  
> @@ -211,7 +214,7 @@ static int tfp410_probe(struct platform_device *pdev)
>  		if (r) {
>  			dev_err(&pdev->dev, "Failed to request PD GPIO %d\n",
>  					ddata->pd_gpio);
> -			goto err_gpio;
> +			return r;
>  		}
>  	}
>  
> @@ -226,21 +229,16 @@ static int tfp410_probe(struct platform_device *pdev)
>  	r = omapdss_register_output(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register output\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -err_gpio:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit tfp410_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_output(&ddata->dssdev);
>  
> @@ -252,8 +250,6 @@ static int __exit tfp410_remove(struct platform_device *pdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		tfp410_disconnect(dssdev, dssdev->dst);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> index 6c478140a52e..226fad5cdab1 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> @@ -40,12 +40,20 @@ static int tpd_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
> +	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
> +	if (IS_ERR(in)) {
> +		dev_err(dssdev->dev, "failed to find video source\n");
> +		return PTR_ERR(in);
> +	}
> +
>  	r = in->ops.hdmi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
>  	dst->src = dssdev;
>  	dssdev->dst = dst;
> @@ -56,6 +64,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
>  	/* DC-DC converter needs at max 300us to get to 90% of 5V */
>  	udelay(300);
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -77,6 +86,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
>  	dssdev->dst = NULL;
>  
>  	in->ops.hdmi->disconnect(in, &ddata->dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int tpd_enable(struct omap_dss_device *dssdev)
> @@ -269,23 +281,6 @@ static irqreturn_t tpd_hpd_isr(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static int tpd_probe_of(struct platform_device *pdev)
> -{
> -	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
> -
> -	in = omapdss_of_find_source_for_first_ep(node);
> -	if (IS_ERR(in)) {
> -		dev_err(&pdev->dev, "failed to find video source\n");
> -		return PTR_ERR(in);
> -	}
> -
> -	ddata->in = in;
> -
> -	return 0;
> -}
> -
>  static int tpd_probe(struct platform_device *pdev)
>  {
>  	struct omap_dss_device *in, *dssdev;
> @@ -299,34 +294,24 @@ static int tpd_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ddata);
>  
> -	r = tpd_probe_of(pdev);
> -	if (r)
> -		return r;
> -
>  	gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 0,
>  		 GPIOD_OUT_LOW);
> -	if (IS_ERR(gpio)) {
> -		r = PTR_ERR(gpio);
> -		goto err_gpio;
> -	}
> +	if (IS_ERR(gpio))
> +		return PTR_ERR(gpio);
>  
>  	ddata->ct_cp_hpd_gpio = gpio;
>  
>  	gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 1,
>  		 GPIOD_OUT_LOW);
> -	if (IS_ERR(gpio)) {
> -		r = PTR_ERR(gpio);
> -		goto err_gpio;
> -	}
> +	if (IS_ERR(gpio))
> +		return PTR_ERR(gpio);
>  
>  	ddata->ls_oe_gpio = gpio;
>  
>  	gpio = devm_gpiod_get_index(&pdev->dev, NULL, 2,
>  		GPIOD_IN);
> -	if (IS_ERR(gpio)) {
> -		r = PTR_ERR(gpio);
> -		goto err_gpio;
> -	}
> +	if (IS_ERR(gpio))
> +		return PTR_ERR(gpio);
>  
>  	ddata->hpd_gpio = gpio;
>  
> @@ -337,7 +322,7 @@ static int tpd_probe(struct platform_device *pdev)
>  		IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>  		"tpd12s015 hpd", ddata);
>  	if (r)
> -		goto err_gpio;
> +		return r;
>  
>  	dssdev = &ddata->dssdev;
>  	dssdev->ops.hdmi = &tpd_hdmi_ops;
> @@ -352,21 +337,16 @@ static int tpd_probe(struct platform_device *pdev)
>  	r = omapdss_register_output(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register output\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -err_gpio:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit tpd_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_output(&ddata->dssdev);
>  
> @@ -378,8 +358,6 @@ static int __exit tpd_remove(struct platform_device *pdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		tpd_disconnect(dssdev, dssdev->dst);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers
  2017-10-13 14:59 ` [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers Laurent Pinchart
@ 2017-10-14 13:12   ` Sebastian Reichel
  2017-10-16  9:09     ` Laurent Pinchart
  0 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-14 13:12 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 16464 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:16PM +0300, Laurent Pinchart wrote:
> The split between the omapdss and omapdrm driver is historic and was due
> to other userspace APIs (FBDEV and V4L2) being supported in addition to
> DRM/KMS. Now that the drivers only supports the DRM/KMS API, there is no
> need to keep them separate anymore.
> 
> Merge the two drivers and remove the now unneeded omapdrm virtual
> platform device.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/Kconfig          |  5 +-
>  drivers/gpu/drm/omapdrm/Makefile         | 25 ++++++++++
>  drivers/gpu/drm/omapdrm/dss/Kconfig      | 12 -----
>  drivers/gpu/drm/omapdrm/dss/Makefile     | 25 ----------
>  drivers/gpu/drm/omapdrm/dss/base.c       | 13 -----
>  drivers/gpu/drm/omapdrm/dss/core.c       | 14 ++----
>  drivers/gpu/drm/omapdrm/dss/dss.c        | 23 ++++++++-
>  drivers/gpu/drm/omapdrm/dss/omapdss.h    |  4 --
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 12 ++++-
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  3 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c       | 82 ++------------------------------
>  drivers/gpu/drm/omapdrm/omap_drv.h       |  4 ++
>  12 files changed, 74 insertions(+), 148 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
> index b3d08c5f41d4..7e5080e45b16 100644
> --- a/drivers/gpu/drm/omapdrm/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/Kconfig
> @@ -2,8 +2,11 @@ config DRM_OMAP
>  	tristate "OMAP DRM"
>  	depends on DRM
>  	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
> -	select OMAP2_DSS
>  	select DRM_KMS_HELPER
> +	select HDMI
> +	select OMAP2_DSS

As far as I can see "CONFIG_OMAP2_DSS" no longer exists after the merge,
so this can be dropped.

Otherwise:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> +	select OMAP2_DSS_INIT
> +	select VIDEOMODE_HELPERS
>  	default n
>  	help
>  	  DRM display driver for OMAP2/3/4 based boards.
> diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
> index b391be7ecb6c..1dafa51ca00e 100644
> --- a/drivers/gpu/drm/omapdrm/Makefile
> +++ b/drivers/gpu/drm/omapdrm/Makefile
> @@ -21,4 +21,29 @@ omapdrm-y := omap_drv.o \
>  
>  omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
>  
> +# Core DSS files
> +omapdrm-y += \
> +	dss/base.o \
> +	dss/core.o \
> +	dss/dispc.o \
> +	dss/dispc_coefs.o \
> +	dss/display.o \
> +	dss/dss.o \
> +	dss/dss-of.o \
> +	dss/output.o \
> +	dss/pll.o \
> +	dss/video-pll.o
> +
> +omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
> +omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
> +	dss/hdmi_pll.o dss/hdmi_phy.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
> +omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
> +
> +ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> +
>  obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
> index 39a30a64448a..157c5601e4be 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
> @@ -1,16 +1,6 @@
>  config OMAP2_DSS_INIT
>  	bool
>  
> -menuconfig OMAP2_DSS
> -        tristate "OMAP2+ Display Subsystem support"
> -	select VIDEOMODE_HELPERS
> -	select OMAP2_DSS_INIT
> -	select HDMI
> -        help
> -	  OMAP2+ Display Subsystem support.
> -
> -if OMAP2_DSS
> -
>  config OMAP2_DSS_DEBUG
>  	bool "Debug support"
>  	default n
> @@ -126,5 +116,3 @@ config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
>  
>  	  This option enables the sleep, and is enabled by default. You can
>  	  disable the sleep if it doesn't cause problems on your platform.
> -
> -endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
> index 531b4d8075e5..3db4bf31aeaf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> +++ b/drivers/gpu/drm/omapdrm/dss/Makefile
> @@ -1,26 +1 @@
>  obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
> -obj-$(CONFIG_OMAP2_DSS) += omapdss.o
> -
> -# Core DSS files
> -omapdss-y := \
> -	base.o \
> -	display.o \
> -	dss-of.o \
> -	output.o \
> -	core.o \
> -	dss.o \
> -	dispc.o \
> -	dispc_coefs.o \
> -	pll.o \
> -	video-pll.o
> -
> -omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
> -omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
> -omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
> -omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
> -omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
> -	hdmi_phy.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
> -omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
> -ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index eff427dd3297..5729f8244bf9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -5,7 +5,6 @@
>  #include <linux/list.h>
>  #include "omapdss.h"
>  
> -static bool dss_initialized;
>  static const struct dispc_ops *ops;
>  
>  static struct list_head omapdss_comp_list;
> @@ -16,17 +15,6 @@ struct omapdss_comp_node {
>  	bool dss_core_component;
>  };
>  
> -void omapdss_set_is_initialized(bool set)
> -{
> -	dss_initialized = set;
> -}
> -
> -bool omapdss_is_initialized(void)
> -{
> -	return dss_initialized;
> -}
> -EXPORT_SYMBOL(omapdss_is_initialized);
> -
>  void dispc_set_ops(const struct dispc_ops *o)
>  {
>  	ops = o;
> @@ -130,4 +118,3 @@ bool omapdss_stack_is_ready(void)
>  
>  	return true;
>  }
> -EXPORT_SYMBOL(omapdss_stack_is_ready);
> diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c
> index 197ddbc1512b..776f43601288 100644
> --- a/drivers/gpu/drm/omapdrm/dss/core.c
> +++ b/drivers/gpu/drm/omapdrm/dss/core.c
> @@ -24,13 +24,14 @@
>  
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> -#include <linux/platform_device.h>
>  
>  #include "omapdss.h"
>  #include "dss.h"
> +#include "../omap_dmm_tiler.h"
>  
>  /* INIT */
>  static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
> +	dmm_init_platform_driver,
>  	dss_init_platform_driver,
>  	dispc_init_platform_driver,
>  #ifdef CONFIG_OMAP2_DSS_DSI
> @@ -62,10 +63,9 @@ static void (*dss_output_drv_unreg_funcs[])(void) = {
>  #endif
>  	dispc_uninit_platform_driver,
>  	dss_uninit_platform_driver,
> +	dmm_uninit_platform_driver,
>  };
>  
> -static struct platform_device *omap_drm_device;
> -
>  static int __init omap_dss_init(void)
>  {
>  	int r;
> @@ -77,12 +77,6 @@ static int __init omap_dss_init(void)
>  			goto err_reg;
>  	}
>  
> -	omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
> -	if (IS_ERR(omap_drm_device)) {
> -		r = PTR_ERR(omap_drm_device);
> -		goto err_reg;
> -	}
> -
>  	return 0;
>  
>  err_reg:
> @@ -98,8 +92,6 @@ static void __exit omap_dss_exit(void)
>  {
>  	int i;
>  
> -	platform_device_unregister(omap_drm_device);
> -
>  	for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i)
>  		dss_output_drv_unreg_funcs[i]();
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index a27edc56a509..5721f3d64bdd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -49,6 +49,7 @@
>  
>  #include "omapdss.h"
>  #include "dss.h"
> +#include "../omap_drv.h"
>  
>  #define DSS_SZ_REGS			SZ_512
>  
> @@ -94,6 +95,8 @@ struct dss_features {
>  
>  static struct {
>  	struct platform_device *pdev;
> +	struct omap_drm_private drm;
> +
>  	void __iomem    *base;
>  	struct regmap	*syscon_pll_ctrl;
>  	u32		syscon_pll_ctrl_offset;
> @@ -1366,10 +1369,15 @@ static int dss_bind(struct device *dev)
>  	pm_set_vt_switch(0);
>  
>  	omapdss_gather_components(dev);
> -	omapdss_set_is_initialized(true);
> +
> +	r = omapdrm_init(&dss.drm, dev);
> +	if (r)
> +		goto err_drm_init;
>  
>  	return 0;
>  
> +err_drm_init:
> +	component_unbind_all(&pdev->dev, NULL);
>  err_component:
>  err_runtime_get:
>  	pm_runtime_disable(&pdev->dev);
> @@ -1390,7 +1398,7 @@ static void dss_unbind(struct device *dev)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  
> -	omapdss_set_is_initialized(false);
> +	omapdrm_cleanup(&dss.drm);
>  
>  	component_unbind_all(&pdev->dev, NULL);
>  
> @@ -1531,7 +1539,18 @@ static int dss_runtime_resume(struct device *dev)
>  	return 0;
>  }
>  
> +static int dss_suspend(struct device *dev)
> +{
> +	return omap_drm_suspend(&dss.drm);
> +}
> +
> +static int dss_resume(struct device *dev)
> +{
> +	return omap_drm_resume(&dss.drm);
> +}
> +
>  static const struct dev_pm_ops dss_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(dss_suspend, dss_resume)
>  	.runtime_suspend = dss_runtime_suspend,
>  	.runtime_resume = dss_runtime_resume,
>  };
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 3a6b33ff2990..6f9b9b2d8af2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -583,8 +583,6 @@ struct omap_dss_driver {
>  		const struct hdmi_avi_infoframe *avi);
>  };
>  
> -bool omapdss_is_initialized(void);
> -
>  int omap_dss_register_driver(struct omap_dss_driver *);
>  void omap_dss_unregister_driver(struct omap_dss_driver *);
>  
> @@ -633,8 +631,6 @@ static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
>  struct omap_dss_device *
>  omapdss_of_find_source_for_first_ep(struct device_node *node);
>  
> -void omapdss_set_is_initialized(bool set);
> -
>  struct device_node *dss_of_port_get_parent_device(struct device_node *port);
>  u32 dss_of_port_get_port_number(struct device_node *port);
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> index b341ebc136fe..dfbf361ac1e4 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> @@ -1042,7 +1042,7 @@ static const struct of_device_id dmm_of_match[] = {
>  };
>  #endif
>  
> -struct platform_driver omap_dmm_driver = {
> +static struct platform_driver omap_dmm_driver = {
>  	.probe = omap_dmm_probe,
>  	.remove = omap_dmm_remove,
>  	.driver = {
> @@ -1053,6 +1053,16 @@ struct platform_driver omap_dmm_driver = {
>  	},
>  };
>  
> +int __init dmm_init_platform_driver(void)
> +{
> +	return platform_driver_register(&omap_dmm_driver);
> +}
> +
> +void dmm_uninit_platform_driver(void)
> +{
> +	platform_driver_unregister(&omap_dmm_driver);
> +}
> +
>  MODULE_LICENSE("GPL v2");
>  MODULE_AUTHOR("Andy Gross <andy.gross@ti.com>");
>  MODULE_DESCRIPTION("OMAP DMM/Tiler Driver");
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> index 09816adfd422..842254d65548 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> @@ -109,7 +109,8 @@ void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
>  u32 tiler_get_cpu_cache_flags(void);
>  bool dmm_is_available(void);
>  
> -extern struct platform_driver omap_dmm_driver;
> +int dmm_init_platform_driver(void) __init;
> +void dmm_uninit_platform_driver(void);
>  
>  /* GEM bo flags -> tiler fmt */
>  static inline enum tiler_fmt gem2fmt(u32 flags)
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index cbca70f80d8e..baf8e32b899b 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -542,7 +542,7 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
>  	{ /* sentinel */ }
>  };
>  
> -static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
> +int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  {
>  	const struct soc_device_attribute *soc;
>  	struct drm_device *ddev;
> @@ -630,7 +630,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	return ret;
>  }
>  
> -static void omapdrm_cleanup(struct omap_drm_private *priv)
> +void omapdrm_cleanup(struct omap_drm_private *priv)
>  {
>  	struct drm_device *ddev = priv->ddev;
>  
> @@ -659,44 +659,6 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
>  	omap_crtc_pre_uninit();
>  }
>  
> -static int pdev_probe(struct platform_device *pdev)
> -{
> -	struct omap_drm_private *priv;
> -	int ret;
> -
> -	if (omapdss_is_initialized() == false)
> -		return -EPROBE_DEFER;
> -
> -	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> -		return ret;
> -	}
> -
> -	/* Allocate and initialize the driver private structure. */
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -
> -	platform_set_drvdata(pdev, priv);
> -
> -	ret = omapdrm_init(priv, &pdev->dev);
> -	if (ret < 0)
> -		kfree(priv);
> -
> -	return ret;
> -}
> -
> -static int pdev_remove(struct platform_device *pdev)
> -{
> -	struct omap_drm_private *priv = platform_get_drvdata(pdev);
> -
> -	omapdrm_cleanup(priv);
> -	kfree(priv);
> -
> -	return 0;
> -}
> -
>  #ifdef CONFIG_PM_SLEEP
>  static int omap_drm_suspend_all_displays(void)
>  {
> @@ -734,9 +696,8 @@ static int omap_drm_resume_all_displays(void)
>  	return 0;
>  }
>  
> -static int omap_drm_suspend(struct device *dev)
> +int omap_drm_suspend(struct omap_drm_private *priv)
>  {
> -	struct omap_drm_private *priv = dev_get_drvdata(dev);
>  	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_kms_helper_poll_disable(drm_dev);
> @@ -748,9 +709,8 @@ static int omap_drm_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int omap_drm_resume(struct device *dev)
> +int omap_drm_resume(struct omap_drm_private *priv)
>  {
> -	struct omap_drm_private *priv = dev_get_drvdata(dev);
>  	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_modeset_lock_all(drm_dev);
> @@ -763,40 +723,6 @@ static int omap_drm_resume(struct device *dev)
>  }
>  #endif
>  
> -static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
> -
> -static struct platform_driver pdev = {
> -	.driver = {
> -		.name = "omapdrm",
> -		.pm = &omapdrm_pm_ops,
> -	},
> -	.probe = pdev_probe,
> -	.remove = pdev_remove,
> -};
> -
> -static struct platform_driver * const drivers[] = {
> -	&omap_dmm_driver,
> -	&pdev,
> -};
> -
> -static int __init omap_drm_init(void)
> -{
> -	DBG("init");
> -
> -	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
> -}
> -
> -static void __exit omap_drm_fini(void)
> -{
> -	DBG("fini");
> -
> -	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
> -}
> -
> -/* need late_initcall() so we load after dss_driver's are loaded */
> -late_initcall(omap_drm_init);
> -module_exit(omap_drm_fini);
> -
>  MODULE_AUTHOR("Rob Clark <rob@ti.com>");
>  MODULE_DESCRIPTION("OMAP DRM Display Driver");
>  MODULE_ALIAS("platform:" DRIVER_NAME);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 2c06533a2d0a..e10b9105379a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -88,6 +88,10 @@ struct omap_drm_private {
>  	u32 irq_mask;			/* enabled irqs in addition to wait_list */
>  };
>  
> +int omapdrm_init(struct omap_drm_private *priv, struct device *dev);
> +void omapdrm_cleanup(struct omap_drm_private *priv);
> +int omap_drm_suspend(struct omap_drm_private *priv);
> +int omap_drm_resume(struct omap_drm_private *priv);
>  
>  int omap_debugfs_init(struct drm_minor *minor);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers
  2017-10-13 14:59 ` [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
@ 2017-10-15 21:10   ` Sebastian Reichel
  2017-10-16  9:11     ` Laurent Pinchart
  0 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-15 21:10 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 18634 bytes --]

Hi Laurent,

On Fri, Oct 13, 2017 at 05:59:17PM +0300, Laurent Pinchart wrote:
> To simplify implementation of debugfs seq_file show handlers, the driver
> passes the pointer to the show function through the debugfs_create_file
> data pointer. This prevents using the pointer to pass driver private
> data to the show handler, and requires all handlers to use global
> variables to access private data.
> 
> To prepare for the removal of global private data in the driver, rework
> the debugfs infrastructure to allow passing a private data pointer to
> show handlers.
> 
> The price to pay is explicit removal of debugfs files to free the
> internally allocated memory. This is desirable anyway as debugfs entries
> should be removed when a component driver is unbound, otherwise crashes
> will occur due to access to freed memory when the components will be
> dynamically allocated instead of stored in global variables.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

(One nit-pick in dss.h, see below)

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c | 13 ++++--
>  drivers/gpu/drm/omapdrm/dss/dsi.c   | 40 +++++++++++-----
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 92 +++++++++++++++++++++++++------------
>  drivers/gpu/drm/omapdrm/dss/dss.h   | 27 +++++++----
>  drivers/gpu/drm/omapdrm/dss/hdmi.h  |  2 +
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  9 ++--
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  9 ++--
>  drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++--
>  8 files changed, 140 insertions(+), 63 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index f0ae6be36a4e..1afd2802e807 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -168,6 +168,8 @@ static struct {
>  	struct platform_device *pdev;
>  	void __iomem    *base;
>  
> +	struct dss_debugfs_entry *debugfs;
> +
>  	int irq;
>  	irq_handler_t user_handler;
>  	void *user_data;
> @@ -3269,7 +3271,7 @@ void dispc_dump_clocks(struct seq_file *s)
>  	dispc_runtime_put();
>  }
>  
> -static void dispc_dump_regs(struct seq_file *s)
> +static int dispc_dump_regs(struct seq_file *s, void *p)
>  {
>  	int i, j;
>  	const char *mgr_names[] = {
> @@ -3290,7 +3292,7 @@ static void dispc_dump_regs(struct seq_file *s)
>  #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
>  
>  	if (dispc_runtime_get())
> -		return;
> +		return 0;
>  
>  	/* DISPC common registers */
>  	DUMPREG(DISPC_REVISION);
> @@ -3462,6 +3464,8 @@ static void dispc_dump_regs(struct seq_file *s)
>  
>  #undef DISPC_REG
>  #undef DUMPREG
> +
> +	return 0;
>  }
>  
>  /* calculate clock rates using dividers in cinfo */
> @@ -4606,7 +4610,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  
>  	dispc_set_ops(&dispc_ops);
>  
> -	dss_debugfs_create_file("dispc", dispc_dump_regs);
> +	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
> +						&dispc);
>  
>  	return 0;
>  
> @@ -4618,6 +4623,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  static void dispc_unbind(struct device *dev, struct device *master,
>  			       void *data)
>  {
> +	dss_debugfs_remove_file(dispc.debugfs);
> +
>  	dispc_set_ops(NULL);
>  
>  	pm_runtime_disable(dev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 6a1569149453..a64e6a39ebf1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -402,6 +402,10 @@ struct dsi_data {
>  #endif
>  	int debug_read;
>  	int debug_write;
> +	struct {
> +		struct dss_debugfs_entry *irqs;
> +		struct dss_debugfs_entry *regs;
> +	} debugfs;
>  
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
>  	spinlock_t irq_stats_lock;
> @@ -1659,18 +1663,20 @@ static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
>  #undef PIS
>  }
>  
> -static void dsi1_dump_irqs(struct seq_file *s)
> +static int dsi1_dump_irqs(struct seq_file *s, void *p)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
>  
>  	dsi_dump_dsidev_irqs(dsidev, s);
> +	return 0;
>  }
>  
> -static void dsi2_dump_irqs(struct seq_file *s)
> +static int dsi2_dump_irqs(struct seq_file *s, void *p)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
>  
>  	dsi_dump_dsidev_irqs(dsidev, s);
> +	return 0;
>  }
>  #endif
>  
> @@ -1758,18 +1764,20 @@ static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
>  #undef DUMPREG
>  }
>  
> -static void dsi1_dump_regs(struct seq_file *s)
> +static int dsi1_dump_regs(struct seq_file *s, void *p)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
>  
>  	dsi_dump_dsidev_regs(dsidev, s);
> +	return 0;
>  }
>  
> -static void dsi2_dump_regs(struct seq_file *s)
> +static int dsi2_dump_regs(struct seq_file *s, void *p)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
>  
>  	dsi_dump_dsidev_regs(dsidev, s);
> +	return 0;
>  }
>  
>  enum dsi_cio_power_state {
> @@ -5567,15 +5575,22 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	dsi_runtime_put(dsidev);
>  
>  	if (dsi->module_id == 0)
> -		dss_debugfs_create_file("dsi1_regs", dsi1_dump_regs);
> -	else if (dsi->module_id == 1)
> -		dss_debugfs_create_file("dsi2_regs", dsi2_dump_regs);
> -
> +		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
> +							    dsi1_dump_regs,
> +							    &dsi);
> +	else
> +		dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
> +							    dsi2_dump_regs,
> +							    &dsi);
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
>  	if (dsi->module_id == 0)
> -		dss_debugfs_create_file("dsi1_irqs", dsi1_dump_irqs);
> -	else if (dsi->module_id == 1)
> -		dss_debugfs_create_file("dsi2_irqs", dsi2_dump_irqs);
> +		dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
> +							    dsi1_dump_irqs,
> +							    &dsi);
> +	else
> +		dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
> +							    dsi2_dump_irqs,
> +							    &dsi);
>  #endif
>  
>  	return 0;
> @@ -5594,6 +5609,9 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
>  	struct platform_device *dsidev = to_platform_device(dev);
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> +	dss_debugfs_remove_file(dsi->debugfs.irqs);
> +	dss_debugfs_remove_file(dsi->debugfs.regs);
> +
>  	of_platform_depopulate(&dsidev->dev);
>  
>  	WARN_ON(dsi->scp_clk_refcount > 0);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 5721f3d64bdd..b45641f6a844 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -118,6 +118,11 @@ static struct {
>  
>  	const struct dss_features *feat;
>  
> +	struct {
> +		struct dss_debugfs_entry *clk;
> +		struct dss_debugfs_entry *dss;
> +	} debugfs;
> +
>  	struct dss_pll	*video1_pll;
>  	struct dss_pll	*video2_pll;
>  } dss;
> @@ -393,12 +398,12 @@ static void dss_dump_clocks(struct seq_file *s)
>  }
>  #endif
>  
> -static void dss_dump_regs(struct seq_file *s)
> +static int dss_dump_regs(struct seq_file *s, void *p)
>  {
>  #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
>  
>  	if (dss_runtime_get())
> -		return;
> +		return 0;
>  
>  	DUMPREG(DSS_REVISION);
>  	DUMPREG(DSS_SYSCONFIG);
> @@ -413,6 +418,7 @@ static void dss_dump_regs(struct seq_file *s)
>  
>  	dss_runtime_put();
>  #undef DUMPREG
> +	return 0;
>  }
>  
>  static int dss_get_channel_index(enum omap_channel channel)
> @@ -906,35 +912,16 @@ void dss_runtime_put(void)
>  
>  /* DEBUGFS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
> -static void dss_debug_dump_clocks(struct seq_file *s)
> +static int dss_debug_dump_clocks(struct seq_file *s, void *p)
>  {
>  	dss_dump_clocks(s);
>  	dispc_dump_clocks(s);
>  #ifdef CONFIG_OMAP2_DSS_DSI
>  	dsi_dump_clocks(s);
>  #endif
> -}
> -
> -static int dss_debug_show(struct seq_file *s, void *unused)
> -{
> -	void (*func)(struct seq_file *) = s->private;
> -
> -	func(s);
>  	return 0;
>  }
>  
> -static int dss_debug_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, dss_debug_show, inode->i_private);
> -}
> -
> -static const struct file_operations dss_debug_fops = {
> -	.open           = dss_debug_open,
> -	.read           = seq_read,
> -	.llseek         = seq_lseek,
> -	.release        = single_release,
> -};
> -
>  static struct dentry *dss_debugfs_dir;
>  
>  static int dss_initialize_debugfs(void)
> @@ -947,9 +934,6 @@ static int dss_initialize_debugfs(void)
>  		return err;
>  	}
>  
> -	debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
> -			&dss_debug_dump_clocks, &dss_debug_fops);
> -
>  	return 0;
>  }
>  
> @@ -959,15 +943,59 @@ static void dss_uninitialize_debugfs(void)
>  		debugfs_remove_recursive(dss_debugfs_dir);
>  }
>  
> -int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
> +struct dss_debugfs_entry {
> +	struct dentry *dentry;
> +	int (*show_fn)(struct seq_file *s, void *data);
> +	void *data;
> +};
> +
> +static int dss_debug_open(struct inode *inode, struct file *file)
>  {
> +	struct dss_debugfs_entry *entry = inode->i_private;
> +
> +	return single_open(file, entry->show_fn, entry->data);
> +}
> +
> +static const struct file_operations dss_debug_fops = {
> +	.open		= dss_debug_open,
> +	.read		= seq_read,
> +	.llseek		= seq_lseek,
> +	.release	= single_release,
> +};
> +
> +struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
> +		int (*show_fn)(struct seq_file *s, void *data), void *data)
> +{
> +	struct dss_debugfs_entry *entry;
>  	struct dentry *d;
>  
> -	d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
> -			write, &dss_debug_fops);
> +	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
> +	if (!entry)
> +		return ERR_PTR(-ENOMEM);
> +
> +	entry->show_fn = show_fn;
> +	entry->data = data;
>  
> -	return PTR_ERR_OR_ZERO(d);
> +	d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
> +				&dss_debug_fops);
> +	if (IS_ERR(d)) {
> +		kfree(entry);
> +		return ERR_PTR(PTR_ERR(d));
> +	}
> +
> +	entry->dentry = d;
> +	return entry;
> +}
> +
> +void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
> +{
> +	if (IS_ERR_OR_NULL(entry))
> +		return;
> +
> +	debugfs_remove(entry->dentry);
> +	kfree(entry);
>  }
> +
>  #else /* CONFIG_OMAP2_DSS_DEBUGFS */
>  static inline int dss_initialize_debugfs(void)
>  {
> @@ -1364,7 +1392,9 @@ static int dss_bind(struct device *dev)
>  	if (r)
>  		goto err_component;
>  
> -	dss_debugfs_create_file("dss", dss_dump_regs);
> +	dss.debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
> +						  &dss);
> +	dss.debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, &dss);
>  
>  	pm_set_vt_switch(0);
>  
> @@ -1377,6 +1407,8 @@ static int dss_bind(struct device *dev)
>  	return 0;
>  
>  err_drm_init:
> +	dss_debugfs_remove_file(dss.debugfs.clk);
> +	dss_debugfs_remove_file(dss.debugfs.dss);
>  	component_unbind_all(&pdev->dev, NULL);
>  err_component:
>  err_runtime_get:
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index db529481b364..e688e937da28 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -27,6 +27,11 @@
>  
>  #include "omapdss.h"
>  
> +struct dentry;

You can drop this one. It is not used in dss.h.

> +struct dss_debugfs_entry;
> +struct platform_device;
> +struct seq_file;
> +
>  #define MAX_DSS_LCD_MANAGERS	3
>  #define MAX_NUM_DSI		2
>  
> @@ -234,9 +239,6 @@ struct dss_lcd_mgr_config {
>  	int lcden_sig_polarity;
>  };
>  
> -struct seq_file;
> -struct platform_device;
> -
>  /* core */
>  static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
>  {
> @@ -255,12 +257,20 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
>  
>  /* DSS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
> -int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
> +struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
> +		int (*show_fn)(struct seq_file *s, void *data), void *data);
> +void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
>  #else
> -static inline int dss_debugfs_create_file(const char *name,
> -					  void (*write)(struct seq_file *))
> +static inline struct dss_debugfs_entry *
> +dss_debugfs_create_file(const char *name,
> +			int (*show_fn)(struct seq_file *s, void *data),
> +			void *data)
> +{
> +	return NULL;
> +}
> +
> +static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
>  {
> -	return 0;
>  }
>  #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
>  
> @@ -325,9 +335,6 @@ static inline void sdi_uninit_port(struct device_node *port)
>  
>  #ifdef CONFIG_OMAP2_DSS_DSI
>  
> -struct dentry;
> -struct file_operations;
> -
>  int dsi_init_platform_driver(void) __init;
>  void dsi_uninit_platform_driver(void);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index c2609c448ddc..a66f8ff06c24 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -358,6 +358,8 @@ struct omap_hdmi {
>  	struct mutex lock;
>  	struct platform_device *pdev;
>  
> +	struct dss_debugfs_entry *debugfs;
> +
>  	struct hdmi_wp_data	wp;
>  	struct hdmi_pll_data	pll;
>  	struct hdmi_phy_data	phy;
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 21ca7bd13fdc..ada4e3a9dba7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -302,13 +302,13 @@ static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
>  	*vm = hdmi.cfg.vm;
>  }
>  
> -static void hdmi_dump_regs(struct seq_file *s)
> +static int hdmi_dump_regs(struct seq_file *s, void *p)
>  {
>  	mutex_lock(&hdmi.lock);
>  
>  	if (hdmi_runtime_get()) {
>  		mutex_unlock(&hdmi.lock);
> -		return;
> +		return 0;
>  	}
>  
>  	hdmi_wp_dump(&hdmi.wp, s);
> @@ -318,6 +318,7 @@ static void hdmi_dump_regs(struct seq_file *s)
>  
>  	hdmi_runtime_put();
>  	mutex_unlock(&hdmi.lock);
> +	return 0;
>  }
>  
>  static int read_edid(u8 *buf, int len)
> @@ -776,7 +777,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  		return r;
>  	}
>  
> -	dss_debugfs_create_file("hdmi", hdmi_dump_regs);
> +	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
>  
>  	return 0;
>  err:
> @@ -788,6 +789,8 @@ static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  
> +	dss_debugfs_remove_file(hdmi.debugfs);
> +
>  	if (hdmi.audio_pdev)
>  		platform_device_unregister(hdmi.audio_pdev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index f6c60a6e54ae..00ea975b75f9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -299,13 +299,13 @@ static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
>  	*vm = hdmi.cfg.vm;
>  }
>  
> -static void hdmi_dump_regs(struct seq_file *s)
> +static int hdmi_dump_regs(struct seq_file *s, void *p)
>  {
>  	mutex_lock(&hdmi.lock);
>  
>  	if (hdmi_runtime_get()) {
>  		mutex_unlock(&hdmi.lock);
> -		return;
> +		return 0;
>  	}
>  
>  	hdmi_wp_dump(&hdmi.wp, s);
> @@ -315,6 +315,7 @@ static void hdmi_dump_regs(struct seq_file *s)
>  
>  	hdmi_runtime_put();
>  	mutex_unlock(&hdmi.lock);
> +	return 0;
>  }
>  
>  static int read_edid(u8 *buf, int len)
> @@ -774,7 +775,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  		return r;
>  	}
>  
> -	dss_debugfs_create_file("hdmi", hdmi_dump_regs);
> +	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
>  
>  	return 0;
>  err:
> @@ -786,6 +787,8 @@ static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  
> +	dss_debugfs_remove_file(hdmi.debugfs);
> +
>  	if (hdmi.audio_pdev)
>  		platform_device_unregister(hdmi.audio_pdev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 1b0fa952b494..68035c1acf1f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -328,6 +328,8 @@ static struct {
>  	u32 wss_data;
>  	struct regulator *vdda_dac_reg;
>  
> +	struct dss_debugfs_entry *debugfs;
> +
>  	struct clk	*tv_dac_clk;
>  
>  	struct videomode vm;
> @@ -671,12 +673,12 @@ static int venc_init_regulator(void)
>  	return 0;
>  }
>  
> -static void venc_dump_regs(struct seq_file *s)
> +static int venc_dump_regs(struct seq_file *s, void *p)
>  {
>  #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
>  
>  	if (venc_runtime_get())
> -		return;
> +		return 0;
>  
>  	DUMPREG(VENC_F_CONTROL);
>  	DUMPREG(VENC_VIDOUT_CTRL);
> @@ -723,6 +725,7 @@ static void venc_dump_regs(struct seq_file *s)
>  	venc_runtime_put();
>  
>  #undef DUMPREG
> +	return 0;
>  }
>  
>  static int venc_get_clocks(struct platform_device *pdev)
> @@ -913,7 +916,7 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
>  		goto err_probe_of;
>  	}
>  
> -	dss_debugfs_create_file("venc", venc_dump_regs);
> +	venc.debugfs = dss_debugfs_create_file("venc", venc_dump_regs, &venc);
>  
>  	venc_init_output(pdev);
>  
> @@ -929,6 +932,8 @@ static void venc_unbind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  
> +	dss_debugfs_remove_file(venc.debugfs);
> +
>  	venc_uninit_output(pdev);
>  
>  	pm_runtime_disable(&pdev->dev);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions
  2017-10-13 14:59 ` [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
@ 2017-10-16  8:39   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  8:39 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 14383 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:18PM +0300, Laurent Pinchart wrote:
> To prepare for the removal of the global variable storing DSS private
> data, pass its pointer to the dss_runtime_{get,put}() functions.
> 
> As this requires getting hold of the DSS private structure in the
> callers, we expose the structure through an opaque pointer that can be
> retrieved through a new dss_device_get() function. The function
> currently returns a pointer to the global data structure, and will later
> be updated to get the pointer from device driver data when the DSS
> private structure will be allocated dynamically.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c       |  7 +++++--
>  drivers/gpu/drm/omapdrm/dss/dss.c       | 37 ++++++++++++++++++++-------------
>  drivers/gpu/drm/omapdrm/dss/dss.h       | 13 ++++++++----
>  drivers/gpu/drm/omapdrm/dss/hdmi.h      |  6 ++++--
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c     |  3 ++-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c     |  3 ++-
>  drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  | 10 +++++----
>  drivers/gpu/drm/omapdrm/dss/video-pll.c | 12 ++++++-----
>  8 files changed, 58 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index a64e6a39ebf1..1dab308c9bc1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5333,7 +5333,8 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
>  	.has_refsel = true,
>  };
>  
> -static int dsi_init_pll_data(struct platform_device *dsidev)
> +static int dsi_init_pll_data(struct dss_device *dss,
> +			     struct platform_device *dsidev)
>  {
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct dss_pll *pll = &dsi->pll;
> @@ -5352,6 +5353,7 @@ static int dsi_init_pll_data(struct platform_device *dsidev)
>  	pll->base = dsi->pll_base;
>  	pll->hw = dsi->data->pll_hw;
>  	pll->ops = &dsi_pll_ops;
> +	pll->dss = dss;
>  
>  	r = dss_pll_register(pll);
>  	if (r)
> @@ -5428,6 +5430,7 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
>  static int dsi_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *dsidev = to_platform_device(dev);
> +	struct dss_device *dss = dss_get_device(master);
>  	const struct soc_device_attribute *soc;
>  	const struct dsi_module_id_data *d;
>  	u32 rev;
> @@ -5538,7 +5541,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	if (r)
>  		return r;
>  
> -	dsi_init_pll_data(dsidev);
> +	dsi_init_pll_data(dss, dsidev);
>  
>  	pm_runtime_enable(&dsidev->dev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index b45641f6a844..a83277ebe1ef 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -93,7 +93,7 @@ struct dss_features {
>  	bool has_lcd_clk_src;
>  };
>  
> -static struct {
> +struct dss_device {
>  	struct platform_device *pdev;
>  	struct omap_drm_private drm;
>  
> @@ -125,7 +125,9 @@ static struct {
>  
>  	struct dss_pll	*video1_pll;
>  	struct dss_pll	*video2_pll;
> -} dss;
> +};
> +
> +static struct dss_device dss;
>  
>  static const char * const dss_generic_clk_source_names[] = {
>  	[DSS_CLK_SRC_FCK]	= "FCK",
> @@ -382,7 +384,7 @@ static void dss_dump_clocks(struct seq_file *s)
>  	const char *fclk_name;
>  	unsigned long fclk_rate;
>  
> -	if (dss_runtime_get())
> +	if (dss_runtime_get(&dss))
>  		return;
>  
>  	seq_printf(s, "- DSS -\n");
> @@ -394,7 +396,7 @@ static void dss_dump_clocks(struct seq_file *s)
>  			fclk_name,
>  			fclk_rate);
>  
> -	dss_runtime_put();
> +	dss_runtime_put(&dss);
>  }
>  #endif
>  
> @@ -402,7 +404,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
>  {
>  #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
>  
> -	if (dss_runtime_get())
> +	if (dss_runtime_get(&dss))
>  		return 0;
>  
>  	DUMPREG(DSS_REVISION);
> @@ -416,7 +418,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
>  		DUMPREG(DSS_SDI_STATUS);
>  	}
>  
> -	dss_runtime_put();
> +	dss_runtime_put(&dss);
>  #undef DUMPREG
>  	return 0;
>  }
> @@ -889,27 +891,32 @@ static void dss_put_clocks(void)
>  		clk_put(dss.parent_clk);
>  }
>  
> -int dss_runtime_get(void)
> +int dss_runtime_get(struct dss_device *dss)
>  {
>  	int r;
>  
>  	DSSDBG("dss_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&dss.pdev->dev);
> +	r = pm_runtime_get_sync(&dss->pdev->dev);
>  	WARN_ON(r < 0);
>  	return r < 0 ? r : 0;
>  }
>  
> -void dss_runtime_put(void)
> +void dss_runtime_put(struct dss_device *dss)
>  {
>  	int r;
>  
>  	DSSDBG("dss_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&dss.pdev->dev);
> +	r = pm_runtime_put_sync(&dss->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS && r != -EBUSY);
>  }
>  
> +struct dss_device *dss_get_device(struct device *dev)
> +{
> +	return &dss;
> +}
> +
>  /* DEBUGFS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
>  static int dss_debug_dump_clocks(struct seq_file *s, void *p)
> @@ -1297,13 +1304,15 @@ static int dss_video_pll_probe(struct platform_device *pdev)
>  	}
>  
>  	if (of_property_match_string(np, "reg-names", "pll1") >= 0) {
> -		dss.video1_pll = dss_video_pll_init(pdev, 0, pll_regulator);
> +		dss.video1_pll = dss_video_pll_init(&dss, pdev, 0,
> +						    pll_regulator);
>  		if (IS_ERR(dss.video1_pll))
>  			return PTR_ERR(dss.video1_pll);
>  	}
>  
>  	if (of_property_match_string(np, "reg-names", "pll2") >= 0) {
> -		dss.video2_pll = dss_video_pll_init(pdev, 1, pll_regulator);
> +		dss.video2_pll = dss_video_pll_init(&dss, pdev, 1,
> +						    pll_regulator);
>  		if (IS_ERR(dss.video2_pll)) {
>  			dss_video_pll_uninit(dss.video1_pll);
>  			return PTR_ERR(dss.video2_pll);
> @@ -1361,7 +1370,7 @@ static int dss_bind(struct device *dev)
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	r = dss_runtime_get();
> +	r = dss_runtime_get(&dss);
>  	if (r)
>  		goto err_runtime_get;
>  
> @@ -1386,7 +1395,7 @@ static int dss_bind(struct device *dev)
>  	rev = dss_read_reg(DSS_REVISION);
>  	pr_info("OMAP DSS rev %d.%d\n", FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
> -	dss_runtime_put();
> +	dss_runtime_put(&dss);
>  
>  	r = component_bind_all(&pdev->dev, NULL);
>  	if (r)
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index e688e937da28..009b7ef200cd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -29,6 +29,7 @@
>  
>  struct dentry;
>  struct dss_debugfs_entry;
> +struct dss_device;
>  struct platform_device;
>  struct seq_file;
>  
> @@ -198,6 +199,7 @@ struct dss_pll_hw {
>  struct dss_pll {
>  	const char *name;
>  	enum dss_pll_id id;
> +	struct dss_device *dss;
>  
>  	struct clk *clkin;
>  	struct regulator *regulator;
> @@ -277,8 +279,10 @@ static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
>  int dss_init_platform_driver(void) __init;
>  void dss_uninit_platform_driver(void);
>  
> -int dss_runtime_get(void);
> -void dss_runtime_put(void);
> +struct dss_device *dss_get_device(struct device *dev);
> +
> +int dss_runtime_get(struct dss_device *dss);
> +void dss_runtime_put(struct dss_device *dss);
>  
>  unsigned long dss_get_dispc_clk_rate(void);
>  unsigned long dss_get_max_fck_rate(void);
> @@ -289,8 +293,9 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
>  const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
>  
>  /* DSS VIDEO PLL */
> -struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
> -	struct regulator *regulator);
> +struct dss_pll *dss_video_pll_init(struct dss_device *dss,
> +				   struct platform_device *pdev, int id,
> +				   struct regulator *regulator);
>  void dss_video_pll_uninit(struct dss_pll *pll);
>  
>  void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index a66f8ff06c24..4dbc4f3d728c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -29,6 +29,8 @@
>  #include "omapdss.h"
>  #include "dss.h"
>  
> +struct dss_device;
> +
>  /* HDMI Wrapper */
>  
>  #define HDMI_WP_REVISION			0x0
> @@ -324,8 +326,8 @@ phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp_data *wp);
>  
>  /* HDMI PLL funcs */
>  void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s);
> -int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
> -	struct hdmi_wp_data *wp);
> +int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev,
> +		  struct hdmi_pll_data *pll, struct hdmi_wp_data *wp);
>  void hdmi_pll_uninit(struct hdmi_pll_data *hpll);
>  
>  /* HDMI PHY funcs */
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index ada4e3a9dba7..d84eba8440c8 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -717,6 +717,7 @@ static int hdmi_audio_register(struct device *dev)
>  static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> +	struct dss_device *dss = dss_get_device(master);
>  	int r;
>  	int irq;
>  
> @@ -734,7 +735,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  	if (r)
>  		return r;
>  
> -	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
> +	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 00ea975b75f9..64cfed89c79b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -719,6 +719,7 @@ static int hdmi_audio_register(struct device *dev)
>  static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> +	struct dss_device *dss = dss_get_device(master);
>  	int r;
>  	int irq;
>  
> @@ -736,7 +737,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  	if (r)
>  		return r;
>  
> -	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
> +	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> index 55bee81f4dd5..9915354b66c9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> @@ -128,7 +128,8 @@ static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = {
>  	.has_refsel = true,
>  };
>  
> -static int hdmi_init_pll_data(struct platform_device *pdev,
> +static int hdmi_init_pll_data(struct dss_device *dss,
> +			      struct platform_device *pdev,
>  			      struct hdmi_pll_data *hpll)
>  {
>  	struct dss_pll *pll = &hpll->pll;
> @@ -145,6 +146,7 @@ static int hdmi_init_pll_data(struct platform_device *pdev,
>  	pll->id = DSS_PLL_HDMI;
>  	pll->base = hpll->base;
>  	pll->clkin = clk;
> +	pll->dss = dss;
>  
>  	if (hpll->wp->version == 4)
>  		pll->hw = &dss_omap4_hdmi_pll_hw;
> @@ -160,8 +162,8 @@ static int hdmi_init_pll_data(struct platform_device *pdev,
>  	return 0;
>  }
>  
> -int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
> -	struct hdmi_wp_data *wp)
> +int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev,
> +		  struct hdmi_pll_data *pll, struct hdmi_wp_data *wp)
>  {
>  	int r;
>  	struct resource *res;
> @@ -174,7 +176,7 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
>  	if (IS_ERR(pll->base))
>  		return PTR_ERR(pll->base);
>  
> -	r = hdmi_init_pll_data(pdev, pll);
> +	r = hdmi_init_pll_data(dss, pdev, pll);
>  	if (r) {
>  		DSSERR("failed to init HDMI PLL\n");
>  		return r;
> diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> index 38a239cc5e04..7ef30f61c52b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> @@ -62,7 +62,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
>  	struct dss_video_pll *vpll = container_of(pll, struct dss_video_pll, pll);
>  	int r;
>  
> -	r = dss_runtime_get();
> +	r = dss_runtime_get(pll->dss);
>  	if (r)
>  		return r;
>  
> @@ -81,7 +81,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
>  err_reset:
>  	dss_dpll_disable_scp_clk(vpll);
>  	dss_ctrl_pll_enable(pll->id, false);
> -	dss_runtime_put();
> +	dss_runtime_put(pll->dss);
>  
>  	return r;
>  }
> @@ -96,7 +96,7 @@ static void dss_video_pll_disable(struct dss_pll *pll)
>  
>  	dss_ctrl_pll_enable(pll->id, false);
>  
> -	dss_runtime_put();
> +	dss_runtime_put(pll->dss);
>  }
>  
>  static const struct dss_pll_ops dss_pll_ops = {
> @@ -134,8 +134,9 @@ static const struct dss_pll_hw dss_dra7_video_pll_hw = {
>  	.errata_i886 = true,
>  };
>  
> -struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
> -	struct regulator *regulator)
> +struct dss_pll *dss_video_pll_init(struct dss_device *dss,
> +				   struct platform_device *pdev, int id,
> +				   struct regulator *regulator)
>  {
>  	const char * const reg_name[] = { "pll1", "pll2" };
>  	const char * const clkctrl_name[] = { "pll1_clkctrl", "pll2_clkctrl" };
> @@ -187,6 +188,7 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
>  	pll->base = pll_base;
>  	pll->hw = &dss_dra7_video_pll_hw;
>  	pll->ops = &dss_pll_ops;
> +	pll->dss = dss;
>  
>  	r = dss_pll_register(pll);
>  	if (r)
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable()
  2017-10-13 14:59 ` [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
@ 2017-10-16  8:42   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  8:42 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4612 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:19PM +0300, Laurent Pinchart wrote:
> This will allow accessing the PLL data to get the DSS device pointer,
> removing the need to access the global DSS private data.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dss.c       | 13 +++++++------
>  drivers/gpu/drm/omapdrm/dss/dss.h       |  2 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  4 ++--
>  drivers/gpu/drm/omapdrm/dss/video-pll.c |  6 +++---
>  4 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index a83277ebe1ef..7179d02e7451 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -191,17 +191,17 @@ static void dss_restore_context(void)
>  #undef SR
>  #undef RR
>  
> -void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
> +void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
>  {
>  	unsigned int shift;
>  	unsigned int val;
>  
> -	if (!dss.syscon_pll_ctrl)
> +	if (!pll->dss->syscon_pll_ctrl)
>  		return;
>  
>  	val = !enable;
>  
> -	switch (pll_id) {
> +	switch (pll->id) {
>  	case DSS_PLL_VIDEO1:
>  		shift = 0;
>  		break;
> @@ -212,12 +212,13 @@ void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
>  		shift = 2;
>  		break;
>  	default:
> -		DSSERR("illegal DSS PLL ID %d\n", pll_id);
> +		DSSERR("illegal DSS PLL ID %d\n", pll->id);
>  		return;
>  	}
>  
> -	regmap_update_bits(dss.syscon_pll_ctrl, dss.syscon_pll_ctrl_offset,
> -		1 << shift, val << shift);
> +	regmap_update_bits(pll->dss->syscon_pll_ctrl,
> +			   pll->dss->syscon_pll_ctrl_offset,
> +			   1 << shift, val << shift);
>  }
>  
>  static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 009b7ef200cd..0b8facf258cf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -298,7 +298,7 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
>  				   struct regulator *regulator);
>  void dss_video_pll_uninit(struct dss_pll *pll);
>  
> -void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
> +void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
>  
>  void dss_sdi_init(int datapairs);
>  int dss_sdi_enable(void);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> index 9915354b66c9..4da32c261c30 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> @@ -48,7 +48,7 @@ static int hdmi_pll_enable(struct dss_pll *dsspll)
>  	r = pm_runtime_get_sync(&pll->pdev->dev);
>  	WARN_ON(r < 0);
>  
> -	dss_ctrl_pll_enable(DSS_PLL_HDMI, true);
> +	dss_ctrl_pll_enable(dsspll, true);
>  
>  	r = hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
>  	if (r)
> @@ -65,7 +65,7 @@ static void hdmi_pll_disable(struct dss_pll *dsspll)
>  
>  	hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_ALLOFF);
>  
> -	dss_ctrl_pll_enable(DSS_PLL_HDMI, false);
> +	dss_ctrl_pll_enable(dsspll, false);
>  
>  	r = pm_runtime_put_sync(&pll->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
> diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> index 7ef30f61c52b..989a5ee4433a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> @@ -66,7 +66,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
>  	if (r)
>  		return r;
>  
> -	dss_ctrl_pll_enable(pll->id, true);
> +	dss_ctrl_pll_enable(pll, true);
>  
>  	dss_dpll_enable_scp_clk(vpll);
>  
> @@ -80,7 +80,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
>  
>  err_reset:
>  	dss_dpll_disable_scp_clk(vpll);
> -	dss_ctrl_pll_enable(pll->id, false);
> +	dss_ctrl_pll_enable(pll, false);
>  	dss_runtime_put(pll->dss);
>  
>  	return r;
> @@ -94,7 +94,7 @@ static void dss_video_pll_disable(struct dss_pll *pll)
>  
>  	dss_dpll_disable_scp_clk(vpll);
>  
> -	dss_ctrl_pll_enable(pll->id, false);
> +	dss_ctrl_pll_enable(pll, false);
>  
>  	dss_runtime_put(pll->dss);
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions
  2017-10-13 14:59 ` [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
@ 2017-10-16  8:47   ` Sebastian Reichel
  2017-10-16  9:03     ` Sebastian Reichel
  0 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  8:47 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 5235 bytes --]

Hi Laurent,

On Fri, Oct 13, 2017 at 05:59:20PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dss.c |  8 ++++----
>  drivers/gpu/drm/omapdrm/dss/dss.h | 14 ++++++++------
>  drivers/gpu/drm/omapdrm/dss/sdi.c | 13 ++++++++-----
>  3 files changed, 20 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 7179d02e7451..f8b71e24a07d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -287,7 +287,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
>  	return 0;
>  }
>  
> -void dss_sdi_init(int datapairs)
> +void dss_sdi_init(struct dss_device *dss, int datapairs)
>  {
>  	u32 l;
>  
> @@ -306,7 +306,7 @@ void dss_sdi_init(int datapairs)
>  	dss_write_reg(DSS_PLL_CONTROL, l);
>  }
>  
> -int dss_sdi_enable(void)
> +int dss_sdi_enable(struct dss_device *dss)
>  {
>  	unsigned long timeout;
>  
> @@ -364,7 +364,7 @@ int dss_sdi_enable(void)
>  	return -ETIMEDOUT;
>  }
>  
> -void dss_sdi_disable(void)
> +void dss_sdi_disable(struct dss_device *dss)
>  {
>  	dispc_lcd_enable_signal(0);
>  
> @@ -1226,7 +1226,7 @@ static int dss_init_ports(struct platform_device *pdev)
>  			dpi_init_port(pdev, port, dss.feat->model);
>  			break;
>  		case OMAP_DISPLAY_TYPE_SDI:
> -			sdi_init_port(pdev, port);
> +			sdi_init_port(&dss, pdev, port);

I guess this should be 'dss' instead of '&dss'? Otherwise looks
fine.

-- Sebastian

>  			break;
>  		default:
>  			break;
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 0b8facf258cf..08651f101518 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -300,9 +300,9 @@ void dss_video_pll_uninit(struct dss_pll *pll);
>  
>  void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
>  
> -void dss_sdi_init(int datapairs);
> -int dss_sdi_enable(void);
> -void dss_sdi_disable(void);
> +void dss_sdi_init(struct dss_device *dss, int datapairs);
> +int dss_sdi_enable(struct dss_device *dss);
> +void dss_sdi_disable(struct dss_device *dss);
>  
>  void dss_select_dsi_clk_source(int dsi_module,
>  		enum dss_clk_source clk_src);
> @@ -323,11 +323,13 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
>  
>  /* SDI */
>  #ifdef CONFIG_OMAP2_DSS_SDI
> -int sdi_init_port(struct platform_device *pdev, struct device_node *port);
> +int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
> +		  struct device_node *port);
>  void sdi_uninit_port(struct device_node *port);
>  #else
> -static inline int sdi_init_port(struct platform_device *pdev,
> -		struct device_node *port)
> +static inline int sdi_init_port(struct dss_device *dss,
> +				struct platform_device *pdev,
> +				struct device_node *port)
>  {
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index d18ad58c5a19..39cb5c8af0dc 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -33,6 +33,7 @@
>  
>  static struct {
>  	struct platform_device *pdev;
> +	struct dss_device *dss;
>  
>  	bool update_enabled;
>  	struct regulator *vdds_sdi_reg;
> @@ -189,8 +190,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	 */
>  	dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
>  
> -	dss_sdi_init(sdi.datapairs);
> -	r = dss_sdi_enable();
> +	dss_sdi_init(sdi.dss, sdi.datapairs);
> +	r = dss_sdi_enable(sdi.dss);
>  	if (r)
>  		goto err_sdi_enable;
>  	mdelay(2);
> @@ -202,7 +203,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	return 0;
>  
>  err_mgr_enable:
> -	dss_sdi_disable();
> +	dss_sdi_disable(sdi.dss);
>  err_sdi_enable:
>  err_set_dss_clock_div:
>  err_calc_clock_div:
> @@ -219,7 +220,7 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
>  
>  	dss_mgr_disable(channel);
>  
> -	dss_sdi_disable();
> +	dss_sdi_disable(sdi.dss);
>  
>  	dispc_runtime_put();
>  
> @@ -347,7 +348,8 @@ static void sdi_uninit_output(struct platform_device *pdev)
>  	omapdss_unregister_output(out);
>  }
>  
> -int sdi_init_port(struct platform_device *pdev, struct device_node *port)
> +int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
> +		  struct device_node *port)
>  {
>  	struct device_node *ep;
>  	u32 datapairs;
> @@ -364,6 +366,7 @@ int sdi_init_port(struct platform_device *pdev, struct device_node *port)
>  	}
>  
>  	sdi.datapairs = datapairs;
> +	sdi.dss = dss;
>  
>  	of_node_put(ep);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions
  2017-10-16  8:47   ` Sebastian Reichel
@ 2017-10-16  9:03     ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:03 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 5938 bytes --]

Hi,

On Mon, Oct 16, 2017 at 10:47:32AM +0200, Sebastian Reichel wrote:
> Hi Laurent,
> 
> On Fri, Oct 13, 2017 at 05:59:20PM +0300, Laurent Pinchart wrote:
> > This removes the need to access the global DSS private data in those
> > functions (both for the current accesses and the future ones that will
> > be introduced when allocating the DSS device dynamically).
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/omapdrm/dss/dss.c |  8 ++++----
> >  drivers/gpu/drm/omapdrm/dss/dss.h | 14 ++++++++------
> >  drivers/gpu/drm/omapdrm/dss/sdi.c | 13 ++++++++-----
> >  3 files changed, 20 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> > index 7179d02e7451..f8b71e24a07d 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> > @@ -287,7 +287,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
> >  	return 0;
> >  }
> >  
> > -void dss_sdi_init(int datapairs)
> > +void dss_sdi_init(struct dss_device *dss, int datapairs)
> >  {
> >  	u32 l;
> >  
> > @@ -306,7 +306,7 @@ void dss_sdi_init(int datapairs)
> >  	dss_write_reg(DSS_PLL_CONTROL, l);
> >  }
> >  
> > -int dss_sdi_enable(void)
> > +int dss_sdi_enable(struct dss_device *dss)
> >  {
> >  	unsigned long timeout;
> >  
> > @@ -364,7 +364,7 @@ int dss_sdi_enable(void)
> >  	return -ETIMEDOUT;
> >  }
> >  
> > -void dss_sdi_disable(void)
> > +void dss_sdi_disable(struct dss_device *dss)
> >  {
> >  	dispc_lcd_enable_signal(0);
> >  
> > @@ -1226,7 +1226,7 @@ static int dss_init_ports(struct platform_device *pdev)
> >  			dpi_init_port(pdev, port, dss.feat->model);
> >  			break;
> >  		case OMAP_DISPLAY_TYPE_SDI:
> > -			sdi_init_port(pdev, port);
> > +			sdi_init_port(&dss, pdev, port);
> 
> I guess this should be 'dss' instead of '&dss'? Otherwise looks
> fine.

Oops, read to fast, this is correct.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> -- Sebastian
> 
> >  			break;
> >  		default:
> >  			break;
> > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> > index 0b8facf258cf..08651f101518 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> > +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> > @@ -300,9 +300,9 @@ void dss_video_pll_uninit(struct dss_pll *pll);
> >  
> >  void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
> >  
> > -void dss_sdi_init(int datapairs);
> > -int dss_sdi_enable(void);
> > -void dss_sdi_disable(void);
> > +void dss_sdi_init(struct dss_device *dss, int datapairs);
> > +int dss_sdi_enable(struct dss_device *dss);
> > +void dss_sdi_disable(struct dss_device *dss);
> >  
> >  void dss_select_dsi_clk_source(int dsi_module,
> >  		enum dss_clk_source clk_src);
> > @@ -323,11 +323,13 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
> >  
> >  /* SDI */
> >  #ifdef CONFIG_OMAP2_DSS_SDI
> > -int sdi_init_port(struct platform_device *pdev, struct device_node *port);
> > +int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
> > +		  struct device_node *port);
> >  void sdi_uninit_port(struct device_node *port);
> >  #else
> > -static inline int sdi_init_port(struct platform_device *pdev,
> > -		struct device_node *port)
> > +static inline int sdi_init_port(struct dss_device *dss,
> > +				struct platform_device *pdev,
> > +				struct device_node *port)
> >  {
> >  	return 0;
> >  }
> > diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> > index d18ad58c5a19..39cb5c8af0dc 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> > @@ -33,6 +33,7 @@
> >  
> >  static struct {
> >  	struct platform_device *pdev;
> > +	struct dss_device *dss;
> >  
> >  	bool update_enabled;
> >  	struct regulator *vdds_sdi_reg;
> > @@ -189,8 +190,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
> >  	 */
> >  	dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
> >  
> > -	dss_sdi_init(sdi.datapairs);
> > -	r = dss_sdi_enable();
> > +	dss_sdi_init(sdi.dss, sdi.datapairs);
> > +	r = dss_sdi_enable(sdi.dss);
> >  	if (r)
> >  		goto err_sdi_enable;
> >  	mdelay(2);
> > @@ -202,7 +203,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
> >  	return 0;
> >  
> >  err_mgr_enable:
> > -	dss_sdi_disable();
> > +	dss_sdi_disable(sdi.dss);
> >  err_sdi_enable:
> >  err_set_dss_clock_div:
> >  err_calc_clock_div:
> > @@ -219,7 +220,7 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
> >  
> >  	dss_mgr_disable(channel);
> >  
> > -	dss_sdi_disable();
> > +	dss_sdi_disable(sdi.dss);
> >  
> >  	dispc_runtime_put();
> >  
> > @@ -347,7 +348,8 @@ static void sdi_uninit_output(struct platform_device *pdev)
> >  	omapdss_unregister_output(out);
> >  }
> >  
> > -int sdi_init_port(struct platform_device *pdev, struct device_node *port)
> > +int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
> > +		  struct device_node *port)
> >  {
> >  	struct device_node *ep;
> >  	u32 datapairs;
> > @@ -364,6 +366,7 @@ int sdi_init_port(struct platform_device *pdev, struct device_node *port)
> >  	}
> >  
> >  	sdi.datapairs = datapairs;
> > +	sdi.dss = dss;
> >  
> >  	of_node_put(ep);
> >  
> > -- 
> > Regards,
> > 
> > Laurent Pinchart
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel



> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules
  2017-10-14 12:22   ` Sebastian Reichel
@ 2017-10-16  9:04     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-16  9:04 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Saturday, 14 October 2017 15:22:00 EEST Sebastian Reichel wrote:
> On Fri, Oct 13, 2017 at 05:59:00PM +0300, Laurent Pinchart wrote:
> > There's no need for the omapdss-base code to be part of a separate
> > module. Merge it with the omapdss module. This allows removing the
> > exports for internal symbols.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/dss/Kconfig   |  4 ----
> >  drivers/gpu/drm/omapdrm/dss/Makefile  | 19 +++++++++++++------
> >  drivers/gpu/drm/omapdrm/dss/base.c    |  7 -------
> >  drivers/gpu/drm/omapdrm/dss/display.c |  2 --
> >  drivers/gpu/drm/omapdrm/dss/dss-of.c  |  2 --
> >  drivers/gpu/drm/omapdrm/dss/output.c  | 14 --------------
> >  6 files changed, 13 insertions(+), 35 deletions(-)

[snip]

> > diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile
> > b/drivers/gpu/drm/omapdrm/dss/Makefile index 3c5644c3fc38..531b4d8075e5
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> > +++ b/drivers/gpu/drm/omapdrm/dss/Makefile
> > @@ -1,12 +1,19 @@
> >  obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
> > -
> > -obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
> > -omapdss-base-y := base.o display.o dss-of.o output.o
> > -
> >  obj-$(CONFIG_OMAP2_DSS) += omapdss.o
> > +
> >  # Core DSS files
> > -omapdss-y := core.o dss.o dispc.o dispc_coefs.o \
> > -	pll.o video-pll.o
> > +omapdss-y := \
> > +	base.o \
> > +	display.o \
> > +	dss-of.o \
> > +	output.o \
> > +	core.o \
> > +	dss.o \
> > +	dispc.o \
> > +	dispc_coefs.o \
> > +	pll.o \
> > +	video-pll.o
> > +
> 
> I guess it makes sense to sort this alphabetically, otherwise:

Good point. I'll do that in v2, and will also sort the entries below.

> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> 
> -- Sebastian
> 
> >  omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
> >  omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
> >  omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o

[snip]

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations
  2017-10-13 14:59 ` [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
@ 2017-10-16  9:05   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:05 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 17362 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:21PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c   | 12 ++++---
>  drivers/gpu/drm/omapdrm/dss/dsi.c   | 18 +++++-----
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 68 ++++++++++++++++++++++---------------
>  drivers/gpu/drm/omapdrm/dss/dss.h   | 25 ++++++++------
>  drivers/gpu/drm/omapdrm/dss/hdmi.h  |  1 +
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 +-
>  7 files changed, 77 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index c7346df60929..38a4c037783a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -40,6 +40,7 @@
>  struct dpi_data {
>  	struct platform_device *pdev;
>  	enum dss_model dss_model;
> +	struct dss_device *dss;
>  
>  	struct regulator *vdds_dsi_reg;
>  	enum dss_clk_source clk_src;
> @@ -304,7 +305,7 @@ static int dpi_set_pll_clk(struct dpi_data *dpi, enum omap_channel channel,
>  	if (r)
>  		return r;
>  
> -	dss_select_lcd_clk_source(channel, dpi->clk_src);
> +	dss_select_lcd_clk_source(dpi->dss, channel, dpi->clk_src);
>  
>  	dpi->mgr_config.clock_info = ctx.dispc_cinfo;
>  
> @@ -414,7 +415,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_get_dispc;
>  
> -	r = dss_dpi_select_source(out->port_num, channel);
> +	r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
>  	if (r)
>  		goto err_src_sel;
>  
> @@ -466,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
>  	dss_mgr_disable(channel);
>  
>  	if (dpi->pll) {
> -		dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> +		dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
>  		dss_pll_disable(dpi->pll);
>  	}
>  
> @@ -750,8 +751,8 @@ static void dpi_uninit_output_port(struct device_node *port)
>  	omapdss_unregister_output(out);
>  }
>  
> -int dpi_init_port(struct platform_device *pdev, struct device_node *port,
> -		  enum dss_model dss_model)
> +int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
> +		  struct device_node *port, enum dss_model dss_model)
>  {
>  	struct dpi_data *dpi;
>  	struct device_node *ep;
> @@ -778,6 +779,7 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port,
>  
>  	dpi->pdev = pdev;
>  	dpi->dss_model = dss_model;
> +	dpi->dss = dss;
>  	port->data = dpi;
>  
>  	mutex_init(&dpi->lock);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 1dab308c9bc1..6d60882dfd10 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -345,6 +345,7 @@ struct dsi_data {
>  
>  	struct clk *dss_clk;
>  	struct regmap *syscon;
> +	struct dss_device *dss;
>  
>  	struct dispc_clock_info user_dispc_cinfo;
>  	struct dss_pll_clock_info user_dsi_cinfo;
> @@ -4217,7 +4218,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
> -	dss_select_lcd_clk_source(channel, dsi->module_id == 0 ?
> +	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
>  			DSS_CLK_SRC_PLL1_1 :
>  			DSS_CLK_SRC_PLL2_1);
>  
> @@ -4271,7 +4272,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
>  		dss_mgr_unregister_framedone_handler(channel,
>  				dsi_framedone_irq_callback, dsidev);
>  err:
> -	dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> +	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
>  	return r;
>  }
>  
> @@ -4284,7 +4285,7 @@ static void dsi_display_uninit_dispc(struct platform_device *dsidev,
>  		dss_mgr_unregister_framedone_handler(channel,
>  				dsi_framedone_irq_callback, dsidev);
>  
> -	dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
> +	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
>  }
>  
>  static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
> @@ -4317,9 +4318,9 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
>  	if (r)
>  		goto err1;
>  
> -	dss_select_dsi_clk_source(dsi->module_id, dsi->module_id == 0 ?
> -			DSS_CLK_SRC_PLL1_2 :
> -			DSS_CLK_SRC_PLL2_2);
> +	dss_select_dsi_clk_source(dsi->dss, dsi->module_id,
> +				  dsi->module_id == 0 ?
> +				  DSS_CLK_SRC_PLL1_2 : DSS_CLK_SRC_PLL2_2);
>  
>  	DSSDBG("PLL OK\n");
>  
> @@ -4351,7 +4352,7 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
>  err3:
>  	dsi_cio_uninit(dsidev);
>  err2:
> -	dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
> +	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
>  err1:
>  	dss_pll_disable(&dsi->pll);
>  err0:
> @@ -4373,7 +4374,7 @@ static void dsi_display_uninit_dsi(struct platform_device *dsidev,
>  	dsi_vc_enable(dsidev, 2, 0);
>  	dsi_vc_enable(dsidev, 3, 0);
>  
> -	dss_select_dsi_clk_source(dsi->module_id, DSS_CLK_SRC_FCK);
> +	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
>  	dsi_cio_uninit(dsidev);
>  	dsi_pll_uninit(dsidev, disconnect_lanes);
>  }
> @@ -5443,6 +5444,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	if (!dsi)
>  		return -ENOMEM;
>  
> +	dsi->dss = dss;
>  	dsi->pdev = dsidev;
>  	dev_set_drvdata(&dsidev->dev, dsi);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index f8b71e24a07d..bd8f7abf0450 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -74,9 +74,11 @@ struct dss_reg {
>  	dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
>  
>  struct dss_ops {
> -	int (*dpi_select_source)(int port, enum omap_channel channel);
> -	int (*select_lcd_source)(enum omap_channel channel,
> -		enum dss_clk_source clk_src);
> +	int (*dpi_select_source)(struct dss_device *dss, int port,
> +				 enum omap_channel channel);
> +	int (*select_lcd_source)(struct dss_device *dss,
> +				 enum omap_channel channel,
> +				 enum dss_clk_source clk_src);
>  };
>  
>  struct dss_features {
> @@ -472,8 +474,8 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
>  	dss.dispc_clk_source = clk_src;
>  }
>  
> -void dss_select_dsi_clk_source(int dsi_module,
> -		enum dss_clk_source clk_src)
> +void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
> +			       enum dss_clk_source clk_src)
>  {
>  	int b, pos;
>  
> @@ -497,11 +499,12 @@ void dss_select_dsi_clk_source(int dsi_module,
>  	pos = dsi_module == 0 ? 1 : 10;
>  	REG_FLD_MOD(DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
>  
> -	dss.dsi_clk_source[dsi_module] = clk_src;
> +	dss->dsi_clk_source[dsi_module] = clk_src;
>  }
>  
> -static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
> -	enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_dra7(struct dss_device *dss,
> +				enum omap_channel channel,
> +				enum dss_clk_source clk_src)
>  {
>  	const u8 ctrl_bits[] = {
>  		[OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -527,8 +530,9 @@ static int dss_lcd_clk_mux_dra7(enum omap_channel channel,
>  	return 0;
>  }
>  
> -static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
> -	enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_omap5(struct dss_device *dss,
> +				 enum omap_channel channel,
> +				 enum dss_clk_source clk_src)
>  {
>  	const u8 ctrl_bits[] = {
>  		[OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -557,8 +561,9 @@ static int dss_lcd_clk_mux_omap5(enum omap_channel channel,
>  	return 0;
>  }
>  
> -static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
> -	enum dss_clk_source clk_src)
> +static int dss_lcd_clk_mux_omap4(struct dss_device *dss,
> +				 enum omap_channel channel,
> +				 enum dss_clk_source clk_src)
>  {
>  	const u8 ctrl_bits[] = {
>  		[OMAP_DSS_CHANNEL_LCD] = 0,
> @@ -585,23 +590,24 @@ static int dss_lcd_clk_mux_omap4(enum omap_channel channel,
>  	return 0;
>  }
>  
> -void dss_select_lcd_clk_source(enum omap_channel channel,
> -		enum dss_clk_source clk_src)
> +void dss_select_lcd_clk_source(struct dss_device *dss,
> +			       enum omap_channel channel,
> +			       enum dss_clk_source clk_src)
>  {
>  	int idx = dss_get_channel_index(channel);
>  	int r;
>  
> -	if (!dss.feat->has_lcd_clk_src) {
> +	if (!dss->feat->has_lcd_clk_src) {
>  		dss_select_dispc_clk_source(clk_src);
> -		dss.lcd_clk_source[idx] = clk_src;
> +		dss->lcd_clk_source[idx] = clk_src;
>  		return;
>  	}
>  
> -	r = dss.feat->ops->select_lcd_source(channel, clk_src);
> +	r = dss->feat->ops->select_lcd_source(dss, channel, clk_src);
>  	if (r)
>  		return;
>  
> -	dss.lcd_clk_source[idx] = clk_src;
> +	dss->lcd_clk_source[idx] = clk_src;
>  }
>  
>  enum dss_clk_source dss_get_dispc_clk_source(void)
> @@ -750,11 +756,12 @@ void dss_set_dac_pwrdn_bgz(bool enable)
>  	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
>  }
>  
> -void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select src)
> +void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> +				     enum dss_hdmi_venc_clk_source_select src)
>  {
>  	enum omap_dss_output_id outputs;
>  
> -	outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
> +	outputs = dss->feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
>  
>  	/* Complain about invalid selections */
>  	WARN_ON((src == DSS_VENC_TV_CLK) && !(outputs & OMAP_DSS_OUTPUT_VENC));
> @@ -780,7 +787,8 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
>  	return REG_GET(DSS_CONTROL, 15, 15);
>  }
>  
> -static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
> +					     enum omap_channel channel)
>  {
>  	if (channel != OMAP_DSS_CHANNEL_LCD)
>  		return -EINVAL;
> @@ -788,7 +796,8 @@ static int dss_dpi_select_source_omap2_omap3(int port, enum omap_channel channel
>  	return 0;
>  }
>  
> -static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap4(struct dss_device *dss, int port,
> +				       enum omap_channel channel)
>  {
>  	int val;
>  
> @@ -808,7 +817,8 @@ static int dss_dpi_select_source_omap4(int port, enum omap_channel channel)
>  	return 0;
>  }
>  
> -static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_omap5(struct dss_device *dss, int port,
> +				       enum omap_channel channel)
>  {
>  	int val;
>  
> @@ -834,11 +844,12 @@ static int dss_dpi_select_source_omap5(int port, enum omap_channel channel)
>  	return 0;
>  }
>  
> -static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
> +static int dss_dpi_select_source_dra7xx(struct dss_device *dss, int port,
> +					enum omap_channel channel)
>  {
>  	switch (port) {
>  	case 0:
> -		return dss_dpi_select_source_omap5(port, channel);
> +		return dss_dpi_select_source_omap5(dss, port, channel);
>  	case 1:
>  		if (channel != OMAP_DSS_CHANNEL_LCD2)
>  			return -EINVAL;
> @@ -854,9 +865,10 @@ static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
>  	return 0;
>  }
>  
> -int dss_dpi_select_source(int port, enum omap_channel channel)
> +int dss_dpi_select_source(struct dss_device *dss, int port,
> +			  enum omap_channel channel)
>  {
> -	return dss.feat->ops->dpi_select_source(port, channel);
> +	return dss->feat->ops->dpi_select_source(dss, port, channel);
>  }
>  
>  static int dss_get_clocks(void)
> @@ -1223,7 +1235,7 @@ static int dss_init_ports(struct platform_device *pdev)
>  
>  		switch (dss.feat->ports[i]) {
>  		case OMAP_DISPLAY_TYPE_DPI:
> -			dpi_init_port(pdev, port, dss.feat->model);
> +			dpi_init_port(&dss, pdev, port, dss.feat->model);
>  			break;
>  		case OMAP_DISPLAY_TYPE_SDI:
>  			sdi_init_port(&dss, pdev, port);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 08651f101518..05fba6b3400b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -287,8 +287,10 @@ void dss_runtime_put(struct dss_device *dss);
>  unsigned long dss_get_dispc_clk_rate(void);
>  unsigned long dss_get_max_fck_rate(void);
>  enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
> -int dss_dpi_select_source(int port, enum omap_channel channel);
> -void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
> +int dss_dpi_select_source(struct dss_device *dss, int port,
> +			  enum omap_channel channel);
> +void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> +				     enum dss_hdmi_venc_clk_source_select src);
>  enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
>  const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
>  
> @@ -304,10 +306,11 @@ void dss_sdi_init(struct dss_device *dss, int datapairs);
>  int dss_sdi_enable(struct dss_device *dss);
>  void dss_sdi_disable(struct dss_device *dss);
>  
> -void dss_select_dsi_clk_source(int dsi_module,
> -		enum dss_clk_source clk_src);
> -void dss_select_lcd_clk_source(enum omap_channel channel,
> -		enum dss_clk_source clk_src);
> +void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
> +			       enum dss_clk_source clk_src);
> +void dss_select_lcd_clk_source(struct dss_device *dss,
> +			       enum omap_channel channel,
> +			       enum dss_clk_source clk_src);
>  enum dss_clk_source dss_get_dispc_clk_source(void);
>  enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
>  enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
> @@ -353,12 +356,14 @@ void dsi_irq_handler(void);
>  
>  /* DPI */
>  #ifdef CONFIG_OMAP2_DSS_DPI
> -int dpi_init_port(struct platform_device *pdev, struct device_node *port,
> -		  enum dss_model dss_model);
> +int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
> +		  struct device_node *port, enum dss_model dss_model);
>  void dpi_uninit_port(struct device_node *port);
>  #else
> -static inline int dpi_init_port(struct platform_device *pdev,
> -		struct device_node *port, enum dss_model dss_model)
> +static inline int dpi_init_port(struct dss_device *port,
> +				struct platform_device *pdev,
> +				struct device_node *port,
> +				enum dss_model dss_model)
>  {
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index 4dbc4f3d728c..fa2fbdaa427c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -359,6 +359,7 @@ static inline bool hdmi_mode_has_audio(struct hdmi_config *cfg)
>  struct omap_hdmi {
>  	struct mutex lock;
>  	struct platform_device *pdev;
> +	struct dss_device *dss;
>  
>  	struct dss_debugfs_entry *debugfs;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index d84eba8440c8..5806587fd89a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -147,7 +147,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
>  	hdmi4_core_powerdown_disable(&hdmi.core);
>  
>  	/* Make selection of HDMI in DSS */
> -	dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
> +	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
>  
>  	hdmi.core_enabled = true;
>  
> @@ -722,6 +722,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  	int irq;
>  
>  	hdmi.pdev = pdev;
> +	hdmi.dss = dss;
>  	dev_set_drvdata(&pdev->dev, &hdmi);
>  
>  	mutex_init(&hdmi.lock);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 64cfed89c79b..c28fe184a7ad 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -149,7 +149,7 @@ static int hdmi_power_on_core(struct omap_dss_device *dssdev)
>  		goto err_runtime_get;
>  
>  	/* Make selection of HDMI in DSS */
> -	dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
> +	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
>  
>  	hdmi.core_enabled = true;
>  
> @@ -724,6 +724,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  	int irq;
>  
>  	hdmi.pdev = pdev;
> +	hdmi.dss = dss;
>  	dev_set_drvdata(&pdev->dev, &hdmi);
>  
>  	mutex_init(&hdmi.lock);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source()
  2017-10-13 14:59 ` [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
@ 2017-10-16  9:08   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:08 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 6811 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:22PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c | 11 +++++++----
>  drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 +++++---
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 18 ++++++++++--------
>  drivers/gpu/drm/omapdrm/dss/dss.h   |  8 +++++---
>  4 files changed, 27 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 1afd2802e807..723828f97196 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -167,6 +167,7 @@ struct dispc_features {
>  static struct {
>  	struct platform_device *pdev;
>  	void __iomem    *base;
> +	struct dss_device *dss;
>  
>  	struct dss_debugfs_entry *debugfs;
>  
> @@ -3116,7 +3117,7 @@ static unsigned long dispc_fclk_rate(void)
>  	unsigned long r;
>  	enum dss_clk_source src;
>  
> -	src = dss_get_dispc_clk_source();
> +	src = dss_get_dispc_clk_source(dispc.dss);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
>  		r = dss_get_dispc_clk_rate();
> @@ -3143,7 +3144,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
>  	if (!dss_mgr_is_lcd(channel))
>  		return dispc_fclk_rate();
>  
> -	src = dss_get_lcd_clk_source(channel);
> +	src = dss_get_lcd_clk_source(dispc.dss, channel);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
>  		r = dss_get_dispc_clk_rate();
> @@ -3223,7 +3224,7 @@ static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel chan
>  
>  	seq_printf(s, "- %s -\n", mgr_desc[channel].name);
>  
> -	lcd_clk_src = dss_get_lcd_clk_source(channel);
> +	lcd_clk_src = dss_get_lcd_clk_source(dispc.dss, channel);
>  
>  	seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
>  		dss_get_clk_source_name(lcd_clk_src));
> @@ -3240,7 +3241,7 @@ void dispc_dump_clocks(struct seq_file *s)
>  {
>  	int lcd;
>  	u32 l;
> -	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source();
> +	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
>  
>  	if (dispc_runtime_get())
>  		return;
> @@ -4542,12 +4543,14 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	const struct soc_device_attribute *soc;
> +	struct dss_device *dss = dss_get_device(master);
>  	u32 rev;
>  	int r = 0;
>  	struct resource *dispc_mem;
>  	struct device_node *np = pdev->dev.of_node;
>  
>  	dispc.pdev = pdev;
> +	dispc.dss = dss;
>  
>  	spin_lock_init(&dispc.control_lock);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 6d60882dfd10..7fb048023fd0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -1292,8 +1292,10 @@ static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
>  {
>  	unsigned long r;
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	enum dss_clk_source source;
>  
> -	if (dss_get_dsi_clk_source(dsi->module_id) == DSS_CLK_SRC_FCK) {
> +	source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id);
> +	if (source == DSS_CLK_SRC_FCK) {
>  		/* DSI FCLK source is DSS_CLK_FCK */
>  		r = clk_get_rate(dsi->dss_clk);
>  	} else {
> @@ -1512,8 +1514,8 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
>  	int dsi_module = dsi->module_id;
>  	struct dss_pll *pll = &dsi->pll;
>  
> -	dispc_clk_src = dss_get_dispc_clk_source();
> -	dsi_clk_src = dss_get_dsi_clk_source(dsi_module);
> +	dispc_clk_src = dss_get_dispc_clk_source(dsi->dss);
> +	dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
>  
>  	if (dsi_runtime_get(dsidev))
>  		return;
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index bd8f7abf0450..ba7a2bf1ec09 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -610,25 +610,27 @@ void dss_select_lcd_clk_source(struct dss_device *dss,
>  	dss->lcd_clk_source[idx] = clk_src;
>  }
>  
> -enum dss_clk_source dss_get_dispc_clk_source(void)
> +enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss)
>  {
> -	return dss.dispc_clk_source;
> +	return dss->dispc_clk_source;
>  }
>  
> -enum dss_clk_source dss_get_dsi_clk_source(int dsi_module)
> +enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
> +					   int dsi_module)
>  {
> -	return dss.dsi_clk_source[dsi_module];
> +	return dss->dsi_clk_source[dsi_module];
>  }
>  
> -enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel)
> +enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
> +					   enum omap_channel channel)
>  {
> -	if (dss.feat->has_lcd_clk_src) {
> +	if (dss->feat->has_lcd_clk_src) {
>  		int idx = dss_get_channel_index(channel);
> -		return dss.lcd_clk_source[idx];
> +		return dss->lcd_clk_source[idx];
>  	} else {
>  		/* LCD_CLK source is the same as DISPC_FCLK source for
>  		 * OMAP2 and OMAP3 */
> -		return dss.dispc_clk_source;
> +		return dss->dispc_clk_source;
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 05fba6b3400b..fdb51063c703 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -311,9 +311,11 @@ void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
>  void dss_select_lcd_clk_source(struct dss_device *dss,
>  			       enum omap_channel channel,
>  			       enum dss_clk_source clk_src);
> -enum dss_clk_source dss_get_dispc_clk_source(void);
> -enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
> -enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
> +enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss);
> +enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
> +					   int dsi_module);
> +enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
> +					   enum omap_channel channel);
>  
>  void dss_set_venc_output(enum omap_dss_venc_type type);
>  void dss_set_dac_pwrdn_bgz(bool enable);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers
  2017-10-14 13:12   ` Sebastian Reichel
@ 2017-10-16  9:09     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-16  9:09 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Saturday, 14 October 2017 16:12:37 EEST Sebastian Reichel wrote:
> On Fri, Oct 13, 2017 at 05:59:16PM +0300, Laurent Pinchart wrote:
> > The split between the omapdss and omapdrm driver is historic and was due
> > to other userspace APIs (FBDEV and V4L2) being supported in addition to
> > DRM/KMS. Now that the drivers only supports the DRM/KMS API, there is no
> > need to keep them separate anymore.
> > 
> > Merge the two drivers and remove the now unneeded omapdrm virtual
> > platform device.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/Kconfig          |  5 +-
> >  drivers/gpu/drm/omapdrm/Makefile         | 25 ++++++++++
> >  drivers/gpu/drm/omapdrm/dss/Kconfig      | 12 -----
> >  drivers/gpu/drm/omapdrm/dss/Makefile     | 25 ----------
> >  drivers/gpu/drm/omapdrm/dss/base.c       | 13 -----
> >  drivers/gpu/drm/omapdrm/dss/core.c       | 14 ++----
> >  drivers/gpu/drm/omapdrm/dss/dss.c        | 23 ++++++++-
> >  drivers/gpu/drm/omapdrm/dss/omapdss.h    |  4 --
> >  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 12 ++++-
> >  drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  3 +-
> >  drivers/gpu/drm/omapdrm/omap_drv.c       | 82 ++-------------------------
> >  drivers/gpu/drm/omapdrm/omap_drv.h       |  4 ++
> >  12 files changed, 74 insertions(+), 148 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/Kconfig
> > b/drivers/gpu/drm/omapdrm/Kconfig index b3d08c5f41d4..7e5080e45b16 100644
> > --- a/drivers/gpu/drm/omapdrm/Kconfig
> > +++ b/drivers/gpu/drm/omapdrm/Kconfig
> > @@ -2,8 +2,11 @@ config DRM_OMAP
> >  	tristate "OMAP DRM"
> >  	depends on DRM
> >  	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
> > -	select OMAP2_DSS
> >  	select DRM_KMS_HELPER
> > +	select HDMI
> > +	select OMAP2_DSS
> 
> As far as I can see "CONFIG_OMAP2_DSS" no longer exists after the merge,
> so this can be dropped.

Good point. I'll fix that in v2.

> Otherwise:
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> 
> -- Sebastian
> 
> > +	select OMAP2_DSS_INIT
> > +	select VIDEOMODE_HELPERS
> >  	default n
> >  	help
> >  	  DRM display driver for OMAP2/3/4 based boards.

[snip]

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers
  2017-10-15 21:10   ` Sebastian Reichel
@ 2017-10-16  9:11     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-16  9:11 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Monday, 16 October 2017 00:10:19 EEST Sebastian Reichel wrote:
> On Fri, Oct 13, 2017 at 05:59:17PM +0300, Laurent Pinchart wrote:
> > To simplify implementation of debugfs seq_file show handlers, the driver
> > passes the pointer to the show function through the debugfs_create_file
> > data pointer. This prevents using the pointer to pass driver private
> > data to the show handler, and requires all handlers to use global
> > variables to access private data.
> > 
> > To prepare for the removal of global private data in the driver, rework
> > the debugfs infrastructure to allow passing a private data pointer to
> > show handlers.
> > 
> > The price to pay is explicit removal of debugfs files to free the
> > internally allocated memory. This is desirable anyway as debugfs entries
> > should be removed when a component driver is unbound, otherwise crashes
> > will occur due to access to freed memory when the components will be
> > dynamically allocated instead of stored in global variables.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> 
> (One nit-pick in dss.h, see below)
> 
> -- Sebastian
> 
> >  drivers/gpu/drm/omapdrm/dss/dispc.c | 13 ++++--
> >  drivers/gpu/drm/omapdrm/dss/dsi.c   | 40 +++++++++++-----
> >  drivers/gpu/drm/omapdrm/dss/dss.c   | 92 +++++++++++++++++++++-----------
> >  drivers/gpu/drm/omapdrm/dss/dss.h   | 27 +++++++----
> >  drivers/gpu/drm/omapdrm/dss/hdmi.h  |  2 +
> >  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  9 ++--
> >  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  9 ++--
> >  drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++--
> >  8 files changed, 140 insertions(+), 63 deletions(-)

[snip]

> > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h
> > b/drivers/gpu/drm/omapdrm/dss/dss.h index db529481b364..e688e937da28
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> > +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> > @@ -27,6 +27,11 @@
> > 
> >  #include "omapdss.h"
> > 
> > +struct dentry;
> 
> You can drop this one. It is not used in dss.h.

Indeed, it's a leftover from a previous version where I was still exposing 
struct dentry. I'll remove it in v2.

> > +struct dss_debugfs_entry;
> > +struct platform_device;
> > +struct seq_file;

[snip]

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions
  2017-10-13 14:59 ` [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
@ 2017-10-16  9:12   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:12 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 9897 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:23PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c |  8 ++++----
>  drivers/gpu/drm/omapdrm/dss/dpi.c   | 14 ++++++++------
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 37 ++++++++++++++++++-------------------
>  drivers/gpu/drm/omapdrm/dss/dss.h   | 10 +++++-----
>  drivers/gpu/drm/omapdrm/dss/sdi.c   |  5 +++--
>  5 files changed, 38 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 723828f97196..7b74c8ee9372 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -3120,7 +3120,7 @@ static unsigned long dispc_fclk_rate(void)
>  	src = dss_get_dispc_clk_source(dispc.dss);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
> -		r = dss_get_dispc_clk_rate();
> +		r = dss_get_dispc_clk_rate(dispc.dss);
>  	} else {
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
> @@ -3147,7 +3147,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
>  	src = dss_get_lcd_clk_source(dispc.dss, channel);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
> -		r = dss_get_dispc_clk_rate();
> +		r = dss_get_dispc_clk_rate(dispc.dss);
>  	} else {
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
> @@ -3505,7 +3505,7 @@ bool dispc_div_calc(unsigned long dispc_freq,
>  	pckd_hw_min = dispc.feat->min_pcd;
>  	pckd_hw_max = 255;
>  
> -	lck_max = dss_get_max_fck_rate();
> +	lck_max = dss_get_max_fck_rate(dispc.dss);
>  
>  	pck_min = pck_min ? pck_min : 1;
>  	pck_max = pck_max ? pck_max : ULONG_MAX;
> @@ -4455,7 +4455,7 @@ static void dispc_errata_i734_wa(void)
>  
>  	/* Set up and enable display manager for LCD1 */
>  	dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, &i734.mgri);
> -	dispc_calc_clock_rates(dss_get_dispc_clk_rate(),
> +	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
>  			       &lcd_conf.clock_info);
>  	dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, &lcd_conf);
>  	dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, &i734.vm);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 38a4c037783a..b0f890a3c8db 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -209,7 +209,7 @@ static bool dpi_calc_pll_cb(int n, int m, unsigned long fint,
>  	ctx->pll_cinfo.clkdco = clkdco;
>  
>  	return dss_pll_hsdiv_calc_a(ctx->pll, clkdco,
> -		ctx->pck_min, dss_get_max_fck_rate(),
> +		ctx->pck_min, dss_get_max_fck_rate(ctx->pll->dss),
>  		dpi_calc_hsdiv_cb, ctx);
>  }
>  
> @@ -258,7 +258,8 @@ static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck,
>  	}
>  }
>  
> -static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
> +static bool dpi_dss_clk_calc(struct dpi_data *dpi, unsigned long pck,
> +			     struct dpi_clk_calc_ctx *ctx)
>  {
>  	int i;
>  
> @@ -279,7 +280,8 @@ static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
>  			ctx->pck_min = 0;
>  		ctx->pck_max = pck + 1000 * i * i * i;
>  
> -		ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx);
> +		ok = dss_div_calc(dpi->dss, pck, ctx->pck_min,
> +				  dpi_calc_dss_cb, ctx);
>  		if (ok)
>  			return ok;
>  	}
> @@ -323,11 +325,11 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
>  	int r;
>  	bool ok;
>  
> -	ok = dpi_dss_clk_calc(pck_req, &ctx);
> +	ok = dpi_dss_clk_calc(dpi, pck_req, &ctx);
>  	if (!ok)
>  		return -EINVAL;
>  
> -	r = dss_set_fck_rate(ctx.fck);
> +	r = dss_set_fck_rate(dpi->dss, ctx.fck);
>  	if (r)
>  		return r;
>  
> @@ -532,7 +534,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
>  
>  		fck = ctx.pll_cinfo.clkout[ctx.clkout_idx];
>  	} else {
> -		ok = dpi_dss_clk_calc(vm->pixelclock, &ctx);
> +		ok = dpi_dss_clk_calc(dpi, vm->pixelclock, &ctx);
>  		if (!ok)
>  			return -EINVAL;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index ba7a2bf1ec09..24237ed0557f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -634,8 +634,8 @@ enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
>  	}
>  }
>  
> -bool dss_div_calc(unsigned long pck, unsigned long fck_min,
> -		dss_div_calc_func func, void *data)
> +bool dss_div_calc(struct dss_device *dss, unsigned long pck,
> +		  unsigned long fck_min, dss_div_calc_func func, void *data)
>  {
>  	int fckd, fckd_start, fckd_stop;
>  	unsigned long fck;
> @@ -644,24 +644,24 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
>  	unsigned long prate;
>  	unsigned int m;
>  
> -	fck_hw_max = dss.feat->fck_freq_max;
> +	fck_hw_max = dss->feat->fck_freq_max;
>  
> -	if (dss.parent_clk == NULL) {
> +	if (dss->parent_clk == NULL) {
>  		unsigned int pckd;
>  
>  		pckd = fck_hw_max / pck;
>  
>  		fck = pck * pckd;
>  
> -		fck = clk_round_rate(dss.dss_clk, fck);
> +		fck = clk_round_rate(dss->dss_clk, fck);
>  
>  		return func(fck, data);
>  	}
>  
> -	fckd_hw_max = dss.feat->fck_div_max;
> +	fckd_hw_max = dss->feat->fck_div_max;
>  
> -	m = dss.feat->dss_fck_multiplier;
> -	prate = clk_get_rate(dss.parent_clk);
> +	m = dss->feat->dss_fck_multiplier;
> +	prate = clk_get_rate(dss->parent_clk);
>  
>  	fck_min = fck_min ? fck_min : 1;
>  
> @@ -678,33 +678,32 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
>  	return false;
>  }
>  
> -int dss_set_fck_rate(unsigned long rate)
> +int dss_set_fck_rate(struct dss_device *dss, unsigned long rate)
>  {
>  	int r;
>  
>  	DSSDBG("set fck to %lu\n", rate);
>  
> -	r = clk_set_rate(dss.dss_clk, rate);
> +	r = clk_set_rate(dss->dss_clk, rate);
>  	if (r)
>  		return r;
>  
> -	dss.dss_clk_rate = clk_get_rate(dss.dss_clk);
> +	dss->dss_clk_rate = clk_get_rate(dss->dss_clk);
>  
> -	WARN_ONCE(dss.dss_clk_rate != rate,
> -			"clk rate mismatch: %lu != %lu", dss.dss_clk_rate,
> -			rate);
> +	WARN_ONCE(dss->dss_clk_rate != rate, "clk rate mismatch: %lu != %lu",
> +		  dss->dss_clk_rate, rate);
>  
>  	return 0;
>  }
>  
> -unsigned long dss_get_dispc_clk_rate(void)
> +unsigned long dss_get_dispc_clk_rate(struct dss_device *dss)
>  {
> -	return dss.dss_clk_rate;
> +	return dss->dss_clk_rate;
>  }
>  
> -unsigned long dss_get_max_fck_rate(void)
> +unsigned long dss_get_max_fck_rate(struct dss_device *dss)
>  {
> -	return dss.feat->fck_freq_max;
> +	return dss->feat->fck_freq_max;
>  }
>  
>  enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel)
> @@ -731,7 +730,7 @@ static int dss_setup_default_clock(void)
>  		fck = DIV_ROUND_UP(prate, fck_div) * dss.feat->dss_fck_multiplier;
>  	}
>  
> -	r = dss_set_fck_rate(fck);
> +	r = dss_set_fck_rate(&dss, fck);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index fdb51063c703..cb257ffc8a54 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -284,8 +284,8 @@ struct dss_device *dss_get_device(struct device *dev);
>  int dss_runtime_get(struct dss_device *dss);
>  void dss_runtime_put(struct dss_device *dss);
>  
> -unsigned long dss_get_dispc_clk_rate(void);
> -unsigned long dss_get_max_fck_rate(void);
> +unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
> +unsigned long dss_get_max_fck_rate(struct dss_device *dss);
>  enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
>  int dss_dpi_select_source(struct dss_device *dss, int port,
>  			  enum omap_channel channel);
> @@ -320,11 +320,11 @@ enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
>  void dss_set_venc_output(enum omap_dss_venc_type type);
>  void dss_set_dac_pwrdn_bgz(bool enable);
>  
> -int dss_set_fck_rate(unsigned long rate);
> +int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
>  
>  typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
> -bool dss_div_calc(unsigned long pck, unsigned long fck_min,
> -		dss_div_calc_func func, void *data);
> +bool dss_div_calc(struct dss_device *dss, unsigned long pck,
> +		  unsigned long fck_min, dss_div_calc_func func, void *data);
>  
>  /* SDI */
>  #ifdef CONFIG_OMAP2_DSS_SDI
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 39cb5c8af0dc..ac436826914a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -101,7 +101,8 @@ static int sdi_calc_clock_div(unsigned long pclk,
>  			ctx.pck_min = 0;
>  		ctx.pck_max = pclk + 1000 * i * i * i;
>  
> -		ok = dss_div_calc(pclk, ctx.pck_min, dpi_calc_dss_cb, &ctx);
> +		ok = dss_div_calc(sdi.dss, pclk, ctx.pck_min,
> +				  dpi_calc_dss_cb, &ctx);
>  		if (ok) {
>  			*fck = ctx.fck;
>  			*dispc_cinfo = ctx.dispc_cinfo;
> @@ -171,7 +172,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  
>  	dss_mgr_set_timings(channel, vm);
>  
> -	r = dss_set_fck_rate(fck);
> +	r = dss_set_fck_rate(sdi.dss, fck);
>  	if (r)
>  		goto err_set_dss_clock_div;
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions
  2017-10-13 14:59 ` [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
@ 2017-10-16  9:15   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:15 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 6024 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:24PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DSS private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DSS device dynamically).
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
>  drivers/gpu/drm/omapdrm/dss/dss.c   |  9 +++++----
>  drivers/gpu/drm/omapdrm/dss/dss.h   |  7 ++++---
>  drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++++++----
>  4 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 7b74c8ee9372..912957c471ce 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -2737,7 +2737,7 @@ static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
>  
>  static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel)
>  {
> -	return dss_get_supported_outputs(channel);
> +	return dss_get_supported_outputs(dispc.dss, channel);
>  }
>  
>  static void dispc_lcd_enable_signal_polarity(bool act_high)
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 24237ed0557f..98a0da32f217 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -706,9 +706,10 @@ unsigned long dss_get_max_fck_rate(struct dss_device *dss)
>  	return dss->feat->fck_freq_max;
>  }
>  
> -enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel)
> +enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
> +						  enum omap_channel channel)
>  {
> -	return dss.feat->outputs[channel];
> +	return dss->feat->outputs[channel];
>  }
>  
>  static int dss_setup_default_clock(void)
> @@ -737,7 +738,7 @@ static int dss_setup_default_clock(void)
>  	return 0;
>  }
>  
> -void dss_set_venc_output(enum omap_dss_venc_type type)
> +void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type)
>  {
>  	int l = 0;
>  
> @@ -752,7 +753,7 @@ void dss_set_venc_output(enum omap_dss_venc_type type)
>  	REG_FLD_MOD(DSS_CONTROL, l, 6, 6);
>  }
>  
> -void dss_set_dac_pwrdn_bgz(bool enable)
> +void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable)
>  {
>  	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index cb257ffc8a54..2641d5c6a32a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -286,7 +286,8 @@ void dss_runtime_put(struct dss_device *dss);
>  
>  unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
>  unsigned long dss_get_max_fck_rate(struct dss_device *dss);
> -enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
> +enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
> +						  enum omap_channel channel);
>  int dss_dpi_select_source(struct dss_device *dss, int port,
>  			  enum omap_channel channel);
>  void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> @@ -317,8 +318,8 @@ enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
>  enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
>  					   enum omap_channel channel);
>  
> -void dss_set_venc_output(enum omap_dss_venc_type type);
> -void dss_set_dac_pwrdn_bgz(bool enable);
> +void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
> +void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
>  
>  int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 68035c1acf1f..179ef73a5564 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -327,6 +327,7 @@ static struct {
>  	struct mutex venc_lock;
>  	u32 wss_data;
>  	struct regulator *vdda_dac_reg;
> +	struct dss_device *dss;
>  
>  	struct dss_debugfs_entry *debugfs;
>  
> @@ -472,8 +473,8 @@ static int venc_power_on(struct omap_dss_device *dssdev)
>  	venc_reset();
>  	venc_write_config(venc_timings_to_config(&venc.vm));
>  
> -	dss_set_venc_output(venc.type);
> -	dss_set_dac_pwrdn_bgz(1);
> +	dss_set_venc_output(venc.dss, venc.type);
> +	dss_set_dac_pwrdn_bgz(venc.dss, 1);
>  
>  	l = 0;
>  
> @@ -503,7 +504,7 @@ static int venc_power_on(struct omap_dss_device *dssdev)
>  	regulator_disable(venc.vdda_dac_reg);
>  err1:
>  	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
> -	dss_set_dac_pwrdn_bgz(0);
> +	dss_set_dac_pwrdn_bgz(venc.dss, 0);
>  
>  	venc_runtime_put();
>  err0:
> @@ -515,7 +516,7 @@ static void venc_power_off(struct omap_dss_device *dssdev)
>  	enum omap_channel channel = dssdev->dispc_channel;
>  
>  	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
> -	dss_set_dac_pwrdn_bgz(0);
> +	dss_set_dac_pwrdn_bgz(venc.dss, 0);
>  
>  	dss_mgr_disable(channel);
>  
> @@ -876,11 +877,13 @@ static const struct soc_device_attribute venc_soc_devices[] = {
>  static int venc_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> +	struct dss_device *dss = dss_get_device(master);
>  	u8 rev_id;
>  	struct resource *venc_mem;
>  	int r;
>  
>  	venc.pdev = pdev;
> +	venc.dss = dss;
>  
>  	/* The OMAP34xx, OMAP35xx and AM35xx VENC require the TV DAC clock. */
>  	if (soc_device_match(venc_soc_devices))
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function
  2017-10-13 14:59 ` [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function Laurent Pinchart
@ 2017-10-16  9:16   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:16 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2188 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:25PM +0300, Laurent Pinchart wrote:
> The function is unused, remove it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dss.c | 14 --------------
>  drivers/gpu/drm/omapdrm/dss/dss.h |  1 -
>  2 files changed, 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 98a0da32f217..8b83bdcde6e2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -775,20 +775,6 @@ void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
>  		REG_FLD_MOD(DSS_CONTROL, src, 15, 15);	/* VENC_HDMI_SWITCH */
>  }
>  
> -enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
> -{
> -	enum omap_dss_output_id outputs;
> -
> -	outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
> -	if ((outputs & OMAP_DSS_OUTPUT_HDMI) == 0)
> -		return DSS_VENC_TV_CLK;
> -
> -	if ((outputs & OMAP_DSS_OUTPUT_VENC) == 0)
> -		return DSS_HDMI_M_PCLK;
> -
> -	return REG_GET(DSS_CONTROL, 15, 15);
> -}
> -
>  static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
>  					     enum omap_channel channel)
>  {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 2641d5c6a32a..6950f5d61b6c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -292,7 +292,6 @@ int dss_dpi_select_source(struct dss_device *dss, int port,
>  			  enum omap_channel channel);
>  void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
>  				     enum dss_hdmi_venc_clk_source_select src);
> -enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
>  const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
>  
>  /* DSS VIDEO PLL */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically
  2017-10-13 14:59 ` [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
@ 2017-10-16  9:39   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16  9:39 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 31158 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:26PM +0300, Laurent Pinchart wrote:
> The DSS private data structure is currently stored as a global variable.
> While no platform with multiple DSS devices currently exists nor is
> planned, this doesn't comply with the kernel device model and should
> thus be fixed.
> 
> As a first step to the fix, allocate the DSS private data structure
> dynamically for each DSS instance. The pointer still needs to be stored
> in a global variable as many functions exposed outside of the dss module
> don't have access to the DSS private data structure. This will be fixed
> in subsequent steps.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dss.c | 385 +++++++++++++++++++++-----------------
>  1 file changed, 209 insertions(+), 176 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 8b83bdcde6e2..8fec9bf6f06f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -67,11 +67,12 @@ struct dss_reg {
>  #define DSS_PLL_CONTROL			DSS_REG(0x0048)
>  #define DSS_SDI_STATUS			DSS_REG(0x005C)
>  
> -#define REG_GET(idx, start, end) \
> -	FLD_GET(dss_read_reg(idx), start, end)
> +#define REG_GET(dss, idx, start, end) \
> +	FLD_GET(dss_read_reg(dss, idx), start, end)
>  
> -#define REG_FLD_MOD(idx, val, start, end) \
> -	dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
> +#define REG_FLD_MOD(dss, idx, val, start, end) \
> +	dss_write_reg(dss, idx, \
> +		      FLD_MOD(dss_read_reg(dss, idx), val, start, end))
>  
>  struct dss_ops {
>  	int (*dpi_select_source)(struct dss_device *dss, int port,
> @@ -129,8 +130,6 @@ struct dss_device {
>  	struct dss_pll	*video2_pll;
>  };
>  
> -static struct dss_device dss;
> -
>  static const char * const dss_generic_clk_source_names[] = {
>  	[DSS_CLK_SRC_FCK]	= "FCK",
>  	[DSS_CLK_SRC_PLL1_1]	= "PLL1:1",
> @@ -142,49 +141,50 @@ static const char * const dss_generic_clk_source_names[] = {
>  	[DSS_CLK_SRC_HDMI_PLL]	= "HDMI PLL",
>  };
>  
> -static inline void dss_write_reg(const struct dss_reg idx, u32 val)
> +static inline void dss_write_reg(struct dss_device *dss,
> +				 const struct dss_reg idx, u32 val)
>  {
> -	__raw_writel(val, dss.base + idx.idx);
> +	__raw_writel(val, dss->base + idx.idx);
>  }
>  
> -static inline u32 dss_read_reg(const struct dss_reg idx)
> +static inline u32 dss_read_reg(struct dss_device *dss, const struct dss_reg idx)
>  {
> -	return __raw_readl(dss.base + idx.idx);
> +	return __raw_readl(dss->base + idx.idx);
>  }
>  
> -#define SR(reg) \
> -	dss.ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(DSS_##reg)
> -#define RR(reg) \
> -	dss_write_reg(DSS_##reg, dss.ctx[(DSS_##reg).idx / sizeof(u32)])
> +#define SR(dss, reg) \
> +	dss->ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(dss, DSS_##reg)
> +#define RR(dss, reg) \
> +	dss_write_reg(dss, DSS_##reg, dss->ctx[(DSS_##reg).idx / sizeof(u32)])
>  
> -static void dss_save_context(void)
> +static void dss_save_context(struct dss_device *dss)
>  {
>  	DSSDBG("dss_save_context\n");
>  
> -	SR(CONTROL);
> +	SR(dss, CONTROL);
>  
> -	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> -		SR(SDI_CONTROL);
> -		SR(PLL_CONTROL);
> +	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> +		SR(dss, SDI_CONTROL);
> +		SR(dss, PLL_CONTROL);
>  	}
>  
> -	dss.ctx_valid = true;
> +	dss->ctx_valid = true;
>  
>  	DSSDBG("context saved\n");
>  }
>  
> -static void dss_restore_context(void)
> +static void dss_restore_context(struct dss_device *dss)
>  {
>  	DSSDBG("dss_restore_context\n");
>  
> -	if (!dss.ctx_valid)
> +	if (!dss->ctx_valid)
>  		return;
>  
> -	RR(CONTROL);
> +	RR(dss, CONTROL);
>  
> -	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> -		RR(SDI_CONTROL);
> -		RR(PLL_CONTROL);
> +	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> +		RR(dss, SDI_CONTROL);
> +		RR(dss, PLL_CONTROL);
>  	}
>  
>  	DSSDBG("context restored\n");
> @@ -223,12 +223,13 @@ void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
>  			   1 << shift, val << shift);
>  }
>  
> -static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
> -	enum omap_channel channel)
> +static int dss_ctrl_pll_set_control_mux(struct dss_device *dss,
> +					enum dss_clk_source clk_src,
> +					enum omap_channel channel)
>  {
>  	unsigned int shift, val;
>  
> -	if (!dss.syscon_pll_ctrl)
> +	if (!dss->syscon_pll_ctrl)
>  		return -EINVAL;
>  
>  	switch (channel) {
> @@ -283,7 +284,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
>  		return -EINVAL;
>  	}
>  
> -	regmap_update_bits(dss.syscon_pll_ctrl, dss.syscon_pll_ctrl_offset,
> +	regmap_update_bits(dss->syscon_pll_ctrl, dss->syscon_pll_ctrl_offset,
>  		0x3 << shift, val << shift);
>  
>  	return 0;
> @@ -295,17 +296,17 @@ void dss_sdi_init(struct dss_device *dss, int datapairs)
>  
>  	BUG_ON(datapairs > 3 || datapairs < 1);
>  
> -	l = dss_read_reg(DSS_SDI_CONTROL);
> +	l = dss_read_reg(dss, DSS_SDI_CONTROL);
>  	l = FLD_MOD(l, 0xf, 19, 15);		/* SDI_PDIV */
>  	l = FLD_MOD(l, datapairs-1, 3, 2);	/* SDI_PRSEL */
>  	l = FLD_MOD(l, 2, 1, 0);		/* SDI_BWSEL */
> -	dss_write_reg(DSS_SDI_CONTROL, l);
> +	dss_write_reg(dss, DSS_SDI_CONTROL, l);
>  
> -	l = dss_read_reg(DSS_PLL_CONTROL);
> +	l = dss_read_reg(dss, DSS_PLL_CONTROL);
>  	l = FLD_MOD(l, 0x7, 25, 22);	/* SDI_PLL_FREQSEL */
>  	l = FLD_MOD(l, 0xb, 16, 11);	/* SDI_PLL_REGN */
>  	l = FLD_MOD(l, 0xb4, 10, 1);	/* SDI_PLL_REGM */
> -	dss_write_reg(DSS_PLL_CONTROL, l);
> +	dss_write_reg(dss, DSS_PLL_CONTROL, l);
>  }
>  
>  int dss_sdi_enable(struct dss_device *dss)
> @@ -315,15 +316,15 @@ int dss_sdi_enable(struct dss_device *dss)
>  	dispc_pck_free_enable(1);
>  
>  	/* Reset SDI PLL */
> -	REG_FLD_MOD(DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
> +	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
>  	udelay(1);	/* wait 2x PCLK */
>  
>  	/* Lock SDI PLL */
> -	REG_FLD_MOD(DSS_PLL_CONTROL, 1, 28, 28); /* SDI_PLL_GOBIT */
> +	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 28, 28); /* SDI_PLL_GOBIT */
>  
>  	/* Waiting for PLL lock request to complete */
>  	timeout = jiffies + msecs_to_jiffies(500);
> -	while (dss_read_reg(DSS_SDI_STATUS) & (1 << 6)) {
> +	while (dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 6)) {
>  		if (time_after_eq(jiffies, timeout)) {
>  			DSSERR("PLL lock request timed out\n");
>  			goto err1;
> @@ -331,11 +332,11 @@ int dss_sdi_enable(struct dss_device *dss)
>  	}
>  
>  	/* Clearing PLL_GO bit */
> -	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 28, 28);
> +	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 28, 28);
>  
>  	/* Waiting for PLL to lock */
>  	timeout = jiffies + msecs_to_jiffies(500);
> -	while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 5))) {
> +	while (!(dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 5))) {
>  		if (time_after_eq(jiffies, timeout)) {
>  			DSSERR("PLL lock timed out\n");
>  			goto err1;
> @@ -346,7 +347,7 @@ int dss_sdi_enable(struct dss_device *dss)
>  
>  	/* Waiting for SDI reset to complete */
>  	timeout = jiffies + msecs_to_jiffies(500);
> -	while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 2))) {
> +	while (!(dss_read_reg(dss, DSS_SDI_STATUS) & (1 << 2))) {
>  		if (time_after_eq(jiffies, timeout)) {
>  			DSSERR("SDI reset timed out\n");
>  			goto err2;
> @@ -359,7 +360,7 @@ int dss_sdi_enable(struct dss_device *dss)
>  	dispc_lcd_enable_signal(0);
>   err1:
>  	/* Reset SDI PLL */
> -	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
> +	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
>  
>  	dispc_pck_free_enable(0);
>  
> @@ -373,7 +374,7 @@ void dss_sdi_disable(struct dss_device *dss)
>  	dispc_pck_free_enable(0);
>  
>  	/* Reset SDI PLL */
> -	REG_FLD_MOD(DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
> +	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
>  }
>  
>  const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
> @@ -382,46 +383,48 @@ const char *dss_get_clk_source_name(enum dss_clk_source clk_src)
>  }
>  
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
> -static void dss_dump_clocks(struct seq_file *s)
> +static void dss_dump_clocks(struct dss_device *dss, struct seq_file *s)
>  {
>  	const char *fclk_name;
>  	unsigned long fclk_rate;
>  
> -	if (dss_runtime_get(&dss))
> +	if (dss_runtime_get(dss))
>  		return;
>  
>  	seq_printf(s, "- DSS -\n");
>  
>  	fclk_name = dss_get_clk_source_name(DSS_CLK_SRC_FCK);
> -	fclk_rate = clk_get_rate(dss.dss_clk);
> +	fclk_rate = clk_get_rate(dss->dss_clk);
>  
>  	seq_printf(s, "%s = %lu\n",
>  			fclk_name,
>  			fclk_rate);
>  
> -	dss_runtime_put(&dss);
> +	dss_runtime_put(dss);
>  }
>  #endif
>  
>  static int dss_dump_regs(struct seq_file *s, void *p)
>  {
> -#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
> +	struct dss_device *dss = s->private;
> +
> +#define DUMPREG(dss, r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(dss, r))
>  
> -	if (dss_runtime_get(&dss))
> +	if (dss_runtime_get(dss))
>  		return 0;
>  
> -	DUMPREG(DSS_REVISION);
> -	DUMPREG(DSS_SYSCONFIG);
> -	DUMPREG(DSS_SYSSTATUS);
> -	DUMPREG(DSS_CONTROL);
> +	DUMPREG(dss, DSS_REVISION);
> +	DUMPREG(dss, DSS_SYSCONFIG);
> +	DUMPREG(dss, DSS_SYSSTATUS);
> +	DUMPREG(dss, DSS_CONTROL);
>  
> -	if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> -		DUMPREG(DSS_SDI_CONTROL);
> -		DUMPREG(DSS_PLL_CONTROL);
> -		DUMPREG(DSS_SDI_STATUS);
> +	if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
> +		DUMPREG(dss, DSS_SDI_CONTROL);
> +		DUMPREG(dss, DSS_PLL_CONTROL);
> +		DUMPREG(dss, DSS_SDI_STATUS);
>  	}
>  
> -	dss_runtime_put(&dss);
> +	dss_runtime_put(dss);
>  #undef DUMPREG
>  	return 0;
>  }
> @@ -441,7 +444,8 @@ static int dss_get_channel_index(enum omap_channel channel)
>  	}
>  }
>  
> -static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
> +static void dss_select_dispc_clk_source(struct dss_device *dss,
> +					enum dss_clk_source clk_src)
>  {
>  	int b;
>  
> @@ -449,7 +453,7 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
>  	 * We always use PRCM clock as the DISPC func clock, except on DSS3,
>  	 * where we don't have separate DISPC and LCD clock sources.
>  	 */
> -	if (WARN_ON(dss.feat->has_lcd_clk_src && clk_src != DSS_CLK_SRC_FCK))
> +	if (WARN_ON(dss->feat->has_lcd_clk_src && clk_src != DSS_CLK_SRC_FCK))
>  		return;
>  
>  	switch (clk_src) {
> @@ -467,11 +471,11 @@ static void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
>  		return;
>  	}
>  
> -	REG_FLD_MOD(DSS_CONTROL, b,			/* DISPC_CLK_SWITCH */
> -		    dss.feat->dispc_clk_switch.start,
> -		    dss.feat->dispc_clk_switch.end);
> +	REG_FLD_MOD(dss, DSS_CONTROL, b,		/* DISPC_CLK_SWITCH */
> +		    dss->feat->dispc_clk_switch.start,
> +		    dss->feat->dispc_clk_switch.end);
>  
> -	dss.dispc_clk_source = clk_src;
> +	dss->dispc_clk_source = clk_src;
>  }
>  
>  void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
> @@ -497,7 +501,7 @@ void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
>  	}
>  
>  	pos = dsi_module == 0 ? 1 : 10;
> -	REG_FLD_MOD(DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
> +	REG_FLD_MOD(dss, DSS_CONTROL, b, pos, pos);	/* DSIx_CLK_SWITCH */
>  
>  	dss->dsi_clk_source[dsi_module] = clk_src;
>  }
> @@ -517,15 +521,15 @@ static int dss_lcd_clk_mux_dra7(struct dss_device *dss,
>  
>  	if (clk_src == DSS_CLK_SRC_FCK) {
>  		/* LCDx_CLK_SWITCH */
> -		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
> +		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
>  		return -EINVAL;
>  	}
>  
> -	r = dss_ctrl_pll_set_control_mux(clk_src, channel);
> +	r = dss_ctrl_pll_set_control_mux(dss, clk_src, channel);
>  	if (r)
>  		return r;
>  
> -	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
> +	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
>  
>  	return 0;
>  }
> @@ -549,14 +553,14 @@ static int dss_lcd_clk_mux_omap5(struct dss_device *dss,
>  
>  	if (clk_src == DSS_CLK_SRC_FCK) {
>  		/* LCDx_CLK_SWITCH */
> -		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
> +		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
>  		return -EINVAL;
>  	}
>  
>  	if (WARN_ON(allowed_plls[channel] != clk_src))
>  		return -EINVAL;
>  
> -	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
> +	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
>  
>  	return 0;
>  }
> @@ -578,14 +582,14 @@ static int dss_lcd_clk_mux_omap4(struct dss_device *dss,
>  
>  	if (clk_src == DSS_CLK_SRC_FCK) {
>  		/* LCDx_CLK_SWITCH */
> -		REG_FLD_MOD(DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
> +		REG_FLD_MOD(dss, DSS_CONTROL, 0, ctrl_bit, ctrl_bit);
>  		return 0;
>  	}
>  
>  	if (WARN_ON(allowed_plls[channel] != clk_src))
>  		return -EINVAL;
>  
> -	REG_FLD_MOD(DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
> +	REG_FLD_MOD(dss, DSS_CONTROL, 1, ctrl_bit, ctrl_bit);
>  
>  	return 0;
>  }
> @@ -598,7 +602,7 @@ void dss_select_lcd_clk_source(struct dss_device *dss,
>  	int r;
>  
>  	if (!dss->feat->has_lcd_clk_src) {
> -		dss_select_dispc_clk_source(clk_src);
> +		dss_select_dispc_clk_source(dss, clk_src);
>  		dss->lcd_clk_source[idx] = clk_src;
>  		return;
>  	}
> @@ -712,26 +716,26 @@ enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
>  	return dss->feat->outputs[channel];
>  }
>  
> -static int dss_setup_default_clock(void)
> +static int dss_setup_default_clock(struct dss_device *dss)
>  {
>  	unsigned long max_dss_fck, prate;
>  	unsigned long fck;
>  	unsigned int fck_div;
>  	int r;
>  
> -	max_dss_fck = dss.feat->fck_freq_max;
> +	max_dss_fck = dss->feat->fck_freq_max;
>  
> -	if (dss.parent_clk == NULL) {
> -		fck = clk_round_rate(dss.dss_clk, max_dss_fck);
> +	if (dss->parent_clk == NULL) {
> +		fck = clk_round_rate(dss->dss_clk, max_dss_fck);
>  	} else {
> -		prate = clk_get_rate(dss.parent_clk);
> +		prate = clk_get_rate(dss->parent_clk);
>  
> -		fck_div = DIV_ROUND_UP(prate * dss.feat->dss_fck_multiplier,
> +		fck_div = DIV_ROUND_UP(prate * dss->feat->dss_fck_multiplier,
>  				max_dss_fck);
> -		fck = DIV_ROUND_UP(prate, fck_div) * dss.feat->dss_fck_multiplier;
> +		fck = DIV_ROUND_UP(prate, fck_div) * dss->feat->dss_fck_multiplier;
>  	}
>  
> -	r = dss_set_fck_rate(&dss, fck);
> +	r = dss_set_fck_rate(dss, fck);
>  	if (r)
>  		return r;
>  
> @@ -750,12 +754,13 @@ void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type)
>  		BUG();
>  
>  	/* venc out selection. 0 = comp, 1 = svideo */
> -	REG_FLD_MOD(DSS_CONTROL, l, 6, 6);
> +	REG_FLD_MOD(dss, DSS_CONTROL, l, 6, 6);
>  }
>  
>  void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable)
>  {
> -	REG_FLD_MOD(DSS_CONTROL, enable, 5, 5);	/* DAC Power-Down Control */
> +	/* DAC Power-Down Control */
> +	REG_FLD_MOD(dss, DSS_CONTROL, enable, 5, 5);
>  }
>  
>  void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
> @@ -772,7 +777,8 @@ void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
>  	/* Select only if we have options */
>  	if ((outputs & OMAP_DSS_OUTPUT_VENC) &&
>  	    (outputs & OMAP_DSS_OUTPUT_HDMI))
> -		REG_FLD_MOD(DSS_CONTROL, src, 15, 15);	/* VENC_HDMI_SWITCH */
> +		/* VENC_HDMI_SWITCH */
> +		REG_FLD_MOD(dss, DSS_CONTROL, src, 15, 15);
>  }
>  
>  static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
> @@ -800,7 +806,7 @@ static int dss_dpi_select_source_omap4(struct dss_device *dss, int port,
>  		return -EINVAL;
>  	}
>  
> -	REG_FLD_MOD(DSS_CONTROL, val, 17, 17);
> +	REG_FLD_MOD(dss, DSS_CONTROL, val, 17, 17);
>  
>  	return 0;
>  }
> @@ -827,7 +833,7 @@ static int dss_dpi_select_source_omap5(struct dss_device *dss, int port,
>  		return -EINVAL;
>  	}
>  
> -	REG_FLD_MOD(DSS_CONTROL, val, 17, 16);
> +	REG_FLD_MOD(dss, DSS_CONTROL, val, 17, 16);
>  
>  	return 0;
>  }
> @@ -859,37 +865,37 @@ int dss_dpi_select_source(struct dss_device *dss, int port,
>  	return dss->feat->ops->dpi_select_source(dss, port, channel);
>  }
>  
> -static int dss_get_clocks(void)
> +static int dss_get_clocks(struct dss_device *dss)
>  {
>  	struct clk *clk;
>  
> -	clk = devm_clk_get(&dss.pdev->dev, "fck");
> +	clk = devm_clk_get(&dss->pdev->dev, "fck");
>  	if (IS_ERR(clk)) {
>  		DSSERR("can't get clock fck\n");
>  		return PTR_ERR(clk);
>  	}
>  
> -	dss.dss_clk = clk;
> +	dss->dss_clk = clk;
>  
> -	if (dss.feat->parent_clk_name) {
> -		clk = clk_get(NULL, dss.feat->parent_clk_name);
> +	if (dss->feat->parent_clk_name) {
> +		clk = clk_get(NULL, dss->feat->parent_clk_name);
>  		if (IS_ERR(clk)) {
> -			DSSERR("Failed to get %s\n", dss.feat->parent_clk_name);
> +			DSSERR("Failed to get %s\n", dss->feat->parent_clk_name);
>  			return PTR_ERR(clk);
>  		}
>  	} else {
>  		clk = NULL;
>  	}
>  
> -	dss.parent_clk = clk;
> +	dss->parent_clk = clk;
>  
>  	return 0;
>  }
>  
> -static void dss_put_clocks(void)
> +static void dss_put_clocks(struct dss_device *dss)
>  {
> -	if (dss.parent_clk)
> -		clk_put(dss.parent_clk);
> +	if (dss->parent_clk)
> +		clk_put(dss->parent_clk);
>  }
>  
>  int dss_runtime_get(struct dss_device *dss)
> @@ -915,14 +921,16 @@ void dss_runtime_put(struct dss_device *dss)
>  
>  struct dss_device *dss_get_device(struct device *dev)
>  {
> -	return &dss;
> +	return dev_get_drvdata(dev);
>  }
>  
>  /* DEBUGFS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
>  static int dss_debug_dump_clocks(struct seq_file *s, void *p)
>  {
> -	dss_dump_clocks(s);
> +	struct dss_device *dss = s->private;
> +
> +	dss_dump_clocks(dss, s);
>  	dispc_dump_clocks(s);
>  #ifdef CONFIG_OMAP2_DSS_DSI
>  	dsi_dump_clocks(s);
> @@ -932,7 +940,7 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
>  
>  static struct dentry *dss_debugfs_dir;
>  
> -static int dss_initialize_debugfs(void)
> +static int dss_initialize_debugfs(struct dss_device *dss)
>  {
>  	dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
>  	if (IS_ERR(dss_debugfs_dir)) {
> @@ -1005,7 +1013,7 @@ void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
>  }
>  
>  #else /* CONFIG_OMAP2_DSS_DEBUGFS */
> -static inline int dss_initialize_debugfs(void)
> +static inline int dss_initialize_debugfs(struct dss_device *dss)
>  {
>  	return 0;
>  }
> @@ -1210,23 +1218,24 @@ static const struct dss_features dra7xx_dss_feats = {
>  	.has_lcd_clk_src	=	true,
>  };
>  
> -static int dss_init_ports(struct platform_device *pdev)
> +static int dss_init_ports(struct dss_device *dss)
>  {
> +	struct platform_device *pdev = dss->pdev;
>  	struct device_node *parent = pdev->dev.of_node;
>  	struct device_node *port;
>  	int i;
>  
> -	for (i = 0; i < dss.feat->num_ports; i++) {
> +	for (i = 0; i < dss->feat->num_ports; i++) {
>  		port = of_graph_get_port_by_id(parent, i);
>  		if (!port)
>  			continue;
>  
> -		switch (dss.feat->ports[i]) {
> +		switch (dss->feat->ports[i]) {
>  		case OMAP_DISPLAY_TYPE_DPI:
> -			dpi_init_port(&dss, pdev, port, dss.feat->model);
> +			dpi_init_port(dss, pdev, port, dss->feat->model);
>  			break;
>  		case OMAP_DISPLAY_TYPE_SDI:
> -			sdi_init_port(&dss, pdev, port);
> +			sdi_init_port(dss, pdev, port);
>  			break;
>  		default:
>  			break;
> @@ -1236,18 +1245,19 @@ static int dss_init_ports(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static void dss_uninit_ports(struct platform_device *pdev)
> +static void dss_uninit_ports(struct dss_device *dss)
>  {
> +	struct platform_device *pdev = dss->pdev;
>  	struct device_node *parent = pdev->dev.of_node;
>  	struct device_node *port;
>  	int i;
>  
> -	for (i = 0; i < dss.feat->num_ports; i++) {
> +	for (i = 0; i < dss->feat->num_ports; i++) {
>  		port = of_graph_get_port_by_id(parent, i);
>  		if (!port)
>  			continue;
>  
> -		switch (dss.feat->ports[i]) {
> +		switch (dss->feat->ports[i]) {
>  		case OMAP_DISPLAY_TYPE_DPI:
>  			dpi_uninit_port(port);
>  			break;
> @@ -1260,8 +1270,9 @@ static void dss_uninit_ports(struct platform_device *pdev)
>  	}
>  }
>  
> -static int dss_video_pll_probe(struct platform_device *pdev)
> +static int dss_video_pll_probe(struct dss_device *dss)
>  {
> +	struct platform_device *pdev = dss->pdev;
>  	struct device_node *np = pdev->dev.of_node;
>  	struct regulator *pll_regulator;
>  	int r;
> @@ -1270,16 +1281,16 @@ static int dss_video_pll_probe(struct platform_device *pdev)
>  		return 0;
>  
>  	if (of_property_read_bool(np, "syscon-pll-ctrl")) {
> -		dss.syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np,
> +		dss->syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np,
>  			"syscon-pll-ctrl");
> -		if (IS_ERR(dss.syscon_pll_ctrl)) {
> +		if (IS_ERR(dss->syscon_pll_ctrl)) {
>  			dev_err(&pdev->dev,
>  				"failed to get syscon-pll-ctrl regmap\n");
> -			return PTR_ERR(dss.syscon_pll_ctrl);
> +			return PTR_ERR(dss->syscon_pll_ctrl);
>  		}
>  
>  		if (of_property_read_u32_index(np, "syscon-pll-ctrl", 1,
> -				&dss.syscon_pll_ctrl_offset)) {
> +				&dss->syscon_pll_ctrl_offset)) {
>  			dev_err(&pdev->dev,
>  				"failed to get syscon-pll-ctrl offset\n");
>  			return -EINVAL;
> @@ -1305,18 +1316,18 @@ static int dss_video_pll_probe(struct platform_device *pdev)
>  	}
>  
>  	if (of_property_match_string(np, "reg-names", "pll1") >= 0) {
> -		dss.video1_pll = dss_video_pll_init(&dss, pdev, 0,
> -						    pll_regulator);
> -		if (IS_ERR(dss.video1_pll))
> -			return PTR_ERR(dss.video1_pll);
> +		dss->video1_pll = dss_video_pll_init(dss, pdev, 0,
> +						     pll_regulator);
> +		if (IS_ERR(dss->video1_pll))
> +			return PTR_ERR(dss->video1_pll);
>  	}
>  
>  	if (of_property_match_string(np, "reg-names", "pll2") >= 0) {
> -		dss.video2_pll = dss_video_pll_init(&dss, pdev, 1,
> -						    pll_regulator);
> -		if (IS_ERR(dss.video2_pll)) {
> -			dss_video_pll_uninit(dss.video1_pll);
> -			return PTR_ERR(dss.video2_pll);
> +		dss->video2_pll = dss_video_pll_init(dss, pdev, 1,
> +						     pll_regulator);
> +		if (IS_ERR(dss->video2_pll)) {
> +			dss_video_pll_uninit(dss->video1_pll);
> +			return PTR_ERR(dss->video2_pll);
>  		}
>  	}
>  
> @@ -1344,117 +1355,119 @@ static const struct soc_device_attribute dss_soc_devices[] = {
>  static int dss_bind(struct device *dev)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> +	struct dss_device *dss = dev_get_drvdata(dev);
>  	struct resource *dss_mem;
>  	u32 rev;
>  	int r;
>  
> -	dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0);
> -	dss.base = devm_ioremap_resource(&pdev->dev, dss_mem);
> -	if (IS_ERR(dss.base))
> -		return PTR_ERR(dss.base);
> +	dss_mem = platform_get_resource(dss->pdev, IORESOURCE_MEM, 0);
> +	dss->base = devm_ioremap_resource(&pdev->dev, dss_mem);
> +	if (IS_ERR(dss->base))
> +		return PTR_ERR(dss->base);
>  
> -	r = dss_get_clocks();
> +	r = dss_get_clocks(dss);
>  	if (r)
>  		return r;
>  
> -	r = dss_setup_default_clock();
> +	r = dss_setup_default_clock(dss);
>  	if (r)
>  		goto err_setup_clocks;
>  
> -	r = dss_video_pll_probe(pdev);
> +	r = dss_video_pll_probe(dss);
>  	if (r)
>  		goto err_pll_init;
>  
> -	r = dss_init_ports(pdev);
> +	r = dss_init_ports(dss);
>  	if (r)
>  		goto err_init_ports;
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	r = dss_runtime_get(&dss);
> +	r = dss_runtime_get(dss);
>  	if (r)
>  		goto err_runtime_get;
>  
> -	dss.dss_clk_rate = clk_get_rate(dss.dss_clk);
> +	dss->dss_clk_rate = clk_get_rate(dss->dss_clk);
>  
>  	/* Select DPLL */
> -	REG_FLD_MOD(DSS_CONTROL, 0, 0, 0);
> +	REG_FLD_MOD(dss, DSS_CONTROL, 0, 0, 0);
>  
> -	dss_select_dispc_clk_source(DSS_CLK_SRC_FCK);
> +	dss_select_dispc_clk_source(dss, DSS_CLK_SRC_FCK);
>  
>  #ifdef CONFIG_OMAP2_DSS_VENC
> -	REG_FLD_MOD(DSS_CONTROL, 1, 4, 4);	/* venc dac demen */
> -	REG_FLD_MOD(DSS_CONTROL, 1, 3, 3);	/* venc clock 4x enable */
> -	REG_FLD_MOD(DSS_CONTROL, 0, 2, 2);	/* venc clock mode = normal */
> +	REG_FLD_MOD(dss, DSS_CONTROL, 1, 4, 4);	/* venc dac demen */
> +	REG_FLD_MOD(dss, DSS_CONTROL, 1, 3, 3);	/* venc clock 4x enable */
> +	REG_FLD_MOD(dss, DSS_CONTROL, 0, 2, 2);	/* venc clock mode = normal */
>  #endif
> -	dss.dsi_clk_source[0] = DSS_CLK_SRC_FCK;
> -	dss.dsi_clk_source[1] = DSS_CLK_SRC_FCK;
> -	dss.dispc_clk_source = DSS_CLK_SRC_FCK;
> -	dss.lcd_clk_source[0] = DSS_CLK_SRC_FCK;
> -	dss.lcd_clk_source[1] = DSS_CLK_SRC_FCK;
> +	dss->dsi_clk_source[0] = DSS_CLK_SRC_FCK;
> +	dss->dsi_clk_source[1] = DSS_CLK_SRC_FCK;
> +	dss->dispc_clk_source = DSS_CLK_SRC_FCK;
> +	dss->lcd_clk_source[0] = DSS_CLK_SRC_FCK;
> +	dss->lcd_clk_source[1] = DSS_CLK_SRC_FCK;
>  
> -	rev = dss_read_reg(DSS_REVISION);
> +	rev = dss_read_reg(dss, DSS_REVISION);
>  	pr_info("OMAP DSS rev %d.%d\n", FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
> -	dss_runtime_put(&dss);
> +	dss_runtime_put(dss);
>  
>  	r = component_bind_all(&pdev->dev, NULL);
>  	if (r)
>  		goto err_component;
>  
> -	dss.debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
> -						  &dss);
> -	dss.debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, &dss);
> +	dss->debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
> +						   dss);
> +	dss->debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, dss);
>  
>  	pm_set_vt_switch(0);
>  
>  	omapdss_gather_components(dev);
>  
> -	r = omapdrm_init(&dss.drm, dev);
> +	r = omapdrm_init(&dss->drm, dev);
>  	if (r)
>  		goto err_drm_init;
>  
>  	return 0;
>  
>  err_drm_init:
> -	dss_debugfs_remove_file(dss.debugfs.clk);
> -	dss_debugfs_remove_file(dss.debugfs.dss);
> +	dss_debugfs_remove_file(dss->debugfs.clk);
> +	dss_debugfs_remove_file(dss->debugfs.dss);
>  	component_unbind_all(&pdev->dev, NULL);
>  err_component:
>  err_runtime_get:
>  	pm_runtime_disable(&pdev->dev);
> -	dss_uninit_ports(pdev);
> +	dss_uninit_ports(dss);
>  err_init_ports:
> -	if (dss.video1_pll)
> -		dss_video_pll_uninit(dss.video1_pll);
> +	if (dss->video1_pll)
> +		dss_video_pll_uninit(dss->video1_pll);
>  
> -	if (dss.video2_pll)
> -		dss_video_pll_uninit(dss.video2_pll);
> +	if (dss->video2_pll)
> +		dss_video_pll_uninit(dss->video2_pll);
>  err_pll_init:
>  err_setup_clocks:
> -	dss_put_clocks();
> +	dss_put_clocks(dss);
>  	return r;
>  }
>  
>  static void dss_unbind(struct device *dev)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> +	struct dss_device *dss = dev_get_drvdata(dev);
>  
> -	omapdrm_cleanup(&dss.drm);
> +	omapdrm_cleanup(&dss->drm);
>  
>  	component_unbind_all(&pdev->dev, NULL);
>  
> -	if (dss.video1_pll)
> -		dss_video_pll_uninit(dss.video1_pll);
> +	if (dss->video1_pll)
> +		dss_video_pll_uninit(dss->video1_pll);
>  
> -	if (dss.video2_pll)
> -		dss_video_pll_uninit(dss.video2_pll);
> +	if (dss->video2_pll)
> +		dss_video_pll_uninit(dss->video2_pll);
>  
> -	dss_uninit_ports(pdev);
> +	dss_uninit_ports(dss);
>  
>  	pm_runtime_disable(&pdev->dev);
>  
> -	dss_put_clocks();
> +	dss_put_clocks(dss);
>  }
>  
>  static const struct component_master_ops dss_component_ops = {
> @@ -1490,14 +1503,20 @@ static int dss_probe(struct platform_device *pdev)
>  {
>  	const struct soc_device_attribute *soc;
>  	struct component_match *match = NULL;
> +	struct dss_device *dss;
>  	int r;
>  
> -	dss.pdev = pdev;
> +	dss = kzalloc(sizeof(*dss), GFP_KERNEL);
> +	if (!dss)
> +		return -ENOMEM;
> +
> +	dss->pdev = pdev;
> +	platform_set_drvdata(pdev, dss);
>  
>  	r = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> -		return r;
> +		goto err_free_dss;
>  	}
>  
>  	/*
> @@ -1506,31 +1525,38 @@ static int dss_probe(struct platform_device *pdev)
>  	 */
>  	soc = soc_device_match(dss_soc_devices);
>  	if (soc)
> -		dss.feat = soc->data;
> +		dss->feat = soc->data;
>  	else
> -		dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
> +		dss->feat = of_match_device(dss_of_match, &pdev->dev)->data;
>  
> -	r = dss_initialize_debugfs();
> +	r = dss_initialize_debugfs(dss);
>  	if (r)
> -		return r;
> +		goto err_free_dss;
>  
>  	/* add all the child devices as components */
>  	device_for_each_child(&pdev->dev, &match, dss_add_child_component);
>  
>  	r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match);
> -	if (r) {
> -		dss_uninitialize_debugfs();
> -		return r;
> -	}
> +	if (r)
> +		goto err_debugfs;
>  
>  	return 0;
> +
> +err_debugfs:
> +	dss_uninitialize_debugfs();
> +err_free_dss:
> +	kfree(dss);
> +	return r;
>  }
>  
>  static int dss_remove(struct platform_device *pdev)
>  {
> +	struct dss_device *dss = platform_get_drvdata(pdev);
> +
>  	component_master_del(&pdev->dev, &dss_component_ops);
>  
>  	dss_uninitialize_debugfs();
> +	kfree(dss);
>  
>  	return 0;
>  }
> @@ -1552,7 +1578,9 @@ static void dss_shutdown(struct platform_device *pdev)
>  
>  static int dss_runtime_suspend(struct device *dev)
>  {
> -	dss_save_context();
> +	struct dss_device *dss = dev_get_drvdata(dev);
> +
> +	dss_save_context(dss);
>  	dss_set_min_bus_tput(dev, 0);
>  
>  	pinctrl_pm_select_sleep_state(dev);
> @@ -1562,6 +1590,7 @@ static int dss_runtime_suspend(struct device *dev)
>  
>  static int dss_runtime_resume(struct device *dev)
>  {
> +	struct dss_device *dss = dev_get_drvdata(dev);
>  	int r;
>  
>  	pinctrl_pm_select_default_state(dev);
> @@ -1577,18 +1606,22 @@ static int dss_runtime_resume(struct device *dev)
>  	if (r)
>  		return r;
>  
> -	dss_restore_context();
> +	dss_restore_context(dss);
>  	return 0;
>  }
>  
>  static int dss_suspend(struct device *dev)
>  {
> -	return omap_drm_suspend(&dss.drm);
> +	struct dss_device *dss = dev_get_drvdata(dev);
> +
> +	return omap_drm_suspend(&dss->drm);
>  }
>  
>  static int dss_resume(struct device *dev)
>  {
> -	return omap_drm_resume(&dss.drm);
> +	struct dss_device *dss = dev_get_drvdata(dev);
> +
> +	return omap_drm_resume(&dss->drm);
>  }
>  
>  static const struct dev_pm_ops dss_pm_ops = {
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  2017-10-13 14:59 ` [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
@ 2017-10-16 10:19   ` Sebastian Reichel
  2017-10-16 10:27   ` Sebastian Reichel
  1 sibling, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16 10:19 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 24229 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:27PM +0300, Laurent Pinchart wrote:
> The omap_hdmi private data structure is currently stored as a global
> variable. While no platform with multiple HDMI4 encoders currently
> exists nor is planned, this doesn't comply with the kernel device model
> and should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/hdmi.h       |   2 +
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c      | 337 +++++++++++++++++--------------
>  drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c  |   4 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi4_core.h |   4 +-
>  4 files changed, 188 insertions(+), 159 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index fa2fbdaa427c..3aeb4cabd59f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -389,4 +389,6 @@ struct omap_hdmi {
>  	bool display_enabled;
>  };
>  
> +#define dssdev_to_hdmi(dssdev) container_of(dssdev, struct omap_hdmi, output)
> +
>  #endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 5806587fd89a..f0a30b248a7d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -44,15 +44,13 @@
>  #include "dss.h"
>  #include "hdmi.h"
>  
> -static struct omap_hdmi hdmi;
> -
> -static int hdmi_runtime_get(void)
> +static int hdmi_runtime_get(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
>  	DSSDBG("hdmi_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&hdmi.pdev->dev);
> +	r = pm_runtime_get_sync(&hdmi->pdev->dev);
>  	WARN_ON(r < 0);
>  	if (r < 0)
>  		return r;
> @@ -60,13 +58,13 @@ static int hdmi_runtime_get(void)
>  	return 0;
>  }
>  
> -static void hdmi_runtime_put(void)
> +static void hdmi_runtime_put(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
>  	DSSDBG("hdmi_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&hdmi.pdev->dev);
> +	r = pm_runtime_put_sync(&hdmi->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> @@ -109,14 +107,14 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static int hdmi_init_regulator(void)
> +static int hdmi_init_regulator(struct omap_hdmi *hdmi)
>  {
>  	struct regulator *reg;
>  
> -	if (hdmi.vdda_reg != NULL)
> +	if (hdmi->vdda_reg != NULL)
>  		return 0;
>  
> -	reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
> +	reg = devm_regulator_get(&hdmi->pdev->dev, "vdda");
>  
>  	if (IS_ERR(reg)) {
>  		if (PTR_ERR(reg) != -EPROBE_DEFER)
> @@ -124,64 +122,64 @@ static int hdmi_init_regulator(void)
>  		return PTR_ERR(reg);
>  	}
>  
> -	hdmi.vdda_reg = reg;
> +	hdmi->vdda_reg = reg;
>  
>  	return 0;
>  }
>  
> -static int hdmi_power_on_core(struct omap_dss_device *dssdev)
> +static int hdmi_power_on_core(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
> -	if (hdmi.core.core_pwr_cnt++)
> +	if (hdmi->core.core_pwr_cnt++)
>  		return 0;
>  
> -	r = regulator_enable(hdmi.vdda_reg);
> +	r = regulator_enable(hdmi->vdda_reg);
>  	if (r)
>  		goto err_reg_enable;
>  
> -	r = hdmi_runtime_get();
> +	r = hdmi_runtime_get(hdmi);
>  	if (r)
>  		goto err_runtime_get;
>  
> -	hdmi4_core_powerdown_disable(&hdmi.core);
> +	hdmi4_core_powerdown_disable(&hdmi->core);
>  
>  	/* Make selection of HDMI in DSS */
> -	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
> +	dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
>  
> -	hdmi.core_enabled = true;
> +	hdmi->core_enabled = true;
>  
>  	return 0;
>  
>  err_runtime_get:
> -	regulator_disable(hdmi.vdda_reg);
> +	regulator_disable(hdmi->vdda_reg);
>  err_reg_enable:
> -	hdmi.core.core_pwr_cnt--;
> +	hdmi->core.core_pwr_cnt--;
>  
>  	return r;
>  }
>  
> -static void hdmi_power_off_core(struct omap_dss_device *dssdev)
> +static void hdmi_power_off_core(struct omap_hdmi *hdmi)
>  {
> -	if (--hdmi.core.core_pwr_cnt)
> +	if (--hdmi->core.core_pwr_cnt)
>  		return;
>  
> -	hdmi.core_enabled = false;
> +	hdmi->core_enabled = false;
>  
> -	hdmi_runtime_put();
> -	regulator_disable(hdmi.vdda_reg);
> +	hdmi_runtime_put(hdmi);
> +	regulator_disable(hdmi->vdda_reg);
>  }
>  
> -static int hdmi_power_on_full(struct omap_dss_device *dssdev)
> +static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  	struct videomode *vm;
> -	enum omap_channel channel = dssdev->dispc_channel;
> -	struct hdmi_wp_data *wp = &hdmi.wp;
> +	enum omap_channel channel = hdmi->output.dispc_channel;
> +	struct hdmi_wp_data *wp = &hdmi->wp;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
>  	unsigned int pc;
>  
> -	r = hdmi_power_on_core(dssdev);
> +	r = hdmi_power_on_core(hdmi);
>  	if (r)
>  		return r;
>  
> @@ -189,7 +187,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	hdmi_wp_clear_irqenable(wp, ~HDMI_IRQ_CORE);
>  	hdmi_wp_set_irqstatus(wp, ~HDMI_IRQ_CORE);
>  
> -	vm = &hdmi.cfg.vm;
> +	vm = &hdmi->cfg.vm;
>  
>  	DSSDBG("hdmi_power_on hactive= %d vactive = %d\n", vm->hactive,
>  	       vm->vactive);
> @@ -201,22 +199,22 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	/* DSS_HDMI_TCLK is bitclk / 10 */
>  	pc *= 10;
>  
> -	dss_pll_calc_b(&hdmi.pll.pll, clk_get_rate(hdmi.pll.pll.clkin),
> +	dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
>  		pc, &hdmi_cinfo);
>  
> -	r = dss_pll_enable(&hdmi.pll.pll);
> +	r = dss_pll_enable(&hdmi->pll.pll);
>  	if (r) {
>  		DSSERR("Failed to enable PLL\n");
>  		goto err_pll_enable;
>  	}
>  
> -	r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo);
> +	r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
>  	if (r) {
>  		DSSERR("Failed to configure PLL\n");
>  		goto err_pll_cfg;
>  	}
>  
> -	r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco,
> +	r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
>  		hdmi_cinfo.clkout[0]);
>  	if (r) {
>  		DSSDBG("Failed to configure PHY\n");
> @@ -227,7 +225,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_phy_pwr;
>  
> -	hdmi4_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
> +	hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
>  
>  	/* tv size */
>  	dss_mgr_set_timings(channel, vm);
> @@ -236,7 +234,7 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_mgr_enable;
>  
> -	r = hdmi_wp_video_start(&hdmi.wp);
> +	r = hdmi_wp_video_start(&hdmi->wp);
>  	if (r)
>  		goto err_vid_enable;
>  
> @@ -248,31 +246,31 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  err_vid_enable:
>  	dss_mgr_disable(channel);
>  err_mgr_enable:
> -	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
> +	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  err_phy_pwr:
>  err_phy_cfg:
>  err_pll_cfg:
> -	dss_pll_disable(&hdmi.pll.pll);
> +	dss_pll_disable(&hdmi->pll.pll);
>  err_pll_enable:
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  	return -EIO;
>  }
>  
> -static void hdmi_power_off_full(struct omap_dss_device *dssdev)
> +static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = hdmi->output.dispc_channel;
>  
> -	hdmi_wp_clear_irqenable(&hdmi.wp, ~HDMI_IRQ_CORE);
> +	hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
>  
> -	hdmi_wp_video_stop(&hdmi.wp);
> +	hdmi_wp_video_stop(&hdmi->wp);
>  
>  	dss_mgr_disable(channel);
>  
> -	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
> +	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  
> -	dss_pll_disable(&hdmi.pll.pll);
> +	dss_pll_disable(&hdmi->pll.pll);
>  
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  }
>  
>  static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
> @@ -287,53 +285,59 @@ static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
>  static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
>  				    struct videomode *vm)
>  {
> -	mutex_lock(&hdmi.lock);
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	mutex_lock(&hdmi->lock);
>  
> -	hdmi.cfg.vm = *vm;
> +	hdmi->cfg.vm = *vm;
>  
>  	dispc_set_tv_pclk(vm->pixelclock);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
>  static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
>  				     struct videomode *vm)
>  {
> -	*vm = hdmi.cfg.vm;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	*vm = hdmi->cfg.vm;
>  }
>  
>  static int hdmi_dump_regs(struct seq_file *s, void *p)
>  {
> -	mutex_lock(&hdmi.lock);
> +	struct omap_hdmi *hdmi = s->private;
>  
> -	if (hdmi_runtime_get()) {
> -		mutex_unlock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
> +
> +	if (hdmi_runtime_get(hdmi)) {
> +		mutex_unlock(&hdmi->lock);
>  		return 0;
>  	}
>  
> -	hdmi_wp_dump(&hdmi.wp, s);
> -	hdmi_pll_dump(&hdmi.pll, s);
> -	hdmi_phy_dump(&hdmi.phy, s);
> -	hdmi4_core_dump(&hdmi.core, s);
> +	hdmi_wp_dump(&hdmi->wp, s);
> +	hdmi_pll_dump(&hdmi->pll, s);
> +	hdmi_phy_dump(&hdmi->phy, s);
> +	hdmi4_core_dump(&hdmi->core, s);
>  
> -	hdmi_runtime_put();
> -	mutex_unlock(&hdmi.lock);
> +	hdmi_runtime_put(hdmi);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  }
>  
> -static int read_edid(u8 *buf, int len)
> +static int read_edid(struct omap_hdmi *hdmi, u8 *buf, int len)
>  {
>  	int r;
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	r = hdmi_runtime_get();
> +	r = hdmi_runtime_get(hdmi);
>  	BUG_ON(r);
>  
> -	r = hdmi4_read_edid(&hdmi.core,  buf, len);
> +	r = hdmi4_read_edid(&hdmi->core,  buf, len);
>  
> -	hdmi_runtime_put();
> -	mutex_unlock(&hdmi.lock);
> +	hdmi_runtime_put(hdmi);
> +	mutex_unlock(&hdmi->lock);
>  
>  	return r;
>  }
> @@ -352,108 +356,113 @@ static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
>  
>  static int hdmi_display_enable(struct omap_dss_device *dssdev)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	unsigned long flags;
>  	int r = 0;
>  
>  	DSSDBG("ENTER hdmi_display_enable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	if (!out->dispc_channel_connected) {
> +	if (!dssdev->dispc_channel_connected) {
>  		DSSERR("failed to enable display: no output/manager\n");
>  		r = -ENODEV;
>  		goto err0;
>  	}
>  
> -	r = hdmi_power_on_full(dssdev);
> +	r = hdmi_power_on_full(hdmi);
>  	if (r) {
>  		DSSERR("failed to power on device\n");
>  		goto err0;
>  	}
>  
> -	if (hdmi.audio_configured) {
> -		r = hdmi4_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
> -				       hdmi.cfg.vm.pixelclock);
> +	if (hdmi->audio_configured) {
> +		r = hdmi4_audio_config(&hdmi->core, &hdmi->wp, &hdmi->audio_config,
> +				       hdmi->cfg.vm.pixelclock);
>  		if (r) {
>  			DSSERR("Error restoring audio configuration: %d", r);
> -			hdmi.audio_abort_cb(&hdmi.pdev->dev);
> -			hdmi.audio_configured = false;
> +			hdmi->audio_abort_cb(&hdmi->pdev->dev);
> +			hdmi->audio_configured = false;
>  		}
>  	}
>  
> -	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
> -	if (hdmi.audio_configured && hdmi.audio_playing)
> -		hdmi_start_audio_stream(&hdmi);
> -	hdmi.display_enabled = true;
> -	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
> +	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
> +	if (hdmi->audio_configured && hdmi->audio_playing)
> +		hdmi_start_audio_stream(hdmi);
> +	hdmi->display_enabled = true;
> +	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  
>  err0:
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return r;
>  }
>  
>  static void hdmi_display_disable(struct omap_dss_device *dssdev)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	unsigned long flags;
>  
>  	DSSDBG("Enter hdmi_display_disable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
> -	hdmi_stop_audio_stream(&hdmi);
> -	hdmi.display_enabled = false;
> -	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
> +	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
> +	hdmi_stop_audio_stream(hdmi);
> +	hdmi->display_enabled = false;
> +	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
>  
> -	hdmi_power_off_full(dssdev);
> +	hdmi_power_off_full(hdmi);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
> -int hdmi4_core_enable(struct omap_dss_device *dssdev)
> +int hdmi4_core_enable(struct hdmi_core_data *core)
>  {
> +	struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
>  	int r = 0;
>  
>  	DSSDBG("ENTER omapdss_hdmi4_core_enable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	r = hdmi_power_on_core(dssdev);
> +	r = hdmi_power_on_core(hdmi);
>  	if (r) {
>  		DSSERR("failed to power on device\n");
>  		goto err0;
>  	}
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  
>  err0:
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return r;
>  }
>  
> -void hdmi4_core_disable(struct omap_dss_device *dssdev)
> +void hdmi4_core_disable(struct hdmi_core_data *core)
>  {
> +	struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
> +
>  	DSSDBG("Enter omapdss_hdmi4_core_disable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
>  static int hdmi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
> -	r = hdmi_init_regulator();
> +	r = hdmi_init_regulator(hdmi);
>  	if (r)
>  		return r;
>  
> @@ -490,45 +499,52 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  static int hdmi_read_edid(struct omap_dss_device *dssdev,
>  		u8 *edid, int len)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	bool need_enable;
>  	int r;
>  
> -	need_enable = hdmi.core_enabled == false;
> +	need_enable = hdmi->core_enabled == false;
>  
>  	if (need_enable) {
> -		r = hdmi4_core_enable(dssdev);
> +		r = hdmi4_core_enable(&hdmi->core);
>  		if (r)
>  			return r;
>  	}
>  
> -	r = read_edid(edid, len);
> +	r = read_edid(hdmi, edid, len);
>  	if (r >= 256)
> -		hdmi4_cec_set_phys_addr(&hdmi.core,
> +		hdmi4_cec_set_phys_addr(&hdmi->core,
>  					cec_get_edid_phys_addr(edid, r, NULL));
>  	else
> -		hdmi4_cec_set_phys_addr(&hdmi.core, CEC_PHYS_ADDR_INVALID);
> +		hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
>  	if (need_enable)
> -		hdmi4_core_disable(dssdev);
> +		hdmi4_core_disable(&hdmi->core);
>  
>  	return r;
>  }
>  
>  static void hdmi_lost_hotplug(struct omap_dss_device *dssdev)
>  {
> -	hdmi4_cec_set_phys_addr(&hdmi.core, CEC_PHYS_ADDR_INVALID);
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
>  }
>  
>  static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
>  		const struct hdmi_avi_infoframe *avi)
>  {
> -	hdmi.cfg.infoframe = *avi;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	hdmi->cfg.infoframe = *avi;
>  	return 0;
>  }
>  
>  static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
>  		bool hdmi_mode)
>  {
> -	hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
>  	return 0;
>  }
>  
> @@ -549,14 +565,14 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
>  	.set_hdmi_mode		= hdmi_set_hdmi_mode,
>  };
>  
> -static void hdmi_init_output(struct platform_device *pdev)
> +static void hdmi_init_output(struct omap_hdmi *hdmi)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_dss_device *out = &hdmi->output;
>  
> -	out->dev = &pdev->dev;
> +	out->dev = &hdmi->pdev->dev;
>  	out->id = OMAP_DSS_OUTPUT_HDMI;
>  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
> -	out->name = "hdmi.0";
> +	out->name = "hdmi->0";
>  	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
>  	out->ops.hdmi = &hdmi_ops;
>  	out->owner = THIS_MODULE;
> @@ -564,15 +580,16 @@ static void hdmi_init_output(struct platform_device *pdev)
>  	omapdss_register_output(out);
>  }
>  
> -static void hdmi_uninit_output(struct platform_device *pdev)
> +static void hdmi_uninit_output(struct omap_hdmi *hdmi)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_dss_device *out = &hdmi->output;
>  
>  	omapdss_unregister_output(out);
>  }
>  
> -static int hdmi_probe_of(struct platform_device *pdev)
> +static int hdmi_probe_of(struct omap_hdmi *hdmi)
>  {
> +	struct platform_device *pdev = hdmi->pdev;
>  	struct device_node *node = pdev->dev.of_node;
>  	struct device_node *ep;
>  	int r;
> @@ -581,7 +598,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
>  	if (!ep)
>  		return 0;
>  
> -	r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
> +	r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
>  	if (r)
>  		goto err;
>  
> @@ -694,21 +711,21 @@ static const struct omap_hdmi_audio_ops hdmi_audio_ops = {
>  	.audio_config = hdmi_audio_config,
>  };
>  
> -static int hdmi_audio_register(struct device *dev)
> +static int hdmi_audio_register(struct omap_hdmi *hdmi)
>  {
>  	struct omap_hdmi_audio_pdata pdata = {
> -		.dev = dev,
> +		.dev = &hdmi->pdev->dev,
>  		.version = 4,
> -		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp),
> +		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
>  		.ops = &hdmi_audio_ops,
>  	};
>  
> -	hdmi.audio_pdev = platform_device_register_data(
> -		dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
> +	hdmi->audio_pdev = platform_device_register_data(
> +		&hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
>  		&pdata, sizeof(pdata));
>  
> -	if (IS_ERR(hdmi.audio_pdev))
> -		return PTR_ERR(hdmi.audio_pdev);
> +	if (IS_ERR(hdmi->audio_pdev))
> +		return PTR_ERR(hdmi->audio_pdev);
>  
>  	return 0;
>  }
> @@ -718,91 +735,101 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct dss_device *dss = dss_get_device(master);
> +	struct omap_hdmi *hdmi;
>  	int r;
>  	int irq;
>  
> -	hdmi.pdev = pdev;
> -	hdmi.dss = dss;
> -	dev_set_drvdata(&pdev->dev, &hdmi);
> +	hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
> +	if (!hdmi)
> +		return -ENOMEM;
> +
> +	hdmi->pdev = pdev;
> +	hdmi->dss = dss;
> +	dev_set_drvdata(&pdev->dev, hdmi);
>  
> -	mutex_init(&hdmi.lock);
> -	spin_lock_init(&hdmi.audio_playing_lock);
> +	mutex_init(&hdmi->lock);
> +	spin_lock_init(&hdmi->audio_playing_lock);
>  
> -	r = hdmi_probe_of(pdev);
> +	r = hdmi_probe_of(hdmi);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_wp_init(pdev, &hdmi.wp, 4);
> +	r = hdmi_wp_init(pdev, &hdmi->wp, 4);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
> +	r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_phy_init(pdev, &hdmi.phy, 4);
> +	r = hdmi_phy_init(pdev, &hdmi->phy, 4);
>  	if (r)
> -		goto err;
> +		goto err_pll;
>  
> -	r = hdmi4_core_init(pdev, &hdmi.core);
> +	r = hdmi4_core_init(pdev, &hdmi->core);
>  	if (r)
> -		goto err;
> +		goto err_pll;
>  
> -	r = hdmi4_cec_init(pdev, &hdmi.core, &hdmi.wp);
> +	r = hdmi4_cec_init(pdev, &hdmi->core, &hdmi->wp);
>  	if (r)
> -		goto err;
> +		goto err_pll;
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		DSSERR("platform_get_irq failed\n");
>  		r = -ENODEV;
> -		goto err;
> +		goto err_pll;
>  	}
>  
>  	r = devm_request_threaded_irq(&pdev->dev, irq,
>  			NULL, hdmi_irq_handler,
> -			IRQF_ONESHOT, "OMAP HDMI", &hdmi);
> +			IRQF_ONESHOT, "OMAP HDMI", hdmi);
>  	if (r) {
>  		DSSERR("HDMI IRQ request failed\n");
> -		goto err;
> +		goto err_pll;
>  	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	hdmi_init_output(pdev);
> +	hdmi_init_output(hdmi);
>  
> -	r = hdmi_audio_register(&pdev->dev);
> +	r = hdmi_audio_register(hdmi);
>  	if (r) {
>  		DSSERR("Registering HDMI audio failed\n");
> -		hdmi_uninit_output(pdev);
> +		hdmi_uninit_output(hdmi);
>  		pm_runtime_disable(&pdev->dev);
>  		return r;
>  	}
>  
> -	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
> +	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
>  
>  	return 0;
> -err:
> -	hdmi_pll_uninit(&hdmi.pll);
> +
> +err_pll:
> +	hdmi_pll_uninit(&hdmi->pll);
> +err_free:
> +	kfree(hdmi);
>  	return r;
>  }
>  
>  static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
> +
> +	dss_debugfs_remove_file(hdmi->debugfs);
>  
> -	dss_debugfs_remove_file(hdmi.debugfs);
> +	if (hdmi->audio_pdev)
> +		platform_device_unregister(hdmi->audio_pdev);
>  
> -	if (hdmi.audio_pdev)
> -		platform_device_unregister(hdmi.audio_pdev);
> +	hdmi_uninit_output(hdmi);
>  
> -	hdmi_uninit_output(pdev);
> +	hdmi4_cec_uninit(&hdmi->core);
>  
> -	hdmi4_cec_uninit(&hdmi.core);
> +	hdmi_pll_uninit(&hdmi->pll);
>  
> -	hdmi_pll_uninit(&hdmi.pll);
> +	pm_runtime_disable(dev);
>  
> -	pm_runtime_disable(&pdev->dev);
> +	kfree(hdmi);
>  }
>  
>  static const struct component_ops hdmi4_component_ops = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
> index d86873f2abe6..3e2c880dbadb 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
> @@ -199,10 +199,10 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
>  		REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
>  		hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
>  		hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
> -		hdmi4_core_disable(NULL);
> +		hdmi4_core_disable(core);
>  		return 0;
>  	}
> -	err = hdmi4_core_enable(NULL);
> +	err = hdmi4_core_enable(core);
>  	if (err)
>  		return err;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
> index b6ab579e44d2..337a317c1a27 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.h
> @@ -266,8 +266,8 @@ void hdmi4_configure(struct hdmi_core_data *core, struct hdmi_wp_data *wp,
>  void hdmi4_core_dump(struct hdmi_core_data *core, struct seq_file *s);
>  int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core);
>  
> -int hdmi4_core_enable(struct omap_dss_device *dssdev);
> -void hdmi4_core_disable(struct omap_dss_device *dssdev);
> +int hdmi4_core_enable(struct hdmi_core_data *core);
> +void hdmi4_core_disable(struct hdmi_core_data *core);
>  void hdmi4_core_powerdown_disable(struct hdmi_core_data *core);
>  
>  int hdmi4_audio_start(struct hdmi_core_data *core, struct hdmi_wp_data *wp);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  2017-10-13 14:59 ` [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
  2017-10-16 10:19   ` Sebastian Reichel
@ 2017-10-16 10:27   ` Sebastian Reichel
  2017-10-16 11:17     ` Laurent Pinchart
  1 sibling, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-16 10:27 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 930 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:27PM +0300, Laurent Pinchart wrote:
> The omap_hdmi private data structure is currently stored as a global
> variable. While no platform with multiple HDMI4 encoders currently
> exists nor is planned, this doesn't comply with the kernel device model
> and should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

[...]

> -static void hdmi_init_output(struct platform_device *pdev)
> +static void hdmi_init_output(struct omap_hdmi *hdmi)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_dss_device *out = &hdmi->output;
>  
> -	out->dev = &pdev->dev;
> +	out->dev = &hdmi->pdev->dev;
>  	out->id = OMAP_DSS_OUTPUT_HDMI;
>  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
> -	out->name = "hdmi.0";
> +	out->name = "hdmi->0";

I guess this was an unintended side-effect of "s/hdmi./hdmi->/g"?

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  2017-10-16 10:27   ` Sebastian Reichel
@ 2017-10-16 11:17     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-16 11:17 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Monday, 16 October 2017 13:27:57 EEST Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Oct 13, 2017 at 05:59:27PM +0300, Laurent Pinchart wrote:
> > The omap_hdmi private data structure is currently stored as a global
> > variable. While no platform with multiple HDMI4 encoders currently
> > exists nor is planned, this doesn't comply with the kernel device model
> > and should thus be fixed.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> 
> [...]
> 
> > -static void hdmi_init_output(struct platform_device *pdev)
> > +static void hdmi_init_output(struct omap_hdmi *hdmi)
> >  {
> > -	struct omap_dss_device *out = &hdmi.output;
> > +	struct omap_dss_device *out = &hdmi->output;
> > 
> > -	out->dev = &pdev->dev;
> > +	out->dev = &hdmi->pdev->dev;
> >  	out->id = OMAP_DSS_OUTPUT_HDMI;
> >  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
> > -	out->name = "hdmi.0";
> > +	out->name = "hdmi->0";
> 
> I guess this was an unintended side-effect of "s/hdmi./hdmi->/g"?

Indeed. I'll fix it in v2, as well as the same mistake in patch 32/48.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 32/48] drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically
  2017-10-13 14:59 ` [PATCH 32/48] drm: omapdrm: hdmi5: " Laurent Pinchart
@ 2017-10-17 18:52   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 18:52 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 23261 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:28PM +0300, Laurent Pinchart wrote:
> The omap_hdmi private data structure is currently stored as a global
> variable. While no platform with multiple HDMI5 encoders currently
> exists nor is planned, this doesn't comply with the kernel device model
> and should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/hdmi5.c | 345 +++++++++++++++++++-----------------
>  1 file changed, 184 insertions(+), 161 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index c28fe184a7ad..ed8a2bd2a035 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -46,15 +46,13 @@
>  #include "hdmi5_core.h"
>  #include "dss.h"
>  
> -static struct omap_hdmi hdmi;
> -
> -static int hdmi_runtime_get(void)
> +static int hdmi_runtime_get(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
>  	DSSDBG("hdmi_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&hdmi.pdev->dev);
> +	r = pm_runtime_get_sync(&hdmi->pdev->dev);
>  	WARN_ON(r < 0);
>  	if (r < 0)
>  		return r;
> @@ -62,19 +60,20 @@ static int hdmi_runtime_get(void)
>  	return 0;
>  }
>  
> -static void hdmi_runtime_put(void)
> +static void hdmi_runtime_put(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
>  	DSSDBG("hdmi_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&hdmi.pdev->dev);
> +	r = pm_runtime_put_sync(&hdmi->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
>  static irqreturn_t hdmi_irq_handler(int irq, void *data)
>  {
> -	struct hdmi_wp_data *wp = data;
> +	struct omap_hdmi *hdmi = data;
> +	struct hdmi_wp_data *wp = &hdmi->wp;
>  	u32 irqstatus;
>  
>  	irqstatus = hdmi_wp_get_irqstatus(wp);
> @@ -97,17 +96,17 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
>  		 * setting the PHY to LDOON. To ignore those, we force the RXDET
>  		 * line to 0 until the PHY power state has been changed.
>  		 */
> -		v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
> +		v = hdmi_read_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
>  		v = FLD_MOD(v, 1, 15, 15); /* FORCE_RXDET_HIGH */
>  		v = FLD_MOD(v, 0, 14, 7); /* RXDET_LINE */
> -		hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
> +		hdmi_write_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
>  
>  		hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
>  				HDMI_IRQ_LINK_DISCONNECT);
>  
>  		hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
>  
> -		REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
> +		REG_FLD_MOD(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
>  
>  	} else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
>  		hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
> @@ -118,70 +117,70 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static int hdmi_init_regulator(void)
> +static int hdmi_init_regulator(struct omap_hdmi *hdmi)
>  {
>  	struct regulator *reg;
>  
> -	if (hdmi.vdda_reg != NULL)
> +	if (hdmi->vdda_reg != NULL)
>  		return 0;
>  
> -	reg = devm_regulator_get(&hdmi.pdev->dev, "vdda");
> +	reg = devm_regulator_get(&hdmi->pdev->dev, "vdda");
>  	if (IS_ERR(reg)) {
>  		DSSERR("can't get VDDA regulator\n");
>  		return PTR_ERR(reg);
>  	}
>  
> -	hdmi.vdda_reg = reg;
> +	hdmi->vdda_reg = reg;
>  
>  	return 0;
>  }
>  
> -static int hdmi_power_on_core(struct omap_dss_device *dssdev)
> +static int hdmi_power_on_core(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  
> -	r = regulator_enable(hdmi.vdda_reg);
> +	r = regulator_enable(hdmi->vdda_reg);
>  	if (r)
>  		return r;
>  
> -	r = hdmi_runtime_get();
> +	r = hdmi_runtime_get(hdmi);
>  	if (r)
>  		goto err_runtime_get;
>  
>  	/* Make selection of HDMI in DSS */
> -	dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
> +	dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
>  
> -	hdmi.core_enabled = true;
> +	hdmi->core_enabled = true;
>  
>  	return 0;
>  
>  err_runtime_get:
> -	regulator_disable(hdmi.vdda_reg);
> +	regulator_disable(hdmi->vdda_reg);
>  
>  	return r;
>  }
>  
> -static void hdmi_power_off_core(struct omap_dss_device *dssdev)
> +static void hdmi_power_off_core(struct omap_hdmi *hdmi)
>  {
> -	hdmi.core_enabled = false;
> +	hdmi->core_enabled = false;
>  
> -	hdmi_runtime_put();
> -	regulator_disable(hdmi.vdda_reg);
> +	hdmi_runtime_put(hdmi);
> +	regulator_disable(hdmi->vdda_reg);
>  }
>  
> -static int hdmi_power_on_full(struct omap_dss_device *dssdev)
> +static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  	struct videomode *vm;
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = hdmi->output.dispc_channel;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
>  	unsigned int pc;
>  
> -	r = hdmi_power_on_core(dssdev);
> +	r = hdmi_power_on_core(hdmi);
>  	if (r)
>  		return r;
>  
> -	vm = &hdmi.cfg.vm;
> +	vm = &hdmi->cfg.vm;
>  
>  	DSSDBG("hdmi_power_on hactive= %d vactive = %d\n", vm->hactive,
>  	       vm->vactive);
> @@ -193,38 +192,38 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	/* DSS_HDMI_TCLK is bitclk / 10 */
>  	pc *= 10;
>  
> -	dss_pll_calc_b(&hdmi.pll.pll, clk_get_rate(hdmi.pll.pll.clkin),
> +	dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
>  		pc, &hdmi_cinfo);
>  
>  	/* disable and clear irqs */
> -	hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
> -	hdmi_wp_set_irqstatus(&hdmi.wp,
> -			hdmi_wp_get_irqstatus(&hdmi.wp));
> +	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
> +	hdmi_wp_set_irqstatus(&hdmi->wp,
> +			hdmi_wp_get_irqstatus(&hdmi->wp));
>  
> -	r = dss_pll_enable(&hdmi.pll.pll);
> +	r = dss_pll_enable(&hdmi->pll.pll);
>  	if (r) {
>  		DSSERR("Failed to enable PLL\n");
>  		goto err_pll_enable;
>  	}
>  
> -	r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo);
> +	r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
>  	if (r) {
>  		DSSERR("Failed to configure PLL\n");
>  		goto err_pll_cfg;
>  	}
>  
> -	r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco,
> +	r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
>  		hdmi_cinfo.clkout[0]);
>  	if (r) {
>  		DSSDBG("Failed to start PHY\n");
>  		goto err_phy_cfg;
>  	}
>  
> -	r = hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_LDOON);
> +	r = hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_LDOON);
>  	if (r)
>  		goto err_phy_pwr;
>  
> -	hdmi5_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
> +	hdmi5_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
>  
>  	/* tv size */
>  	dss_mgr_set_timings(channel, vm);
> @@ -233,11 +232,11 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_mgr_enable;
>  
> -	r = hdmi_wp_video_start(&hdmi.wp);
> +	r = hdmi_wp_video_start(&hdmi->wp);
>  	if (r)
>  		goto err_vid_enable;
>  
> -	hdmi_wp_set_irqenable(&hdmi.wp,
> +	hdmi_wp_set_irqenable(&hdmi->wp,
>  			HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
>  
>  	return 0;
> @@ -245,31 +244,31 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
>  err_vid_enable:
>  	dss_mgr_disable(channel);
>  err_mgr_enable:
> -	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
> +	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  err_phy_pwr:
>  err_phy_cfg:
>  err_pll_cfg:
> -	dss_pll_disable(&hdmi.pll.pll);
> +	dss_pll_disable(&hdmi->pll.pll);
>  err_pll_enable:
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  	return -EIO;
>  }
>  
> -static void hdmi_power_off_full(struct omap_dss_device *dssdev)
> +static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = hdmi->output.dispc_channel;
>  
> -	hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
> +	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
>  
> -	hdmi_wp_video_stop(&hdmi.wp);
> +	hdmi_wp_video_stop(&hdmi->wp);
>  
>  	dss_mgr_disable(channel);
>  
> -	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
> +	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  
> -	dss_pll_disable(&hdmi.pll.pll);
> +	dss_pll_disable(&hdmi->pll.pll);
>  
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  }
>  
>  static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
> @@ -284,67 +283,73 @@ static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
>  static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
>  				    struct videomode *vm)
>  {
> -	mutex_lock(&hdmi.lock);
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  
> -	hdmi.cfg.vm = *vm;
> +	mutex_lock(&hdmi->lock);
> +
> +	hdmi->cfg.vm = *vm;
>  
>  	dispc_set_tv_pclk(vm->pixelclock);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
>  static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
>  				     struct videomode *vm)
>  {
> -	*vm = hdmi.cfg.vm;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	*vm = hdmi->cfg.vm;
>  }
>  
>  static int hdmi_dump_regs(struct seq_file *s, void *p)
>  {
> -	mutex_lock(&hdmi.lock);
> +	struct omap_hdmi *hdmi = s->private;
>  
> -	if (hdmi_runtime_get()) {
> -		mutex_unlock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
> +
> +	if (hdmi_runtime_get(hdmi)) {
> +		mutex_unlock(&hdmi->lock);
>  		return 0;
>  	}
>  
> -	hdmi_wp_dump(&hdmi.wp, s);
> -	hdmi_pll_dump(&hdmi.pll, s);
> -	hdmi_phy_dump(&hdmi.phy, s);
> -	hdmi5_core_dump(&hdmi.core, s);
> +	hdmi_wp_dump(&hdmi->wp, s);
> +	hdmi_pll_dump(&hdmi->pll, s);
> +	hdmi_phy_dump(&hdmi->phy, s);
> +	hdmi5_core_dump(&hdmi->core, s);
>  
> -	hdmi_runtime_put();
> -	mutex_unlock(&hdmi.lock);
> +	hdmi_runtime_put(hdmi);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  }
>  
> -static int read_edid(u8 *buf, int len)
> +static int read_edid(struct omap_hdmi *hdmi, u8 *buf, int len)
>  {
>  	int r;
>  	int idlemode;
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	r = hdmi_runtime_get();
> +	r = hdmi_runtime_get(hdmi);
>  	BUG_ON(r);
>  
> -	idlemode = REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
> +	idlemode = REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
>  	/* No-idle mode */
> -	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
> +	REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
>  
> -	r = hdmi5_read_edid(&hdmi.core,  buf, len);
> +	r = hdmi5_read_edid(&hdmi->core,  buf, len);
>  
> -	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
> +	REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
>  
> -	hdmi_runtime_put();
> -	mutex_unlock(&hdmi.lock);
> +	hdmi_runtime_put(hdmi);
> +	mutex_unlock(&hdmi->lock);
>  
>  	return r;
>  }
>  
>  static void hdmi_start_audio_stream(struct omap_hdmi *hd)
>  {
> -	REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
> +	REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
>  	hdmi_wp_audio_enable(&hd->wp, true);
>  	hdmi_wp_audio_core_req_enable(&hd->wp, true);
>  }
> @@ -358,108 +363,110 @@ static void hdmi_stop_audio_stream(struct omap_hdmi *hd)
>  
>  static int hdmi_display_enable(struct omap_dss_device *dssdev)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	unsigned long flags;
>  	int r = 0;
>  
>  	DSSDBG("ENTER hdmi_display_enable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	if (!out->dispc_channel_connected) {
> +	if (!dssdev->dispc_channel_connected) {
>  		DSSERR("failed to enable display: no output/manager\n");
>  		r = -ENODEV;
>  		goto err0;
>  	}
>  
> -	r = hdmi_power_on_full(dssdev);
> +	r = hdmi_power_on_full(hdmi);
>  	if (r) {
>  		DSSERR("failed to power on device\n");
>  		goto err0;
>  	}
>  
> -	if (hdmi.audio_configured) {
> -		r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
> -				       hdmi.cfg.vm.pixelclock);
> +	if (hdmi->audio_configured) {
> +		r = hdmi5_audio_config(&hdmi->core, &hdmi->wp, &hdmi->audio_config,
> +				       hdmi->cfg.vm.pixelclock);
>  		if (r) {
>  			DSSERR("Error restoring audio configuration: %d", r);
> -			hdmi.audio_abort_cb(&hdmi.pdev->dev);
> -			hdmi.audio_configured = false;
> +			hdmi->audio_abort_cb(&hdmi->pdev->dev);
> +			hdmi->audio_configured = false;
>  		}
>  	}
>  
> -	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
> -	if (hdmi.audio_configured && hdmi.audio_playing)
> -		hdmi_start_audio_stream(&hdmi);
> -	hdmi.display_enabled = true;
> -	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
> +	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
> +	if (hdmi->audio_configured && hdmi->audio_playing)
> +		hdmi_start_audio_stream(hdmi);
> +	hdmi->display_enabled = true;
> +	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  
>  err0:
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return r;
>  }
>  
>  static void hdmi_display_disable(struct omap_dss_device *dssdev)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	unsigned long flags;
>  
>  	DSSDBG("Enter hdmi_display_disable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
> -	hdmi_stop_audio_stream(&hdmi);
> -	hdmi.display_enabled = false;
> -	spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
> +	spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
> +	hdmi_stop_audio_stream(hdmi);
> +	hdmi->display_enabled = false;
> +	spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
>  
> -	hdmi_power_off_full(dssdev);
> +	hdmi_power_off_full(hdmi);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
> -static int hdmi_core_enable(struct omap_dss_device *dssdev)
> +static int hdmi_core_enable(struct omap_hdmi *hdmi)
>  {
>  	int r = 0;
>  
>  	DSSDBG("ENTER omapdss_hdmi_core_enable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	r = hdmi_power_on_core(dssdev);
> +	r = hdmi_power_on_core(hdmi);
>  	if (r) {
>  		DSSERR("failed to power on device\n");
>  		goto err0;
>  	}
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return 0;
>  
>  err0:
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  	return r;
>  }
>  
> -static void hdmi_core_disable(struct omap_dss_device *dssdev)
> +static void hdmi_core_disable(struct omap_hdmi *hdmi)
>  {
>  	DSSDBG("Enter omapdss_hdmi_core_disable\n");
>  
> -	mutex_lock(&hdmi.lock);
> +	mutex_lock(&hdmi->lock);
>  
> -	hdmi_power_off_core(dssdev);
> +	hdmi_power_off_core(hdmi);
>  
> -	mutex_unlock(&hdmi.lock);
> +	mutex_unlock(&hdmi->lock);
>  }
>  
>  static int hdmi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
> -	r = hdmi_init_regulator();
> +	r = hdmi_init_regulator(hdmi);
>  	if (r)
>  		return r;
>  
> @@ -496,21 +503,22 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  static int hdmi_read_edid(struct omap_dss_device *dssdev,
>  		u8 *edid, int len)
>  {
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  	bool need_enable;
>  	int r;
>  
> -	need_enable = hdmi.core_enabled == false;
> +	need_enable = hdmi->core_enabled == false;
>  
>  	if (need_enable) {
> -		r = hdmi_core_enable(dssdev);
> +		r = hdmi_core_enable(hdmi);
>  		if (r)
>  			return r;
>  	}
>  
> -	r = read_edid(edid, len);
> +	r = read_edid(hdmi, edid, len);
>  
>  	if (need_enable)
> -		hdmi_core_disable(dssdev);
> +		hdmi_core_disable(hdmi);
>  
>  	return r;
>  }
> @@ -518,14 +526,18 @@ static int hdmi_read_edid(struct omap_dss_device *dssdev,
>  static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
>  		const struct hdmi_avi_infoframe *avi)
>  {
> -	hdmi.cfg.infoframe = *avi;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	hdmi->cfg.infoframe = *avi;
>  	return 0;
>  }
>  
>  static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
>  		bool hdmi_mode)
>  {
> -	hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI;
>  	return 0;
>  }
>  
> @@ -545,14 +557,14 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
>  	.set_hdmi_mode		= hdmi_set_hdmi_mode,
>  };
>  
> -static void hdmi_init_output(struct platform_device *pdev)
> +static void hdmi_init_output(struct omap_hdmi *hdmi)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_dss_device *out = &hdmi->output;
>  
> -	out->dev = &pdev->dev;
> +	out->dev = &hdmi->pdev->dev;
>  	out->id = OMAP_DSS_OUTPUT_HDMI;
>  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
> -	out->name = "hdmi.0";
> +	out->name = "hdmi->0";
>  	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
>  	out->ops.hdmi = &hdmi_ops;
>  	out->owner = THIS_MODULE;
> @@ -560,15 +572,16 @@ static void hdmi_init_output(struct platform_device *pdev)
>  	omapdss_register_output(out);
>  }
>  
> -static void hdmi_uninit_output(struct platform_device *pdev)
> +static void hdmi_uninit_output(struct omap_hdmi *hdmi)
>  {
> -	struct omap_dss_device *out = &hdmi.output;
> +	struct omap_dss_device *out = &hdmi->output;
>  
>  	omapdss_unregister_output(out);
>  }
>  
> -static int hdmi_probe_of(struct platform_device *pdev)
> +static int hdmi_probe_of(struct omap_hdmi *hdmi)
>  {
> +	struct platform_device *pdev = hdmi->pdev;
>  	struct device_node *node = pdev->dev.of_node;
>  	struct device_node *ep;
>  	int r;
> @@ -577,7 +590,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
>  	if (!ep)
>  		return 0;
>  
> -	r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy);
> +	r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
>  	if (r)
>  		goto err;
>  
> @@ -691,26 +704,26 @@ static const struct omap_hdmi_audio_ops hdmi_audio_ops = {
>  	.audio_config = hdmi_audio_config,
>  };
>  
> -static int hdmi_audio_register(struct device *dev)
> +static int hdmi_audio_register(struct omap_hdmi *hdmi)
>  {
>  	struct omap_hdmi_audio_pdata pdata = {
> -		.dev = dev,
> +		.dev = &hdmi->pdev->dev,
>  		.version = 5,
> -		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp),
> +		.audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
>  		.ops = &hdmi_audio_ops,
>  	};
>  
> -	hdmi.audio_pdev = platform_device_register_data(
> -		dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
> +	hdmi->audio_pdev = platform_device_register_data(
> +		&hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
>  		&pdata, sizeof(pdata));
>  
> -	if (IS_ERR(hdmi.audio_pdev))
> -		return PTR_ERR(hdmi.audio_pdev);
> +	if (IS_ERR(hdmi->audio_pdev))
> +		return PTR_ERR(hdmi->audio_pdev);
>  
> -	hdmi_runtime_get();
> -	hdmi.wp_idlemode =
> -		REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
> -	hdmi_runtime_put();
> +	hdmi_runtime_get(hdmi);
> +	hdmi->wp_idlemode =
> +		REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
> +	hdmi_runtime_put(hdmi);
>  
>  	return 0;
>  }
> @@ -720,85 +733,95 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct dss_device *dss = dss_get_device(master);
> +	struct omap_hdmi *hdmi;
>  	int r;
>  	int irq;
>  
> -	hdmi.pdev = pdev;
> -	hdmi.dss = dss;
> -	dev_set_drvdata(&pdev->dev, &hdmi);
> +	hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
> +	if (!hdmi)
> +		return -ENOMEM;
>  
> -	mutex_init(&hdmi.lock);
> -	spin_lock_init(&hdmi.audio_playing_lock);
> +	hdmi->pdev = pdev;
> +	hdmi->dss = dss;
> +	dev_set_drvdata(&pdev->dev, hdmi);
>  
> -	r = hdmi_probe_of(pdev);
> +	mutex_init(&hdmi->lock);
> +	spin_lock_init(&hdmi->audio_playing_lock);
> +
> +	r = hdmi_probe_of(hdmi);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_wp_init(pdev, &hdmi.wp, 5);
> +	r = hdmi_wp_init(pdev, &hdmi->wp, 5);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp);
> +	r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	r = hdmi_phy_init(pdev, &hdmi.phy, 5);
> +	r = hdmi_phy_init(pdev, &hdmi->phy, 5);
>  	if (r)
> -		goto err;
> +		goto err_pll;
>  
> -	r = hdmi5_core_init(pdev, &hdmi.core);
> +	r = hdmi5_core_init(pdev, &hdmi->core);
>  	if (r)
> -		goto err;
> +		goto err_pll;
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		DSSERR("platform_get_irq failed\n");
>  		r = -ENODEV;
> -		goto err;
> +		goto err_pll;
>  	}
>  
>  	r = devm_request_threaded_irq(&pdev->dev, irq,
>  			NULL, hdmi_irq_handler,
> -			IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp);
> +			IRQF_ONESHOT, "OMAP HDMI", hdmi);
>  	if (r) {
>  		DSSERR("HDMI IRQ request failed\n");
> -		goto err;
> +		goto err_pll;
>  	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	hdmi_init_output(pdev);
> +	hdmi_init_output(hdmi);
>  
> -	r = hdmi_audio_register(&pdev->dev);
> +	r = hdmi_audio_register(hdmi);
>  	if (r) {
>  		DSSERR("Registering HDMI audio failed %d\n", r);
> -		hdmi_uninit_output(pdev);
> +		hdmi_uninit_output(hdmi);
>  		pm_runtime_disable(&pdev->dev);
>  		return r;
>  	}
>  
> -	hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
> +	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
>  
>  	return 0;
> -err:
> -	hdmi_pll_uninit(&hdmi.pll);
> +
> +err_pll:
> +	hdmi_pll_uninit(&hdmi->pll);
> +err_free:
> +	kfree(hdmi);
>  	return r;
>  }
>  
>  static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
> +
> +	dss_debugfs_remove_file(hdmi->debugfs);
>  
> -	dss_debugfs_remove_file(hdmi.debugfs);
> +	if (hdmi->audio_pdev)
> +		platform_device_unregister(hdmi->audio_pdev);
>  
> -	if (hdmi.audio_pdev)
> -		platform_device_unregister(hdmi.audio_pdev);
> +	hdmi_uninit_output(hdmi);
>  
> -	hdmi_uninit_output(pdev);
> +	hdmi_pll_uninit(&hdmi->pll);
>  
> -	hdmi_pll_uninit(&hdmi.pll);
> +	pm_runtime_disable(dev);
>  
> -	pm_runtime_disable(&pdev->dev);
> +	kfree(hdmi);
>  }
>  
>  static const struct component_ops hdmi5_component_ops = {
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private data structure dynamically
  2017-10-13 14:59 ` [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private " Laurent Pinchart
@ 2017-10-17 18:52   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 18:52 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 26532 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:29PM +0300, Laurent Pinchart wrote:
> The venc private data structure is currently stored as a global
> variable. While no platform with multiple VENC encoders currently exists
> nor is planned, this doesn't comply with the kernel device model and
> should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/venc.c | 425 ++++++++++++++++++++-----------------
>  1 file changed, 228 insertions(+), 197 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 179ef73a5564..7acdbfefe397 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -321,7 +321,7 @@ static enum venc_videomode venc_get_videomode(const struct videomode *vm)
>  	return VENC_MODE_UNKNOWN;
>  }
>  
> -static struct {
> +struct venc_device {
>  	struct platform_device *pdev;
>  	void __iomem *base;
>  	struct mutex venc_lock;
> @@ -339,81 +339,87 @@ static struct {
>  	bool requires_tv_dac_clk;
>  
>  	struct omap_dss_device output;
> -} venc;
> +};
> +
> +#define dssdev_to_venc(dssdev) container_of(dssdev, struct venc_device, output)
>  
> -static inline void venc_write_reg(int idx, u32 val)
> +static inline void venc_write_reg(struct venc_device *venc, int idx, u32 val)
>  {
> -	__raw_writel(val, venc.base + idx);
> +	__raw_writel(val, venc->base + idx);
>  }
>  
> -static inline u32 venc_read_reg(int idx)
> +static inline u32 venc_read_reg(struct venc_device *venc, int idx)
>  {
> -	u32 l = __raw_readl(venc.base + idx);
> +	u32 l = __raw_readl(venc->base + idx);
>  	return l;
>  }
>  
> -static void venc_write_config(const struct venc_config *config)
> +static void venc_write_config(struct venc_device *venc,
> +			      const struct venc_config *config)
>  {
>  	DSSDBG("write venc conf\n");
>  
> -	venc_write_reg(VENC_LLEN, config->llen);
> -	venc_write_reg(VENC_FLENS, config->flens);
> -	venc_write_reg(VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
> -	venc_write_reg(VENC_C_PHASE, config->c_phase);
> -	venc_write_reg(VENC_GAIN_U, config->gain_u);
> -	venc_write_reg(VENC_GAIN_V, config->gain_v);
> -	venc_write_reg(VENC_GAIN_Y, config->gain_y);
> -	venc_write_reg(VENC_BLACK_LEVEL, config->black_level);
> -	venc_write_reg(VENC_BLANK_LEVEL, config->blank_level);
> -	venc_write_reg(VENC_M_CONTROL, config->m_control);
> -	venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
> -			venc.wss_data);
> -	venc_write_reg(VENC_S_CARR, config->s_carr);
> -	venc_write_reg(VENC_L21__WC_CTL, config->l21__wc_ctl);
> -	venc_write_reg(VENC_SAVID__EAVID, config->savid__eavid);
> -	venc_write_reg(VENC_FLEN__FAL, config->flen__fal);
> -	venc_write_reg(VENC_LAL__PHASE_RESET, config->lal__phase_reset);
> -	venc_write_reg(VENC_HS_INT_START_STOP_X, config->hs_int_start_stop_x);
> -	venc_write_reg(VENC_HS_EXT_START_STOP_X, config->hs_ext_start_stop_x);
> -	venc_write_reg(VENC_VS_INT_START_X, config->vs_int_start_x);
> -	venc_write_reg(VENC_VS_INT_STOP_X__VS_INT_START_Y,
> +	venc_write_reg(venc, VENC_LLEN, config->llen);
> +	venc_write_reg(venc, VENC_FLENS, config->flens);
> +	venc_write_reg(venc, VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
> +	venc_write_reg(venc, VENC_C_PHASE, config->c_phase);
> +	venc_write_reg(venc, VENC_GAIN_U, config->gain_u);
> +	venc_write_reg(venc, VENC_GAIN_V, config->gain_v);
> +	venc_write_reg(venc, VENC_GAIN_Y, config->gain_y);
> +	venc_write_reg(venc, VENC_BLACK_LEVEL, config->black_level);
> +	venc_write_reg(venc, VENC_BLANK_LEVEL, config->blank_level);
> +	venc_write_reg(venc, VENC_M_CONTROL, config->m_control);
> +	venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
> +		       venc->wss_data);
> +	venc_write_reg(venc, VENC_S_CARR, config->s_carr);
> +	venc_write_reg(venc, VENC_L21__WC_CTL, config->l21__wc_ctl);
> +	venc_write_reg(venc, VENC_SAVID__EAVID, config->savid__eavid);
> +	venc_write_reg(venc, VENC_FLEN__FAL, config->flen__fal);
> +	venc_write_reg(venc, VENC_LAL__PHASE_RESET, config->lal__phase_reset);
> +	venc_write_reg(venc, VENC_HS_INT_START_STOP_X,
> +		       config->hs_int_start_stop_x);
> +	venc_write_reg(venc, VENC_HS_EXT_START_STOP_X,
> +		       config->hs_ext_start_stop_x);
> +	venc_write_reg(venc, VENC_VS_INT_START_X, config->vs_int_start_x);
> +	venc_write_reg(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y,
>  		       config->vs_int_stop_x__vs_int_start_y);
> -	venc_write_reg(VENC_VS_INT_STOP_Y__VS_EXT_START_X,
> +	venc_write_reg(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X,
>  		       config->vs_int_stop_y__vs_ext_start_x);
> -	venc_write_reg(VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
> +	venc_write_reg(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
>  		       config->vs_ext_stop_x__vs_ext_start_y);
> -	venc_write_reg(VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y);
> -	venc_write_reg(VENC_AVID_START_STOP_X, config->avid_start_stop_x);
> -	venc_write_reg(VENC_AVID_START_STOP_Y, config->avid_start_stop_y);
> -	venc_write_reg(VENC_FID_INT_START_X__FID_INT_START_Y,
> +	venc_write_reg(venc, VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y);
> +	venc_write_reg(venc, VENC_AVID_START_STOP_X, config->avid_start_stop_x);
> +	venc_write_reg(venc, VENC_AVID_START_STOP_Y, config->avid_start_stop_y);
> +	venc_write_reg(venc, VENC_FID_INT_START_X__FID_INT_START_Y,
>  		       config->fid_int_start_x__fid_int_start_y);
> -	venc_write_reg(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X,
> +	venc_write_reg(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X,
>  		       config->fid_int_offset_y__fid_ext_start_x);
> -	venc_write_reg(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y,
> +	venc_write_reg(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y,
>  		       config->fid_ext_start_y__fid_ext_offset_y);
>  
> -	venc_write_reg(VENC_DAC_B__DAC_C,  venc_read_reg(VENC_DAC_B__DAC_C));
> -	venc_write_reg(VENC_VIDOUT_CTRL, config->vidout_ctrl);
> -	venc_write_reg(VENC_HFLTR_CTRL, config->hfltr_ctrl);
> -	venc_write_reg(VENC_X_COLOR, config->x_color);
> -	venc_write_reg(VENC_LINE21, config->line21);
> -	venc_write_reg(VENC_LN_SEL, config->ln_sel);
> -	venc_write_reg(VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger);
> -	venc_write_reg(VENC_TVDETGP_INT_START_STOP_X,
> +	venc_write_reg(venc, VENC_DAC_B__DAC_C,
> +		       venc_read_reg(venc, VENC_DAC_B__DAC_C));
> +	venc_write_reg(venc, VENC_VIDOUT_CTRL, config->vidout_ctrl);
> +	venc_write_reg(venc, VENC_HFLTR_CTRL, config->hfltr_ctrl);
> +	venc_write_reg(venc, VENC_X_COLOR, config->x_color);
> +	venc_write_reg(venc, VENC_LINE21, config->line21);
> +	venc_write_reg(venc, VENC_LN_SEL, config->ln_sel);
> +	venc_write_reg(venc, VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger);
> +	venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_X,
>  		       config->tvdetgp_int_start_stop_x);
> -	venc_write_reg(VENC_TVDETGP_INT_START_STOP_Y,
> +	venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_Y,
>  		       config->tvdetgp_int_start_stop_y);
> -	venc_write_reg(VENC_GEN_CTRL, config->gen_ctrl);
> -	venc_write_reg(VENC_F_CONTROL, config->f_control);
> -	venc_write_reg(VENC_SYNC_CTRL, config->sync_ctrl);
> +	venc_write_reg(venc, VENC_GEN_CTRL, config->gen_ctrl);
> +	venc_write_reg(venc, VENC_F_CONTROL, config->f_control);
> +	venc_write_reg(venc, VENC_SYNC_CTRL, config->sync_ctrl);
>  }
>  
> -static void venc_reset(void)
> +static void venc_reset(struct venc_device *venc)
>  {
>  	int t = 1000;
>  
> -	venc_write_reg(VENC_F_CONTROL, 1<<8);
> -	while (venc_read_reg(VENC_F_CONTROL) & (1<<8)) {
> +	venc_write_reg(venc, VENC_F_CONTROL, 1<<8);
> +	while (venc_read_reg(venc, VENC_F_CONTROL) & (1<<8)) {
>  		if (--t == 0) {
>  			DSSERR("Failed to reset venc\n");
>  			return;
> @@ -427,24 +433,24 @@ static void venc_reset(void)
>  #endif
>  }
>  
> -static int venc_runtime_get(void)
> +static int venc_runtime_get(struct venc_device *venc)
>  {
>  	int r;
>  
>  	DSSDBG("venc_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&venc.pdev->dev);
> +	r = pm_runtime_get_sync(&venc->pdev->dev);
>  	WARN_ON(r < 0);
>  	return r < 0 ? r : 0;
>  }
>  
> -static void venc_runtime_put(void)
> +static void venc_runtime_put(struct venc_device *venc)
>  {
>  	int r;
>  
>  	DSSDBG("venc_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&venc.pdev->dev);
> +	r = pm_runtime_put_sync(&venc->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> @@ -460,37 +466,37 @@ static const struct venc_config *venc_timings_to_config(struct videomode *vm)
>  	}
>  }
>  
> -static int venc_power_on(struct omap_dss_device *dssdev)
> +static int venc_power_on(struct venc_device *venc)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = venc->output.dispc_channel;
>  	u32 l;
>  	int r;
>  
> -	r = venc_runtime_get();
> +	r = venc_runtime_get(venc);
>  	if (r)
>  		goto err0;
>  
> -	venc_reset();
> -	venc_write_config(venc_timings_to_config(&venc.vm));
> +	venc_reset(venc);
> +	venc_write_config(venc, venc_timings_to_config(&venc->vm));
>  
> -	dss_set_venc_output(venc.dss, venc.type);
> -	dss_set_dac_pwrdn_bgz(venc.dss, 1);
> +	dss_set_venc_output(venc->dss, venc->type);
> +	dss_set_dac_pwrdn_bgz(venc->dss, 1);
>  
>  	l = 0;
>  
> -	if (venc.type == OMAP_DSS_VENC_TYPE_COMPOSITE)
> +	if (venc->type == OMAP_DSS_VENC_TYPE_COMPOSITE)
>  		l |= 1 << 1;
>  	else /* S-Video */
>  		l |= (1 << 0) | (1 << 2);
>  
> -	if (venc.invert_polarity == false)
> +	if (venc->invert_polarity == false)
>  		l |= 1 << 3;
>  
> -	venc_write_reg(VENC_OUTPUT_CONTROL, l);
> +	venc_write_reg(venc, VENC_OUTPUT_CONTROL, l);
>  
> -	dss_mgr_set_timings(channel, &venc.vm);
> +	dss_mgr_set_timings(channel, &venc->vm);
>  
> -	r = regulator_enable(venc.vdda_dac_reg);
> +	r = regulator_enable(venc->vdda_dac_reg);
>  	if (r)
>  		goto err1;
>  
> @@ -501,78 +507,81 @@ static int venc_power_on(struct omap_dss_device *dssdev)
>  	return 0;
>  
>  err2:
> -	regulator_disable(venc.vdda_dac_reg);
> +	regulator_disable(venc->vdda_dac_reg);
>  err1:
> -	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
> -	dss_set_dac_pwrdn_bgz(venc.dss, 0);
> +	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
> +	dss_set_dac_pwrdn_bgz(venc->dss, 0);
>  
> -	venc_runtime_put();
> +	venc_runtime_put(venc);
>  err0:
>  	return r;
>  }
>  
> -static void venc_power_off(struct omap_dss_device *dssdev)
> +static void venc_power_off(struct venc_device *venc)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = venc->output.dispc_channel;
>  
> -	venc_write_reg(VENC_OUTPUT_CONTROL, 0);
> -	dss_set_dac_pwrdn_bgz(venc.dss, 0);
> +	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
> +	dss_set_dac_pwrdn_bgz(venc->dss, 0);
>  
>  	dss_mgr_disable(channel);
>  
> -	regulator_disable(venc.vdda_dac_reg);
> +	regulator_disable(venc->vdda_dac_reg);
>  
> -	venc_runtime_put();
> +	venc_runtime_put(venc);
>  }
>  
>  static int venc_display_enable(struct omap_dss_device *dssdev)
>  {
> -	struct omap_dss_device *out = &venc.output;
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
>  	int r;
>  
>  	DSSDBG("venc_display_enable\n");
>  
> -	mutex_lock(&venc.venc_lock);
> +	mutex_lock(&venc->venc_lock);
>  
> -	if (!out->dispc_channel_connected) {
> +	if (!dssdev->dispc_channel_connected) {
>  		DSSERR("Failed to enable display: no output/manager\n");
>  		r = -ENODEV;
>  		goto err0;
>  	}
>  
> -	r = venc_power_on(dssdev);
> +	r = venc_power_on(venc);
>  	if (r)
>  		goto err0;
>  
> -	venc.wss_data = 0;
> +	venc->wss_data = 0;
>  
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  
>  	return 0;
>  err0:
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  	return r;
>  }
>  
>  static void venc_display_disable(struct omap_dss_device *dssdev)
>  {
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
> +
>  	DSSDBG("venc_display_disable\n");
>  
> -	mutex_lock(&venc.venc_lock);
> +	mutex_lock(&venc->venc_lock);
>  
> -	venc_power_off(dssdev);
> +	venc_power_off(venc);
>  
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  }
>  
>  static void venc_set_timings(struct omap_dss_device *dssdev,
>  			     struct videomode *vm)
>  {
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
>  	struct videomode actual_vm;
>  
>  	DSSDBG("venc_set_timings\n");
>  
> -	mutex_lock(&venc.venc_lock);
> +	mutex_lock(&venc->venc_lock);
>  
>  	switch (venc_get_videomode(vm)) {
>  	default:
> @@ -586,14 +595,14 @@ static void venc_set_timings(struct omap_dss_device *dssdev,
>  	}
>  
>  	/* Reset WSS data when the TV standard changes. */
> -	if (memcmp(&venc.vm, &actual_vm, sizeof(actual_vm)))
> -		venc.wss_data = 0;
> +	if (memcmp(&venc->vm, &actual_vm, sizeof(actual_vm)))
> +		venc->wss_data = 0;
>  
> -	venc.vm = actual_vm;
> +	venc->vm = actual_vm;
>  
>  	dispc_set_tv_pclk(13500000);
>  
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  }
>  
>  static int venc_check_timings(struct omap_dss_device *dssdev,
> @@ -613,128 +622,135 @@ static int venc_check_timings(struct omap_dss_device *dssdev,
>  static void venc_get_timings(struct omap_dss_device *dssdev,
>  			     struct videomode *vm)
>  {
> -	mutex_lock(&venc.venc_lock);
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
> +
> +	mutex_lock(&venc->venc_lock);
>  
> -	*vm = venc.vm;
> +	*vm = venc->vm;
>  
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  }
>  
>  static u32 venc_get_wss(struct omap_dss_device *dssdev)
>  {
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
> +
>  	/* Invert due to VENC_L21_WC_CTL:INV=1 */
> -	return (venc.wss_data >> 8) ^ 0xfffff;
> +	return (venc->wss_data >> 8) ^ 0xfffff;
>  }
>  
>  static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss)
>  {
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
>  	const struct venc_config *config;
>  	int r;
>  
>  	DSSDBG("venc_set_wss\n");
>  
> -	mutex_lock(&venc.venc_lock);
> +	mutex_lock(&venc->venc_lock);
>  
> -	config = venc_timings_to_config(&venc.vm);
> +	config = venc_timings_to_config(&venc->vm);
>  
>  	/* Invert due to VENC_L21_WC_CTL:INV=1 */
> -	venc.wss_data = (wss ^ 0xfffff) << 8;
> +	venc->wss_data = (wss ^ 0xfffff) << 8;
>  
> -	r = venc_runtime_get();
> +	r = venc_runtime_get(venc);
>  	if (r)
>  		goto err;
>  
> -	venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
> -			venc.wss_data);
> +	venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
> +		       venc->wss_data);
>  
> -	venc_runtime_put();
> +	venc_runtime_put(venc);
>  
>  err:
> -	mutex_unlock(&venc.venc_lock);
> +	mutex_unlock(&venc->venc_lock);
>  
>  	return r;
>  }
>  
> -static int venc_init_regulator(void)
> +static int venc_init_regulator(struct venc_device *venc)
>  {
>  	struct regulator *vdda_dac;
>  
> -	if (venc.vdda_dac_reg != NULL)
> +	if (venc->vdda_dac_reg != NULL)
>  		return 0;
>  
> -	vdda_dac = devm_regulator_get(&venc.pdev->dev, "vdda");
> +	vdda_dac = devm_regulator_get(&venc->pdev->dev, "vdda");
>  	if (IS_ERR(vdda_dac)) {
>  		if (PTR_ERR(vdda_dac) != -EPROBE_DEFER)
>  			DSSERR("can't get VDDA_DAC regulator\n");
>  		return PTR_ERR(vdda_dac);
>  	}
>  
> -	venc.vdda_dac_reg = vdda_dac;
> +	venc->vdda_dac_reg = vdda_dac;
>  
>  	return 0;
>  }
>  
>  static int venc_dump_regs(struct seq_file *s, void *p)
>  {
> -#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
> +	struct venc_device *venc = s->private;
> +
> +#define DUMPREG(venc, r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(venc, r))
>  
> -	if (venc_runtime_get())
> +	if (venc_runtime_get(venc))
>  		return 0;
>  
> -	DUMPREG(VENC_F_CONTROL);
> -	DUMPREG(VENC_VIDOUT_CTRL);
> -	DUMPREG(VENC_SYNC_CTRL);
> -	DUMPREG(VENC_LLEN);
> -	DUMPREG(VENC_FLENS);
> -	DUMPREG(VENC_HFLTR_CTRL);
> -	DUMPREG(VENC_CC_CARR_WSS_CARR);
> -	DUMPREG(VENC_C_PHASE);
> -	DUMPREG(VENC_GAIN_U);
> -	DUMPREG(VENC_GAIN_V);
> -	DUMPREG(VENC_GAIN_Y);
> -	DUMPREG(VENC_BLACK_LEVEL);
> -	DUMPREG(VENC_BLANK_LEVEL);
> -	DUMPREG(VENC_X_COLOR);
> -	DUMPREG(VENC_M_CONTROL);
> -	DUMPREG(VENC_BSTAMP_WSS_DATA);
> -	DUMPREG(VENC_S_CARR);
> -	DUMPREG(VENC_LINE21);
> -	DUMPREG(VENC_LN_SEL);
> -	DUMPREG(VENC_L21__WC_CTL);
> -	DUMPREG(VENC_HTRIGGER_VTRIGGER);
> -	DUMPREG(VENC_SAVID__EAVID);
> -	DUMPREG(VENC_FLEN__FAL);
> -	DUMPREG(VENC_LAL__PHASE_RESET);
> -	DUMPREG(VENC_HS_INT_START_STOP_X);
> -	DUMPREG(VENC_HS_EXT_START_STOP_X);
> -	DUMPREG(VENC_VS_INT_START_X);
> -	DUMPREG(VENC_VS_INT_STOP_X__VS_INT_START_Y);
> -	DUMPREG(VENC_VS_INT_STOP_Y__VS_EXT_START_X);
> -	DUMPREG(VENC_VS_EXT_STOP_X__VS_EXT_START_Y);
> -	DUMPREG(VENC_VS_EXT_STOP_Y);
> -	DUMPREG(VENC_AVID_START_STOP_X);
> -	DUMPREG(VENC_AVID_START_STOP_Y);
> -	DUMPREG(VENC_FID_INT_START_X__FID_INT_START_Y);
> -	DUMPREG(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X);
> -	DUMPREG(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y);
> -	DUMPREG(VENC_TVDETGP_INT_START_STOP_X);
> -	DUMPREG(VENC_TVDETGP_INT_START_STOP_Y);
> -	DUMPREG(VENC_GEN_CTRL);
> -	DUMPREG(VENC_OUTPUT_CONTROL);
> -	DUMPREG(VENC_OUTPUT_TEST);
> -
> -	venc_runtime_put();
> +	DUMPREG(venc, VENC_F_CONTROL);
> +	DUMPREG(venc, VENC_VIDOUT_CTRL);
> +	DUMPREG(venc, VENC_SYNC_CTRL);
> +	DUMPREG(venc, VENC_LLEN);
> +	DUMPREG(venc, VENC_FLENS);
> +	DUMPREG(venc, VENC_HFLTR_CTRL);
> +	DUMPREG(venc, VENC_CC_CARR_WSS_CARR);
> +	DUMPREG(venc, VENC_C_PHASE);
> +	DUMPREG(venc, VENC_GAIN_U);
> +	DUMPREG(venc, VENC_GAIN_V);
> +	DUMPREG(venc, VENC_GAIN_Y);
> +	DUMPREG(venc, VENC_BLACK_LEVEL);
> +	DUMPREG(venc, VENC_BLANK_LEVEL);
> +	DUMPREG(venc, VENC_X_COLOR);
> +	DUMPREG(venc, VENC_M_CONTROL);
> +	DUMPREG(venc, VENC_BSTAMP_WSS_DATA);
> +	DUMPREG(venc, VENC_S_CARR);
> +	DUMPREG(venc, VENC_LINE21);
> +	DUMPREG(venc, VENC_LN_SEL);
> +	DUMPREG(venc, VENC_L21__WC_CTL);
> +	DUMPREG(venc, VENC_HTRIGGER_VTRIGGER);
> +	DUMPREG(venc, VENC_SAVID__EAVID);
> +	DUMPREG(venc, VENC_FLEN__FAL);
> +	DUMPREG(venc, VENC_LAL__PHASE_RESET);
> +	DUMPREG(venc, VENC_HS_INT_START_STOP_X);
> +	DUMPREG(venc, VENC_HS_EXT_START_STOP_X);
> +	DUMPREG(venc, VENC_VS_INT_START_X);
> +	DUMPREG(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y);
> +	DUMPREG(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X);
> +	DUMPREG(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y);
> +	DUMPREG(venc, VENC_VS_EXT_STOP_Y);
> +	DUMPREG(venc, VENC_AVID_START_STOP_X);
> +	DUMPREG(venc, VENC_AVID_START_STOP_Y);
> +	DUMPREG(venc, VENC_FID_INT_START_X__FID_INT_START_Y);
> +	DUMPREG(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X);
> +	DUMPREG(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y);
> +	DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_X);
> +	DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_Y);
> +	DUMPREG(venc, VENC_GEN_CTRL);
> +	DUMPREG(venc, VENC_OUTPUT_CONTROL);
> +	DUMPREG(venc, VENC_OUTPUT_TEST);
> +
> +	venc_runtime_put(venc);
>  
>  #undef DUMPREG
>  	return 0;
>  }
>  
> -static int venc_get_clocks(struct platform_device *pdev)
> +static int venc_get_clocks(struct venc_device *venc)
>  {
>  	struct clk *clk;
>  
> -	if (venc.requires_tv_dac_clk) {
> -		clk = devm_clk_get(&pdev->dev, "tv_dac_clk");
> +	if (venc->requires_tv_dac_clk) {
> +		clk = devm_clk_get(&venc->pdev->dev, "tv_dac_clk");
>  		if (IS_ERR(clk)) {
>  			DSSERR("can't get tv_dac_clk\n");
>  			return PTR_ERR(clk);
> @@ -743,7 +759,7 @@ static int venc_get_clocks(struct platform_device *pdev)
>  		clk = NULL;
>  	}
>  
> -	venc.tv_dac_clk = clk;
> +	venc->tv_dac_clk = clk;
>  
>  	return 0;
>  }
> @@ -751,10 +767,11 @@ static int venc_get_clocks(struct platform_device *pdev)
>  static int venc_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
> -	r = venc_init_regulator();
> +	r = venc_init_regulator(venc);
>  	if (r)
>  		return r;
>  
> @@ -803,11 +820,11 @@ static const struct omapdss_atv_ops venc_ops = {
>  	.get_wss = venc_get_wss,
>  };
>  
> -static void venc_init_output(struct platform_device *pdev)
> +static void venc_init_output(struct venc_device *venc)
>  {
> -	struct omap_dss_device *out = &venc.output;
> +	struct omap_dss_device *out = &venc->output;
>  
> -	out->dev = &pdev->dev;
> +	out->dev = &venc->pdev->dev;
>  	out->id = OMAP_DSS_OUTPUT_VENC;
>  	out->output_type = OMAP_DISPLAY_TYPE_VENC;
>  	out->name = "venc.0";
> @@ -818,16 +835,14 @@ static void venc_init_output(struct platform_device *pdev)
>  	omapdss_register_output(out);
>  }
>  
> -static void venc_uninit_output(struct platform_device *pdev)
> +static void venc_uninit_output(struct venc_device *venc)
>  {
> -	struct omap_dss_device *out = &venc.output;
> -
> -	omapdss_unregister_output(out);
> +	omapdss_unregister_output(&venc->output);
>  }
>  
> -static int venc_probe_of(struct platform_device *pdev)
> +static int venc_probe_of(struct venc_device *venc)
>  {
> -	struct device_node *node = pdev->dev.of_node;
> +	struct device_node *node = venc->pdev->dev.of_node;
>  	struct device_node *ep;
>  	u32 channels;
>  	int r;
> @@ -836,24 +851,25 @@ static int venc_probe_of(struct platform_device *pdev)
>  	if (!ep)
>  		return 0;
>  
> -	venc.invert_polarity = of_property_read_bool(ep, "ti,invert-polarity");
> +	venc->invert_polarity = of_property_read_bool(ep, "ti,invert-polarity");
>  
>  	r = of_property_read_u32(ep, "ti,channels", &channels);
>  	if (r) {
> -		dev_err(&pdev->dev,
> +		dev_err(&venc->pdev->dev,
>  			"failed to read property 'ti,channels': %d\n", r);
>  		goto err;
>  	}
>  
>  	switch (channels) {
>  	case 1:
> -		venc.type = OMAP_DSS_VENC_TYPE_COMPOSITE;
> +		venc->type = OMAP_DSS_VENC_TYPE_COMPOSITE;
>  		break;
>  	case 2:
> -		venc.type = OMAP_DSS_VENC_TYPE_SVIDEO;
> +		venc->type = OMAP_DSS_VENC_TYPE_SVIDEO;
>  		break;
>  	default:
> -		dev_err(&pdev->dev, "bad channel propert '%d'\n", channels);
> +		dev_err(&venc->pdev->dev, "bad channel propert '%d'\n",
> +			channels);
>  		r = -EINVAL;
>  		goto err;
>  	}
> @@ -878,68 +894,80 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct dss_device *dss = dss_get_device(master);
> +	struct venc_device *venc;
>  	u8 rev_id;
>  	struct resource *venc_mem;
>  	int r;
>  
> -	venc.pdev = pdev;
> -	venc.dss = dss;
> +	venc = kzalloc(sizeof(*venc), GFP_KERNEL);
> +	if (!venc)
> +		return -ENOMEM;
> +
> +	venc->pdev = pdev;
> +	venc->dss = dss;
> +	dev_set_drvdata(dev, venc);
>  
>  	/* The OMAP34xx, OMAP35xx and AM35xx VENC require the TV DAC clock. */
>  	if (soc_device_match(venc_soc_devices))
> -		venc.requires_tv_dac_clk = true;
> +		venc->requires_tv_dac_clk = true;
>  
> -	mutex_init(&venc.venc_lock);
> +	mutex_init(&venc->venc_lock);
>  
> -	venc.wss_data = 0;
> +	venc->wss_data = 0;
>  
> -	venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0);
> -	venc.base = devm_ioremap_resource(&pdev->dev, venc_mem);
> -	if (IS_ERR(venc.base))
> -		return PTR_ERR(venc.base);
> +	venc_mem = platform_get_resource(venc->pdev, IORESOURCE_MEM, 0);
> +	venc->base = devm_ioremap_resource(&pdev->dev, venc_mem);
> +	if (IS_ERR(venc->base)) {
> +		r = PTR_ERR(venc->base);
> +		goto err_free;
> +	}
>  
> -	r = venc_get_clocks(pdev);
> +	r = venc_get_clocks(venc);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	r = venc_runtime_get();
> +	r = venc_runtime_get(venc);
>  	if (r)
>  		goto err_runtime_get;
>  
> -	rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
> +	rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff);
>  	dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id);
>  
> -	venc_runtime_put();
> +	venc_runtime_put(venc);
>  
> -	r = venc_probe_of(pdev);
> +	r = venc_probe_of(venc);
>  	if (r) {
>  		DSSERR("Invalid DT data\n");
>  		goto err_probe_of;
>  	}
>  
> -	venc.debugfs = dss_debugfs_create_file("venc", venc_dump_regs, &venc);
> +	venc->debugfs = dss_debugfs_create_file("venc", venc_dump_regs, venc);
>  
> -	venc_init_output(pdev);
> +	venc_init_output(venc);
>  
>  	return 0;
>  
>  err_probe_of:
>  err_runtime_get:
>  	pm_runtime_disable(&pdev->dev);
> +err_free:
> +	kfree(venc);
>  	return r;
>  }
>  
>  static void venc_unbind(struct device *dev, struct device *master, void *data)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> +	struct venc_device *venc = dev_get_drvdata(dev);
>  
> -	dss_debugfs_remove_file(venc.debugfs);
> +	dss_debugfs_remove_file(venc->debugfs);
>  
> -	venc_uninit_output(pdev);
> +	venc_uninit_output(venc);
>  
> -	pm_runtime_disable(&pdev->dev);
> +	pm_runtime_disable(dev);
> +
> +	kfree(venc);
>  }
>  
>  static const struct component_ops venc_component_ops = {
> @@ -960,8 +988,10 @@ static int venc_remove(struct platform_device *pdev)
>  
>  static int venc_runtime_suspend(struct device *dev)
>  {
> -	if (venc.tv_dac_clk)
> -		clk_disable_unprepare(venc.tv_dac_clk);
> +	struct venc_device *venc = dev_get_drvdata(dev);
> +
> +	if (venc->tv_dac_clk)
> +		clk_disable_unprepare(venc->tv_dac_clk);
>  
>  	dispc_runtime_put();
>  
> @@ -970,14 +1000,15 @@ static int venc_runtime_suspend(struct device *dev)
>  
>  static int venc_runtime_resume(struct device *dev)
>  {
> +	struct venc_device *venc = dev_get_drvdata(dev);
>  	int r;
>  
>  	r = dispc_runtime_get();
>  	if (r < 0)
>  		return r;
>  
> -	if (venc.tv_dac_clk)
> -		clk_prepare_enable(venc.tv_dac_clk);
> +	if (venc->tv_dac_clk)
> +		clk_prepare_enable(venc->tv_dac_clk);
>  
>  	return 0;
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi private data structure dynamically
  2017-10-13 14:59 ` [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi " Laurent Pinchart
@ 2017-10-17 19:09   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 19:09 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 10222 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:30PM +0300, Laurent Pinchart wrote:
> The sdi private data structure is currently stored as a global
> variable. While no platform with multiple SDI encoders currently exists
> nor is planned, this doesn't comply with the kernel device model and
> should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/sdi.c | 122 +++++++++++++++++++++-----------------
>  1 file changed, 69 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index ac436826914a..a35dc51c5a6a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -31,7 +31,7 @@
>  #include "omapdss.h"
>  #include "dss.h"
>  
> -static struct {
> +struct sdi_device {
>  	struct platform_device *pdev;
>  	struct dss_device *dss;
>  
> @@ -43,9 +43,9 @@ static struct {
>  	int datapairs;
>  
>  	struct omap_dss_device output;
> +};
>  
> -	bool port_initialized;
> -} sdi;
> +#define dssdev_to_sdi(dssdev) container_of(dssdev, struct sdi_device, output)
>  
>  struct sdi_clk_calc_ctx {
>  	unsigned long pck_min, pck_max;
> @@ -77,9 +77,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
>  			dpi_calc_dispc_cb, ctx);
>  }
>  
> -static int sdi_calc_clock_div(unsigned long pclk,
> -		unsigned long *fck,
> -		struct dispc_clock_info *dispc_cinfo)
> +static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
> +			      unsigned long *fck,
> +			      struct dispc_clock_info *dispc_cinfo)
>  {
>  	int i;
>  	struct sdi_clk_calc_ctx ctx;
> @@ -101,7 +101,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
>  			ctx.pck_min = 0;
>  		ctx.pck_max = pclk + 1000 * i * i * i;
>  
> -		ok = dss_div_calc(sdi.dss, pclk, ctx.pck_min,
> +		ok = dss_div_calc(sdi->dss, pclk, ctx.pck_min,
>  				  dpi_calc_dss_cb, &ctx);
>  		if (ok) {
>  			*fck = ctx.fck;
> @@ -113,26 +113,27 @@ static int sdi_calc_clock_div(unsigned long pclk,
>  	return -EINVAL;
>  }
>  
> -static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
> +static void sdi_config_lcd_manager(struct sdi_device *sdi)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	enum omap_channel channel = sdi->output.dispc_channel;
>  
> -	sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
> +	sdi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
>  
> -	sdi.mgr_config.stallmode = false;
> -	sdi.mgr_config.fifohandcheck = false;
> +	sdi->mgr_config.stallmode = false;
> +	sdi->mgr_config.fifohandcheck = false;
>  
> -	sdi.mgr_config.video_port_width = 24;
> -	sdi.mgr_config.lcden_sig_polarity = 1;
> +	sdi->mgr_config.video_port_width = 24;
> +	sdi->mgr_config.lcden_sig_polarity = 1;
>  
> -	dss_mgr_set_lcd_config(channel, &sdi.mgr_config);
> +	dss_mgr_set_lcd_config(channel, &sdi->mgr_config);
>  }
>  
>  static int sdi_display_enable(struct omap_dss_device *dssdev)
>  {
> -	struct omap_dss_device *out = &sdi.output;
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> +	struct omap_dss_device *out = &sdi->output;
>  	enum omap_channel channel = dssdev->dispc_channel;
> -	struct videomode *vm = &sdi.vm;
> +	struct videomode *vm = &sdi->vm;
>  	unsigned long fck;
>  	struct dispc_clock_info dispc_cinfo;
>  	unsigned long pck;
> @@ -143,7 +144,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  		return -ENODEV;
>  	}
>  
> -	r = regulator_enable(sdi.vdds_sdi_reg);
> +	r = regulator_enable(sdi->vdds_sdi_reg);
>  	if (r)
>  		goto err_reg_enable;
>  
> @@ -154,11 +155,11 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	/* 15.5.9.1.2 */
>  	vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_SYNC_POSEDGE;
>  
> -	r = sdi_calc_clock_div(vm->pixelclock, &fck, &dispc_cinfo);
> +	r = sdi_calc_clock_div(sdi, vm->pixelclock, &fck, &dispc_cinfo);
>  	if (r)
>  		goto err_calc_clock_div;
>  
> -	sdi.mgr_config.clock_info = dispc_cinfo;
> +	sdi->mgr_config.clock_info = dispc_cinfo;
>  
>  	pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div;
>  
> @@ -172,11 +173,11 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  
>  	dss_mgr_set_timings(channel, vm);
>  
> -	r = dss_set_fck_rate(sdi.dss, fck);
> +	r = dss_set_fck_rate(sdi->dss, fck);
>  	if (r)
>  		goto err_set_dss_clock_div;
>  
> -	sdi_config_lcd_manager(dssdev);
> +	sdi_config_lcd_manager(sdi);
>  
>  	/*
>  	 * LCLK and PCLK divisors are located in shadow registers, and we
> @@ -189,10 +190,10 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	 * need to care about the shadow register mechanism for pck-free. The
>  	 * exact reason for this is unknown.
>  	 */
> -	dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
> +	dispc_mgr_set_clock_div(channel, &sdi->mgr_config.clock_info);
>  
> -	dss_sdi_init(sdi.dss, sdi.datapairs);
> -	r = dss_sdi_enable(sdi.dss);
> +	dss_sdi_init(sdi->dss, sdi->datapairs);
> +	r = dss_sdi_enable(sdi->dss);
>  	if (r)
>  		goto err_sdi_enable;
>  	mdelay(2);
> @@ -204,40 +205,45 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	return 0;
>  
>  err_mgr_enable:
> -	dss_sdi_disable(sdi.dss);
> +	dss_sdi_disable(sdi->dss);
>  err_sdi_enable:
>  err_set_dss_clock_div:
>  err_calc_clock_div:
>  	dispc_runtime_put();
>  err_get_dispc:
> -	regulator_disable(sdi.vdds_sdi_reg);
> +	regulator_disable(sdi->vdds_sdi_reg);
>  err_reg_enable:
>  	return r;
>  }
>  
>  static void sdi_display_disable(struct omap_dss_device *dssdev)
>  {
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  
>  	dss_mgr_disable(channel);
>  
> -	dss_sdi_disable(sdi.dss);
> +	dss_sdi_disable(sdi->dss);
>  
>  	dispc_runtime_put();
>  
> -	regulator_disable(sdi.vdds_sdi_reg);
> +	regulator_disable(sdi->vdds_sdi_reg);
>  }
>  
>  static void sdi_set_timings(struct omap_dss_device *dssdev,
>  			    struct videomode *vm)
>  {
> -	sdi.vm = *vm;
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> +
> +	sdi->vm = *vm;
>  }
>  
>  static void sdi_get_timings(struct omap_dss_device *dssdev,
>  			    struct videomode *vm)
>  {
> -	*vm = sdi.vm;
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> +
> +	*vm = sdi->vm;
>  }
>  
>  static int sdi_check_timings(struct omap_dss_device *dssdev,
> @@ -254,21 +260,21 @@ static int sdi_check_timings(struct omap_dss_device *dssdev,
>  	return 0;
>  }
>  
> -static int sdi_init_regulator(void)
> +static int sdi_init_regulator(struct sdi_device *sdi)
>  {
>  	struct regulator *vdds_sdi;
>  
> -	if (sdi.vdds_sdi_reg)
> +	if (sdi->vdds_sdi_reg)
>  		return 0;
>  
> -	vdds_sdi = devm_regulator_get(&sdi.pdev->dev, "vdds_sdi");
> +	vdds_sdi = devm_regulator_get(&sdi->pdev->dev, "vdds_sdi");
>  	if (IS_ERR(vdds_sdi)) {
>  		if (PTR_ERR(vdds_sdi) != -EPROBE_DEFER)
>  			DSSERR("can't get VDDS_SDI regulator\n");
>  		return PTR_ERR(vdds_sdi);
>  	}
>  
> -	sdi.vdds_sdi_reg = vdds_sdi;
> +	sdi->vdds_sdi_reg = vdds_sdi;
>  
>  	return 0;
>  }
> @@ -276,10 +282,11 @@ static int sdi_init_regulator(void)
>  static int sdi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
> -	r = sdi_init_regulator();
> +	r = sdi_init_regulator(sdi);
>  	if (r)
>  		return r;
>  
> @@ -325,11 +332,11 @@ static const struct omapdss_sdi_ops sdi_ops = {
>  	.get_timings = sdi_get_timings,
>  };
>  
> -static void sdi_init_output(struct platform_device *pdev)
> +static void sdi_init_output(struct sdi_device *sdi)
>  {
> -	struct omap_dss_device *out = &sdi.output;
> +	struct omap_dss_device *out = &sdi->output;
>  
> -	out->dev = &pdev->dev;
> +	out->dev = &sdi->pdev->dev;
>  	out->id = OMAP_DSS_OUTPUT_SDI;
>  	out->output_type = OMAP_DISPLAY_TYPE_SDI;
>  	out->name = "sdi.0";
> @@ -342,23 +349,28 @@ static void sdi_init_output(struct platform_device *pdev)
>  	omapdss_register_output(out);
>  }
>  
> -static void sdi_uninit_output(struct platform_device *pdev)
> +static void sdi_uninit_output(struct sdi_device *sdi)
>  {
> -	struct omap_dss_device *out = &sdi.output;
> -
> -	omapdss_unregister_output(out);
> +	omapdss_unregister_output(&sdi->output);
>  }
>  
>  int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
>  		  struct device_node *port)
>  {
> +	struct sdi_device *sdi;
>  	struct device_node *ep;
>  	u32 datapairs;
>  	int r;
>  
> +	sdi = kzalloc(sizeof(*sdi), GFP_KERNEL);
> +	if (!sdi)
> +		return -ENOMEM;
> +
>  	ep = of_get_next_child(port, NULL);
> -	if (!ep)
> -		return 0;
> +	if (!ep) {
> +		r = 0;
> +		goto err_free;
> +	}
>  
>  	r = of_property_read_u32(ep, "datapairs", &datapairs);
>  	if (r) {
> @@ -366,29 +378,33 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
>  		goto err_datapairs;
>  	}
>  
> -	sdi.datapairs = datapairs;
> -	sdi.dss = dss;
> +	sdi->datapairs = datapairs;
> +	sdi->dss = dss;
>  
>  	of_node_put(ep);
>  
> -	sdi.pdev = pdev;
> +	sdi->pdev = pdev;
> +	port->data = sdi;
>  
> -	sdi_init_output(pdev);
> -
> -	sdi.port_initialized = true;
> +	sdi_init_output(sdi);
>  
>  	return 0;
>  
>  err_datapairs:
>  	of_node_put(ep);
> +err_free:
> +	kfree(sdi);
>  
>  	return r;
>  }
>  
>  void sdi_uninit_port(struct device_node *port)
>  {
> -	if (!sdi.port_initialized)
> +	struct sdi_device *sdi = port->data;
> +
> +	if (!sdi)
>  		return;
>  
> -	sdi_uninit_output(sdi.pdev);
> +	sdi_uninit_output(sdi);
> +	kfree(sdi);
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status
  2017-10-13 14:59 ` [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status Laurent Pinchart
@ 2017-10-17 19:12   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 19:12 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 5277 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:31PM +0300, Laurent Pinchart wrote:
> The wait_for_bit_change() function returns the value of the bit it
> polls. This requires the caller to compare the return value to the
> expected bit value. As all the existing callers need is to check whether
> the bit has reached the expected value, it's easier to return a boolean
> status from the function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 7fb048023fd0..c94bb6404a69 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -531,7 +531,7 @@ static void dsi_completion_handler(void *data, u32 mask)
>  	complete((struct completion *)data);
>  }
>  
> -static inline int wait_for_bit_change(struct platform_device *dsidev,
> +static inline bool wait_for_bit_change(struct platform_device *dsidev,
>  		const struct dsi_reg idx, int bitnum, int value)
>  {
>  	unsigned long timeout;
> @@ -542,21 +542,21 @@ static inline int wait_for_bit_change(struct platform_device *dsidev,
>  	t = 100;
>  	while (t-- > 0) {
>  		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
> -			return value;
> +			return true;
>  	}
>  
>  	/* then loop for 500ms, sleeping for 1ms in between */
>  	timeout = jiffies + msecs_to_jiffies(500);
>  	while (time_before(jiffies, timeout)) {
>  		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
> -			return value;
> +			return true;
>  
>  		wait = ns_to_ktime(1000 * 1000);
>  		set_current_state(TASK_UNINTERRUPTIBLE);
>  		schedule_hrtimeout(&wait, HRTIMER_MODE_REL);
>  	}
>  
> -	return !value;
> +	return false;
>  }
>  
>  static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
> @@ -1259,9 +1259,9 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
>  	enable = enable ? 1 : 0;
>  	REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
>  
> -	if (wait_for_bit_change(dsidev, DSI_CTRL, 0, enable) != enable) {
> -			DSSERR("Failed to set dsi_if_enable to %d\n", enable);
> -			return -EIO;
> +	if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
> +		DSSERR("Failed to set dsi_if_enable to %d\n", enable);
> +		return -EIO;
>  	}
>  
>  	return 0;
> @@ -1450,7 +1450,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
>  	/* XXX PLL does not come out of reset without this... */
>  	dispc_pck_free_enable(1);
>  
> -	if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1) != 1) {
> +	if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
>  		DSSERR("PLL not coming out of reset.\n");
>  		r = -ENODEV;
>  		dispc_pck_free_enable(0);
> @@ -2200,7 +2200,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  	 * I/O. */
>  	dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
>  
> -	if (wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1) != 1) {
> +	if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
>  		DSSERR("CIO SCP Clock domain not coming out of reset.\n");
>  		r = -EIO;
>  		goto err_scp_clk_dom;
> @@ -2248,7 +2248,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  	if (r)
>  		goto err_cio_pwr;
>  
> -	if (wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1) != 1) {
> +	if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
>  		DSSERR("CIO PWR clock domain not coming out of reset.\n");
>  		r = -ENODEV;
>  		goto err_cio_pwr_dom;
> @@ -2389,7 +2389,7 @@ static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
>  	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
>  	dsi_write_reg(dsidev, DSI_TIMING1, r);
>  
> -	if (wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0) != 0) {
> +	if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
>  		DSSERR("TX_STOP bit not going down\n");
>  		return -EIO;
>  	}
> @@ -2531,10 +2531,9 @@ static int dsi_vc_enable(struct platform_device *dsidev, int channel,
>  
>  	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
>  
> -	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel),
> -		0, enable) != enable) {
> -			DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
> -			return -EIO;
> +	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
> +		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
> +		return -EIO;
>  	}
>  
>  	return 0;
> @@ -2586,7 +2585,7 @@ static int dsi_vc_config_source(struct platform_device *dsidev, int channel,
>  	dsi_vc_enable(dsidev, channel, 0);
>  
>  	/* VC_BUSY */
> -	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0) != 0) {
> +	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0)) {
>  		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
>  		return -EIO;
>  	}
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions
  2017-10-13 14:59 ` [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
@ 2017-10-17 20:02   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:02 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 119119 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:32PM +0300, Laurent Pinchart wrote:
> Internal dsi functions take a pointer to the DSI platform_device and
> then cast it to a dsi_data pointer. That's pointless as the caller
> already has the dsi_data pointer. Pass it directly instead of the
> platform_device pointer.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 1228 +++++++++++++++++--------------------
>  1 file changed, 564 insertions(+), 664 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index c94bb6404a69..312804104ad3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -121,11 +121,11 @@ struct dsi_reg { u16 module; u16 idx; };
>  #define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
>  #define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
>  
> -#define REG_GET(dsidev, idx, start, end) \
> -	FLD_GET(dsi_read_reg(dsidev, idx), start, end)
> +#define REG_GET(dsi, idx, start, end) \
> +	FLD_GET(dsi_read_reg(dsi, idx), start, end)
>  
> -#define REG_FLD_MOD(dsidev, idx, val, start, end) \
> -	dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end))
> +#define REG_FLD_MOD(dsi, idx, val, start, end) \
> +	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
>  
>  /* Global interrupts */
>  #define DSI_IRQ_VC0		(1 << 0)
> @@ -215,13 +215,14 @@ struct dsi_reg { u16 module; u16 idx; };
>  	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
>  
>  typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
> +struct dsi_data;
>  
> -static int dsi_display_init_dispc(struct platform_device *dsidev,
> +static int dsi_display_init_dispc(struct dsi_data *dsi,
>  	enum omap_channel channel);
> -static void dsi_display_uninit_dispc(struct platform_device *dsidev,
> +static void dsi_display_uninit_dispc(struct dsi_data *dsi,
>  	enum omap_channel channel);
>  
> -static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
> +static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
>  
>  /* DSI PLL HSDIV indices */
>  #define HSDIV_DISPC	0
> @@ -284,7 +285,7 @@ struct dsi_isr_tables {
>  };
>  
>  struct dsi_clk_calc_ctx {
> -	struct platform_device *dsidev;
> +	struct dsi_data *dsi;
>  	struct dss_pll *pll;
>  
>  	/* inputs */
> @@ -431,7 +432,7 @@ struct dsi_data {
>  };
>  
>  struct dsi_packet_sent_handler_data {
> -	struct platform_device *dsidev;
> +	struct dsi_data *dsi;
>  	struct completion *completion;
>  };
>  
> @@ -450,7 +451,7 @@ static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss
>  	return to_platform_device(dssdev->dev);
>  }
>  
> -static struct platform_device *dsi_get_dsidev_from_id(int module)
> +static struct dsi_data *dsi_get_dsi_from_id(int module)
>  {
>  	struct omap_dss_device *out;
>  	enum omap_dss_output_id	id;
> @@ -468,13 +469,12 @@ static struct platform_device *dsi_get_dsidev_from_id(int module)
>  
>  	out = omap_dss_get_output(id);
>  
> -	return out ? to_platform_device(out->dev) : NULL;
> +	return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
>  }
>  
> -static inline void dsi_write_reg(struct platform_device *dsidev,
> -		const struct dsi_reg idx, u32 val)
> +static inline void dsi_write_reg(struct dsi_data *dsi,
> +				 const struct dsi_reg idx, u32 val)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	void __iomem *base;
>  
>  	switch(idx.module) {
> @@ -487,10 +487,8 @@ static inline void dsi_write_reg(struct platform_device *dsidev,
>  	__raw_writel(val, base + idx.idx);
>  }
>  
> -static inline u32 dsi_read_reg(struct platform_device *dsidev,
> -		const struct dsi_reg idx)
> +static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	void __iomem *base;
>  
>  	switch(idx.module) {
> @@ -519,10 +517,8 @@ static void dsi_bus_unlock(struct omap_dss_device *dssdev)
>  	up(&dsi->bus_lock);
>  }
>  
> -static bool dsi_bus_is_locked(struct platform_device *dsidev)
> +static bool dsi_bus_is_locked(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	return dsi->bus_lock.count == 0;
>  }
>  
> @@ -531,8 +527,9 @@ static void dsi_completion_handler(void *data, u32 mask)
>  	complete((struct completion *)data);
>  }
>  
> -static inline bool wait_for_bit_change(struct platform_device *dsidev,
> -		const struct dsi_reg idx, int bitnum, int value)
> +static inline bool wait_for_bit_change(struct dsi_data *dsi,
> +				       const struct dsi_reg idx,
> +				       int bitnum, int value)
>  {
>  	unsigned long timeout;
>  	ktime_t wait;
> @@ -541,14 +538,14 @@ static inline bool wait_for_bit_change(struct platform_device *dsidev,
>  	/* first busyloop to see if the bit changes right away */
>  	t = 100;
>  	while (t-- > 0) {
> -		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
> +		if (REG_GET(dsi, idx, bitnum, bitnum) == value)
>  			return true;
>  	}
>  
>  	/* then loop for 500ms, sleeping for 1ms in between */
>  	timeout = jiffies + msecs_to_jiffies(500);
>  	while (time_before(jiffies, timeout)) {
> -		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
> +		if (REG_GET(dsi, idx, bitnum, bitnum) == value)
>  			return true;
>  
>  		wait = ns_to_ktime(1000 * 1000);
> @@ -576,21 +573,18 @@ static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
>  }
>  
>  #ifdef DSI_PERF_MEASURE
> -static void dsi_perf_mark_setup(struct platform_device *dsidev)
> +static void dsi_perf_mark_setup(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	dsi->perf_setup_time = ktime_get();
>  }
>  
> -static void dsi_perf_mark_start(struct platform_device *dsidev)
> +static void dsi_perf_mark_start(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	dsi->perf_start_time = ktime_get();
>  }
>  
> -static void dsi_perf_show(struct platform_device *dsidev, const char *name)
> +static void dsi_perf_show(struct dsi_data *dsi, const char *name)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	ktime_t t, setup_time, trans_time;
>  	u32 total_bytes;
>  	u32 setup_us, trans_us, total_us;
> @@ -624,16 +618,15 @@ static void dsi_perf_show(struct platform_device *dsidev, const char *name)
>  		total_bytes * 1000 / total_us);
>  }
>  #else
> -static inline void dsi_perf_mark_setup(struct platform_device *dsidev)
> +static inline void dsi_perf_mark_setup(struct dsi_data *dsi)
>  {
>  }
>  
> -static inline void dsi_perf_mark_start(struct platform_device *dsidev)
> +static inline void dsi_perf_mark_start(struct dsi_data *dsi)
>  {
>  }
>  
> -static inline void dsi_perf_show(struct platform_device *dsidev,
> -		const char *name)
> +static inline void dsi_perf_show(struct dsi_data *dsi, const char *name)
>  {
>  }
>  #endif
> @@ -730,10 +723,9 @@ static void print_irq_status_cio(u32 status)
>  }
>  
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
> -static void dsi_collect_irq_stats(struct platform_device *dsidev, u32 irqstatus,
> -		u32 *vcstatus, u32 ciostatus)
> +static void dsi_collect_irq_stats(struct dsi_data *dsi, u32 irqstatus,
> +				  u32 *vcstatus, u32 ciostatus)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int i;
>  
>  	spin_lock(&dsi->irq_stats_lock);
> @@ -749,15 +741,14 @@ static void dsi_collect_irq_stats(struct platform_device *dsidev, u32 irqstatus,
>  	spin_unlock(&dsi->irq_stats_lock);
>  }
>  #else
> -#define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus)
> +#define dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus)
>  #endif
>  
>  static int debug_irq;
>  
> -static void dsi_handle_irq_errors(struct platform_device *dsidev, u32 irqstatus,
> -		u32 *vcstatus, u32 ciostatus)
> +static void dsi_handle_irq_errors(struct dsi_data *dsi, u32 irqstatus,
> +				  u32 *vcstatus, u32 ciostatus)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int i;
>  
>  	if (irqstatus & DSI_IRQ_ERROR_MASK) {
> @@ -826,20 +817,16 @@ static void dsi_handle_isrs(struct dsi_isr_tables *isr_tables,
>  
>  static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
>  {
> -	struct platform_device *dsidev;
> -	struct dsi_data *dsi;
> +	struct dsi_data *dsi = arg;
>  	u32 irqstatus, vcstatus[4], ciostatus;
>  	int i;
>  
> -	dsidev = (struct platform_device *) arg;
> -	dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (!dsi->is_enabled)
>  		return IRQ_NONE;
>  
>  	spin_lock(&dsi->irq_lock);
>  
> -	irqstatus = dsi_read_reg(dsidev, DSI_IRQSTATUS);
> +	irqstatus = dsi_read_reg(dsi, DSI_IRQSTATUS);
>  
>  	/* IRQ is not for us */
>  	if (!irqstatus) {
> @@ -847,9 +834,9 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
>  		return IRQ_NONE;
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK);
> +	dsi_write_reg(dsi, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK);
>  	/* flush posted write */
> -	dsi_read_reg(dsidev, DSI_IRQSTATUS);
> +	dsi_read_reg(dsi, DSI_IRQSTATUS);
>  
>  	for (i = 0; i < 4; ++i) {
>  		if ((irqstatus & (1 << i)) == 0) {
> @@ -857,19 +844,19 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
>  			continue;
>  		}
>  
> -		vcstatus[i] = dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i));
> +		vcstatus[i] = dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i));
>  
> -		dsi_write_reg(dsidev, DSI_VC_IRQSTATUS(i), vcstatus[i]);
> +		dsi_write_reg(dsi, DSI_VC_IRQSTATUS(i), vcstatus[i]);
>  		/* flush posted write */
> -		dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i));
> +		dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i));
>  	}
>  
>  	if (irqstatus & DSI_IRQ_COMPLEXIO_ERR) {
> -		ciostatus = dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS);
> +		ciostatus = dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS);
>  
> -		dsi_write_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS, ciostatus);
> +		dsi_write_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS, ciostatus);
>  		/* flush posted write */
> -		dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS);
> +		dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS);
>  	} else {
>  		ciostatus = 0;
>  	}
> @@ -888,19 +875,20 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)
>  
>  	dsi_handle_isrs(&dsi->isr_tables_copy, irqstatus, vcstatus, ciostatus);
>  
> -	dsi_handle_irq_errors(dsidev, irqstatus, vcstatus, ciostatus);
> +	dsi_handle_irq_errors(dsi, irqstatus, vcstatus, ciostatus);
>  
> -	dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus);
> +	dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus);
>  
>  	return IRQ_HANDLED;
>  }
>  
>  /* dsi->irq_lock has to be locked by the caller */
> -static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
> -		struct dsi_isr_data *isr_array,
> -		unsigned int isr_array_size, u32 default_mask,
> -		const struct dsi_reg enable_reg,
> -		const struct dsi_reg status_reg)
> +static void _omap_dsi_configure_irqs(struct dsi_data *dsi,
> +				     struct dsi_isr_data *isr_array,
> +				     unsigned int isr_array_size,
> +				     u32 default_mask,
> +				     const struct dsi_reg enable_reg,
> +				     const struct dsi_reg status_reg)
>  {
>  	struct dsi_isr_data *isr_data;
>  	u32 mask;
> @@ -918,54 +906,48 @@ static void _omap_dsi_configure_irqs(struct platform_device *dsidev,
>  		mask |= isr_data->mask;
>  	}
>  
> -	old_mask = dsi_read_reg(dsidev, enable_reg);
> +	old_mask = dsi_read_reg(dsi, enable_reg);
>  	/* clear the irqstatus for newly enabled irqs */
> -	dsi_write_reg(dsidev, status_reg, (mask ^ old_mask) & mask);
> -	dsi_write_reg(dsidev, enable_reg, mask);
> +	dsi_write_reg(dsi, status_reg, (mask ^ old_mask) & mask);
> +	dsi_write_reg(dsi, enable_reg, mask);
>  
>  	/* flush posted writes */
> -	dsi_read_reg(dsidev, enable_reg);
> -	dsi_read_reg(dsidev, status_reg);
> +	dsi_read_reg(dsi, enable_reg);
> +	dsi_read_reg(dsi, status_reg);
>  }
>  
>  /* dsi->irq_lock has to be locked by the caller */
> -static void _omap_dsi_set_irqs(struct platform_device *dsidev)
> +static void _omap_dsi_set_irqs(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 mask = DSI_IRQ_ERROR_MASK;
>  #ifdef DSI_CATCH_MISSING_TE
>  	mask |= DSI_IRQ_TE_TRIGGER;
>  #endif
> -	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table,
> +	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table), mask,
>  			DSI_IRQENABLE, DSI_IRQSTATUS);
>  }
>  
>  /* dsi->irq_lock has to be locked by the caller */
> -static void _omap_dsi_set_irqs_vc(struct platform_device *dsidev, int vc)
> +static void _omap_dsi_set_irqs_vc(struct dsi_data *dsi, int vc)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
> -	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_vc[vc],
> +	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_vc[vc],
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]),
>  			DSI_VC_IRQ_ERROR_MASK,
>  			DSI_VC_IRQENABLE(vc), DSI_VC_IRQSTATUS(vc));
>  }
>  
>  /* dsi->irq_lock has to be locked by the caller */
> -static void _omap_dsi_set_irqs_cio(struct platform_device *dsidev)
> +static void _omap_dsi_set_irqs_cio(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
> -	_omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_cio,
> +	_omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_cio,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_cio),
>  			DSI_CIO_IRQ_ERROR_MASK,
>  			DSI_COMPLEXIO_IRQ_ENABLE, DSI_COMPLEXIO_IRQ_STATUS);
>  }
>  
> -static void _dsi_initialize_irq(struct platform_device *dsidev)
> +static void _dsi_initialize_irq(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int vc;
>  
> @@ -973,10 +955,10 @@ static void _dsi_initialize_irq(struct platform_device *dsidev)
>  
>  	memset(&dsi->isr_tables, 0, sizeof(dsi->isr_tables));
>  
> -	_omap_dsi_set_irqs(dsidev);
> +	_omap_dsi_set_irqs(dsi);
>  	for (vc = 0; vc < 4; ++vc)
> -		_omap_dsi_set_irqs_vc(dsidev, vc);
> -	_omap_dsi_set_irqs_cio(dsidev);
> +		_omap_dsi_set_irqs_vc(dsi, vc);
> +	_omap_dsi_set_irqs_cio(dsi);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  }
> @@ -1037,10 +1019,9 @@ static int _dsi_unregister_isr(omap_dsi_isr_t isr, void *arg, u32 mask,
>  	return -EINVAL;
>  }
>  
> -static int dsi_register_isr(struct platform_device *dsidev, omap_dsi_isr_t isr,
> -		void *arg, u32 mask)
> +static int dsi_register_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
> +			    void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1050,17 +1031,16 @@ static int dsi_register_isr(struct platform_device *dsidev, omap_dsi_isr_t isr,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs(dsidev);
> +		_omap_dsi_set_irqs(dsi);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_unregister_isr(struct platform_device *dsidev,
> -		omap_dsi_isr_t isr, void *arg, u32 mask)
> +static int dsi_unregister_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
> +			      void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1070,17 +1050,16 @@ static int dsi_unregister_isr(struct platform_device *dsidev,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs(dsidev);
> +		_omap_dsi_set_irqs(dsi);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_register_isr_vc(struct platform_device *dsidev, int channel,
> -		omap_dsi_isr_t isr, void *arg, u32 mask)
> +static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
> +			       omap_dsi_isr_t isr, void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1091,17 +1070,16 @@ static int dsi_register_isr_vc(struct platform_device *dsidev, int channel,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_vc(dsidev, channel);
> +		_omap_dsi_set_irqs_vc(dsi, channel);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_unregister_isr_vc(struct platform_device *dsidev, int channel,
> -		omap_dsi_isr_t isr, void *arg, u32 mask)
> +static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
> +				 omap_dsi_isr_t isr, void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1112,17 +1090,16 @@ static int dsi_unregister_isr_vc(struct platform_device *dsidev, int channel,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_vc(dsidev, channel);
> +		_omap_dsi_set_irqs_vc(dsi, channel);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_register_isr_cio(struct platform_device *dsidev,
> -		omap_dsi_isr_t isr, void *arg, u32 mask)
> +static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
> +				void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1132,17 +1109,16 @@ static int dsi_register_isr_cio(struct platform_device *dsidev,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_cio(dsidev);
> +		_omap_dsi_set_irqs_cio(dsi);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_unregister_isr_cio(struct platform_device *dsidev,
> -		omap_dsi_isr_t isr, void *arg, u32 mask)
> +static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
> +				  void *arg, u32 mask)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	int r;
>  
> @@ -1152,18 +1128,18 @@ static int dsi_unregister_isr_cio(struct platform_device *dsidev,
>  			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_cio(dsidev);
> +		_omap_dsi_set_irqs_cio(dsi);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static u32 dsi_get_errors(struct platform_device *dsidev)
> +static u32 dsi_get_errors(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	u32 e;
> +
>  	spin_lock_irqsave(&dsi->errors_lock, flags);
>  	e = dsi->errors;
>  	dsi->errors = 0;
> @@ -1171,10 +1147,9 @@ static u32 dsi_get_errors(struct platform_device *dsidev)
>  	return e;
>  }
>  
> -static int dsi_runtime_get(struct platform_device *dsidev)
> +static int dsi_runtime_get(struct dsi_data *dsi)
>  {
>  	int r;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
>  	DSSDBG("dsi_runtime_get\n");
>  
> @@ -1183,9 +1158,8 @@ static int dsi_runtime_get(struct platform_device *dsidev)
>  	return r < 0 ? r : 0;
>  }
>  
> -static void dsi_runtime_put(struct platform_device *dsidev)
> +static void dsi_runtime_put(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
>  	DSSDBG("dsi_runtime_put\n");
> @@ -1194,9 +1168,8 @@ static void dsi_runtime_put(struct platform_device *dsidev)
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> -static int dsi_regulator_init(struct platform_device *dsidev)
> +static int dsi_regulator_init(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct regulator *vdds_dsi;
>  
>  	if (dsi->vdds_dsi_reg != NULL)
> @@ -1215,16 +1188,15 @@ static int dsi_regulator_init(struct platform_device *dsidev)
>  	return 0;
>  }
>  
> -static void _dsi_print_reset_status(struct platform_device *dsidev)
> +static void _dsi_print_reset_status(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 l;
>  	int b0, b1, b2;
>  
>  	/* A dummy read using the SCP interface to any DSIPHY register is
>  	 * required after DSIPHY reset to complete the reset of the DSI complex
>  	 * I/O. */
> -	l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
> +	l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
>  
>  	if (dsi->data->quirks & DSI_QUIRK_REVERSE_TXCLKESC) {
>  		b0 = 28;
> @@ -1237,7 +1209,7 @@ static void _dsi_print_reset_status(struct platform_device *dsidev)
>  	}
>  
>  #define DSI_FLD_GET(fld, start, end)\
> -	FLD_GET(dsi_read_reg(dsidev, DSI_##fld), start, end)
> +	FLD_GET(dsi_read_reg(dsi, DSI_##fld), start, end)
>  
>  	pr_debug("DSI resets: PLL (%d) CIO (%d) PHY (%x%x%x, %d, %d, %d)\n",
>  		DSI_FLD_GET(PLL_STATUS, 0, 0),
> @@ -1252,14 +1224,14 @@ static void _dsi_print_reset_status(struct platform_device *dsidev)
>  #undef DSI_FLD_GET
>  }
>  
> -static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
> +static inline int dsi_if_enable(struct dsi_data *dsi, bool enable)
>  {
>  	DSSDBG("dsi_if_enable(%d)\n", enable);
>  
>  	enable = enable ? 1 : 0;
> -	REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
> +	REG_FLD_MOD(dsi, DSI_CTRL, enable, 0, 0); /* IF_EN */
>  
> -	if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
> +	if (!wait_for_bit_change(dsi, DSI_CTRL, 0, enable)) {
>  		DSSERR("Failed to set dsi_if_enable to %d\n", enable);
>  		return -EIO;
>  	}
> @@ -1267,31 +1239,24 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
>  	return 0;
>  }
>  
> -static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
> +static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	return dsi->pll.cinfo.clkout[HSDIV_DISPC];
>  }
>  
> -static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device *dsidev)
> +static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	return dsi->pll.cinfo.clkout[HSDIV_DSI];
>  }
>  
> -static unsigned long dsi_get_txbyteclkhs(struct platform_device *dsidev)
> +static unsigned long dsi_get_txbyteclkhs(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	return dsi->pll.cinfo.clkdco / 16;
>  }
>  
> -static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
> +static unsigned long dsi_fclk_rate(struct dsi_data *dsi)
>  {
>  	unsigned long r;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	enum dss_clk_source source;
>  
>  	source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id);
> @@ -1300,7 +1265,7 @@ static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
>  		r = clk_get_rate(dsi->dss_clk);
>  	} else {
>  		/* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */
> -		r = dsi_get_pll_hsdiv_dsi_rate(dsidev);
> +		r = dsi_get_pll_hsdiv_dsi_rate(dsi);
>  	}
>  
>  	return r;
> @@ -1325,9 +1290,8 @@ static int dsi_lp_clock_calc(unsigned long dsi_fclk,
>  	return 0;
>  }
>  
> -static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
> +static int dsi_set_lp_clk_divisor(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long dsi_fclk;
>  	unsigned int lp_clk_div;
>  	unsigned long lp_clk;
> @@ -1339,7 +1303,7 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
>  	if (lp_clk_div == 0 || lp_clk_div > lpdiv_max)
>  		return -EINVAL;
>  
> -	dsi_fclk = dsi_fclk_rate(dsidev);
> +	dsi_fclk = dsi_fclk_rate(dsi);
>  
>  	lp_clk = dsi_fclk / 2 / lp_clk_div;
>  
> @@ -1348,29 +1312,25 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
>  	dsi->current_lp_cinfo.lp_clk_div = lp_clk_div;
>  
>  	/* LP_CLK_DIVISOR */
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, lp_clk_div, 12, 0);
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, lp_clk_div, 12, 0);
>  
>  	/* LP_RX_SYNCHRO_ENABLE */
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21);
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21);
>  
>  	return 0;
>  }
>  
> -static void dsi_enable_scp_clk(struct platform_device *dsidev)
> +static void dsi_enable_scp_clk(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (dsi->scp_clk_refcount++ == 0)
> -		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */
> +		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */
>  }
>  
> -static void dsi_disable_scp_clk(struct platform_device *dsidev)
> +static void dsi_disable_scp_clk(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	WARN_ON(dsi->scp_clk_refcount == 0);
>  	if (--dsi->scp_clk_refcount == 0)
> -		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */
> +		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */
>  }
>  
>  enum dsi_pll_power_state {
> @@ -1380,10 +1340,8 @@ enum dsi_pll_power_state {
>  	DSI_PLL_POWER_ON_DIV	= 0x3,
>  };
>  
> -static int dsi_pll_power(struct platform_device *dsidev,
> -		enum dsi_pll_power_state state)
> +static int dsi_pll_power(struct dsi_data *dsi, enum dsi_pll_power_state state)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int t = 0;
>  
>  	/* DSI-PLL power command 0x3 is not working */
> @@ -1392,10 +1350,10 @@ static int dsi_pll_power(struct platform_device *dsidev,
>  		state = DSI_PLL_POWER_ON_ALL;
>  
>  	/* PLL_PWR_CMD */
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, state, 31, 30);
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, state, 31, 30);
>  
>  	/* PLL_PWR_STATUS */
> -	while (FLD_GET(dsi_read_reg(dsidev, DSI_CLK_CTRL), 29, 28) != state) {
> +	while (FLD_GET(dsi_read_reg(dsi, DSI_CLK_CTRL), 29, 28) != state) {
>  		if (++t > 1000) {
>  			DSSERR("Failed to set DSI PLL power mode to %d\n",
>  					state);
> @@ -1422,23 +1380,22 @@ static void dsi_pll_calc_dsi_fck(struct dsi_data *dsi,
>  static int dsi_pll_enable(struct dss_pll *pll)
>  {
>  	struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
> -	struct platform_device *dsidev = dsi->pdev;
>  	int r = 0;
>  
>  	DSSDBG("PLL init\n");
>  
> -	r = dsi_regulator_init(dsidev);
> +	r = dsi_regulator_init(dsi);
>  	if (r)
>  		return r;
>  
> -	r = dsi_runtime_get(dsidev);
> +	r = dsi_runtime_get(dsi);
>  	if (r)
>  		return r;
>  
>  	/*
>  	 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4.
>  	 */
> -	dsi_enable_scp_clk(dsidev);
> +	dsi_enable_scp_clk(dsi);
>  
>  	if (!dsi->vdds_dsi_enabled) {
>  		r = regulator_enable(dsi->vdds_dsi_reg);
> @@ -1450,7 +1407,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
>  	/* XXX PLL does not come out of reset without this... */
>  	dispc_pck_free_enable(1);
>  
> -	if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
> +	if (!wait_for_bit_change(dsi, DSI_PLL_STATUS, 0, 1)) {
>  		DSSERR("PLL not coming out of reset.\n");
>  		r = -ENODEV;
>  		dispc_pck_free_enable(0);
> @@ -1461,7 +1418,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
>  	 * fill the whole display. No idea about this */
>  	dispc_pck_free_enable(0);
>  
> -	r = dsi_pll_power(dsidev, DSI_PLL_POWER_ON_ALL);
> +	r = dsi_pll_power(dsi, DSI_PLL_POWER_ON_ALL);
>  
>  	if (r)
>  		goto err1;
> @@ -1475,24 +1432,22 @@ static int dsi_pll_enable(struct dss_pll *pll)
>  		dsi->vdds_dsi_enabled = false;
>  	}
>  err0:
> -	dsi_disable_scp_clk(dsidev);
> -	dsi_runtime_put(dsidev);
> +	dsi_disable_scp_clk(dsi);
> +	dsi_runtime_put(dsi);
>  	return r;
>  }
>  
> -static void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes)
> +static void dsi_pll_uninit(struct dsi_data *dsi, bool disconnect_lanes)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
> -	dsi_pll_power(dsidev, DSI_PLL_POWER_OFF);
> +	dsi_pll_power(dsi, DSI_PLL_POWER_OFF);
>  	if (disconnect_lanes) {
>  		WARN_ON(!dsi->vdds_dsi_enabled);
>  		regulator_disable(dsi->vdds_dsi_reg);
>  		dsi->vdds_dsi_enabled = false;
>  	}
>  
> -	dsi_disable_scp_clk(dsidev);
> -	dsi_runtime_put(dsidev);
> +	dsi_disable_scp_clk(dsi);
> +	dsi_runtime_put(dsi);
>  
>  	DSSDBG("PLL uninit done\n");
>  }
> @@ -1500,15 +1455,12 @@ static void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes
>  static void dsi_pll_disable(struct dss_pll *pll)
>  {
>  	struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
> -	struct platform_device *dsidev = dsi->pdev;
>  
> -	dsi_pll_uninit(dsidev, true);
> +	dsi_pll_uninit(dsi, true);
>  }
>  
> -static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
> -		struct seq_file *s)
> +static void dsi_dump_dsi_clocks(struct dsi_data *dsi, struct seq_file *s)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct dss_pll_clock_info *cinfo = &dsi->pll.cinfo;
>  	enum dss_clk_source dispc_clk_src, dsi_clk_src;
>  	int dsi_module = dsi->module_id;
> @@ -1517,7 +1469,7 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
>  	dispc_clk_src = dss_get_dispc_clk_source(dsi->dss);
>  	dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
>  
> -	if (dsi_runtime_get(dsidev))
> +	if (dsi_runtime_get(dsi))
>  		return;
>  
>  	seq_printf(s,	"- DSI%d PLL -\n", dsi_module + 1);
> @@ -1552,35 +1504,33 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
>  	seq_printf(s,	"dsi fclk source = %s\n",
>  			dss_get_clk_source_name(dsi_clk_src));
>  
> -	seq_printf(s,	"DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev));
> +	seq_printf(s,	"DSI_FCLK\t%lu\n", dsi_fclk_rate(dsi));
>  
>  	seq_printf(s,	"DDR_CLK\t\t%lu\n",
>  			cinfo->clkdco / 4);
>  
> -	seq_printf(s,	"TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev));
> +	seq_printf(s,	"TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsi));
>  
>  	seq_printf(s,	"LP_CLK\t\t%lu\n", dsi->current_lp_cinfo.lp_clk);
>  
> -	dsi_runtime_put(dsidev);
> +	dsi_runtime_put(dsi);
>  }
>  
>  void dsi_dump_clocks(struct seq_file *s)
>  {
> -	struct platform_device *dsidev;
> +	struct dsi_data *dsi;
>  	int i;
>  
>  	for  (i = 0; i < MAX_NUM_DSI; i++) {
> -		dsidev = dsi_get_dsidev_from_id(i);
> -		if (dsidev)
> -			dsi_dump_dsidev_clocks(dsidev, s);
> +		dsi = dsi_get_dsi_from_id(i);
> +		if (dsi)
> +			dsi_dump_dsi_clocks(dsi, s);
>  	}
>  }
>  
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
> -static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
> -		struct seq_file *s)
> +static void dsi_dump_dsi_irqs(struct dsi_data *dsi, struct seq_file *s)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned long flags;
>  	struct dsi_irq_stats stats;
>  
> @@ -1668,29 +1618,28 @@ static void dsi_dump_dsidev_irqs(struct platform_device *dsidev,
>  
>  static int dsi1_dump_irqs(struct seq_file *s, void *p)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
> +	struct dsi_data *dsi = dsi_get_dsi_from_id(0);
>  
> -	dsi_dump_dsidev_irqs(dsidev, s);
> +	dsi_dump_dsi_irqs(dsi, s);
>  	return 0;
>  }
>  
>  static int dsi2_dump_irqs(struct seq_file *s, void *p)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
> +	struct dsi_data *dsi = dsi_get_dsi_from_id(1);
>  
> -	dsi_dump_dsidev_irqs(dsidev, s);
> +	dsi_dump_dsi_irqs(dsi, s);
>  	return 0;
>  }
>  #endif
>  
> -static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
> -		struct seq_file *s)
> +static void dsi_dump_dsi_regs(struct dsi_data *dsi, struct seq_file *s)
>  {
> -#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r))
> +#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsi, r))
>  
> -	if (dsi_runtime_get(dsidev))
> +	if (dsi_runtime_get(dsi))
>  		return;
> -	dsi_enable_scp_clk(dsidev);
> +	dsi_enable_scp_clk(dsi);
>  
>  	DUMPREG(DSI_REVISION);
>  	DUMPREG(DSI_SYSCONFIG);
> @@ -1762,24 +1711,24 @@ static void dsi_dump_dsidev_regs(struct platform_device *dsidev,
>  	DUMPREG(DSI_PLL_CONFIGURATION1);
>  	DUMPREG(DSI_PLL_CONFIGURATION2);
>  
> -	dsi_disable_scp_clk(dsidev);
> -	dsi_runtime_put(dsidev);
> +	dsi_disable_scp_clk(dsi);
> +	dsi_runtime_put(dsi);
>  #undef DUMPREG
>  }
>  
>  static int dsi1_dump_regs(struct seq_file *s, void *p)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
> +	struct dsi_data *dsi = dsi_get_dsi_from_id(0);
>  
> -	dsi_dump_dsidev_regs(dsidev, s);
> +	dsi_dump_dsi_regs(dsi, s);
>  	return 0;
>  }
>  
>  static int dsi2_dump_regs(struct seq_file *s, void *p)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
> +	struct dsi_data *dsi = dsi_get_dsi_from_id(1);
>  
> -	dsi_dump_dsidev_regs(dsidev, s);
> +	dsi_dump_dsi_regs(dsi, s);
>  	return 0;
>  }
>  
> @@ -1789,16 +1738,15 @@ enum dsi_cio_power_state {
>  	DSI_COMPLEXIO_POWER_ULPS	= 0x2,
>  };
>  
> -static int dsi_cio_power(struct platform_device *dsidev,
> -		enum dsi_cio_power_state state)
> +static int dsi_cio_power(struct dsi_data *dsi, enum dsi_cio_power_state state)
>  {
>  	int t = 0;
>  
>  	/* PWR_CMD */
> -	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG1, state, 28, 27);
> +	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG1, state, 28, 27);
>  
>  	/* PWR_STATUS */
> -	while (FLD_GET(dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1),
> +	while (FLD_GET(dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1),
>  			26, 25) != state) {
>  		if (++t > 1000) {
>  			DSSERR("failed to set complexio power state to "
> @@ -1811,9 +1759,8 @@ static int dsi_cio_power(struct platform_device *dsidev,
>  	return 0;
>  }
>  
> -static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
> +static unsigned int dsi_get_line_buf_size(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int val;
>  
>  	/* line buffer on OMAP3 is 1024 x 24bits */
> @@ -1823,7 +1770,7 @@ static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
>  	if (!(dsi->data->quirks & DSI_QUIRK_GNQ))
>  		return 1023 * 3;
>  
> -	val = REG_GET(dsidev, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */
> +	val = REG_GET(dsi, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */
>  
>  	switch (val) {
>  	case 1:
> @@ -1846,9 +1793,8 @@ static unsigned int dsi_get_line_buf_size(struct platform_device *dsidev)
>  	}
>  }
>  
> -static int dsi_set_lane_config(struct platform_device *dsidev)
> +static int dsi_set_lane_config(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	static const u8 offsets[] = { 0, 4, 8, 12, 16 };
>  	static const enum dsi_lane_function functions[] = {
>  		DSI_LANE_CLK,
> @@ -1860,7 +1806,7 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
>  	u32 r;
>  	int i;
>  
> -	r = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1);
> +	r = dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1);
>  
>  	for (i = 0; i < dsi->num_lanes_used; ++i) {
>  		unsigned int offset = offsets[i];
> @@ -1889,33 +1835,28 @@ static int dsi_set_lane_config(struct platform_device *dsidev)
>  		r = FLD_MOD(r, 0, offset + 3, offset + 3);
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_COMPLEXIO_CFG1, r);
> +	dsi_write_reg(dsi, DSI_COMPLEXIO_CFG1, r);
>  
>  	return 0;
>  }
>  
> -static inline unsigned int ns2ddr(struct platform_device *dsidev,
> -				  unsigned int ns)
> +static inline unsigned int ns2ddr(struct dsi_data *dsi, unsigned int ns)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	/* convert time in ns to ddr ticks, rounding up */
>  	unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
> +
>  	return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
>  }
>  
> -static inline unsigned int ddr2ns(struct platform_device *dsidev,
> -				  unsigned int ddr)
> +static inline unsigned int ddr2ns(struct dsi_data *dsi, unsigned int ddr)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
> +
>  	return ddr * 1000 * 1000 / (ddr_clk / 1000);
>  }
>  
> -static void dsi_cio_timings(struct platform_device *dsidev)
> +static void dsi_cio_timings(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r;
>  	u32 ths_prepare, ths_prepare_ths_zero, ths_trail, ths_exit;
>  	u32 tlpx_half, tclk_trail, tclk_zero;
> @@ -1926,54 +1867,54 @@ static void dsi_cio_timings(struct platform_device *dsidev)
>  	/* 1 * DDR_CLK = 2 * UI */
>  
>  	/* min 40ns + 4*UI	max 85ns + 6*UI */
> -	ths_prepare = ns2ddr(dsidev, 70) + 2;
> +	ths_prepare = ns2ddr(dsi, 70) + 2;
>  
>  	/* min 145ns + 10*UI */
> -	ths_prepare_ths_zero = ns2ddr(dsidev, 175) + 2;
> +	ths_prepare_ths_zero = ns2ddr(dsi, 175) + 2;
>  
>  	/* min max(8*UI, 60ns+4*UI) */
> -	ths_trail = ns2ddr(dsidev, 60) + 5;
> +	ths_trail = ns2ddr(dsi, 60) + 5;
>  
>  	/* min 100ns */
> -	ths_exit = ns2ddr(dsidev, 145);
> +	ths_exit = ns2ddr(dsi, 145);
>  
>  	/* tlpx min 50n */
> -	tlpx_half = ns2ddr(dsidev, 25);
> +	tlpx_half = ns2ddr(dsi, 25);
>  
>  	/* min 60ns */
> -	tclk_trail = ns2ddr(dsidev, 60) + 2;
> +	tclk_trail = ns2ddr(dsi, 60) + 2;
>  
>  	/* min 38ns, max 95ns */
> -	tclk_prepare = ns2ddr(dsidev, 65);
> +	tclk_prepare = ns2ddr(dsi, 65);
>  
>  	/* min tclk-prepare + tclk-zero = 300ns */
> -	tclk_zero = ns2ddr(dsidev, 260);
> +	tclk_zero = ns2ddr(dsi, 260);
>  
>  	DSSDBG("ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n",
> -		ths_prepare, ddr2ns(dsidev, ths_prepare),
> -		ths_prepare_ths_zero, ddr2ns(dsidev, ths_prepare_ths_zero));
> +		ths_prepare, ddr2ns(dsi, ths_prepare),
> +		ths_prepare_ths_zero, ddr2ns(dsi, ths_prepare_ths_zero));
>  	DSSDBG("ths_trail %u (%uns), ths_exit %u (%uns)\n",
> -			ths_trail, ddr2ns(dsidev, ths_trail),
> -			ths_exit, ddr2ns(dsidev, ths_exit));
> +			ths_trail, ddr2ns(dsi, ths_trail),
> +			ths_exit, ddr2ns(dsi, ths_exit));
>  
>  	DSSDBG("tlpx_half %u (%uns), tclk_trail %u (%uns), "
>  			"tclk_zero %u (%uns)\n",
> -			tlpx_half, ddr2ns(dsidev, tlpx_half),
> -			tclk_trail, ddr2ns(dsidev, tclk_trail),
> -			tclk_zero, ddr2ns(dsidev, tclk_zero));
> +			tlpx_half, ddr2ns(dsi, tlpx_half),
> +			tclk_trail, ddr2ns(dsi, tclk_trail),
> +			tclk_zero, ddr2ns(dsi, tclk_zero));
>  	DSSDBG("tclk_prepare %u (%uns)\n",
> -			tclk_prepare, ddr2ns(dsidev, tclk_prepare));
> +			tclk_prepare, ddr2ns(dsi, tclk_prepare));
>  
>  	/* program timings */
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
>  	r = FLD_MOD(r, ths_prepare, 31, 24);
>  	r = FLD_MOD(r, ths_prepare_ths_zero, 23, 16);
>  	r = FLD_MOD(r, ths_trail, 15, 8);
>  	r = FLD_MOD(r, ths_exit, 7, 0);
> -	dsi_write_reg(dsidev, DSI_DSIPHY_CFG0, r);
> +	dsi_write_reg(dsi, DSI_DSIPHY_CFG0, r);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
>  	r = FLD_MOD(r, tlpx_half, 20, 16);
>  	r = FLD_MOD(r, tclk_trail, 15, 8);
>  	r = FLD_MOD(r, tclk_zero, 7, 0);
> @@ -1984,18 +1925,18 @@ static void dsi_cio_timings(struct platform_device *dsidev)
>  		r = FLD_MOD(r, 1, 23, 23);	/* CLKINP_SEL = enable */
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_DSIPHY_CFG1, r);
> +	dsi_write_reg(dsi, DSI_DSIPHY_CFG1, r);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2);
>  	r = FLD_MOD(r, tclk_prepare, 7, 0);
> -	dsi_write_reg(dsidev, DSI_DSIPHY_CFG2, r);
> +	dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r);
>  }
>  
>  /* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
> -static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
> -		unsigned int mask_p, unsigned int mask_n)
> +static void dsi_cio_enable_lane_override(struct dsi_data *dsi,
> +					 unsigned int mask_p,
> +					 unsigned int mask_n)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int i;
>  	u32 l;
>  	u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26;
> @@ -2024,26 +1965,25 @@ static void dsi_cio_enable_lane_override(struct platform_device *dsidev,
>  	/* Set the lane override configuration */
>  
>  	/* REGLPTXSCPDAT4TO0DXDY */
> -	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
> +	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
>  
>  	/* Enable lane override */
>  
>  	/* ENLPTXSCPDAT */
> -	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 1, 27, 27);
> +	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27);
>  }
>  
> -static void dsi_cio_disable_lane_override(struct platform_device *dsidev)
> +static void dsi_cio_disable_lane_override(struct dsi_data *dsi)
>  {
>  	/* Disable lane override */
> -	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
> +	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
>  	/* Reset the lane override configuration */
>  	/* REGLPTXSCPDAT4TO0DXDY */
> -	REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 22, 17);
> +	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17);
>  }
>  
> -static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
> +static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int t, i;
>  	bool in_use[DSI_MAX_NR_LANES];
>  	static const u8 offsets_old[] = { 28, 27, 26 };
> @@ -2063,7 +2003,7 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
>  		u32 l;
>  		int ok;
>  
> -		l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
> +		l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
>  
>  		ok = 0;
>  		for (i = 0; i < dsi->num_lanes_supported; ++i) {
> @@ -2090,9 +2030,8 @@ static int dsi_cio_wait_tx_clk_esc_reset(struct platform_device *dsidev)
>  }
>  
>  /* return bitmask of enabled lanes, lane0 being the lsb */
> -static unsigned int dsi_get_lane_mask(struct platform_device *dsidev)
> +static unsigned int dsi_get_lane_mask(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned int mask = 0;
>  	int i;
>  
> @@ -2181,42 +2120,41 @@ static void dsi_disable_pads(struct dsi_data *dsi)
>  		dsi_omap5_mux_pads(dsi, 0);
>  }
>  
> -static int dsi_cio_init(struct platform_device *dsidev)
> +static int dsi_cio_init(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  	u32 l;
>  
>  	DSSDBG("DSI CIO init starts");
>  
> -	r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev));
> +	r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsi));
>  	if (r)
>  		return r;
>  
> -	dsi_enable_scp_clk(dsidev);
> +	dsi_enable_scp_clk(dsi);
>  
>  	/* A dummy read using the SCP interface to any DSIPHY register is
>  	 * required after DSIPHY reset to complete the reset of the DSI complex
>  	 * I/O. */
> -	dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
> +	dsi_read_reg(dsi, DSI_DSIPHY_CFG5);
>  
> -	if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
> +	if (!wait_for_bit_change(dsi, DSI_DSIPHY_CFG5, 30, 1)) {
>  		DSSERR("CIO SCP Clock domain not coming out of reset.\n");
>  		r = -EIO;
>  		goto err_scp_clk_dom;
>  	}
>  
> -	r = dsi_set_lane_config(dsidev);
> +	r = dsi_set_lane_config(dsi);
>  	if (r)
>  		goto err_scp_clk_dom;
>  
>  	/* set TX STOP MODE timer to maximum for this operation */
> -	l = dsi_read_reg(dsidev, DSI_TIMING1);
> +	l = dsi_read_reg(dsi, DSI_TIMING1);
>  	l = FLD_MOD(l, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
>  	l = FLD_MOD(l, 1, 14, 14);	/* STOP_STATE_X16_IO */
>  	l = FLD_MOD(l, 1, 13, 13);	/* STOP_STATE_X4_IO */
>  	l = FLD_MOD(l, 0x1fff, 12, 0);	/* STOP_STATE_COUNTER_IO */
> -	dsi_write_reg(dsidev, DSI_TIMING1, l);
> +	dsi_write_reg(dsi, DSI_TIMING1, l);
>  
>  	if (dsi->ulps_enabled) {
>  		unsigned int mask_p;
> @@ -2241,24 +2179,24 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  			mask_p |= 1 << i;
>  		}
>  
> -		dsi_cio_enable_lane_override(dsidev, mask_p, 0);
> +		dsi_cio_enable_lane_override(dsi, mask_p, 0);
>  	}
>  
> -	r = dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ON);
> +	r = dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ON);
>  	if (r)
>  		goto err_cio_pwr;
>  
> -	if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
> +	if (!wait_for_bit_change(dsi, DSI_COMPLEXIO_CFG1, 29, 1)) {
>  		DSSERR("CIO PWR clock domain not coming out of reset.\n");
>  		r = -ENODEV;
>  		goto err_cio_pwr_dom;
>  	}
>  
> -	dsi_if_enable(dsidev, true);
> -	dsi_if_enable(dsidev, false);
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */
> +	dsi_if_enable(dsi, true);
> +	dsi_if_enable(dsi, false);
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */
>  
> -	r = dsi_cio_wait_tx_clk_esc_reset(dsidev);
> +	r = dsi_cio_wait_tx_clk_esc_reset(dsi);
>  	if (r)
>  		goto err_tx_clk_esc_rst;
>  
> @@ -2270,17 +2208,17 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  
>  		/* Disable the override. The lanes should be set to Mark-11
>  		 * state by the HW */
> -		dsi_cio_disable_lane_override(dsidev);
> +		dsi_cio_disable_lane_override(dsi);
>  	}
>  
>  	/* FORCE_TX_STOP_MODE_IO */
> -	REG_FLD_MOD(dsidev, DSI_TIMING1, 0, 15, 15);
> +	REG_FLD_MOD(dsi, DSI_TIMING1, 0, 15, 15);
>  
> -	dsi_cio_timings(dsidev);
> +	dsi_cio_timings(dsi);
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
>  		/* DDR_CLK_ALWAYS_ON */
> -		REG_FLD_MOD(dsidev, DSI_CLK_CTRL,
> +		REG_FLD_MOD(dsi, DSI_CLK_CTRL,
>  			dsi->vm_timings.ddr_clk_always_on, 13, 13);
>  	}
>  
> @@ -2291,35 +2229,32 @@ static int dsi_cio_init(struct platform_device *dsidev)
>  	return 0;
>  
>  err_tx_clk_esc_rst:
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */
>  err_cio_pwr_dom:
> -	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF);
> +	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
>  err_cio_pwr:
>  	if (dsi->ulps_enabled)
> -		dsi_cio_disable_lane_override(dsidev);
> +		dsi_cio_disable_lane_override(dsi);
>  err_scp_clk_dom:
> -	dsi_disable_scp_clk(dsidev);
> +	dsi_disable_scp_clk(dsi);
>  	dsi_disable_pads(dsi);
>  	return r;
>  }
>  
> -static void dsi_cio_uninit(struct platform_device *dsidev)
> +static void dsi_cio_uninit(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	/* DDR_CLK_ALWAYS_ON */
> -	REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13);
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
>  
> -	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF);
> -	dsi_disable_scp_clk(dsidev);
> +	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
> +	dsi_disable_scp_clk(dsi);
>  	dsi_disable_pads(dsi);
>  }
>  
> -static void dsi_config_tx_fifo(struct platform_device *dsidev,
> -		enum fifo_size size1, enum fifo_size size2,
> -		enum fifo_size size3, enum fifo_size size4)
> +static void dsi_config_tx_fifo(struct dsi_data *dsi,
> +			       enum fifo_size size1, enum fifo_size size2,
> +			       enum fifo_size size3, enum fifo_size size4)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r = 0;
>  	int add = 0;
>  	int i;
> @@ -2345,14 +2280,13 @@ static void dsi_config_tx_fifo(struct platform_device *dsidev,
>  		add += size;
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_TX_FIFO_VC_SIZE, r);
> +	dsi_write_reg(dsi, DSI_TX_FIFO_VC_SIZE, r);
>  }
>  
> -static void dsi_config_rx_fifo(struct platform_device *dsidev,
> +static void dsi_config_rx_fifo(struct dsi_data *dsi,
>  		enum fifo_size size1, enum fifo_size size2,
>  		enum fifo_size size3, enum fifo_size size4)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r = 0;
>  	int add = 0;
>  	int i;
> @@ -2378,18 +2312,18 @@ static void dsi_config_rx_fifo(struct platform_device *dsidev,
>  		add += size;
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_RX_FIFO_VC_SIZE, r);
> +	dsi_write_reg(dsi, DSI_RX_FIFO_VC_SIZE, r);
>  }
>  
> -static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
> +static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi)
>  {
>  	u32 r;
>  
> -	r = dsi_read_reg(dsidev, DSI_TIMING1);
> +	r = dsi_read_reg(dsi, DSI_TIMING1);
>  	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
> -	dsi_write_reg(dsidev, DSI_TIMING1, r);
> +	dsi_write_reg(dsi, DSI_TIMING1, r);
>  
> -	if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
> +	if (!wait_for_bit_change(dsi, DSI_TIMING1, 15, 0)) {
>  		DSSERR("TX_STOP bit not going down\n");
>  		return -EIO;
>  	}
> @@ -2397,29 +2331,28 @@ static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
>  	return 0;
>  }
>  
> -static bool dsi_vc_is_enabled(struct platform_device *dsidev, int channel)
> +static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel)
>  {
> -	return REG_GET(dsidev, DSI_VC_CTRL(channel), 0, 0);
> +	return REG_GET(dsi, DSI_VC_CTRL(channel), 0, 0);
>  }
>  
>  static void dsi_packet_sent_handler_vp(void *data, u32 mask)
>  {
>  	struct dsi_packet_sent_handler_data *vp_data =
>  		(struct dsi_packet_sent_handler_data *) data;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(vp_data->dsidev);
> +	struct dsi_data *dsi = vp_data->dsi;
>  	const int channel = dsi->update_channel;
>  	u8 bit = dsi->te_enabled ? 30 : 31;
>  
> -	if (REG_GET(vp_data->dsidev, DSI_VC_TE(channel), bit, bit) == 0)
> +	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit) == 0)
>  		complete(vp_data->completion);
>  }
>  
> -static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
> +static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	struct dsi_packet_sent_handler_data vp_data = {
> -		.dsidev = dsidev,
> +		.dsi = dsi,
>  		.completion = &completion
>  	};
>  	int r = 0;
> @@ -2427,13 +2360,13 @@ static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
>  
>  	bit = dsi->te_enabled ? 30 : 31;
>  
> -	r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
> +	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  	if (r)
>  		goto err0;
>  
>  	/* Wait for completion only if TE_EN/TE_START is still set */
> -	if (REG_GET(dsidev, DSI_VC_TE(channel), bit, bit)) {
> +	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit)) {
>  		if (wait_for_completion_timeout(&completion,
>  				msecs_to_jiffies(10)) == 0) {
>  			DSSERR("Failed to complete previous frame transfer\n");
> @@ -2442,12 +2375,12 @@ static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel)
>  		}
>  	}
>  
> -	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
> +	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  
>  	return 0;
>  err1:
> -	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
> +	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  err0:
>  	return r;
> @@ -2457,29 +2390,29 @@ static void dsi_packet_sent_handler_l4(void *data, u32 mask)
>  {
>  	struct dsi_packet_sent_handler_data *l4_data =
>  		(struct dsi_packet_sent_handler_data *) data;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(l4_data->dsidev);
> +	struct dsi_data *dsi = l4_data->dsi;
>  	const int channel = dsi->update_channel;
>  
> -	if (REG_GET(l4_data->dsidev, DSI_VC_CTRL(channel), 5, 5) == 0)
> +	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5) == 0)
>  		complete(l4_data->completion);
>  }
>  
> -static int dsi_sync_vc_l4(struct platform_device *dsidev, int channel)
> +static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
>  {
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	struct dsi_packet_sent_handler_data l4_data = {
> -		.dsidev = dsidev,
> +		.dsi = dsi,
>  		.completion = &completion
>  	};
>  	int r = 0;
>  
> -	r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
> +	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  	if (r)
>  		goto err0;
>  
>  	/* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
> -	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 5, 5)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5)) {
>  		if (wait_for_completion_timeout(&completion,
>  				msecs_to_jiffies(10)) == 0) {
>  			DSSERR("Failed to complete previous l4 transfer\n");
> @@ -2488,50 +2421,47 @@ static int dsi_sync_vc_l4(struct platform_device *dsidev, int channel)
>  		}
>  	}
>  
> -	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
> +	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  
>  	return 0;
>  err1:
> -	dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
> +	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  err0:
>  	return r;
>  }
>  
> -static int dsi_sync_vc(struct platform_device *dsidev, int channel)
> +static int dsi_sync_vc(struct dsi_data *dsi, int channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	WARN_ON(in_interrupt());
>  
> -	if (!dsi_vc_is_enabled(dsidev, channel))
> +	if (!dsi_vc_is_enabled(dsi, channel))
>  		return 0;
>  
>  	switch (dsi->vc[channel].source) {
>  	case DSI_VC_SOURCE_VP:
> -		return dsi_sync_vc_vp(dsidev, channel);
> +		return dsi_sync_vc_vp(dsi, channel);
>  	case DSI_VC_SOURCE_L4:
> -		return dsi_sync_vc_l4(dsidev, channel);
> +		return dsi_sync_vc_l4(dsi, channel);
>  	default:
>  		BUG();
>  		return -EINVAL;
>  	}
>  }
>  
> -static int dsi_vc_enable(struct platform_device *dsidev, int channel,
> -		bool enable)
> +static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
>  {
>  	DSSDBG("dsi_vc_enable channel %d, enable %d\n",
>  			channel, enable);
>  
>  	enable = enable ? 1 : 0;
>  
> -	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 0, 0);
>  
> -	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
> +	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 0, enable)) {
>  		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
>  		return -EIO;
>  	}
> @@ -2539,14 +2469,13 @@ static int dsi_vc_enable(struct platform_device *dsidev, int channel,
>  	return 0;
>  }
>  
> -static void dsi_vc_initial_config(struct platform_device *dsidev, int channel)
> +static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r;
>  
>  	DSSDBG("Initial config of virtual channel %d", channel);
>  
> -	r = dsi_read_reg(dsidev, DSI_VC_CTRL(channel));
> +	r = dsi_read_reg(dsi, DSI_VC_CTRL(channel));
>  
>  	if (FLD_GET(r, 15, 15)) /* VC_BUSY */
>  		DSSERR("VC(%d) busy when trying to configure it!\n",
> @@ -2565,41 +2494,39 @@ static void dsi_vc_initial_config(struct platform_device *dsidev, int channel)
>  	r = FLD_MOD(r, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
>  	r = FLD_MOD(r, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
>  
> -	dsi_write_reg(dsidev, DSI_VC_CTRL(channel), r);
> +	dsi_write_reg(dsi, DSI_VC_CTRL(channel), r);
>  
>  	dsi->vc[channel].source = DSI_VC_SOURCE_L4;
>  }
>  
> -static int dsi_vc_config_source(struct platform_device *dsidev, int channel,
> -		enum dsi_vc_source source)
> +static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
> +				enum dsi_vc_source source)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (dsi->vc[channel].source == source)
>  		return 0;
>  
>  	DSSDBG("Source config of virtual channel %d", channel);
>  
> -	dsi_sync_vc(dsidev, channel);
> +	dsi_sync_vc(dsi, channel);
>  
> -	dsi_vc_enable(dsidev, channel, 0);
> +	dsi_vc_enable(dsi, channel, 0);
>  
>  	/* VC_BUSY */
> -	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0)) {
> +	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 15, 0)) {
>  		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
>  		return -EIO;
>  	}
>  
>  	/* SOURCE, 0 = L4, 1 = video port */
> -	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), source, 1, 1);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), source, 1, 1);
>  
>  	/* DCS_CMD_ENABLE */
>  	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
>  		bool enable = source == DSI_VC_SOURCE_VP;
> -		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 30, 30);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 30, 30);
>  	}
>  
> -	dsi_vc_enable(dsidev, channel, 1);
> +	dsi_vc_enable(dsi, channel, 1);
>  
>  	dsi->vc[channel].source = source;
>  
> @@ -2614,28 +2541,28 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
>  
>  	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> -	dsi_vc_enable(dsidev, channel, 0);
> -	dsi_if_enable(dsidev, 0);
> +	dsi_vc_enable(dsi, channel, 0);
> +	dsi_if_enable(dsi, 0);
>  
> -	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 9, 9);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 9, 9);
>  
> -	dsi_vc_enable(dsidev, channel, 1);
> -	dsi_if_enable(dsidev, 1);
> +	dsi_vc_enable(dsi, channel, 1);
> +	dsi_if_enable(dsi, 1);
>  
> -	dsi_force_tx_stop_mode_io(dsidev);
> +	dsi_force_tx_stop_mode_io(dsi);
>  
>  	/* start the DDR clock by sending a NULL packet */
>  	if (dsi->vm_timings.ddr_clk_always_on && enable)
> -		dsi_vc_send_null(dssdev, channel);
> +		dsi_vc_send_null(dsi, channel);
>  }
>  
> -static void dsi_vc_flush_long_data(struct platform_device *dsidev, int channel)
> +static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
>  {
> -	while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
> +	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
>  		u32 val;
> -		val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
> +		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
>  		DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
>  				(val >> 0) & 0xff,
>  				(val >> 8) & 0xff,
> @@ -2681,14 +2608,13 @@ static void dsi_show_rx_ack_with_err(u16 err)
>  		DSSERR("\t\tDSI Protocol Violation\n");
>  }
>  
> -static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
> -		int channel)
> +static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
>  {
>  	/* RX_FIFO_NOT_EMPTY */
> -	while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
> +	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
>  		u32 val;
>  		u8 dt;
> -		val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
> +		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
>  		DSSERR("\trawval %#08x\n", val);
>  		dt = FLD_GET(val, 5, 0);
>  		if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) {
> @@ -2703,7 +2629,7 @@ static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
>  		} else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) {
>  			DSSERR("\tDCS long response, len %d\n",
>  					FLD_GET(val, 23, 8));
> -			dsi_vc_flush_long_data(dsidev, channel);
> +			dsi_vc_flush_long_data(dsi, channel);
>  		} else {
>  			DSSERR("\tunknown datatype 0x%02x\n", dt);
>  		}
> @@ -2711,25 +2637,23 @@ static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev,
>  	return 0;
>  }
>  
> -static int dsi_vc_send_bta(struct platform_device *dsidev, int channel)
> +static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (dsi->debug_write || dsi->debug_read)
>  		DSSDBG("dsi_vc_send_bta %d\n", channel);
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
>  		DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
> -		dsi_vc_flush_receive_data(dsidev, channel);
> +		dsi_vc_flush_receive_data(dsi, channel);
>  	}
>  
> -	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
>  
>  	/* flush posted write */
> -	dsi_read_reg(dsidev, DSI_VC_CTRL(channel));
> +	dsi_read_reg(dsi, DSI_VC_CTRL(channel));
>  
>  	return 0;
>  }
> @@ -2737,21 +2661,22 @@ static int dsi_vc_send_bta(struct platform_device *dsidev, int channel)
>  static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	int r = 0;
>  	u32 err;
>  
> -	r = dsi_register_isr_vc(dsidev, channel, dsi_completion_handler,
> +	r = dsi_register_isr_vc(dsi, channel, dsi_completion_handler,
>  			&completion, DSI_VC_IRQ_BTA);
>  	if (r)
>  		goto err0;
>  
> -	r = dsi_register_isr(dsidev, dsi_completion_handler, &completion,
> +	r = dsi_register_isr(dsi, dsi_completion_handler, &completion,
>  			DSI_IRQ_ERROR_MASK);
>  	if (r)
>  		goto err1;
>  
> -	r = dsi_vc_send_bta(dsidev, channel);
> +	r = dsi_vc_send_bta(dsi, channel);
>  	if (r)
>  		goto err2;
>  
> @@ -2762,41 +2687,40 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
>  		goto err2;
>  	}
>  
> -	err = dsi_get_errors(dsidev);
> +	err = dsi_get_errors(dsi);
>  	if (err) {
>  		DSSERR("Error while sending BTA: %x\n", err);
>  		r = -EIO;
>  		goto err2;
>  	}
>  err2:
> -	dsi_unregister_isr(dsidev, dsi_completion_handler, &completion,
> +	dsi_unregister_isr(dsi, dsi_completion_handler, &completion,
>  			DSI_IRQ_ERROR_MASK);
>  err1:
> -	dsi_unregister_isr_vc(dsidev, channel, dsi_completion_handler,
> +	dsi_unregister_isr_vc(dsi, channel, dsi_completion_handler,
>  			&completion, DSI_VC_IRQ_BTA);
>  err0:
>  	return r;
>  }
>  
> -static inline void dsi_vc_write_long_header(struct platform_device *dsidev,
> -		int channel, u8 data_type, u16 len, u8 ecc)
> +static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
> +					    u8 data_type, u16 len, u8 ecc)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 val;
>  	u8 data_id;
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	data_id = data_type | dsi->vc[channel].vc_id << 6;
>  
>  	val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
>  		FLD_VAL(ecc, 31, 24);
>  
> -	dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_HEADER(channel), val);
> +	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(channel), val);
>  }
>  
> -static inline void dsi_vc_write_long_payload(struct platform_device *dsidev,
> -		int channel, u8 b1, u8 b2, u8 b3, u8 b4)
> +static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
> +					     u8 b1, u8 b2, u8 b3, u8 b4)
>  {
>  	u32 val;
>  
> @@ -2805,14 +2729,13 @@ static inline void dsi_vc_write_long_payload(struct platform_device *dsidev,
>  /*	DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
>  			b1, b2, b3, b4, val); */
>  
> -	dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
> +	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
>  }
>  
> -static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
> -		u8 data_type, u8 *data, u16 len, u8 ecc)
> +static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
> +			    u8 *data, u16 len, u8 ecc)
>  {
>  	/*u32 val; */
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int i;
>  	u8 *p;
>  	int r = 0;
> @@ -2827,9 +2750,9 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
>  		return -EINVAL;
>  	}
>  
> -	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4);
> +	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
>  
> -	dsi_vc_write_long_header(dsidev, channel, data_type, len, ecc);
> +	dsi_vc_write_long_header(dsi, channel, data_type, len, ecc);
>  
>  	p = data;
>  	for (i = 0; i < len >> 2; i++) {
> @@ -2841,7 +2764,7 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
>  		b3 = *p++;
>  		b4 = *p++;
>  
> -		dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, b4);
> +		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4);
>  	}
>  
>  	i = len % 4;
> @@ -2866,29 +2789,28 @@ static int dsi_vc_send_long(struct platform_device *dsidev, int channel,
>  			break;
>  		}
>  
> -		dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, 0);
> +		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0);
>  	}
>  
>  	return r;
>  }
>  
> -static int dsi_vc_send_short(struct platform_device *dsidev, int channel,
> -		u8 data_type, u16 data, u8 ecc)
> +static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
> +			     u16 data, u8 ecc)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r;
>  	u8 data_id;
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	if (dsi->debug_write)
>  		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
>  				channel,
>  				data_type, data & 0xff, (data >> 8) & 0xff);
>  
> -	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4);
> +	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
>  
> -	if (FLD_GET(dsi_read_reg(dsidev, DSI_VC_CTRL(channel)), 16, 16)) {
> +	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) {
>  		DSSERR("ERROR FIFO FULL, aborting transfer\n");
>  		return -EINVAL;
>  	}
> @@ -2897,41 +2819,39 @@ static int dsi_vc_send_short(struct platform_device *dsidev, int channel,
>  
>  	r = (data_id << 0) | (data << 8) | (ecc << 24);
>  
> -	dsi_write_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel), r);
> +	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r);
>  
>  	return 0;
>  }
>  
> -static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel)
> +static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -
> -	return dsi_vc_send_long(dsidev, channel, MIPI_DSI_NULL_PACKET, NULL,
> -		0, 0);
> +	return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
>  }
>  
> -static int dsi_vc_write_nosync_common(struct platform_device *dsidev,
> -		int channel, u8 *data, int len, enum dss_dsi_content_type type)
> +static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
> +				      u8 *data, int len,
> +				      enum dss_dsi_content_type type)
>  {
>  	int r;
>  
>  	if (len == 0) {
>  		BUG_ON(type == DSS_DSI_CONTENT_DCS);
> -		r = dsi_vc_send_short(dsidev, channel,
> +		r = dsi_vc_send_short(dsi, channel,
>  				MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0);
>  	} else if (len == 1) {
> -		r = dsi_vc_send_short(dsidev, channel,
> +		r = dsi_vc_send_short(dsi, channel,
>  				type == DSS_DSI_CONTENT_GENERIC ?
>  				MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
>  				MIPI_DSI_DCS_SHORT_WRITE, data[0], 0);
>  	} else if (len == 2) {
> -		r = dsi_vc_send_short(dsidev, channel,
> +		r = dsi_vc_send_short(dsi, channel,
>  				type == DSS_DSI_CONTENT_GENERIC ?
>  				MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
>  				MIPI_DSI_DCS_SHORT_WRITE_PARAM,
>  				data[0] | (data[1] << 8), 0);
>  	} else {
> -		r = dsi_vc_send_long(dsidev, channel,
> +		r = dsi_vc_send_long(dsi, channel,
>  				type == DSS_DSI_CONTENT_GENERIC ?
>  				MIPI_DSI_GENERIC_LONG_WRITE :
>  				MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
> @@ -2944,8 +2864,9 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
>  		u8 *data, int len)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> -	return dsi_vc_write_nosync_common(dsidev, channel, data, len,
> +	return dsi_vc_write_nosync_common(dsi, channel, data, len,
>  			DSS_DSI_CONTENT_DCS);
>  }
>  
> @@ -2953,18 +2874,21 @@ static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int chann
>  		u8 *data, int len)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> -	return dsi_vc_write_nosync_common(dsidev, channel, data, len,
> +	return dsi_vc_write_nosync_common(dsi, channel, data, len,
>  			DSS_DSI_CONTENT_GENERIC);
>  }
>  
> -static int dsi_vc_write_common(struct omap_dss_device *dssdev, int channel,
> -		u8 *data, int len, enum dss_dsi_content_type type)
> +static int dsi_vc_write_common(struct omap_dss_device *dssdev,
> +			       int channel, u8 *data, int len,
> +			       enum dss_dsi_content_type type)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
> -	r = dsi_vc_write_nosync_common(dsidev, channel, data, len, type);
> +	r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
>  	if (r)
>  		goto err;
>  
> @@ -2973,9 +2897,9 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev, int channel,
>  		goto err;
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
>  		DSSERR("rx fifo not empty after write, dumping data:\n");
> -		dsi_vc_flush_receive_data(dsidev, channel);
> +		dsi_vc_flush_receive_data(dsi, channel);
>  		r = -EIO;
>  		goto err;
>  	}
> @@ -3001,17 +2925,16 @@ static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8
>  			DSS_DSI_CONTENT_GENERIC);
>  }
>  
> -static int dsi_vc_dcs_send_read_request(struct platform_device *dsidev,
> -		int channel, u8 dcs_cmd)
> +static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
> +					u8 dcs_cmd)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
>  	if (dsi->debug_read)
>  		DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
>  			channel, dcs_cmd);
>  
> -	r = dsi_vc_send_short(dsidev, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
> +	r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
>  	if (r) {
>  		DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
>  			" failed\n", channel, dcs_cmd);
> @@ -3021,10 +2944,9 @@ static int dsi_vc_dcs_send_read_request(struct platform_device *dsidev,
>  	return 0;
>  }
>  
> -static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
> -		int channel, u8 *reqdata, int reqlen)
> +static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
> +					    u8 *reqdata, int reqlen)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u16 data;
>  	u8 data_type;
>  	int r;
> @@ -3047,7 +2969,7 @@ static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
>  		return -EINVAL;
>  	}
>  
> -	r = dsi_vc_send_short(dsidev, channel, data_type, data, 0);
> +	r = dsi_vc_send_short(dsi, channel, data_type, data, 0);
>  	if (r) {
>  		DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
>  			" failed\n", channel, reqlen);
> @@ -3057,22 +2979,21 @@ static int dsi_vc_generic_send_read_request(struct platform_device *dsidev,
>  	return 0;
>  }
>  
> -static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel,
> -		u8 *buf, int buflen, enum dss_dsi_content_type type)
> +static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
> +			       int buflen, enum dss_dsi_content_type type)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 val;
>  	u8 dt;
>  	int r;
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20) == 0) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20) == 0) {
>  		DSSERR("RX fifo empty when trying to read.\n");
>  		r = -EIO;
>  		goto err;
>  	}
>  
> -	val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel));
> +	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
>  	if (dsi->debug_read)
>  		DSSDBG("\theader: %08x\n", val);
>  	dt = FLD_GET(val, 5, 0);
> @@ -3135,7 +3056,7 @@ static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel,
>  		/* two byte checksum ends the packet, not included in len */
>  		for (w = 0; w < len + 2;) {
>  			int b;
> -			val = dsi_read_reg(dsidev,
> +			val = dsi_read_reg(dsi,
>  				DSI_VC_SHORT_PACKET_HEADER(channel));
>  			if (dsi->debug_read)
>  				DSSDBG("\t\t%02x %02x %02x %02x\n",
> @@ -3170,9 +3091,10 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
>  		u8 *buf, int buflen)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
> -	r = dsi_vc_dcs_send_read_request(dsidev, channel, dcs_cmd);
> +	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
>  	if (r)
>  		goto err;
>  
> @@ -3180,7 +3102,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
> +	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
>  		DSS_DSI_CONTENT_DCS);
>  	if (r < 0)
>  		goto err;
> @@ -3200,9 +3122,10 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
>  		u8 *reqdata, int reqlen, u8 *buf, int buflen)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
> -	r = dsi_vc_generic_send_read_request(dsidev, channel, reqdata, reqlen);
> +	r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
>  	if (r)
>  		return r;
>  
> @@ -3210,7 +3133,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
>  	if (r)
>  		return r;
>  
> -	r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
> +	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
>  		DSS_DSI_CONTENT_GENERIC);
>  	if (r < 0)
>  		return r;
> @@ -3227,21 +3150,21 @@ static int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int cha
>  		u16 len)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  
> -	return dsi_vc_send_short(dsidev, channel,
> +	return dsi_vc_send_short(dsi, channel,
>  			MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
>  }
>  
> -static int dsi_enter_ulps(struct platform_device *dsidev)
> +static int dsi_enter_ulps(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	int r, i;
>  	unsigned int mask;
>  
>  	DSSDBG("Entering ULPS");
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	WARN_ON(dsi->ulps_enabled);
>  
> @@ -3249,35 +3172,35 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
>  		return 0;
>  
>  	/* DDR_CLK_ALWAYS_ON */
> -	if (REG_GET(dsidev, DSI_CLK_CTRL, 13, 13)) {
> -		dsi_if_enable(dsidev, 0);
> -		REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13);
> -		dsi_if_enable(dsidev, 1);
> +	if (REG_GET(dsi, DSI_CLK_CTRL, 13, 13)) {
> +		dsi_if_enable(dsi, 0);
> +		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
> +		dsi_if_enable(dsi, 1);
>  	}
>  
> -	dsi_sync_vc(dsidev, 0);
> -	dsi_sync_vc(dsidev, 1);
> -	dsi_sync_vc(dsidev, 2);
> -	dsi_sync_vc(dsidev, 3);
> +	dsi_sync_vc(dsi, 0);
> +	dsi_sync_vc(dsi, 1);
> +	dsi_sync_vc(dsi, 2);
> +	dsi_sync_vc(dsi, 3);
>  
> -	dsi_force_tx_stop_mode_io(dsidev);
> +	dsi_force_tx_stop_mode_io(dsi);
>  
> -	dsi_vc_enable(dsidev, 0, false);
> -	dsi_vc_enable(dsidev, 1, false);
> -	dsi_vc_enable(dsidev, 2, false);
> -	dsi_vc_enable(dsidev, 3, false);
> +	dsi_vc_enable(dsi, 0, false);
> +	dsi_vc_enable(dsi, 1, false);
> +	dsi_vc_enable(dsi, 2, false);
> +	dsi_vc_enable(dsi, 3, false);
>  
> -	if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
> +	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
>  		DSSERR("HS busy when enabling ULPS\n");
>  		return -EIO;
>  	}
>  
> -	if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
> +	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
>  		DSSERR("LP busy when enabling ULPS\n");
>  		return -EIO;
>  	}
>  
> -	r = dsi_register_isr_cio(dsidev, dsi_completion_handler, &completion,
> +	r = dsi_register_isr_cio(dsi, dsi_completion_handler, &completion,
>  			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
>  	if (r)
>  		return r;
> @@ -3291,10 +3214,10 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
>  	}
>  	/* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
>  	/* LANEx_ULPS_SIG2 */
> -	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, mask, 9, 5);
> +	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, mask, 9, 5);
>  
>  	/* flush posted write and wait for SCP interface to finish the write */
> -	dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2);
> +	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
>  
>  	if (wait_for_completion_timeout(&completion,
>  				msecs_to_jiffies(1000)) == 0) {
> @@ -3303,31 +3226,31 @@ static int dsi_enter_ulps(struct platform_device *dsidev)
>  		goto err;
>  	}
>  
> -	dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion,
> +	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
>  			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
>  
>  	/* Reset LANEx_ULPS_SIG2 */
> -	REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, 0, 9, 5);
> +	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, 0, 9, 5);
>  
>  	/* flush posted write and wait for SCP interface to finish the write */
> -	dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2);
> +	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
>  
> -	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ULPS);
> +	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ULPS);
>  
> -	dsi_if_enable(dsidev, false);
> +	dsi_if_enable(dsi, false);
>  
>  	dsi->ulps_enabled = true;
>  
>  	return 0;
>  
>  err:
> -	dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion,
> +	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
>  			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
>  	return r;
>  }
>  
> -static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
> -		unsigned int ticks, bool x4, bool x16)
> +static void dsi_set_lp_rx_timeout(struct dsi_data *dsi, unsigned int ticks,
> +				  bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3336,14 +3259,14 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
>  	BUG_ON(ticks > 0x1fff);
>  
>  	/* ticks in DSI_FCK */
> -	fck = dsi_fclk_rate(dsidev);
> +	fck = dsi_fclk_rate(dsi);
>  
> -	r = dsi_read_reg(dsidev, DSI_TIMING2);
> +	r = dsi_read_reg(dsi, DSI_TIMING2);
>  	r = FLD_MOD(r, 1, 15, 15);	/* LP_RX_TO */
>  	r = FLD_MOD(r, x16 ? 1 : 0, 14, 14);	/* LP_RX_TO_X16 */
>  	r = FLD_MOD(r, x4 ? 1 : 0, 13, 13);	/* LP_RX_TO_X4 */
>  	r = FLD_MOD(r, ticks, 12, 0);	/* LP_RX_COUNTER */
> -	dsi_write_reg(dsidev, DSI_TIMING2, r);
> +	dsi_write_reg(dsi, DSI_TIMING2, r);
>  
>  	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
>  
> @@ -3353,8 +3276,8 @@ static void dsi_set_lp_rx_timeout(struct platform_device *dsidev,
>  			(total_ticks * 1000) / (fck / 1000 / 1000));
>  }
>  
> -static void dsi_set_ta_timeout(struct platform_device *dsidev,
> -			       unsigned int ticks, bool x8, bool x16)
> +static void dsi_set_ta_timeout(struct dsi_data *dsi, unsigned int ticks,
> +			       bool x8, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3363,14 +3286,14 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev,
>  	BUG_ON(ticks > 0x1fff);
>  
>  	/* ticks in DSI_FCK */
> -	fck = dsi_fclk_rate(dsidev);
> +	fck = dsi_fclk_rate(dsi);
>  
> -	r = dsi_read_reg(dsidev, DSI_TIMING1);
> +	r = dsi_read_reg(dsi, DSI_TIMING1);
>  	r = FLD_MOD(r, 1, 31, 31);	/* TA_TO */
>  	r = FLD_MOD(r, x16 ? 1 : 0, 30, 30);	/* TA_TO_X16 */
>  	r = FLD_MOD(r, x8 ? 1 : 0, 29, 29);	/* TA_TO_X8 */
>  	r = FLD_MOD(r, ticks, 28, 16);	/* TA_TO_COUNTER */
> -	dsi_write_reg(dsidev, DSI_TIMING1, r);
> +	dsi_write_reg(dsi, DSI_TIMING1, r);
>  
>  	total_ticks = ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1);
>  
> @@ -3380,8 +3303,8 @@ static void dsi_set_ta_timeout(struct platform_device *dsidev,
>  			(total_ticks * 1000) / (fck / 1000 / 1000));
>  }
>  
> -static void dsi_set_stop_state_counter(struct platform_device *dsidev,
> -				       unsigned int ticks, bool x4, bool x16)
> +static void dsi_set_stop_state_counter(struct dsi_data *dsi, unsigned int ticks,
> +				       bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3390,14 +3313,14 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
>  	BUG_ON(ticks > 0x1fff);
>  
>  	/* ticks in DSI_FCK */
> -	fck = dsi_fclk_rate(dsidev);
> +	fck = dsi_fclk_rate(dsi);
>  
> -	r = dsi_read_reg(dsidev, DSI_TIMING1);
> +	r = dsi_read_reg(dsi, DSI_TIMING1);
>  	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
>  	r = FLD_MOD(r, x16 ? 1 : 0, 14, 14);	/* STOP_STATE_X16_IO */
>  	r = FLD_MOD(r, x4 ? 1 : 0, 13, 13);	/* STOP_STATE_X4_IO */
>  	r = FLD_MOD(r, ticks, 12, 0);	/* STOP_STATE_COUNTER_IO */
> -	dsi_write_reg(dsidev, DSI_TIMING1, r);
> +	dsi_write_reg(dsi, DSI_TIMING1, r);
>  
>  	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
>  
> @@ -3407,8 +3330,8 @@ static void dsi_set_stop_state_counter(struct platform_device *dsidev,
>  			(total_ticks * 1000) / (fck / 1000 / 1000));
>  }
>  
> -static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
> -				  unsigned int ticks, bool x4, bool x16)
> +static void dsi_set_hs_tx_timeout(struct dsi_data *dsi, unsigned int ticks,
> +				  bool x4, bool x16)
>  {
>  	unsigned long fck;
>  	unsigned long total_ticks;
> @@ -3417,14 +3340,14 @@ static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
>  	BUG_ON(ticks > 0x1fff);
>  
>  	/* ticks in TxByteClkHS */
> -	fck = dsi_get_txbyteclkhs(dsidev);
> +	fck = dsi_get_txbyteclkhs(dsi);
>  
> -	r = dsi_read_reg(dsidev, DSI_TIMING2);
> +	r = dsi_read_reg(dsi, DSI_TIMING2);
>  	r = FLD_MOD(r, 1, 31, 31);	/* HS_TX_TO */
>  	r = FLD_MOD(r, x16 ? 1 : 0, 30, 30);	/* HS_TX_TO_X16 */
>  	r = FLD_MOD(r, x4 ? 1 : 0, 29, 29);	/* HS_TX_TO_X8 (4 really) */
>  	r = FLD_MOD(r, ticks, 28, 16);	/* HS_TX_TO_COUNTER */
> -	dsi_write_reg(dsidev, DSI_TIMING2, r);
> +	dsi_write_reg(dsi, DSI_TIMING2, r);
>  
>  	total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
>  
> @@ -3434,9 +3357,8 @@ static void dsi_set_hs_tx_timeout(struct platform_device *dsidev,
>  			(total_ticks * 1000) / (fck / 1000 / 1000));
>  }
>  
> -static void dsi_config_vp_num_line_buffers(struct platform_device *dsidev)
> +static void dsi_config_vp_num_line_buffers(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int num_line_buffers;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> @@ -3456,12 +3378,11 @@ static void dsi_config_vp_num_line_buffers(struct platform_device *dsidev)
>  	}
>  
>  	/* LINE_BUFFER */
> -	REG_FLD_MOD(dsidev, DSI_CTRL, num_line_buffers, 13, 12);
> +	REG_FLD_MOD(dsi, DSI_CTRL, num_line_buffers, 13, 12);
>  }
>  
> -static void dsi_config_vp_sync_events(struct platform_device *dsidev)
> +static void dsi_config_vp_sync_events(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	bool sync_end;
>  	u32 r;
>  
> @@ -3470,7 +3391,7 @@ static void dsi_config_vp_sync_events(struct platform_device *dsidev)
>  	else
>  		sync_end = false;
>  
> -	r = dsi_read_reg(dsidev, DSI_CTRL);
> +	r = dsi_read_reg(dsi, DSI_CTRL);
>  	r = FLD_MOD(r, 1, 9, 9);		/* VP_DE_POL */
>  	r = FLD_MOD(r, 1, 10, 10);		/* VP_HSYNC_POL */
>  	r = FLD_MOD(r, 1, 11, 11);		/* VP_VSYNC_POL */
> @@ -3478,12 +3399,11 @@ static void dsi_config_vp_sync_events(struct platform_device *dsidev)
>  	r = FLD_MOD(r, sync_end, 16, 16);	/* VP_VSYNC_END */
>  	r = FLD_MOD(r, 1, 17, 17);		/* VP_HSYNC_START */
>  	r = FLD_MOD(r, sync_end, 18, 18);	/* VP_HSYNC_END */
> -	dsi_write_reg(dsidev, DSI_CTRL, r);
> +	dsi_write_reg(dsi, DSI_CTRL, r);
>  }
>  
> -static void dsi_config_blanking_modes(struct platform_device *dsidev)
> +static void dsi_config_blanking_modes(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int blanking_mode = dsi->vm_timings.blanking_mode;
>  	int hfp_blanking_mode = dsi->vm_timings.hfp_blanking_mode;
>  	int hbp_blanking_mode = dsi->vm_timings.hbp_blanking_mode;
> @@ -3494,12 +3414,12 @@ static void dsi_config_blanking_modes(struct platform_device *dsidev)
>  	 * 0 = TX FIFO packets sent or LPS in corresponding blanking periods
>  	 * 1 = Long blanking packets are sent in corresponding blanking periods
>  	 */
> -	r = dsi_read_reg(dsidev, DSI_CTRL);
> +	r = dsi_read_reg(dsi, DSI_CTRL);
>  	r = FLD_MOD(r, blanking_mode, 20, 20);		/* BLANKING_MODE */
>  	r = FLD_MOD(r, hfp_blanking_mode, 21, 21);	/* HFP_BLANKING */
>  	r = FLD_MOD(r, hbp_blanking_mode, 22, 22);	/* HBP_BLANKING */
>  	r = FLD_MOD(r, hsa_blanking_mode, 23, 23);	/* HSA_BLANKING */
> -	dsi_write_reg(dsidev, DSI_CTRL, r);
> +	dsi_write_reg(dsi, DSI_CTRL, r);
>  }
>  
>  /*
> @@ -3564,9 +3484,8 @@ static int dsi_compute_interleave_lp(int blank, int enter_hs, int exit_hs,
>  	return max(lp_inter, 0);
>  }
>  
> -static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
> +static void dsi_config_cmd_mode_interleaving(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int blanking_mode;
>  	int hfp_blanking_mode, hbp_blanking_mode, hsa_blanking_mode;
>  	int hsa, hfp, hbp, width_bytes, bllp, lp_clk_div;
> @@ -3583,33 +3502,33 @@ static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
>  	int bl_interleave_hs = 0, bl_interleave_lp = 0;
>  	u32 r;
>  
> -	r = dsi_read_reg(dsidev, DSI_CTRL);
> +	r = dsi_read_reg(dsi, DSI_CTRL);
>  	blanking_mode = FLD_GET(r, 20, 20);
>  	hfp_blanking_mode = FLD_GET(r, 21, 21);
>  	hbp_blanking_mode = FLD_GET(r, 22, 22);
>  	hsa_blanking_mode = FLD_GET(r, 23, 23);
>  
> -	r = dsi_read_reg(dsidev, DSI_VM_TIMING1);
> +	r = dsi_read_reg(dsi, DSI_VM_TIMING1);
>  	hbp = FLD_GET(r, 11, 0);
>  	hfp = FLD_GET(r, 23, 12);
>  	hsa = FLD_GET(r, 31, 24);
>  
> -	r = dsi_read_reg(dsidev, DSI_CLK_TIMING);
> +	r = dsi_read_reg(dsi, DSI_CLK_TIMING);
>  	ddr_clk_post = FLD_GET(r, 7, 0);
>  	ddr_clk_pre = FLD_GET(r, 15, 8);
>  
> -	r = dsi_read_reg(dsidev, DSI_VM_TIMING7);
> +	r = dsi_read_reg(dsi, DSI_VM_TIMING7);
>  	exit_hs_mode_lat = FLD_GET(r, 15, 0);
>  	enter_hs_mode_lat = FLD_GET(r, 31, 16);
>  
> -	r = dsi_read_reg(dsidev, DSI_CLK_CTRL);
> +	r = dsi_read_reg(dsi, DSI_CLK_CTRL);
>  	lp_clk_div = FLD_GET(r, 12, 0);
>  	ddr_alwon = FLD_GET(r, 13, 13);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
>  	ths_exit = FLD_GET(r, 7, 0);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
>  	tclk_trail = FLD_GET(r, 15, 8);
>  
>  	exiths_clk = ths_exit + tclk_trail;
> @@ -3663,45 +3582,44 @@ static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
>  		hsa_interleave_lp, hfp_interleave_lp, hbp_interleave_lp,
>  		bl_interleave_lp);
>  
> -	r = dsi_read_reg(dsidev, DSI_VM_TIMING4);
> +	r = dsi_read_reg(dsi, DSI_VM_TIMING4);
>  	r = FLD_MOD(r, hsa_interleave_hs, 23, 16);
>  	r = FLD_MOD(r, hfp_interleave_hs, 15, 8);
>  	r = FLD_MOD(r, hbp_interleave_hs, 7, 0);
> -	dsi_write_reg(dsidev, DSI_VM_TIMING4, r);
> +	dsi_write_reg(dsi, DSI_VM_TIMING4, r);
>  
> -	r = dsi_read_reg(dsidev, DSI_VM_TIMING5);
> +	r = dsi_read_reg(dsi, DSI_VM_TIMING5);
>  	r = FLD_MOD(r, hsa_interleave_lp, 23, 16);
>  	r = FLD_MOD(r, hfp_interleave_lp, 15, 8);
>  	r = FLD_MOD(r, hbp_interleave_lp, 7, 0);
> -	dsi_write_reg(dsidev, DSI_VM_TIMING5, r);
> +	dsi_write_reg(dsi, DSI_VM_TIMING5, r);
>  
> -	r = dsi_read_reg(dsidev, DSI_VM_TIMING6);
> +	r = dsi_read_reg(dsi, DSI_VM_TIMING6);
>  	r = FLD_MOD(r, bl_interleave_hs, 31, 15);
>  	r = FLD_MOD(r, bl_interleave_lp, 16, 0);
> -	dsi_write_reg(dsidev, DSI_VM_TIMING6, r);
> +	dsi_write_reg(dsi, DSI_VM_TIMING6, r);
>  }
>  
> -static int dsi_proto_config(struct platform_device *dsidev)
> +static int dsi_proto_config(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u32 r;
>  	int buswidth = 0;
>  
> -	dsi_config_tx_fifo(dsidev, DSI_FIFO_SIZE_32,
> +	dsi_config_tx_fifo(dsi, DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32);
>  
> -	dsi_config_rx_fifo(dsidev, DSI_FIFO_SIZE_32,
> +	dsi_config_rx_fifo(dsi, DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32,
>  			DSI_FIFO_SIZE_32);
>  
>  	/* XXX what values for the timeouts? */
> -	dsi_set_stop_state_counter(dsidev, 0x1000, false, false);
> -	dsi_set_ta_timeout(dsidev, 0x1fff, true, true);
> -	dsi_set_lp_rx_timeout(dsidev, 0x1fff, true, true);
> -	dsi_set_hs_tx_timeout(dsidev, 0x1fff, true, true);
> +	dsi_set_stop_state_counter(dsi, 0x1000, false, false);
> +	dsi_set_ta_timeout(dsi, 0x1fff, true, true);
> +	dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true);
> +	dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true);
>  
>  	switch (dsi_get_pixel_size(dsi->pix_fmt)) {
>  	case 16:
> @@ -3718,7 +3636,7 @@ static int dsi_proto_config(struct platform_device *dsidev)
>  		return -EINVAL;
>  	}
>  
> -	r = dsi_read_reg(dsidev, DSI_CTRL);
> +	r = dsi_read_reg(dsi, DSI_CTRL);
>  	r = FLD_MOD(r, 1, 1, 1);	/* CS_RX_EN */
>  	r = FLD_MOD(r, 1, 2, 2);	/* ECC_RX_EN */
>  	r = FLD_MOD(r, 1, 3, 3);	/* TX_FIFO_ARBITRATION */
> @@ -3733,27 +3651,26 @@ static int dsi_proto_config(struct platform_device *dsidev)
>  		r = FLD_MOD(r, 0, 25, 25);
>  	}
>  
> -	dsi_write_reg(dsidev, DSI_CTRL, r);
> +	dsi_write_reg(dsi, DSI_CTRL, r);
>  
> -	dsi_config_vp_num_line_buffers(dsidev);
> +	dsi_config_vp_num_line_buffers(dsi);
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		dsi_config_vp_sync_events(dsidev);
> -		dsi_config_blanking_modes(dsidev);
> -		dsi_config_cmd_mode_interleaving(dsidev);
> +		dsi_config_vp_sync_events(dsi);
> +		dsi_config_blanking_modes(dsi);
> +		dsi_config_cmd_mode_interleaving(dsi);
>  	}
>  
> -	dsi_vc_initial_config(dsidev, 0);
> -	dsi_vc_initial_config(dsidev, 1);
> -	dsi_vc_initial_config(dsidev, 2);
> -	dsi_vc_initial_config(dsidev, 3);
> +	dsi_vc_initial_config(dsi, 0);
> +	dsi_vc_initial_config(dsi, 1);
> +	dsi_vc_initial_config(dsi, 2);
> +	dsi_vc_initial_config(dsi, 3);
>  
>  	return 0;
>  }
>  
> -static void dsi_proto_timings(struct platform_device *dsidev)
> +static void dsi_proto_timings(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	unsigned int tlpx, tclk_zero, tclk_prepare, tclk_trail;
>  	unsigned int tclk_pre, tclk_post;
>  	unsigned int ths_prepare, ths_prepare_ths_zero, ths_zero;
> @@ -3764,25 +3681,25 @@ static void dsi_proto_timings(struct platform_device *dsidev)
>  	int ndl = dsi->num_lanes_used - 1;
>  	u32 r;
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0);
>  	ths_prepare = FLD_GET(r, 31, 24);
>  	ths_prepare_ths_zero = FLD_GET(r, 23, 16);
>  	ths_zero = ths_prepare_ths_zero - ths_prepare;
>  	ths_trail = FLD_GET(r, 15, 8);
>  	ths_exit = FLD_GET(r, 7, 0);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1);
>  	tlpx = FLD_GET(r, 20, 16) * 2;
>  	tclk_trail = FLD_GET(r, 15, 8);
>  	tclk_zero = FLD_GET(r, 7, 0);
>  
> -	r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2);
> +	r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2);
>  	tclk_prepare = FLD_GET(r, 7, 0);
>  
>  	/* min 8*UI */
>  	tclk_pre = 20;
>  	/* min 60ns + 52*UI */
> -	tclk_post = ns2ddr(dsidev, 60) + 26;
> +	tclk_post = ns2ddr(dsi, 60) + 26;
>  
>  	ths_eot = DIV_ROUND_UP(4, ndl);
>  
> @@ -3793,10 +3710,10 @@ static void dsi_proto_timings(struct platform_device *dsidev)
>  	BUG_ON(ddr_clk_pre == 0 || ddr_clk_pre > 255);
>  	BUG_ON(ddr_clk_post == 0 || ddr_clk_post > 255);
>  
> -	r = dsi_read_reg(dsidev, DSI_CLK_TIMING);
> +	r = dsi_read_reg(dsi, DSI_CLK_TIMING);
>  	r = FLD_MOD(r, ddr_clk_pre, 15, 8);
>  	r = FLD_MOD(r, ddr_clk_post, 7, 0);
> -	dsi_write_reg(dsidev, DSI_CLK_TIMING, r);
> +	dsi_write_reg(dsi, DSI_CLK_TIMING, r);
>  
>  	DSSDBG("ddr_clk_pre %u, ddr_clk_post %u\n",
>  			ddr_clk_pre,
> @@ -3810,7 +3727,7 @@ static void dsi_proto_timings(struct platform_device *dsidev)
>  
>  	r = FLD_VAL(enter_hs_mode_lat, 31, 16) |
>  		FLD_VAL(exit_hs_mode_lat, 15, 0);
> -	dsi_write_reg(dsidev, DSI_VM_TIMING7, r);
> +	dsi_write_reg(dsi, DSI_VM_TIMING7, r);
>  
>  	DSSDBG("enter_hs_mode_lat %u, exit_hs_mode_lat %u\n",
>  			enter_hs_mode_lat, exit_hs_mode_lat);
> @@ -3844,23 +3761,23 @@ static void dsi_proto_timings(struct platform_device *dsidev)
>  		DSSDBG("VBP: %d, VFP: %d, VSA: %d, VACT: %d lines\n", vbp, vfp,
>  			vsa, vm->vactive);
>  
> -		r = dsi_read_reg(dsidev, DSI_VM_TIMING1);
> +		r = dsi_read_reg(dsi, DSI_VM_TIMING1);
>  		r = FLD_MOD(r, hbp, 11, 0);	/* HBP */
>  		r = FLD_MOD(r, hfp, 23, 12);	/* HFP */
>  		r = FLD_MOD(r, hsync_end ? hsa : 0, 31, 24);	/* HSA */
> -		dsi_write_reg(dsidev, DSI_VM_TIMING1, r);
> +		dsi_write_reg(dsi, DSI_VM_TIMING1, r);
>  
> -		r = dsi_read_reg(dsidev, DSI_VM_TIMING2);
> +		r = dsi_read_reg(dsi, DSI_VM_TIMING2);
>  		r = FLD_MOD(r, vbp, 7, 0);	/* VBP */
>  		r = FLD_MOD(r, vfp, 15, 8);	/* VFP */
>  		r = FLD_MOD(r, vsa, 23, 16);	/* VSA */
>  		r = FLD_MOD(r, window_sync, 27, 24);	/* WINDOW_SYNC */
> -		dsi_write_reg(dsidev, DSI_VM_TIMING2, r);
> +		dsi_write_reg(dsi, DSI_VM_TIMING2, r);
>  
> -		r = dsi_read_reg(dsidev, DSI_VM_TIMING3);
> +		r = dsi_read_reg(dsi, DSI_VM_TIMING3);
>  		r = FLD_MOD(r, vm->vactive, 14, 0);	/* VACT */
>  		r = FLD_MOD(r, tl, 31, 16);		/* TL */
> -		dsi_write_reg(dsidev, DSI_VM_TIMING3, r);
> +		dsi_write_reg(dsi, DSI_VM_TIMING3, r);
>  	}
>  }
>  
> @@ -3947,7 +3864,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  		return -ENODEV;
>  	}
>  
> -	r = dsi_display_init_dispc(dsidev, dispc_channel);
> +	r = dsi_display_init_dispc(dsi, dispc_channel);
>  	if (r)
>  		goto err_init_dispc;
>  
> @@ -3970,19 +3887,19 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  			goto err_pix_fmt;
>  		}
>  
> -		dsi_if_enable(dsidev, false);
> -		dsi_vc_enable(dsidev, channel, false);
> +		dsi_if_enable(dsi, false);
> +		dsi_vc_enable(dsi, channel, false);
>  
>  		/* MODE, 1 = video mode */
> -		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 4, 4);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 4, 4);
>  
>  		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
>  
> -		dsi_vc_write_long_header(dsidev, channel, data_type,
> +		dsi_vc_write_long_header(dsi, channel, data_type,
>  				word_count, 0);
>  
> -		dsi_vc_enable(dsidev, channel, true);
> -		dsi_if_enable(dsidev, true);
> +		dsi_vc_enable(dsi, channel, true);
> +		dsi_if_enable(dsi, true);
>  	}
>  
>  	r = dss_mgr_enable(dispc_channel);
> @@ -3993,11 +3910,11 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  
>  err_mgr_enable:
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		dsi_if_enable(dsidev, false);
> -		dsi_vc_enable(dsidev, channel, false);
> +		dsi_if_enable(dsi, false);
> +		dsi_vc_enable(dsi, channel, false);
>  	}
>  err_pix_fmt:
> -	dsi_display_uninit_dispc(dsidev, dispc_channel);
> +	dsi_display_uninit_dispc(dsi, dispc_channel);
>  err_init_dispc:
>  	return r;
>  }
> @@ -4009,24 +3926,23 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
>  	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		dsi_if_enable(dsidev, false);
> -		dsi_vc_enable(dsidev, channel, false);
> +		dsi_if_enable(dsi, false);
> +		dsi_vc_enable(dsi, channel, false);
>  
>  		/* MODE, 0 = command mode */
> -		REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 0, 4, 4);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 0, 4, 4);
>  
> -		dsi_vc_enable(dsidev, channel, true);
> -		dsi_if_enable(dsidev, true);
> +		dsi_vc_enable(dsi, channel, true);
> +		dsi_if_enable(dsi, true);
>  	}
>  
>  	dss_mgr_disable(dispc_channel);
>  
> -	dsi_display_uninit_dispc(dsidev, dispc_channel);
> +	dsi_display_uninit_dispc(dsi, dispc_channel);
>  }
>  
> -static void dsi_update_screen_dispc(struct platform_device *dsidev)
> +static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  	unsigned int bytespp;
>  	unsigned int bytespl;
> @@ -4043,7 +3959,7 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
>  
>  	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
>  
> -	dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_VP);
> +	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP);
>  
>  	bytespp	= dsi_get_pixel_size(dsi->pix_fmt) / 8;
>  	bytespl = w * bytespp;
> @@ -4064,16 +3980,16 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
>  		total_len += (bytespf % packet_payload) + 1;
>  
>  	l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */
> -	dsi_write_reg(dsidev, DSI_VC_TE(channel), l);
> +	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
>  
> -	dsi_vc_write_long_header(dsidev, channel, MIPI_DSI_DCS_LONG_WRITE,
> +	dsi_vc_write_long_header(dsi, channel, MIPI_DSI_DCS_LONG_WRITE,
>  		packet_len, 0);
>  
>  	if (dsi->te_enabled)
>  		l = FLD_MOD(l, 1, 30, 30); /* TE_EN */
>  	else
>  		l = FLD_MOD(l, 1, 31, 31); /* TE_START */
> -	dsi_write_reg(dsidev, DSI_VC_TE(channel), l);
> +	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
>  
>  	/* We put SIDLEMODE to no-idle for the duration of the transfer,
>  	 * because DSS interrupts are not capable of waking up the CPU and the
> @@ -4083,7 +3999,7 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
>  	 */
>  	dispc_disable_sidle();
>  
> -	dsi_perf_mark_start(dsidev);
> +	dsi_perf_mark_start(dsi);
>  
>  	r = schedule_delayed_work(&dsi->framedone_timeout_work,
>  		msecs_to_jiffies(250));
> @@ -4096,9 +4012,9 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
>  	if (dsi->te_enabled) {
>  		/* disable LP_RX_TO, so that we can receive TE.  Time to wait
>  		 * for TE is longer than the timer allows */
> -		REG_FLD_MOD(dsidev, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
> +		REG_FLD_MOD(dsi, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
>  
> -		dsi_vc_send_bta(dsidev, channel);
> +		dsi_vc_send_bta(dsi, channel);
>  
>  #ifdef DSI_CATCH_MISSING_TE
>  		mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250));
> @@ -4113,22 +4029,20 @@ static void dsi_te_timeout(unsigned long arg)
>  }
>  #endif
>  
> -static void dsi_handle_framedone(struct platform_device *dsidev, int error)
> +static void dsi_handle_framedone(struct dsi_data *dsi, int error)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	/* SIDLEMODE back to smart-idle */
>  	dispc_enable_sidle();
>  
>  	if (dsi->te_enabled) {
>  		/* enable LP_RX_TO again after the TE */
> -		REG_FLD_MOD(dsidev, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
> +		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
>  	}
>  
>  	dsi->framedone_callback(error, dsi->framedone_data);
>  
>  	if (!error)
> -		dsi_perf_show(dsidev, "DISPC");
> +		dsi_perf_show(dsi, "DISPC");
>  }
>  
>  static void dsi_framedone_timeout_work_callback(struct work_struct *work)
> @@ -4144,13 +4058,12 @@ static void dsi_framedone_timeout_work_callback(struct work_struct *work)
>  
>  	DSSERR("Framedone not received for 250ms!\n");
>  
> -	dsi_handle_framedone(dsi->pdev, -ETIMEDOUT);
> +	dsi_handle_framedone(dsi, -ETIMEDOUT);
>  }
>  
>  static void dsi_framedone_irq_callback(void *data)
>  {
> -	struct platform_device *dsidev = (struct platform_device *) data;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = data;
>  
>  	/* Note: We get FRAMEDONE when DISPC has finished sending pixels and
>  	 * turns itself off. However, DSI still has the pixels in its buffers,
> @@ -4159,7 +4072,7 @@ static void dsi_framedone_irq_callback(void *data)
>  
>  	cancel_delayed_work(&dsi->framedone_timeout_work);
>  
> -	dsi_handle_framedone(dsidev, 0);
> +	dsi_handle_framedone(dsi, 0);
>  }
>  
>  static int dsi_update(struct omap_dss_device *dssdev, int channel,
> @@ -4169,7 +4082,7 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
>  	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	u16 dw, dh;
>  
> -	dsi_perf_mark_setup(dsidev);
> +	dsi_perf_mark_setup(dsi);
>  
>  	dsi->update_channel = channel;
>  
> @@ -4183,21 +4096,20 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
>  	dsi->update_bytes = dw * dh *
>  		dsi_get_pixel_size(dsi->pix_fmt) / 8;
>  #endif
> -	dsi_update_screen_dispc(dsidev);
> +	dsi_update_screen_dispc(dsi);
>  
>  	return 0;
>  }
>  
>  /* Display funcs */
>  
> -static int dsi_configure_dispc_clocks(struct platform_device *dsidev)
> +static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct dispc_clock_info dispc_cinfo;
>  	int r;
>  	unsigned long fck;
>  
> -	fck = dsi_get_pll_hsdiv_dispc_rate(dsidev);
> +	fck = dsi_get_pll_hsdiv_dispc_rate(dsi);
>  
>  	dispc_cinfo.lck_div = dsi->user_dispc_cinfo.lck_div;
>  	dispc_cinfo.pck_div = dsi->user_dispc_cinfo.pck_div;
> @@ -4213,10 +4125,9 @@ static int dsi_configure_dispc_clocks(struct platform_device *dsidev)
>  	return 0;
>  }
>  
> -static int dsi_display_init_dispc(struct platform_device *dsidev,
> -		enum omap_channel channel)
> +static int dsi_display_init_dispc(struct dsi_data *dsi,
> +				  enum omap_channel channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
>  	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
> @@ -4225,7 +4136,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
>  
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) {
>  		r = dss_mgr_register_framedone_handler(channel,
> -				dsi_framedone_irq_callback, dsidev);
> +				dsi_framedone_irq_callback, dsi);
>  		if (r) {
>  			DSSERR("can't register FRAMEDONE handler\n");
>  			goto err;
> @@ -4256,7 +4167,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
>  
>  	dss_mgr_set_timings(channel, &dsi->vm);
>  
> -	r = dsi_configure_dispc_clocks(dsidev);
> +	r = dsi_configure_dispc_clocks(dsi);
>  	if (r)
>  		goto err1;
>  
> @@ -4271,27 +4182,24 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
>  err1:
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
>  		dss_mgr_unregister_framedone_handler(channel,
> -				dsi_framedone_irq_callback, dsidev);
> +				dsi_framedone_irq_callback, dsi);
>  err:
>  	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
>  	return r;
>  }
>  
> -static void dsi_display_uninit_dispc(struct platform_device *dsidev,
> -		enum omap_channel channel)
> +static void dsi_display_uninit_dispc(struct dsi_data *dsi,
> +				     enum omap_channel channel)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
>  		dss_mgr_unregister_framedone_handler(channel,
> -				dsi_framedone_irq_callback, dsidev);
> +				dsi_framedone_irq_callback, dsi);
>  
>  	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
>  }
>  
> -static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
> +static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct dss_pll_clock_info cinfo;
>  	int r;
>  
> @@ -4306,16 +4214,15 @@ static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
>  	return 0;
>  }
>  
> -static int dsi_display_init_dsi(struct platform_device *dsidev)
> +static int dsi_display_init_dsi(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	int r;
>  
>  	r = dss_pll_enable(&dsi->pll);
>  	if (r)
>  		goto err0;
>  
> -	r = dsi_configure_dsi_clocks(dsidev);
> +	r = dsi_configure_dsi_clocks(dsi);
>  	if (r)
>  		goto err1;
>  
> @@ -4325,33 +4232,33 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
>  
>  	DSSDBG("PLL OK\n");
>  
> -	r = dsi_cio_init(dsidev);
> +	r = dsi_cio_init(dsi);
>  	if (r)
>  		goto err2;
>  
> -	_dsi_print_reset_status(dsidev);
> +	_dsi_print_reset_status(dsi);
>  
> -	dsi_proto_timings(dsidev);
> -	dsi_set_lp_clk_divisor(dsidev);
> +	dsi_proto_timings(dsi);
> +	dsi_set_lp_clk_divisor(dsi);
>  
>  	if (1)
> -		_dsi_print_reset_status(dsidev);
> +		_dsi_print_reset_status(dsi);
>  
> -	r = dsi_proto_config(dsidev);
> +	r = dsi_proto_config(dsi);
>  	if (r)
>  		goto err3;
>  
>  	/* enable interface */
> -	dsi_vc_enable(dsidev, 0, 1);
> -	dsi_vc_enable(dsidev, 1, 1);
> -	dsi_vc_enable(dsidev, 2, 1);
> -	dsi_vc_enable(dsidev, 3, 1);
> -	dsi_if_enable(dsidev, 1);
> -	dsi_force_tx_stop_mode_io(dsidev);
> +	dsi_vc_enable(dsi, 0, 1);
> +	dsi_vc_enable(dsi, 1, 1);
> +	dsi_vc_enable(dsi, 2, 1);
> +	dsi_vc_enable(dsi, 3, 1);
> +	dsi_if_enable(dsi, 1);
> +	dsi_force_tx_stop_mode_io(dsi);
>  
>  	return 0;
>  err3:
> -	dsi_cio_uninit(dsidev);
> +	dsi_cio_uninit(dsi);
>  err2:
>  	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
>  err1:
> @@ -4360,24 +4267,22 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
>  	return r;
>  }
>  
> -static void dsi_display_uninit_dsi(struct platform_device *dsidev,
> -		bool disconnect_lanes, bool enter_ulps)
> +static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
> +				   bool enter_ulps)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> -
>  	if (enter_ulps && !dsi->ulps_enabled)
> -		dsi_enter_ulps(dsidev);
> +		dsi_enter_ulps(dsi);
>  
>  	/* disable interface */
> -	dsi_if_enable(dsidev, 0);
> -	dsi_vc_enable(dsidev, 0, 0);
> -	dsi_vc_enable(dsidev, 1, 0);
> -	dsi_vc_enable(dsidev, 2, 0);
> -	dsi_vc_enable(dsidev, 3, 0);
> +	dsi_if_enable(dsi, 0);
> +	dsi_vc_enable(dsi, 0, 0);
> +	dsi_vc_enable(dsi, 1, 0);
> +	dsi_vc_enable(dsi, 2, 0);
> +	dsi_vc_enable(dsi, 3, 0);
>  
>  	dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK);
> -	dsi_cio_uninit(dsidev);
> -	dsi_pll_uninit(dsidev, disconnect_lanes);
> +	dsi_cio_uninit(dsi);
> +	dsi_pll_uninit(dsi, disconnect_lanes);
>  }
>  
>  static int dsi_display_enable(struct omap_dss_device *dssdev)
> @@ -4388,17 +4293,17 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
>  
>  	DSSDBG("dsi_display_enable\n");
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	mutex_lock(&dsi->lock);
>  
> -	r = dsi_runtime_get(dsidev);
> +	r = dsi_runtime_get(dsi);
>  	if (r)
>  		goto err_get_dsi;
>  
> -	_dsi_initialize_irq(dsidev);
> +	_dsi_initialize_irq(dsi);
>  
> -	r = dsi_display_init_dsi(dsidev);
> +	r = dsi_display_init_dsi(dsi);
>  	if (r)
>  		goto err_init_dsi;
>  
> @@ -4407,7 +4312,7 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
>  	return 0;
>  
>  err_init_dsi:
> -	dsi_runtime_put(dsidev);
> +	dsi_runtime_put(dsi);
>  err_get_dsi:
>  	mutex_unlock(&dsi->lock);
>  	DSSDBG("dsi_display_enable FAILED\n");
> @@ -4422,18 +4327,18 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
>  
>  	DSSDBG("dsi_display_disable\n");
>  
> -	WARN_ON(!dsi_bus_is_locked(dsidev));
> +	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	mutex_lock(&dsi->lock);
>  
> -	dsi_sync_vc(dsidev, 0);
> -	dsi_sync_vc(dsidev, 1);
> -	dsi_sync_vc(dsidev, 2);
> -	dsi_sync_vc(dsidev, 3);
> +	dsi_sync_vc(dsi, 0);
> +	dsi_sync_vc(dsi, 1);
> +	dsi_sync_vc(dsi, 2);
> +	dsi_sync_vc(dsi, 3);
>  
> -	dsi_display_uninit_dsi(dsidev, disconnect_lanes, enter_ulps);
> +	dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
>  
> -	dsi_runtime_put(dsidev);
> +	dsi_runtime_put(dsi);
>  
>  	mutex_unlock(&dsi->lock);
>  }
> @@ -4570,7 +4475,7 @@ static bool dsi_cm_calc_pll_cb(int n, int m, unsigned long fint,
>  		unsigned long clkdco, void *data)
>  {
>  	struct dsi_clk_calc_ctx *ctx = data;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
> +	struct dsi_data *dsi = ctx->dsi;
>  
>  	ctx->dsi_cinfo.n = n;
>  	ctx->dsi_cinfo.m = m;
> @@ -4606,7 +4511,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
>  	txbyteclk = pck * bitspp / 8 / ndl;
>  
>  	memset(ctx, 0, sizeof(*ctx));
> -	ctx->dsidev = dsi->pdev;
> +	ctx->dsi = dsi;
>  	ctx->pll = &dsi->pll;
>  	ctx->config = cfg;
>  	ctx->req_pck_min = pck;
> @@ -4623,7 +4528,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
>  
>  static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx *ctx)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
> +	struct dsi_data *dsi = ctx->dsi;
>  	const struct omap_dss_dsi_config *cfg = ctx->config;
>  	int bitspp = dsi_get_pixel_size(cfg->pixel_format);
>  	int ndl = dsi->num_lanes_used - 1;
> @@ -4870,7 +4775,7 @@ static bool dsi_vm_calc_pll_cb(int n, int m, unsigned long fint,
>  		unsigned long clkdco, void *data)
>  {
>  	struct dsi_clk_calc_ctx *ctx = data;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(ctx->dsidev);
> +	struct dsi_data *dsi = ctx->dsi;
>  
>  	ctx->dsi_cinfo.n = n;
>  	ctx->dsi_cinfo.m = m;
> @@ -4897,7 +4802,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
>  	clkin = clk_get_rate(dsi->pll.clkin);
>  
>  	memset(ctx, 0, sizeof(*ctx));
> -	ctx->dsidev = dsi->pdev;
> +	ctx->dsi = dsi;
>  	ctx->pll = &dsi->pll;
>  	ctx->config = cfg;
>  
> @@ -5070,12 +4975,11 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
>  }
>  
>  
> -static int dsi_get_clocks(struct platform_device *dsidev)
> +static int dsi_get_clocks(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct clk *clk;
>  
> -	clk = devm_clk_get(&dsidev->dev, "fck");
> +	clk = devm_clk_get(&dsi->pdev->dev, "fck");
>  	if (IS_ERR(clk)) {
>  		DSSERR("can't get fck\n");
>  		return PTR_ERR(clk);
> @@ -5090,10 +4994,11 @@ static int dsi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> +	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  	int r;
>  
> -	r = dsi_regulator_init(dsidev);
> +	r = dsi_regulator_init(dsi);
>  	if (r)
>  		return r;
>  
> @@ -5166,12 +5071,11 @@ static const struct omapdss_dsi_ops dsi_ops = {
>  	.set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
>  };
>  
> -static void dsi_init_output(struct platform_device *dsidev)
> +static void dsi_init_output(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct omap_dss_device *out = &dsi->output;
>  
> -	out->dev = &dsidev->dev;
> +	out->dev = &dsi->pdev->dev;
>  	out->id = dsi->module_id == 0 ?
>  			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
>  
> @@ -5184,18 +5088,16 @@ static void dsi_init_output(struct platform_device *dsidev)
>  	omapdss_register_output(out);
>  }
>  
> -static void dsi_uninit_output(struct platform_device *dsidev)
> +static void dsi_uninit_output(struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct omap_dss_device *out = &dsi->output;
>  
>  	omapdss_unregister_output(out);
>  }
>  
> -static int dsi_probe_of(struct platform_device *pdev)
> +static int dsi_probe_of(struct dsi_data *dsi)
>  {
> -	struct device_node *node = pdev->dev.of_node;
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
> +	struct device_node *node = dsi->pdev->dev.of_node;
>  	struct property *prop;
>  	u32 lane_arr[10];
>  	int len, num_pins;
> @@ -5209,7 +5111,7 @@ static int dsi_probe_of(struct platform_device *pdev)
>  
>  	prop = of_find_property(ep, "lanes", &len);
>  	if (prop == NULL) {
> -		dev_err(&pdev->dev, "failed to find lane data\n");
> +		dev_err(&dsi->pdev->dev, "failed to find lane data\n");
>  		r = -EINVAL;
>  		goto err;
>  	}
> @@ -5218,14 +5120,14 @@ static int dsi_probe_of(struct platform_device *pdev)
>  
>  	if (num_pins < 4 || num_pins % 2 != 0 ||
>  		num_pins > dsi->num_lanes_supported * 2) {
> -		dev_err(&pdev->dev, "bad number of lanes\n");
> +		dev_err(&dsi->pdev->dev, "bad number of lanes\n");
>  		r = -EINVAL;
>  		goto err;
>  	}
>  
>  	r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
>  	if (r) {
> -		dev_err(&pdev->dev, "failed to read lane data\n");
> +		dev_err(&dsi->pdev->dev, "failed to read lane data\n");
>  		goto err;
>  	}
>  
> @@ -5235,7 +5137,7 @@ static int dsi_probe_of(struct platform_device *pdev)
>  
>  	r = dsi_configure_pins(&dsi->output, &pin_cfg);
>  	if (r) {
> -		dev_err(&pdev->dev, "failed to configure pins");
> +		dev_err(&dsi->pdev->dev, "failed to configure pins");
>  		goto err;
>  	}
>  
> @@ -5335,15 +5237,13 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
>  	.has_refsel = true,
>  };
>  
> -static int dsi_init_pll_data(struct dss_device *dss,
> -			     struct platform_device *dsidev)
> +static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
>  {
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
>  	struct dss_pll *pll = &dsi->pll;
>  	struct clk *clk;
>  	int r;
>  
> -	clk = devm_clk_get(&dsidev->dev, "sys_clk");
> +	clk = devm_clk_get(&dsi->pdev->dev, "sys_clk");
>  	if (IS_ERR(clk)) {
>  		DSSERR("can't get sys_clk\n");
>  		return PTR_ERR(clk);
> @@ -5492,7 +5392,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	}
>  
>  	r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
> -			     IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev);
> +			     IRQF_SHARED, dev_name(&dsidev->dev), dsi);
>  	if (r < 0) {
>  		DSSERR("request_irq failed\n");
>  		return r;
> @@ -5540,19 +5440,19 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  		dsi->vc[i].vc_id = 0;
>  	}
>  
> -	r = dsi_get_clocks(dsidev);
> +	r = dsi_get_clocks(dsi);
>  	if (r)
>  		return r;
>  
> -	dsi_init_pll_data(dss, dsidev);
> +	dsi_init_pll_data(dss, dsi);
>  
>  	pm_runtime_enable(&dsidev->dev);
>  
> -	r = dsi_runtime_get(dsidev);
> +	r = dsi_runtime_get(dsi);
>  	if (r)
>  		goto err_runtime_get;
>  
> -	rev = dsi_read_reg(dsidev, DSI_REVISION);
> +	rev = dsi_read_reg(dsi, DSI_REVISION);
>  	dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
>  	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
> @@ -5560,15 +5460,15 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	 * of data to 3 by default */
>  	if (dsi->data->quirks & DSI_QUIRK_GNQ)
>  		/* NB_DATA_LANES */
> -		dsi->num_lanes_supported = 1 + REG_GET(dsidev, DSI_GNQ, 11, 9);
> +		dsi->num_lanes_supported = 1 + REG_GET(dsi, DSI_GNQ, 11, 9);
>  	else
>  		dsi->num_lanes_supported = 3;
>  
> -	dsi->line_buffer_size = dsi_get_line_buf_size(dsidev);
> +	dsi->line_buffer_size = dsi_get_line_buf_size(dsi);
>  
> -	dsi_init_output(dsidev);
> +	dsi_init_output(dsi);
>  
> -	r = dsi_probe_of(dsidev);
> +	r = dsi_probe_of(dsi);
>  	if (r) {
>  		DSSERR("Invalid DSI DT data\n");
>  		goto err_probe_of;
> @@ -5578,7 +5478,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	if (r)
>  		DSSERR("Failed to populate DSI child devices: %d\n", r);
>  
> -	dsi_runtime_put(dsidev);
> +	dsi_runtime_put(dsi);
>  
>  	if (dsi->module_id == 0)
>  		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
> @@ -5602,8 +5502,8 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	return 0;
>  
>  err_probe_of:
> -	dsi_uninit_output(dsidev);
> -	dsi_runtime_put(dsidev);
> +	dsi_uninit_output(dsi);
> +	dsi_runtime_put(dsi);
>  
>  err_runtime_get:
>  	pm_runtime_disable(&dsidev->dev);
> @@ -5624,7 +5524,7 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
>  
>  	dss_pll_unregister(&dsi->pll);
>  
> -	dsi_uninit_output(dsidev);
> +	dsi_uninit_output(dsi);
>  
>  	pm_runtime_disable(&dsidev->dev);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions
  2017-10-13 14:59 ` [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
@ 2017-10-17 20:06   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:06 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 13789 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:33PM +0300, Laurent Pinchart wrote:
> The dsi_get_dsidrv_data() and dsi_get_dsidev_from_dssdev() inline
> functions convert a struct omap_dss_device pointer to the corresponding
> struct platform_device, and a struct platform_device pointer to the
> corresponding struct dsi_data. They are nearly always called together
> without any use of the intermediate platform_device, so combine them
> into a single function.
> 
> In the three locations where only dsi_get_dsidrv_data() is used, call
> dev_get_drvdata() directly.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 90 +++++++++++++--------------------------
>  1 file changed, 30 insertions(+), 60 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 312804104ad3..a763ab7ed657 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -441,14 +441,9 @@ static bool dsi_perf;
>  module_param(dsi_perf, bool, 0644);
>  #endif
>  
> -static inline struct dsi_data *dsi_get_dsidrv_data(struct platform_device *dsidev)
> +static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
>  {
> -	return dev_get_drvdata(&dsidev->dev);
> -}
> -
> -static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss_device *dssdev)
> -{
> -	return to_platform_device(dssdev->dev);
> +	return dev_get_drvdata(dssdev->dev);
>  }
>  
>  static struct dsi_data *dsi_get_dsi_from_id(int module)
> @@ -469,7 +464,7 @@ static struct dsi_data *dsi_get_dsi_from_id(int module)
>  
>  	out = omap_dss_get_output(id);
>  
> -	return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
> +	return out ? to_dsi_data(out) : NULL;
>  }
>  
>  static inline void dsi_write_reg(struct dsi_data *dsi,
> @@ -503,16 +498,14 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
>  
>  static void dsi_bus_lock(struct omap_dss_device *dssdev)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	down(&dsi->bus_lock);
>  }
>  
>  static void dsi_bus_unlock(struct omap_dss_device *dssdev)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	up(&dsi->bus_lock);
>  }
> @@ -2536,8 +2529,7 @@ static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
>  static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
>  		bool enable)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
>  
> @@ -2660,8 +2652,7 @@ static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
>  
>  static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	int r = 0;
>  	u32 err;
> @@ -2863,8 +2854,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
>  static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
>  		u8 *data, int len)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	return dsi_vc_write_nosync_common(dsi, channel, data, len,
>  			DSS_DSI_CONTENT_DCS);
> @@ -2873,8 +2863,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
>  static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
>  		u8 *data, int len)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	return dsi_vc_write_nosync_common(dsi, channel, data, len,
>  			DSS_DSI_CONTENT_GENERIC);
> @@ -2884,8 +2873,7 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
>  			       int channel, u8 *data, int len,
>  			       enum dss_dsi_content_type type)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
>  	r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
> @@ -3090,8 +3078,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
>  static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
>  		u8 *buf, int buflen)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
>  	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
> @@ -3121,8 +3108,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
>  static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
>  		u8 *reqdata, int reqlen, u8 *buf, int buflen)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
>  	r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
> @@ -3149,8 +3135,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
>  static int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
>  		u16 len)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	return dsi_vc_send_short(dsi, channel,
>  			MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
> @@ -3784,8 +3769,7 @@ static void dsi_proto_timings(struct dsi_data *dsi)
>  static int dsi_configure_pins(struct omap_dss_device *dssdev,
>  		const struct omap_dsi_pin_config *pin_cfg)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int num_pins;
>  	const int *pins;
>  	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
> @@ -3850,8 +3834,7 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
>  
>  static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
>  	struct omap_dss_device *out = &dsi->output;
> @@ -3921,8 +3904,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  
>  static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> @@ -4078,8 +4060,7 @@ static void dsi_framedone_irq_callback(void *data)
>  static int dsi_update(struct omap_dss_device *dssdev, int channel,
>  		void (*callback)(int, void *), void *data)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	u16 dw, dh;
>  
>  	dsi_perf_mark_setup(dsi);
> @@ -4287,8 +4268,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
>  
>  static int dsi_display_enable(struct omap_dss_device *dssdev)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r = 0;
>  
>  	DSSDBG("dsi_display_enable\n");
> @@ -4322,8 +4302,7 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
>  static void dsi_display_disable(struct omap_dss_device *dssdev,
>  		bool disconnect_lanes, bool enter_ulps)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	DSSDBG("dsi_display_disable\n");
>  
> @@ -4345,8 +4324,7 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
>  
>  static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	dsi->te_enabled = enable;
>  	return 0;
> @@ -4832,8 +4810,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
>  static int dsi_set_config(struct omap_dss_device *dssdev,
>  		const struct omap_dss_dsi_config *config)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	struct dsi_clk_calc_ctx ctx;
>  	bool ok;
>  	int r;
> @@ -4920,8 +4897,7 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
>  
>  static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
> @@ -4938,8 +4914,7 @@ static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
>  
>  static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	if (vc_id < 0 || vc_id > 3) {
>  		DSSERR("VC ID out of range\n");
> @@ -4964,8 +4939,7 @@ static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id)
>  
>  static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	if ((channel >= 0 && channel <= 3) &&
>  		dsi->vc[channel].dssdev == dssdev) {
> @@ -4993,8 +4967,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
>  static int dsi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  	int r;
>  
> @@ -5512,13 +5485,12 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  
>  static void dsi_unbind(struct device *dev, struct device *master, void *data)
>  {
> -	struct platform_device *dsidev = to_platform_device(dev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
> +	struct dsi_data *dsi = dev_get_drvdata(dev);
>  
>  	dss_debugfs_remove_file(dsi->debugfs.irqs);
>  	dss_debugfs_remove_file(dsi->debugfs.regs);
>  
> -	of_platform_depopulate(&dsidev->dev);
> +	of_platform_depopulate(dev);
>  
>  	WARN_ON(dsi->scp_clk_refcount > 0);
>  
> @@ -5526,7 +5498,7 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)
>  
>  	dsi_uninit_output(dsi);
>  
> -	pm_runtime_disable(&dsidev->dev);
> +	pm_runtime_disable(dev);
>  
>  	if (dsi->vdds_dsi_reg != NULL && dsi->vdds_dsi_enabled) {
>  		regulator_disable(dsi->vdds_dsi_reg);
> @@ -5552,8 +5524,7 @@ static int dsi_remove(struct platform_device *pdev)
>  
>  static int dsi_runtime_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
> +	struct dsi_data *dsi = dev_get_drvdata(dev);
>  
>  	dsi->is_enabled = false;
>  	/* ensure the irq handler sees the is_enabled value */
> @@ -5568,8 +5539,7 @@ static int dsi_runtime_suspend(struct device *dev)
>  
>  static int dsi_runtime_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
> +	struct dsi_data *dsi = dev_get_drvdata(dev);
>  	int r;
>  
>  	r = dispc_runtime_get();
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function
  2017-10-13 14:59 ` [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
@ 2017-10-17 20:08   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:08 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 5045 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:34PM +0300, Laurent Pinchart wrote:
> The dsi_bind() function receives a pointer to a struct device that it
> casts to a struct platform_device, only to use the platform device's dev
> field through the code. Use the dev pointer directly.
> 
> While at it rename the struct platform_device pointer dsidev to pdev to
> make it more explicit.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 35 ++++++++++++++++++-----------------
>  1 file changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index a763ab7ed657..4f67dd70f279 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5302,9 +5302,10 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
>  	{ .machine = "AM35*",		.data = &dsi_of_data_omap34xx },
>  	{ /* sentinel */ }
>  };
> +
>  static int dsi_bind(struct device *dev, struct device *master, void *data)
>  {
> -	struct platform_device *dsidev = to_platform_device(dev);
> +	struct platform_device *pdev = to_platform_device(dev);
>  	struct dss_device *dss = dss_get_device(master);
>  	const struct soc_device_attribute *soc;
>  	const struct dsi_module_id_data *d;
> @@ -5314,13 +5315,13 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	struct resource *dsi_mem;
>  	struct resource *res;
>  
> -	dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL);
> +	dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
>  	if (!dsi)
>  		return -ENOMEM;
>  
>  	dsi->dss = dss;
> -	dsi->pdev = dsidev;
> -	dev_set_drvdata(&dsidev->dev, dsi);
> +	dsi->pdev = pdev;
> +	dev_set_drvdata(dev, dsi);
>  
>  	spin_lock_init(&dsi->irq_lock);
>  	spin_lock_init(&dsi->errors_lock);
> @@ -5343,29 +5344,29 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	dsi->te_timer.data = 0;
>  #endif
>  
> -	dsi_mem = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "proto");
> -	dsi->proto_base = devm_ioremap_resource(&dsidev->dev, dsi_mem);
> +	dsi_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "proto");
> +	dsi->proto_base = devm_ioremap_resource(dev, dsi_mem);
>  	if (IS_ERR(dsi->proto_base))
>  		return PTR_ERR(dsi->proto_base);
>  
> -	res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy");
> -	dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res);
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy");
> +	dsi->phy_base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(dsi->phy_base))
>  		return PTR_ERR(dsi->phy_base);
>  
> -	res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll");
> -	dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res);
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll");
> +	dsi->pll_base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(dsi->pll_base))
>  		return PTR_ERR(dsi->pll_base);
>  
> -	dsi->irq = platform_get_irq(dsi->pdev, 0);
> +	dsi->irq = platform_get_irq(pdev, 0);
>  	if (dsi->irq < 0) {
>  		DSSERR("platform_get_irq failed\n");
>  		return -ENODEV;
>  	}
>  
> -	r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
> -			     IRQF_SHARED, dev_name(&dsidev->dev), dsi);
> +	r = devm_request_irq(dev, dsi->irq, omap_dsi_irq_handler,
> +			     IRQF_SHARED, dev_name(dev), dsi);
>  	if (r < 0) {
>  		DSSERR("request_irq failed\n");
>  		return r;
> @@ -5419,14 +5420,14 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  
>  	dsi_init_pll_data(dss, dsi);
>  
> -	pm_runtime_enable(&dsidev->dev);
> +	pm_runtime_enable(dev);
>  
>  	r = dsi_runtime_get(dsi);
>  	if (r)
>  		goto err_runtime_get;
>  
>  	rev = dsi_read_reg(dsi, DSI_REVISION);
> -	dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
> +	dev_dbg(dev, "OMAP DSI rev %d.%d\n",
>  	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
>  	/* DSI on OMAP3 doesn't have register DSI_GNQ, set number
> @@ -5447,7 +5448,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  		goto err_probe_of;
>  	}
>  
> -	r = of_platform_populate(dsidev->dev.of_node, NULL, NULL, &dsidev->dev);
> +	r = of_platform_populate(dev->of_node, NULL, NULL, dev);
>  	if (r)
>  		DSSERR("Failed to populate DSI child devices: %d\n", r);
>  
> @@ -5479,7 +5480,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	dsi_runtime_put(dsi);
>  
>  err_runtime_get:
> -	pm_runtime_disable(&dsidev->dev);
> +	pm_runtime_disable(dev);
>  	return r;
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data
  2017-10-13 14:59 ` [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
@ 2017-10-17 20:11   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:11 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4712 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:35PM +0300, Laurent Pinchart wrote:
> The dsi_data structure stores a pointer to a struct platform_device. The
> driver only uses the dev member of the platform device structure. Store
> the struct device pointer instead and use it directly.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 4f67dd70f279..9be26eb262f3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -332,7 +332,7 @@ struct dsi_of_data {
>  };
>  
>  struct dsi_data {
> -	struct platform_device *pdev;
> +	struct device *dev;
>  	void __iomem *proto_base;
>  	void __iomem *phy_base;
>  	void __iomem *pll_base;
> @@ -1146,7 +1146,7 @@ static int dsi_runtime_get(struct dsi_data *dsi)
>  
>  	DSSDBG("dsi_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&dsi->pdev->dev);
> +	r = pm_runtime_get_sync(dsi->dev);
>  	WARN_ON(r < 0);
>  	return r < 0 ? r : 0;
>  }
> @@ -1157,7 +1157,7 @@ static void dsi_runtime_put(struct dsi_data *dsi)
>  
>  	DSSDBG("dsi_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&dsi->pdev->dev);
> +	r = pm_runtime_put_sync(dsi->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> @@ -1168,7 +1168,7 @@ static int dsi_regulator_init(struct dsi_data *dsi)
>  	if (dsi->vdds_dsi_reg != NULL)
>  		return 0;
>  
> -	vdds_dsi = devm_regulator_get(&dsi->pdev->dev, "vdd");
> +	vdds_dsi = devm_regulator_get(dsi->dev, "vdd");
>  
>  	if (IS_ERR(vdds_dsi)) {
>  		if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
> @@ -4953,7 +4953,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
>  {
>  	struct clk *clk;
>  
> -	clk = devm_clk_get(&dsi->pdev->dev, "fck");
> +	clk = devm_clk_get(dsi->dev, "fck");
>  	if (IS_ERR(clk)) {
>  		DSSERR("can't get fck\n");
>  		return PTR_ERR(clk);
> @@ -5048,7 +5048,7 @@ static void dsi_init_output(struct dsi_data *dsi)
>  {
>  	struct omap_dss_device *out = &dsi->output;
>  
> -	out->dev = &dsi->pdev->dev;
> +	out->dev = dsi->dev;
>  	out->id = dsi->module_id == 0 ?
>  			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
>  
> @@ -5070,7 +5070,7 @@ static void dsi_uninit_output(struct dsi_data *dsi)
>  
>  static int dsi_probe_of(struct dsi_data *dsi)
>  {
> -	struct device_node *node = dsi->pdev->dev.of_node;
> +	struct device_node *node = dsi->dev->of_node;
>  	struct property *prop;
>  	u32 lane_arr[10];
>  	int len, num_pins;
> @@ -5084,7 +5084,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
>  
>  	prop = of_find_property(ep, "lanes", &len);
>  	if (prop == NULL) {
> -		dev_err(&dsi->pdev->dev, "failed to find lane data\n");
> +		dev_err(dsi->dev, "failed to find lane data\n");
>  		r = -EINVAL;
>  		goto err;
>  	}
> @@ -5093,14 +5093,14 @@ static int dsi_probe_of(struct dsi_data *dsi)
>  
>  	if (num_pins < 4 || num_pins % 2 != 0 ||
>  		num_pins > dsi->num_lanes_supported * 2) {
> -		dev_err(&dsi->pdev->dev, "bad number of lanes\n");
> +		dev_err(dsi->dev, "bad number of lanes\n");
>  		r = -EINVAL;
>  		goto err;
>  	}
>  
>  	r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
>  	if (r) {
> -		dev_err(&dsi->pdev->dev, "failed to read lane data\n");
> +		dev_err(dsi->dev, "failed to read lane data\n");
>  		goto err;
>  	}
>  
> @@ -5110,7 +5110,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
>  
>  	r = dsi_configure_pins(&dsi->output, &pin_cfg);
>  	if (r) {
> -		dev_err(&dsi->pdev->dev, "failed to configure pins");
> +		dev_err(dsi->dev, "failed to configure pins");
>  		goto err;
>  	}
>  
> @@ -5216,7 +5216,7 @@ static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
>  	struct clk *clk;
>  	int r;
>  
> -	clk = devm_clk_get(&dsi->pdev->dev, "sys_clk");
> +	clk = devm_clk_get(dsi->dev, "sys_clk");
>  	if (IS_ERR(clk)) {
>  		DSSERR("can't get sys_clk\n");
>  		return PTR_ERR(clk);
> @@ -5320,7 +5320,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  		return -ENOMEM;
>  
>  	dsi->dss = dss;
> -	dsi->pdev = pdev;
> +	dsi->dev = dev;
>  	dev_set_drvdata(dev, dsi);
>  
>  	spin_lock_init(&dsi->irq_lock);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions
  2017-10-13 14:59 ` [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
@ 2017-10-17 20:13   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:13 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3400 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:36PM +0300, Laurent Pinchart wrote:
> The dsi_display_init_dispc() and dsi_display_uninit_dispc() functions
> take a channel argument that is reduntant as it is always identical to
> the dsi->output.dispc_channel. Remove the argument and use the field
> directly in the functions to avoid misuse.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 9be26eb262f3..d1cc036ed280 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -217,10 +217,8 @@ struct dsi_reg { u16 module; u16 idx; };
>  typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
>  struct dsi_data;
>  
> -static int dsi_display_init_dispc(struct dsi_data *dsi,
> -	enum omap_channel channel);
> -static void dsi_display_uninit_dispc(struct dsi_data *dsi,
> -	enum omap_channel channel);
> +static int dsi_display_init_dispc(struct dsi_data *dsi);
> +static void dsi_display_uninit_dispc(struct dsi_data *dsi);
>  
>  static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
>  
> @@ -3847,7 +3845,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  		return -ENODEV;
>  	}
>  
> -	r = dsi_display_init_dispc(dsi, dispc_channel);
> +	r = dsi_display_init_dispc(dsi);
>  	if (r)
>  		goto err_init_dispc;
>  
> @@ -3897,7 +3895,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  		dsi_vc_enable(dsi, channel, false);
>  	}
>  err_pix_fmt:
> -	dsi_display_uninit_dispc(dsi, dispc_channel);
> +	dsi_display_uninit_dispc(dsi);
>  err_init_dispc:
>  	return r;
>  }
> @@ -3920,7 +3918,7 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
>  
>  	dss_mgr_disable(dispc_channel);
>  
> -	dsi_display_uninit_dispc(dsi, dispc_channel);
> +	dsi_display_uninit_dispc(dsi);
>  }
>  
>  static void dsi_update_screen_dispc(struct dsi_data *dsi)
> @@ -4106,9 +4104,9 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static int dsi_display_init_dispc(struct dsi_data *dsi,
> -				  enum omap_channel channel)
> +static int dsi_display_init_dispc(struct dsi_data *dsi)
>  {
> +	enum omap_channel channel = dsi->output.dispc_channel;
>  	int r;
>  
>  	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
> @@ -4169,9 +4167,10 @@ static int dsi_display_init_dispc(struct dsi_data *dsi,
>  	return r;
>  }
>  
> -static void dsi_display_uninit_dispc(struct dsi_data *dsi,
> -				     enum omap_channel channel)
> +static void dsi_display_uninit_dispc(struct dsi_data *dsi)
>  {
> +	enum omap_channel channel = dsi->output.dispc_channel;
> +
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
>  		dss_mgr_unregister_framedone_handler(channel,
>  				dsi_framedone_irq_callback, dsi);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions
  2017-10-13 14:59 ` [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
@ 2017-10-17 20:31   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:31 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 28976 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:37PM +0300, Laurent Pinchart wrote:
> The dss_mgr_*() functions take a channel argument to identify the
> channel they operate on. This prevents the functions from accessing
> driver data structures without resorting to global variables. In an
> effort to remove global variables, pass the omap_dss_device pointer
> associated with the channel instead. This will be used to look up the
> omap_drm_private data structure to pass to the dss_mgr_ops.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c     | 32 ++++++++++----------------
>  drivers/gpu/drm/omapdrm/dss/dsi.c     | 30 +++++++++++--------------
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 20 +++++++----------
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 20 +++++++----------
>  drivers/gpu/drm/omapdrm/dss/omapdss.h | 22 +++++++++---------
>  drivers/gpu/drm/omapdrm/dss/output.c  | 42 ++++++++++++++++++-----------------
>  drivers/gpu/drm/omapdrm/dss/sdi.c     | 27 +++++++++-------------
>  drivers/gpu/drm/omapdrm/dss/venc.c    | 18 ++++++---------
>  8 files changed, 92 insertions(+), 119 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index b0f890a3c8db..3894e53ff58d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -344,8 +344,6 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
>  
>  static int dpi_set_mode(struct dpi_data *dpi)
>  {
> -	struct omap_dss_device *out = &dpi->output;
> -	enum omap_channel channel = out->dispc_channel;
>  	struct videomode *vm = &dpi->vm;
>  	int lck_div = 0, pck_div = 0;
>  	unsigned long fck = 0;
> @@ -353,8 +351,8 @@ static int dpi_set_mode(struct dpi_data *dpi)
>  	int r = 0;
>  
>  	if (dpi->pll)
> -		r = dpi_set_pll_clk(dpi, channel, vm->pixelclock, &fck,
> -				&lck_div, &pck_div);
> +		r = dpi_set_pll_clk(dpi, dpi->output.dispc_channel,
> +				    vm->pixelclock, &fck, &lck_div, &pck_div);
>  	else
>  		r = dpi_set_dispc_clk(dpi, vm->pixelclock, &fck,
>  				&lck_div, &pck_div);
> @@ -370,16 +368,13 @@ static int dpi_set_mode(struct dpi_data *dpi)
>  		vm->pixelclock = pck;
>  	}
>  
> -	dss_mgr_set_timings(channel, vm);
> +	dss_mgr_set_timings(&dpi->output, vm);
>  
>  	return 0;
>  }
>  
>  static void dpi_config_lcd_manager(struct dpi_data *dpi)
>  {
> -	struct omap_dss_device *out = &dpi->output;
> -	enum omap_channel channel = out->dispc_channel;
> -
>  	dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
>  
>  	dpi->mgr_config.stallmode = false;
> @@ -389,14 +384,13 @@ static void dpi_config_lcd_manager(struct dpi_data *dpi)
>  
>  	dpi->mgr_config.lcden_sig_polarity = 0;
>  
> -	dss_mgr_set_lcd_config(channel, &dpi->mgr_config);
> +	dss_mgr_set_lcd_config(&dpi->output, &dpi->mgr_config);
>  }
>  
>  static int dpi_display_enable(struct omap_dss_device *dssdev)
>  {
>  	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
>  	struct omap_dss_device *out = &dpi->output;
> -	enum omap_channel channel = out->dispc_channel;
>  	int r;
>  
>  	mutex_lock(&dpi->lock);
> @@ -417,7 +411,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_get_dispc;
>  
> -	r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
> +	r = dss_dpi_select_source(dpi->dss, out->port_num, out->dispc_channel);
>  	if (r)
>  		goto err_src_sel;
>  
> @@ -435,7 +429,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  
>  	mdelay(2);
>  
> -	r = dss_mgr_enable(channel);
> +	r = dss_mgr_enable(&dpi->output);
>  	if (r)
>  		goto err_mgr_enable;
>  
> @@ -462,14 +456,14 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  static void dpi_display_disable(struct omap_dss_device *dssdev)
>  {
>  	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
> -	enum omap_channel channel = dpi->output.dispc_channel;
>  
>  	mutex_lock(&dpi->lock);
>  
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&dpi->output);
>  
>  	if (dpi->pll) {
> -		dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
> +		dss_select_lcd_clk_source(dpi->dss, dpi->output.dispc_channel,
> +					  DSS_CLK_SRC_FCK);
>  		dss_pll_disable(dpi->pll);
>  	}
>  
> @@ -659,7 +653,6 @@ static int dpi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
> -	enum omap_channel channel = dpi->output.dispc_channel;
>  	int r;
>  
>  	r = dpi_init_regulator(dpi);
> @@ -668,7 +661,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
>  
>  	dpi_init_pll(dpi);
>  
> -	r = dss_mgr_connect(channel, dssdev);
> +	r = dss_mgr_connect(&dpi->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -676,7 +669,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dst->name);
> -		dss_mgr_disconnect(channel, dssdev);
> +		dss_mgr_disconnect(&dpi->output, dssdev);
>  		return r;
>  	}
>  
> @@ -687,7 +680,6 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
> -	enum omap_channel channel = dpi->output.dispc_channel;
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -696,7 +688,7 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(channel, dssdev);
> +	dss_mgr_disconnect(&dpi->output, dssdev);
>  }
>  
>  static const struct omapdss_dpi_ops dpi_ops = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index d1cc036ed280..512625ed03e2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3833,7 +3833,6 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
>  static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
>  	struct omap_dss_device *out = &dsi->output;
>  	u8 data_type;
> @@ -3883,7 +3882,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  		dsi_if_enable(dsi, true);
>  	}
>  
> -	r = dss_mgr_enable(dispc_channel);
> +	r = dss_mgr_enable(&dsi->output);
>  	if (r)
>  		goto err_mgr_enable;
>  
> @@ -3903,7 +3902,6 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
>  		dsi_if_enable(dsi, false);
> @@ -3916,14 +3914,13 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
>  		dsi_if_enable(dsi, true);
>  	}
>  
> -	dss_mgr_disable(dispc_channel);
> +	dss_mgr_disable(&dsi->output);
>  
>  	dsi_display_uninit_dispc(dsi);
>  }
>  
>  static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  {
> -	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  	unsigned int bytespp;
>  	unsigned int bytespl;
>  	unsigned int bytespf;
> @@ -3985,9 +3982,9 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  		msecs_to_jiffies(250));
>  	BUG_ON(r == 0);
>  
> -	dss_mgr_set_timings(dispc_channel, &dsi->vm);
> +	dss_mgr_set_timings(&dsi->output, &dsi->vm);
>  
> -	dss_mgr_start_update(dispc_channel);
> +	dss_mgr_start_update(&dsi->output);
>  
>  	if (dsi->te_enabled) {
>  		/* disable LP_RX_TO, so that we can receive TE.  Time to wait
> @@ -4114,7 +4111,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
>  			DSS_CLK_SRC_PLL2_1);
>  
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) {
> -		r = dss_mgr_register_framedone_handler(channel,
> +		r = dss_mgr_register_framedone_handler(&dsi->output,
>  				dsi_framedone_irq_callback, dsi);
>  		if (r) {
>  			DSSERR("can't register FRAMEDONE handler\n");
> @@ -4144,7 +4141,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
>  	dsi->vm.flags &= ~DISPLAY_FLAGS_SYNC_POSEDGE;
>  	dsi->vm.flags |= DISPLAY_FLAGS_SYNC_NEGEDGE;
>  
> -	dss_mgr_set_timings(channel, &dsi->vm);
> +	dss_mgr_set_timings(&dsi->output, &dsi->vm);
>  
>  	r = dsi_configure_dispc_clocks(dsi);
>  	if (r)
> @@ -4155,12 +4152,12 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
>  			dsi_get_pixel_size(dsi->pix_fmt);
>  	dsi->mgr_config.lcden_sig_polarity = 0;
>  
> -	dss_mgr_set_lcd_config(channel, &dsi->mgr_config);
> +	dss_mgr_set_lcd_config(&dsi->output, &dsi->mgr_config);
>  
>  	return 0;
>  err1:
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
> -		dss_mgr_unregister_framedone_handler(channel,
> +		dss_mgr_unregister_framedone_handler(&dsi->output,
>  				dsi_framedone_irq_callback, dsi);
>  err:
>  	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> @@ -4172,7 +4169,7 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi)
>  	enum omap_channel channel = dsi->output.dispc_channel;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
> -		dss_mgr_unregister_framedone_handler(channel,
> +		dss_mgr_unregister_framedone_handler(&dsi->output,
>  				dsi_framedone_irq_callback, dsi);
>  
>  	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> @@ -4967,14 +4964,13 @@ static int dsi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	enum omap_channel dispc_channel = dssdev->dispc_channel;
>  	int r;
>  
>  	r = dsi_regulator_init(dsi);
>  	if (r)
>  		return r;
>  
> -	r = dss_mgr_connect(dispc_channel, dssdev);
> +	r = dss_mgr_connect(&dsi->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -4982,7 +4978,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dssdev->name);
> -		dss_mgr_disconnect(dispc_channel, dssdev);
> +		dss_mgr_disconnect(&dsi->output, dssdev);
>  		return r;
>  	}
>  
> @@ -4992,7 +4988,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
>  static void dsi_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	enum omap_channel dispc_channel = dssdev->dispc_channel;
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -5001,7 +4997,7 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(dispc_channel, dssdev);
> +	dss_mgr_disconnect(&dsi->output, dssdev);
>  }
>  
>  static const struct omapdss_dsi_ops dsi_ops = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index f0a30b248a7d..56de3c75b0a0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -174,7 +174,6 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  	struct videomode *vm;
> -	enum omap_channel channel = hdmi->output.dispc_channel;
>  	struct hdmi_wp_data *wp = &hdmi->wp;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
>  	unsigned int pc;
> @@ -228,9 +227,9 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  	hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
>  
>  	/* tv size */
> -	dss_mgr_set_timings(channel, vm);
> +	dss_mgr_set_timings(&hdmi->output, vm);
>  
> -	r = dss_mgr_enable(channel);
> +	r = dss_mgr_enable(&hdmi->output);
>  	if (r)
>  		goto err_mgr_enable;
>  
> @@ -244,7 +243,7 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  	return 0;
>  
>  err_vid_enable:
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&hdmi->output);
>  err_mgr_enable:
>  	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  err_phy_pwr:
> @@ -258,13 +257,11 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  
>  static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  {
> -	enum omap_channel channel = hdmi->output.dispc_channel;
> -
>  	hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
>  
>  	hdmi_wp_video_stop(&hdmi->wp);
>  
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&hdmi->output);
>  
>  	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  
> @@ -459,14 +456,13 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> -	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
>  	r = hdmi_init_regulator(hdmi);
>  	if (r)
>  		return r;
>  
> -	r = dss_mgr_connect(channel, dssdev);
> +	r = dss_mgr_connect(&hdmi->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -474,7 +470,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dst->name);
> -		dss_mgr_disconnect(channel, dssdev);
> +		dss_mgr_disconnect(&hdmi->output, dssdev);
>  		return r;
>  	}
>  
> @@ -484,7 +480,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -493,7 +489,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(channel, dssdev);
> +	dss_mgr_disconnect(&hdmi->output, dssdev);
>  }
>  
>  static int hdmi_read_edid(struct omap_dss_device *dssdev,
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index ed8a2bd2a035..1e839af800e7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -172,7 +172,6 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  {
>  	int r;
>  	struct videomode *vm;
> -	enum omap_channel channel = hdmi->output.dispc_channel;
>  	struct dss_pll_clock_info hdmi_cinfo = { 0 };
>  	unsigned int pc;
>  
> @@ -226,9 +225,9 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  	hdmi5_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
>  
>  	/* tv size */
> -	dss_mgr_set_timings(channel, vm);
> +	dss_mgr_set_timings(&hdmi->output, vm);
>  
> -	r = dss_mgr_enable(channel);
> +	r = dss_mgr_enable(&hdmi->output);
>  	if (r)
>  		goto err_mgr_enable;
>  
> @@ -242,7 +241,7 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  	return 0;
>  
>  err_vid_enable:
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&hdmi->output);
>  err_mgr_enable:
>  	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  err_phy_pwr:
> @@ -256,13 +255,11 @@ static int hdmi_power_on_full(struct omap_hdmi *hdmi)
>  
>  static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  {
> -	enum omap_channel channel = hdmi->output.dispc_channel;
> -
>  	hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff);
>  
>  	hdmi_wp_video_stop(&hdmi->wp);
>  
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&hdmi->output);
>  
>  	hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
>  
> @@ -463,14 +460,13 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> -	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
>  	r = hdmi_init_regulator(hdmi);
>  	if (r)
>  		return r;
>  
> -	r = dss_mgr_connect(channel, dssdev);
> +	r = dss_mgr_connect(&hdmi->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -478,7 +474,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dst->name);
> -		dss_mgr_disconnect(channel, dssdev);
> +		dss_mgr_disconnect(&hdmi->output, dssdev);
>  		return r;
>  	}
>  
> @@ -488,7 +484,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
>  static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -497,7 +493,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(channel, dssdev);
> +	dss_mgr_disconnect(&hdmi->output, dssdev);
>  }
>  
>  static int hdmi_read_edid(struct omap_dss_device *dssdev,
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 6f9b9b2d8af2..8024680e8d57 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -656,20 +656,20 @@ struct dss_mgr_ops {
>  int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
>  void dss_uninstall_mgr_ops(void);
>  
> -int dss_mgr_connect(enum omap_channel channel,
> -		struct omap_dss_device *dst);
> -void dss_mgr_disconnect(enum omap_channel channel,
> -		struct omap_dss_device *dst);
> -void dss_mgr_set_timings(enum omap_channel channel,
> +int dss_mgr_connect(struct omap_dss_device *dssdev,
> +		    struct omap_dss_device *dst);
> +void dss_mgr_disconnect(struct omap_dss_device *dssdev,
> +			struct omap_dss_device *dst);
> +void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  		const struct videomode *vm);
> -void dss_mgr_set_lcd_config(enum omap_channel channel,
> +void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  		const struct dss_lcd_mgr_config *config);
> -int dss_mgr_enable(enum omap_channel channel);
> -void dss_mgr_disable(enum omap_channel channel);
> -void dss_mgr_start_update(enum omap_channel channel);
> -int dss_mgr_register_framedone_handler(enum omap_channel channel,
> +int dss_mgr_enable(struct omap_dss_device *dssdev);
> +void dss_mgr_disable(struct omap_dss_device *dssdev);
> +void dss_mgr_start_update(struct omap_dss_device *dssdev);
> +int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data);
> -void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
> +void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data);
>  
>  /* dispc ops */
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index a84ab0337a91..0573b5099f8f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -184,52 +184,54 @@ void dss_uninstall_mgr_ops(void)
>  }
>  EXPORT_SYMBOL(dss_uninstall_mgr_ops);
>  
> -int dss_mgr_connect(enum omap_channel channel,
> -		struct omap_dss_device *dst)
> +int dss_mgr_connect(struct omap_dss_device *dssdev, struct omap_dss_device *dst)
>  {
> -	return dss_mgr_ops->connect(channel, dst);
> +	return dss_mgr_ops->connect(dssdev->dispc_channel, dst);
>  }
>  
> -void dss_mgr_disconnect(enum omap_channel channel,
> -		struct omap_dss_device *dst)
> +void dss_mgr_disconnect(struct omap_dss_device *dssdev,
> +			struct omap_dss_device *dst)
>  {
> -	dss_mgr_ops->disconnect(channel, dst);
> +	dss_mgr_ops->disconnect(dssdev->dispc_channel, dst);
>  }
>  
> -void dss_mgr_set_timings(enum omap_channel channel, const struct videomode *vm)
> +void dss_mgr_set_timings(struct omap_dss_device *dssdev,
> +			 const struct videomode *vm)
>  {
> -	dss_mgr_ops->set_timings(channel, vm);
> +	dss_mgr_ops->set_timings(dssdev->dispc_channel, vm);
>  }
>  
> -void dss_mgr_set_lcd_config(enum omap_channel channel,
> +void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  		const struct dss_lcd_mgr_config *config)
>  {
> -	dss_mgr_ops->set_lcd_config(channel, config);
> +	dss_mgr_ops->set_lcd_config(dssdev->dispc_channel, config);
>  }
>  
> -int dss_mgr_enable(enum omap_channel channel)
> +int dss_mgr_enable(struct omap_dss_device *dssdev)
>  {
> -	return dss_mgr_ops->enable(channel);
> +	return dss_mgr_ops->enable(dssdev->dispc_channel);
>  }
>  
> -void dss_mgr_disable(enum omap_channel channel)
> +void dss_mgr_disable(struct omap_dss_device *dssdev)
>  {
> -	dss_mgr_ops->disable(channel);
> +	dss_mgr_ops->disable(dssdev->dispc_channel);
>  }
>  
> -void dss_mgr_start_update(enum omap_channel channel)
> +void dss_mgr_start_update(struct omap_dss_device *dssdev)
>  {
> -	dss_mgr_ops->start_update(channel);
> +	dss_mgr_ops->start_update(dssdev->dispc_channel);
>  }
>  
> -int dss_mgr_register_framedone_handler(enum omap_channel channel,
> +int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
>  {
> -	return dss_mgr_ops->register_framedone_handler(channel, handler, data);
> +	return dss_mgr_ops->register_framedone_handler(dssdev->dispc_channel,
> +						       handler, data);
>  }
>  
> -void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
> +void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
>  {
> -	dss_mgr_ops->unregister_framedone_handler(channel, handler, data);
> +	dss_mgr_ops->unregister_framedone_handler(dssdev->dispc_channel,
> +						  handler, data);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index a35dc51c5a6a..681a3653dd8c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -115,8 +115,6 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
>  
>  static void sdi_config_lcd_manager(struct sdi_device *sdi)
>  {
> -	enum omap_channel channel = sdi->output.dispc_channel;
> -
>  	sdi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
>  
>  	sdi->mgr_config.stallmode = false;
> @@ -125,21 +123,19 @@ static void sdi_config_lcd_manager(struct sdi_device *sdi)
>  	sdi->mgr_config.video_port_width = 24;
>  	sdi->mgr_config.lcden_sig_polarity = 1;
>  
> -	dss_mgr_set_lcd_config(channel, &sdi->mgr_config);
> +	dss_mgr_set_lcd_config(&sdi->output, &sdi->mgr_config);
>  }
>  
>  static int sdi_display_enable(struct omap_dss_device *dssdev)
>  {
>  	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> -	struct omap_dss_device *out = &sdi->output;
> -	enum omap_channel channel = dssdev->dispc_channel;
>  	struct videomode *vm = &sdi->vm;
>  	unsigned long fck;
>  	struct dispc_clock_info dispc_cinfo;
>  	unsigned long pck;
>  	int r;
>  
> -	if (!out->dispc_channel_connected) {
> +	if (!sdi->output.dispc_channel_connected) {
>  		DSSERR("failed to enable display: no output/manager\n");
>  		return -ENODEV;
>  	}
> @@ -171,7 +167,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	}
>  
>  
> -	dss_mgr_set_timings(channel, vm);
> +	dss_mgr_set_timings(&sdi->output, vm);
>  
>  	r = dss_set_fck_rate(sdi->dss, fck);
>  	if (r)
> @@ -190,7 +186,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	 * need to care about the shadow register mechanism for pck-free. The
>  	 * exact reason for this is unknown.
>  	 */
> -	dispc_mgr_set_clock_div(channel, &sdi->mgr_config.clock_info);
> +	dispc_mgr_set_clock_div(sdi->output.dispc_channel,
> +				&sdi->mgr_config.clock_info);
>  
>  	dss_sdi_init(sdi->dss, sdi->datapairs);
>  	r = dss_sdi_enable(sdi->dss);
> @@ -198,7 +195,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  		goto err_sdi_enable;
>  	mdelay(2);
>  
> -	r = dss_mgr_enable(channel);
> +	r = dss_mgr_enable(&sdi->output);
>  	if (r)
>  		goto err_mgr_enable;
>  
> @@ -219,9 +216,8 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  static void sdi_display_disable(struct omap_dss_device *dssdev)
>  {
>  	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> -	enum omap_channel channel = dssdev->dispc_channel;
>  
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&sdi->output);
>  
>  	dss_sdi_disable(sdi->dss);
>  
> @@ -283,14 +279,13 @@ static int sdi_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
> -	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
>  	r = sdi_init_regulator(sdi);
>  	if (r)
>  		return r;
>  
> -	r = dss_mgr_connect(channel, dssdev);
> +	r = dss_mgr_connect(&sdi->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -298,7 +293,7 @@ static int sdi_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dst->name);
> -		dss_mgr_disconnect(channel, dssdev);
> +		dss_mgr_disconnect(&sdi->output, dssdev);
>  		return r;
>  	}
>  
> @@ -308,7 +303,7 @@ static int sdi_connect(struct omap_dss_device *dssdev,
>  static void sdi_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -317,7 +312,7 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(channel, dssdev);
> +	dss_mgr_disconnect(&sdi->output, dssdev);
>  }
>  
>  static const struct omapdss_sdi_ops sdi_ops = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 7acdbfefe397..d82645e84db7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -468,7 +468,6 @@ static const struct venc_config *venc_timings_to_config(struct videomode *vm)
>  
>  static int venc_power_on(struct venc_device *venc)
>  {
> -	enum omap_channel channel = venc->output.dispc_channel;
>  	u32 l;
>  	int r;
>  
> @@ -494,13 +493,13 @@ static int venc_power_on(struct venc_device *venc)
>  
>  	venc_write_reg(venc, VENC_OUTPUT_CONTROL, l);
>  
> -	dss_mgr_set_timings(channel, &venc->vm);
> +	dss_mgr_set_timings(&venc->output, &venc->vm);
>  
>  	r = regulator_enable(venc->vdda_dac_reg);
>  	if (r)
>  		goto err1;
>  
> -	r = dss_mgr_enable(channel);
> +	r = dss_mgr_enable(&venc->output);
>  	if (r)
>  		goto err2;
>  
> @@ -519,12 +518,10 @@ static int venc_power_on(struct venc_device *venc)
>  
>  static void venc_power_off(struct venc_device *venc)
>  {
> -	enum omap_channel channel = venc->output.dispc_channel;
> -
>  	venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0);
>  	dss_set_dac_pwrdn_bgz(venc->dss, 0);
>  
> -	dss_mgr_disable(channel);
> +	dss_mgr_disable(&venc->output);
>  
>  	regulator_disable(venc->vdda_dac_reg);
>  
> @@ -768,14 +765,13 @@ static int venc_connect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
>  	struct venc_device *venc = dssdev_to_venc(dssdev);
> -	enum omap_channel channel = dssdev->dispc_channel;
>  	int r;
>  
>  	r = venc_init_regulator(venc);
>  	if (r)
>  		return r;
>  
> -	r = dss_mgr_connect(channel, dssdev);
> +	r = dss_mgr_connect(&venc->output, dssdev);
>  	if (r)
>  		return r;
>  
> @@ -783,7 +779,7 @@ static int venc_connect(struct omap_dss_device *dssdev,
>  	if (r) {
>  		DSSERR("failed to connect output to new device: %s\n",
>  				dst->name);
> -		dss_mgr_disconnect(channel, dssdev);
> +		dss_mgr_disconnect(&venc->output, dssdev);
>  		return r;
>  	}
>  
> @@ -793,7 +789,7 @@ static int venc_connect(struct omap_dss_device *dssdev,
>  static void venc_disconnect(struct omap_dss_device *dssdev,
>  		struct omap_dss_device *dst)
>  {
> -	enum omap_channel channel = dssdev->dispc_channel;
> +	struct venc_device *venc = dssdev_to_venc(dssdev);
>  
>  	WARN_ON(dst != dssdev->dst);
>  
> @@ -802,7 +798,7 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
>  
>  	omapdss_output_unset_device(dssdev);
>  
> -	dss_mgr_disconnect(channel, dssdev);
> +	dss_mgr_disconnect(&venc->output, dssdev);
>  }
>  
>  static const struct omapdss_atv_ops venc_ops = {
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes
  2017-10-13 14:59 ` [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes Laurent Pinchart
@ 2017-10-17 20:37   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 20:37 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2034 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:38PM +0300, Laurent Pinchart wrote:
> The omap_dss_register_driver(), omap_dss_unregister_driver() and
> dispc_enable_gamma_table() functions don't exist anymore, remove their
> prototypes.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Yeah, I also found the ones from omapdss.h:

https://patchwork.kernel.org/patch/9859893/

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dss.h     | 1 -
>  drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ---
>  2 files changed, 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 6950f5d61b6c..5d6f8afca49d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -388,7 +388,6 @@ void dispc_disable_sidle(void);
>  void dispc_lcd_enable_signal(bool enable);
>  void dispc_pck_free_enable(bool enable);
>  void dispc_enable_fifomerge(bool enable);
> -void dispc_enable_gamma_table(bool enable);
>  
>  typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
>  		unsigned long pck, void *data);
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 8024680e8d57..32c5944b0bea 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -583,9 +583,6 @@ struct omap_dss_driver {
>  		const struct hdmi_avi_infoframe *avi);
>  };
>  
> -int omap_dss_register_driver(struct omap_dss_driver *);
> -void omap_dss_unregister_driver(struct omap_dss_driver *);
> -
>  int omapdss_register_display(struct omap_dss_device *dssdev);
>  void omapdss_unregister_display(struct omap_dss_device *dssdev);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops
  2017-10-13 14:59 ` [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
@ 2017-10-17 21:23   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 21:23 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 16773 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:39PM +0300, Laurent Pinchart wrote:
> The dss_mgr_ops operations implemented by the omapdrm side have to look
> up the omap_crtc objects from global variables as they are only passed a
> channel number. In order to remove global variables pass the
> omap_drm_private pointer to the dss_mgr_ops. This requires storing a
> pointer to the dss_device in the omap_dss_device structure to allow
> looking up the omap_drm_private in the dss_mgr_*() functions.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c     |  1 +
>  drivers/gpu/drm/omapdrm/dss/dsi.c     |  1 +
>  drivers/gpu/drm/omapdrm/dss/dss.c     | 37 ---------------------------------
>  drivers/gpu/drm/omapdrm/dss/dss.h     | 37 +++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c   |  1 +
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c   |  1 +
>  drivers/gpu/drm/omapdrm/dss/omapdss.h | 39 ++++++++++++++++++++++-------------
>  drivers/gpu/drm/omapdrm/dss/output.c  | 23 +++++++++++++--------
>  drivers/gpu/drm/omapdrm/dss/sdi.c     |  1 +
>  drivers/gpu/drm/omapdrm/dss/venc.c    |  1 +
>  drivers/gpu/drm/omapdrm/omap_crtc.c   | 27 ++++++++++++++----------
>  11 files changed, 98 insertions(+), 71 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 3894e53ff58d..ae43ba81eb96 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -727,6 +727,7 @@ static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
>  	}
>  
>  	out->dev = &dpi->pdev->dev;
> +	out->dss = dpi->dss;
>  	out->id = OMAP_DSS_OUTPUT_DPI;
>  	out->output_type = OMAP_DISPLAY_TYPE_DPI;
>  	out->dispc_channel = dpi_get_channel(dpi, port_num);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 512625ed03e2..eafea72998dd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5044,6 +5044,7 @@ static void dsi_init_output(struct dsi_data *dsi)
>  	struct omap_dss_device *out = &dsi->output;
>  
>  	out->dev = dsi->dev;
> +	out->dss = dsi->dss;
>  	out->id = dsi->module_id == 0 ?
>  			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 8fec9bf6f06f..0e8c70591308 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -49,9 +49,6 @@
>  
>  #include "omapdss.h"
>  #include "dss.h"
> -#include "../omap_drv.h"
> -
> -#define DSS_SZ_REGS			SZ_512
>  
>  struct dss_reg {
>  	u16 idx;
> @@ -96,40 +93,6 @@ struct dss_features {
>  	bool has_lcd_clk_src;
>  };
>  
> -struct dss_device {
> -	struct platform_device *pdev;
> -	struct omap_drm_private drm;
> -
> -	void __iomem    *base;
> -	struct regmap	*syscon_pll_ctrl;
> -	u32		syscon_pll_ctrl_offset;
> -
> -	struct clk	*parent_clk;
> -	struct clk	*dss_clk;
> -	unsigned long	dss_clk_rate;
> -
> -	unsigned long	cache_req_pck;
> -	unsigned long	cache_prate;
> -	struct dispc_clock_info cache_dispc_cinfo;
> -
> -	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
> -	enum dss_clk_source dispc_clk_source;
> -	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
> -
> -	bool		ctx_valid;
> -	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
> -
> -	const struct dss_features *feat;
> -
> -	struct {
> -		struct dss_debugfs_entry *clk;
> -		struct dss_debugfs_entry *dss;
> -	} debugfs;
> -
> -	struct dss_pll	*video1_pll;
> -	struct dss_pll	*video2_pll;
> -};
> -
>  static const char * const dss_generic_clk_source_names[] = {
>  	[DSS_CLK_SRC_FCK]	= "FCK",
>  	[DSS_CLK_SRC_PLL1_1]	= "PLL1:1",
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 5d6f8afca49d..cda2cbd888f0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -26,6 +26,7 @@
>  #include <linux/interrupt.h>
>  
>  #include "omapdss.h"
> +#include "../omap_drv.h"
>  
>  struct dentry;
>  struct dss_debugfs_entry;
> @@ -241,6 +242,42 @@ struct dss_lcd_mgr_config {
>  	int lcden_sig_polarity;
>  };
>  
> +#define DSS_SZ_REGS			SZ_512
> +
> +struct dss_device {
> +	struct platform_device *pdev;
> +	struct omap_drm_private drm;
> +
> +	void __iomem    *base;
> +	struct regmap	*syscon_pll_ctrl;
> +	u32		syscon_pll_ctrl_offset;
> +
> +	struct clk	*parent_clk;
> +	struct clk	*dss_clk;
> +	unsigned long	dss_clk_rate;
> +
> +	unsigned long	cache_req_pck;
> +	unsigned long	cache_prate;
> +	struct dispc_clock_info cache_dispc_cinfo;
> +
> +	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
> +	enum dss_clk_source dispc_clk_source;
> +	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
> +
> +	bool		ctx_valid;
> +	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
> +
> +	const struct dss_features *feat;
> +
> +	struct {
> +		struct dss_debugfs_entry *clk;
> +		struct dss_debugfs_entry *dss;
> +	} debugfs;
> +
> +	struct dss_pll	*video1_pll;
> +	struct dss_pll	*video2_pll;
> +};
> +
>  /* core */
>  static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
>  {
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 56de3c75b0a0..501813f03466 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -566,6 +566,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
>  	struct omap_dss_device *out = &hdmi->output;
>  
>  	out->dev = &hdmi->pdev->dev;
> +	out->dss = hdmi->dss;
>  	out->id = OMAP_DSS_OUTPUT_HDMI;
>  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
>  	out->name = "hdmi->0";
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 1e839af800e7..44954bdea6ce 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -558,6 +558,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
>  	struct omap_dss_device *out = &hdmi->output;
>  
>  	out->dev = &hdmi->pdev->dev;
> +	out->dss = hdmi->dss;
>  	out->id = OMAP_DSS_OUTPUT_HDMI;
>  	out->output_type = OMAP_DISPLAY_TYPE_HDMI;
>  	out->name = "hdmi->0";
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 32c5944b0bea..76ce94376454 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -59,6 +59,7 @@
>  #define DISPC_IRQ_ACBIAS_COUNT_STAT3	(1 << 29)
>  #define DISPC_IRQ_FRAMEDONE3		(1 << 30)
>  
> +struct omap_drm_private;
>  struct omap_dss_device;
>  struct dss_lcd_mgr_config;
>  struct snd_aes_iec958;
> @@ -471,6 +472,7 @@ struct omapdss_dsi_ops {
>  struct omap_dss_device {
>  	struct kobject kobj;
>  	struct device *dev;
> +	struct dss_device *dss; /* valid for DSS outputs only */
>  
>  	struct module *owner;
>  
> @@ -632,21 +634,30 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port);
>  u32 dss_of_port_get_port_number(struct device_node *port);
>  
>  struct dss_mgr_ops {
> -	int (*connect)(enum omap_channel channel,
> -		struct omap_dss_device *dst);
> -	void (*disconnect)(enum omap_channel channel,
> -		struct omap_dss_device *dst);
> -
> -	void (*start_update)(enum omap_channel channel);
> -	int (*enable)(enum omap_channel channel);
> -	void (*disable)(enum omap_channel channel);
> -	void (*set_timings)(enum omap_channel channel,
> -			const struct videomode *vm);
> -	void (*set_lcd_config)(enum omap_channel channel,
> -			const struct dss_lcd_mgr_config *config);
> -	int (*register_framedone_handler)(enum omap_channel channel,
> +	int (*connect)(struct omap_drm_private *priv,
> +		       enum omap_channel channel,
> +		       struct omap_dss_device *dst);
> +	void (*disconnect)(struct omap_drm_private *priv,
> +			   enum omap_channel channel,
> +			   struct omap_dss_device *dst);
> +
> +	void (*start_update)(struct omap_drm_private *priv,
> +			     enum omap_channel channel);
> +	int (*enable)(struct omap_drm_private *priv,
> +		      enum omap_channel channel);
> +	void (*disable)(struct omap_drm_private *priv,
> +			enum omap_channel channel);
> +	void (*set_timings)(struct omap_drm_private *priv,
> +			    enum omap_channel channel,
> +			    const struct videomode *vm);
> +	void (*set_lcd_config)(struct omap_drm_private *priv,
> +			       enum omap_channel channel,
> +			       const struct dss_lcd_mgr_config *config);
> +	int (*register_framedone_handler)(struct omap_drm_private *priv,
> +			enum omap_channel channel,
>  			void (*handler)(void *), void *data);
> -	void (*unregister_framedone_handler)(enum omap_channel channel,
> +	void (*unregister_framedone_handler)(struct omap_drm_private *priv,
> +			enum omap_channel channel,
>  			void (*handler)(void *), void *data);
>  };
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 0573b5099f8f..4a6ccad7e970 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -21,6 +21,7 @@
>  #include <linux/slab.h>
>  #include <linux/of.h>
>  
> +#include "dss.h"
>  #include "omapdss.h"
>  
>  static LIST_HEAD(output_list);
> @@ -186,52 +187,56 @@ EXPORT_SYMBOL(dss_uninstall_mgr_ops);
>  
>  int dss_mgr_connect(struct omap_dss_device *dssdev, struct omap_dss_device *dst)
>  {
> -	return dss_mgr_ops->connect(dssdev->dispc_channel, dst);
> +	return dss_mgr_ops->connect(&dssdev->dss->drm,
> +				    dssdev->dispc_channel, dst);
>  }
>  
>  void dss_mgr_disconnect(struct omap_dss_device *dssdev,
>  			struct omap_dss_device *dst)
>  {
> -	dss_mgr_ops->disconnect(dssdev->dispc_channel, dst);
> +	dss_mgr_ops->disconnect(&dssdev->dss->drm, dssdev->dispc_channel, dst);
>  }
>  
>  void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  			 const struct videomode *vm)
>  {
> -	dss_mgr_ops->set_timings(dssdev->dispc_channel, vm);
> +	dss_mgr_ops->set_timings(&dssdev->dss->drm, dssdev->dispc_channel, vm);
>  }
>  
>  void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  		const struct dss_lcd_mgr_config *config)
>  {
> -	dss_mgr_ops->set_lcd_config(dssdev->dispc_channel, config);
> +	dss_mgr_ops->set_lcd_config(&dssdev->dss->drm,
> +				    dssdev->dispc_channel, config);
>  }
>  
>  int dss_mgr_enable(struct omap_dss_device *dssdev)
>  {
> -	return dss_mgr_ops->enable(dssdev->dispc_channel);
> +	return dss_mgr_ops->enable(&dssdev->dss->drm, dssdev->dispc_channel);
>  }
>  
>  void dss_mgr_disable(struct omap_dss_device *dssdev)
>  {
> -	dss_mgr_ops->disable(dssdev->dispc_channel);
> +	dss_mgr_ops->disable(&dssdev->dss->drm, dssdev->dispc_channel);
>  }
>  
>  void dss_mgr_start_update(struct omap_dss_device *dssdev)
>  {
> -	dss_mgr_ops->start_update(dssdev->dispc_channel);
> +	dss_mgr_ops->start_update(&dssdev->dss->drm, dssdev->dispc_channel);
>  }
>  
>  int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
>  {
> -	return dss_mgr_ops->register_framedone_handler(dssdev->dispc_channel,
> +	return dss_mgr_ops->register_framedone_handler(&dssdev->dss->drm,
> +						       dssdev->dispc_channel,
>  						       handler, data);
>  }
>  
>  void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
>  {
> -	dss_mgr_ops->unregister_framedone_handler(dssdev->dispc_channel,
> +	dss_mgr_ops->unregister_framedone_handler(&dssdev->dss->drm,
> +						  dssdev->dispc_channel,
>  						  handler, data);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 681a3653dd8c..c41bf0d7dd18 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -332,6 +332,7 @@ static void sdi_init_output(struct sdi_device *sdi)
>  	struct omap_dss_device *out = &sdi->output;
>  
>  	out->dev = &sdi->pdev->dev;
> +	out->dss = sdi->dss;
>  	out->id = OMAP_DSS_OUTPUT_SDI;
>  	out->output_type = OMAP_DISPLAY_TYPE_SDI;
>  	out->name = "sdi.0";
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index d82645e84db7..f120d2910d0d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -821,6 +821,7 @@ static void venc_init_output(struct venc_device *venc)
>  	struct omap_dss_device *out = &venc->output;
>  
>  	out->dev = &venc->pdev->dev;
> +	out->dss = venc->dss;
>  	out->id = OMAP_DSS_OUTPUT_VENC;
>  	out->output_type = OMAP_DISPLAY_TYPE_VENC;
>  	out->name = "venc.0";
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index f78eac4a8b34..90a61a8199b4 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -114,7 +114,8 @@ static struct omap_crtc *omap_crtcs[8];
>  static struct omap_dss_device *omap_crtc_output[8];
>  
>  /* we can probably ignore these until we support command-mode panels: */
> -static int omap_crtc_dss_connect(enum omap_channel channel,
> +static int omap_crtc_dss_connect(struct omap_drm_private *priv,
> +		enum omap_channel channel,
>  		struct omap_dss_device *dst)
>  {
>  	const struct dispc_ops *dispc_ops = dispc_get_ops();
> @@ -131,14 +132,16 @@ static int omap_crtc_dss_connect(enum omap_channel channel,
>  	return 0;
>  }
>  
> -static void omap_crtc_dss_disconnect(enum omap_channel channel,
> +static void omap_crtc_dss_disconnect(struct omap_drm_private *priv,
> +		enum omap_channel channel,
>  		struct omap_dss_device *dst)
>  {
>  	omap_crtc_output[channel] = NULL;
>  	dst->dispc_channel_connected = false;
>  }
>  
> -static void omap_crtc_dss_start_update(enum omap_channel channel)
> +static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
> +				       enum omap_channel channel)
>  {
>  }
>  
> @@ -208,10 +211,10 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  }
>  
>  
> -static int omap_crtc_dss_enable(enum omap_channel channel)
> +static int omap_crtc_dss_enable(struct omap_drm_private *priv,
> +				enum omap_channel channel)
>  {
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
> -	struct omap_drm_private *priv = omap_crtc->base.dev->dev_private;
>  
>  	priv->dispc_ops->mgr_set_timings(omap_crtc->channel, &omap_crtc->vm);
>  	omap_crtc_set_enabled(&omap_crtc->base, true);
> @@ -219,14 +222,16 @@ static int omap_crtc_dss_enable(enum omap_channel channel)
>  	return 0;
>  }
>  
> -static void omap_crtc_dss_disable(enum omap_channel channel)
> +static void omap_crtc_dss_disable(struct omap_drm_private *priv,
> +				  enum omap_channel channel)
>  {
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
>  
>  	omap_crtc_set_enabled(&omap_crtc->base, false);
>  }
>  
> -static void omap_crtc_dss_set_timings(enum omap_channel channel,
> +static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
> +		enum omap_channel channel,
>  		const struct videomode *vm)
>  {
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
> @@ -234,25 +239,25 @@ static void omap_crtc_dss_set_timings(enum omap_channel channel,
>  	omap_crtc->vm = *vm;
>  }
>  
> -static void omap_crtc_dss_set_lcd_config(enum omap_channel channel,
> +static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
> +		enum omap_channel channel,
>  		const struct dss_lcd_mgr_config *config)
>  {
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
> -	struct omap_drm_private *priv = omap_crtc->base.dev->dev_private;
>  
>  	DBG("%s", omap_crtc->name);
>  	priv->dispc_ops->mgr_set_lcd_config(omap_crtc->channel, config);
>  }
>  
>  static int omap_crtc_dss_register_framedone(
> -		enum omap_channel channel,
> +		struct omap_drm_private *priv, enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
>  	return 0;
>  }
>  
>  static void omap_crtc_dss_unregister_framedone(
> -		enum omap_channel channel,
> +		struct omap_drm_private *priv, enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations
  2017-10-13 14:59 ` [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
@ 2017-10-17 21:23   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 21:23 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 51155 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:40PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DISPC private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DISPC private data dynamically).
> 
> In order to allow the omapdrm side to call the dispc_ops with a DISPC
> pointer, we also introduce a new function dss_get_dispc() to retrieve
> the DISPC corresponding to the DSS.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c   | 221 +++++++++++++++++++---------------
>  drivers/gpu/drm/omapdrm/dss/dpi.c     |   6 +-
>  drivers/gpu/drm/omapdrm/dss/dsi.c     |   4 +-
>  drivers/gpu/drm/omapdrm/dss/dss.c     |   7 +-
>  drivers/gpu/drm/omapdrm/dss/dss.h     |   7 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c   |   7 +-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c   |   7 +-
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  91 ++++++++------
>  drivers/gpu/drm/omapdrm/dss/sdi.c     |   6 +-
>  drivers/gpu/drm/omapdrm/dss/venc.c    |   4 +-
>  drivers/gpu/drm/omapdrm/omap_crtc.c   |  31 +++--
>  drivers/gpu/drm/omapdrm/omap_drv.c    |  18 +--
>  drivers/gpu/drm/omapdrm/omap_drv.h    |   5 +-
>  drivers/gpu/drm/omapdrm/omap_irq.c    |  32 ++---
>  drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +-
>  15 files changed, 261 insertions(+), 197 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 912957c471ce..1bca5785b8a8 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -164,7 +164,7 @@ struct dispc_features {
>  #define DISPC_MAX_NR_FIFOS 5
>  #define DISPC_MAX_CHANNEL_GAMMA 4
>  
> -static struct {
> +struct dispc_device {
>  	struct platform_device *pdev;
>  	void __iomem    *base;
>  	struct dss_device *dss;
> @@ -196,7 +196,9 @@ static struct {
>  
>  	/* DISPC_CONTROL & DISPC_CONFIG lock*/
>  	spinlock_t control_lock;
> -} dispc;
> +};
> +
> +static struct dispc_device dispc;
>  
>  enum omap_color_component {
>  	/* used for all color formats for OMAP3 and earlier
> @@ -363,9 +365,7 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
>  static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane);
>  static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane);
>  
> -static void dispc_clear_irqstatus(u32 mask);
> -static bool dispc_mgr_is_enabled(enum omap_channel channel);
> -static void dispc_clear_irqstatus(u32 mask);
> +static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
>  
>  static inline void dispc_write_reg(const u16 idx, u32 val)
>  {
> @@ -398,14 +398,14 @@ static void mgr_fld_write(enum omap_channel channel,
>  		spin_unlock_irqrestore(&dispc.control_lock, flags);
>  }
>  
> -static int dispc_get_num_ovls(void)
> +static int dispc_get_num_ovls(struct dispc_device *dispc)
>  {
> -	return dispc.feat->num_ovls;
> +	return dispc->feat->num_ovls;
>  }
>  
> -static int dispc_get_num_mgrs(void)
> +static int dispc_get_num_mgrs(struct dispc_device *dispc)
>  {
> -	return dispc.feat->num_mgrs;
> +	return dispc->feat->num_mgrs;
>  }
>  
>  static void dispc_get_reg_field(enum dispc_feat_reg_field id,
> @@ -457,7 +457,7 @@ static void dispc_save_context(void)
>  		SR(CONFIG3);
>  	}
>  
> -	for (i = 0; i < dispc_get_num_mgrs(); i++) {
> +	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
>  		SR(DEFAULT_COLOR(i));
>  		SR(TRANS_COLOR(i));
>  		SR(SIZE_MGR(i));
> @@ -479,7 +479,7 @@ static void dispc_save_context(void)
>  		}
>  	}
>  
> -	for (i = 0; i < dispc_get_num_ovls(); i++) {
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
>  		SR(OVL_BA0(i));
>  		SR(OVL_BA1(i));
>  		SR(OVL_POSITION(i));
> @@ -563,7 +563,7 @@ static void dispc_restore_context(void)
>  	if (dispc_has_feature(FEAT_MGR_LCD3))
>  		RR(CONFIG3);
>  
> -	for (i = 0; i < dispc_get_num_mgrs(); i++) {
> +	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
>  		RR(DEFAULT_COLOR(i));
>  		RR(TRANS_COLOR(i));
>  		RR(SIZE_MGR(i));
> @@ -585,7 +585,7 @@ static void dispc_restore_context(void)
>  		}
>  	}
>  
> -	for (i = 0; i < dispc_get_num_ovls(); i++) {
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
>  		RR(OVL_BA0(i));
>  		RR(OVL_BA1(i));
>  		RR(OVL_POSITION(i));
> @@ -650,7 +650,7 @@ static void dispc_restore_context(void)
>  	if (dispc_has_feature(FEAT_MGR_LCD3))
>  		RR(CONTROL3);
>  	/* clear spurious SYNC_LOST_DIGIT interrupts */
> -	dispc_clear_irqstatus(DISPC_IRQ_SYNC_LOST_DIGIT);
> +	dispc_clear_irqstatus(&dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
>  
>  	/*
>  	 * enable last so IRQs won't trigger before
> @@ -664,41 +664,44 @@ static void dispc_restore_context(void)
>  #undef SR
>  #undef RR
>  
> -int dispc_runtime_get(void)
> +int dispc_runtime_get(struct dispc_device *dispc)
>  {
>  	int r;
>  
>  	DSSDBG("dispc_runtime_get\n");
>  
> -	r = pm_runtime_get_sync(&dispc.pdev->dev);
> +	r = pm_runtime_get_sync(&dispc->pdev->dev);
>  	WARN_ON(r < 0);
>  	return r < 0 ? r : 0;
>  }
>  
> -void dispc_runtime_put(void)
> +void dispc_runtime_put(struct dispc_device *dispc)
>  {
>  	int r;
>  
>  	DSSDBG("dispc_runtime_put\n");
>  
> -	r = pm_runtime_put_sync(&dispc.pdev->dev);
> +	r = pm_runtime_put_sync(&dispc->pdev->dev);
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> -static u32 dispc_mgr_get_vsync_irq(enum omap_channel channel)
> +static u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
> +				   enum omap_channel channel)
>  {
>  	return mgr_desc[channel].vsync_irq;
>  }
>  
> -static u32 dispc_mgr_get_framedone_irq(enum omap_channel channel)
> +static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
> +				       enum omap_channel channel)
>  {
> -	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc.feat->no_framedone_tv)
> +	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
>  		return 0;
>  
>  	return mgr_desc[channel].framedone_irq;
>  }
>  
> -static u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel)
> +static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
> +				       enum omap_channel channel)
>  {
>  	return mgr_desc[channel].sync_lost_irq;
>  }
> @@ -708,27 +711,30 @@ u32 dispc_wb_get_framedone_irq(void)
>  	return DISPC_IRQ_FRAMEDONEWB;
>  }
>  
> -static void dispc_mgr_enable(enum omap_channel channel, bool enable)
> +static void dispc_mgr_enable(struct dispc_device *dispc,
> +			     enum omap_channel channel, bool enable)
>  {
>  	mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable);
>  	/* flush posted write */
>  	mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
>  }
>  
> -static bool dispc_mgr_is_enabled(enum omap_channel channel)
> +static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
> +				 enum omap_channel channel)
>  {
>  	return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
>  }
>  
> -static bool dispc_mgr_go_busy(enum omap_channel channel)
> +static bool dispc_mgr_go_busy(struct dispc_device *dispc,
> +			      enum omap_channel channel)
>  {
>  	return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1;
>  }
>  
> -static void dispc_mgr_go(enum omap_channel channel)
> +static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
>  {
> -	WARN_ON(!dispc_mgr_is_enabled(channel));
> -	WARN_ON(dispc_mgr_go_busy(channel));
> +	WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
> +	WARN_ON(dispc_mgr_go_busy(dispc, channel));
>  
>  	DSSDBG("GO %s\n", mgr_desc[channel].name);
>  
> @@ -866,7 +872,7 @@ static void dispc_ovl_write_color_conv_coef(enum omap_plane_id plane,
>  static void dispc_setup_color_conv_coef(void)
>  {
>  	int i;
> -	int num_ovl = dispc_get_num_ovls();
> +	int num_ovl = dispc_get_num_ovls(&dispc);
>  	const struct color_conv_coef ctbl_bt601_5_ovl = {
>  		/* YUV -> RGB */
>  		298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
> @@ -958,7 +964,7 @@ static void dispc_ovl_enable_zorder_planes(void)
>  	if (!dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
>  		return;
>  
> -	for (i = 0; i < dispc_get_num_ovls(); i++)
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); i++)
>  		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
>  }
>  
> @@ -1215,7 +1221,7 @@ static void dispc_configure_burst_sizes(void)
>  	const int burst_size = BURST_SIZE_X8;
>  
>  	/* Configure burst size always to maximum size */
> -	for (i = 0; i < dispc_get_num_ovls(); ++i)
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
>  		dispc_ovl_set_burst_size(i, burst_size);
>  	if (dispc.feat->has_writeback)
>  		dispc_ovl_set_burst_size(OMAP_DSS_WB, burst_size);
> @@ -1242,9 +1248,10 @@ static bool dispc_ovl_color_mode_supported(enum omap_plane_id plane, u32 fourcc)
>  	return false;
>  }
>  
> -static const u32 *dispc_ovl_get_color_modes(enum omap_plane_id plane)
> +static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
> +					    enum omap_plane_id plane)
>  {
> -	return dispc.feat->supported_color_modes[plane];
> +	return dispc->feat->supported_color_modes[plane];
>  }
>  
>  static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable)
> @@ -1361,7 +1368,7 @@ static void dispc_init_fifos(void)
>  	/*
>  	 * Setup default fifo thresholds.
>  	 */
> -	for (i = 0; i < dispc_get_num_ovls(); ++i) {
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
>  		u32 low, high;
>  		const bool use_fifomerge = false;
>  		const bool manual_update = false;
> @@ -1464,7 +1471,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
>  
>  	if (use_fifomerge) {
>  		total_fifo_size = 0;
> -		for (i = 0; i < dispc_get_num_ovls(); ++i)
> +		for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
>  			total_fifo_size += dispc_ovl_get_fifo_size(i);
>  	} else {
>  		total_fifo_size = ovl_fifo_size;
> @@ -1530,7 +1537,7 @@ static void dispc_init_mflag(void)
>  		(1 << 0) |	/* MFLAG_CTRL = force always on */
>  		(0 << 2));	/* MFLAG_START = disable */
>  
> -	for (i = 0; i < dispc_get_num_ovls(); ++i) {
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
>  		u32 size = dispc_ovl_get_fifo_size(i);
>  		u32 unit = dispc.feat->buffer_size_unit;
>  		u32 low, high;
> @@ -2633,13 +2640,14 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
>  	return 0;
>  }
>  
> -static int dispc_ovl_setup(enum omap_plane_id plane,
> -		const struct omap_overlay_info *oi,
> -		const struct videomode *vm, bool mem_to_mem,
> -		enum omap_channel channel)
> +static int dispc_ovl_setup(struct dispc_device *dispc,
> +			   enum omap_plane_id plane,
> +			   const struct omap_overlay_info *oi,
> +			   const struct videomode *vm, bool mem_to_mem,
> +			   enum omap_channel channel)
>  {
>  	int r;
> -	enum omap_overlay_caps caps = dispc.feat->overlay_caps[plane];
> +	enum omap_overlay_caps caps = dispc->feat->overlay_caps[plane];
>  	const bool replication = true;
>  
>  	DSSDBG("dispc_ovl_setup %d, pa %pad, pa_uv %pad, sw %d, %d,%d, %dx%d ->"
> @@ -2726,7 +2734,8 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
>  	return r;
>  }
>  
> -static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
> +static int dispc_ovl_enable(struct dispc_device *dispc,
> +			    enum omap_plane_id plane, bool enable)
>  {
>  	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
>  
> @@ -2735,9 +2744,11 @@ static int dispc_ovl_enable(enum omap_plane_id plane, bool enable)
>  	return 0;
>  }
>  
> -static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel)
> +static enum omap_dss_output_id
> +dispc_mgr_get_supported_outputs(struct dispc_device *dispc,
> +				enum omap_channel channel)
>  {
> -	return dss_get_supported_outputs(dispc.dss, channel);
> +	return dss_get_supported_outputs(dispc->dss, channel);
>  }
>  
>  static void dispc_lcd_enable_signal_polarity(bool act_high)
> @@ -2812,8 +2823,9 @@ static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch,
>  		REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
>  }
>  
> -static void dispc_mgr_setup(enum omap_channel channel,
> -		const struct omap_overlay_manager_info *info)
> +static void dispc_mgr_setup(struct dispc_device *dispc,
> +			    enum omap_channel channel,
> +			    const struct omap_overlay_manager_info *info)
>  {
>  	dispc_mgr_set_default_color(channel, info->default_color);
>  	dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key);
> @@ -2885,8 +2897,9 @@ static void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable)
>  	mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable);
>  }
>  
> -static void dispc_mgr_set_lcd_config(enum omap_channel channel,
> -		const struct dss_lcd_mgr_config *config)
> +static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
> +				     enum omap_channel channel,
> +				     const struct dss_lcd_mgr_config *config)
>  {
>  	dispc_mgr_set_io_pad_mode(config->io_pad_mode);
>  
> @@ -3041,8 +3054,9 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
>  }
>  
>  /* change name to mode? */
> -static void dispc_mgr_set_timings(enum omap_channel channel,
> -			   const struct videomode *vm)
> +static void dispc_mgr_set_timings(struct dispc_device *dispc,
> +				  enum omap_channel channel,
> +				  const struct videomode *vm)
>  {
>  	unsigned int xtot, ytot;
>  	unsigned long ht, vt;
> @@ -3080,7 +3094,7 @@ static void dispc_mgr_set_timings(enum omap_channel channel,
>  		if (t.flags & DISPLAY_FLAGS_INTERLACED)
>  			t.vactive /= 2;
>  
> -		if (dispc.feat->supports_double_pixel)
> +		if (dispc->feat->supports_double_pixel)
>  			REG_FLD_MOD(DISPC_CONTROL,
>  				    !!(t.flags & DISPLAY_FLAGS_DOUBLECLK),
>  				    19, 17);
> @@ -3243,7 +3257,7 @@ void dispc_dump_clocks(struct seq_file *s)
>  	u32 l;
>  	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
>  
> -	if (dispc_runtime_get())
> +	if (dispc_runtime_get(&dispc))
>  		return;
>  
>  	seq_printf(s, "- DISPC -\n");
> @@ -3269,7 +3283,7 @@ void dispc_dump_clocks(struct seq_file *s)
>  	if (dispc_has_feature(FEAT_MGR_LCD3))
>  		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(&dispc);
>  }
>  
>  static int dispc_dump_regs(struct seq_file *s, void *p)
> @@ -3292,7 +3306,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  
>  #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
>  
> -	if (dispc_runtime_get())
> +	if (dispc_runtime_get(&dispc))
>  		return 0;
>  
>  	/* DISPC common registers */
> @@ -3330,7 +3344,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  	p_names = mgr_names;
>  
>  	/* DISPC channel specific registers */
> -	for (i = 0; i < dispc_get_num_mgrs(); i++) {
> +	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
>  		DUMPREG(i, DISPC_DEFAULT_COLOR);
>  		DUMPREG(i, DISPC_TRANS_COLOR);
>  		DUMPREG(i, DISPC_SIZE_MGR);
> @@ -3356,7 +3370,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  
>  	p_names = ovl_names;
>  
> -	for (i = 0; i < dispc_get_num_ovls(); i++) {
> +	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
>  		DUMPREG(i, DISPC_OVL_BA0);
>  		DUMPREG(i, DISPC_OVL_BA1);
>  		DUMPREG(i, DISPC_OVL_POSITION);
> @@ -3434,7 +3448,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  	/* Video pipeline coefficient registers */
>  
>  	/* start from OMAP_DSS_VIDEO1 */
> -	for (i = 1; i < dispc_get_num_ovls(); i++) {
> +	for (i = 1; i < dispc_get_num_ovls(&dispc); i++) {
>  		for (j = 0; j < 8; j++)
>  			DUMPREG(i, DISPC_OVL_FIR_COEF_H, j);
>  
> @@ -3461,7 +3475,7 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  		}
>  	}
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(&dispc);
>  
>  #undef DISPC_REG
>  #undef DUMPREG
> @@ -3569,22 +3583,22 @@ int dispc_mgr_get_clock_div(enum omap_channel channel,
>  	return 0;
>  }
>  
> -static u32 dispc_read_irqstatus(void)
> +static u32 dispc_read_irqstatus(struct dispc_device *dispc)
>  {
>  	return dispc_read_reg(DISPC_IRQSTATUS);
>  }
>  
> -static void dispc_clear_irqstatus(u32 mask)
> +static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
>  {
>  	dispc_write_reg(DISPC_IRQSTATUS, mask);
>  }
>  
> -static void dispc_write_irqenable(u32 mask)
> +static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
>  {
>  	u32 old_mask = dispc_read_reg(DISPC_IRQENABLE);
>  
>  	/* clear the irqstatus for newly enabled irqs */
> -	dispc_clear_irqstatus((mask ^ old_mask) & mask);
> +	dispc_clear_irqstatus(dispc, (mask ^ old_mask) & mask);
>  
>  	dispc_write_reg(DISPC_IRQENABLE, mask);
>  
> @@ -3602,11 +3616,12 @@ void dispc_disable_sidle(void)
>  	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
>  }
>  
> -static u32 dispc_mgr_gamma_size(enum omap_channel channel)
> +static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
> +				enum omap_channel channel)
>  {
>  	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
>  
> -	if (!dispc.feat->has_gamma_table)
> +	if (!dispc->feat->has_gamma_table)
>  		return 0;
>  
>  	return gdesc->len;
> @@ -3655,18 +3670,19 @@ static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
>  	{ .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, },
>  };
>  
> -static void dispc_mgr_set_gamma(enum omap_channel channel,
> -			 const struct drm_color_lut *lut,
> -			 unsigned int length)
> +static void dispc_mgr_set_gamma(struct dispc_device *dispc,
> +				enum omap_channel channel,
> +				const struct drm_color_lut *lut,
> +				unsigned int length)
>  {
>  	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
> -	u32 *table = dispc.gamma_table[channel];
> +	u32 *table = dispc->gamma_table[channel];
>  	uint i;
>  
>  	DSSDBG("%s: channel %d, lut len %u, hw len %u\n", __func__,
>  	       channel, length, gdesc->len);
>  
> -	if (!dispc.feat->has_gamma_table)
> +	if (!dispc->feat->has_gamma_table)
>  		return;
>  
>  	if (lut == NULL || length < 2) {
> @@ -3698,7 +3714,7 @@ static void dispc_mgr_set_gamma(enum omap_channel channel,
>  		}
>  	}
>  
> -	if (dispc.is_enabled)
> +	if (dispc->is_enabled)
>  		dispc_mgr_write_gamma_table(channel);
>  }
>  
> @@ -3728,7 +3744,7 @@ static int dispc_init_gamma_tables(void)
>  
>  		dispc.gamma_table[channel] = gt;
>  
> -		dispc_mgr_set_gamma(channel, NULL, 0);
> +		dispc_mgr_set_gamma(&dispc, channel, NULL, 0);
>  	}
>  	return 0;
>  }
> @@ -4298,35 +4314,36 @@ static irqreturn_t dispc_irq_handler(int irq, void *arg)
>  	return dispc.user_handler(irq, dispc.user_data);
>  }
>  
> -static int dispc_request_irq(irq_handler_t handler, void *dev_id)
> +static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
> +			     void *dev_id)
>  {
>  	int r;
>  
> -	if (dispc.user_handler != NULL)
> +	if (dispc->user_handler != NULL)
>  		return -EBUSY;
>  
> -	dispc.user_handler = handler;
> -	dispc.user_data = dev_id;
> +	dispc->user_handler = handler;
> +	dispc->user_data = dev_id;
>  
>  	/* ensure the dispc_irq_handler sees the values above */
>  	smp_wmb();
>  
> -	r = devm_request_irq(&dispc.pdev->dev, dispc.irq, dispc_irq_handler,
> -			     IRQF_SHARED, "OMAP DISPC", &dispc);
> +	r = devm_request_irq(&dispc->pdev->dev, dispc->irq, dispc_irq_handler,
> +			     IRQF_SHARED, "OMAP DISPC", dispc);
>  	if (r) {
> -		dispc.user_handler = NULL;
> -		dispc.user_data = NULL;
> +		dispc->user_handler = NULL;
> +		dispc->user_data = NULL;
>  	}
>  
>  	return r;
>  }
>  
> -static void dispc_free_irq(void *dev_id)
> +static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
>  {
> -	devm_free_irq(&dispc.pdev->dev, dispc.irq, &dispc);
> +	devm_free_irq(&dispc->pdev->dev, dispc->irq, dispc);
>  
> -	dispc.user_handler = NULL;
> -	dispc.user_data = NULL;
> +	dispc->user_handler = NULL;
> +	dispc->user_data = NULL;
>  }
>  
>  /*
> @@ -4430,7 +4447,8 @@ static void dispc_errata_i734_wa_fini(void)
>  
>  static void dispc_errata_i734_wa(void)
>  {
> -	u32 framedone_irq = dispc_mgr_get_framedone_irq(OMAP_DSS_CHANNEL_LCD);
> +	u32 framedone_irq = dispc_mgr_get_framedone_irq(&dispc,
> +							OMAP_DSS_CHANNEL_LCD);
>  	struct omap_overlay_info ovli;
>  	struct dss_lcd_mgr_config lcd_conf;
>  	u32 gatestate;
> @@ -4449,39 +4467,39 @@ static void dispc_errata_i734_wa(void)
>  	REG_FLD_MOD(DISPC_CONFIG, 0x1f, 8, 4);
>  
>  	/* Setup and enable GFX plane */
> -	dispc_ovl_setup(OMAP_DSS_GFX, &ovli, &i734.vm, false,
> -		OMAP_DSS_CHANNEL_LCD);
> -	dispc_ovl_enable(OMAP_DSS_GFX, true);
> +	dispc_ovl_setup(&dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
> +			OMAP_DSS_CHANNEL_LCD);
> +	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, true);
>  
>  	/* Set up and enable display manager for LCD1 */
> -	dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, &i734.mgri);
> +	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
>  	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
>  			       &lcd_conf.clock_info);
> -	dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, &lcd_conf);
> -	dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, &i734.vm);
> +	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
> +	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
>  
> -	dispc_clear_irqstatus(framedone_irq);
> +	dispc_clear_irqstatus(&dispc, framedone_irq);
>  
>  	/* Enable and shut the channel to produce just one frame */
> -	dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, true);
> -	dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, false);
> +	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, true);
> +	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, false);
>  
>  	/* Busy wait for framedone. We can't fiddle with irq handlers
>  	 * in PM resume. Typically the loop runs less than 5 times and
>  	 * waits less than a micro second.
>  	 */
>  	count = 0;
> -	while (!(dispc_read_irqstatus() & framedone_irq)) {
> +	while (!(dispc_read_irqstatus(&dispc) & framedone_irq)) {
>  		if (count++ > 10000) {
>  			dev_err(&dispc.pdev->dev, "%s: framedone timeout\n",
>  				__func__);
>  			break;
>  		}
>  	}
> -	dispc_ovl_enable(OMAP_DSS_GFX, false);
> +	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, false);
>  
>  	/* Clear all irq bits before continuing */
> -	dispc_clear_irqstatus(0xffffffff);
> +	dispc_clear_irqstatus(&dispc, 0xffffffff);
>  
>  	/* Restore the original state to LCD1 output gates */
>  	REG_FLD_MOD(DISPC_CONFIG, gatestate, 8, 4);
> @@ -4599,7 +4617,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(&dispc);
>  	if (r)
>  		goto err_runtime_get;
>  
> @@ -4609,9 +4627,10 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
>  	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(&dispc);
>  
>  	dispc_set_ops(&dispc_ops);
> +	dss->dispc = &dispc;
>  
>  	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
>  						&dispc);
> @@ -4623,12 +4642,14 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	return r;
>  }
>  
> -static void dispc_unbind(struct device *dev, struct device *master,
> -			       void *data)
> +static void dispc_unbind(struct device *dev, struct device *master, void *data)
>  {
> +	struct dss_device *dss = dispc.dss;
> +
>  	dss_debugfs_remove_file(dispc.debugfs);
>  
>  	dispc_set_ops(NULL);
> +	dss->dispc = NULL;
>  
>  	pm_runtime_disable(dev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index ae43ba81eb96..aa10db453fd0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -407,7 +407,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  			goto err_reg_enable;
>  	}
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(dpi->dss->dispc);
>  	if (r)
>  		goto err_get_dispc;
>  
> @@ -443,7 +443,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
>  		dss_pll_disable(dpi->pll);
>  err_pll_init:
>  err_src_sel:
> -	dispc_runtime_put();
> +	dispc_runtime_put(dpi->dss->dispc);
>  err_get_dispc:
>  	if (dpi->vdds_dsi_reg)
>  		regulator_disable(dpi->vdds_dsi_reg);
> @@ -467,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
>  		dss_pll_disable(dpi->pll);
>  	}
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(dpi->dss->dispc);
>  
>  	if (dpi->vdds_dsi_reg)
>  		regulator_disable(dpi->vdds_dsi_reg);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index eafea72998dd..1cac221e499a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5529,7 +5529,7 @@ static int dsi_runtime_suspend(struct device *dev)
>  	/* wait for current handler to finish before turning the DSI off */
>  	synchronize_irq(dsi->irq);
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(dsi->dss->dispc);
>  
>  	return 0;
>  }
> @@ -5539,7 +5539,7 @@ static int dsi_runtime_resume(struct device *dev)
>  	struct dsi_data *dsi = dev_get_drvdata(dev);
>  	int r;
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(dsi->dss->dispc);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 0e8c70591308..fcdd7d00caa8 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -887,6 +887,11 @@ struct dss_device *dss_get_device(struct device *dev)
>  	return dev_get_drvdata(dev);
>  }
>  
> +struct dispc_device *dss_get_dispc(struct dss_device *dss)
> +{
> +	return dss->dispc;
> +}
> +
>  /* DEBUGFS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
>  static int dss_debug_dump_clocks(struct seq_file *s, void *p)
> @@ -1385,7 +1390,7 @@ static int dss_bind(struct device *dev)
>  
>  	omapdss_gather_components(dev);
>  
> -	r = omapdrm_init(&dss->drm, dev);
> +	r = omapdrm_init(dss, &dss->drm, dev);
>  	if (r)
>  		goto err_drm_init;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index cda2cbd888f0..5f3e26bec402 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -29,6 +29,7 @@
>  #include "../omap_drv.h"
>  
>  struct dentry;
> +struct dispc_device;
>  struct dss_debugfs_entry;
>  struct dss_device;
>  struct platform_device;
> @@ -276,6 +277,8 @@ struct dss_device {
>  
>  	struct dss_pll	*video1_pll;
>  	struct dss_pll	*video2_pll;
> +
> +	struct dispc_device *dispc;
>  };
>  
>  /* core */
> @@ -416,8 +419,8 @@ int dispc_init_platform_driver(void) __init;
>  void dispc_uninit_platform_driver(void);
>  void dispc_dump_clocks(struct seq_file *s);
>  
> -int dispc_runtime_get(void);
> -void dispc_runtime_put(void);
> +int dispc_runtime_get(struct dispc_device *dispc);
> +void dispc_runtime_put(struct dispc_device *dispc);
>  
>  void dispc_enable_sidle(void);
>  void dispc_disable_sidle(void);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 501813f03466..cf4b2c9bbcbd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -847,16 +847,19 @@ static int hdmi4_remove(struct platform_device *pdev)
>  
>  static int hdmi_runtime_suspend(struct device *dev)
>  {
> -	dispc_runtime_put();
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
> +
> +	dispc_runtime_put(hdmi->dss->dispc);
>  
>  	return 0;
>  }
>  
>  static int hdmi_runtime_resume(struct device *dev)
>  {
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
>  	int r;
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(hdmi->dss->dispc);
>  	if (r < 0)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 44954bdea6ce..66b603c5b2fc 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -839,16 +839,19 @@ static int hdmi5_remove(struct platform_device *pdev)
>  
>  static int hdmi_runtime_suspend(struct device *dev)
>  {
> -	dispc_runtime_put();
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
> +
> +	dispc_runtime_put(hdmi->dss->dispc);
>  
>  	return 0;
>  }
>  
>  static int hdmi_runtime_resume(struct device *dev)
>  {
> +	struct omap_hdmi *hdmi = dev_get_drvdata(dev);
>  	int r;
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(hdmi->dss->dispc);
>  	if (r < 0)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 76ce94376454..9ebd695de075 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -61,6 +61,8 @@
>  
>  struct omap_drm_private;
>  struct omap_dss_device;
> +struct dispc_device;
> +struct dss_device;
>  struct dss_lcd_mgr_config;
>  struct snd_aes_iec958;
>  struct snd_cea_861_aud_if;
> @@ -683,49 +685,64 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  /* dispc ops */
>  
>  struct dispc_ops {
> -	u32 (*read_irqstatus)(void);
> -	void (*clear_irqstatus)(u32 mask);
> -	void (*write_irqenable)(u32 mask);
> -
> -	int (*request_irq)(irq_handler_t handler, void *dev_id);
> -	void (*free_irq)(void *dev_id);
> -
> -	int (*runtime_get)(void);
> -	void (*runtime_put)(void);
> -
> -	int (*get_num_ovls)(void);
> -	int (*get_num_mgrs)(void);
> -
> -	void (*mgr_enable)(enum omap_channel channel, bool enable);
> -	bool (*mgr_is_enabled)(enum omap_channel channel);
> -	u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
> -	u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
> -	u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
> -	bool (*mgr_go_busy)(enum omap_channel channel);
> -	void (*mgr_go)(enum omap_channel channel);
> -	void (*mgr_set_lcd_config)(enum omap_channel channel,
> -			const struct dss_lcd_mgr_config *config);
> -	void (*mgr_set_timings)(enum omap_channel channel,
> -			const struct videomode *vm);
> -	void (*mgr_setup)(enum omap_channel channel,
> -			const struct omap_overlay_manager_info *info);
> -	enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
> -	u32 (*mgr_gamma_size)(enum omap_channel channel);
> -	void (*mgr_set_gamma)(enum omap_channel channel,
> -		const struct drm_color_lut *lut,
> -		unsigned int length);
> -
> -	int (*ovl_enable)(enum omap_plane_id plane, bool enable);
> -	int (*ovl_setup)(enum omap_plane_id plane,
> +	u32 (*read_irqstatus)(struct dispc_device *dispc);
> +	void (*clear_irqstatus)(struct dispc_device *dispc, u32 mask);
> +	void (*write_irqenable)(struct dispc_device *dispc, u32 mask);
> +
> +	int (*request_irq)(struct dispc_device *dispc, irq_handler_t handler,
> +			   void *dev_id);
> +	void (*free_irq)(struct dispc_device *dispc, void *dev_id);
> +
> +	int (*runtime_get)(struct dispc_device *dispc);
> +	void (*runtime_put)(struct dispc_device *dispc);
> +
> +	int (*get_num_ovls)(struct dispc_device *dispc);
> +	int (*get_num_mgrs)(struct dispc_device *dispc);
> +
> +	void (*mgr_enable)(struct dispc_device *dispc,
> +			   enum omap_channel channel, bool enable);
> +	bool (*mgr_is_enabled)(struct dispc_device *dispc,
> +			       enum omap_channel channel);
> +	u32 (*mgr_get_vsync_irq)(struct dispc_device *dispc,
> +				 enum omap_channel channel);
> +	u32 (*mgr_get_framedone_irq)(struct dispc_device *dispc,
> +				     enum omap_channel channel);
> +	u32 (*mgr_get_sync_lost_irq)(struct dispc_device *dispc,
> +				     enum omap_channel channel);
> +	bool (*mgr_go_busy)(struct dispc_device *dispc,
> +			    enum omap_channel channel);
> +	void (*mgr_go)(struct dispc_device *dispc, enum omap_channel channel);
> +	void (*mgr_set_lcd_config)(struct dispc_device *dispc,
> +				   enum omap_channel channel,
> +				   const struct dss_lcd_mgr_config *config);
> +	void (*mgr_set_timings)(struct dispc_device *dispc,
> +				enum omap_channel channel,
> +				const struct videomode *vm);
> +	void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
> +			  const struct omap_overlay_manager_info *info);
> +	enum omap_dss_output_id (*mgr_get_supported_outputs)(
> +			struct dispc_device *dispc, enum omap_channel channel);
> +	u32 (*mgr_gamma_size)(struct dispc_device *dispc,
> +			      enum omap_channel channel);
> +	void (*mgr_set_gamma)(struct dispc_device *dispc,
> +			      enum omap_channel channel,
> +			      const struct drm_color_lut *lut,
> +			      unsigned int length);
> +
> +	int (*ovl_enable)(struct dispc_device *dispc, enum omap_plane_id plane,
> +			  bool enable);
> +	int (*ovl_setup)(struct dispc_device *dispc, enum omap_plane_id plane,
>  			 const struct omap_overlay_info *oi,
> -			const struct videomode *vm, bool mem_to_mem,
> -			enum omap_channel channel);
> +			 const struct videomode *vm, bool mem_to_mem,
> +			 enum omap_channel channel);
>  
> -	const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane);
> +	const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
> +					  enum omap_plane_id plane);
>  };
>  
>  void dispc_set_ops(const struct dispc_ops *o);
>  const struct dispc_ops *dispc_get_ops(void);
> +struct dispc_device *dss_get_dispc(struct dss_device *dss);
>  
>  bool omapdss_component_is_display(struct device_node *node);
>  bool omapdss_component_is_output(struct device_node *node);
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index c41bf0d7dd18..efa73cfabce6 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -144,7 +144,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	if (r)
>  		goto err_reg_enable;
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(sdi->dss->dispc);
>  	if (r)
>  		goto err_get_dispc;
>  
> @@ -206,7 +206,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  err_sdi_enable:
>  err_set_dss_clock_div:
>  err_calc_clock_div:
> -	dispc_runtime_put();
> +	dispc_runtime_put(sdi->dss->dispc);
>  err_get_dispc:
>  	regulator_disable(sdi->vdds_sdi_reg);
>  err_reg_enable:
> @@ -221,7 +221,7 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
>  
>  	dss_sdi_disable(sdi->dss);
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(sdi->dss->dispc);
>  
>  	regulator_disable(sdi->vdds_sdi_reg);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index f120d2910d0d..13ed7426ea09 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -990,7 +990,7 @@ static int venc_runtime_suspend(struct device *dev)
>  	if (venc->tv_dac_clk)
>  		clk_disable_unprepare(venc->tv_dac_clk);
>  
> -	dispc_runtime_put();
> +	dispc_runtime_put(venc->dss->dispc);
>  
>  	return 0;
>  }
> @@ -1000,7 +1000,7 @@ static int venc_runtime_resume(struct device *dev)
>  	struct venc_device *venc = dev_get_drvdata(dev);
>  	int r;
>  
> -	r = dispc_runtime_get();
> +	r = dispc_runtime_get(venc->dss->dispc);
>  	if (r < 0)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index 90a61a8199b4..494d10cd3233 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -118,12 +118,13 @@ static int omap_crtc_dss_connect(struct omap_drm_private *priv,
>  		enum omap_channel channel,
>  		struct omap_dss_device *dst)
>  {
> -	const struct dispc_ops *dispc_ops = dispc_get_ops();
> +	const struct dispc_ops *dispc_ops = priv->dispc_ops;
> +	struct dispc_device *dispc = priv->dispc;
>  
>  	if (omap_crtc_output[channel])
>  		return -EINVAL;
>  
> -	if ((dispc_ops->mgr_get_supported_outputs(channel) & dst->id) == 0)
> +	if (!(dispc_ops->mgr_get_supported_outputs(dispc, channel) & dst->id))
>  		return -EINVAL;
>  
>  	omap_crtc_output[channel] = dst;
> @@ -160,7 +161,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  		return;
>  
>  	if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
> -		priv->dispc_ops->mgr_enable(channel, enable);
> +		priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
>  		omap_crtc->enabled = enable;
>  		return;
>  	}
> @@ -173,8 +174,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  		omap_crtc->ignore_digit_sync_lost = true;
>  	}
>  
> -	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(channel);
> -	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(channel);
> +	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(priv->dispc,
> +							       channel);
> +	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel);
>  
>  	if (enable) {
>  		wait = omap_irq_wait_init(dev, vsync_irq, 1);
> @@ -194,7 +196,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  			wait = omap_irq_wait_init(dev, vsync_irq, 2);
>  	}
>  
> -	priv->dispc_ops->mgr_enable(channel, enable);
> +	priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
>  	omap_crtc->enabled = enable;
>  
>  	ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
> @@ -216,7 +218,8 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
>  {
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
>  
> -	priv->dispc_ops->mgr_set_timings(omap_crtc->channel, &omap_crtc->vm);
> +	priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
> +					 &omap_crtc->vm);
>  	omap_crtc_set_enabled(&omap_crtc->base, true);
>  
>  	return 0;
> @@ -246,7 +249,8 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
>  	struct omap_crtc *omap_crtc = omap_crtcs[channel];
>  
>  	DBG("%s", omap_crtc->name);
> -	priv->dispc_ops->mgr_set_lcd_config(omap_crtc->channel, config);
> +	priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
> +					    config);
>  }
>  
>  static int omap_crtc_dss_register_framedone(
> @@ -303,7 +307,7 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
>  	 * If the dispc is busy we're racing the flush operation. Try again on
>  	 * the next vblank interrupt.
>  	 */
> -	if (priv->dispc_ops->mgr_go_busy(omap_crtc->channel)) {
> +	if (priv->dispc_ops->mgr_go_busy(priv->dispc, omap_crtc->channel)) {
>  		spin_unlock(&crtc->dev->event_lock);
>  		return;
>  	}
> @@ -340,7 +344,7 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
>  	info.partial_alpha_enabled = false;
>  	info.cpr_enable = false;
>  
> -	priv->dispc_ops->mgr_setup(omap_crtc->channel, &info);
> +	priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
>  }
>  
>  /* -----------------------------------------------------------------------------
> @@ -505,7 +509,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  			length = crtc->state->gamma_lut->length /
>  				sizeof(*lut);
>  		}
> -		priv->dispc_ops->mgr_set_gamma(omap_crtc->channel, lut, length);
> +		priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
> +					       lut, length);
>  	}
>  
>  	omap_crtc_write_crtc_properties(crtc);
> @@ -520,7 +525,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  	WARN_ON(ret != 0);
>  
>  	spin_lock_irq(&crtc->dev->event_lock);
> -	priv->dispc_ops->mgr_go(omap_crtc->channel);
> +	priv->dispc_ops->mgr_go(priv->dispc, omap_crtc->channel);
>  	omap_crtc_arm_event(crtc);
>  	spin_unlock_irq(&crtc->dev->event_lock);
>  }
> @@ -701,7 +706,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  	 * extracted with dispc_mgr_gamma_size(). If it returns 0
>  	 * gamma table is not supprted.
>  	 */
> -	if (priv->dispc_ops->mgr_gamma_size(channel)) {
> +	if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
>  		unsigned int gamma_lut_size = 256;
>  
>  		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index baf8e32b899b..36b2d89f60db 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -79,7 +79,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
>  	struct drm_device *dev = old_state->dev;
>  	struct omap_drm_private *priv = dev->dev_private;
>  
> -	priv->dispc_ops->runtime_get();
> +	priv->dispc_ops->runtime_get(priv->dispc);
>  
>  	/* Apply the atomic update. */
>  	drm_atomic_helper_commit_modeset_disables(dev, old_state);
> @@ -123,7 +123,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
>  
>  	drm_atomic_helper_cleanup_planes(dev, old_state);
>  
> -	priv->dispc_ops->runtime_put();
> +	priv->dispc_ops->runtime_put(priv->dispc);
>  }
>  
>  static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = {
> @@ -201,7 +201,7 @@ static int omap_connect_dssdevs(void)
>  static int omap_modeset_init_properties(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_planes = priv->dispc_ops->get_num_ovls();
> +	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
>  
>  	priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
>  						      num_planes - 1);
> @@ -215,8 +215,8 @@ static int omap_modeset_init(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
>  	struct omap_dss_device *dssdev = NULL;
> -	int num_ovls = priv->dispc_ops->get_num_ovls();
> -	int num_mgrs = priv->dispc_ops->get_num_mgrs();
> +	int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
> +	int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
>  	int num_crtcs, crtc_idx, plane_idx;
>  	int ret;
>  	u32 plane_crtc_mask;
> @@ -542,7 +542,8 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
>  	{ /* sentinel */ }
>  };
>  
> -int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
> +int omapdrm_init(struct dss_device *dss, struct omap_drm_private *priv,
> +		 struct device *dev)
>  {
>  	const struct soc_device_attribute *soc;
>  	struct drm_device *ddev;
> @@ -553,14 +554,15 @@ int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  
>  	priv->dev = dev;
>  
> +	priv->dispc = dss_get_dispc(dss);
> +	priv->dispc_ops = dispc_get_ops();
> +
>  	omap_crtc_pre_init();
>  
>  	ret = omap_connect_dssdevs();
>  	if (ret)
>  		goto err_crtc_uninit;
>  
> -	priv->dispc_ops = dispc_get_ops();
> -
>  	soc = soc_device_match(omapdrm_soc_devices);
>  	priv->omaprev = soc ? (unsigned int)soc->data : 0;
>  	priv->wq = alloc_ordered_workqueue("omapdrm", 0);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index e10b9105379a..3ccc1b289201 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -45,6 +45,7 @@
>  
>  #define MODULE_NAME     "omapdrm"
>  
> +struct dss_device;
>  struct omap_drm_usergart;
>  
>  struct omap_drm_private {
> @@ -52,6 +53,7 @@ struct omap_drm_private {
>  	struct device *dev;
>  	u32 omaprev;
>  
> +	struct dispc_device *dispc;
>  	const struct dispc_ops *dispc_ops;
>  
>  	unsigned int num_crtcs;
> @@ -88,7 +90,8 @@ struct omap_drm_private {
>  	u32 irq_mask;			/* enabled irqs in addition to wait_list */
>  };
>  
> -int omapdrm_init(struct omap_drm_private *priv, struct device *dev);
> +int omapdrm_init(struct dss_device *dss, struct omap_drm_private *priv,
> +		 struct device *dev);
>  void omapdrm_cleanup(struct omap_drm_private *priv);
>  int omap_drm_suspend(struct omap_drm_private *priv);
>  int omap_drm_resume(struct omap_drm_private *priv);
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
> index ef5132237100..dd2180b641e0 100644
> --- a/drivers/gpu/drm/omapdrm/omap_irq.c
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.c
> @@ -40,7 +40,7 @@ static void omap_irq_update(struct drm_device *dev)
>  
>  	DBG("irqmask=%08x", irqmask);
>  
> -	priv->dispc_ops->write_irqenable(irqmask);
> +	priv->dispc_ops->write_irqenable(priv->dispc, irqmask);
>  }
>  
>  static void omap_irq_wait_handler(struct omap_irq_wait *wait)
> @@ -110,7 +110,8 @@ int omap_irq_enable_vblank(struct drm_crtc *crtc)
>  	DBG("dev=%p, crtc=%u", dev, channel);
>  
>  	spin_lock_irqsave(&priv->wait_lock, flags);
> -	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(channel);
> +	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
> +							     channel);
>  	omap_irq_update(dev);
>  	spin_unlock_irqrestore(&priv->wait_lock, flags);
>  
> @@ -136,7 +137,8 @@ void omap_irq_disable_vblank(struct drm_crtc *crtc)
>  	DBG("dev=%p, crtc=%u", dev, channel);
>  
>  	spin_lock_irqsave(&priv->wait_lock, flags);
> -	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(channel);
> +	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
> +							      channel);
>  	omap_irq_update(dev);
>  	spin_unlock_irqrestore(&priv->wait_lock, flags);
>  }
> @@ -200,9 +202,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
>  	unsigned int id;
>  	u32 irqstatus;
>  
> -	irqstatus = priv->dispc_ops->read_irqstatus();
> -	priv->dispc_ops->clear_irqstatus(irqstatus);
> -	priv->dispc_ops->read_irqstatus();        /* flush posted write */
> +	irqstatus = priv->dispc_ops->read_irqstatus(priv->dispc);
> +	priv->dispc_ops->clear_irqstatus(priv->dispc, irqstatus);
> +	priv->dispc_ops->read_irqstatus(priv->dispc);	/* flush posted write */
>  
>  	VERB("irqs: %08x", irqstatus);
>  
> @@ -210,12 +212,12 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
>  		struct drm_crtc *crtc = priv->crtcs[id];
>  		enum omap_channel channel = omap_crtc_channel(crtc);
>  
> -		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(channel)) {
> +		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel)) {
>  			drm_handle_vblank(dev, id);
>  			omap_crtc_vblank_irq(crtc);
>  		}
>  
> -		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(channel))
> +		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, channel))
>  			omap_crtc_error_irq(crtc, irqstatus);
>  	}
>  
> @@ -249,7 +251,7 @@ static const u32 omap_underflow_irqs[] = {
>  int omap_drm_irq_install(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs();
> +	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
>  	unsigned int max_planes;
>  	unsigned int i;
>  	int ret;
> @@ -267,13 +269,13 @@ int omap_drm_irq_install(struct drm_device *dev)
>  	}
>  
>  	for (i = 0; i < num_mgrs; ++i)
> -		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(i);
> +		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, i);
>  
> -	priv->dispc_ops->runtime_get();
> -	priv->dispc_ops->clear_irqstatus(0xffffffff);
> -	priv->dispc_ops->runtime_put();
> +	priv->dispc_ops->runtime_get(priv->dispc);
> +	priv->dispc_ops->clear_irqstatus(priv->dispc, 0xffffffff);
> +	priv->dispc_ops->runtime_put(priv->dispc);
>  
> -	ret = priv->dispc_ops->request_irq(omap_irq_handler, dev);
> +	ret = priv->dispc_ops->request_irq(priv->dispc, omap_irq_handler, dev);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -291,5 +293,5 @@ void omap_drm_irq_uninstall(struct drm_device *dev)
>  
>  	dev->irq_enabled = false;
>  
> -	priv->dispc_ops->free_irq(dev);
> +	priv->dispc_ops->free_irq(priv->dispc, dev);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 903e0fa5442a..26b32b04c17b 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -79,17 +79,17 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
>  			&info.paddr, &info.p_uv_addr);
>  
>  	/* and finally, update omapdss: */
> -	ret = priv->dispc_ops->ovl_setup(omap_plane->id, &info,
> +	ret = priv->dispc_ops->ovl_setup(priv->dispc, omap_plane->id, &info,
>  			      omap_crtc_timings(state->crtc), false,
>  			      omap_crtc_channel(state->crtc));
>  	if (ret) {
>  		dev_err(plane->dev->dev, "Failed to setup plane %s\n",
>  			omap_plane->name);
> -		priv->dispc_ops->ovl_enable(omap_plane->id, false);
> +		priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
>  		return;
>  	}
>  
> -	priv->dispc_ops->ovl_enable(omap_plane->id, true);
> +	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, true);
>  }
>  
>  static void omap_plane_atomic_disable(struct drm_plane *plane,
> @@ -102,7 +102,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
>  	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
>  			   ? 0 : omap_plane->id;
>  
> -	priv->dispc_ops->ovl_enable(omap_plane->id, false);
> +	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
>  }
>  
>  static int omap_plane_atomic_check(struct drm_plane *plane,
> @@ -261,7 +261,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  		u32 possible_crtcs)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_planes = priv->dispc_ops->get_num_ovls();
> +	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
>  	struct drm_plane *plane;
>  	struct omap_plane *omap_plane;
>  	enum omap_plane_id id;
> @@ -280,7 +280,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  	if (!omap_plane)
>  		return ERR_PTR(-ENOMEM);
>  
> -	formats = priv->dispc_ops->ovl_get_color_modes(id);
> +	formats = priv->dispc_ops->ovl_get_color_modes(priv->dispc, id);
>  	for (nformats = 0; formats[nformats]; ++nformats)
>  		;
>  	omap_plane->id = id;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions
  2017-10-13 14:59 ` [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
@ 2017-10-17 21:24   ` Sebastian Reichel
  2017-10-17 21:44     ` Laurent Pinchart
  0 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 21:24 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 27734 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:41PM +0300, Laurent Pinchart wrote:
> This removes the need to access the global DISPC private data in those
> functions (both for the current accesses and the future ones that will
> be introduced when allocating the DISPC private data dynamically).
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

IMHO this patch can be squashed into the previous patch.

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c | 101 ++++++++++++++++++++----------------
>  drivers/gpu/drm/omapdrm/dss/dpi.c   |  12 +++--
>  drivers/gpu/drm/omapdrm/dss/dsi.c   |  22 ++++----
>  drivers/gpu/drm/omapdrm/dss/dss.c   |  14 ++---
>  drivers/gpu/drm/omapdrm/dss/dss.h   |  74 ++++++++++++++------------
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c |   6 ++-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c |   6 ++-
>  drivers/gpu/drm/omapdrm/dss/sdi.c   |  13 +++--
>  drivers/gpu/drm/omapdrm/dss/venc.c  |   2 +-
>  9 files changed, 139 insertions(+), 111 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 1bca5785b8a8..180ad55bbdec 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -706,7 +706,7 @@ static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
>  	return mgr_desc[channel].sync_lost_irq;
>  }
>  
> -u32 dispc_wb_get_framedone_irq(void)
> +u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
>  {
>  	return DISPC_IRQ_FRAMEDONEWB;
>  }
> @@ -741,12 +741,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
>  	mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1);
>  }
>  
> -bool dispc_wb_go_busy(void)
> +bool dispc_wb_go_busy(struct dispc_device *dispc)
>  {
>  	return REG_GET(DISPC_CONTROL2, 6, 6) == 1;
>  }
>  
> -void dispc_wb_go(void)
> +void dispc_wb_go(struct dispc_device *dispc)
>  {
>  	enum omap_plane_id plane = OMAP_DSS_WB;
>  	bool enable, go;
> @@ -1198,7 +1198,8 @@ static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
>  	}
>  }
>  
> -void dispc_wb_set_channel_in(enum dss_writeback_channel channel)
> +void dispc_wb_set_channel_in(struct dispc_device *dispc,
> +			     enum dss_writeback_channel channel)
>  {
>  	enum omap_plane_id plane = OMAP_DSS_WB;
>  
> @@ -1373,10 +1374,10 @@ static void dispc_init_fifos(void)
>  		const bool use_fifomerge = false;
>  		const bool manual_update = false;
>  
> -		dispc_ovl_compute_fifo_thresholds(i, &low, &high,
> +		dispc_ovl_compute_fifo_thresholds(&dispc, i, &low, &high,
>  			use_fifomerge, manual_update);
>  
> -		dispc_ovl_set_fifo_threshold(i, low, high);
> +		dispc_ovl_set_fifo_threshold(&dispc, i, low, high);
>  	}
>  
>  	if (dispc.feat->has_writeback) {
> @@ -1384,10 +1385,11 @@ static void dispc_init_fifos(void)
>  		const bool use_fifomerge = false;
>  		const bool manual_update = false;
>  
> -		dispc_ovl_compute_fifo_thresholds(OMAP_DSS_WB, &low, &high,
> -			use_fifomerge, manual_update);
> +		dispc_ovl_compute_fifo_thresholds(&dispc, OMAP_DSS_WB,
> +						  &low, &high,
> +						  use_fifomerge, manual_update);
>  
> -		dispc_ovl_set_fifo_threshold(OMAP_DSS_WB, low, high);
> +		dispc_ovl_set_fifo_threshold(&dispc, OMAP_DSS_WB, low, high);
>  	}
>  }
>  
> @@ -1404,13 +1406,14 @@ static u32 dispc_ovl_get_fifo_size(enum omap_plane_id plane)
>  	return size;
>  }
>  
> -void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
> -				  u32 high)
> +void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
> +				  enum omap_plane_id plane,
> +				  u32 low, u32 high)
>  {
>  	u8 hi_start, hi_end, lo_start, lo_end;
>  	u32 unit;
>  
> -	unit = dispc.feat->buffer_size_unit;
> +	unit = dispc->feat->buffer_size_unit;
>  
>  	WARN_ON(low % unit != 0);
>  	WARN_ON(high % unit != 0);
> @@ -1438,12 +1441,12 @@ void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
>  	 * large for the preload field, set the threshold to the maximum value
>  	 * that can be held by the preload register
>  	 */
> -	if (dispc_has_feature(FEAT_PRELOAD) && dispc.feat->set_max_preload &&
> +	if (dispc_has_feature(FEAT_PRELOAD) && dispc->feat->set_max_preload &&
>  			plane != OMAP_DSS_WB)
>  		dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
>  }
>  
> -void dispc_enable_fifomerge(bool enable)
> +void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
>  {
>  	if (!dispc_has_feature(FEAT_FIFO_MERGE)) {
>  		WARN_ON(enable);
> @@ -1454,15 +1457,16 @@ void dispc_enable_fifomerge(bool enable)
>  	REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
>  }
>  
> -void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
> -		u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
> -		bool manual_update)
> +void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
> +				       enum omap_plane_id plane,
> +				       u32 *fifo_low, u32 *fifo_high,
> +				       bool use_fifomerge, bool manual_update)
>  {
>  	/*
>  	 * All sizes are in bytes. Both the buffer and burst are made of
>  	 * buffer_units, and the fifo thresholds must be buffer_unit aligned.
>  	 */
> -	unsigned int buf_unit = dispc.feat->buffer_size_unit;
> +	unsigned int buf_unit = dispc->feat->buffer_size_unit;
>  	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
>  	int i;
>  
> @@ -1471,7 +1475,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
>  
>  	if (use_fifomerge) {
>  		total_fifo_size = 0;
> -		for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
> +		for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
>  			total_fifo_size += dispc_ovl_get_fifo_size(i);
>  	} else {
>  		total_fifo_size = ovl_fifo_size;
> @@ -2667,8 +2671,9 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
>  	return r;
>  }
>  
> -int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
> -		bool mem_to_mem, const struct videomode *vm)
> +int dispc_wb_setup(struct dispc_device *dispc,
> +		   const struct omap_dss_writeback_info *wi,
> +		   bool mem_to_mem, const struct videomode *vm)
>  {
>  	int r;
>  	u32 l;
> @@ -2759,7 +2764,7 @@ static void dispc_lcd_enable_signal_polarity(bool act_high)
>  	REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
>  }
>  
> -void dispc_lcd_enable_signal(bool enable)
> +void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable)
>  {
>  	if (!dispc_has_feature(FEAT_LCDENABLESIGNAL))
>  		return;
> @@ -2767,7 +2772,7 @@ void dispc_lcd_enable_signal(bool enable)
>  	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
>  }
>  
> -void dispc_pck_free_enable(bool enable)
> +void dispc_pck_free_enable(struct dispc_device *dispc, bool enable)
>  {
>  	if (!dispc_has_feature(FEAT_PCKFREEENABLE))
>  		return;
> @@ -2906,7 +2911,7 @@ static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
>  	dispc_mgr_enable_stallmode(channel, config->stallmode);
>  	dispc_mgr_enable_fifohandcheck(channel, config->fifohandcheck);
>  
> -	dispc_mgr_set_clock_div(channel, &config->clock_info);
> +	dispc_mgr_set_clock_div(dispc, channel, &config->clock_info);
>  
>  	dispc_mgr_set_tft_data_lines(channel, config->video_port_width);
>  
> @@ -2943,7 +2948,8 @@ static bool _dispc_mgr_pclk_ok(enum omap_channel channel,
>  		return pclk <= dispc.feat->max_tv_pclk;
>  }
>  
> -bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm)
> +bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
> +			  const struct videomode *vm)
>  {
>  	if (!_dispc_mgr_size_ok(vm->hactive, vm->vactive))
>  		return false;
> @@ -3064,7 +3070,7 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
>  
>  	DSSDBG("channel %d xres %u yres %u\n", channel, t.hactive, t.vactive);
>  
> -	if (!dispc_mgr_timings_ok(channel, &t)) {
> +	if (!dispc_mgr_timings_ok(dispc, channel, &t)) {
>  		BUG();
>  		return;
>  	}
> @@ -3197,9 +3203,9 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
>  	}
>  }
>  
> -void dispc_set_tv_pclk(unsigned long pclk)
> +void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk)
>  {
> -	dispc.tv_pclk_rate = pclk;
> +	dispc->tv_pclk_rate = pclk;
>  }
>  
>  static unsigned long dispc_core_clk_rate(void)
> @@ -3251,13 +3257,13 @@ static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel chan
>  		dispc_mgr_pclk_rate(channel), pcd);
>  }
>  
> -void dispc_dump_clocks(struct seq_file *s)
> +void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
>  {
>  	int lcd;
>  	u32 l;
> -	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
> +	enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc->dss);
>  
> -	if (dispc_runtime_get(&dispc))
> +	if (dispc_runtime_get(dispc))
>  		return;
>  
>  	seq_printf(s, "- DISPC -\n");
> @@ -3283,7 +3289,7 @@ void dispc_dump_clocks(struct seq_file *s)
>  	if (dispc_has_feature(FEAT_MGR_LCD3))
>  		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
>  
> -	dispc_runtime_put(&dispc);
> +	dispc_runtime_put(dispc);
>  }
>  
>  static int dispc_dump_regs(struct seq_file *s, void *p)
> @@ -3484,8 +3490,9 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  }
>  
>  /* calculate clock rates using dividers in cinfo */
> -int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
> -		struct dispc_clock_info *cinfo)
> +int dispc_calc_clock_rates(struct dispc_device *dispc,
> +			   unsigned long dispc_fclk_rate,
> +			   struct dispc_clock_info *cinfo)
>  {
>  	if (cinfo->lck_div > 255 || cinfo->lck_div == 0)
>  		return -EINVAL;
> @@ -3498,9 +3505,9 @@ int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
>  	return 0;
>  }
>  
> -bool dispc_div_calc(unsigned long dispc_freq,
> -		unsigned long pck_min, unsigned long pck_max,
> -		dispc_div_calc_func func, void *data)
> +bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
> +		    unsigned long pck_min, unsigned long pck_max,
> +		    dispc_div_calc_func func, void *data)
>  {
>  	int lckd, lckd_start, lckd_stop;
>  	int pckd, pckd_start, pckd_stop;
> @@ -3516,10 +3523,10 @@ bool dispc_div_calc(unsigned long dispc_freq,
>  	min_fck_per_pck = 0;
>  #endif
>  
> -	pckd_hw_min = dispc.feat->min_pcd;
> +	pckd_hw_min = dispc->feat->min_pcd;
>  	pckd_hw_max = 255;
>  
> -	lck_max = dss_get_max_fck_rate(dispc.dss);
> +	lck_max = dss_get_max_fck_rate(dispc->dss);
>  
>  	pck_min = pck_min ? pck_min : 1;
>  	pck_max = pck_max ? pck_max : ULONG_MAX;
> @@ -3558,8 +3565,9 @@ bool dispc_div_calc(unsigned long dispc_freq,
>  	return false;
>  }
>  
> -void dispc_mgr_set_clock_div(enum omap_channel channel,
> -		const struct dispc_clock_info *cinfo)
> +void dispc_mgr_set_clock_div(struct dispc_device *dispc,
> +			     enum omap_channel channel,
> +			     const struct dispc_clock_info *cinfo)
>  {
>  	DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
>  	DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
> @@ -3567,8 +3575,9 @@ void dispc_mgr_set_clock_div(enum omap_channel channel,
>  	dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div);
>  }
>  
> -int dispc_mgr_get_clock_div(enum omap_channel channel,
> -		struct dispc_clock_info *cinfo)
> +int dispc_mgr_get_clock_div(struct dispc_device *dispc,
> +			    enum omap_channel channel,
> +			    struct dispc_clock_info *cinfo)
>  {
>  	unsigned long fck;
>  
> @@ -3606,12 +3615,12 @@ static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
>  	dispc_read_reg(DISPC_IRQENABLE);
>  }
>  
> -void dispc_enable_sidle(void)
> +void dispc_enable_sidle(struct dispc_device *dispc)
>  {
>  	REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3);	/* SIDLEMODE: smart idle */
>  }
>  
> -void dispc_disable_sidle(void)
> +void dispc_disable_sidle(struct dispc_device *dispc)
>  {
>  	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
>  }
> @@ -4473,7 +4482,7 @@ static void dispc_errata_i734_wa(void)
>  
>  	/* Set up and enable display manager for LCD1 */
>  	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
> -	dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
> +	dispc_calc_clock_rates(&dispc, dss_get_dispc_clk_rate(dispc.dss),
>  			       &lcd_conf.clock_info);
>  	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
>  	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index aa10db453fd0..66183fc77bb2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -192,8 +192,9 @@ static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
>  	ctx->pll_cinfo.mX[ctx->clkout_idx] = m_dispc;
>  	ctx->pll_cinfo.clkout[ctx->clkout_idx] = dispc;
>  
> -	return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max,
> -			dpi_calc_dispc_cb, ctx);
> +	return dispc_div_calc(ctx->pll->dss->dispc, dispc,
> +			      ctx->pck_min, ctx->pck_max,
> +			      dpi_calc_dispc_cb, ctx);
>  }
>  
>  
> @@ -219,8 +220,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
>  
>  	ctx->fck = fck;
>  
> -	return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
> -			dpi_calc_dispc_cb, ctx);
> +	return dispc_div_calc(ctx->pll->dss->dispc, fck,
> +			      ctx->pck_min, ctx->pck_max,
> +			      dpi_calc_dispc_cb, ctx);
>  }
>  
>  static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck,
> @@ -515,7 +517,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
>  	if (vm->hactive % 8 != 0)
>  		return -EINVAL;
>  
> -	if (!dispc_mgr_timings_ok(channel, vm))
> +	if (!dispc_mgr_timings_ok(dpi->dss->dispc, channel, vm))
>  		return -EINVAL;
>  
>  	if (vm->pixelclock == 0)
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 1cac221e499a..c7700dfccc08 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -1396,18 +1396,18 @@ static int dsi_pll_enable(struct dss_pll *pll)
>  	}
>  
>  	/* XXX PLL does not come out of reset without this... */
> -	dispc_pck_free_enable(1);
> +	dispc_pck_free_enable(dsi->dss->dispc, 1);
>  
>  	if (!wait_for_bit_change(dsi, DSI_PLL_STATUS, 0, 1)) {
>  		DSSERR("PLL not coming out of reset.\n");
>  		r = -ENODEV;
> -		dispc_pck_free_enable(0);
> +		dispc_pck_free_enable(dsi->dss->dispc, 0);
>  		goto err1;
>  	}
>  
>  	/* XXX ... but if left on, we get problems when planes do not
>  	 * fill the whole display. No idea about this */
> -	dispc_pck_free_enable(0);
> +	dispc_pck_free_enable(dsi->dss->dispc, 0);
>  
>  	r = dsi_pll_power(dsi, DSI_PLL_POWER_ON_ALL);
>  
> @@ -3974,7 +3974,7 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  	 * the same goes for any DSS interrupts, but for some reason I have not
>  	 * seen the problem anywhere else than here.
>  	 */
> -	dispc_disable_sidle();
> +	dispc_disable_sidle(dsi->dss->dispc);
>  
>  	dsi_perf_mark_start(dsi);
>  
> @@ -4009,7 +4009,7 @@ static void dsi_te_timeout(unsigned long arg)
>  static void dsi_handle_framedone(struct dsi_data *dsi, int error)
>  {
>  	/* SIDLEMODE back to smart-idle */
> -	dispc_enable_sidle();
> +	dispc_enable_sidle(dsi->dss->dispc);
>  
>  	if (dsi->te_enabled) {
>  		/* enable LP_RX_TO again after the TE */
> @@ -4090,7 +4090,7 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
>  	dispc_cinfo.lck_div = dsi->user_dispc_cinfo.lck_div;
>  	dispc_cinfo.pck_div = dsi->user_dispc_cinfo.pck_div;
>  
> -	r = dispc_calc_clock_rates(fck, &dispc_cinfo);
> +	r = dispc_calc_clock_rates(dsi->dss->dispc, fck, &dispc_cinfo);
>  	if (r) {
>  		DSSERR("Failed to calc dispc clocks\n");
>  		return r;
> @@ -4441,8 +4441,9 @@ static bool dsi_cm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
>  	ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc;
>  	ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc;
>  
> -	return dispc_div_calc(dispc, ctx->req_pck_min, ctx->req_pck_max,
> -			dsi_cm_calc_dispc_cb, ctx);
> +	return dispc_div_calc(ctx->dsi->dss->dispc, dispc,
> +			      ctx->req_pck_min, ctx->req_pck_max,
> +			      dsi_cm_calc_dispc_cb, ctx);
>  }
>  
>  static bool dsi_cm_calc_pll_cb(int n, int m, unsigned long fint,
> @@ -4741,8 +4742,9 @@ static bool dsi_vm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
>  	else
>  		pck_max = ctx->req_pck_max;
>  
> -	return dispc_div_calc(dispc, ctx->req_pck_min, pck_max,
> -			dsi_vm_calc_dispc_cb, ctx);
> +	return dispc_div_calc(ctx->dsi->dss->dispc, dispc,
> +			      ctx->req_pck_min, pck_max,
> +			      dsi_vm_calc_dispc_cb, ctx);
>  }
>  
>  static bool dsi_vm_calc_pll_cb(int n, int m, unsigned long fint,
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index fcdd7d00caa8..5d927dfe0a7f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -276,7 +276,7 @@ int dss_sdi_enable(struct dss_device *dss)
>  {
>  	unsigned long timeout;
>  
> -	dispc_pck_free_enable(1);
> +	dispc_pck_free_enable(dss->dispc, 1);
>  
>  	/* Reset SDI PLL */
>  	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */
> @@ -306,7 +306,7 @@ int dss_sdi_enable(struct dss_device *dss)
>  		}
>  	}
>  
> -	dispc_lcd_enable_signal(1);
> +	dispc_lcd_enable_signal(dss->dispc, 1);
>  
>  	/* Waiting for SDI reset to complete */
>  	timeout = jiffies + msecs_to_jiffies(500);
> @@ -320,21 +320,21 @@ int dss_sdi_enable(struct dss_device *dss)
>  	return 0;
>  
>   err2:
> -	dispc_lcd_enable_signal(0);
> +	dispc_lcd_enable_signal(dss->dispc, 0);
>   err1:
>  	/* Reset SDI PLL */
>  	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
>  
> -	dispc_pck_free_enable(0);
> +	dispc_pck_free_enable(dss->dispc, 0);
>  
>  	return -ETIMEDOUT;
>  }
>  
>  void dss_sdi_disable(struct dss_device *dss)
>  {
> -	dispc_lcd_enable_signal(0);
> +	dispc_lcd_enable_signal(dss->dispc, 0);
>  
> -	dispc_pck_free_enable(0);
> +	dispc_pck_free_enable(dss->dispc, 0);
>  
>  	/* Reset SDI PLL */
>  	REG_FLD_MOD(dss, DSS_PLL_CONTROL, 0, 18, 18); /* SDI_PLL_SYSRESET */
> @@ -899,7 +899,7 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
>  	struct dss_device *dss = s->private;
>  
>  	dss_dump_clocks(dss, s);
> -	dispc_dump_clocks(s);
> +	dispc_dump_clocks(dss->dispc, s);
>  #ifdef CONFIG_OMAP2_DSS_DSI
>  	dsi_dump_clocks(s);
>  #endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 5f3e26bec402..ceba8441c7cc 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -417,47 +417,55 @@ static inline void dpi_uninit_port(struct device_node *port)
>  /* DISPC */
>  int dispc_init_platform_driver(void) __init;
>  void dispc_uninit_platform_driver(void);
> -void dispc_dump_clocks(struct seq_file *s);
> +void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s);
>  
>  int dispc_runtime_get(struct dispc_device *dispc);
>  void dispc_runtime_put(struct dispc_device *dispc);
>  
> -void dispc_enable_sidle(void);
> -void dispc_disable_sidle(void);
> +void dispc_enable_sidle(struct dispc_device *dispc);
> +void dispc_disable_sidle(struct dispc_device *dispc);
>  
> -void dispc_lcd_enable_signal(bool enable);
> -void dispc_pck_free_enable(bool enable);
> -void dispc_enable_fifomerge(bool enable);
> +void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable);
> +void dispc_pck_free_enable(struct dispc_device *dispc, bool enable);
> +void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable);
>  
>  typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
>  		unsigned long pck, void *data);
> -bool dispc_div_calc(unsigned long dispc,
> -		unsigned long pck_min, unsigned long pck_max,
> -		dispc_div_calc_func func, void *data);
> -
> -bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm);
> -int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
> -		struct dispc_clock_info *cinfo);
> -
> -
> -void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
> -				  u32 high);
> -void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
> -		u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
> -		bool manual_update);
> -
> -void dispc_mgr_set_clock_div(enum omap_channel channel,
> -		const struct dispc_clock_info *cinfo);
> -int dispc_mgr_get_clock_div(enum omap_channel channel,
> -		struct dispc_clock_info *cinfo);
> -void dispc_set_tv_pclk(unsigned long pclk);
> -
> -u32 dispc_wb_get_framedone_irq(void);
> -bool dispc_wb_go_busy(void);
> -void dispc_wb_go(void);
> -void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
> -int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
> -		bool mem_to_mem, const struct videomode *vm);
> +bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
> +		    unsigned long pck_min, unsigned long pck_max,
> +		    dispc_div_calc_func func, void *data);
> +
> +bool dispc_mgr_timings_ok(struct dispc_device *dispc,
> +			  enum omap_channel channel,
> +			  const struct videomode *vm);
> +int dispc_calc_clock_rates(struct dispc_device *dispc,
> +			   unsigned long dispc_fclk_rate,
> +			   struct dispc_clock_info *cinfo);
> +
> +
> +void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
> +				  enum omap_plane_id plane, u32 low, u32 high);
> +void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
> +				       enum omap_plane_id plane,
> +				       u32 *fifo_low, u32 *fifo_high,
> +				       bool use_fifomerge, bool manual_update);
> +
> +void dispc_mgr_set_clock_div(struct dispc_device *dispc,
> +			     enum omap_channel channel,
> +			     const struct dispc_clock_info *cinfo);
> +int dispc_mgr_get_clock_div(struct dispc_device *dispc,
> +			    enum omap_channel channel,
> +			    struct dispc_clock_info *cinfo);
> +void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk);
> +
> +u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc);
> +bool dispc_wb_go_busy(struct dispc_device *dispc);
> +void dispc_wb_go(struct dispc_device *dispc);
> +void dispc_wb_set_channel_in(struct dispc_device *dispc,
> +			     enum dss_writeback_channel channel);
> +int dispc_wb_setup(struct dispc_device *dispc,
> +		   const struct omap_dss_writeback_info *wi,
> +		   bool mem_to_mem, const struct videomode *vm);
>  
>  /* VENC */
>  int venc_init_platform_driver(void) __init;
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index cf4b2c9bbcbd..2050601fef0a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -273,7 +273,9 @@ static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
>  				     struct videomode *vm)
>  {
> -	if (!dispc_mgr_timings_ok(dssdev->dispc_channel, vm))
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	if (!dispc_mgr_timings_ok(hdmi->dss->dispc, dssdev->dispc_channel, vm))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -288,7 +290,7 @@ static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
>  
>  	hdmi->cfg.vm = *vm;
>  
> -	dispc_set_tv_pclk(vm->pixelclock);
> +	dispc_set_tv_pclk(hdmi->dss->dispc, vm->pixelclock);
>  
>  	mutex_unlock(&hdmi->lock);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 66b603c5b2fc..ec3b044925d0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -271,7 +271,9 @@ static void hdmi_power_off_full(struct omap_hdmi *hdmi)
>  static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
>  				     struct videomode *vm)
>  {
> -	if (!dispc_mgr_timings_ok(dssdev->dispc_channel, vm))
> +	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
> +
> +	if (!dispc_mgr_timings_ok(hdmi->dss->dispc, dssdev->dispc_channel, vm))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -286,7 +288,7 @@ static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
>  
>  	hdmi->cfg.vm = *vm;
>  
> -	dispc_set_tv_pclk(vm->pixelclock);
> +	dispc_set_tv_pclk(hdmi->dss->dispc, vm->pixelclock);
>  
>  	mutex_unlock(&hdmi->lock);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index efa73cfabce6..b0ef2395e8a1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -48,6 +48,7 @@ struct sdi_device {
>  #define dssdev_to_sdi(dssdev) container_of(dssdev, struct sdi_device, output)
>  
>  struct sdi_clk_calc_ctx {
> +	struct sdi_device *sdi;
>  	unsigned long pck_min, pck_max;
>  
>  	unsigned long fck;
> @@ -73,8 +74,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
>  
>  	ctx->fck = fck;
>  
> -	return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
> -			dpi_calc_dispc_cb, ctx);
> +	return dispc_div_calc(ctx->sdi->dss->dispc, fck,
> +			      ctx->pck_min, ctx->pck_max,
> +			      dpi_calc_dispc_cb, ctx);
>  }
>  
>  static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
> @@ -82,7 +84,7 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
>  			      struct dispc_clock_info *dispc_cinfo)
>  {
>  	int i;
> -	struct sdi_clk_calc_ctx ctx;
> +	struct sdi_clk_calc_ctx ctx = { .sdi = sdi };
>  
>  	/*
>  	 * DSS fclk gives us very few possibilities, so finding a good pixel
> @@ -186,7 +188,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
>  	 * need to care about the shadow register mechanism for pck-free. The
>  	 * exact reason for this is unknown.
>  	 */
> -	dispc_mgr_set_clock_div(sdi->output.dispc_channel,
> +	dispc_mgr_set_clock_div(sdi->dss->dispc, sdi->output.dispc_channel,
>  				&sdi->mgr_config.clock_info);
>  
>  	dss_sdi_init(sdi->dss, sdi->datapairs);
> @@ -245,9 +247,10 @@ static void sdi_get_timings(struct omap_dss_device *dssdev,
>  static int sdi_check_timings(struct omap_dss_device *dssdev,
>  			     struct videomode *vm)
>  {
> +	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
>  	enum omap_channel channel = dssdev->dispc_channel;
>  
> -	if (!dispc_mgr_timings_ok(channel, vm))
> +	if (!dispc_mgr_timings_ok(sdi->dss->dispc, channel, vm))
>  		return -EINVAL;
>  
>  	if (vm->pixelclock == 0)
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 13ed7426ea09..449a82b84d03 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -597,7 +597,7 @@ static void venc_set_timings(struct omap_dss_device *dssdev,
>  
>  	venc->vm = actual_vm;
>  
> -	dispc_set_tv_pclk(13500000);
> +	dispc_set_tv_pclk(venc->dss->dispc, 13500000);
>  
>  	mutex_unlock(&venc->venc_lock);
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions
  2017-10-17 21:24   ` Sebastian Reichel
@ 2017-10-17 21:44     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-17 21:44 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Wednesday, 18 October 2017 00:24:54 EEST Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Oct 13, 2017 at 05:59:41PM +0300, Laurent Pinchart wrote:
> > This removes the need to access the global DISPC private data in those
> > functions (both for the current accesses and the future ones that will
> > be introduced when allocating the DISPC private data dynamically).
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> 
> IMHO this patch can be squashed into the previous patch.

I've split the changes in two patches to try and keep them reviewable, given 
the amount of lines changed, but I'm fine merging them together too.

> >  drivers/gpu/drm/omapdrm/dss/dispc.c | 101 +++++++++++++++++--------------
> >  drivers/gpu/drm/omapdrm/dss/dpi.c   |  12 +++--
> >  drivers/gpu/drm/omapdrm/dss/dsi.c   |  22 ++++----
> >  drivers/gpu/drm/omapdrm/dss/dss.c   |  14 ++---
> >  drivers/gpu/drm/omapdrm/dss/dss.h   |  74 ++++++++++++++------------
> >  drivers/gpu/drm/omapdrm/dss/hdmi4.c |   6 ++-
> >  drivers/gpu/drm/omapdrm/dss/hdmi5.c |   6 ++-
> >  drivers/gpu/drm/omapdrm/dss/sdi.c   |  13 +++--
> >  drivers/gpu/drm/omapdrm/dss/venc.c  |   2 +-
> >  9 files changed, 139 insertions(+), 111 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically
  2017-10-13 14:59 ` [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
@ 2017-10-17 22:09   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 22:09 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 131913 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:42PM +0300, Laurent Pinchart wrote:
> The dispc private data structure is currently stored as a global
> variable. While no platform with multiple DISPC currently exists
> nor is planned, this doesn't comply with the kernel device model and
> should thus be fixed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c | 1924 +++++++++++++++++++----------------
>  1 file changed, 1032 insertions(+), 892 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 180ad55bbdec..aaf7396f0273 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -49,6 +49,8 @@
>  #include "dss.h"
>  #include "dispc.h"
>  
> +struct dispc_device;
> +
>  /* DISPC */
>  #define DISPC_SZ_REGS			SZ_4K
>  
> @@ -58,11 +60,12 @@ enum omap_burst_size {
>  	BURST_SIZE_X8 = 2,
>  };
>  
> -#define REG_GET(idx, start, end) \
> -	FLD_GET(dispc_read_reg(idx), start, end)
> +#define REG_GET(dispc, idx, start, end) \
> +	FLD_GET(dispc_read_reg(dispc, idx), start, end)
>  
> -#define REG_FLD_MOD(idx, val, start, end)				\
> -	dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end))
> +#define REG_FLD_MOD(dispc, idx, val, start, end)			\
> +	dispc_write_reg(dispc, idx, \
> +			FLD_MOD(dispc_read_reg(dispc, idx), val, start, end))
>  
>  /* DISPC has feature id */
>  enum dispc_feature_id {
> @@ -107,7 +110,8 @@ struct dispc_features {
>  	unsigned int max_downscale;
>  	unsigned int max_line_width;
>  	unsigned int min_pcd;
> -	int (*calc_scaling) (unsigned long pclk, unsigned long lclk,
> +	int (*calc_scaling)(struct dispc_device *dispc,
> +		unsigned long pclk, unsigned long lclk,
>  		const struct videomode *vm,
>  		u16 width, u16 height, u16 out_width, u16 out_height,
>  		u32 fourcc, bool *five_taps,
> @@ -198,8 +202,6 @@ struct dispc_device {
>  	spinlock_t control_lock;
>  };
>  
> -static struct dispc_device dispc;
> -
>  enum omap_color_component {
>  	/* used for all color formats for OMAP3 and earlier
>  	 * and for RGB and Y color component on OMAP4
> @@ -357,45 +359,52 @@ struct color_conv_coef {
>  	int full_range;
>  };
>  
> -static unsigned long dispc_fclk_rate(void);
> -static unsigned long dispc_core_clk_rate(void);
> -static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
> -static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
> +static unsigned long dispc_fclk_rate(struct dispc_device *dispc);
> +static unsigned long dispc_core_clk_rate(struct dispc_device *dispc);
> +static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
> +					 enum omap_channel channel);
> +static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
> +					 enum omap_channel channel);
>  
> -static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane);
> -static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane);
> +static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
> +					   enum omap_plane_id plane);
> +static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
> +					   enum omap_plane_id plane);
>  
>  static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
>  
> -static inline void dispc_write_reg(const u16 idx, u32 val)
> +static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 val)
>  {
> -	__raw_writel(val, dispc.base + idx);
> +	__raw_writel(val, dispc->base + idx);
>  }
>  
> -static inline u32 dispc_read_reg(const u16 idx)
> +static inline u32 dispc_read_reg(struct dispc_device *dispc, u16 idx)
>  {
> -	return __raw_readl(dispc.base + idx);
> +	return __raw_readl(dispc->base + idx);
>  }
>  
> -static u32 mgr_fld_read(enum omap_channel channel, enum mgr_reg_fields regfld)
> +static u32 mgr_fld_read(struct dispc_device *dispc, enum omap_channel channel,
> +			enum mgr_reg_fields regfld)
>  {
>  	const struct dispc_reg_field rfld = mgr_desc[channel].reg_desc[regfld];
> -	return REG_GET(rfld.reg, rfld.high, rfld.low);
> +
> +	return REG_GET(dispc, rfld.reg, rfld.high, rfld.low);
>  }
>  
> -static void mgr_fld_write(enum omap_channel channel,
> -					enum mgr_reg_fields regfld, int val) {
> +static void mgr_fld_write(struct dispc_device *dispc, enum omap_channel channel,
> +			  enum mgr_reg_fields regfld, int val)
> +{
>  	const struct dispc_reg_field rfld = mgr_desc[channel].reg_desc[regfld];
>  	const bool need_lock = rfld.reg == DISPC_CONTROL || rfld.reg == DISPC_CONFIG;
>  	unsigned long flags;
>  
>  	if (need_lock)
> -		spin_lock_irqsave(&dispc.control_lock, flags);
> +		spin_lock_irqsave(&dispc->control_lock, flags);
>  
> -	REG_FLD_MOD(rfld.reg, val, rfld.high, rfld.low);
> +	REG_FLD_MOD(dispc, rfld.reg, val, rfld.high, rfld.low);
>  
>  	if (need_lock)
> -		spin_unlock_irqrestore(&dispc.control_lock, flags);
> +		spin_unlock_irqrestore(&dispc->control_lock, flags);
>  }
>  
>  static int dispc_get_num_ovls(struct dispc_device *dispc)
> @@ -408,255 +417,257 @@ static int dispc_get_num_mgrs(struct dispc_device *dispc)
>  	return dispc->feat->num_mgrs;
>  }
>  
> -static void dispc_get_reg_field(enum dispc_feat_reg_field id,
> +static void dispc_get_reg_field(struct dispc_device *dispc,
> +				enum dispc_feat_reg_field id,
>  				u8 *start, u8 *end)
>  {
> -	if (id >= dispc.feat->num_reg_fields)
> +	if (id >= dispc->feat->num_reg_fields)
>  		BUG();
>  
> -	*start = dispc.feat->reg_fields[id].start;
> -	*end = dispc.feat->reg_fields[id].end;
> +	*start = dispc->feat->reg_fields[id].start;
> +	*end = dispc->feat->reg_fields[id].end;
>  }
>  
> -static bool dispc_has_feature(enum dispc_feature_id id)
> +static bool dispc_has_feature(struct dispc_device *dispc,
> +			      enum dispc_feature_id id)
>  {
>  	unsigned int i;
>  
> -	for (i = 0; i < dispc.feat->num_features; i++) {
> -		if (dispc.feat->features[i] == id)
> +	for (i = 0; i < dispc->feat->num_features; i++) {
> +		if (dispc->feat->features[i] == id)
>  			return true;
>  	}
>  
>  	return false;
>  }
>  
> -#define SR(reg) \
> -	dispc.ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(DISPC_##reg)
> -#define RR(reg) \
> -	dispc_write_reg(DISPC_##reg, dispc.ctx[DISPC_##reg / sizeof(u32)])
> +#define SR(dispc, reg) \
> +	dispc->ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(dispc, DISPC_##reg)
> +#define RR(dispc, reg) \
> +	dispc_write_reg(dispc, DISPC_##reg, dispc->ctx[DISPC_##reg / sizeof(u32)])
>  
> -static void dispc_save_context(void)
> +static void dispc_save_context(struct dispc_device *dispc)
>  {
>  	int i, j;
>  
>  	DSSDBG("dispc_save_context\n");
>  
> -	SR(IRQENABLE);
> -	SR(CONTROL);
> -	SR(CONFIG);
> -	SR(LINE_NUMBER);
> -	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
> -			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
> -		SR(GLOBAL_ALPHA);
> -	if (dispc_has_feature(FEAT_MGR_LCD2)) {
> -		SR(CONTROL2);
> -		SR(CONFIG2);
> +	SR(dispc, IRQENABLE);
> +	SR(dispc, CONTROL);
> +	SR(dispc, CONFIG);
> +	SR(dispc, LINE_NUMBER);
> +	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
> +			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
> +		SR(dispc, GLOBAL_ALPHA);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
> +		SR(dispc, CONTROL2);
> +		SR(dispc, CONFIG2);
>  	}
> -	if (dispc_has_feature(FEAT_MGR_LCD3)) {
> -		SR(CONTROL3);
> -		SR(CONFIG3);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
> +		SR(dispc, CONTROL3);
> +		SR(dispc, CONFIG3);
>  	}
>  
> -	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
> -		SR(DEFAULT_COLOR(i));
> -		SR(TRANS_COLOR(i));
> -		SR(SIZE_MGR(i));
> +	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
> +		SR(dispc, DEFAULT_COLOR(i));
> +		SR(dispc, TRANS_COLOR(i));
> +		SR(dispc, SIZE_MGR(i));
>  		if (i == OMAP_DSS_CHANNEL_DIGIT)
>  			continue;
> -		SR(TIMING_H(i));
> -		SR(TIMING_V(i));
> -		SR(POL_FREQ(i));
> -		SR(DIVISORo(i));
> -
> -		SR(DATA_CYCLE1(i));
> -		SR(DATA_CYCLE2(i));
> -		SR(DATA_CYCLE3(i));
> -
> -		if (dispc_has_feature(FEAT_CPR)) {
> -			SR(CPR_COEF_R(i));
> -			SR(CPR_COEF_G(i));
> -			SR(CPR_COEF_B(i));
> +		SR(dispc, TIMING_H(i));
> +		SR(dispc, TIMING_V(i));
> +		SR(dispc, POL_FREQ(i));
> +		SR(dispc, DIVISORo(i));
> +
> +		SR(dispc, DATA_CYCLE1(i));
> +		SR(dispc, DATA_CYCLE2(i));
> +		SR(dispc, DATA_CYCLE3(i));
> +
> +		if (dispc_has_feature(dispc, FEAT_CPR)) {
> +			SR(dispc, CPR_COEF_R(i));
> +			SR(dispc, CPR_COEF_G(i));
> +			SR(dispc, CPR_COEF_B(i));
>  		}
>  	}
>  
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
> -		SR(OVL_BA0(i));
> -		SR(OVL_BA1(i));
> -		SR(OVL_POSITION(i));
> -		SR(OVL_SIZE(i));
> -		SR(OVL_ATTRIBUTES(i));
> -		SR(OVL_FIFO_THRESHOLD(i));
> -		SR(OVL_ROW_INC(i));
> -		SR(OVL_PIXEL_INC(i));
> -		if (dispc_has_feature(FEAT_PRELOAD))
> -			SR(OVL_PRELOAD(i));
> +	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
> +		SR(dispc, OVL_BA0(i));
> +		SR(dispc, OVL_BA1(i));
> +		SR(dispc, OVL_POSITION(i));
> +		SR(dispc, OVL_SIZE(i));
> +		SR(dispc, OVL_ATTRIBUTES(i));
> +		SR(dispc, OVL_FIFO_THRESHOLD(i));
> +		SR(dispc, OVL_ROW_INC(i));
> +		SR(dispc, OVL_PIXEL_INC(i));
> +		if (dispc_has_feature(dispc, FEAT_PRELOAD))
> +			SR(dispc, OVL_PRELOAD(i));
>  		if (i == OMAP_DSS_GFX) {
> -			SR(OVL_WINDOW_SKIP(i));
> -			SR(OVL_TABLE_BA(i));
> +			SR(dispc, OVL_WINDOW_SKIP(i));
> +			SR(dispc, OVL_TABLE_BA(i));
>  			continue;
>  		}
> -		SR(OVL_FIR(i));
> -		SR(OVL_PICTURE_SIZE(i));
> -		SR(OVL_ACCU0(i));
> -		SR(OVL_ACCU1(i));
> +		SR(dispc, OVL_FIR(i));
> +		SR(dispc, OVL_PICTURE_SIZE(i));
> +		SR(dispc, OVL_ACCU0(i));
> +		SR(dispc, OVL_ACCU1(i));
>  
>  		for (j = 0; j < 8; j++)
> -			SR(OVL_FIR_COEF_H(i, j));
> +			SR(dispc, OVL_FIR_COEF_H(i, j));
>  
>  		for (j = 0; j < 8; j++)
> -			SR(OVL_FIR_COEF_HV(i, j));
> +			SR(dispc, OVL_FIR_COEF_HV(i, j));
>  
>  		for (j = 0; j < 5; j++)
> -			SR(OVL_CONV_COEF(i, j));
> +			SR(dispc, OVL_CONV_COEF(i, j));
>  
> -		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
> +		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
>  			for (j = 0; j < 8; j++)
> -				SR(OVL_FIR_COEF_V(i, j));
> +				SR(dispc, OVL_FIR_COEF_V(i, j));
>  		}
>  
> -		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
> -			SR(OVL_BA0_UV(i));
> -			SR(OVL_BA1_UV(i));
> -			SR(OVL_FIR2(i));
> -			SR(OVL_ACCU2_0(i));
> -			SR(OVL_ACCU2_1(i));
> +		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
> +			SR(dispc, OVL_BA0_UV(i));
> +			SR(dispc, OVL_BA1_UV(i));
> +			SR(dispc, OVL_FIR2(i));
> +			SR(dispc, OVL_ACCU2_0(i));
> +			SR(dispc, OVL_ACCU2_1(i));
>  
>  			for (j = 0; j < 8; j++)
> -				SR(OVL_FIR_COEF_H2(i, j));
> +				SR(dispc, OVL_FIR_COEF_H2(i, j));
>  
>  			for (j = 0; j < 8; j++)
> -				SR(OVL_FIR_COEF_HV2(i, j));
> +				SR(dispc, OVL_FIR_COEF_HV2(i, j));
>  
>  			for (j = 0; j < 8; j++)
> -				SR(OVL_FIR_COEF_V2(i, j));
> +				SR(dispc, OVL_FIR_COEF_V2(i, j));
>  		}
> -		if (dispc_has_feature(FEAT_ATTR2))
> -			SR(OVL_ATTRIBUTES2(i));
> +		if (dispc_has_feature(dispc, FEAT_ATTR2))
> +			SR(dispc, OVL_ATTRIBUTES2(i));
>  	}
>  
> -	if (dispc_has_feature(FEAT_CORE_CLK_DIV))
> -		SR(DIVISOR);
> +	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
> +		SR(dispc, DIVISOR);
>  
> -	dispc.ctx_valid = true;
> +	dispc->ctx_valid = true;
>  
>  	DSSDBG("context saved\n");
>  }
>  
> -static void dispc_restore_context(void)
> +static void dispc_restore_context(struct dispc_device *dispc)
>  {
>  	int i, j;
>  
>  	DSSDBG("dispc_restore_context\n");
>  
> -	if (!dispc.ctx_valid)
> +	if (!dispc->ctx_valid)
>  		return;
>  
> -	/*RR(IRQENABLE);*/
> -	/*RR(CONTROL);*/
> -	RR(CONFIG);
> -	RR(LINE_NUMBER);
> -	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
> -			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
> -		RR(GLOBAL_ALPHA);
> -	if (dispc_has_feature(FEAT_MGR_LCD2))
> -		RR(CONFIG2);
> -	if (dispc_has_feature(FEAT_MGR_LCD3))
> -		RR(CONFIG3);
> -
> -	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
> -		RR(DEFAULT_COLOR(i));
> -		RR(TRANS_COLOR(i));
> -		RR(SIZE_MGR(i));
> +	/*RR(dispc, IRQENABLE);*/
> +	/*RR(dispc, CONTROL);*/
> +	RR(dispc, CONFIG);
> +	RR(dispc, LINE_NUMBER);
> +	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
> +			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
> +		RR(dispc, GLOBAL_ALPHA);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
> +		RR(dispc, CONFIG2);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
> +		RR(dispc, CONFIG3);
> +
> +	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
> +		RR(dispc, DEFAULT_COLOR(i));
> +		RR(dispc, TRANS_COLOR(i));
> +		RR(dispc, SIZE_MGR(i));
>  		if (i == OMAP_DSS_CHANNEL_DIGIT)
>  			continue;
> -		RR(TIMING_H(i));
> -		RR(TIMING_V(i));
> -		RR(POL_FREQ(i));
> -		RR(DIVISORo(i));
> -
> -		RR(DATA_CYCLE1(i));
> -		RR(DATA_CYCLE2(i));
> -		RR(DATA_CYCLE3(i));
> -
> -		if (dispc_has_feature(FEAT_CPR)) {
> -			RR(CPR_COEF_R(i));
> -			RR(CPR_COEF_G(i));
> -			RR(CPR_COEF_B(i));
> +		RR(dispc, TIMING_H(i));
> +		RR(dispc, TIMING_V(i));
> +		RR(dispc, POL_FREQ(i));
> +		RR(dispc, DIVISORo(i));
> +
> +		RR(dispc, DATA_CYCLE1(i));
> +		RR(dispc, DATA_CYCLE2(i));
> +		RR(dispc, DATA_CYCLE3(i));
> +
> +		if (dispc_has_feature(dispc, FEAT_CPR)) {
> +			RR(dispc, CPR_COEF_R(i));
> +			RR(dispc, CPR_COEF_G(i));
> +			RR(dispc, CPR_COEF_B(i));
>  		}
>  	}
>  
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
> -		RR(OVL_BA0(i));
> -		RR(OVL_BA1(i));
> -		RR(OVL_POSITION(i));
> -		RR(OVL_SIZE(i));
> -		RR(OVL_ATTRIBUTES(i));
> -		RR(OVL_FIFO_THRESHOLD(i));
> -		RR(OVL_ROW_INC(i));
> -		RR(OVL_PIXEL_INC(i));
> -		if (dispc_has_feature(FEAT_PRELOAD))
> -			RR(OVL_PRELOAD(i));
> +	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
> +		RR(dispc, OVL_BA0(i));
> +		RR(dispc, OVL_BA1(i));
> +		RR(dispc, OVL_POSITION(i));
> +		RR(dispc, OVL_SIZE(i));
> +		RR(dispc, OVL_ATTRIBUTES(i));
> +		RR(dispc, OVL_FIFO_THRESHOLD(i));
> +		RR(dispc, OVL_ROW_INC(i));
> +		RR(dispc, OVL_PIXEL_INC(i));
> +		if (dispc_has_feature(dispc, FEAT_PRELOAD))
> +			RR(dispc, OVL_PRELOAD(i));
>  		if (i == OMAP_DSS_GFX) {
> -			RR(OVL_WINDOW_SKIP(i));
> -			RR(OVL_TABLE_BA(i));
> +			RR(dispc, OVL_WINDOW_SKIP(i));
> +			RR(dispc, OVL_TABLE_BA(i));
>  			continue;
>  		}
> -		RR(OVL_FIR(i));
> -		RR(OVL_PICTURE_SIZE(i));
> -		RR(OVL_ACCU0(i));
> -		RR(OVL_ACCU1(i));
> +		RR(dispc, OVL_FIR(i));
> +		RR(dispc, OVL_PICTURE_SIZE(i));
> +		RR(dispc, OVL_ACCU0(i));
> +		RR(dispc, OVL_ACCU1(i));
>  
>  		for (j = 0; j < 8; j++)
> -			RR(OVL_FIR_COEF_H(i, j));
> +			RR(dispc, OVL_FIR_COEF_H(i, j));
>  
>  		for (j = 0; j < 8; j++)
> -			RR(OVL_FIR_COEF_HV(i, j));
> +			RR(dispc, OVL_FIR_COEF_HV(i, j));
>  
>  		for (j = 0; j < 5; j++)
> -			RR(OVL_CONV_COEF(i, j));
> +			RR(dispc, OVL_CONV_COEF(i, j));
>  
> -		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
> +		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
>  			for (j = 0; j < 8; j++)
> -				RR(OVL_FIR_COEF_V(i, j));
> +				RR(dispc, OVL_FIR_COEF_V(i, j));
>  		}
>  
> -		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
> -			RR(OVL_BA0_UV(i));
> -			RR(OVL_BA1_UV(i));
> -			RR(OVL_FIR2(i));
> -			RR(OVL_ACCU2_0(i));
> -			RR(OVL_ACCU2_1(i));
> +		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
> +			RR(dispc, OVL_BA0_UV(i));
> +			RR(dispc, OVL_BA1_UV(i));
> +			RR(dispc, OVL_FIR2(i));
> +			RR(dispc, OVL_ACCU2_0(i));
> +			RR(dispc, OVL_ACCU2_1(i));
>  
>  			for (j = 0; j < 8; j++)
> -				RR(OVL_FIR_COEF_H2(i, j));
> +				RR(dispc, OVL_FIR_COEF_H2(i, j));
>  
>  			for (j = 0; j < 8; j++)
> -				RR(OVL_FIR_COEF_HV2(i, j));
> +				RR(dispc, OVL_FIR_COEF_HV2(i, j));
>  
>  			for (j = 0; j < 8; j++)
> -				RR(OVL_FIR_COEF_V2(i, j));
> +				RR(dispc, OVL_FIR_COEF_V2(i, j));
>  		}
> -		if (dispc_has_feature(FEAT_ATTR2))
> -			RR(OVL_ATTRIBUTES2(i));
> +		if (dispc_has_feature(dispc, FEAT_ATTR2))
> +			RR(dispc, OVL_ATTRIBUTES2(i));
>  	}
>  
> -	if (dispc_has_feature(FEAT_CORE_CLK_DIV))
> -		RR(DIVISOR);
> +	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
> +		RR(dispc, DIVISOR);
>  
>  	/* enable last, because LCD & DIGIT enable are here */
> -	RR(CONTROL);
> -	if (dispc_has_feature(FEAT_MGR_LCD2))
> -		RR(CONTROL2);
> -	if (dispc_has_feature(FEAT_MGR_LCD3))
> -		RR(CONTROL3);
> +	RR(dispc, CONTROL);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
> +		RR(dispc, CONTROL2);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
> +		RR(dispc, CONTROL3);
>  	/* clear spurious SYNC_LOST_DIGIT interrupts */
> -	dispc_clear_irqstatus(&dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
> +	dispc_clear_irqstatus(dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
>  
>  	/*
>  	 * enable last so IRQs won't trigger before
>  	 * the context is fully restored
>  	 */
> -	RR(IRQENABLE);
> +	RR(dispc, IRQENABLE);
>  
>  	DSSDBG("context restored\n");
>  }
> @@ -714,21 +725,21 @@ u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
>  static void dispc_mgr_enable(struct dispc_device *dispc,
>  			     enum omap_channel channel, bool enable)
>  {
> -	mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
>  	/* flush posted write */
> -	mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
> +	mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
>  }
>  
>  static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
>  				 enum omap_channel channel)
>  {
> -	return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE);
> +	return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
>  }
>  
>  static bool dispc_mgr_go_busy(struct dispc_device *dispc,
>  			      enum omap_channel channel)
>  {
> -	return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1;
> +	return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
>  }
>  
>  static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
> @@ -738,12 +749,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
>  
>  	DSSDBG("GO %s\n", mgr_desc[channel].name);
>  
> -	mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
>  }
>  
>  bool dispc_wb_go_busy(struct dispc_device *dispc)
>  {
> -	return REG_GET(DISPC_CONTROL2, 6, 6) == 1;
> +	return REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
>  }
>  
>  void dispc_wb_go(struct dispc_device *dispc)
> @@ -751,65 +762,72 @@ void dispc_wb_go(struct dispc_device *dispc)
>  	enum omap_plane_id plane = OMAP_DSS_WB;
>  	bool enable, go;
>  
> -	enable = REG_GET(DISPC_OVL_ATTRIBUTES(plane), 0, 0) == 1;
> +	enable = REG_GET(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 0) == 1;
>  
>  	if (!enable)
>  		return;
>  
> -	go = REG_GET(DISPC_CONTROL2, 6, 6) == 1;
> +	go = REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
>  	if (go) {
>  		DSSERR("GO bit not down for WB\n");
>  		return;
>  	}
>  
> -	REG_FLD_MOD(DISPC_CONTROL2, 1, 6, 6);
> +	REG_FLD_MOD(dispc, DISPC_CONTROL2, 1, 6, 6);
>  }
>  
> -static void dispc_ovl_write_firh_reg(enum omap_plane_id plane, int reg,
> +static void dispc_ovl_write_firh_reg(struct dispc_device *dispc,
> +				     enum omap_plane_id plane, int reg,
>  				     u32 value)
>  {
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_H(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H(plane, reg), value);
>  }
>  
> -static void dispc_ovl_write_firhv_reg(enum omap_plane_id plane, int reg,
> +static void dispc_ovl_write_firhv_reg(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int reg,
>  				      u32 value)
>  {
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_HV(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV(plane, reg), value);
>  }
>  
> -static void dispc_ovl_write_firv_reg(enum omap_plane_id plane, int reg,
> +static void dispc_ovl_write_firv_reg(struct dispc_device *dispc,
> +				     enum omap_plane_id plane, int reg,
>  				     u32 value)
>  {
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_V(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V(plane, reg), value);
>  }
>  
> -static void dispc_ovl_write_firh2_reg(enum omap_plane_id plane, int reg,
> +static void dispc_ovl_write_firh2_reg(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int reg,
>  				      u32 value)
>  {
>  	BUG_ON(plane == OMAP_DSS_GFX);
>  
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_H2(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H2(plane, reg), value);
>  }
>  
> -static void dispc_ovl_write_firhv2_reg(enum omap_plane_id plane, int reg,
> -		u32 value)
> +static void dispc_ovl_write_firhv2_reg(struct dispc_device *dispc,
> +				       enum omap_plane_id plane, int reg,
> +				       u32 value)
>  {
>  	BUG_ON(plane == OMAP_DSS_GFX);
>  
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
>  }
>  
> -static void dispc_ovl_write_firv2_reg(enum omap_plane_id plane, int reg,
> +static void dispc_ovl_write_firv2_reg(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int reg,
>  				      u32 value)
>  {
>  	BUG_ON(plane == OMAP_DSS_GFX);
>  
> -	dispc_write_reg(DISPC_OVL_FIR_COEF_V2(plane, reg), value);
> +	dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V2(plane, reg), value);
>  }
>  
> -static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
> -				int fir_vinc, int five_taps,
> -				enum omap_color_component color_comp)
> +static void dispc_ovl_set_scale_coef(struct dispc_device *dispc,
> +				     enum omap_plane_id plane, int fir_hinc,
> +				     int fir_vinc, int five_taps,
> +				     enum omap_color_component color_comp)
>  {
>  	const struct dispc_coef *h_coef, *v_coef;
>  	int i;
> @@ -830,11 +848,11 @@ static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
>  			| FLD_VAL(v_coef[i].hc3_vc2, 31, 24);
>  
>  		if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
> -			dispc_ovl_write_firh_reg(plane, i, h);
> -			dispc_ovl_write_firhv_reg(plane, i, hv);
> +			dispc_ovl_write_firh_reg(dispc, plane, i, h);
> +			dispc_ovl_write_firhv_reg(dispc, plane, i, hv);
>  		} else {
> -			dispc_ovl_write_firh2_reg(plane, i, h);
> -			dispc_ovl_write_firhv2_reg(plane, i, hv);
> +			dispc_ovl_write_firh2_reg(dispc, plane, i, h);
> +			dispc_ovl_write_firhv2_reg(dispc, plane, i, hv);
>  		}
>  
>  	}
> @@ -845,34 +863,35 @@ static void dispc_ovl_set_scale_coef(enum omap_plane_id plane, int fir_hinc,
>  			v = FLD_VAL(v_coef[i].hc0_vc00, 7, 0)
>  				| FLD_VAL(v_coef[i].hc4_vc22, 15, 8);
>  			if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y)
> -				dispc_ovl_write_firv_reg(plane, i, v);
> +				dispc_ovl_write_firv_reg(dispc, plane, i, v);
>  			else
> -				dispc_ovl_write_firv2_reg(plane, i, v);
> +				dispc_ovl_write_firv2_reg(dispc, plane, i, v);
>  		}
>  	}
>  }
>  
>  
> -static void dispc_ovl_write_color_conv_coef(enum omap_plane_id plane,
> -		const struct color_conv_coef *ct)
> +static void dispc_ovl_write_color_conv_coef(struct dispc_device *dispc,
> +					    enum omap_plane_id plane,
> +					    const struct color_conv_coef *ct)
>  {
>  #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
>  
> -	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->rcr, ct->ry));
> -	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->gy,  ct->rcb));
> -	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->gcb, ct->gcr));
> -	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->bcr, ct->by));
> -	dispc_write_reg(DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->bcb));
> +	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->rcr, ct->ry));
> +	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->gy,  ct->rcb));
> +	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->gcb, ct->gcr));
> +	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->bcr, ct->by));
> +	dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->bcb));
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
>  
>  #undef CVAL
>  }
>  
> -static void dispc_setup_color_conv_coef(void)
> +static void dispc_setup_color_conv_coef(struct dispc_device *dispc)
>  {
>  	int i;
> -	int num_ovl = dispc_get_num_ovls(&dispc);
> +	int num_ovl = dispc_get_num_ovls(dispc);
>  	const struct color_conv_coef ctbl_bt601_5_ovl = {
>  		/* YUV -> RGB */
>  		298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
> @@ -883,34 +902,40 @@ static void dispc_setup_color_conv_coef(void)
>  	};
>  
>  	for (i = 1; i < num_ovl; i++)
> -		dispc_ovl_write_color_conv_coef(i, &ctbl_bt601_5_ovl);
> +		dispc_ovl_write_color_conv_coef(dispc, i, &ctbl_bt601_5_ovl);
>  
> -	if (dispc.feat->has_writeback)
> -		dispc_ovl_write_color_conv_coef(OMAP_DSS_WB, &ctbl_bt601_5_wb);
> +	if (dispc->feat->has_writeback)
> +		dispc_ovl_write_color_conv_coef(dispc, OMAP_DSS_WB,
> +						&ctbl_bt601_5_wb);
>  }
>  
> -static void dispc_ovl_set_ba0(enum omap_plane_id plane, u32 paddr)
> +static void dispc_ovl_set_ba0(struct dispc_device *dispc,
> +			      enum omap_plane_id plane, u32 paddr)
>  {
> -	dispc_write_reg(DISPC_OVL_BA0(plane), paddr);
> +	dispc_write_reg(dispc, DISPC_OVL_BA0(plane), paddr);
>  }
>  
> -static void dispc_ovl_set_ba1(enum omap_plane_id plane, u32 paddr)
> +static void dispc_ovl_set_ba1(struct dispc_device *dispc,
> +			      enum omap_plane_id plane, u32 paddr)
>  {
> -	dispc_write_reg(DISPC_OVL_BA1(plane), paddr);
> +	dispc_write_reg(dispc, DISPC_OVL_BA1(plane), paddr);
>  }
>  
> -static void dispc_ovl_set_ba0_uv(enum omap_plane_id plane, u32 paddr)
> +static void dispc_ovl_set_ba0_uv(struct dispc_device *dispc,
> +				 enum omap_plane_id plane, u32 paddr)
>  {
> -	dispc_write_reg(DISPC_OVL_BA0_UV(plane), paddr);
> +	dispc_write_reg(dispc, DISPC_OVL_BA0_UV(plane), paddr);
>  }
>  
> -static void dispc_ovl_set_ba1_uv(enum omap_plane_id plane, u32 paddr)
> +static void dispc_ovl_set_ba1_uv(struct dispc_device *dispc,
> +				 enum omap_plane_id plane, u32 paddr)
>  {
> -	dispc_write_reg(DISPC_OVL_BA1_UV(plane), paddr);
> +	dispc_write_reg(dispc, DISPC_OVL_BA1_UV(plane), paddr);
>  }
>  
> -static void dispc_ovl_set_pos(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, int x, int y)
> +static void dispc_ovl_set_pos(struct dispc_device *dispc,
> +			      enum omap_plane_id plane,
> +			      enum omap_overlay_caps caps, int x, int y)
>  {
>  	u32 val;
>  
> @@ -919,22 +944,24 @@ static void dispc_ovl_set_pos(enum omap_plane_id plane,
>  
>  	val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0);
>  
> -	dispc_write_reg(DISPC_OVL_POSITION(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_POSITION(plane), val);
>  }
>  
> -static void dispc_ovl_set_input_size(enum omap_plane_id plane, int width,
> -		int height)
> +static void dispc_ovl_set_input_size(struct dispc_device *dispc,
> +				     enum omap_plane_id plane, int width,
> +				     int height)
>  {
>  	u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
>  
>  	if (plane == OMAP_DSS_GFX || plane == OMAP_DSS_WB)
> -		dispc_write_reg(DISPC_OVL_SIZE(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
>  	else
> -		dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
>  }
>  
> -static void dispc_ovl_set_output_size(enum omap_plane_id plane, int width,
> -		int height)
> +static void dispc_ovl_set_output_size(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int width,
> +				      int height)
>  {
>  	u32 val;
>  
> @@ -943,42 +970,47 @@ static void dispc_ovl_set_output_size(enum omap_plane_id plane, int width,
>  	val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
>  
>  	if (plane == OMAP_DSS_WB)
> -		dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
>  	else
> -		dispc_write_reg(DISPC_OVL_SIZE(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
>  }
>  
> -static void dispc_ovl_set_zorder(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, u8 zorder)
> +static void dispc_ovl_set_zorder(struct dispc_device *dispc,
> +				 enum omap_plane_id plane,
> +				 enum omap_overlay_caps caps, u8 zorder)
>  {
>  	if ((caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
>  		return;
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
>  }
>  
> -static void dispc_ovl_enable_zorder_planes(void)
> +static void dispc_ovl_enable_zorder_planes(struct dispc_device *dispc)
>  {
>  	int i;
>  
> -	if (!dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
> +	if (!dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
>  		return;
>  
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); i++)
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
> +	for (i = 0; i < dispc_get_num_ovls(dispc); i++)
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
>  }
>  
> -static void dispc_ovl_set_pre_mult_alpha(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, bool enable)
> +static void dispc_ovl_set_pre_mult_alpha(struct dispc_device *dispc,
> +					 enum omap_plane_id plane,
> +					 enum omap_overlay_caps caps,
> +					 bool enable)
>  {
>  	if ((caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
>  		return;
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
>  }
>  
> -static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, u8 global_alpha)
> +static void dispc_ovl_setup_global_alpha(struct dispc_device *dispc,
> +					 enum omap_plane_id plane,
> +					 enum omap_overlay_caps caps,
> +					 u8 global_alpha)
>  {
>  	static const unsigned int shifts[] = { 0, 8, 16, 24, };
>  	int shift;
> @@ -987,20 +1019,23 @@ static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
>  		return;
>  
>  	shift = shifts[plane];
> -	REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
> +	REG_FLD_MOD(dispc, DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
>  }
>  
> -static void dispc_ovl_set_pix_inc(enum omap_plane_id plane, s32 inc)
> +static void dispc_ovl_set_pix_inc(struct dispc_device *dispc,
> +				  enum omap_plane_id plane, s32 inc)
>  {
> -	dispc_write_reg(DISPC_OVL_PIXEL_INC(plane), inc);
> +	dispc_write_reg(dispc, DISPC_OVL_PIXEL_INC(plane), inc);
>  }
>  
> -static void dispc_ovl_set_row_inc(enum omap_plane_id plane, s32 inc)
> +static void dispc_ovl_set_row_inc(struct dispc_device *dispc,
> +				  enum omap_plane_id plane, s32 inc)
>  {
> -	dispc_write_reg(DISPC_OVL_ROW_INC(plane), inc);
> +	dispc_write_reg(dispc, DISPC_OVL_ROW_INC(plane), inc);
>  }
>  
> -static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 fourcc)
> +static void dispc_ovl_set_color_mode(struct dispc_device *dispc,
> +				     enum omap_plane_id plane, u32 fourcc)
>  {
>  	u32 m = 0;
>  	if (plane != OMAP_DSS_GFX) {
> @@ -1069,7 +1104,7 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 fourcc)
>  		}
>  	}
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
>  }
>  
>  static bool format_is_yuv(u32 fourcc)
> @@ -1084,19 +1119,21 @@ static bool format_is_yuv(u32 fourcc)
>  	}
>  }
>  
> -static void dispc_ovl_configure_burst_type(enum omap_plane_id plane,
> -		enum omap_dss_rotation_type rotation_type)
> +static void dispc_ovl_configure_burst_type(struct dispc_device *dispc,
> +					   enum omap_plane_id plane,
> +					   enum omap_dss_rotation_type rotation)
>  {
> -	if (dispc_has_feature(FEAT_BURST_2D) == 0)
> +	if (dispc_has_feature(dispc, FEAT_BURST_2D) == 0)
>  		return;
>  
> -	if (rotation_type == OMAP_DSS_ROT_TILER)
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29);
> +	if (rotation == OMAP_DSS_ROT_TILER)
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29);
>  	else
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29);
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29);
>  }
>  
> -static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
> +static void dispc_ovl_set_channel_out(struct dispc_device *dispc,
> +				      enum omap_plane_id plane,
>  				      enum omap_channel channel)
>  {
>  	int shift;
> @@ -1117,8 +1154,8 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
>  		return;
>  	}
>  
> -	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
> -	if (dispc_has_feature(FEAT_MGR_LCD2)) {
> +	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
>  		switch (channel) {
>  		case OMAP_DSS_CHANNEL_LCD:
>  			chan = 0;
> @@ -1133,7 +1170,7 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
>  			chan2 = 1;
>  			break;
>  		case OMAP_DSS_CHANNEL_LCD3:
> -			if (dispc_has_feature(FEAT_MGR_LCD3)) {
> +			if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
>  				chan = 0;
>  				chan2 = 2;
>  			} else {
> @@ -1155,10 +1192,11 @@ static void dispc_ovl_set_channel_out(enum omap_plane_id plane,
>  	} else {
>  		val = FLD_MOD(val, channel, shift, shift);
>  	}
> -	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
>  }
>  
> -static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
> +static enum omap_channel dispc_ovl_get_channel_out(struct dispc_device *dispc,
> +						   enum omap_plane_id plane)
>  {
>  	int shift;
>  	u32 val;
> @@ -1177,12 +1215,12 @@ static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane_id plane)
>  		return 0;
>  	}
>  
> -	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
> +	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
>  
>  	if (FLD_GET(val, shift, shift) == 1)
>  		return OMAP_DSS_CHANNEL_DIGIT;
>  
> -	if (!dispc_has_feature(FEAT_MGR_LCD2))
> +	if (!dispc_has_feature(dispc, FEAT_MGR_LCD2))
>  		return OMAP_DSS_CHANNEL_LCD;
>  
>  	switch (FLD_GET(val, 31, 30)) {
> @@ -1203,43 +1241,47 @@ void dispc_wb_set_channel_in(struct dispc_device *dispc,
>  {
>  	enum omap_plane_id plane = OMAP_DSS_WB;
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), channel, 18, 16);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), channel, 18, 16);
>  }
>  
> -static void dispc_ovl_set_burst_size(enum omap_plane_id plane,
> -		enum omap_burst_size burst_size)
> +static void dispc_ovl_set_burst_size(struct dispc_device *dispc,
> +				     enum omap_plane_id plane,
> +				     enum omap_burst_size burst_size)
>  {
>  	static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
>  	int shift;
>  
>  	shift = shifts[plane];
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), burst_size,
> +		    shift + 1, shift);
>  }
>  
> -static void dispc_configure_burst_sizes(void)
> +static void dispc_configure_burst_sizes(struct dispc_device *dispc)
>  {
>  	int i;
>  	const int burst_size = BURST_SIZE_X8;
>  
>  	/* Configure burst size always to maximum size */
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i)
> -		dispc_ovl_set_burst_size(i, burst_size);
> -	if (dispc.feat->has_writeback)
> -		dispc_ovl_set_burst_size(OMAP_DSS_WB, burst_size);
> +	for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
> +		dispc_ovl_set_burst_size(dispc, i, burst_size);
> +	if (dispc->feat->has_writeback)
> +		dispc_ovl_set_burst_size(dispc, OMAP_DSS_WB, burst_size);
>  }
>  
> -static u32 dispc_ovl_get_burst_size(enum omap_plane_id plane)
> +static u32 dispc_ovl_get_burst_size(struct dispc_device *dispc,
> +				    enum omap_plane_id plane)
>  {
>  	/* burst multiplier is always x8 (see dispc_configure_burst_sizes()) */
> -	return dispc.feat->burst_size_unit * 8;
> +	return dispc->feat->burst_size_unit * 8;
>  }
>  
> -static bool dispc_ovl_color_mode_supported(enum omap_plane_id plane, u32 fourcc)
> +static bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
> +					   enum omap_plane_id plane, u32 fourcc)
>  {
>  	const u32 *modes;
>  	unsigned int i;
>  
> -	modes = dispc.feat->supported_color_modes[plane];
> +	modes = dispc->feat->supported_color_modes[plane];
>  
>  	for (i = 0; modes[i]; ++i) {
>  		if (modes[i] == fourcc)
> @@ -1255,16 +1297,18 @@ static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
>  	return dispc->feat->supported_color_modes[plane];
>  }
>  
> -static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable)
> +static void dispc_mgr_enable_cpr(struct dispc_device *dispc,
> +				 enum omap_channel channel, bool enable)
>  {
>  	if (channel == OMAP_DSS_CHANNEL_DIGIT)
>  		return;
>  
> -	mgr_fld_write(channel, DISPC_MGR_FLD_CPR, enable);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_CPR, enable);
>  }
>  
> -static void dispc_mgr_set_cpr_coef(enum omap_channel channel,
> -		const struct omap_dss_cpr_coefs *coefs)
> +static void dispc_mgr_set_cpr_coef(struct dispc_device *dispc,
> +				   enum omap_channel channel,
> +				   const struct omap_dss_cpr_coefs *coefs)
>  {
>  	u32 coef_r, coef_g, coef_b;
>  
> @@ -1278,25 +1322,27 @@ static void dispc_mgr_set_cpr_coef(enum omap_channel channel,
>  	coef_b = FLD_VAL(coefs->br, 31, 22) | FLD_VAL(coefs->bg, 20, 11) |
>  		FLD_VAL(coefs->bb, 9, 0);
>  
> -	dispc_write_reg(DISPC_CPR_COEF_R(channel), coef_r);
> -	dispc_write_reg(DISPC_CPR_COEF_G(channel), coef_g);
> -	dispc_write_reg(DISPC_CPR_COEF_B(channel), coef_b);
> +	dispc_write_reg(dispc, DISPC_CPR_COEF_R(channel), coef_r);
> +	dispc_write_reg(dispc, DISPC_CPR_COEF_G(channel), coef_g);
> +	dispc_write_reg(dispc, DISPC_CPR_COEF_B(channel), coef_b);
>  }
>  
> -static void dispc_ovl_set_vid_color_conv(enum omap_plane_id plane,
> -					 bool enable)
> +static void dispc_ovl_set_vid_color_conv(struct dispc_device *dispc,
> +					 enum omap_plane_id plane, bool enable)
>  {
>  	u32 val;
>  
>  	BUG_ON(plane == OMAP_DSS_GFX);
>  
> -	val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
> +	val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
>  	val = FLD_MOD(val, enable, 9, 9);
> -	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
>  }
>  
> -static void dispc_ovl_enable_replication(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, bool enable)
> +static void dispc_ovl_enable_replication(struct dispc_device *dispc,
> +					 enum omap_plane_id plane,
> +					 enum omap_overlay_caps caps,
> +					 bool enable)
>  {
>  	static const unsigned int shifts[] = { 5, 10, 10, 10 };
>  	int shift;
> @@ -1305,21 +1351,21 @@ static void dispc_ovl_enable_replication(enum omap_plane_id plane,
>  		return;
>  
>  	shift = shifts[plane];
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
>  }
>  
> -static void dispc_mgr_set_size(enum omap_channel channel, u16 width,
> -		u16 height)
> +static void dispc_mgr_set_size(struct dispc_device *dispc,
> +			       enum omap_channel channel, u16 width, u16 height)
>  {
>  	u32 val;
>  
> -	val = FLD_VAL(height - 1, dispc.feat->mgr_height_start, 16) |
> -		FLD_VAL(width - 1, dispc.feat->mgr_width_start, 0);
> +	val = FLD_VAL(height - 1, dispc->feat->mgr_height_start, 16) |
> +		FLD_VAL(width - 1, dispc->feat->mgr_width_start, 0);
>  
> -	dispc_write_reg(DISPC_SIZE_MGR(channel), val);
> +	dispc_write_reg(dispc, DISPC_SIZE_MGR(channel), val);
>  }
>  
> -static void dispc_init_fifos(void)
> +static void dispc_init_fifos(struct dispc_device *dispc)
>  {
>  	u32 size;
>  	int fifo;
> @@ -1327,20 +1373,21 @@ static void dispc_init_fifos(void)
>  	u32 unit;
>  	int i;
>  
> -	unit = dispc.feat->buffer_size_unit;
> +	unit = dispc->feat->buffer_size_unit;
>  
> -	dispc_get_reg_field(FEAT_REG_FIFOSIZE, &start, &end);
> +	dispc_get_reg_field(dispc, FEAT_REG_FIFOSIZE, &start, &end);
>  
> -	for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
> -		size = REG_GET(DISPC_OVL_FIFO_SIZE_STATUS(fifo), start, end);
> +	for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
> +		size = REG_GET(dispc, DISPC_OVL_FIFO_SIZE_STATUS(fifo),
> +			       start, end);
>  		size *= unit;
> -		dispc.fifo_size[fifo] = size;
> +		dispc->fifo_size[fifo] = size;
>  
>  		/*
>  		 * By default fifos are mapped directly to overlays, fifo 0 to
>  		 * ovl 0, fifo 1 to ovl 1, etc.
>  		 */
> -		dispc.fifo_assignment[fifo] = fifo;
> +		dispc->fifo_assignment[fifo] = fifo;
>  	}
>  
>  	/*
> @@ -1350,57 +1397,58 @@ static void dispc_init_fifos(void)
>  	 * giving GFX plane a larger fifo. WB but should work fine with a
>  	 * smaller fifo.
>  	 */
> -	if (dispc.feat->gfx_fifo_workaround) {
> +	if (dispc->feat->gfx_fifo_workaround) {
>  		u32 v;
>  
> -		v = dispc_read_reg(DISPC_GLOBAL_BUFFER);
> +		v = dispc_read_reg(dispc, DISPC_GLOBAL_BUFFER);
>  
>  		v = FLD_MOD(v, 4, 2, 0); /* GFX BUF top to WB */
>  		v = FLD_MOD(v, 4, 5, 3); /* GFX BUF bottom to WB */
>  		v = FLD_MOD(v, 0, 26, 24); /* WB BUF top to GFX */
>  		v = FLD_MOD(v, 0, 29, 27); /* WB BUF bottom to GFX */
>  
> -		dispc_write_reg(DISPC_GLOBAL_BUFFER, v);
> +		dispc_write_reg(dispc, DISPC_GLOBAL_BUFFER, v);
>  
> -		dispc.fifo_assignment[OMAP_DSS_GFX] = OMAP_DSS_WB;
> -		dispc.fifo_assignment[OMAP_DSS_WB] = OMAP_DSS_GFX;
> +		dispc->fifo_assignment[OMAP_DSS_GFX] = OMAP_DSS_WB;
> +		dispc->fifo_assignment[OMAP_DSS_WB] = OMAP_DSS_GFX;
>  	}
>  
>  	/*
>  	 * Setup default fifo thresholds.
>  	 */
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
> +	for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
>  		u32 low, high;
>  		const bool use_fifomerge = false;
>  		const bool manual_update = false;
>  
> -		dispc_ovl_compute_fifo_thresholds(&dispc, i, &low, &high,
> -			use_fifomerge, manual_update);
> +		dispc_ovl_compute_fifo_thresholds(dispc, i, &low, &high,
> +						  use_fifomerge, manual_update);
>  
> -		dispc_ovl_set_fifo_threshold(&dispc, i, low, high);
> +		dispc_ovl_set_fifo_threshold(dispc, i, low, high);
>  	}
>  
> -	if (dispc.feat->has_writeback) {
> +	if (dispc->feat->has_writeback) {
>  		u32 low, high;
>  		const bool use_fifomerge = false;
>  		const bool manual_update = false;
>  
> -		dispc_ovl_compute_fifo_thresholds(&dispc, OMAP_DSS_WB,
> -						  &low, &high,
> -						  use_fifomerge, manual_update);
> +		dispc_ovl_compute_fifo_thresholds(dispc, OMAP_DSS_WB,
> +						  &low, &high, use_fifomerge,
> +						  manual_update);
>  
> -		dispc_ovl_set_fifo_threshold(&dispc, OMAP_DSS_WB, low, high);
> +		dispc_ovl_set_fifo_threshold(dispc, OMAP_DSS_WB, low, high);
>  	}
>  }
>  
> -static u32 dispc_ovl_get_fifo_size(enum omap_plane_id plane)
> +static u32 dispc_ovl_get_fifo_size(struct dispc_device *dispc,
> +				   enum omap_plane_id plane)
>  {
>  	int fifo;
>  	u32 size = 0;
>  
> -	for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
> -		if (dispc.fifo_assignment[fifo] == plane)
> -			size += dispc.fifo_size[fifo];
> +	for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
> +		if (dispc->fifo_assignment[fifo] == plane)
> +			size += dispc->fifo_size[fifo];
>  	}
>  
>  	return size;
> @@ -1421,18 +1469,20 @@ void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
>  	low /= unit;
>  	high /= unit;
>  
> -	dispc_get_reg_field(FEAT_REG_FIFOHIGHTHRESHOLD, &hi_start, &hi_end);
> -	dispc_get_reg_field(FEAT_REG_FIFOLOWTHRESHOLD, &lo_start, &lo_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_FIFOHIGHTHRESHOLD,
> +			    &hi_start, &hi_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_FIFOLOWTHRESHOLD,
> +			    &lo_start, &lo_end);
>  
>  	DSSDBG("fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n",
>  			plane,
> -			REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
> +			REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
>  				lo_start, lo_end) * unit,
> -			REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane),
> +			REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
>  				hi_start, hi_end) * unit,
>  			low * unit, high * unit);
>  
> -	dispc_write_reg(DISPC_OVL_FIFO_THRESHOLD(plane),
> +	dispc_write_reg(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
>  			FLD_VAL(high, hi_start, hi_end) |
>  			FLD_VAL(low, lo_start, lo_end));
>  
> @@ -1441,20 +1491,20 @@ void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
>  	 * large for the preload field, set the threshold to the maximum value
>  	 * that can be held by the preload register
>  	 */
> -	if (dispc_has_feature(FEAT_PRELOAD) && dispc->feat->set_max_preload &&
> -			plane != OMAP_DSS_WB)
> -		dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
> +	if (dispc_has_feature(dispc, FEAT_PRELOAD) &&
> +	    dispc->feat->set_max_preload && plane != OMAP_DSS_WB)
> +		dispc_write_reg(dispc, DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
>  }
>  
>  void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
>  {
> -	if (!dispc_has_feature(FEAT_FIFO_MERGE)) {
> +	if (!dispc_has_feature(dispc, FEAT_FIFO_MERGE)) {
>  		WARN_ON(enable);
>  		return;
>  	}
>  
>  	DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
> -	REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
> +	REG_FLD_MOD(dispc, DISPC_CONFIG, enable ? 1 : 0, 14, 14);
>  }
>  
>  void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
> @@ -1470,13 +1520,13 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
>  	unsigned int ovl_fifo_size, total_fifo_size, burst_size;
>  	int i;
>  
> -	burst_size = dispc_ovl_get_burst_size(plane);
> -	ovl_fifo_size = dispc_ovl_get_fifo_size(plane);
> +	burst_size = dispc_ovl_get_burst_size(dispc, plane);
> +	ovl_fifo_size = dispc_ovl_get_fifo_size(dispc, plane);
>  
>  	if (use_fifomerge) {
>  		total_fifo_size = 0;
>  		for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
> -			total_fifo_size += dispc_ovl_get_fifo_size(i);
> +			total_fifo_size += dispc_ovl_get_fifo_size(dispc, i);
>  	} else {
>  		total_fifo_size = ovl_fifo_size;
>  	}
> @@ -1487,7 +1537,7 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
>  	 * combined fifo size
>  	 */
>  
> -	if (manual_update && dispc_has_feature(FEAT_OMAP3_DSI_FIFO_BUG)) {
> +	if (manual_update && dispc_has_feature(dispc, FEAT_OMAP3_DSI_FIFO_BUG)) {
>  		*fifo_low = ovl_fifo_size - burst_size * 2;
>  		*fifo_high = total_fifo_size - burst_size;
>  	} else if (plane == OMAP_DSS_WB) {
> @@ -1504,7 +1554,8 @@ void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
>  	}
>  }
>  
> -static void dispc_ovl_set_mflag(enum omap_plane_id plane, bool enable)
> +static void dispc_ovl_set_mflag(struct dispc_device *dispc,
> +				enum omap_plane_id plane, bool enable)
>  {
>  	int bit;
>  
> @@ -1513,17 +1564,18 @@ static void dispc_ovl_set_mflag(enum omap_plane_id plane, bool enable)
>  	else
>  		bit = 23;
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit);
>  }
>  
> -static void dispc_ovl_set_mflag_threshold(enum omap_plane_id plane,
> -	int low, int high)
> +static void dispc_ovl_set_mflag_threshold(struct dispc_device *dispc,
> +					  enum omap_plane_id plane,
> +					  int low, int high)
>  {
> -	dispc_write_reg(DISPC_OVL_MFLAG_THRESHOLD(plane),
> +	dispc_write_reg(dispc, DISPC_OVL_MFLAG_THRESHOLD(plane),
>  		FLD_VAL(high, 31, 16) |	FLD_VAL(low, 15, 0));
>  }
>  
> -static void dispc_init_mflag(void)
> +static void dispc_init_mflag(struct dispc_device *dispc)
>  {
>  	int i;
>  
> @@ -1537,16 +1589,16 @@ static void dispc_init_mflag(void)
>  	 *
>  	 * As a work-around, set force MFLAG to always on.
>  	 */
> -	dispc_write_reg(DISPC_GLOBAL_MFLAG_ATTRIBUTE,
> +	dispc_write_reg(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE,
>  		(1 << 0) |	/* MFLAG_CTRL = force always on */
>  		(0 << 2));	/* MFLAG_START = disable */
>  
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); ++i) {
> -		u32 size = dispc_ovl_get_fifo_size(i);
> -		u32 unit = dispc.feat->buffer_size_unit;
> +	for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
> +		u32 size = dispc_ovl_get_fifo_size(dispc, i);
> +		u32 unit = dispc->feat->buffer_size_unit;
>  		u32 low, high;
>  
> -		dispc_ovl_set_mflag(i, true);
> +		dispc_ovl_set_mflag(dispc, i, true);
>  
>  		/*
>  		 * Simulation team suggests below thesholds:
> @@ -1557,15 +1609,15 @@ static void dispc_init_mflag(void)
>  		low = size * 4 / 8 / unit;
>  		high = size * 5 / 8 / unit;
>  
> -		dispc_ovl_set_mflag_threshold(i, low, high);
> +		dispc_ovl_set_mflag_threshold(dispc, i, low, high);
>  	}
>  
> -	if (dispc.feat->has_writeback) {
> -		u32 size = dispc_ovl_get_fifo_size(OMAP_DSS_WB);
> -		u32 unit = dispc.feat->buffer_size_unit;
> +	if (dispc->feat->has_writeback) {
> +		u32 size = dispc_ovl_get_fifo_size(dispc, OMAP_DSS_WB);
> +		u32 unit = dispc->feat->buffer_size_unit;
>  		u32 low, high;
>  
> -		dispc_ovl_set_mflag(OMAP_DSS_WB, true);
> +		dispc_ovl_set_mflag(dispc, OMAP_DSS_WB, true);
>  
>  		/*
>  		 * Simulation team suggests below thesholds:
> @@ -1576,98 +1628,112 @@ static void dispc_init_mflag(void)
>  		low = size * 4 / 8 / unit;
>  		high = size * 5 / 8 / unit;
>  
> -		dispc_ovl_set_mflag_threshold(OMAP_DSS_WB, low, high);
> +		dispc_ovl_set_mflag_threshold(dispc, OMAP_DSS_WB, low, high);
>  	}
>  }
>  
> -static void dispc_ovl_set_fir(enum omap_plane_id plane,
> -				int hinc, int vinc,
> -				enum omap_color_component color_comp)
> +static void dispc_ovl_set_fir(struct dispc_device *dispc,
> +			      enum omap_plane_id plane,
> +			      int hinc, int vinc,
> +			      enum omap_color_component color_comp)
>  {
>  	u32 val;
>  
>  	if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
>  		u8 hinc_start, hinc_end, vinc_start, vinc_end;
>  
> -		dispc_get_reg_field(FEAT_REG_FIRHINC, &hinc_start, &hinc_end);
> -		dispc_get_reg_field(FEAT_REG_FIRVINC, &vinc_start, &vinc_end);
> +		dispc_get_reg_field(dispc, FEAT_REG_FIRHINC,
> +				    &hinc_start, &hinc_end);
> +		dispc_get_reg_field(dispc, FEAT_REG_FIRVINC,
> +				    &vinc_start, &vinc_end);
>  		val = FLD_VAL(vinc, vinc_start, vinc_end) |
>  				FLD_VAL(hinc, hinc_start, hinc_end);
>  
> -		dispc_write_reg(DISPC_OVL_FIR(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_FIR(plane), val);
>  	} else {
>  		val = FLD_VAL(vinc, 28, 16) | FLD_VAL(hinc, 12, 0);
> -		dispc_write_reg(DISPC_OVL_FIR2(plane), val);
> +		dispc_write_reg(dispc, DISPC_OVL_FIR2(plane), val);
>  	}
>  }
>  
> -static void dispc_ovl_set_vid_accu0(enum omap_plane_id plane, int haccu,
> +static void dispc_ovl_set_vid_accu0(struct dispc_device *dispc,
> +				    enum omap_plane_id plane, int haccu,
>  				    int vaccu)
>  {
>  	u32 val;
>  	u8 hor_start, hor_end, vert_start, vert_end;
>  
> -	dispc_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
> -	dispc_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
> +			    &hor_start, &hor_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
> +			    &vert_start, &vert_end);
>  
>  	val = FLD_VAL(vaccu, vert_start, vert_end) |
>  			FLD_VAL(haccu, hor_start, hor_end);
>  
> -	dispc_write_reg(DISPC_OVL_ACCU0(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ACCU0(plane), val);
>  }
>  
> -static void dispc_ovl_set_vid_accu1(enum omap_plane_id plane, int haccu,
> +static void dispc_ovl_set_vid_accu1(struct dispc_device *dispc,
> +				    enum omap_plane_id plane, int haccu,
>  				    int vaccu)
>  {
>  	u32 val;
>  	u8 hor_start, hor_end, vert_start, vert_end;
>  
> -	dispc_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end);
> -	dispc_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
> +			    &hor_start, &hor_end);
> +	dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
> +			    &vert_start, &vert_end);
>  
>  	val = FLD_VAL(vaccu, vert_start, vert_end) |
>  			FLD_VAL(haccu, hor_start, hor_end);
>  
> -	dispc_write_reg(DISPC_OVL_ACCU1(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ACCU1(plane), val);
>  }
>  
> -static void dispc_ovl_set_vid_accu2_0(enum omap_plane_id plane, int haccu,
> -		int vaccu)
> +static void dispc_ovl_set_vid_accu2_0(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int haccu,
> +				      int vaccu)
>  {
>  	u32 val;
>  
>  	val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
> -	dispc_write_reg(DISPC_OVL_ACCU2_0(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ACCU2_0(plane), val);
>  }
>  
> -static void dispc_ovl_set_vid_accu2_1(enum omap_plane_id plane, int haccu,
> -		int vaccu)
> +static void dispc_ovl_set_vid_accu2_1(struct dispc_device *dispc,
> +				      enum omap_plane_id plane, int haccu,
> +				      int vaccu)
>  {
>  	u32 val;
>  
>  	val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
> -	dispc_write_reg(DISPC_OVL_ACCU2_1(plane), val);
> +	dispc_write_reg(dispc, DISPC_OVL_ACCU2_1(plane), val);
>  }
>  
> -static void dispc_ovl_set_scale_param(enum omap_plane_id plane,
> -		u16 orig_width, u16 orig_height,
> -		u16 out_width, u16 out_height,
> -		bool five_taps, u8 rotation,
> -		enum omap_color_component color_comp)
> +static void dispc_ovl_set_scale_param(struct dispc_device *dispc,
> +				      enum omap_plane_id plane,
> +				      u16 orig_width, u16 orig_height,
> +				      u16 out_width, u16 out_height,
> +				      bool five_taps, u8 rotation,
> +				      enum omap_color_component color_comp)
>  {
>  	int fir_hinc, fir_vinc;
>  
>  	fir_hinc = 1024 * orig_width / out_width;
>  	fir_vinc = 1024 * orig_height / out_height;
>  
> -	dispc_ovl_set_scale_coef(plane, fir_hinc, fir_vinc, five_taps,
> -				color_comp);
> -	dispc_ovl_set_fir(plane, fir_hinc, fir_vinc, color_comp);
> +	dispc_ovl_set_scale_coef(dispc, plane, fir_hinc, fir_vinc, five_taps,
> +				 color_comp);
> +	dispc_ovl_set_fir(dispc, plane, fir_hinc, fir_vinc, color_comp);
>  }
>  
> -static void dispc_ovl_set_accu_uv(enum omap_plane_id plane,
> -		u16 orig_width,	u16 orig_height, u16 out_width, u16 out_height,
> -		bool ilace, u32 fourcc, u8 rotation)
> +static void dispc_ovl_set_accu_uv(struct dispc_device *dispc,
> +				  enum omap_plane_id plane,
> +				  u16 orig_width, u16 orig_height,
> +				  u16 out_width, u16 out_height,
> +				  bool ilace, u32 fourcc, u8 rotation)
>  {
>  	int h_accu2_0, h_accu2_1;
>  	int v_accu2_0, v_accu2_1;
> @@ -1748,25 +1814,26 @@ static void dispc_ovl_set_accu_uv(enum omap_plane_id plane,
>  	v_accu2_0 = (accu_val->v0_m * chroma_vinc / accu_val->v0_n) % 1024;
>  	v_accu2_1 = (accu_val->v1_m * chroma_vinc / accu_val->v1_n) % 1024;
>  
> -	dispc_ovl_set_vid_accu2_0(plane, h_accu2_0, v_accu2_0);
> -	dispc_ovl_set_vid_accu2_1(plane, h_accu2_1, v_accu2_1);
> +	dispc_ovl_set_vid_accu2_0(dispc, plane, h_accu2_0, v_accu2_0);
> +	dispc_ovl_set_vid_accu2_1(dispc, plane, h_accu2_1, v_accu2_1);
>  }
>  
> -static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
> -		u16 orig_width, u16 orig_height,
> -		u16 out_width, u16 out_height,
> -		bool ilace, bool five_taps,
> -		bool fieldmode, u32 fourcc,
> -		u8 rotation)
> +static void dispc_ovl_set_scaling_common(struct dispc_device *dispc,
> +					 enum omap_plane_id plane,
> +					 u16 orig_width, u16 orig_height,
> +					 u16 out_width, u16 out_height,
> +					 bool ilace, bool five_taps,
> +					 bool fieldmode, u32 fourcc,
> +					 u8 rotation)
>  {
>  	int accu0 = 0;
>  	int accu1 = 0;
>  	u32 l;
>  
> -	dispc_ovl_set_scale_param(plane, orig_width, orig_height,
> -				out_width, out_height, five_taps,
> -				rotation, DISPC_COLOR_COMPONENT_RGB_Y);
> -	l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
> +	dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
> +				  out_width, out_height, five_taps,
> +				  rotation, DISPC_COLOR_COMPONENT_RGB_Y);
> +	l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
>  
>  	/* RESIZEENABLE and VERTICALTAPS */
>  	l &= ~((0x3 << 5) | (0x1 << 21));
> @@ -1775,19 +1842,19 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
>  	l |= five_taps ? (1 << 21) : 0;
>  
>  	/* VRESIZECONF and HRESIZECONF */
> -	if (dispc_has_feature(FEAT_RESIZECONF)) {
> +	if (dispc_has_feature(dispc, FEAT_RESIZECONF)) {
>  		l &= ~(0x3 << 7);
>  		l |= (orig_width <= out_width) ? 0 : (1 << 7);
>  		l |= (orig_height <= out_height) ? 0 : (1 << 8);
>  	}
>  
>  	/* LINEBUFFERSPLIT */
> -	if (dispc_has_feature(FEAT_LINEBUFFERSPLIT)) {
> +	if (dispc_has_feature(dispc, FEAT_LINEBUFFERSPLIT)) {
>  		l &= ~(0x1 << 22);
>  		l |= five_taps ? (1 << 22) : 0;
>  	}
>  
> -	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l);
> +	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
>  
>  	/*
>  	 * field 0 = even field = bottom field
> @@ -1802,33 +1869,35 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane,
>  		}
>  	}
>  
> -	dispc_ovl_set_vid_accu0(plane, 0, accu0);
> -	dispc_ovl_set_vid_accu1(plane, 0, accu1);
> +	dispc_ovl_set_vid_accu0(dispc, plane, 0, accu0);
> +	dispc_ovl_set_vid_accu1(dispc, plane, 0, accu1);
>  }
>  
> -static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane,
> -		u16 orig_width, u16 orig_height,
> -		u16 out_width, u16 out_height,
> -		bool ilace, bool five_taps,
> -		bool fieldmode, u32 fourcc,
> -		u8 rotation)
> +static void dispc_ovl_set_scaling_uv(struct dispc_device *dispc,
> +				     enum omap_plane_id plane,
> +				     u16 orig_width, u16 orig_height,
> +				     u16 out_width, u16 out_height,
> +				     bool ilace, bool five_taps,
> +				     bool fieldmode, u32 fourcc,
> +				     u8 rotation)
>  {
>  	int scale_x = out_width != orig_width;
>  	int scale_y = out_height != orig_height;
>  	bool chroma_upscale = plane != OMAP_DSS_WB;
>  
> -	if (!dispc_has_feature(FEAT_HANDLE_UV_SEPARATE))
> +	if (!dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE))
>  		return;
>  
>  	if (!format_is_yuv(fourcc)) {
>  		/* reset chroma resampling for RGB formats  */
>  		if (plane != OMAP_DSS_WB)
> -			REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 8, 8);
> +			REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
> +				    0, 8, 8);
>  		return;
>  	}
>  
> -	dispc_ovl_set_accu_uv(plane, orig_width, orig_height, out_width,
> -			out_height, ilace, fourcc, rotation);
> +	dispc_ovl_set_accu_uv(dispc, plane, orig_width, orig_height, out_width,
> +			      out_height, ilace, fourcc, rotation);
>  
>  	switch (fourcc) {
>  	case DRM_FORMAT_NV12:
> @@ -1870,46 +1939,43 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane,
>  	if (out_height != orig_height)
>  		scale_y = true;
>  
> -	dispc_ovl_set_scale_param(plane, orig_width, orig_height,
> -			out_width, out_height, five_taps,
> -				rotation, DISPC_COLOR_COMPONENT_UV);
> +	dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
> +				  out_width, out_height, five_taps,
> +				  rotation, DISPC_COLOR_COMPONENT_UV);
>  
>  	if (plane != OMAP_DSS_WB)
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane),
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
>  			(scale_x || scale_y) ? 1 : 0, 8, 8);
>  
>  	/* set H scaling */
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
>  	/* set V scaling */
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
>  }
>  
> -static void dispc_ovl_set_scaling(enum omap_plane_id plane,
> -		u16 orig_width, u16 orig_height,
> -		u16 out_width, u16 out_height,
> -		bool ilace, bool five_taps,
> -		bool fieldmode, u32 fourcc,
> -		u8 rotation)
> +static void dispc_ovl_set_scaling(struct dispc_device *dispc,
> +				  enum omap_plane_id plane,
> +				  u16 orig_width, u16 orig_height,
> +				  u16 out_width, u16 out_height,
> +				  bool ilace, bool five_taps,
> +				  bool fieldmode, u32 fourcc,
> +				  u8 rotation)
>  {
>  	BUG_ON(plane == OMAP_DSS_GFX);
>  
> -	dispc_ovl_set_scaling_common(plane,
> -			orig_width, orig_height,
> -			out_width, out_height,
> -			ilace, five_taps,
> -			fieldmode, fourcc,
> -			rotation);
> +	dispc_ovl_set_scaling_common(dispc, plane, orig_width, orig_height,
> +				     out_width, out_height, ilace, five_taps,
> +				     fieldmode, fourcc, rotation);
>  
> -	dispc_ovl_set_scaling_uv(plane,
> -		orig_width, orig_height,
> -		out_width, out_height,
> -		ilace, five_taps,
> -		fieldmode, fourcc,
> -		rotation);
> +	dispc_ovl_set_scaling_uv(dispc, plane, orig_width, orig_height,
> +				 out_width, out_height, ilace, five_taps,
> +				 fieldmode, fourcc, rotation);
>  }
>  
> -static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation,
> -		enum omap_dss_rotation_type rotation_type, u32 fourcc)
> +static void dispc_ovl_set_rotation_attrs(struct dispc_device *dispc,
> +					 enum omap_plane_id plane, u8 rotation,
> +					 enum omap_dss_rotation_type rotation_type,
> +					 u32 fourcc)
>  {
>  	bool row_repeat = false;
>  	int vidrot = 0;
> @@ -1963,19 +2029,19 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation,
>  	if (fourcc == DRM_FORMAT_NV12 && rotation_type != OMAP_DSS_ROT_TILER)
>  		vidrot = 1;
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
> -	if (dispc_has_feature(FEAT_ROWREPEATENABLE))
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane),
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
> +	if (dispc_has_feature(dispc, FEAT_ROWREPEATENABLE))
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane),
>  			row_repeat ? 1 : 0, 18, 18);
>  
> -	if (dispc_ovl_color_mode_supported(plane, DRM_FORMAT_NV12)) {
> +	if (dispc_ovl_color_mode_supported(dispc, plane, DRM_FORMAT_NV12)) {
>  		bool doublestride =
>  			fourcc == DRM_FORMAT_NV12 &&
>  			rotation_type == OMAP_DSS_ROT_TILER &&
>  			!drm_rotation_90_or_270(rotation);
>  
>  		/* DOUBLESTRIDE */
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), doublestride, 22, 22);
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), doublestride, 22, 22);
>  	}
>  }
>  
> @@ -2212,27 +2278,31 @@ static unsigned long calc_core_clk_44xx(unsigned long pclk, u16 width,
>  		return pclk;
>  }
>  
> -static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk,
> -		const struct videomode *vm,
> -		u16 width, u16 height, u16 out_width, u16 out_height,
> -		u32 fourcc, bool *five_taps,
> -		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
> -		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
> +static int dispc_ovl_calc_scaling_24xx(struct dispc_device *dispc,
> +				       unsigned long pclk, unsigned long lclk,
> +				       const struct videomode *vm,
> +				       u16 width, u16 height,
> +				       u16 out_width, u16 out_height,
> +				       u32 fourcc, bool *five_taps,
> +				       int *x_predecim, int *y_predecim,
> +				       int *decim_x, int *decim_y,
> +				       u16 pos_x, unsigned long *core_clk,
> +				       bool mem_to_mem)
>  {
>  	int error;
>  	u16 in_width, in_height;
>  	int min_factor = min(*decim_x, *decim_y);
> -	const int maxsinglelinewidth = dispc.feat->max_line_width;
> +	const int maxsinglelinewidth = dispc->feat->max_line_width;
>  
>  	*five_taps = false;
>  
>  	do {
>  		in_height = height / *decim_y;
>  		in_width = width / *decim_x;
> -		*core_clk = dispc.feat->calc_core_clk(pclk, in_width,
> +		*core_clk = dispc->feat->calc_core_clk(pclk, in_width,
>  				in_height, out_width, out_height, mem_to_mem);
>  		error = (in_width > maxsinglelinewidth || !*core_clk ||
> -			*core_clk > dispc_core_clk_rate());
> +			*core_clk > dispc_core_clk_rate(dispc));
>  		if (error) {
>  			if (*decim_x == *decim_y) {
>  				*decim_x = min_factor;
> @@ -2257,16 +2327,20 @@ static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk,
>  	return 0;
>  }
>  
> -static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
> -		const struct videomode *vm,
> -		u16 width, u16 height, u16 out_width, u16 out_height,
> -		u32 fourcc, bool *five_taps,
> -		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
> -		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
> +static int dispc_ovl_calc_scaling_34xx(struct dispc_device *dispc,
> +				       unsigned long pclk, unsigned long lclk,
> +				       const struct videomode *vm,
> +				       u16 width, u16 height,
> +				       u16 out_width, u16 out_height,
> +				       u32 fourcc, bool *five_taps,
> +				       int *x_predecim, int *y_predecim,
> +				       int *decim_x, int *decim_y,
> +				       u16 pos_x, unsigned long *core_clk,
> +				       bool mem_to_mem)
>  {
>  	int error;
>  	u16 in_width, in_height;
> -	const int maxsinglelinewidth = dispc.feat->max_line_width;
> +	const int maxsinglelinewidth = dispc->feat->max_line_width;
>  
>  	do {
>  		in_height = height / *decim_y;
> @@ -2283,7 +2357,7 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
>  						in_width, in_height, out_width,
>  						out_height, fourcc);
>  		else
> -			*core_clk = dispc.feat->calc_core_clk(pclk, in_width,
> +			*core_clk = dispc->feat->calc_core_clk(pclk, in_width,
>  					in_height, out_width, out_height,
>  					mem_to_mem);
>  
> @@ -2297,7 +2371,7 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
>  
>  		error = (error || in_width > maxsinglelinewidth * 2 ||
>  			(in_width > maxsinglelinewidth && *five_taps) ||
> -			!*core_clk || *core_clk > dispc_core_clk_rate());
> +			!*core_clk || *core_clk > dispc_core_clk_rate(dispc));
>  
>  		if (!error) {
>  			/* verify that we're inside the limits of scaler */
> @@ -2341,24 +2415,28 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
>  	return 0;
>  }
>  
> -static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
> -		const struct videomode *vm,
> -		u16 width, u16 height, u16 out_width, u16 out_height,
> -		u32 fourcc, bool *five_taps,
> -		int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
> -		u16 pos_x, unsigned long *core_clk, bool mem_to_mem)
> +static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc,
> +				       unsigned long pclk, unsigned long lclk,
> +				       const struct videomode *vm,
> +				       u16 width, u16 height,
> +				       u16 out_width, u16 out_height,
> +				       u32 fourcc, bool *five_taps,
> +				       int *x_predecim, int *y_predecim,
> +				       int *decim_x, int *decim_y,
> +				       u16 pos_x, unsigned long *core_clk,
> +				       bool mem_to_mem)
>  {
>  	u16 in_width, in_width_max;
>  	int decim_x_min = *decim_x;
>  	u16 in_height = height / *decim_y;
> -	const int maxsinglelinewidth = dispc.feat->max_line_width;
> -	const int maxdownscale = dispc.feat->max_downscale;
> +	const int maxsinglelinewidth = dispc->feat->max_line_width;
> +	const int maxdownscale = dispc->feat->max_downscale;
>  
>  	if (mem_to_mem) {
>  		in_width_max = out_width * maxdownscale;
>  	} else {
> -		in_width_max = dispc_core_clk_rate() /
> -					DIV_ROUND_UP(pclk, out_width);
> +		in_width_max = dispc_core_clk_rate(dispc)
> +			     / DIV_ROUND_UP(pclk, out_width);
>  	}
>  
>  	*decim_x = DIV_ROUND_UP(width, in_width_max);
> @@ -2396,7 +2474,7 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
>  		return -EINVAL;
>  	}
>  
> -	*core_clk = dispc.feat->calc_core_clk(pclk, in_width, in_height,
> +	*core_clk = dispc->feat->calc_core_clk(pclk, in_width, in_height,
>  				out_width, out_height, mem_to_mem);
>  	return 0;
>  }
> @@ -2404,15 +2482,18 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
>  #define DIV_FRAC(dividend, divisor) \
>  	((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
>  
> -static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
> -		enum omap_overlay_caps caps,
> -		const struct videomode *vm,
> -		u16 width, u16 height, u16 out_width, u16 out_height,
> -		u32 fourcc, bool *five_taps,
> -		int *x_predecim, int *y_predecim, u16 pos_x,
> -		enum omap_dss_rotation_type rotation_type, bool mem_to_mem)
> -{
> -	const int maxdownscale = dispc.feat->max_downscale;
> +static int dispc_ovl_calc_scaling(struct dispc_device *dispc,
> +				  unsigned long pclk, unsigned long lclk,
> +				  enum omap_overlay_caps caps,
> +				  const struct videomode *vm,
> +				  u16 width, u16 height,
> +				  u16 out_width, u16 out_height,
> +				  u32 fourcc, bool *five_taps,
> +				  int *x_predecim, int *y_predecim, u16 pos_x,
> +				  enum omap_dss_rotation_type rotation_type,
> +				  bool mem_to_mem)
> +{
> +	const int maxdownscale = dispc->feat->max_downscale;
>  	const int max_decim_limit = 16;
>  	unsigned long core_clk = 0;
>  	int decim_x, decim_y, ret;
> @@ -2433,7 +2514,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
>  	} else {
>  		*x_predecim = max_decim_limit;
>  		*y_predecim = (rotation_type == OMAP_DSS_ROT_TILER &&
> -				dispc_has_feature(FEAT_BURST_2D)) ?
> +				dispc_has_feature(dispc, FEAT_BURST_2D)) ?
>  				2 : max_decim_limit;
>  	}
>  
> @@ -2446,10 +2527,11 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
>  	if (decim_y > *y_predecim || out_height > height * 8)
>  		return -EINVAL;
>  
> -	ret = dispc.feat->calc_scaling(pclk, lclk, vm, width, height,
> -		out_width, out_height, fourcc, five_taps,
> -		x_predecim, y_predecim, &decim_x, &decim_y, pos_x, &core_clk,
> -		mem_to_mem);
> +	ret = dispc->feat->calc_scaling(dispc, pclk, lclk, vm, width, height,
> +					out_width, out_height, fourcc,
> +					five_taps, x_predecim, y_predecim,
> +					&decim_x, &decim_y, pos_x, &core_clk,
> +					mem_to_mem);
>  	if (ret)
>  		return ret;
>  
> @@ -2465,13 +2547,13 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
>  		out_height / (height / decim_y), DIV_FRAC(out_height, height / decim_y),
>  
>  		*five_taps ? 5 : 3,
> -		core_clk, dispc_core_clk_rate());
> +		core_clk, dispc_core_clk_rate(dispc));
>  
> -	if (!core_clk || core_clk > dispc_core_clk_rate()) {
> +	if (!core_clk || core_clk > dispc_core_clk_rate(dispc)) {
>  		DSSERR("failed to set up scaling, "
>  			"required core clk rate = %lu Hz, "
>  			"current core clk rate = %lu Hz\n",
> -			core_clk, dispc_core_clk_rate());
> +			core_clk, dispc_core_clk_rate(dispc));
>  		return -EINVAL;
>  	}
>  
> @@ -2480,14 +2562,18 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
>  	return 0;
>  }
>  
> -static int dispc_ovl_setup_common(enum omap_plane_id plane,
> -		enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr,
> -		u16 screen_width, int pos_x, int pos_y, u16 width, u16 height,
> -		u16 out_width, u16 out_height, u32 fourcc,
> -		u8 rotation, u8 zorder, u8 pre_mult_alpha,
> -		u8 global_alpha, enum omap_dss_rotation_type rotation_type,
> -		bool replication, const struct videomode *vm,
> -		bool mem_to_mem)
> +static int dispc_ovl_setup_common(struct dispc_device *dispc,
> +				  enum omap_plane_id plane,
> +				  enum omap_overlay_caps caps,
> +				  u32 paddr, u32 p_uv_addr,
> +				  u16 screen_width, int pos_x, int pos_y,
> +				  u16 width, u16 height,
> +				  u16 out_width, u16 out_height,
> +				  u32 fourcc, u8 rotation, u8 zorder,
> +				  u8 pre_mult_alpha, u8 global_alpha,
> +				  enum omap_dss_rotation_type rotation_type,
> +				  bool replication, const struct videomode *vm,
> +				  bool mem_to_mem)
>  {
>  	bool five_taps = true;
>  	bool fieldmode = false;
> @@ -2501,8 +2587,8 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
>  	u16 in_width = width;
>  	int x_predecim = 1, y_predecim = 1;
>  	bool ilace = !!(vm->flags & DISPLAY_FLAGS_INTERLACED);
> -	unsigned long pclk = dispc_plane_pclk_rate(plane);
> -	unsigned long lclk = dispc_plane_lclk_rate(plane);
> +	unsigned long pclk = dispc_plane_pclk_rate(dispc, plane);
> +	unsigned long lclk = dispc_plane_lclk_rate(dispc, plane);
>  
>  	if (paddr == 0 && rotation_type != OMAP_DSS_ROT_TILER)
>  		return -EINVAL;
> @@ -2529,13 +2615,13 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
>  			out_height);
>  	}
>  
> -	if (!dispc_ovl_color_mode_supported(plane, fourcc))
> +	if (!dispc_ovl_color_mode_supported(dispc, plane, fourcc))
>  		return -EINVAL;
>  
> -	r = dispc_ovl_calc_scaling(pclk, lclk, caps, vm, in_width,
> -			in_height, out_width, out_height, fourcc,
> -			&five_taps, &x_predecim, &y_predecim, pos_x,
> -			rotation_type, mem_to_mem);
> +	r = dispc_ovl_calc_scaling(dispc, pclk, lclk, caps, vm, in_width,
> +				   in_height, out_width, out_height, fourcc,
> +				   &five_taps, &x_predecim, &y_predecim, pos_x,
> +				   rotation_type, mem_to_mem);
>  	if (r)
>  		return r;
>  
> @@ -2597,49 +2683,50 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane,
>  	DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
>  			offset0, offset1, row_inc, pix_inc);
>  
> -	dispc_ovl_set_color_mode(plane, fourcc);
> +	dispc_ovl_set_color_mode(dispc, plane, fourcc);
>  
> -	dispc_ovl_configure_burst_type(plane, rotation_type);
> +	dispc_ovl_configure_burst_type(dispc, plane, rotation_type);
>  
> -	if (dispc.feat->reverse_ilace_field_order)
> +	if (dispc->feat->reverse_ilace_field_order)
>  		swap(offset0, offset1);
>  
> -	dispc_ovl_set_ba0(plane, paddr + offset0);
> -	dispc_ovl_set_ba1(plane, paddr + offset1);
> +	dispc_ovl_set_ba0(dispc, plane, paddr + offset0);
> +	dispc_ovl_set_ba1(dispc, plane, paddr + offset1);
>  
>  	if (fourcc == DRM_FORMAT_NV12) {
> -		dispc_ovl_set_ba0_uv(plane, p_uv_addr + offset0);
> -		dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1);
> +		dispc_ovl_set_ba0_uv(dispc, plane, p_uv_addr + offset0);
> +		dispc_ovl_set_ba1_uv(dispc, plane, p_uv_addr + offset1);
>  	}
>  
> -	if (dispc.feat->last_pixel_inc_missing)
> +	if (dispc->feat->last_pixel_inc_missing)
>  		row_inc += pix_inc - 1;
>  
> -	dispc_ovl_set_row_inc(plane, row_inc);
> -	dispc_ovl_set_pix_inc(plane, pix_inc);
> +	dispc_ovl_set_row_inc(dispc, plane, row_inc);
> +	dispc_ovl_set_pix_inc(dispc, plane, pix_inc);
>  
>  	DSSDBG("%d,%d %dx%d -> %dx%d\n", pos_x, pos_y, in_width,
>  			in_height, out_width, out_height);
>  
> -	dispc_ovl_set_pos(plane, caps, pos_x, pos_y);
> +	dispc_ovl_set_pos(dispc, plane, caps, pos_x, pos_y);
>  
> -	dispc_ovl_set_input_size(plane, in_width, in_height);
> +	dispc_ovl_set_input_size(dispc, plane, in_width, in_height);
>  
>  	if (caps & OMAP_DSS_OVL_CAP_SCALE) {
> -		dispc_ovl_set_scaling(plane, in_width, in_height, out_width,
> -				   out_height, ilace, five_taps, fieldmode,
> -				   fourcc, rotation);
> -		dispc_ovl_set_output_size(plane, out_width, out_height);
> -		dispc_ovl_set_vid_color_conv(plane, cconv);
> +		dispc_ovl_set_scaling(dispc, plane, in_width, in_height,
> +				      out_width, out_height, ilace, five_taps,
> +				      fieldmode, fourcc, rotation);
> +		dispc_ovl_set_output_size(dispc, plane, out_width, out_height);
> +		dispc_ovl_set_vid_color_conv(dispc, plane, cconv);
>  	}
>  
> -	dispc_ovl_set_rotation_attrs(plane, rotation, rotation_type, fourcc);
> +	dispc_ovl_set_rotation_attrs(dispc, plane, rotation, rotation_type,
> +				     fourcc);
>  
> -	dispc_ovl_set_zorder(plane, caps, zorder);
> -	dispc_ovl_set_pre_mult_alpha(plane, caps, pre_mult_alpha);
> -	dispc_ovl_setup_global_alpha(plane, caps, global_alpha);
> +	dispc_ovl_set_zorder(dispc, plane, caps, zorder);
> +	dispc_ovl_set_pre_mult_alpha(dispc, plane, caps, pre_mult_alpha);
> +	dispc_ovl_setup_global_alpha(dispc, plane, caps, global_alpha);
>  
> -	dispc_ovl_enable_replication(plane, caps, replication);
> +	dispc_ovl_enable_replication(dispc, plane, caps, replication);
>  
>  	return 0;
>  }
> @@ -2660,9 +2747,9 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
>  		oi->pos_y, oi->width, oi->height, oi->out_width, oi->out_height,
>  		oi->fourcc, oi->rotation, channel, replication);
>  
> -	dispc_ovl_set_channel_out(plane, channel);
> +	dispc_ovl_set_channel_out(dispc, plane, channel);
>  
> -	r = dispc_ovl_setup_common(plane, caps, oi->paddr, oi->p_uv_addr,
> +	r = dispc_ovl_setup_common(dispc, plane, caps, oi->paddr, oi->p_uv_addr,
>  		oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height,
>  		oi->out_width, oi->out_height, oi->fourcc, oi->rotation,
>  		oi->zorder, oi->pre_mult_alpha, oi->global_alpha,
> @@ -2691,7 +2778,7 @@ int dispc_wb_setup(struct dispc_device *dispc,
>  		"rot %d\n", wi->paddr, wi->p_uv_addr, in_width,
>  		in_height, wi->width, wi->height, wi->fourcc, wi->rotation);
>  
> -	r = dispc_ovl_setup_common(plane, caps, wi->paddr, wi->p_uv_addr,
> +	r = dispc_ovl_setup_common(dispc, plane, caps, wi->paddr, wi->p_uv_addr,
>  		wi->buf_width, pos_x, pos_y, in_width, in_height, wi->width,
>  		wi->height, wi->fourcc, wi->rotation, zorder,
>  		wi->pre_mult_alpha, global_alpha, wi->rotation_type,
> @@ -2714,18 +2801,18 @@ int dispc_wb_setup(struct dispc_device *dispc,
>  	}
>  
>  	/* setup extra DISPC_WB_ATTRIBUTES */
> -	l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane));
> +	l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
>  	l = FLD_MOD(l, truncation, 10, 10);	/* TRUNCATIONENABLE */
>  	l = FLD_MOD(l, mem_to_mem, 19, 19);	/* WRITEBACKMODE */
>  	if (mem_to_mem)
>  		l = FLD_MOD(l, 1, 26, 24);	/* CAPTUREMODE */
>  	else
>  		l = FLD_MOD(l, 0, 26, 24);	/* CAPTUREMODE */
> -	dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l);
> +	dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
>  
>  	if (mem_to_mem) {
>  		/* WBDELAYCOUNT */
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 7, 0);
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), 0, 7, 0);
>  	} else {
>  		int wbdelay;
>  
> @@ -2733,7 +2820,7 @@ int dispc_wb_setup(struct dispc_device *dispc,
>  			      vm->vsync_len + vm->vback_porch, (u32)255);
>  
>  		/* WBDELAYCOUNT */
> -		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), wbdelay, 7, 0);
> +		REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), wbdelay, 7, 0);
>  	}
>  
>  	return r;
> @@ -2744,7 +2831,7 @@ static int dispc_ovl_enable(struct dispc_device *dispc,
>  {
>  	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
>  
> -	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
> +	REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
>  
>  	return 0;
>  }
> @@ -2756,94 +2843,106 @@ dispc_mgr_get_supported_outputs(struct dispc_device *dispc,
>  	return dss_get_supported_outputs(dispc->dss, channel);
>  }
>  
> -static void dispc_lcd_enable_signal_polarity(bool act_high)
> +static void dispc_lcd_enable_signal_polarity(struct dispc_device *dispc,
> +					     bool act_high)
>  {
> -	if (!dispc_has_feature(FEAT_LCDENABLEPOL))
> +	if (!dispc_has_feature(dispc, FEAT_LCDENABLEPOL))
>  		return;
>  
> -	REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
> +	REG_FLD_MOD(dispc, DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
>  }
>  
>  void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable)
>  {
> -	if (!dispc_has_feature(FEAT_LCDENABLESIGNAL))
> +	if (!dispc_has_feature(dispc, FEAT_LCDENABLESIGNAL))
>  		return;
>  
> -	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
> +	REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 28, 28);
>  }
>  
>  void dispc_pck_free_enable(struct dispc_device *dispc, bool enable)
>  {
> -	if (!dispc_has_feature(FEAT_PCKFREEENABLE))
> +	if (!dispc_has_feature(dispc, FEAT_PCKFREEENABLE))
>  		return;
>  
> -	REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27);
> +	REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 27, 27);
>  }
>  
> -static void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable)
> +static void dispc_mgr_enable_fifohandcheck(struct dispc_device *dispc,
> +					   enum omap_channel channel,
> +					   bool enable)
>  {
> -	mgr_fld_write(channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable);
>  }
>  
>  
> -static void dispc_mgr_set_lcd_type_tft(enum omap_channel channel)
> +static void dispc_mgr_set_lcd_type_tft(struct dispc_device *dispc,
> +				       enum omap_channel channel)
>  {
> -	mgr_fld_write(channel, DISPC_MGR_FLD_STNTFT, 1);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STNTFT, 1);
>  }
>  
> -static void dispc_set_loadmode(enum omap_dss_load_mode mode)
> +static void dispc_set_loadmode(struct dispc_device *dispc,
> +			       enum omap_dss_load_mode mode)
>  {
> -	REG_FLD_MOD(DISPC_CONFIG, mode, 2, 1);
> +	REG_FLD_MOD(dispc, DISPC_CONFIG, mode, 2, 1);
>  }
>  
>  
> -static void dispc_mgr_set_default_color(enum omap_channel channel, u32 color)
> +static void dispc_mgr_set_default_color(struct dispc_device *dispc,
> +					enum omap_channel channel, u32 color)
>  {
> -	dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color);
> +	dispc_write_reg(dispc, DISPC_DEFAULT_COLOR(channel), color);
>  }
>  
> -static void dispc_mgr_set_trans_key(enum omap_channel ch,
> -		enum omap_dss_trans_key_type type,
> -		u32 trans_key)
> +static void dispc_mgr_set_trans_key(struct dispc_device *dispc,
> +				    enum omap_channel ch,
> +				    enum omap_dss_trans_key_type type,
> +				    u32 trans_key)
>  {
> -	mgr_fld_write(ch, DISPC_MGR_FLD_TCKSELECTION, type);
> +	mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKSELECTION, type);
>  
> -	dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key);
> +	dispc_write_reg(dispc, DISPC_TRANS_COLOR(ch), trans_key);
>  }
>  
> -static void dispc_mgr_enable_trans_key(enum omap_channel ch, bool enable)
> +static void dispc_mgr_enable_trans_key(struct dispc_device *dispc,
> +				       enum omap_channel ch, bool enable)
>  {
> -	mgr_fld_write(ch, DISPC_MGR_FLD_TCKENABLE, enable);
> +	mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKENABLE, enable);
>  }
>  
> -static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch,
> -		bool enable)
> +static void dispc_mgr_enable_alpha_fixed_zorder(struct dispc_device *dispc,
> +						enum omap_channel ch,
> +						bool enable)
>  {
> -	if (!dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER))
> +	if (!dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER))
>  		return;
>  
>  	if (ch == OMAP_DSS_CHANNEL_LCD)
> -		REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18);
> +		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 18, 18);
>  	else if (ch == OMAP_DSS_CHANNEL_DIGIT)
> -		REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
> +		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 19, 19);
>  }
>  
>  static void dispc_mgr_setup(struct dispc_device *dispc,
>  			    enum omap_channel channel,
>  			    const struct omap_overlay_manager_info *info)
>  {
> -	dispc_mgr_set_default_color(channel, info->default_color);
> -	dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key);
> -	dispc_mgr_enable_trans_key(channel, info->trans_enabled);
> -	dispc_mgr_enable_alpha_fixed_zorder(channel,
> +	dispc_mgr_set_default_color(dispc, channel, info->default_color);
> +	dispc_mgr_set_trans_key(dispc, channel, info->trans_key_type,
> +				info->trans_key);
> +	dispc_mgr_enable_trans_key(dispc, channel, info->trans_enabled);
> +	dispc_mgr_enable_alpha_fixed_zorder(dispc, channel,
>  			info->partial_alpha_enabled);
> -	if (dispc_has_feature(FEAT_CPR)) {
> -		dispc_mgr_enable_cpr(channel, info->cpr_enable);
> -		dispc_mgr_set_cpr_coef(channel, &info->cpr_coefs);
> +	if (dispc_has_feature(dispc, FEAT_CPR)) {
> +		dispc_mgr_enable_cpr(dispc, channel, info->cpr_enable);
> +		dispc_mgr_set_cpr_coef(dispc, channel, &info->cpr_coefs);
>  	}
>  }
>  
> -static void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_lines)
> +static void dispc_mgr_set_tft_data_lines(struct dispc_device *dispc,
> +					 enum omap_channel channel,
> +					 u8 data_lines)
>  {
>  	int code;
>  
> @@ -2865,10 +2964,11 @@ static void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_line
>  		return;
>  	}
>  
> -	mgr_fld_write(channel, DISPC_MGR_FLD_TFTDATALINES, code);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_TFTDATALINES, code);
>  }
>  
> -static void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode)
> +static void dispc_mgr_set_io_pad_mode(struct dispc_device *dispc,
> +				      enum dss_io_pad_mode mode)
>  {
>  	u32 l;
>  	int gpout0, gpout1;
> @@ -2891,70 +2991,74 @@ static void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode)
>  		return;
>  	}
>  
> -	l = dispc_read_reg(DISPC_CONTROL);
> +	l = dispc_read_reg(dispc, DISPC_CONTROL);
>  	l = FLD_MOD(l, gpout0, 15, 15);
>  	l = FLD_MOD(l, gpout1, 16, 16);
> -	dispc_write_reg(DISPC_CONTROL, l);
> +	dispc_write_reg(dispc, DISPC_CONTROL, l);
>  }
>  
> -static void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable)
> +static void dispc_mgr_enable_stallmode(struct dispc_device *dispc,
> +				       enum omap_channel channel, bool enable)
>  {
> -	mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable);
> +	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STALLMODE, enable);
>  }
>  
>  static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
>  				     enum omap_channel channel,
>  				     const struct dss_lcd_mgr_config *config)
>  {
> -	dispc_mgr_set_io_pad_mode(config->io_pad_mode);
> +	dispc_mgr_set_io_pad_mode(dispc, config->io_pad_mode);
>  
> -	dispc_mgr_enable_stallmode(channel, config->stallmode);
> -	dispc_mgr_enable_fifohandcheck(channel, config->fifohandcheck);
> +	dispc_mgr_enable_stallmode(dispc, channel, config->stallmode);
> +	dispc_mgr_enable_fifohandcheck(dispc, channel, config->fifohandcheck);
>  
>  	dispc_mgr_set_clock_div(dispc, channel, &config->clock_info);
>  
> -	dispc_mgr_set_tft_data_lines(channel, config->video_port_width);
> +	dispc_mgr_set_tft_data_lines(dispc, channel, config->video_port_width);
>  
> -	dispc_lcd_enable_signal_polarity(config->lcden_sig_polarity);
> +	dispc_lcd_enable_signal_polarity(dispc, config->lcden_sig_polarity);
>  
> -	dispc_mgr_set_lcd_type_tft(channel);
> +	dispc_mgr_set_lcd_type_tft(dispc, channel);
>  }
>  
> -static bool _dispc_mgr_size_ok(u16 width, u16 height)
> +static bool _dispc_mgr_size_ok(struct dispc_device *dispc,
> +			       u16 width, u16 height)
>  {
> -	return width <= dispc.feat->mgr_width_max &&
> -		height <= dispc.feat->mgr_height_max;
> +	return width <= dispc->feat->mgr_width_max &&
> +		height <= dispc->feat->mgr_height_max;
>  }
>  
> -static bool _dispc_lcd_timings_ok(int hsync_len, int hfp, int hbp,
> -		int vsw, int vfp, int vbp)
> +static bool _dispc_lcd_timings_ok(struct dispc_device *dispc,
> +				  int hsync_len, int hfp, int hbp,
> +				  int vsw, int vfp, int vbp)
>  {
> -	if (hsync_len < 1 || hsync_len > dispc.feat->sw_max ||
> -			hfp < 1 || hfp > dispc.feat->hp_max ||
> -			hbp < 1 || hbp > dispc.feat->hp_max ||
> -			vsw < 1 || vsw > dispc.feat->sw_max ||
> -			vfp < 0 || vfp > dispc.feat->vp_max ||
> -			vbp < 0 || vbp > dispc.feat->vp_max)
> +	if (hsync_len < 1 || hsync_len > dispc->feat->sw_max ||
> +	    hfp < 1 || hfp > dispc->feat->hp_max ||
> +	    hbp < 1 || hbp > dispc->feat->hp_max ||
> +	    vsw < 1 || vsw > dispc->feat->sw_max ||
> +	    vfp < 0 || vfp > dispc->feat->vp_max ||
> +	    vbp < 0 || vbp > dispc->feat->vp_max)
>  		return false;
>  	return true;
>  }
>  
> -static bool _dispc_mgr_pclk_ok(enum omap_channel channel,
> -		unsigned long pclk)
> +static bool _dispc_mgr_pclk_ok(struct dispc_device *dispc,
> +			       enum omap_channel channel,
> +			       unsigned long pclk)
>  {
>  	if (dss_mgr_is_lcd(channel))
> -		return pclk <= dispc.feat->max_lcd_pclk;
> +		return pclk <= dispc->feat->max_lcd_pclk;
>  	else
> -		return pclk <= dispc.feat->max_tv_pclk;
> +		return pclk <= dispc->feat->max_tv_pclk;
>  }
>  
>  bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
>  			  const struct videomode *vm)
>  {
> -	if (!_dispc_mgr_size_ok(vm->hactive, vm->vactive))
> +	if (!_dispc_mgr_size_ok(dispc, vm->hactive, vm->vactive))
>  		return false;
>  
> -	if (!_dispc_mgr_pclk_ok(channel, vm->pixelclock))
> +	if (!_dispc_mgr_pclk_ok(dispc, channel, vm->pixelclock))
>  		return false;
>  
>  	if (dss_mgr_is_lcd(channel)) {
> @@ -2962,7 +3066,7 @@ bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
>  		if (vm->flags & DISPLAY_FLAGS_INTERLACED)
>  			return false;
>  
> -		if (!_dispc_lcd_timings_ok(vm->hsync_len,
> +		if (!_dispc_lcd_timings_ok(dispc, vm->hsync_len,
>  				vm->hfront_porch, vm->hback_porch,
>  				vm->vsync_len, vm->vfront_porch,
>  				vm->vback_porch))
> @@ -2972,21 +3076,22 @@ bool dispc_mgr_timings_ok(struct dispc_device *dispc, enum omap_channel channel,
>  	return true;
>  }
>  
> -static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
> +static void _dispc_mgr_set_lcd_timings(struct dispc_device *dispc,
> +				       enum omap_channel channel,
>  				       const struct videomode *vm)
>  {
>  	u32 timing_h, timing_v, l;
>  	bool onoff, rf, ipc, vs, hs, de;
>  
> -	timing_h = FLD_VAL(vm->hsync_len - 1, dispc.feat->sw_start, 0) |
> -		   FLD_VAL(vm->hfront_porch - 1, dispc.feat->fp_start, 8) |
> -		   FLD_VAL(vm->hback_porch - 1, dispc.feat->bp_start, 20);
> -	timing_v = FLD_VAL(vm->vsync_len - 1, dispc.feat->sw_start, 0) |
> -		   FLD_VAL(vm->vfront_porch, dispc.feat->fp_start, 8) |
> -		   FLD_VAL(vm->vback_porch, dispc.feat->bp_start, 20);
> +	timing_h = FLD_VAL(vm->hsync_len - 1, dispc->feat->sw_start, 0) |
> +		   FLD_VAL(vm->hfront_porch - 1, dispc->feat->fp_start, 8) |
> +		   FLD_VAL(vm->hback_porch - 1, dispc->feat->bp_start, 20);
> +	timing_v = FLD_VAL(vm->vsync_len - 1, dispc->feat->sw_start, 0) |
> +		   FLD_VAL(vm->vfront_porch, dispc->feat->fp_start, 8) |
> +		   FLD_VAL(vm->vback_porch, dispc->feat->bp_start, 20);
>  
> -	dispc_write_reg(DISPC_TIMING_H(channel), timing_h);
> -	dispc_write_reg(DISPC_TIMING_V(channel), timing_v);
> +	dispc_write_reg(dispc, DISPC_TIMING_H(channel), timing_h);
> +	dispc_write_reg(dispc, DISPC_TIMING_V(channel), timing_v);
>  
>  	if (vm->flags & DISPLAY_FLAGS_VSYNC_HIGH)
>  		vs = false;
> @@ -3024,12 +3129,12 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
>  		FLD_VAL(vs, 12, 12);
>  
>  	/* always set ALIGN bit when available */
> -	if (dispc.feat->supports_sync_align)
> +	if (dispc->feat->supports_sync_align)
>  		l |= (1 << 18);
>  
> -	dispc_write_reg(DISPC_POL_FREQ(channel), l);
> +	dispc_write_reg(dispc, DISPC_POL_FREQ(channel), l);
>  
> -	if (dispc.syscon_pol) {
> +	if (dispc->syscon_pol) {
>  		const int shifts[] = {
>  			[OMAP_DSS_CHANNEL_LCD] = 0,
>  			[OMAP_DSS_CHANNEL_LCD2] = 1,
> @@ -3044,8 +3149,8 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel,
>  		mask <<= 16 + shifts[channel];
>  		val <<= 16 + shifts[channel];
>  
> -		regmap_update_bits(dispc.syscon_pol, dispc.syscon_pol_offset,
> -			mask, val);
> +		regmap_update_bits(dispc->syscon_pol, dispc->syscon_pol_offset,
> +				   mask, val);
>  	}
>  }
>  
> @@ -3076,7 +3181,7 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
>  	}
>  
>  	if (dss_mgr_is_lcd(channel)) {
> -		_dispc_mgr_set_lcd_timings(channel, &t);
> +		_dispc_mgr_set_lcd_timings(dispc, channel, &t);
>  
>  		xtot = t.hactive + t.hfront_porch + t.hsync_len + t.hback_porch;
>  		ytot = t.vactive + t.vfront_porch + t.vsync_len + t.vback_porch;
> @@ -3101,46 +3206,48 @@ static void dispc_mgr_set_timings(struct dispc_device *dispc,
>  			t.vactive /= 2;
>  
>  		if (dispc->feat->supports_double_pixel)
> -			REG_FLD_MOD(DISPC_CONTROL,
> +			REG_FLD_MOD(dispc, DISPC_CONTROL,
>  				    !!(t.flags & DISPLAY_FLAGS_DOUBLECLK),
>  				    19, 17);
>  	}
>  
> -	dispc_mgr_set_size(channel, t.hactive, t.vactive);
> +	dispc_mgr_set_size(dispc, channel, t.hactive, t.vactive);
>  }
>  
> -static void dispc_mgr_set_lcd_divisor(enum omap_channel channel, u16 lck_div,
> -		u16 pck_div)
> +static void dispc_mgr_set_lcd_divisor(struct dispc_device *dispc,
> +				      enum omap_channel channel, u16 lck_div,
> +				      u16 pck_div)
>  {
>  	BUG_ON(lck_div < 1);
>  	BUG_ON(pck_div < 1);
>  
> -	dispc_write_reg(DISPC_DIVISORo(channel),
> +	dispc_write_reg(dispc, DISPC_DIVISORo(channel),
>  			FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0));
>  
> -	if (!dispc_has_feature(FEAT_CORE_CLK_DIV) &&
> +	if (!dispc_has_feature(dispc, FEAT_CORE_CLK_DIV) &&
>  			channel == OMAP_DSS_CHANNEL_LCD)
> -		dispc.core_clk_rate = dispc_fclk_rate() / lck_div;
> +		dispc->core_clk_rate = dispc_fclk_rate(dispc) / lck_div;
>  }
>  
> -static void dispc_mgr_get_lcd_divisor(enum omap_channel channel, int *lck_div,
> -		int *pck_div)
> +static void dispc_mgr_get_lcd_divisor(struct dispc_device *dispc,
> +				      enum omap_channel channel, int *lck_div,
> +				      int *pck_div)
>  {
>  	u32 l;
> -	l = dispc_read_reg(DISPC_DIVISORo(channel));
> +	l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
>  	*lck_div = FLD_GET(l, 23, 16);
>  	*pck_div = FLD_GET(l, 7, 0);
>  }
>  
> -static unsigned long dispc_fclk_rate(void)
> +static unsigned long dispc_fclk_rate(struct dispc_device *dispc)
>  {
>  	unsigned long r;
>  	enum dss_clk_source src;
>  
> -	src = dss_get_dispc_clk_source(dispc.dss);
> +	src = dss_get_dispc_clk_source(dispc->dss);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
> -		r = dss_get_dispc_clk_rate(dispc.dss);
> +		r = dss_get_dispc_clk_rate(dispc->dss);
>  	} else {
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
> @@ -3154,7 +3261,8 @@ static unsigned long dispc_fclk_rate(void)
>  	return r;
>  }
>  
> -static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
> +static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
> +					 enum omap_channel channel)
>  {
>  	int lcd;
>  	unsigned long r;
> @@ -3162,12 +3270,12 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
>  
>  	/* for TV, LCLK rate is the FCLK rate */
>  	if (!dss_mgr_is_lcd(channel))
> -		return dispc_fclk_rate();
> +		return dispc_fclk_rate(dispc);
>  
> -	src = dss_get_lcd_clk_source(dispc.dss, channel);
> +	src = dss_get_lcd_clk_source(dispc->dss, channel);
>  
>  	if (src == DSS_CLK_SRC_FCK) {
> -		r = dss_get_dispc_clk_rate(dispc.dss);
> +		r = dss_get_dispc_clk_rate(dispc->dss);
>  	} else {
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
> @@ -3178,12 +3286,13 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
>  		r = pll->cinfo.clkout[clkout_idx];
>  	}
>  
> -	lcd = REG_GET(DISPC_DIVISORo(channel), 23, 16);
> +	lcd = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
>  
>  	return r / lcd;
>  }
>  
> -static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
> +static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
> +					 enum omap_channel channel)
>  {
>  	unsigned long r;
>  
> @@ -3191,15 +3300,15 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel)
>  		int pcd;
>  		u32 l;
>  
> -		l = dispc_read_reg(DISPC_DIVISORo(channel));
> +		l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
>  
>  		pcd = FLD_GET(l, 7, 0);
>  
> -		r = dispc_mgr_lclk_rate(channel);
> +		r = dispc_mgr_lclk_rate(dispc, channel);
>  
>  		return r / pcd;
>  	} else {
> -		return dispc.tv_pclk_rate;
> +		return dispc->tv_pclk_rate;
>  	}
>  }
>  
> @@ -3208,53 +3317,57 @@ void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk)
>  	dispc->tv_pclk_rate = pclk;
>  }
>  
> -static unsigned long dispc_core_clk_rate(void)
> +static unsigned long dispc_core_clk_rate(struct dispc_device *dispc)
>  {
> -	return dispc.core_clk_rate;
> +	return dispc->core_clk_rate;
>  }
>  
> -static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane)
> +static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
> +					   enum omap_plane_id plane)
>  {
>  	enum omap_channel channel;
>  
>  	if (plane == OMAP_DSS_WB)
>  		return 0;
>  
> -	channel = dispc_ovl_get_channel_out(plane);
> +	channel = dispc_ovl_get_channel_out(dispc, plane);
>  
> -	return dispc_mgr_pclk_rate(channel);
> +	return dispc_mgr_pclk_rate(dispc, channel);
>  }
>  
> -static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane)
> +static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
> +					   enum omap_plane_id plane)
>  {
>  	enum omap_channel channel;
>  
>  	if (plane == OMAP_DSS_WB)
>  		return 0;
>  
> -	channel	= dispc_ovl_get_channel_out(plane);
> +	channel	= dispc_ovl_get_channel_out(dispc, plane);
>  
> -	return dispc_mgr_lclk_rate(channel);
> +	return dispc_mgr_lclk_rate(dispc, channel);
>  }
>  
> -static void dispc_dump_clocks_channel(struct seq_file *s, enum omap_channel channel)
> +static void dispc_dump_clocks_channel(struct dispc_device *dispc,
> +				      struct seq_file *s,
> +				      enum omap_channel channel)
>  {
>  	int lcd, pcd;
>  	enum dss_clk_source lcd_clk_src;
>  
>  	seq_printf(s, "- %s -\n", mgr_desc[channel].name);
>  
> -	lcd_clk_src = dss_get_lcd_clk_source(dispc.dss, channel);
> +	lcd_clk_src = dss_get_lcd_clk_source(dispc->dss, channel);
>  
>  	seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
>  		dss_get_clk_source_name(lcd_clk_src));
>  
> -	dispc_mgr_get_lcd_divisor(channel, &lcd, &pcd);
> +	dispc_mgr_get_lcd_divisor(dispc, channel, &lcd, &pcd);
>  
>  	seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
> -		dispc_mgr_lclk_rate(channel), lcd);
> +		dispc_mgr_lclk_rate(dispc, channel), lcd);
>  	seq_printf(s, "pck\t\t%-16lupck div\t%u\n",
> -		dispc_mgr_pclk_rate(channel), pcd);
> +		dispc_mgr_pclk_rate(dispc, channel), pcd);
>  }
>  
>  void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
> @@ -3271,29 +3384,30 @@ void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
>  	seq_printf(s, "dispc fclk source = %s\n",
>  			dss_get_clk_source_name(dispc_clk_src));
>  
> -	seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate());
> +	seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate(dispc));
>  
> -	if (dispc_has_feature(FEAT_CORE_CLK_DIV)) {
> +	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
>  		seq_printf(s, "- DISPC-CORE-CLK -\n");
> -		l = dispc_read_reg(DISPC_DIVISOR);
> +		l = dispc_read_reg(dispc, DISPC_DIVISOR);
>  		lcd = FLD_GET(l, 23, 16);
>  
>  		seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
> -				(dispc_fclk_rate()/lcd), lcd);
> +				(dispc_fclk_rate(dispc)/lcd), lcd);
>  	}
>  
> -	dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD);
> +	dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD);
>  
> -	if (dispc_has_feature(FEAT_MGR_LCD2))
> -		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD2);
> -	if (dispc_has_feature(FEAT_MGR_LCD3))
> -		dispc_dump_clocks_channel(s, OMAP_DSS_CHANNEL_LCD3);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
> +		dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD2);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
> +		dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD3);
>  
>  	dispc_runtime_put(dispc);
>  }
>  
>  static int dispc_dump_regs(struct seq_file *s, void *p)
>  {
> +	struct dispc_device *dispc = s->private;
>  	int i, j;
>  	const char *mgr_names[] = {
>  		[OMAP_DSS_CHANNEL_LCD]		= "LCD",
> @@ -3310,178 +3424,179 @@ static int dispc_dump_regs(struct seq_file *s, void *p)
>  	};
>  	const char **p_names;
>  
> -#define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
> +#define DUMPREG(dispc, r) \
> +	seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(dispc, r))
>  
> -	if (dispc_runtime_get(&dispc))
> +	if (dispc_runtime_get(dispc))
>  		return 0;
>  
>  	/* DISPC common registers */
> -	DUMPREG(DISPC_REVISION);
> -	DUMPREG(DISPC_SYSCONFIG);
> -	DUMPREG(DISPC_SYSSTATUS);
> -	DUMPREG(DISPC_IRQSTATUS);
> -	DUMPREG(DISPC_IRQENABLE);
> -	DUMPREG(DISPC_CONTROL);
> -	DUMPREG(DISPC_CONFIG);
> -	DUMPREG(DISPC_CAPABLE);
> -	DUMPREG(DISPC_LINE_STATUS);
> -	DUMPREG(DISPC_LINE_NUMBER);
> -	if (dispc_has_feature(FEAT_ALPHA_FIXED_ZORDER) ||
> -			dispc_has_feature(FEAT_ALPHA_FREE_ZORDER))
> -		DUMPREG(DISPC_GLOBAL_ALPHA);
> -	if (dispc_has_feature(FEAT_MGR_LCD2)) {
> -		DUMPREG(DISPC_CONTROL2);
> -		DUMPREG(DISPC_CONFIG2);
> +	DUMPREG(dispc, DISPC_REVISION);
> +	DUMPREG(dispc, DISPC_SYSCONFIG);
> +	DUMPREG(dispc, DISPC_SYSSTATUS);
> +	DUMPREG(dispc, DISPC_IRQSTATUS);
> +	DUMPREG(dispc, DISPC_IRQENABLE);
> +	DUMPREG(dispc, DISPC_CONTROL);
> +	DUMPREG(dispc, DISPC_CONFIG);
> +	DUMPREG(dispc, DISPC_CAPABLE);
> +	DUMPREG(dispc, DISPC_LINE_STATUS);
> +	DUMPREG(dispc, DISPC_LINE_NUMBER);
> +	if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
> +			dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
> +		DUMPREG(dispc, DISPC_GLOBAL_ALPHA);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
> +		DUMPREG(dispc, DISPC_CONTROL2);
> +		DUMPREG(dispc, DISPC_CONFIG2);
>  	}
> -	if (dispc_has_feature(FEAT_MGR_LCD3)) {
> -		DUMPREG(DISPC_CONTROL3);
> -		DUMPREG(DISPC_CONFIG3);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
> +		DUMPREG(dispc, DISPC_CONTROL3);
> +		DUMPREG(dispc, DISPC_CONFIG3);
>  	}
> -	if (dispc_has_feature(FEAT_MFLAG))
> -		DUMPREG(DISPC_GLOBAL_MFLAG_ATTRIBUTE);
> +	if (dispc_has_feature(dispc, FEAT_MFLAG))
> +		DUMPREG(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE);
>  
>  #undef DUMPREG
>  
>  #define DISPC_REG(i, name) name(i)
> -#define DUMPREG(i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
> +#define DUMPREG(dispc, i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
>  	(int)(48 - strlen(#r) - strlen(p_names[i])), " ", \
> -	dispc_read_reg(DISPC_REG(i, r)))
> +	dispc_read_reg(dispc, DISPC_REG(i, r)))
>  
>  	p_names = mgr_names;
>  
>  	/* DISPC channel specific registers */
> -	for (i = 0; i < dispc_get_num_mgrs(&dispc); i++) {
> -		DUMPREG(i, DISPC_DEFAULT_COLOR);
> -		DUMPREG(i, DISPC_TRANS_COLOR);
> -		DUMPREG(i, DISPC_SIZE_MGR);
> +	for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
> +		DUMPREG(dispc, i, DISPC_DEFAULT_COLOR);
> +		DUMPREG(dispc, i, DISPC_TRANS_COLOR);
> +		DUMPREG(dispc, i, DISPC_SIZE_MGR);
>  
>  		if (i == OMAP_DSS_CHANNEL_DIGIT)
>  			continue;
>  
> -		DUMPREG(i, DISPC_TIMING_H);
> -		DUMPREG(i, DISPC_TIMING_V);
> -		DUMPREG(i, DISPC_POL_FREQ);
> -		DUMPREG(i, DISPC_DIVISORo);
> +		DUMPREG(dispc, i, DISPC_TIMING_H);
> +		DUMPREG(dispc, i, DISPC_TIMING_V);
> +		DUMPREG(dispc, i, DISPC_POL_FREQ);
> +		DUMPREG(dispc, i, DISPC_DIVISORo);
>  
> -		DUMPREG(i, DISPC_DATA_CYCLE1);
> -		DUMPREG(i, DISPC_DATA_CYCLE2);
> -		DUMPREG(i, DISPC_DATA_CYCLE3);
> +		DUMPREG(dispc, i, DISPC_DATA_CYCLE1);
> +		DUMPREG(dispc, i, DISPC_DATA_CYCLE2);
> +		DUMPREG(dispc, i, DISPC_DATA_CYCLE3);
>  
> -		if (dispc_has_feature(FEAT_CPR)) {
> -			DUMPREG(i, DISPC_CPR_COEF_R);
> -			DUMPREG(i, DISPC_CPR_COEF_G);
> -			DUMPREG(i, DISPC_CPR_COEF_B);
> +		if (dispc_has_feature(dispc, FEAT_CPR)) {
> +			DUMPREG(dispc, i, DISPC_CPR_COEF_R);
> +			DUMPREG(dispc, i, DISPC_CPR_COEF_G);
> +			DUMPREG(dispc, i, DISPC_CPR_COEF_B);
>  		}
>  	}
>  
>  	p_names = ovl_names;
>  
> -	for (i = 0; i < dispc_get_num_ovls(&dispc); i++) {
> -		DUMPREG(i, DISPC_OVL_BA0);
> -		DUMPREG(i, DISPC_OVL_BA1);
> -		DUMPREG(i, DISPC_OVL_POSITION);
> -		DUMPREG(i, DISPC_OVL_SIZE);
> -		DUMPREG(i, DISPC_OVL_ATTRIBUTES);
> -		DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD);
> -		DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
> -		DUMPREG(i, DISPC_OVL_ROW_INC);
> -		DUMPREG(i, DISPC_OVL_PIXEL_INC);
> -
> -		if (dispc_has_feature(FEAT_PRELOAD))
> -			DUMPREG(i, DISPC_OVL_PRELOAD);
> -		if (dispc_has_feature(FEAT_MFLAG))
> -			DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
> +	for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
> +		DUMPREG(dispc, i, DISPC_OVL_BA0);
> +		DUMPREG(dispc, i, DISPC_OVL_BA1);
> +		DUMPREG(dispc, i, DISPC_OVL_POSITION);
> +		DUMPREG(dispc, i, DISPC_OVL_SIZE);
> +		DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
> +		DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
> +		DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
> +		DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
> +		DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
> +
> +		if (dispc_has_feature(dispc, FEAT_PRELOAD))
> +			DUMPREG(dispc, i, DISPC_OVL_PRELOAD);
> +		if (dispc_has_feature(dispc, FEAT_MFLAG))
> +			DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
>  
>  		if (i == OMAP_DSS_GFX) {
> -			DUMPREG(i, DISPC_OVL_WINDOW_SKIP);
> -			DUMPREG(i, DISPC_OVL_TABLE_BA);
> +			DUMPREG(dispc, i, DISPC_OVL_WINDOW_SKIP);
> +			DUMPREG(dispc, i, DISPC_OVL_TABLE_BA);
>  			continue;
>  		}
>  
> -		DUMPREG(i, DISPC_OVL_FIR);
> -		DUMPREG(i, DISPC_OVL_PICTURE_SIZE);
> -		DUMPREG(i, DISPC_OVL_ACCU0);
> -		DUMPREG(i, DISPC_OVL_ACCU1);
> -		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
> -			DUMPREG(i, DISPC_OVL_BA0_UV);
> -			DUMPREG(i, DISPC_OVL_BA1_UV);
> -			DUMPREG(i, DISPC_OVL_FIR2);
> -			DUMPREG(i, DISPC_OVL_ACCU2_0);
> -			DUMPREG(i, DISPC_OVL_ACCU2_1);
> +		DUMPREG(dispc, i, DISPC_OVL_FIR);
> +		DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
> +		DUMPREG(dispc, i, DISPC_OVL_ACCU0);
> +		DUMPREG(dispc, i, DISPC_OVL_ACCU1);
> +		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
> +			DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
> +			DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
> +			DUMPREG(dispc, i, DISPC_OVL_FIR2);
> +			DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
> +			DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
>  		}
> -		if (dispc_has_feature(FEAT_ATTR2))
> -			DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
> +		if (dispc_has_feature(dispc, FEAT_ATTR2))
> +			DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
>  	}
>  
> -	if (dispc.feat->has_writeback) {
> +	if (dispc->feat->has_writeback) {
>  		i = OMAP_DSS_WB;
> -		DUMPREG(i, DISPC_OVL_BA0);
> -		DUMPREG(i, DISPC_OVL_BA1);
> -		DUMPREG(i, DISPC_OVL_SIZE);
> -		DUMPREG(i, DISPC_OVL_ATTRIBUTES);
> -		DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD);
> -		DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
> -		DUMPREG(i, DISPC_OVL_ROW_INC);
> -		DUMPREG(i, DISPC_OVL_PIXEL_INC);
> -
> -		if (dispc_has_feature(FEAT_MFLAG))
> -			DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
> -
> -		DUMPREG(i, DISPC_OVL_FIR);
> -		DUMPREG(i, DISPC_OVL_PICTURE_SIZE);
> -		DUMPREG(i, DISPC_OVL_ACCU0);
> -		DUMPREG(i, DISPC_OVL_ACCU1);
> -		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
> -			DUMPREG(i, DISPC_OVL_BA0_UV);
> -			DUMPREG(i, DISPC_OVL_BA1_UV);
> -			DUMPREG(i, DISPC_OVL_FIR2);
> -			DUMPREG(i, DISPC_OVL_ACCU2_0);
> -			DUMPREG(i, DISPC_OVL_ACCU2_1);
> +		DUMPREG(dispc, i, DISPC_OVL_BA0);
> +		DUMPREG(dispc, i, DISPC_OVL_BA1);
> +		DUMPREG(dispc, i, DISPC_OVL_SIZE);
> +		DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
> +		DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
> +		DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
> +		DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
> +		DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
> +
> +		if (dispc_has_feature(dispc, FEAT_MFLAG))
> +			DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
> +
> +		DUMPREG(dispc, i, DISPC_OVL_FIR);
> +		DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
> +		DUMPREG(dispc, i, DISPC_OVL_ACCU0);
> +		DUMPREG(dispc, i, DISPC_OVL_ACCU1);
> +		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
> +			DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
> +			DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
> +			DUMPREG(dispc, i, DISPC_OVL_FIR2);
> +			DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
> +			DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
>  		}
> -		if (dispc_has_feature(FEAT_ATTR2))
> -			DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
> +		if (dispc_has_feature(dispc, FEAT_ATTR2))
> +			DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
>  	}
>  
>  #undef DISPC_REG
>  #undef DUMPREG
>  
>  #define DISPC_REG(plane, name, i) name(plane, i)
> -#define DUMPREG(plane, name, i) \
> +#define DUMPREG(dispc, plane, name, i) \
>  	seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \
>  	(int)(46 - strlen(#name) - strlen(p_names[plane])), " ", \
> -	dispc_read_reg(DISPC_REG(plane, name, i)))
> +	dispc_read_reg(dispc, DISPC_REG(plane, name, i)))
>  
>  	/* Video pipeline coefficient registers */
>  
>  	/* start from OMAP_DSS_VIDEO1 */
> -	for (i = 1; i < dispc_get_num_ovls(&dispc); i++) {
> +	for (i = 1; i < dispc_get_num_ovls(dispc); i++) {
>  		for (j = 0; j < 8; j++)
> -			DUMPREG(i, DISPC_OVL_FIR_COEF_H, j);
> +			DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H, j);
>  
>  		for (j = 0; j < 8; j++)
> -			DUMPREG(i, DISPC_OVL_FIR_COEF_HV, j);
> +			DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV, j);
>  
>  		for (j = 0; j < 5; j++)
> -			DUMPREG(i, DISPC_OVL_CONV_COEF, j);
> +			DUMPREG(dispc, i, DISPC_OVL_CONV_COEF, j);
>  
> -		if (dispc_has_feature(FEAT_FIR_COEF_V)) {
> +		if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
>  			for (j = 0; j < 8; j++)
> -				DUMPREG(i, DISPC_OVL_FIR_COEF_V, j);
> +				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V, j);
>  		}
>  
> -		if (dispc_has_feature(FEAT_HANDLE_UV_SEPARATE)) {
> +		if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
>  			for (j = 0; j < 8; j++)
> -				DUMPREG(i, DISPC_OVL_FIR_COEF_H2, j);
> +				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H2, j);
>  
>  			for (j = 0; j < 8; j++)
> -				DUMPREG(i, DISPC_OVL_FIR_COEF_HV2, j);
> +				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV2, j);
>  
>  			for (j = 0; j < 8; j++)
> -				DUMPREG(i, DISPC_OVL_FIR_COEF_V2, j);
> +				DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V2, j);
>  		}
>  	}
>  
> -	dispc_runtime_put(&dispc);
> +	dispc_runtime_put(dispc);
>  
>  #undef DISPC_REG
>  #undef DUMPREG
> @@ -3549,8 +3664,8 @@ bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
>  			 * also. Thus we need to use the calculated lck. For
>  			 * OMAP4+ the DISPC fclk is a separate clock.
>  			 */
> -			if (dispc_has_feature(FEAT_CORE_CLK_DIV))
> -				fck = dispc_core_clk_rate();
> +			if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
> +				fck = dispc_core_clk_rate(dispc);
>  			else
>  				fck = lck;
>  
> @@ -3572,7 +3687,7 @@ void dispc_mgr_set_clock_div(struct dispc_device *dispc,
>  	DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
>  	DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
>  
> -	dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div);
> +	dispc_mgr_set_lcd_divisor(dispc, channel, cinfo->lck_div, cinfo->pck_div);
>  }
>  
>  int dispc_mgr_get_clock_div(struct dispc_device *dispc,
> @@ -3581,10 +3696,10 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
>  {
>  	unsigned long fck;
>  
> -	fck = dispc_fclk_rate();
> +	fck = dispc_fclk_rate(dispc);
>  
> -	cinfo->lck_div = REG_GET(DISPC_DIVISORo(channel), 23, 16);
> -	cinfo->pck_div = REG_GET(DISPC_DIVISORo(channel), 7, 0);
> +	cinfo->lck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
> +	cinfo->pck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 7, 0);
>  
>  	cinfo->lck = fck / cinfo->lck_div;
>  	cinfo->pck = cinfo->lck / cinfo->pck_div;
> @@ -3594,35 +3709,36 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
>  
>  static u32 dispc_read_irqstatus(struct dispc_device *dispc)
>  {
> -	return dispc_read_reg(DISPC_IRQSTATUS);
> +	return dispc_read_reg(dispc, DISPC_IRQSTATUS);
>  }
>  
>  static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
>  {
> -	dispc_write_reg(DISPC_IRQSTATUS, mask);
> +	dispc_write_reg(dispc, DISPC_IRQSTATUS, mask);
>  }
>  
>  static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
>  {
> -	u32 old_mask = dispc_read_reg(DISPC_IRQENABLE);
> +	u32 old_mask = dispc_read_reg(dispc, DISPC_IRQENABLE);
>  
>  	/* clear the irqstatus for newly enabled irqs */
>  	dispc_clear_irqstatus(dispc, (mask ^ old_mask) & mask);
>  
> -	dispc_write_reg(DISPC_IRQENABLE, mask);
> +	dispc_write_reg(dispc, DISPC_IRQENABLE, mask);
>  
>  	/* flush posted write */
> -	dispc_read_reg(DISPC_IRQENABLE);
> +	dispc_read_reg(dispc, DISPC_IRQENABLE);
>  }
>  
>  void dispc_enable_sidle(struct dispc_device *dispc)
>  {
> -	REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3);	/* SIDLEMODE: smart idle */
> +	/* SIDLEMODE: smart idle */
> +	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 2, 4, 3);
>  }
>  
>  void dispc_disable_sidle(struct dispc_device *dispc)
>  {
> -	REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
> +	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
>  }
>  
>  static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
> @@ -3636,10 +3752,11 @@ static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
>  	return gdesc->len;
>  }
>  
> -static void dispc_mgr_write_gamma_table(enum omap_channel channel)
> +static void dispc_mgr_write_gamma_table(struct dispc_device *dispc,
> +					enum omap_channel channel)
>  {
>  	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
> -	u32 *table = dispc.gamma_table[channel];
> +	u32 *table = dispc->gamma_table[channel];
>  	unsigned int i;
>  
>  	DSSDBG("%s: channel %d\n", __func__, channel);
> @@ -3652,26 +3769,26 @@ static void dispc_mgr_write_gamma_table(enum omap_channel channel)
>  		else if (i == 0)
>  			v |= 1 << 31;
>  
> -		dispc_write_reg(gdesc->reg, v);
> +		dispc_write_reg(dispc, gdesc->reg, v);
>  	}
>  }
>  
> -static void dispc_restore_gamma_tables(void)
> +static void dispc_restore_gamma_tables(struct dispc_device *dispc)
>  {
>  	DSSDBG("%s()\n", __func__);
>  
> -	if (!dispc.feat->has_gamma_table)
> +	if (!dispc->feat->has_gamma_table)
>  		return;
>  
> -	dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD);
> +	dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD);
>  
> -	dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_DIGIT);
> +	dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_DIGIT);
>  
> -	if (dispc_has_feature(FEAT_MGR_LCD2))
> -		dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD2);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
> +		dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD2);
>  
> -	if (dispc_has_feature(FEAT_MGR_LCD3))
> -		dispc_mgr_write_gamma_table(OMAP_DSS_CHANNEL_LCD3);
> +	if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
> +		dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD3);
>  }
>  
>  static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
> @@ -3724,81 +3841,82 @@ static void dispc_mgr_set_gamma(struct dispc_device *dispc,
>  	}
>  
>  	if (dispc->is_enabled)
> -		dispc_mgr_write_gamma_table(channel);
> +		dispc_mgr_write_gamma_table(dispc, channel);
>  }
>  
> -static int dispc_init_gamma_tables(void)
> +static int dispc_init_gamma_tables(struct dispc_device *dispc)
>  {
>  	int channel;
>  
> -	if (!dispc.feat->has_gamma_table)
> +	if (!dispc->feat->has_gamma_table)
>  		return 0;
>  
> -	for (channel = 0; channel < ARRAY_SIZE(dispc.gamma_table); channel++) {
> +	for (channel = 0; channel < ARRAY_SIZE(dispc->gamma_table); channel++) {
>  		const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
>  		u32 *gt;
>  
>  		if (channel == OMAP_DSS_CHANNEL_LCD2 &&
> -		    !dispc_has_feature(FEAT_MGR_LCD2))
> +		    !dispc_has_feature(dispc, FEAT_MGR_LCD2))
>  			continue;
>  
>  		if (channel == OMAP_DSS_CHANNEL_LCD3 &&
> -		    !dispc_has_feature(FEAT_MGR_LCD3))
> +		    !dispc_has_feature(dispc, FEAT_MGR_LCD3))
>  			continue;
>  
> -		gt = devm_kmalloc_array(&dispc.pdev->dev, gdesc->len,
> -					   sizeof(u32), GFP_KERNEL);
> +		gt = devm_kmalloc_array(&dispc->pdev->dev, gdesc->len,
> +					sizeof(u32), GFP_KERNEL);
>  		if (!gt)
>  			return -ENOMEM;
>  
> -		dispc.gamma_table[channel] = gt;
> +		dispc->gamma_table[channel] = gt;
>  
> -		dispc_mgr_set_gamma(&dispc, channel, NULL, 0);
> +		dispc_mgr_set_gamma(dispc, channel, NULL, 0);
>  	}
>  	return 0;
>  }
>  
> -static void _omap_dispc_initial_config(void)
> +static void _omap_dispc_initial_config(struct dispc_device *dispc)
>  {
>  	u32 l;
>  
>  	/* Exclusively enable DISPC_CORE_CLK and set divider to 1 */
> -	if (dispc_has_feature(FEAT_CORE_CLK_DIV)) {
> -		l = dispc_read_reg(DISPC_DIVISOR);
> +	if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
> +		l = dispc_read_reg(dispc, DISPC_DIVISOR);
>  		/* Use DISPC_DIVISOR.LCD, instead of DISPC_DIVISOR1.LCD */
>  		l = FLD_MOD(l, 1, 0, 0);
>  		l = FLD_MOD(l, 1, 23, 16);
> -		dispc_write_reg(DISPC_DIVISOR, l);
> +		dispc_write_reg(dispc, DISPC_DIVISOR, l);
>  
> -		dispc.core_clk_rate = dispc_fclk_rate();
> +		dispc->core_clk_rate = dispc_fclk_rate(dispc);
>  	}
>  
>  	/* Use gamma table mode, instead of palette mode */
> -	if (dispc.feat->has_gamma_table)
> -		REG_FLD_MOD(DISPC_CONFIG, 1, 3, 3);
> +	if (dispc->feat->has_gamma_table)
> +		REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 3, 3);
>  
>  	/* For older DSS versions (FEAT_FUNCGATED) this enables
>  	 * func-clock auto-gating. For newer versions
> -	 * (dispc.feat->has_gamma_table) this enables tv-out gamma tables.
> +	 * (dispc->feat->has_gamma_table) this enables tv-out gamma tables.
>  	 */
> -	if (dispc_has_feature(FEAT_FUNCGATED) || dispc.feat->has_gamma_table)
> -		REG_FLD_MOD(DISPC_CONFIG, 1, 9, 9);
> +	if (dispc_has_feature(dispc, FEAT_FUNCGATED) ||
> +	    dispc->feat->has_gamma_table)
> +		REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 9, 9);
>  
> -	dispc_setup_color_conv_coef();
> +	dispc_setup_color_conv_coef(dispc);
>  
> -	dispc_set_loadmode(OMAP_DSS_LOAD_FRAME_ONLY);
> +	dispc_set_loadmode(dispc, OMAP_DSS_LOAD_FRAME_ONLY);
>  
> -	dispc_init_fifos();
> +	dispc_init_fifos(dispc);
>  
> -	dispc_configure_burst_sizes();
> +	dispc_configure_burst_sizes(dispc);
>  
> -	dispc_ovl_enable_zorder_planes();
> +	dispc_ovl_enable_zorder_planes(dispc);
>  
> -	if (dispc.feat->mstandby_workaround)
> -		REG_FLD_MOD(DISPC_MSTANDBY_CTRL, 1, 0, 0);
> +	if (dispc->feat->mstandby_workaround)
> +		REG_FLD_MOD(dispc, DISPC_MSTANDBY_CTRL, 1, 0, 0);
>  
> -	if (dispc_has_feature(FEAT_MFLAG))
> -		dispc_init_mflag();
> +	if (dispc_has_feature(dispc, FEAT_MFLAG))
> +		dispc_init_mflag(dispc);
>  }
>  
>  static const enum dispc_feature_id omap2_dispc_features_list[] = {
> @@ -4317,10 +4435,12 @@ static const struct dispc_features omap54xx_dispc_feats = {
>  
>  static irqreturn_t dispc_irq_handler(int irq, void *arg)
>  {
> -	if (!dispc.is_enabled)
> +	struct dispc_device *dispc = arg;
> +
> +	if (!dispc->is_enabled)
>  		return IRQ_NONE;
>  
> -	return dispc.user_handler(irq, dispc.user_data);
> +	return dispc->user_handler(irq, dispc->user_data);
>  }
>  
>  static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
> @@ -4426,18 +4546,18 @@ static struct i734_buf {
>  	void *vaddr;
>  } i734_buf;
>  
> -static int dispc_errata_i734_wa_init(void)
> +static int dispc_errata_i734_wa_init(struct dispc_device *dispc)
>  {
> -	if (!dispc.feat->has_gamma_i734_bug)
> +	if (!dispc->feat->has_gamma_i734_bug)
>  		return 0;
>  
>  	i734_buf.size = i734.ovli.width * i734.ovli.height *
>  		color_mode_to_bpp(i734.ovli.fourcc) / 8;
>  
> -	i734_buf.vaddr = dma_alloc_writecombine(&dispc.pdev->dev, i734_buf.size,
> +	i734_buf.vaddr = dma_alloc_writecombine(&dispc->pdev->dev, i734_buf.size,
>  						&i734_buf.paddr, GFP_KERNEL);
>  	if (!i734_buf.vaddr) {
> -		dev_err(&dispc.pdev->dev, "%s: dma_alloc_writecombine failed",
> +		dev_err(&dispc->pdev->dev, "%s: dma_alloc_writecombine failed",
>  			__func__);
>  		return -ENOMEM;
>  	}
> @@ -4445,73 +4565,73 @@ static int dispc_errata_i734_wa_init(void)
>  	return 0;
>  }
>  
> -static void dispc_errata_i734_wa_fini(void)
> +static void dispc_errata_i734_wa_fini(struct dispc_device *dispc)
>  {
> -	if (!dispc.feat->has_gamma_i734_bug)
> +	if (!dispc->feat->has_gamma_i734_bug)
>  		return;
>  
> -	dma_free_writecombine(&dispc.pdev->dev, i734_buf.size, i734_buf.vaddr,
> +	dma_free_writecombine(&dispc->pdev->dev, i734_buf.size, i734_buf.vaddr,
>  			      i734_buf.paddr);
>  }
>  
> -static void dispc_errata_i734_wa(void)
> +static void dispc_errata_i734_wa(struct dispc_device *dispc)
>  {
> -	u32 framedone_irq = dispc_mgr_get_framedone_irq(&dispc,
> +	u32 framedone_irq = dispc_mgr_get_framedone_irq(dispc,
>  							OMAP_DSS_CHANNEL_LCD);
>  	struct omap_overlay_info ovli;
>  	struct dss_lcd_mgr_config lcd_conf;
>  	u32 gatestate;
>  	unsigned int count;
>  
> -	if (!dispc.feat->has_gamma_i734_bug)
> +	if (!dispc->feat->has_gamma_i734_bug)
>  		return;
>  
> -	gatestate = REG_GET(DISPC_CONFIG, 8, 4);
> +	gatestate = REG_GET(dispc, DISPC_CONFIG, 8, 4);
>  
>  	ovli = i734.ovli;
>  	ovli.paddr = i734_buf.paddr;
>  	lcd_conf = i734.lcd_conf;
>  
>  	/* Gate all LCD1 outputs */
> -	REG_FLD_MOD(DISPC_CONFIG, 0x1f, 8, 4);
> +	REG_FLD_MOD(dispc, DISPC_CONFIG, 0x1f, 8, 4);
>  
>  	/* Setup and enable GFX plane */
> -	dispc_ovl_setup(&dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
> +	dispc_ovl_setup(dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
>  			OMAP_DSS_CHANNEL_LCD);
> -	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, true);
> +	dispc_ovl_enable(dispc, OMAP_DSS_GFX, true);
>  
>  	/* Set up and enable display manager for LCD1 */
> -	dispc_mgr_setup(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
> -	dispc_calc_clock_rates(&dispc, dss_get_dispc_clk_rate(dispc.dss),
> +	dispc_mgr_setup(dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
> +	dispc_calc_clock_rates(dispc, dss_get_dispc_clk_rate(dispc->dss),
>  			       &lcd_conf.clock_info);
> -	dispc_mgr_set_lcd_config(&dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
> -	dispc_mgr_set_timings(&dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
> +	dispc_mgr_set_lcd_config(dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
> +	dispc_mgr_set_timings(dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
>  
> -	dispc_clear_irqstatus(&dispc, framedone_irq);
> +	dispc_clear_irqstatus(dispc, framedone_irq);
>  
>  	/* Enable and shut the channel to produce just one frame */
> -	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, true);
> -	dispc_mgr_enable(&dispc, OMAP_DSS_CHANNEL_LCD, false);
> +	dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, true);
> +	dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, false);
>  
>  	/* Busy wait for framedone. We can't fiddle with irq handlers
>  	 * in PM resume. Typically the loop runs less than 5 times and
>  	 * waits less than a micro second.
>  	 */
>  	count = 0;
> -	while (!(dispc_read_irqstatus(&dispc) & framedone_irq)) {
> +	while (!(dispc_read_irqstatus(dispc) & framedone_irq)) {
>  		if (count++ > 10000) {
> -			dev_err(&dispc.pdev->dev, "%s: framedone timeout\n",
> +			dev_err(&dispc->pdev->dev, "%s: framedone timeout\n",
>  				__func__);
>  			break;
>  		}
>  	}
> -	dispc_ovl_enable(&dispc, OMAP_DSS_GFX, false);
> +	dispc_ovl_enable(dispc, OMAP_DSS_GFX, false);
>  
>  	/* Clear all irq bits before continuing */
> -	dispc_clear_irqstatus(&dispc, 0xffffffff);
> +	dispc_clear_irqstatus(dispc, 0xffffffff);
>  
>  	/* Restore the original state to LCD1 output gates */
> -	REG_FLD_MOD(DISPC_CONFIG, gatestate, 8, 4);
> +	REG_FLD_MOD(dispc, DISPC_CONFIG, gatestate, 8, 4);
>  }
>  
>  static const struct dispc_ops dispc_ops = {
> @@ -4571,15 +4691,21 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	const struct soc_device_attribute *soc;
>  	struct dss_device *dss = dss_get_device(master);
> +	struct dispc_device *dispc;
>  	u32 rev;
>  	int r = 0;
>  	struct resource *dispc_mem;
>  	struct device_node *np = pdev->dev.of_node;
>  
> -	dispc.pdev = pdev;
> -	dispc.dss = dss;
> +	dispc = kzalloc(sizeof(*dispc), GFP_KERNEL);
> +	if (!dispc)
> +		return -ENOMEM;
> +
> +	dispc->pdev = pdev;
> +	platform_set_drvdata(pdev, dispc);
> +	dispc->dss = dss;
>  
> -	spin_lock_init(&dispc.control_lock);
> +	spin_lock_init(&dispc->control_lock);
>  
>  	/*
>  	 * The OMAP3-based models can't be told apart using the compatible
> @@ -4587,82 +4713,92 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	 */
>  	soc = soc_device_match(dispc_soc_devices);
>  	if (soc)
> -		dispc.feat = soc->data;
> +		dispc->feat = soc->data;
>  	else
> -		dispc.feat = of_match_device(dispc_of_match, &pdev->dev)->data;
> +		dispc->feat = of_match_device(dispc_of_match, &pdev->dev)->data;
>  
> -	r = dispc_errata_i734_wa_init();
> +	r = dispc_errata_i734_wa_init(dispc);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
> -	dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
> -	dispc.base = devm_ioremap_resource(&pdev->dev, dispc_mem);
> -	if (IS_ERR(dispc.base))
> -		return PTR_ERR(dispc.base);
> +	dispc_mem = platform_get_resource(dispc->pdev, IORESOURCE_MEM, 0);
> +	dispc->base = devm_ioremap_resource(&pdev->dev, dispc_mem);
> +	if (IS_ERR(dispc->base)) {
> +		r = PTR_ERR(dispc->base);
> +		goto err_free;
> +	}
>  
> -	dispc.irq = platform_get_irq(dispc.pdev, 0);
> -	if (dispc.irq < 0) {
> +	dispc->irq = platform_get_irq(dispc->pdev, 0);
> +	if (dispc->irq < 0) {
>  		DSSERR("platform_get_irq failed\n");
> -		return -ENODEV;
> +		r = -ENODEV;
> +		goto err_free;
>  	}
>  
>  	if (np && of_property_read_bool(np, "syscon-pol")) {
> -		dispc.syscon_pol = syscon_regmap_lookup_by_phandle(np, "syscon-pol");
> -		if (IS_ERR(dispc.syscon_pol)) {
> +		dispc->syscon_pol = syscon_regmap_lookup_by_phandle(np, "syscon-pol");
> +		if (IS_ERR(dispc->syscon_pol)) {
>  			dev_err(&pdev->dev, "failed to get syscon-pol regmap\n");
> -			return PTR_ERR(dispc.syscon_pol);
> +			r = PTR_ERR(dispc->syscon_pol);
> +			goto err_free;
>  		}
>  
>  		if (of_property_read_u32_index(np, "syscon-pol", 1,
> -				&dispc.syscon_pol_offset)) {
> +				&dispc->syscon_pol_offset)) {
>  			dev_err(&pdev->dev, "failed to get syscon-pol offset\n");
> -			return -EINVAL;
> +			r = -EINVAL;
> +			goto err_free;
>  		}
>  	}
>  
> -	r = dispc_init_gamma_tables();
> +	r = dispc_init_gamma_tables(dispc);
>  	if (r)
> -		return r;
> +		goto err_free;
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> -	r = dispc_runtime_get(&dispc);
> +	r = dispc_runtime_get(dispc);
>  	if (r)
>  		goto err_runtime_get;
>  
> -	_omap_dispc_initial_config();
> +	_omap_dispc_initial_config(dispc);
>  
> -	rev = dispc_read_reg(DISPC_REVISION);
> +	rev = dispc_read_reg(dispc, DISPC_REVISION);
>  	dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
>  	       FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
>  
> -	dispc_runtime_put(&dispc);
> +	dispc_runtime_put(dispc);
>  
>  	dispc_set_ops(&dispc_ops);
> -	dss->dispc = &dispc;
> +	dss->dispc = dispc;
>  
> -	dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
> -						&dispc);
> +	dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
> +						 dispc);
>  
>  	return 0;
>  
>  err_runtime_get:
>  	pm_runtime_disable(&pdev->dev);
> +err_free:
> +	kfree(dispc);
>  	return r;
>  }
>  
>  static void dispc_unbind(struct device *dev, struct device *master, void *data)
>  {
> -	struct dss_device *dss = dispc.dss;
> +	struct dispc_device *dispc = dev_get_drvdata(dev);
> +	struct dss_device *dss = dispc->dss;
>  
> -	dss_debugfs_remove_file(dispc.debugfs);
> +	dss_debugfs_remove_file(dispc->debugfs);
>  
>  	dispc_set_ops(NULL);
>  	dss->dispc = NULL;
>  
>  	pm_runtime_disable(dev);
>  
> -	dispc_errata_i734_wa_fini();
> +	dispc_errata_i734_wa_fini(dispc);
> +
> +	kfree(dispc);
>  }
>  
>  static const struct component_ops dispc_component_ops = {
> @@ -4683,36 +4819,40 @@ static int dispc_remove(struct platform_device *pdev)
>  
>  static int dispc_runtime_suspend(struct device *dev)
>  {
> -	dispc.is_enabled = false;
> +	struct dispc_device *dispc = dev_get_drvdata(dev);
> +
> +	dispc->is_enabled = false;
>  	/* ensure the dispc_irq_handler sees the is_enabled value */
>  	smp_wmb();
>  	/* wait for current handler to finish before turning the DISPC off */
> -	synchronize_irq(dispc.irq);
> +	synchronize_irq(dispc->irq);
>  
> -	dispc_save_context();
> +	dispc_save_context(dispc);
>  
>  	return 0;
>  }
>  
>  static int dispc_runtime_resume(struct device *dev)
>  {
> +	struct dispc_device *dispc = dev_get_drvdata(dev);
> +
>  	/*
>  	 * The reset value for load mode is 0 (OMAP_DSS_LOAD_CLUT_AND_FRAME)
>  	 * but we always initialize it to 2 (OMAP_DSS_LOAD_FRAME_ONLY) in
>  	 * _omap_dispc_initial_config(). We can thus use it to detect if
>  	 * we have lost register context.
>  	 */
> -	if (REG_GET(DISPC_CONFIG, 2, 1) != OMAP_DSS_LOAD_FRAME_ONLY) {
> -		_omap_dispc_initial_config();
> +	if (REG_GET(dispc, DISPC_CONFIG, 2, 1) != OMAP_DSS_LOAD_FRAME_ONLY) {
> +		_omap_dispc_initial_config(dispc);
>  
> -		dispc_errata_i734_wa();
> +		dispc_errata_i734_wa(dispc);
>  
> -		dispc_restore_context();
> +		dispc_restore_context(dispc);
>  
> -		dispc_restore_gamma_tables();
> +		dispc_restore_gamma_tables(dispc);
>  	}
>  
> -	dispc.is_enabled = true;
> +	dispc->is_enabled = true;
>  	/* ensure the dispc_irq_handler sees the is_enabled value */
>  	smp_wmb();
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device
  2017-10-13 14:59 ` [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Laurent Pinchart
@ 2017-10-17 22:16   ` Sebastian Reichel
  2017-10-17 22:34     ` Laurent Pinchart
  0 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 22:16 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 9036 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:43PM +0300, Laurent Pinchart wrote:
> As part of an effort to remove the usage of global variables in the
> driver, store the debugfs root directory in the dss_device structure
> instead of a global variable.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
>  drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 ++++----
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 39 +++++++++++++++++++------------------
>  drivers/gpu/drm/omapdrm/dss/dss.h   |  9 ++++++---
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 ++-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 ++-
>  drivers/gpu/drm/omapdrm/dss/venc.c  |  3 ++-
>  7 files changed, 37 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index aaf7396f0273..5eacf4cdac54 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -4772,7 +4772,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	dispc_set_ops(&dispc_ops);
>  	dss->dispc = dispc;
>  
> -	dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
> +	dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
>  						 dispc);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index c7700dfccc08..48ea5285cf20 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5453,20 +5453,20 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
>  	dsi_runtime_put(dsi);
>  
>  	if (dsi->module_id == 0)
> -		dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
> +		dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi1_regs",
>  							    dsi1_dump_regs,
>  							    &dsi);
>  	else
> -		dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
> +		dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi2_regs",
>  							    dsi2_dump_regs,
>  							    &dsi);
>  #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
>  	if (dsi->module_id == 0)
> -		dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
> +		dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi1_irqs",
>  							    dsi1_dump_irqs,
>  							    &dsi);
>  	else
> -		dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
> +		dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi2_irqs",
>  							    dsi2_dump_irqs,
>  							    &dsi);
>  #endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 5d927dfe0a7f..f4e15850cc9d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -906,25 +906,23 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
>  	return 0;
>  }
>  
> -static struct dentry *dss_debugfs_dir;
> -
>  static int dss_initialize_debugfs(struct dss_device *dss)
>  {
> -	dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
> -	if (IS_ERR(dss_debugfs_dir)) {
> -		int err = PTR_ERR(dss_debugfs_dir);
> +	static struct dentry *dir;

static?

Otherwise:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> -		dss_debugfs_dir = NULL;
> -		return err;
> -	}
> +	dir = debugfs_create_dir("omapdss", NULL);
> +	if (IS_ERR(dir))
> +		return PTR_ERR(dir);
> +
> +	dss->debugfs.root = dir;
>  
>  	return 0;
>  }
>  
> -static void dss_uninitialize_debugfs(void)
> +static void dss_uninitialize_debugfs(struct dss_device *dss)
>  {
> -	if (dss_debugfs_dir)
> -		debugfs_remove_recursive(dss_debugfs_dir);
> +	if (dss->debugfs.root)
> +		debugfs_remove_recursive(dss->debugfs.root);
>  }
>  
>  struct dss_debugfs_entry {
> @@ -947,8 +945,10 @@ static const struct file_operations dss_debug_fops = {
>  	.release	= single_release,
>  };
>  
> -struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
> -		int (*show_fn)(struct seq_file *s, void *data), void *data)
> +struct dss_debugfs_entry *
> +dss_debugfs_create_file(struct dss_device *dss, const char *name,
> +			int (*show_fn)(struct seq_file *s, void *data),
> +			void *data)
>  {
>  	struct dss_debugfs_entry *entry;
>  	struct dentry *d;
> @@ -960,7 +960,7 @@ struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
>  	entry->show_fn = show_fn;
>  	entry->data = data;
>  
> -	d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
> +	d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
>  				&dss_debug_fops);
>  	if (IS_ERR(d)) {
>  		kfree(entry);
> @@ -985,7 +985,7 @@ static inline int dss_initialize_debugfs(struct dss_device *dss)
>  {
>  	return 0;
>  }
> -static inline void dss_uninitialize_debugfs(void)
> +static inline void dss_uninitialize_debugfs(struct dss_device *dss)
>  {
>  }
>  #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
> @@ -1382,9 +1382,10 @@ static int dss_bind(struct device *dev)
>  	if (r)
>  		goto err_component;
>  
> -	dss->debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
> +	dss->debugfs.clk = dss_debugfs_create_file(dss, "clk",
> +						   dss_debug_dump_clocks, dss);
> +	dss->debugfs.dss = dss_debugfs_create_file(dss, "dss", dss_dump_regs,
>  						   dss);
> -	dss->debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, dss);
>  
>  	pm_set_vt_switch(0);
>  
> @@ -1511,7 +1512,7 @@ static int dss_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_debugfs:
> -	dss_uninitialize_debugfs();
> +	dss_uninitialize_debugfs(dss);
>  err_free_dss:
>  	kfree(dss);
>  	return r;
> @@ -1523,7 +1524,7 @@ static int dss_remove(struct platform_device *pdev)
>  
>  	component_master_del(&pdev->dev, &dss_component_ops);
>  
> -	dss_uninitialize_debugfs();
> +	dss_uninitialize_debugfs(dss);
>  	kfree(dss);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index ceba8441c7cc..76a2561dfd22 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -271,6 +271,7 @@ struct dss_device {
>  	const struct dss_features *feat;
>  
>  	struct {
> +		struct dentry *root;
>  		struct dss_debugfs_entry *clk;
>  		struct dss_debugfs_entry *dss;
>  	} debugfs;
> @@ -299,12 +300,14 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
>  
>  /* DSS */
>  #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
> -struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
> -		int (*show_fn)(struct seq_file *s, void *data), void *data);
> +struct dss_debugfs_entry *
> +dss_debugfs_create_file(struct dss_device *dss, const char *name,
> +			int (*show_fn)(struct seq_file *s, void *data),
> +			void *data);
>  void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
>  #else
>  static inline struct dss_debugfs_entry *
> -dss_debugfs_create_file(const char *name,
> +dss_debugfs_create_file(struct dss_device *dss, const char *name,
>  			int (*show_fn)(struct seq_file *s, void *data),
>  			void *data)
>  {
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 2050601fef0a..f523b426420f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -800,7 +800,8 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
>  		return r;
>  	}
>  
> -	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
> +	hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
> +						hdmi);
>  
>  	return 0;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index ec3b044925d0..9017d78a9756 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -794,7 +794,8 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
>  		return r;
>  	}
>  
> -	hdmi->debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, hdmi);
> +	hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
> +						hdmi);
>  
>  	return 0;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 449a82b84d03..5e475cafb7a4 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -940,7 +940,8 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
>  		goto err_probe_of;
>  	}
>  
> -	venc->debugfs = dss_debugfs_create_file("venc", venc_dump_regs, venc);
> +	venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs,
> +						venc);
>  
>  	venc_init_output(venc);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array in struct dss_device
  2017-10-13 14:59 ` [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array " Laurent Pinchart
@ 2017-10-17 22:21   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 22:21 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 10078 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:44PM +0300, Laurent Pinchart wrote:
> As part of an effort to remove the usage of global variables in the
> driver, store the registered plls array in the dss_device structure
> instead of a global variable.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dispc.c     |  4 ++--
>  drivers/gpu/drm/omapdrm/dss/dpi.c       | 17 +++++++-------
>  drivers/gpu/drm/omapdrm/dss/dsi.c       |  3 +--
>  drivers/gpu/drm/omapdrm/dss/dss.h       | 12 +++++-----
>  drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  3 +--
>  drivers/gpu/drm/omapdrm/dss/pll.c       | 40 +++++++++++++++++----------------
>  drivers/gpu/drm/omapdrm/dss/video-pll.c |  3 +--
>  7 files changed, 42 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 5eacf4cdac54..181a8ea072b1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -3252,7 +3252,7 @@ static unsigned long dispc_fclk_rate(struct dispc_device *dispc)
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
>  
> -		pll = dss_pll_find_by_src(src);
> +		pll = dss_pll_find_by_src(dispc->dss, src);
>  		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
>  
>  		r = pll->cinfo.clkout[clkout_idx];
> @@ -3280,7 +3280,7 @@ static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
>  		struct dss_pll *pll;
>  		unsigned int clkout_idx;
>  
> -		pll = dss_pll_find_by_src(src);
> +		pll = dss_pll_find_by_src(dispc->dss, src);
>  		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
>  
>  		r = pll->cinfo.clkout[clkout_idx];
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 66183fc77bb2..2fb9406d2059 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -60,7 +60,8 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
>  	return container_of(dssdev, struct dpi_data, output);
>  }
>  
> -static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
> +static enum dss_clk_source dpi_get_clk_src_dra7xx(struct dpi_data *dpi,
> +						  enum omap_channel channel)
>  {
>  	/*
>  	 * Possible clock sources:
> @@ -72,23 +73,23 @@ static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
>  	switch (channel) {
>  	case OMAP_DSS_CHANNEL_LCD:
>  	{
> -		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1))
> +		if (dss_pll_find_by_src(dpi->dss, 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))
> +		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
>  			return DSS_CLK_SRC_PLL1_3;
> -		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3))
> +		if (dss_pll_find_by_src(dpi->dss, 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))
> +		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_1))
>  			return DSS_CLK_SRC_PLL2_1;
> -		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
> +		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
>  			return DSS_CLK_SRC_PLL1_3;
>  		break;
>  	}
> @@ -135,7 +136,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
>  		}
>  
>  	case DSS_MODEL_DRA7:
> -		return dpi_get_clk_src_dra7xx(channel);
> +		return dpi_get_clk_src_dra7xx(dpi, channel);
>  
>  	default:
>  		return DSS_CLK_SRC_FCK;
> @@ -603,7 +604,7 @@ static void dpi_init_pll(struct dpi_data *dpi)
>  
>  	dpi->clk_src = dpi_get_clk_src(dpi);
>  
> -	pll = dss_pll_find_by_src(dpi->clk_src);
> +	pll = dss_pll_find_by_src(dpi->dss, dpi->clk_src);
>  	if (!pll)
>  		return;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 48ea5285cf20..bc9d6b7ce6a9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5226,9 +5226,8 @@ static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi)
>  	pll->base = dsi->pll_base;
>  	pll->hw = dsi->data->pll_hw;
>  	pll->ops = &dsi_pll_ops;
> -	pll->dss = dss;
>  
> -	r = dss_pll_register(pll);
> +	r = dss_pll_register(dss, pll);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 76a2561dfd22..9ca4391624cc 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -276,8 +276,9 @@ struct dss_device {
>  		struct dss_debugfs_entry *dss;
>  	} debugfs;
>  
> -	struct dss_pll	*video1_pll;
> -	struct dss_pll	*video2_pll;
> +	struct dss_pll *plls[4];
> +	struct dss_pll *video1_pll;
> +	struct dss_pll *video2_pll;
>  
>  	struct dispc_device *dispc;
>  };
> @@ -499,10 +500,11 @@ typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
>  typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
>  		void *data);
>  
> -int dss_pll_register(struct dss_pll *pll);
> +int dss_pll_register(struct dss_device *dss, struct dss_pll *pll);
>  void dss_pll_unregister(struct dss_pll *pll);
> -struct dss_pll *dss_pll_find(const char *name);
> -struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
> +struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name);
> +struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
> +				    enum dss_clk_source src);
>  unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
>  int dss_pll_enable(struct dss_pll *pll);
>  void dss_pll_disable(struct dss_pll *pll);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> index 4da32c261c30..d1116757182e 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> @@ -146,7 +146,6 @@ static int hdmi_init_pll_data(struct dss_device *dss,
>  	pll->id = DSS_PLL_HDMI;
>  	pll->base = hpll->base;
>  	pll->clkin = clk;
> -	pll->dss = dss;
>  
>  	if (hpll->wp->version == 4)
>  		pll->hw = &dss_omap4_hdmi_pll_hw;
> @@ -155,7 +154,7 @@ static int hdmi_init_pll_data(struct dss_device *dss,
>  
>  	pll->ops = &hdmi_pll_ops;
>  
> -	r = dss_pll_register(pll);
> +	r = dss_pll_register(dss, pll);
>  	if (r)
>  		return r;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
> index d298cd5a927a..56fc2fccd0e0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/pll.c
> @@ -35,15 +35,14 @@
>  #define PLL_SSC_CONFIGURATION2		0x001C
>  #define PLL_CONFIGURATION4		0x0020
>  
> -static struct dss_pll *dss_plls[4];
> -
> -int dss_pll_register(struct dss_pll *pll)
> +int dss_pll_register(struct dss_device *dss, struct dss_pll *pll)
>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
> -		if (!dss_plls[i]) {
> -			dss_plls[i] = pll;
> +	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
> +		if (!dss->plls[i]) {
> +			dss->plls[i] = pll;
> +			pll->dss = dss;
>  			return 0;
>  		}
>  	}
> @@ -53,29 +52,32 @@ int dss_pll_register(struct dss_pll *pll)
>  
>  void dss_pll_unregister(struct dss_pll *pll)
>  {
> +	struct dss_device *dss = pll->dss;
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
> -		if (dss_plls[i] == pll) {
> -			dss_plls[i] = NULL;
> +	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
> +		if (dss->plls[i] == pll) {
> +			dss->plls[i] = NULL;
> +			pll->dss = NULL;
>  			return;
>  		}
>  	}
>  }
>  
> -struct dss_pll *dss_pll_find(const char *name)
> +struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name)
>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
> -		if (dss_plls[i] && strcmp(dss_plls[i]->name, name) == 0)
> -			return dss_plls[i];
> +	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
> +		if (dss->plls[i] && strcmp(dss->plls[i]->name, name) == 0)
> +			return dss->plls[i];
>  	}
>  
>  	return NULL;
>  }
>  
> -struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
> +struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
> +				    enum dss_clk_source src)
>  {
>  	struct dss_pll *pll;
>  
> @@ -85,22 +87,22 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
>  		return NULL;
>  
>  	case DSS_CLK_SRC_HDMI_PLL:
> -		return dss_pll_find("hdmi");
> +		return dss_pll_find(dss, "hdmi");
>  
>  	case DSS_CLK_SRC_PLL1_1:
>  	case DSS_CLK_SRC_PLL1_2:
>  	case DSS_CLK_SRC_PLL1_3:
> -		pll = dss_pll_find("dsi0");
> +		pll = dss_pll_find(dss, "dsi0");
>  		if (!pll)
> -			pll = dss_pll_find("video0");
> +			pll = dss_pll_find(dss, "video0");
>  		return pll;
>  
>  	case DSS_CLK_SRC_PLL2_1:
>  	case DSS_CLK_SRC_PLL2_2:
>  	case DSS_CLK_SRC_PLL2_3:
> -		pll = dss_pll_find("dsi1");
> +		pll = dss_pll_find(dss, "dsi1");
>  		if (!pll)
> -			pll = dss_pll_find("video1");
> +			pll = dss_pll_find(dss, "video1");
>  		return pll;
>  	}
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> index 989a5ee4433a..2ea50cbe53ab 100644
> --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> @@ -188,9 +188,8 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
>  	pll->base = pll_base;
>  	pll->hw = &dss_dra7_video_pll_hw;
>  	pll->ops = &dss_pll_ops;
> -	pll->dss = dss;
>  
> -	r = dss_pll_register(pll);
> +	r = dss_pll_register(dss, pll);
>  	if (r)
>  		return ERR_PTR(r);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header.
  2017-10-13 14:59 ` [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header Laurent Pinchart
@ 2017-10-17 22:25   ` Sebastian Reichel
  0 siblings, 0 replies; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 22:25 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 24388 bytes --]

Hi,

On Fri, Oct 13, 2017 at 05:59:05PM +0300, Laurent Pinchart wrote:
> The number of function declarations in the omap_drv.h degrades
> readability. To fix it, create new header files for each part of the
> driver and move the related functions.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/omap_connector.h |  37 +++++++++
>  drivers/gpu/drm/omapdrm/omap_crtc.h      |  43 ++++++++++
>  drivers/gpu/drm/omapdrm/omap_drv.h       | 133 +++----------------------------
>  drivers/gpu/drm/omapdrm/omap_encoder.h   |  33 ++++++++
>  drivers/gpu/drm/omapdrm/omap_fb.h        |  46 +++++++++++
>  drivers/gpu/drm/omapdrm/omap_fbdev.h     |  39 +++++++++
>  drivers/gpu/drm/omapdrm/omap_gem.h       |  99 +++++++++++++++++++++++
>  drivers/gpu/drm/omapdrm/omap_irq.h       |  39 +++++++++
>  drivers/gpu/drm/omapdrm/omap_plane.h     |  37 +++++++++
>  9 files changed, 386 insertions(+), 120 deletions(-)
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_crtc.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_encoder.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_fb.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_fbdev.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_gem.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_irq.h
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_plane.h
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_connector.h b/drivers/gpu/drm/omapdrm/omap_connector.h
> new file mode 100644
> index 000000000000..98bbc779b302
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_connector.h
> @@ -0,0 +1,37 @@
> +/*
> + * omap_connector.h -- OMAP DRM Connector
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_CONNECTOR_H__
> +#define __OMAPDRM_CONNECTOR_H__
> +
> +#include <linux/types.h>
> +
> +struct drm_connector;
> +struct drm_device;
> +struct drm_encoder;
> +struct omap_dss_device;
> +
> +struct drm_connector *omap_connector_init(struct drm_device *dev,
> +		int connector_type, struct omap_dss_device *dssdev,
> +		struct drm_encoder *encoder);
> +struct drm_encoder *omap_connector_attached_encoder(
> +		struct drm_connector *connector);
> +bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
> +
> +#endif /* __OMAPDRM_CONNECTOR_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
> new file mode 100644
> index 000000000000..ad7b007c6174
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
> @@ -0,0 +1,43 @@
> +/*
> + * omap_crtc.h -- OMAP DRM CRTC
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_CRTC_H__
> +#define __OMAPDRM_CRTC_H__
> +
> +#include <linux/types.h>
> +
> +enum omap_channel;
> +
> +struct drm_crtc;
> +struct drm_device;
> +struct drm_plane;
> +struct omap_dss_device;
> +struct videomode;
> +
> +struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
> +enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
> +void omap_crtc_pre_init(void);
> +void omap_crtc_pre_uninit(void);
> +struct drm_crtc *omap_crtc_init(struct drm_device *dev,
> +		struct drm_plane *plane, struct omap_dss_device *dssdev);
> +int omap_crtc_wait_pending(struct drm_crtc *crtc);
> +void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
> +void omap_crtc_vblank_irq(struct drm_crtc *crtc);
> +
> +#endif /* __OMAPDRM_CRTC_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 04f35f74f80c..afb2a5a96278 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -17,8 +17,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -#ifndef __OMAP_DRV_H__
> -#define __OMAP_DRV_H__
> +#ifndef __OMAPDRM_DRV_H__
> +#define __OMAPDRM_DRV_H__
>  
>  #include <linux/module.h>
>  #include <linux/types.h>
> @@ -31,6 +31,15 @@
>  
>  #include "dss/omapdss.h"
>  
> +#include "omap_connector.h"
> +#include "omap_crtc.h"
> +#include "omap_encoder.h"
> +#include "omap_fb.h"
> +#include "omap_fbdev.h"
> +#include "omap_gem.h"
> +#include "omap_irq.h"
> +#include "omap_plane.h"
> +
>  #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
>  #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
>  
> @@ -38,14 +47,6 @@
>  
>  struct omap_drm_usergart;
>  
> -/* For KMS code that needs to wait for a certain # of IRQs:
> - */
> -struct omap_irq_wait;
> -struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev,
> -		uint32_t irqmask, int count);
> -int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
> -		unsigned long timeout);
> -
>  struct omap_drm_private {
>  	uint32_t omaprev;
>  
> @@ -86,114 +87,6 @@ struct omap_drm_private {
>  };
>  
>  
> -#ifdef CONFIG_DEBUG_FS
>  int omap_debugfs_init(struct drm_minor *minor);
> -void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
> -void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
> -void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
> -#endif
> -
> -#ifdef CONFIG_PM
> -int omap_gem_resume(struct drm_device *dev);
> -#endif
> -
> -int omap_irq_enable_vblank(struct drm_crtc *crtc);
> -void omap_irq_disable_vblank(struct drm_crtc *crtc);
> -void omap_drm_irq_uninstall(struct drm_device *dev);
> -int omap_drm_irq_install(struct drm_device *dev);
> -
> -#ifdef CONFIG_DRM_FBDEV_EMULATION
> -struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
> -void omap_fbdev_free(struct drm_device *dev);
> -#else
> -static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> -{
> -	return NULL;
> -}
> -static inline void omap_fbdev_free(struct drm_device *dev)
> -{
> -}
> -#endif
> -
> -struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
> -enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
> -void omap_crtc_pre_init(void);
> -void omap_crtc_pre_uninit(void);
> -struct drm_crtc *omap_crtc_init(struct drm_device *dev,
> -		struct drm_plane *plane, struct omap_dss_device *dssdev);
> -int omap_crtc_wait_pending(struct drm_crtc *crtc);
> -void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
> -void omap_crtc_vblank_irq(struct drm_crtc *crtc);
> -
> -struct drm_plane *omap_plane_init(struct drm_device *dev,
> -		int idx, enum drm_plane_type type,
> -		u32 possible_crtcs);
> -void omap_plane_install_properties(struct drm_plane *plane,
> -		struct drm_mode_object *obj);
> -
> -struct drm_encoder *omap_encoder_init(struct drm_device *dev,
> -		struct omap_dss_device *dssdev);
> -
> -struct drm_connector *omap_connector_init(struct drm_device *dev,
> -		int connector_type, struct omap_dss_device *dssdev,
> -		struct drm_encoder *encoder);
> -struct drm_encoder *omap_connector_attached_encoder(
> -		struct drm_connector *connector);
> -bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
> -
> -struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
> -		struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
> -struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
> -		const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
> -int omap_framebuffer_pin(struct drm_framebuffer *fb);
> -void omap_framebuffer_unpin(struct drm_framebuffer *fb);
> -void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
> -		struct drm_plane_state *state, struct omap_overlay_info *info);
> -struct drm_connector *omap_framebuffer_get_next_connector(
> -		struct drm_framebuffer *fb, struct drm_connector *from);
> -bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
> -
> -void omap_gem_init(struct drm_device *dev);
> -void omap_gem_deinit(struct drm_device *dev);
> -
> -struct drm_gem_object *omap_gem_new(struct drm_device *dev,
> -		union omap_gem_size gsize, uint32_t flags);
> -struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
> -		struct sg_table *sgt);
> -int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> -		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
> -void omap_gem_free_object(struct drm_gem_object *obj);
> -void *omap_gem_vaddr(struct drm_gem_object *obj);
> -int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> -		uint32_t handle, uint64_t *offset);
> -int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> -		struct drm_mode_create_dumb *args);
> -int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
> -int omap_gem_mmap_obj(struct drm_gem_object *obj,
> -		struct vm_area_struct *vma);
> -int omap_gem_fault(struct vm_fault *vmf);
> -int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
> -void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
> -void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
> -		enum dma_data_direction dir);
> -int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
> -void omap_gem_unpin(struct drm_gem_object *obj);
> -int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
> -		bool remap);
> -int omap_gem_put_pages(struct drm_gem_object *obj);
> -uint32_t omap_gem_flags(struct drm_gem_object *obj);
> -int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
> -		int x, int y, dma_addr_t *dma_addr);
> -uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
> -size_t omap_gem_mmap_size(struct drm_gem_object *obj);
> -int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
> -
> -struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
> -		struct drm_gem_object *obj, int flags);
> -struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
> -		struct dma_buf *buffer);
> -
> -/* map crtc to vblank mask */
> -struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder);
> -
> -#endif /* __OMAP_DRV_H__ */
> +
> +#endif /* __OMAPDRM_DRV_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.h b/drivers/gpu/drm/omapdrm/omap_encoder.h
> new file mode 100644
> index 000000000000..d2f308bec494
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_encoder.h
> @@ -0,0 +1,33 @@
> +/*
> + * omap_encoder.h -- OMAP DRM Encoder
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_ENCODER_H__
> +#define __OMAPDRM_ENCODER_H__
> +
> +struct drm_device;
> +struct drm_encoder;
> +struct omap_dss_device;
> +
> +struct drm_encoder *omap_encoder_init(struct drm_device *dev,
> +		struct omap_dss_device *dssdev);
> +
> +/* map crtc to vblank mask */
> +struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder);
> +
> +#endif /* __OMAPDRM_ENCODER_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.h b/drivers/gpu/drm/omapdrm/omap_fb.h
> new file mode 100644
> index 000000000000..94ad5f9e4404
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.h
> @@ -0,0 +1,46 @@
> +/*
> + * omap_fb.h -- OMAP DRM Framebuffer
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_FB_H__
> +#define __OMAPDRM_FB_H__
> +
> +struct drm_connector;
> +struct drm_device;
> +struct drm_file;
> +struct drm_framebuffer;
> +struct drm_gem_object;
> +struct drm_mode_fb_cmd2;
> +struct drm_plane_state;
> +struct omap_overlay_info;
> +struct seq_file;
> +
> +struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
> +		struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
> +struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
> +		const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
> +int omap_framebuffer_pin(struct drm_framebuffer *fb);
> +void omap_framebuffer_unpin(struct drm_framebuffer *fb);
> +void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
> +		struct drm_plane_state *state, struct omap_overlay_info *info);
> +struct drm_connector *omap_framebuffer_get_next_connector(
> +		struct drm_framebuffer *fb, struct drm_connector *from);
> +bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
> +void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
> +
> +#endif /* __OMAPDRM_FB_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.h b/drivers/gpu/drm/omapdrm/omap_fbdev.h
> new file mode 100644
> index 000000000000..1f5ba0996a1a
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.h
> @@ -0,0 +1,39 @@
> +/*
> + * omap_fbdev.h -- OMAP DRM FBDEV Compatibility
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_FBDEV_H__
> +#define __OMAPDRM_FBDEV_H__
> +
> +struct drm_device;
> +struct drm_fb_helper;
> +
> +#ifdef CONFIG_DRM_FBDEV_EMULATION
> +struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
> +void omap_fbdev_free(struct drm_device *dev);
> +#else
> +static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> +{
> +	return NULL;
> +}
> +static inline void omap_fbdev_free(struct drm_device *dev)
> +{
> +}
> +#endif
> +
> +#endif /* __OMAPDRM_FBDEV_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
> new file mode 100644
> index 000000000000..35fa690b3d90
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.h
> @@ -0,0 +1,99 @@
> +/*
> + * omap_gem.h -- OMAP DRM GEM Object Management
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_GEM_H__
> +#define __OMAPDRM_GEM_H__
> +
> +#include <linux/types.h>
> +
> +enum dma_data_direction;
> +
> +struct dma_buf;
> +struct drm_device;
> +struct drm_file;
> +struct drm_gem_object;
> +struct drm_mode_create_dumb;
> +struct file;
> +struct list_head;
> +struct page;
> +struct seq_file;
> +struct vm_area_struct;
> +struct vm_fault;
> +
> +union omap_gem_size;
> +
> +/* Initialization and Cleanup */
> +void omap_gem_init(struct drm_device *dev);
> +void omap_gem_deinit(struct drm_device *dev);
> +
> +#ifdef CONFIG_PM
> +int omap_gem_resume(struct drm_device *dev);
> +#endif
> +
> +#ifdef CONFIG_DEBUG_FS
> +void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
> +void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
> +#endif
> +
> +/* GEM Object Creation and Deletion */
> +struct drm_gem_object *omap_gem_new(struct drm_device *dev,
> +		union omap_gem_size gsize, uint32_t flags);
> +struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
> +		struct sg_table *sgt);
> +int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> +		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
> +void omap_gem_free_object(struct drm_gem_object *obj);
> +void *omap_gem_vaddr(struct drm_gem_object *obj);
> +
> +/* Dumb Buffers Interface */
> +int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
> +		uint32_t handle, uint64_t *offset);
> +int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> +		struct drm_mode_create_dumb *args);
> +
> +/* mmap() Interface */
> +int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
> +int omap_gem_mmap_obj(struct drm_gem_object *obj,
> +		struct vm_area_struct *vma);
> +uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
> +size_t omap_gem_mmap_size(struct drm_gem_object *obj);
> +
> +/* PRIME Interface */
> +struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
> +		struct drm_gem_object *obj, int flags);
> +struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
> +		struct dma_buf *buffer);
> +
> +int omap_gem_fault(struct vm_fault *vmf);
> +int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
> +void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
> +void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
> +		enum dma_data_direction dir);
> +int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
> +void omap_gem_unpin(struct drm_gem_object *obj);
> +int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
> +		bool remap);
> +int omap_gem_put_pages(struct drm_gem_object *obj);
> +
> +uint32_t omap_gem_flags(struct drm_gem_object *obj);
> +int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
> +		int x, int y, dma_addr_t *dma_addr);
> +int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
> +
> +#endif /* __OMAPDRM_GEM_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.h b/drivers/gpu/drm/omapdrm/omap_irq.h
> new file mode 100644
> index 000000000000..606c09932bc0
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.h
> @@ -0,0 +1,39 @@
> +/*
> + * omap_irq.h -- OMAP DRM IRQ Handling
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_IRQ_H__
> +#define __OMAPDRM_IRQ_H__
> +
> +#include <linux/types.h>
> +
> +struct drm_crtc;
> +struct drm_device;
> +struct omap_irq_wait;
> +
> +int omap_irq_enable_vblank(struct drm_crtc *crtc);
> +void omap_irq_disable_vblank(struct drm_crtc *crtc);
> +void omap_drm_irq_uninstall(struct drm_device *dev);
> +int omap_drm_irq_install(struct drm_device *dev);
> +
> +struct omap_irq_wait *omap_irq_wait_init(struct drm_device *dev,
> +		uint32_t irqmask, int count);
> +int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
> +		unsigned long timeout);
> +
> +#endif /* __OMAPDRM_IRQ_H__ */
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.h b/drivers/gpu/drm/omapdrm/omap_plane.h
> new file mode 100644
> index 000000000000..dc5e82ad061d
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.h
> @@ -0,0 +1,37 @@
> +/*
> + * omap_plane.h -- OMAP DRM Plane
> + *
> + * Copyright (C) 2011 Texas Instruments
> + * Author: Rob Clark <rob@ti.com>
> + *
> + * 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/>.
> + */
> +
> +#ifndef __OMAPDRM_PLANE_H__
> +#define __OMAPDRM_PLANE_H__
> +
> +#include <linux/types.h>
> +
> +enum drm_plane_type;
> +
> +struct drm_device;
> +struct drm_mode_object;
> +struct drm_plane;
> +
> +struct drm_plane *omap_plane_init(struct drm_device *dev,
> +		int idx, enum drm_plane_type type,
> +		u32 possible_crtcs);
> +void omap_plane_install_properties(struct drm_plane *plane,
> +		struct drm_mode_object *obj);
> +
> +#endif /* __OMAPDRM_PLANE_H__ */
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (47 preceding siblings ...)
  2017-10-13 14:59 ` [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array " Laurent Pinchart
@ 2017-10-17 22:29 ` Sebastian Reichel
  2017-10-17 22:36   ` Laurent Pinchart
  2017-10-18  9:46 ` Tomi Valkeinen
                   ` (2 subsequent siblings)
  51 siblings, 1 reply; 114+ messages in thread
From: Sebastian Reichel @ 2017-10-17 22:29 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1854 bytes --]

Hi Laurent,

On Fri, Oct 13, 2017 at 05:58:56PM +0300, Laurent Pinchart wrote:
> This patch series merges the omapdrm and omapdss drivers into a single driver
> called omapdrm. The split in two drivers was historical, in order to support
> the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
> there's no need to keep two seperate drivers.
> 
> The series starts with a few cleanups (01/48 to 03/48) and quickly proceeds to
> merging the omapdss and omapdss-base modules (04/48). It then prepares the
> omapdss code (05/48 to 08/48), perform a few more cleanups (09/48 to 11/48)
> and prepares the omapdrm code (12/48).
> 
> Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers. All
> those drivers defer probing when their video source can't be found at probe
> time. This would cause endless probe deferral when merging omapdrm and omapdss
> as the drivers need omapdss to be fully initialized to probe successfully, but
> cause omapdrm to defer probing when they're not available.
> 
> Patch 20/48 merges the omapdrm and omapdss drivers.
> 
> The next patches are added bonuses that start removal of global variables from
> the driver. The code relies heavily on global variables for objects that are
> instance-specific, and should thus be dynamically allocated. Most of the
> patches change internal APIs to pass objects to driver functions (21/48 to
> 28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a few miscellaneous
> cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches 30/48 to 34/48 and 46/48
> then allocate instance objects dynamically to replace global variables, and
> patches 47/48 and 48/48 move global variables to existing instance objects.
> 
> The series has been tested on a Pandaboard with the DVI and HDMI output.

Nice cleanup! :)

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device
  2017-10-17 22:16   ` Sebastian Reichel
@ 2017-10-17 22:34     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-17 22:34 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Wednesday, 18 October 2017 01:16:53 EEST Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Oct 13, 2017 at 05:59:43PM +0300, Laurent Pinchart wrote:
> > As part of an effort to remove the usage of global variables in the
> > driver, store the debugfs root directory in the dss_device structure
> > instead of a global variable.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
> >  drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 ++++----
> >  drivers/gpu/drm/omapdrm/dss/dss.c   | 39 +++++++++++++++++---------------
> >  drivers/gpu/drm/omapdrm/dss/dss.h   |  9 ++++++---
> >  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 ++-
> >  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 ++-
> >  drivers/gpu/drm/omapdrm/dss/venc.c  |  3 ++-
> >  7 files changed, 37 insertions(+), 30 deletions(-)

[snip]

> > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c
> > b/drivers/gpu/drm/omapdrm/dss/dss.c index 5d927dfe0a7f..f4e15850cc9d
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> > @@ -906,25 +906,23 @@ static int dss_debug_dump_clocks(struct seq_file *s,
> > void *p)
> >  	return 0;
> >  }
> > 
> > -static struct dentry *dss_debugfs_dir;
> > -
> >  static int dss_initialize_debugfs(struct dss_device *dss)
> >  {
> > -	dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
> > -	if (IS_ERR(dss_debugfs_dir)) {
> > -		int err = PTR_ERR(dss_debugfs_dir);
> > +	static struct dentry *dir;
> 
> static?

Oops. Will fix in v2. Thanks for catching it.

> Otherwise:
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> 
> -- Sebastian
> 
> > -		dss_debugfs_dir = NULL;
> > -		return err;
> > -	}
> > +	dir = debugfs_create_dir("omapdss", NULL);
> > +	if (IS_ERR(dir))
> > +		return PTR_ERR(dir);
> > +
> > +	dss->debugfs.root = dir;
> >  	return 0;
> >  }

[snip]

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-17 22:29 ` [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Sebastian Reichel
@ 2017-10-17 22:36   ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-17 22:36 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, dri-devel

Hi Sebastian,

On Wednesday, 18 October 2017 01:29:56 EEST Sebastian Reichel wrote:
> On Fri, Oct 13, 2017 at 05:58:56PM +0300, Laurent Pinchart wrote:
> > This patch series merges the omapdrm and omapdss drivers into a single
> > driver called omapdrm. The split in two drivers was historical, in order
> > to support the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports
> > DRM/KMS only there's no need to keep two seperate drivers.
> > 
> > The series starts with a few cleanups (01/48 to 03/48) and quickly
> > proceeds to merging the omapdss and omapdss-base modules (04/48). It then
> > prepares the omapdss code (05/48 to 08/48), perform a few more cleanups
> > (09/48 to 11/48) and prepares the omapdrm code (12/48).
> > 
> > Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers.
> > All those drivers defer probing when their video source can't be found at
> > probe time. This would cause endless probe deferral when merging omapdrm
> > and omapdss as the drivers need omapdss to be fully initialized to probe
> > successfully, but cause omapdrm to defer probing when they're not
> > available.
> > 
> > Patch 20/48 merges the omapdrm and omapdss drivers.
> > 
> > The next patches are added bonuses that start removal of global variables
> > from the driver. The code relies heavily on global variables for objects
> > that are instance-specific, and should thus be dynamically allocated.
> > Most of the patches change internal APIs to pass objects to driver
> > functions (21/48 to 28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a
> > few miscellaneous cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches
> > 30/48 to 34/48 and 46/48 then allocate instance objects dynamically to
> > replace global variables, and patches 47/48 and 48/48 move global
> > variables to existing instance objects.
> > 
> > The series has been tested on a Pandaboard with the DVI and HDMI output.
> 
> Nice cleanup! :)

And great review ! :-) Thank you.

There will be more coming, probably another cleanup round before I start 
moving the encoder, connector and panel drivers to drm_bridge and drm_panel.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules
  2017-10-13 14:59 ` [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules Laurent Pinchart
  2017-10-14 12:22   ` Sebastian Reichel
@ 2017-10-18  9:19   ` Tomi Valkeinen
  2017-10-18 12:28     ` Laurent Pinchart
  1 sibling, 1 reply; 114+ messages in thread
From: Tomi Valkeinen @ 2017-10-18  9:19 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 13/10/17 17:59, Laurent Pinchart wrote:
> There's no need for the omapdss-base code to be part of a separate
> module. Merge it with the omapdss module. This allows removing the
> exports for internal symbols.

The need was to support DSS6 driver, which is built as separate module.
That's not in the mainline yet.

If we merge dss6 driver into the same omapdrm.ko, then there should be
no issues.

 Tomi

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (48 preceding siblings ...)
  2017-10-17 22:29 ` [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Sebastian Reichel
@ 2017-10-18  9:46 ` Tomi Valkeinen
  2017-10-18  9:56   ` Tomi Valkeinen
  2017-10-18 12:56 ` Tomi Valkeinen
  2017-12-01 12:55 ` Tomi Valkeinen
  51 siblings, 1 reply; 114+ messages in thread
From: Tomi Valkeinen @ 2017-10-18  9:46 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel

Hi Laurent,


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 13/10/17 17:58, Laurent Pinchart wrote:
> Hello,
> 
> This patch series merges the omapdrm and omapdss drivers into a single driver
> called omapdrm. The split in two drivers was historical, in order to support
> the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
> there's no need to keep two seperate drivers.
> 
> The series starts with a few cleanups (01/48 to 03/48) and quickly proceeds to
> merging the omapdss and omapdss-base modules (04/48). It then prepares the
> omapdss code (05/48 to 08/48), perform a few more cleanups (09/48 to 11/48)
> and prepares the omapdrm code (12/48).
> 
> Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers. All
> those drivers defer probing when their video source can't be found at probe
> time. This would cause endless probe deferral when merging omapdrm and omapdss
> as the drivers need omapdss to be fully initialized to probe successfully, but
> cause omapdrm to defer probing when they're not available.
> 
> Patch 20/48 merges the omapdrm and omapdss drivers.
> 
> The next patches are added bonuses that start removal of global variables from
> the driver. The code relies heavily on global variables for objects that are
> instance-specific, and should thus be dynamically allocated. Most of the
> patches change internal APIs to pass objects to driver functions (21/48 to
> 28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a few miscellaneous
> cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches 30/48 to 34/48 and 46/48
> then allocate instance objects dynamically to replace global variables, and
> patches 47/48 and 48/48 move global variables to existing instance objects.
> 
> The series has been tested on a Pandaboard with the DVI and HDMI output.

Here's what I get on AM5 EVM:

# ./s-drm-new 
[   17.535638] sysrq: SysRq : Changing Loglevel
[   17.540179] sysrq: Loglevel set to 9
insmod nfs/work/linux/sound/soc/omap/snd-soc-omap-hdmi-audio.ko
insmod nfs/work/linux/drivers/media/cec/cec.ko
insmod nfs/work/linux/drivers/video/fbdev/core/cfbcopyarea.ko
insmod nfs/work/linux/drivers/video/fbdev/core/cfbimgblt.ko
insmod nfs/work/linux/drivers/video/fbdev/core/cfbfillrect.ko
insmod nfs/work/linux/drivers/gpu/drm/drm.ko
insmod nfs/work/linux/drivers/gpu/drm/drm_kms_helper.ko
insmod nfs/work/linux/drivers/gpu/drm/omapdrm/omapdrm.ko
[   17.966444] dmm 4e000000.dmm: initialized all PAT entries
[   18.004857] DSS: OMAP DSS rev 6.1
[   18.010743] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.025076] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.050076] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.074540] omapdss_dss 58000000.dss: master bind failed: -517
[   18.083499] DSS: OMAP DSS rev 6.1
[   18.088284] alloc_contig_range: [fd874, fd875) PFNs busy
[   18.095583] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
# [   18.113296] alloc_contig_range: [fd8c0, fd8e0) PFNs busy
[   18.119651] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.134440] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.154449] omapdss_dss 58000000.dss: master bind failed: -517
[   18.163344] DSS: OMAP DSS rev 6.1
[   18.167982] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.179600] alloc_contig_range: [fd8c0, fd8e0) PFNs busy
[   18.185013] alloc_contig_range: [fd8e0, fd900) PFNs busy
[   18.190805] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.203003] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.219239] omapdss_dss 58000000.dss: master bind failed: -517
[   18.228977] DSS: OMAP DSS rev 6.1
[   18.232446] alloc_contig_range: [fd874, fd875) PFNs busy
[   18.238816] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.250433] alloc_contig_range: [fd8c0, fd8e0) PFNs busy
[   18.255847] alloc_contig_range: [fd8e0, fd900) PFNs busy
[   18.261406] alloc_contig_range: [fd9a0, fd9c0) PFNs busy
[   18.267156] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.279429] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.297217] omapdss_dss 58000000.dss: master bind failed: -517
[   18.305306] DSS: OMAP DSS rev 6.1
[   18.309734] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.321303] alloc_contig_range: [fd8c0, fd8e0) PFNs busy
[   18.326830] alloc_contig_range: [fd8e0, fd900) PFNs busy
[   18.332468] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.344813] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.361397] omapdss_dss 58000000.dss: master bind failed: -517
[   18.369603] DSS: OMAP DSS rev 6.1
[   18.373978] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.387972] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.400358] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.417037] omapdss_dss 58000000.dss: master bind failed: -517
[   18.425116] DSS: OMAP DSS rev 6.1
[   18.429554] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.441269] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.453897] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.470158] omapdss_dss 58000000.dss: master bind failed: -517
[   18.478372] DSS: OMAP DSS rev 6.1
[   18.482757] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.494562] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.506848] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.520734] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.540107] omapdss_dss 58000000.dss: master bind failed: -517
[   18.548322] DSS: OMAP DSS rev 6.1
[   18.552654] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.564934] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.577309] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.590448] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.609305] omapdss_dss 58000000.dss: master bind failed: -517
[   18.617489] DSS: OMAP DSS rev 6.1
[   18.621870] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.633776] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.646049] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.660047] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: Permission denied
[   18.678718] omapdss_dss 58000000.dss: master bind failed: -517
[   18.686933] DSS: OMAP DSS rev 6.1
[   18.691260] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.703308] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.715547] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.729422] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.748279] omapdss_dss 58000000.dss: master bind failed: -517
[   18.750583] DSS: OMAP DSS rev 6.1
[   18.751625] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.759036] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.761967] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.794535] omapdss_dss 58000000.dss: master bind failed: -517
[   18.803032] DSS: OMAP DSS rev 6.1
[   18.808001] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.819415] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.821623] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.824505] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.865204] omapdss_dss 58000000.dss: master bind failed: -517
[   18.873379] DSS: OMAP DSS rev 6.1
[   18.878182] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.889609] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.890512] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
[   18.893486] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   18.934801] omapdss_dss 58000000.dss: master bind failed: -517
[   18.942980] DSS: OMAP DSS rev 6.1
[   18.947418] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   18.959247] udevd[158]: error opening ATTR{/sys/devices/platform/44000000.ocp/58000000.dss/58040000.encoder/omap-hdmi-audio.2.auto/sound/card1/con
trolC1/../uevent} for writing: No such file or directory
[   18.959296] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-18  9:46 ` Tomi Valkeinen
@ 2017-10-18  9:56   ` Tomi Valkeinen
  2018-01-19  3:48     ` Laurent Pinchart
  0 siblings, 1 reply; 114+ messages in thread
From: Tomi Valkeinen @ 2017-10-18  9:56 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 18/10/17 12:46, Tomi Valkeinen wrote:
> Hi Laurent,
> 
> On 13/10/17 17:58, Laurent Pinchart wrote:
>> Hello,
>>
>> This patch series merges the omapdrm and omapdss drivers into a single driver
>> called omapdrm. The split in two drivers was historical, in order to support
>> the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
>> there's no need to keep two seperate drivers.
>>
>> The series starts with a few cleanups (01/48 to 03/48) and quickly proceeds to
>> merging the omapdss and omapdss-base modules (04/48). It then prepares the
>> omapdss code (05/48 to 08/48), perform a few more cleanups (09/48 to 11/48)
>> and prepares the omapdrm code (12/48).
>>
>> Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers. All
>> those drivers defer probing when their video source can't be found at probe
>> time. This would cause endless probe deferral when merging omapdrm and omapdss
>> as the drivers need omapdss to be fully initialized to probe successfully, but
>> cause omapdrm to defer probing when they're not available.
>>
>> Patch 20/48 merges the omapdrm and omapdss drivers.
>>
>> The next patches are added bonuses that start removal of global variables from
>> the driver. The code relies heavily on global variables for objects that are
>> instance-specific, and should thus be dynamically allocated. Most of the
>> patches change internal APIs to pass objects to driver functions (21/48 to
>> 28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a few miscellaneous
>> cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches 30/48 to 34/48 and 46/48
>> then allocate instance objects dynamically to replace global variables, and
>> patches 47/48 and 48/48 move global variables to existing instance objects.
>>
>> The series has been tested on a Pandaboard with the DVI and HDMI output.
> 
> Here's what I get on AM5 EVM:
> 
> # ./s-drm-new 
> [   17.535638] sysrq: SysRq : Changing Loglevel
> [   17.540179] sysrq: Loglevel set to 9
> insmod nfs/work/linux/sound/soc/omap/snd-soc-omap-hdmi-audio.ko
> insmod nfs/work/linux/drivers/media/cec/cec.ko
> insmod nfs/work/linux/drivers/video/fbdev/core/cfbcopyarea.ko
> insmod nfs/work/linux/drivers/video/fbdev/core/cfbimgblt.ko
> insmod nfs/work/linux/drivers/video/fbdev/core/cfbfillrect.ko
> insmod nfs/work/linux/drivers/gpu/drm/drm.ko
> insmod nfs/work/linux/drivers/gpu/drm/drm_kms_helper.ko
> insmod nfs/work/linux/drivers/gpu/drm/omapdrm/omapdrm.ko
> [   17.966444] dmm 4e000000.dmm: initialized all PAT entries
> [   18.004857] DSS: OMAP DSS rev 6.1
> [   18.010743] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
> [   18.025076] omap-hdmi-audio omap-hdmi-audio.2.auto: snd-soc-dummy-dai <-> 58040000.encoder mapping ok
> [   18.050076] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
> [   18.074540] omapdss_dss 58000000.dss: master bind failed: -517

If I disable HDMI audio, the spam goes away, and I just get:

[   14.783558] dmm 4e000000.dmm: initialized all PAT entries
[   14.805775] DSS: OMAP DSS rev 6.1
[   14.809989] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops [omapdrm])
[   14.821844] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops [omapdrm])
[   14.833482] omapdss_dss 58000000.dss: master bind failed: -517

When I remove modules, something is left enabled as I get:

[   99.623954] platform 58000000.dss: enabled after unload, idling

If, after loading omapdrm as above, I also load encoder/panel drivers, I get a picture after a spam of "omapdss_dss 58000000.dss: master bind failed: -517" and "alloc_contig_range: [fd874, fd875) PFNs busy" messages.

But then, I can't unload any modules as they are all in use.

 Tomi

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules
  2017-10-18  9:19   ` Tomi Valkeinen
@ 2017-10-18 12:28     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2017-10-18 12:28 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: dri-devel

Hi Tomi,

On Wednesday, 18 October 2017 12:19:26 EEST Tomi Valkeinen wrote:
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> On 13/10/17 17:59, Laurent Pinchart wrote:
> > There's no need for the omapdss-base code to be part of a separate
> > module. Merge it with the omapdss module. This allows removing the
> > exports for internal symbols.
> 
> The need was to support DSS6 driver, which is built as separate module.
> That's not in the mainline yet.
> 
> If we merge dss6 driver into the same omapdrm.ko, then there should be
> no issues.

As this series merges omapdrm and omapdss I think it would make sense to 
support DSS[2-5] and DSS6 in the same module (probably with a Kconfig option 
to select which variant(s) to support).

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (49 preceding siblings ...)
  2017-10-18  9:46 ` Tomi Valkeinen
@ 2017-10-18 12:56 ` Tomi Valkeinen
  2017-12-01 12:55 ` Tomi Valkeinen
  51 siblings, 0 replies; 114+ messages in thread
From: Tomi Valkeinen @ 2017-10-18 12:56 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 13/10/17 17:58, Laurent Pinchart wrote:
> Hello,
> 
> This patch series merges the omapdrm and omapdss drivers into a single driver
> called omapdrm. The split in two drivers was historical, in order to support

So how do the loadtime and runtime dependencies go with this series? In
the current mainline, it's kind of clear:

We have omapdss, and the panel and encoder drivers register themselves
to omapdss. So panels and encoders depend on omapdss. On top of that we
have omapdrm which then uses both omapdss and panels. Unloading happens
in reverse order.

With only omapdrm, the panels and encoders must depend on that. But
omapdrm will use the panels, so there's a runtime dependency that way.

Do we need to use sysfs's unbind first to remove some drivers, before
module unloading is possible? Which ones? Does it work?

 Tomi

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
                   ` (50 preceding siblings ...)
  2017-10-18 12:56 ` Tomi Valkeinen
@ 2017-12-01 12:55 ` Tomi Valkeinen
  51 siblings, 0 replies; 114+ messages in thread
From: Tomi Valkeinen @ 2017-12-01 12:55 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel

Hi,

On 13/10/17 17:58, Laurent Pinchart wrote:
> Hello,
> 
> This patch series merges the omapdrm and omapdss drivers into a single driver
> called omapdrm. The split in two drivers was historical, in order to support
> the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
> there's no need to keep two seperate drivers.

I've picked the following patches from the beginning of the series for
v4.16. I would have picked a few more, but started to get conflicts.

drm: omapdrm: Deconstruct the omap_drv.h header.
drm: omapdrm: venc: Return error code on OF parsing failure
drm: omapdrm: dpi: Remove dpi_data port_initialized field
drm: omapdrm: dss: Make dss_dump_clocks() function static
drm: omapdrm: dss: Set the DMA coherent mask
drm: omapdrm: Remove unused omap_dss_find_device() function
drm: omapdrm: Pass drm_device to omap_gem_resume()
drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [PATCH 00/48] omapdrm: Merge omapdrm and omapdss
  2017-10-18  9:56   ` Tomi Valkeinen
@ 2018-01-19  3:48     ` Laurent Pinchart
  0 siblings, 0 replies; 114+ messages in thread
From: Laurent Pinchart @ 2018-01-19  3:48 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: dri-devel

Hi Tomi,

On Wednesday, 18 October 2017 12:56:12 EET Tomi Valkeinen wrote:
> On 18/10/17 12:46, Tomi Valkeinen wrote:
> > On 13/10/17 17:58, Laurent Pinchart wrote:
> >> Hello,
> >> 
> >> This patch series merges the omapdrm and omapdss drivers into a single
> >> driver called omapdrm. The split in two drivers was historical, in order
> >> to support the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver
> >> supports DRM/KMS only there's no need to keep two seperate drivers.

[snip]

> >> The series has been tested on a Pandaboard with the DVI and HDMI output.
> > 
> > Here's what I get on AM5 EVM:

[snip]

> [   14.783558] dmm 4e000000.dmm: initialized all PAT entries
> [   14.805775] DSS: OMAP DSS rev 6.1
> [   14.809989] omapdss_dss 58000000.dss: bound 58001000.dispc (ops
> dispc_component_ops [omapdrm])
> [   14.821844] omapdss_dss 58000000.dss: bound 58040000.encoder (ops
> hdmi5_component_ops [omapdrm])
> [   14.833482] omapdss_dss 58000000.dss: master bind failed: -517
> 
> When I remove modules, something is left enabled as I get:
> 
> [   99.623954] platform 58000000.dss: enabled after unload, idling

I initially thought this would disappear after fixing the other issues, but it 
seems to be a problem of its own, which I have thus investigated. I had to 
trace through the runtime PM code to understand what was going on, which 
wasn't a pleasant experience, but I managed to find the root cause and to 
create a fix.

The culprit is initialization of runtime PM in the DSS component master bind 
handler coupled with probe deferral from within that handler.

The bind handler performs the following sequence of PM operations:

        pm_runtime_enable(dev);
        pm_runtime_get_sync(dev);

        ... (access the hardware to read the device revision) ... 

        pm_runtime_put_sync(dev);

If a failure occurs at this point, the error path calls pm_runtime_disable() 
to balance the pm_runtime_enable() call.

Now it should be noted that the bind handler is called when one of the 
component registers itself, which happens in the component's probe handler. 
Furthermore, as the components are children of the DSS, the device core calls 
pm_runtime_get_sync() on the DSS platform device before calling the 
component's probe handler. This increases the DSS power usage count but 
doesn't runtime resume the device, as runtime PM is disabled at that point.

The bind handler is thus called with runtime PM disabled, with the device 
runtime suspended, but with the power usage count larger than 0. The 
pm_runtime_get_sync() call will thus further increase the power usage count 
and runtime resume the device. The pm_runtime_put_sync() handler will decrease 
the power usage count to a non-zero value and will thus not suspend the 
device. Finally, the pm_runtime_disable() call will disable runtime PM, 
preventing the pm_runtime_put() call in the device core from runtime 
suspending the device. The DSS device is thus left powered on. 

To fix this, I've created a patch that moves the runtime PM initialization 
code (as well as most of the rest of the initialization code) from the bind 
handler to the probe handler. I'll post it in v2 of this series.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 114+ messages in thread

end of thread, other threads:[~2018-01-19  3:48 UTC | newest]

Thread overview: 114+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 14:58 [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Laurent Pinchart
2017-10-13 14:58 ` [PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error Laurent Pinchart
2017-10-14 12:11   ` Sebastian Reichel
2017-10-13 14:58 ` [PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume() Laurent Pinchart
2017-10-14 12:15   ` Sebastian Reichel
2017-10-13 14:58 ` [PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function Laurent Pinchart
2017-10-14 12:16   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules Laurent Pinchart
2017-10-14 12:22   ` Sebastian Reichel
2017-10-16  9:04     ` Laurent Pinchart
2017-10-18  9:19   ` Tomi Valkeinen
2017-10-18 12:28     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask Laurent Pinchart
2017-10-14 12:24   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static Laurent Pinchart
2017-10-14 12:24   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field Laurent Pinchart
2017-10-14 12:28   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure Laurent Pinchart
2017-10-14 12:29   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header Laurent Pinchart
2017-10-17 22:25   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 10/48] drm: omapdrm: Use kernel integer types Laurent Pinchart
2017-10-14 12:34   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 11/48] drm: omapdrm: Use unsigned int type Laurent Pinchart
2017-10-14 12:37   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions Laurent Pinchart
2017-10-14 12:41   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration Laurent Pinchart
2017-10-14 12:42   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers Laurent Pinchart
2017-10-14 12:43   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers Laurent Pinchart
2017-10-14 12:44   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers Laurent Pinchart
2017-10-14 12:45   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time Laurent Pinchart
2017-10-14 12:51   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 18/48] drm: omapdrm: displays: Get panel " Laurent Pinchart
2017-10-14 12:55   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 19/48] drm: omapdrm: displays: Get encoder " Laurent Pinchart
2017-10-14 12:58   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers Laurent Pinchart
2017-10-14 13:12   ` Sebastian Reichel
2017-10-16  9:09     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
2017-10-15 21:10   ` Sebastian Reichel
2017-10-16  9:11     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
2017-10-16  8:39   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
2017-10-16  8:42   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
2017-10-16  8:47   ` Sebastian Reichel
2017-10-16  9:03     ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
2017-10-16  9:05   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
2017-10-16  9:08   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
2017-10-16  9:12   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
2017-10-16  9:15   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function Laurent Pinchart
2017-10-16  9:16   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
2017-10-16  9:39   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
2017-10-16 10:19   ` Sebastian Reichel
2017-10-16 10:27   ` Sebastian Reichel
2017-10-16 11:17     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 32/48] drm: omapdrm: hdmi5: " Laurent Pinchart
2017-10-17 18:52   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 33/48] drm: omapdrm: venc: Allocate the venc private " Laurent Pinchart
2017-10-17 18:52   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi " Laurent Pinchart
2017-10-17 19:09   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status Laurent Pinchart
2017-10-17 19:12   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
2017-10-17 20:02   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
2017-10-17 20:06   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
2017-10-17 20:08   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
2017-10-17 20:11   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
2017-10-17 20:13   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
2017-10-17 20:31   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes Laurent Pinchart
2017-10-17 20:37   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
2017-10-17 21:23   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
2017-10-17 21:23   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
2017-10-17 21:24   ` Sebastian Reichel
2017-10-17 21:44     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 46/48] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
2017-10-17 22:09   ` Sebastian Reichel
2017-10-13 14:59 ` [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Laurent Pinchart
2017-10-17 22:16   ` Sebastian Reichel
2017-10-17 22:34     ` Laurent Pinchart
2017-10-13 14:59 ` [PATCH 48/48] drm: omapdrm: dss: Store the registered plls array " Laurent Pinchart
2017-10-17 22:21   ` Sebastian Reichel
2017-10-17 22:29 ` [PATCH 00/48] omapdrm: Merge omapdrm and omapdss Sebastian Reichel
2017-10-17 22:36   ` Laurent Pinchart
2017-10-18  9:46 ` Tomi Valkeinen
2017-10-18  9:56   ` Tomi Valkeinen
2018-01-19  3:48     ` Laurent Pinchart
2017-10-18 12:56 ` Tomi Valkeinen
2017-12-01 12:55 ` Tomi Valkeinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.