Skip to contentSkip to conversation

Add support for KeemBay DRM driver

PATCH Superseded Anitha Chrisanthus 3 participants 8 messages Jul 17, 2020 – Jul 30, 2020

Subsystems (3)

v3 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Anitha Chrisanthus

author maintainer
#0 lore raw

PATCH v3 1/1 Add support for KeemBay DRM driver

This is a new DRM driver for Intel's KeemBay SOC. The SoC couples an ARM Cortex A53 CPU with an Intel Movidius VPU.

This driver is tested with the KMB EVM board which is the refernce baord for Keem Bay SOC. The SOC's display pipeline is as follows

+--------------+    +---------+    +-----------------------+
|LCD controller| -> |Mipi DSI | -> |Mipi to HDMI Converter |
+--------------+    +---------+    +-----------------------+

LCD controller and Mipi DSI transmitter are part of the SOC and mipi to HDMI converter is ADV7535 for KMB EVM board.

The DRM driver is a basic KMS atomic modesetting display driver and has no 2D or 3D graphics.It calls into the ADV bridge driver at the connector level.

Only 1080p resolution and single plane is supported at this time. The usecase is for debugging video and camera outputs.

Device tree patches are under review here
https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

Changes since v1:
- Removed redundant license text, updated license
- Rearranged include blocks
- renamed global vars and removed extern in c
- Used upclassing for dev_private
- Used drm_dev_init in drm device create
- minor cleanups

Changes since v2:
- squashed all commits to a single commit
- logging changed to drm_info, drm_dbg etc.
- used devm_drm_dev_alloc()
- removed commented out sections and general cleanup

Anitha Chrisanthus (1):
drm/kmb: Add support for KeemBay Display

 drivers/gpu/drm/Kconfig         |    2 +
 drivers/gpu/drm/Makefile        |    1 +
 drivers/gpu/drm/kmb/Kconfig     |   12 +
 drivers/gpu/drm/kmb/Makefile    |    2 +
 drivers/gpu/drm/kmb/kmb_crtc.c  |  219 +++++
 drivers/gpu/drm/kmb/kmb_crtc.h  |   41 +
 drivers/gpu/drm/kmb/kmb_drv.c   |  759 ++++++++++++++++
 drivers/gpu/drm/kmb/kmb_drv.h   |  165 ++++
 drivers/gpu/drm/kmb/kmb_dsi.c   | 1833 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/kmb/kmb_dsi.h   |  370 ++++++++
 drivers/gpu/drm/kmb/kmb_plane.c |  515 +++++++++++
 drivers/gpu/drm/kmb/kmb_plane.h |  124 +++
 drivers/gpu/drm/kmb/kmb_regs.h  |  738 ++++++++++++++++
 13 files changed, 4781 insertions(+)
 create mode 100644 drivers/gpu/drm/kmb/Kconfig
 create mode 100644 drivers/gpu/drm/kmb/Makefile
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_regs.h
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#1 lore raw

PATCH v3 1/1 drm/kmb: Add support for KeemBay Display

This is a basic KMS atomic modesetting display driver for KeemBay family of SOCs. Driver has no 2D or 3D graphics.It calls into the ADV bridge driver at the connector level.

Single CRTC with LCD controller->mipi DSI-> ADV bridge

Only 1080p resolution and single plane is supported at this time.

v2: moved extern to .h, removed license text
use drm_dev_init, upclassed dev_private, removed HAVE_IRQ.

v3: Squashed all 59 commits to one

---
 drivers/gpu/drm/Kconfig         |    2 +
 drivers/gpu/drm/Makefile        |    1 +
 drivers/gpu/drm/kmb/Kconfig     |   12 +
 drivers/gpu/drm/kmb/Makefile    |    2 +
 drivers/gpu/drm/kmb/kmb_crtc.c  |  219 +++++
 drivers/gpu/drm/kmb/kmb_crtc.h  |   41 +
 drivers/gpu/drm/kmb/kmb_drv.c   |  759 ++++++++++++++++
 drivers/gpu/drm/kmb/kmb_drv.h   |  165 ++++
 drivers/gpu/drm/kmb/kmb_dsi.c   | 1833 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/kmb/kmb_dsi.h   |  370 ++++++++
 drivers/gpu/drm/kmb/kmb_plane.c |  515 +++++++++++
 drivers/gpu/drm/kmb/kmb_plane.h |  124 +++
 drivers/gpu/drm/kmb/kmb_regs.h  |  738 ++++++++++++++++
 13 files changed, 4781 insertions(+)
 create mode 100644 drivers/gpu/drm/kmb/Kconfig
 create mode 100644 drivers/gpu/drm/kmb/Makefile
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_regs.h
drivers/gpu/drm/Kconfig +2 -0
index c4fd57d..5292574 100644
@@ -275,6 +275,8 @@ source "drivers/gpu/drm/nouveau/Kconfig"
 
 source "drivers/gpu/drm/i915/Kconfig"
 
+source "drivers/gpu/drm/kmb/Kconfig"
+
 config DRM_VGEM
 	tristate "Virtual GEM provider"
 	depends on DRM
drivers/gpu/drm/Makefile +1 -0
index 2c0e5a7..bdbdc63 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
 obj-$(CONFIG_DRM_MGA)	+= mga/
 obj-$(CONFIG_DRM_I810)	+= i810/
 obj-$(CONFIG_DRM_I915)	+= i915/
+obj-$(CONFIG_DRM_KMB_DISPLAY)  += kmb/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
drivers/gpu/drm/kmb/Kconfig new file +12 -0
new file mode 100644
index 0000000..005a9962
@@ -0,0 +1,12 @@
+config DRM_KMB_DISPLAY
+	tristate "KEEMBAY DISPLAY"
+	depends on DRM && OF && (ARM || ARM64)
+	depends on COMMON_CLK
+	select DRM_KMS_HELPER
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	help
+	Choose this option if you have an KEEMBAY DISPLAY controller.
+
+	If M is selected the module will be called kmb-display.
drivers/gpu/drm/kmb/Makefile new file +2 -0
new file mode 100644
index 0000000..527d737
@@ -0,0 +1,2 @@
+kmb-drm-y := kmb_crtc.o kmb_drv.o kmb_plane.o kmb_dsi.o
+obj-$(CONFIG_DRM_KMB_DISPLAY)	+= kmb-drm.o
drivers/gpu/drm/kmb/kmb_crtc.c new file +219 -0

219 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_crtc.h new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_drv.c new file +759 -0

759 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_drv.h new file +165 -0

165 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_dsi.c new file +1833 -0

1,787 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_dsi.h new file +370 -0

370 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_plane.c new file +515 -0

515 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_plane.h new file +124 -0

124 lines not on this page · raw message

drivers/gpu/drm/kmb/kmb_regs.h new file +738 -0

738 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH v3] drm/kmb: Add support for KeemBay Display

Hi Anitha.

Quoted 8 lines · Anitha Chrisanthus

This is a basic KMS atomic modesetting display driver for KeemBay family of SOCs. Driver has no 2D or 3D graphics.It calls into the ADV bridge driver at the connector level.

Single CRTC with LCD controller->mipi DSI-> ADV bridge

Only 1080p resolution and single plane is supported at this time.

Quoted 7 lines

v2: moved extern to .h, removed license text
use drm_dev_init, upclassed dev_private, removed HAVE_IRQ.

v3: Squashed all 59 commits to one

This was much easier to look into with it all squashed together. See comments scattered in the following.

The only major feedback is that kmb_dsi really looks like something that should be implemented as a real bridge driver.
Lots of small details to bring the driver up to the current standard. And other bits I noted while browsing the code.

Sam

Quoted 60 lines
---
 drivers/gpu/drm/Kconfig         |    2 +
 drivers/gpu/drm/Makefile        |    1 +
 drivers/gpu/drm/kmb/Kconfig     |   12 +
 drivers/gpu/drm/kmb/Makefile    |    2 +
 drivers/gpu/drm/kmb/kmb_crtc.c  |  219 +++++
 drivers/gpu/drm/kmb/kmb_crtc.h  |   41 +
 drivers/gpu/drm/kmb/kmb_drv.c   |  759 ++++++++++++++++
 drivers/gpu/drm/kmb/kmb_drv.h   |  165 ++++
 drivers/gpu/drm/kmb/kmb_dsi.c   | 1833 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/kmb/kmb_dsi.h   |  370 ++++++++
 drivers/gpu/drm/kmb/kmb_plane.c |  515 +++++++++++
 drivers/gpu/drm/kmb/kmb_plane.h |  124 +++
 drivers/gpu/drm/kmb/kmb_regs.h  |  738 ++++++++++++++++
 13 files changed, 4781 insertions(+)
 create mode 100644 drivers/gpu/drm/kmb/Kconfig
 create mode 100644 drivers/gpu/drm/kmb/Makefile
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_regs.h
drivers/gpu/drm/Kconfig +2 -0
index c4fd57d..5292574 100644
@@ -275,6 +275,8 @@ source "drivers/gpu/drm/nouveau/Kconfig"
 
 source "drivers/gpu/drm/i915/Kconfig"
 
+source "drivers/gpu/drm/kmb/Kconfig"
+
 config DRM_VGEM
 	tristate "Virtual GEM provider"
 	depends on DRM
drivers/gpu/drm/Makefile +1 -0
index 2c0e5a7..bdbdc63 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
 obj-$(CONFIG_DRM_MGA)	+= mga/
 obj-$(CONFIG_DRM_I810)	+= i810/
 obj-$(CONFIG_DRM_I915)	+= i915/
+obj-$(CONFIG_DRM_KMB_DISPLAY)  += kmb/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
drivers/gpu/drm/kmb/Kconfig new file +2 -0
new file mode 100644
index 0000000..005a9962
@@ -0,0 +1,12 @@
+config DRM_KMB_DISPLAY
+	tristate "KEEMBAY DISPLAY"

drivers/gpu/drm/kmb/Kconfig line 12

Quoted 10 lines
drivers/gpu/drm/kmb/Kconfig new file +10 -0
+	depends on DRM && OF && (ARM || ARM64)
+	depends on COMMON_CLK
+	select DRM_KMS_HELPER
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	help
+	Choose this option if you have an KEEMBAY DISPLAY controller.
+
+	If M is selected the module will be called kmb-display.

It would be good if you could elaborate just a bit more here. Just so users knows a bit more what it is. For example I think most users will not know this is something from Intel.
Also I think the module is not named kmb-display, so this needs to be addressed.

Quoted 27 lines
drivers/gpu/drm/kmb/Makefile new file +2 -0
new file mode 100644
index 0000000..527d737
@@ -0,0 +1,2 @@
+kmb-drm-y := kmb_crtc.o kmb_drv.o kmb_plane.o kmb_dsi.o
+obj-$(CONFIG_DRM_KMB_DISPLAY)	+= kmb-drm.o
drivers/gpu/drm/kmb/kmb_crtc.c new file +13 -0
new file mode 100644
index 0000000..570d46e
@@ -0,0 +1,219 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright © 2018-2020 Intel Corporation
+ */
+
+#include <linux/clk.h>
+#include <linux/of_graph.h>
+#include <linux/platform_data/simplefb.h>
+#include <video/videomode.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>

drivers/gpu/drm/kmb/kmb_crtc.c line 23

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_of.h>
+#include <drm/drm_plane_helper.h>
+#include "kmb_crtc.h"
+#include "kmb_drv.h"
+#include "kmb_plane.h"
+#include "kmb_regs.h"
+#include "kmb_dsi.h"

Almost OK - an empty line between each block would be appreciated.

drivers/gpu/drm/kmb/kmb_crtc.c line 31

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +8 -0
+
+static void kmb_crtc_cleanup(struct drm_crtc *crtc)
+{
+	struct kmb_crtc *l_crtc = to_kmb_crtc(crtc);
+
+	drm_crtc_cleanup(crtc);
+	kfree(l_crtc);
+}

I cannot find where kmb_crtc is allocated - is this a left-over from some old code and it is no longer used/relevant?

drivers/gpu/drm/kmb/kmb_crtc.c line 36

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +5 -0
+
+static int kmb_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);

bikeshedding...
general comment.
s/dev_p/kmb - it is a pointer to kmb_drm_private - so name it kmb to better reflect this. Bikeshedding - feel free to ignore.

drivers/gpu/drm/kmb/kmb_crtc.c line 38

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +2 -0
+
+	/*clear interrupt */

General comment. Include whitespace after "/*" and start with a capital letter.
Not a big deal, but this steal focus when not followed.

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +7 -0
+	kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);
+	/*set which interval to generate vertical interrupt */
+	kmb_write_lcd(dev_p, LCD_VSTATUS_COMPARE,
+		      LCD_VSTATUS_COMPARE_VSYNC);
+	/* enable vertical interrupt */
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);

drivers/gpu/drm/kmb/kmb_crtc.c line 55

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+	return 0;
+}
+
+static void kmb_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	/*clear interrupt */
+	kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);

I had expected you should clear the interrupt _after_ disabling the interrupt. But I guess this is no big deal as interrupt may occur also just before the disable.

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +11 -0
+	/* disable vertical interrupt */
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			LCD_INT_VERT_COMP);
+}
+
+static const struct drm_crtc_funcs kmb_crtc_funcs = {
+	.destroy = kmb_crtc_cleanup,
+	.set_config = drm_atomic_helper_set_config,
+	.page_flip = drm_atomic_helper_page_flip,
+	.reset = drm_atomic_helper_crtc_reset,
+	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,

drivers/gpu/drm/kmb/kmb_crtc.c line 76

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+	.enable_vblank = kmb_crtc_enable_vblank,
+	.disable_vblank = kmb_crtc_disable_vblank,
+};
+
+static void kmb_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_display_mode *m = &crtc->state->adjusted_mode;
+	struct videomode vm;

videomode should not be required here.

Quoted 14 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +14 -0
+	int vsync_start_offset;
+	int vsync_end_offset;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+	unsigned int val = 0;
+
+	/* initialize mipi */
+	kmb_dsi_hw_init(dev, m);
+	drm_info(dev,
+		"vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d hsync_len=%d\n",
+		 m->crtc_vsync_start - m->crtc_vdisplay,
+		 m->crtc_vtotal - m->crtc_vsync_end,
+		 m->crtc_vsync_end - m->crtc_vsync_start,
+		 m->crtc_hsync_start - m->crtc_hdisplay,
+		 m->crtc_htotal - m->crtc_hsync_end,

drivers/gpu/drm/kmb/kmb_crtc.c line 100

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+		 m->crtc_hsync_end - m->crtc_hsync_start);
+	val = kmb_read_lcd(dev_p, LCD_INT_ENABLE);
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE, val);
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR, ~0x0);
+	vm.vfront_porch = 2;
+	vm.vback_porch = 2;
+	vm.vsync_len = 8;
+	vm.hfront_porch = 0;
+	vm.hback_porch = 0;
+	vm.hsync_len = 28;

This looks like values that should come from the panel - and not values hardcoded in the driver.

The use of struct videomode should be avoid IMO. videomode balongs to fbdev time, use display_timing is you need something like it.

Quoted 31 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +31 -0
+
+	vsync_start_offset =  m->crtc_vsync_start -  m->crtc_hsync_start;
+	vsync_end_offset =  m->crtc_vsync_end - m->crtc_hsync_end;
+
+	drm_dbg(dev, "%s : %dactive height= %d vbp=%d vfp=%d vsync-w=%d h-active=%d h-bp=%d h-fp=%d hysnc-l=%d",
+			__func__, __LINE__,
+			m->crtc_vdisplay, vm.vback_porch, vm.vfront_porch,
+			vm.vsync_len, m->crtc_hdisplay, vm.hback_porch,
+			vm.hfront_porch, vm.hsync_len);
+	kmb_write_lcd(dev_p, LCD_V_ACTIVEHEIGHT,
+			m->crtc_vdisplay - 1);
+	kmb_write_lcd(dev_p, LCD_V_BACKPORCH, vm.vback_porch);
+	kmb_write_lcd(dev_p, LCD_V_FRONTPORCH, vm.vfront_porch);
+	kmb_write_lcd(dev_p, LCD_VSYNC_WIDTH, vm.vsync_len - 1);
+	kmb_write_lcd(dev_p, LCD_H_ACTIVEWIDTH,
+			m->crtc_hdisplay - 1);
+	kmb_write_lcd(dev_p, LCD_H_BACKPORCH, vm.hback_porch);
+	kmb_write_lcd(dev_p, LCD_H_FRONTPORCH, vm.hfront_porch);
+	kmb_write_lcd(dev_p, LCD_HSYNC_WIDTH, vm.hsync_len - 1);
+	/*this is hardcoded as 0 in the Myriadx code */
+	kmb_write_lcd(dev_p, LCD_VSYNC_START, 0);
+	kmb_write_lcd(dev_p, LCD_VSYNC_END, 0);
+	/* back ground color */
+	kmb_write_lcd(dev_p, LCD_BG_COLOUR_LS, 0x4);
+	if (m->flags == DRM_MODE_FLAG_INTERLACE) {
+		kmb_write_lcd(dev_p,
+			      LCD_VSYNC_WIDTH_EVEN, vm.vsync_len - 1);
+		kmb_write_lcd(dev_p,
+				LCD_V_BACKPORCH_EVEN, vm.vback_porch);
+		kmb_write_lcd(dev_p,
+				LCD_V_FRONTPORCH_EVEN, vm.vfront_porch);

drivers/gpu/drm/kmb/kmb_crtc.c line 140

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +9 -0
+		kmb_write_lcd(dev_p, LCD_V_ACTIVEHEIGHT_EVEN,
+			      m->crtc_vdisplay - 1);
+		/*this is hardcoded as 10 in the Myriadx code */
+		kmb_write_lcd(dev_p, LCD_VSYNC_START_EVEN, 10);
+		kmb_write_lcd(dev_p, LCD_VSYNC_END_EVEN, 10);
+	}
+	kmb_write_lcd(dev_p, LCD_TIMING_GEN_TRIG, ENABLE);
+	kmb_set_bitmask_lcd(dev_p, LCD_CONTROL, LCD_CTRL_ENABLE);
 
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE, val);

Is LCD_INT_ENABLE, really a readable register? val is assigned the value from LCD_INT_ENABLE, before.

Quoted 52 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +52 -0
+	/* TBD */
+	/* set clocks here */
+}
+
+static void kmb_crtc_atomic_enable(struct drm_crtc *crtc,
+				   struct drm_crtc_state *old_state)
+{
+	struct kmb_drm_private *lcd = crtc_to_kmb_priv(crtc);
+
+	clk_prepare_enable(lcd->clk);
+	kmb_crtc_mode_set_nofb(crtc);
+	drm_crtc_vblank_on(crtc);
+}
+
+static void kmb_crtc_atomic_disable(struct drm_crtc *crtc,
+				    struct drm_crtc_state *old_state)
+{
+	struct kmb_drm_private *lcd = crtc_to_kmb_priv(crtc);
+
+	/* always disable planes on the CRTC that is being turned off */
+	drm_atomic_helper_disable_planes_on_crtc(old_state, false);
+
+	drm_crtc_vblank_off(crtc);
+	clk_disable_unprepare(lcd->clk);
+}
+
+static void kmb_crtc_atomic_begin(struct drm_crtc *crtc,
+				  struct drm_crtc_state *state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);
+}
+
+static void kmb_crtc_atomic_flush(struct drm_crtc *crtc,
+				  struct drm_crtc_state *state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);
+
+	spin_lock_irq(&crtc->dev->event_lock);
+	if (crtc->state->event)
+		drm_crtc_send_vblank_event(crtc, crtc->state->event);
+	crtc->state->event = NULL;
+	spin_unlock_irq(&crtc->dev->event_lock);
+}
+

drivers/gpu/drm/kmb/kmb_crtc.c line 202

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+static const struct drm_crtc_helper_funcs kmb_crtc_helper_funcs = {
+	.atomic_begin = kmb_crtc_atomic_begin,
+	.atomic_enable = kmb_crtc_atomic_enable,
+	.atomic_disable = kmb_crtc_atomic_disable,
+	.atomic_flush = kmb_crtc_atomic_flush,
+};
+
+int kmb_setup_crtc(struct drm_device *drm)
+{
+	struct kmb_drm_private *lcd = to_kmb(drm);

General comment.
It makes code more read-able if the same local name is used all over. Right now there is lcd and dev_p (and then I went agead and suggested kmb as a third name - sigh).

Quoted 46 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +17 -0
+	struct kmb_plane *primary;
+	int ret;
+
+	primary = kmb_plane_init(drm);
+	if (IS_ERR(primary))
+		return PTR_ERR(primary);
+
+	ret = drm_crtc_init_with_planes(drm, &lcd->crtc, &primary->base_plane,
+					NULL, &kmb_crtc_funcs, NULL);
+	if (ret) {
+		kmb_plane_destroy(&primary->base_plane);
+		return ret;
+	}
+
+	drm_crtc_helper_add(&lcd->crtc, &kmb_crtc_helper_funcs);
+	return 0;
+}
drivers/gpu/drm/kmb/kmb_crtc.h new file +23 -0
new file mode 100644
index 0000000..51a0a39
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright © 2018-2020 Intel Corporation
+ */
+
+#ifndef __KMB_CRTC_H__
+#define __KMB_CRTC_H__
+
+#include <linux/clk.h>
+#include <linux/of_graph.h>
+#include <linux/platform_data/simplefb.h>
+#include <video/videomode.h>
+#include <drm/drm_debugfs.h>
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_file.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include <drm/drm_vblank.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>

drivers/gpu/drm/kmb/kmb_crtc.h line 33

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +10 -0
+#include <linux/wait.h>
+#include "kmb_drv.h"
+
+#define to_kmb_crtc_state(x) container_of(x, struct kmb_crtc_state, crtc_base)
+#define to_kmb_crtc(x) container_of(x, struct kmb_crtc, crtc_base)
+
+struct kmb_crtc {
+	struct drm_crtc crtc_base;
+	struct kmb_drm_private kmb_dev;
+};

This struct looks unused - delete it.

drivers/gpu/drm/kmb/kmb_crtc.h line 37

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +4 -0
+
+struct kmb_crtc_state {
+	struct drm_crtc_state crtc_base;
+};

This struct looks unused - delete it.

drivers/gpu/drm/kmb/kmb_crtc.h line 39

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +2 -0
+
+extern void kmb_plane_destroy(struct drm_plane *plane);

General comment - drop extern in fron of prototypes in .h files. kmb_plane_destroy is declared in another .h file - so drop this.

drivers/gpu/drm/kmb/kmb_crtc.h line 40

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.h new file +1 -0
+extern struct kmb_plane *kmb_plane_init(struct drm_device *drm);

This is likewise decalred in another .h file - drop it.

drivers/gpu/drm/kmb/kmb_crtc.h line 41

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.h new file +1 -0
+#endif /* __KMB_CRTC_H__ */

kmb_setup_crtc() is decalred in mkb_drv.h - so there i s no need for this header file anymore - delete it.

Quoted 28 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +22 -0
new file mode 100644
index 0000000..159f36a
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright © 2018-2020 Intel Corporation
+ */
+
+#include <linux/clk.h>
+#include <linux/console.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/of_graph.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/pm_runtime.h>
+#include <linux/spinlock.h>
+#include <drm/drm.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_ioctl.h>

drivers/gpu/drm/kmb/kmb_drv.c line 32

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+#include <drm/drm_irq.h>
+#include <drm/drm_of.h>
+#include <drm/drm_probe_helper.h>
+#include "kmb_crtc.h"
+#include "kmb_drv.h"
+#include "kmb_dsi.h"
+#include "kmb_plane.h"
+#include "kmb_regs.h"
+
+//#define DEBUG

No // comments (not may rule, but some people request them removed)

drivers/gpu/drm/kmb/kmb_drv.c line 34

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+/* IRQ handler */
+static irqreturn_t kmb_isr(int irq, void *arg);

No need for this prototype - drop it.

drivers/gpu/drm/kmb/kmb_drv.c line 41

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+
+int kmb_under_flow = 0, kmb_flush_done = 0, layer_no = 0;
+static struct clk *clk_lcd;
+static struct clk *clk_mipi;
+static struct clk *clk_mipi_ecfg;
+static struct clk *clk_mipi_cfg;
+static struct clk *clk_pll0;

Why are they not all part of kmb_drm_private?

drivers/gpu/drm/kmb/kmb_drv.c line 43

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+struct drm_bridge *adv_bridge;

Same here?

drivers/gpu/drm/kmb/kmb_drv.c line 45

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+int kmb_display_clk_enable(void)

pass kmb_drm_private so drm_* can be used for logging.

Quoted 17 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +17 -0
+{
+	int ret = 0;
+
+	ret = clk_prepare_enable(clk_lcd);
+	if (ret) {
+		DRM_ERROR("Failed to enable LCD clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi);
+	if (ret) {
+		DRM_ERROR("Failed to enable MIPI clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi_ecfg);
+	if (ret) {

drivers/gpu/drm/kmb/kmb_drv.c line 72

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		DRM_ERROR("Failed to enable MIPI_ECFG clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi_cfg);
+	if (ret) {
+		DRM_ERROR("Failed to enable MIPI_CFG clock: %d\n", ret);
+		return ret;
+	}
+	DRM_INFO("SUCCESS : enabled LCD MIPI clocks\n");

Consider using an array for the clocks - simpler code.

Quoted 30 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +30 -0
+	return 0;
+}
+
+static int kmb_display_clk_disable(void)
+{
+	if (clk_lcd)
+		clk_disable_unprepare(clk_lcd);
+	if (clk_mipi)
+		clk_disable_unprepare(clk_mipi);
+	if (clk_mipi_ecfg)
+		clk_disable_unprepare(clk_mipi_ecfg);
+	if (clk_mipi_cfg)
+		clk_disable_unprepare(clk_mipi_cfg);
+	return 0;
+}
+
+static void __iomem *kmb_map_mmio(struct platform_device *pdev, char *name)
+{
+	struct resource *res;
+	u32 size;
+	void __iomem *mem;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	if (!res) {
+		DRM_ERROR("failed to get resource for %s\n", name);
+		return ERR_PTR(-ENOMEM);
+	}
+	size = resource_size(res);
+	if (!request_mem_region(res->start, size, name)) {
+		DRM_ERROR("failed to reserve %s registers\n", name);

drivers/gpu/drm/kmb/kmb_drv.c line 112

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		return ERR_PTR(-ENOMEM);
+	}
+	mem = ioremap(res->start, size);
+	if (!mem) {
+		DRM_ERROR("failed to ioremap %s registers\n", name);
+		release_mem_region(res->start, size);
+		return ERR_PTR(-ENOMEM);
+	}
+	return mem;
+}

Error handling when calling kmb_map_mmio() looks wrong. The best way to fix it up would be to introduce the devm_ variants so this gets cleaned up automatically.
I think devm_ioremap_resource() will ct it - did not check it.

drivers/gpu/drm/kmb/kmb_drv.c line 114

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+//#define ICAM_LCD_QOS

Some debug left over that should be dropped?

Quoted 16 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +16 -0
+static int kmb_load(struct drm_device *drm, unsigned long flags)
+{
+	struct kmb_drm_private *dev_p = to_kmb(drm);
+	struct platform_device *pdev = to_platform_device(drm->dev);
+	int irq_lcd;
+	int ret = 0;
+	unsigned long clk;
+#ifdef ICAM_LCD_QOS
+	int val = 0;
+#endif
+	struct device_node *vpu_dev;
+
+	/* Map MIPI MMIO registers */
+	dev_p->mipi_mmio = kmb_map_mmio(pdev, "mipi_regs");
+	if (IS_ERR(dev_p->mipi_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MIPI registers\n");

drivers/gpu/drm/kmb/kmb_drv.c line 140

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		iounmap(dev_p->lcd_mmio);
+		return -ENOMEM;
+	}
+
+	/* Map LCD MMIO registers */
+	dev_p->lcd_mmio = kmb_map_mmio(pdev, "lcd_regs");
+	if (IS_ERR(dev_p->lcd_mmio)) {
+		drm_err(&dev_p->drm, "failed to map LCD registers\n");
+		return -ENOMEM;
+	}

Here is the broken error handling.
Fails to iounmap dev_p->mipi_mmio when lcd_mmio fails. And a few lines up lcd_mmio is unmapped before it is mapped.

Quoted 15 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +15 -0
+
+	/* This is only for MIPI_TX_MSS_LCD_MIPI_CFG and
+	 * MSS_CAM_CLK_CTRL register
+	 */
+	dev_p->msscam_mmio = kmb_map_mmio(pdev, "msscam_regs");
+	if (IS_ERR(dev_p->msscam_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MSSCAM registers\n");
+		iounmap(dev_p->lcd_mmio);
+		iounmap(dev_p->mipi_mmio);
+		return -ENOMEM;
+	}
+
+	if (IS_ERR(dev_p->msscam_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MSSCAM registers\n");
+		iounmap(dev_p->lcd_mmio);

drivers/gpu/drm/kmb/kmb_drv.c line 165

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		iounmap(dev_p->mipi_mmio);
+		return -ENOMEM;
+	}
+#ifdef ICAM_LCD_QOS
+	dev_p->icamlcd_mmio = ioremap_nocache(ICAM_MMIO, ICAM_MMIO_SIZE);
+	if (IS_ERR(dev_p->icamlcd_mmio)) {
+		drm_err(&dev_p->drm, "failed to map ICAM registers\n");
+		return -ENOMEM;
+	}
+#endif

The function is already long enough.
Consider pulling clock stuff out in a helper function.

Quoted 79 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +79 -0
+	/* Enable display clocks */
+	clk_lcd = clk_get(&pdev->dev, "clk_lcd");
+	if (IS_ERR(clk_lcd)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_lcd\n");
+		goto setup_fail;
+	}
+
+	clk_mipi = clk_get(&pdev->dev, "clk_mipi");
+	if (IS_ERR(clk_mipi)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi\n");
+		goto setup_fail;
+	}
+
+	clk_mipi_ecfg = clk_get(&pdev->dev, "clk_mipi_ecfg");
+	if (IS_ERR(clk_mipi_ecfg)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi_ecfg\n");
+		goto setup_fail;
+	}
+
+	clk_mipi_cfg = clk_get(&pdev->dev, "clk_mipi_cfg");
+	if (IS_ERR(clk_mipi_cfg)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi_cfg\n");
+		goto setup_fail;
+	}
+	vpu_dev = of_find_node_by_path("/soc/vpu-ipc");
+	clk_pll0 = of_clk_get_by_name(vpu_dev, "pll_0_out_0");
+	if (IS_ERR(clk_pll0)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_pll0 ");
+		goto setup_fail;
+	}
+	dev_p->sys_clk_mhz = clk_get_rate(clk_pll0)/1000000;
+	drm_info(&dev_p->drm, "system clk = %d Mhz", dev_p->sys_clk_mhz);
+
+	/* Set LCD clock to 200 Mhz */
+	ret = clk_set_rate(clk_lcd, KMB_LCD_DEFAULT_CLK);
+	if (clk_get_rate(clk_lcd) != KMB_LCD_DEFAULT_CLK) {
+		drm_err(&dev_p->drm, "failed to set to clk_lcd to %d\n",
+			  KMB_LCD_DEFAULT_CLK);
+	}
+	drm_info(&dev_p->drm, "clk_lcd = %ld\n", clk_get_rate(clk_lcd));
+
+	/* Set MIPI clock to 24 Mhz */
+	ret = clk_set_rate(clk_mipi, KMB_MIPI_DEFAULT_CLK);
+	if (clk_get_rate(clk_mipi) != KMB_MIPI_DEFAULT_CLK) {
+		drm_err(&dev_p->drm, "failed to set to clk_mipi to %d\n",
+			  KMB_MIPI_DEFAULT_CLK);
+		goto setup_fail;
+	}
+	drm_info(&dev_p->drm, "clk_mipi = %ld\n", clk_get_rate(clk_mipi));
+
+	clk = clk_get_rate(clk_mipi_ecfg);
+	if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+		/* Set MIPI_ECFG clock to 24 Mhz */
+		ret = clk_set_rate(clk_mipi_ecfg, KMB_MIPI_DEFAULT_CFG_CLK);
+		clk = clk_get_rate(clk_mipi_ecfg);
+		if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+			drm_err(&dev_p->drm,
+				"failed to set to clk_mipi_ecfg to %d\n",
+				 KMB_MIPI_DEFAULT_CFG_CLK);
+			goto setup_fail;
+		}
+
+		drm_info(&dev_p->drm, "clk_mipi_ecfg after set = %ld\n", clk);
+	}
+
+	clk = clk_get_rate(clk_mipi_cfg);
+	if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+		/* Set MIPI_CFG clock to 24 Mhz */
+		ret = clk_set_rate(clk_mipi_cfg, 24000000);
+		clk = clk_get_rate(clk_mipi_cfg);
+		if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+			drm_err(&dev_p->drm,
+					"failed to set clk_mipi_cfg to %d\n",
+				  KMB_MIPI_DEFAULT_CFG_CLK);
+			goto setup_fail;
+		}
+		drm_info(&dev_p->drm,
+				"Get clk_mipi_cfg after set = %ld\n", clk);
+	}

drivers/gpu/drm/kmb/kmb_drv.c line 254

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+	ret = kmb_display_clk_enable();
+
+	/* Enable MSS_CAM_CLK_CTRL for MIPI TX and LCD */
+	kmb_set_bitmask_msscam(dev_p, MSS_CAM_CLK_CTRL, 0x1fff);
+	kmb_set_bitmask_msscam(dev_p, MSS_CAM_RSTN_CTRL, 0xffffffff);
+
+	/* Register irqs here - section 17.3 in databook
+	 * lists LCD at 79 and 82 for MIPI under MSS CPU -
+	 * firmware has redirected  79 to A53 IRQ 33

extra space

Quoted 66 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +66 -0
+	 */
+
+	/* Allocate LCD interrupt resources, enable interrupt line,
+	 * and setup IRQ handling
+	 */
+	irq_lcd = platform_get_irq_byname(pdev, "irq_lcd");
+	if (irq_lcd < 0) {
+		drm_err(&dev_p->drm, "irq_lcd not found");
+		goto setup_fail;
+	}
+
+	/* Get the optional framebuffer memory resource */
+	ret = of_reserved_mem_device_init(drm->dev);
+	if (ret && ret != -ENODEV)
+		return ret;
+
+	spin_lock_init(&dev_p->irq_lock);
+
+	ret = kmb_setup_crtc(drm);
+	if (ret < 0) {
+		drm_err(&dev_p->drm, "failed to create crtc\n");
+		goto setup_fail;
+	}
+
+	/* Initialize MIPI DSI */
+	ret = kmb_dsi_init(drm, adv_bridge);
+	if (ret) {
+		drm_err(&dev_p->drm, "failed to initialize DSI\n");
+		goto setup_fail;
+	}
+
+	ret = drm_irq_install(drm, irq_lcd);
+	if (ret < 0) {
+		drm_err(&dev_p->drm, "failed to install IRQ handler\n");
+		goto irq_fail;
+	}
+
+	dev_p->irq_lcd = irq_lcd;
+
+	/* icam tests */
+#ifdef ICAM_LCD_QOS
+	/*generator mode = 0 fixed mode=1 limiter */
+	writel(1, (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET + LCD_QOS_MODE));
+	/* b/w */
+	writel(0x60, (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET + LCD_QOS_BW));
+
+	/* set priority.p1 */
+	val = readl(dev_p->icamlcd_mmio + ICAM_LCD_OFFSET + LCD_QOS_PRORITY);
+	val &= ~(0x700);
+	writel(val | 0x100,
+	       (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET + LCD_QOS_PRORITY));
+
+	drm_info(&dev_p->drm,
+			"ICAM mode = 0x%x, priority = 0x%x bandwidth=0x%x",
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_MODE),
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_PRORITY),
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_BW));
+#endif
+	return 0;
+
+ irq_fail:
+	drm_crtc_cleanup(&dev_p->crtc);
+ setup_fail:
+	of_reserved_mem_device_release(drm->dev);
+
+	return ret;

drivers/gpu/drm/kmb/kmb_drv.c line 330

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+}
+
+int kmb_atomic_helper_check(struct drm_device *dev,
+			    struct drm_atomic_state *state)
+{
+	if (!state)
+		return 0;
+
+	return drm_atomic_helper_check(dev, state);
+}

I do not think this "if (!state)" gives us something extra - I think we are guranteed it is set here?
Daniel?

drivers/gpu/drm/kmb/kmb_drv.c line 340

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+static const struct drm_mode_config_funcs kmb_mode_config_funcs = {
+	.fb_create = drm_gem_fb_create,
+	.atomic_check = kmb_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void kmb_setup_mode_config(struct drm_device *drm)
+{
+	drm_mode_config_init(drm);

Use drmm_mode_config - this will also simplify cleanup.

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+	drm->mode_config.min_width = KMB_MIN_WIDTH;
+	drm->mode_config.min_height = KMB_MIN_HEIGHT;
+	drm->mode_config.max_width = KMB_MAX_WIDTH;
+	drm->mode_config.max_height = KMB_MAX_HEIGHT;
+	drm->mode_config.funcs = &kmb_mode_config_funcs;
+}
+

drivers/gpu/drm/kmb/kmb_drv.c line 357

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+static irqreturn_t handle_lcd_irq(struct drm_device *dev)
+{
+	unsigned long status, val, val1;
+	int plane_id, dma0_state, dma1_state;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	status = kmb_read_lcd(dev_p, LCD_INT_STATUS);
+
+	if (status & LCD_INT_EOF) {
+		/* TODO - handle EOF interrupt? */

Is this TODO still valid?

drivers/gpu/drm/kmb/kmb_drv.c line 368

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +11 -0
+
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_EOF);
+
+		/* When disabling/enabling LCD layers, the change takes effect
+		 * immediately and does not wait for EOF (end of frame).
+		 * When kmb_plane_atomic_disable is called, mark the plane as
+		 * disabled but actually disable the plane when EOF irq is
+		 * being handled.
+		 */
+		for (plane_id = LAYER_0;
+				plane_id < KMB_MAX_PLANES; plane_id++) {

dev_p->n_layers and not KMB_MAX_PLANES?

Quoted 195 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +195 -0
+			if (plane_status[plane_id].disable) {
+				kmb_clr_bitmask_lcd(dev_p,
+						    LCD_LAYERn_DMA_CFG
+						    (plane_id),
+						    LCD_DMA_LAYER_ENABLE);
+
+				kmb_clr_bitmask_lcd(dev_p, LCD_CONTROL,
+					    plane_status[plane_id].ctrl);
+
+				plane_status[plane_id].disable = false;
+			}
+		}
+		if (kmb_under_flow) {
+			/*DMA Recovery after underflow */
+			dma0_state = (layer_no == 0) ?
+			    LCD_VIDEO0_DMA0_STATE : LCD_VIDEO1_DMA0_STATE;
+			dma1_state = (layer_no == 0) ?
+			    LCD_VIDEO0_DMA1_STATE : LCD_VIDEO1_DMA1_STATE;
+
+			do {
+				kmb_write_lcd(dev_p, LCD_FIFO_FLUSH, 1);
+				val = kmb_read_lcd(dev_p, dma0_state)
+				    & LCD_DMA_STATE_ACTIVE;
+				val1 = kmb_read_lcd(dev_p, dma1_state)
+				    & LCD_DMA_STATE_ACTIVE;
+			} while ((val || val1));
+			/*disable dma */
+			kmb_clr_bitmask_lcd(dev_p, LCD_LAYERn_DMA_CFG(layer_no),
+					    LCD_DMA_LAYER_ENABLE);
+			kmb_write_lcd(dev_p, LCD_FIFO_FLUSH, 1);
+			kmb_flush_done = 1;
+			kmb_under_flow = 0;
+		}
+
+	}
+
+	if (status & LCD_INT_LINE_CMP) {
+		/* clear line compare interrupt */
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_LINE_CMP);
+	}
+
+	if (status & LCD_INT_VERT_COMP) {
+		/* Read VSTATUS */
+		val = kmb_read_lcd(dev_p, LCD_VSTATUS);
+		val = (val & LCD_VSTATUS_VERTICAL_STATUS_MASK);
+		switch (val) {
+		case LCD_VSTATUS_COMPARE_VSYNC:
+			/* Clear vertical compare interrupt */
+			kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);
+			if (kmb_flush_done) {
+				kmb_set_bitmask_lcd(dev_p,
+						    LCD_LAYERn_DMA_CFG
+						    (layer_no),
+						    LCD_DMA_LAYER_ENABLE);
+				kmb_flush_done = 0;
+			}
+			drm_handle_vblank(dev, 0);
+			break;
+		case LCD_VSTATUS_COMPARE_BACKPORCH:
+		case LCD_VSTATUS_COMPARE_ACTIVE:
+		case LCD_VSTATUS_COMPARE_FRONT_PORCH:
+			kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);
+			break;
+		}
+	}
+	if (status & LCD_INT_DMA_ERR) {
+		val =
+		    (status & LCD_INT_DMA_ERR &
+		     kmb_read_lcd(dev_p, LCD_INT_ENABLE));
+		/* LAYER0 - VL0 */
+		if (val & (LAYER0_DMA_FIFO_UNDERFLOW |
+			   LAYER0_DMA_CB_FIFO_UNDERFLOW |
+			   LAYER0_DMA_CR_FIFO_UNDERFLOW)) {
+			kmb_under_flow++;
+			drm_info(&dev_p->drm,
+			    "!LAYER0:VL0 DMA UNDERFLOW val = 0x%lx,under_flow=%d",
+			     val, kmb_under_flow);
+			/*disable underflow inerrupt */
+			kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+					    LAYER0_DMA_FIFO_UNDERFLOW |
+					    LAYER0_DMA_CB_FIFO_UNDERFLOW |
+					    LAYER0_DMA_CR_FIFO_UNDERFLOW);
+			kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR,
+					    LAYER0_DMA_CB_FIFO_UNDERFLOW |
+					    LAYER0_DMA_FIFO_UNDERFLOW |
+					    LAYER0_DMA_CR_FIFO_UNDERFLOW);
+			/*disable auto restart mode */
+			kmb_clr_bitmask_lcd(dev_p, LCD_LAYERn_DMA_CFG(0),
+				    LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);
+			layer_no = 0;
+		}
+
+		if (val & LAYER0_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA OVERFLOW val = 0x%lx", val);
+		if (val & LAYER0_DMA_CB_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA CB OVERFLOW val = 0x%lx", val);
+		if (val & LAYER0_DMA_CR_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA CR OVERFLOW val = 0x%lx", val);
+
+		/* LAYER1 - VL1 */
+		if (val & (LAYER1_DMA_FIFO_UNDERFLOW |
+			   LAYER1_DMA_CB_FIFO_UNDERFLOW |
+			   LAYER1_DMA_CR_FIFO_UNDERFLOW)) {
+			kmb_under_flow++;
+			drm_info(&dev_p->drm,
+			    "!LAYER1:VL1 DMA UNDERFLOW val = 0x%lx, under_flow=%d",
+			     val, kmb_under_flow);
+			/*disable underflow inerrupt */
+			kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+					    LAYER1_DMA_FIFO_UNDERFLOW |
+					    LAYER1_DMA_CB_FIFO_UNDERFLOW |
+					    LAYER1_DMA_CR_FIFO_UNDERFLOW);
+			kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR,
+					    LAYER1_DMA_CB_FIFO_UNDERFLOW |
+					    LAYER1_DMA_FIFO_UNDERFLOW |
+					    LAYER1_DMA_CR_FIFO_UNDERFLOW);
+			/*disable auto restart mode */
+			kmb_clr_bitmask_lcd(dev_p, LCD_LAYERn_DMA_CFG(1),
+				    LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);
+			layer_no = 1;
+		}
+
+		/* LAYER1 - VL1 */
+		if (val & LAYER1_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA OVERFLOW val = 0x%lx", val);
+		if (val & LAYER1_DMA_CB_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA CB OVERFLOW val = 0x%lx", val);
+		if (val & LAYER1_DMA_CR_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA CR OVERFLOW val = 0x%lx", val);
+
+		/* LAYER2 - GL0 */
+		if (val & LAYER2_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER2:GL0 DMA UNDERFLOW val = 0x%lx", val);
+		if (val & LAYER2_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER2:GL0 DMA OVERFLOW val = 0x%lx", val);
+
+		/* LAYER3 - GL1 */
+		if (val & LAYER3_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER3:GL1 DMA UNDERFLOW val = 0x%lx", val);
+		if (val & LAYER3_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER3:GL1 DMA OVERFLOW val = 0x%lx", val);
+	}
+
+	if (status & LCD_INT_LAYER) {
+		/* Clear layer interrupts */
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_LAYER);
+	}
+
+	/* Clear all interrupts */
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR, 1);
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t kmb_isr(int irq, void *arg)
+{
+	struct drm_device *dev = (struct drm_device *)arg;
+	irqreturn_t ret = IRQ_NONE;
+
+	ret = handle_lcd_irq(dev);
+	return ret;
+}
+
+static void kmb_irq_reset(struct drm_device *drm)
+{
+	kmb_write_lcd(to_kmb(drm), LCD_INT_CLEAR, 0xFFFF);
+	kmb_write_lcd(to_kmb(drm), LCD_INT_ENABLE, 0);
+}
+
+DEFINE_DRM_GEM_CMA_FOPS(fops);
+
+static struct drm_driver kmb_driver = {
+	.driver_features = DRIVER_GEM |
+	    DRIVER_MODESET | DRIVER_ATOMIC,
+	.irq_handler = kmb_isr,
+	.irq_preinstall = kmb_irq_reset,
+	.irq_uninstall = kmb_irq_reset,
+	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_vm_ops = &drm_gem_cma_vm_ops,
+	.dumb_create = drm_gem_cma_dumb_create,
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,

drivers/gpu/drm/kmb/kmb_drv.c line 573

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	.gem_prime_vmap = drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap = drm_gem_cma_prime_mmap,
+	.fops = &fops,
+	.name = "kmb-drm",
+	.desc = "KEEMBAY DISPLAY DRIVER ",
+	.date = "20190122",
+	.major = 1,
+	.minor = 0,
+};

kmb_driver needs a diet.
As a minimum introduce DRM_GEM_CMA_VMAP_DRIVER_OPS

gem_free_object_unlocked is deprecated - check drm_drv.h gem_prime_export likewise.
Check them all.

Quoted 62 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +62 -0
+
+static void kmb_drm_unload(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *dev_p = to_kmb(drm);
+
+#ifdef DEBUG
+	dump_stack();
+#endif
+	drm_dev_unregister(drm);
+	drm_kms_helper_poll_fini(drm);
+	of_node_put(dev_p->crtc.port);
+	dev_p->crtc.port = NULL;
+	pm_runtime_get_sync(drm->dev);
+	drm_irq_uninstall(drm);
+	pm_runtime_put_sync(drm->dev);
+	pm_runtime_disable(drm->dev);
+
+	if (dev_p->lcd_mmio) {
+		iounmap(dev_p->lcd_mmio);
+		release_mem_region(LCD_BASE_ADDR, LCD_MMIO_SIZE);
+	}
+
+	if (dev_p->mipi_mmio) {
+		iounmap(dev_p->mipi_mmio);
+		release_mem_region(MIPI_BASE_ADDR, MIPI_MMIO_SIZE);
+	}
+
+	if (dev_p->msscam_mmio) {
+		iounmap(dev_p->msscam_mmio);
+		release_mem_region(MSS_CAM_BASE_ADDR, MSS_CAM_MMIO_SIZE);
+	}
+
+	of_reserved_mem_device_release(drm->dev);
+	drm_mode_config_cleanup(drm);
+
+	/* Release clks */
+	kmb_display_clk_disable();
+	clk_put(clk_lcd);
+	clk_put(clk_mipi);
+
+	dev_set_drvdata(dev, NULL);
+
+	/* Unregister DSI host */
+	kmb_dsi_host_unregister();
+}
+
+static int kmb_probe(struct platform_device *pdev)
+{
+	struct device *dev = get_device(&pdev->dev);
+	struct kmb_drm_private *dev_p;
+	int ret = 0;
+
+	/* The bridge (ADV 7535) will return -EPROBE_DEFER until it
+	 * has a mipi_dsi_host to register its device to. So, we
+	 * first register the DSI host during probe time, and then return
+	 * -EPROBE_DEFER until the bridge is loaded. Probe will be called again
+	 *  and then the rest of the driver initialization can procees
+	 *  afterwards and the bridge can be successfully attached.
+	 */
+	adv_bridge = kmb_dsi_host_bridge_init(dev);
+

drivers/gpu/drm/kmb/kmb_drv.c line 645

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	if (adv_bridge == ERR_PTR(-EPROBE_DEFER))
+		return -EPROBE_DEFER;
+	else if (IS_ERR(adv_bridge)) {
+		DRM_ERROR("probe failed to initialize DSI host bridge\n");
+		return PTR_ERR(adv_bridge);
+	}
+
+	/* Create DRM device */
+	dev_p = devm_drm_dev_alloc(dev, &kmb_driver,
+			struct kmb_drm_private, drm);

Use devm_drm_dev_init()
See example in drm_drv.c for more info.

drivers/gpu/drm/kmb/kmb_drv.c line 649

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +4 -0
+	if (IS_ERR(dev_p))
+		return PTR_ERR(dev_p);
+
+	dev_p->drm.dev_private = dev_p;

dev_private is deprecated - drop it.

Quoted 54 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +54 -0
+	dev_set_drvdata(dev, &dev_p->drm);
+
+	kmb_setup_mode_config(&dev_p->drm);
+	dev_set_drvdata(dev, &dev_p->drm);
+
+	/* Load driver */
+	dev_p->n_layers = KMB_MAX_PLANES;
+	ret = kmb_load(&dev_p->drm, 0);
+	if (ret == -EPROBE_DEFER) {
+		drm_info(&dev_p->drm, "wait for external bridge driver DT\n");
+		return -EPROBE_DEFER;
+	} else if (ret)
+		goto err_free;
+
+	/* Set the CRTC's port so that the encoder component can find it */
+	dev_p->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);
+	ret = drm_vblank_init(&dev_p->drm, dev_p->drm.mode_config.num_crtc);
+	drm_info(&dev_p->drm, "mode_config.num_crtc=%d\n",
+			dev_p->drm.mode_config.num_crtc);
+	if (ret < 0) {
+		drm_err(&dev_p->drm, "failed to initialize vblank\n");
+		goto err_vblank;
+	}
+
+	drm_mode_config_reset(&dev_p->drm);
+	drm_kms_helper_poll_init(&dev_p->drm);
+
+	/* Register graphics device with the kernel */
+	ret = drm_dev_register(&dev_p->drm, 0);
+
+	if (ret)
+		goto err_register;
+
+	return 0;
+
+ err_register:
+	drm_kms_helper_poll_fini(&dev_p->drm);
+ err_vblank:
+	pm_runtime_disable(dev_p->drm.dev);
+ err_free:
+	drm_mode_config_cleanup(&dev_p->drm);
+	dev_set_drvdata(dev, NULL);
+	kmb_dsi_host_unregister();
+
+	return ret;
+}
+
+static int kmb_remove(struct platform_device *pdev)
+{
+	kmb_drm_unload(&pdev->dev);
+	return 0;
+}
+
+static const struct of_device_id kmb_of_match[] = {

drivers/gpu/drm/kmb/kmb_drv.c line 713

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	{.compatible = "intel,kmb_display"},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, kmb_of_match);
+
+static int __maybe_unused kmb_pm_suspend(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *lcd = drm ? drm->dev_private : NULL;

Use of dev_private is deprecated - drop it.

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +9 -0
+
+	if (!lcd)
+		return 0;
+
+	drm_kms_helper_poll_disable(drm);
+
+	lcd->state = drm_atomic_helper_suspend(drm);
+	if (IS_ERR(lcd->state)) {
+		drm_kms_helper_poll_enable(drm);

drivers/gpu/drm/kmb/kmb_drv.c line 732

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		return PTR_ERR(lcd->state);
+	}
+
+	return 0;
+}
+
+static int __maybe_unused kmb_pm_resume(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *lcd = drm ? drm->dev_private : NULL;

Use of dev_private is deprecated - drop it.

Quoted 188 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +27 -0
+
+	if (!lcd)
+		return 0;
+
+	drm_atomic_helper_resume(drm, lcd->state);
+	drm_kms_helper_poll_enable(drm);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(kmb_pm_ops, kmb_pm_suspend, kmb_pm_resume);
+
+static struct platform_driver kmb_platform_driver = {
+	.probe = kmb_probe,
+	.remove = kmb_remove,
+	.driver = {
+		   .name = "kmb-drm",
+		   .pm = &kmb_pm_ops,
+		   .of_match_table = kmb_of_match,
+		   },
+};
+
+module_platform_driver(kmb_platform_driver);
+
+MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION("Keembay Display driver");
+MODULE_LICENSE("GPL v2");
drivers/gpu/drm/kmb/kmb_drv.h new file +155 -0
new file mode 100644
index 0000000..3bc07bc
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright © 2018-2020 Intel Corporation
+ */
+
+#ifndef __KMB_DRV_H__
+#define __KMB_DRV_H__
+
+#include "kmb_regs.h"
+
+#define KMB_MAX_WIDTH			1920 /*max width in pixels */
+#define KMB_MAX_HEIGHT			1080 /*max height in pixels */
+#define KMB_MIN_WIDTH                   1920 /*max width in pixels */
+#define KMB_MIN_HEIGHT                  1080 /*max height in pixels */
+#define KMB_LCD_DEFAULT_CLK		200000000
+#define KMB_MIPI_DEFAULT_CLK		24000000
+#define KMB_MIPI_DEFAULT_CFG_CLK	24000000
+#define KMB_SYS_CLK_MHZ			500
+
+#define crtc_to_kmb_priv(x)	container_of(x, struct kmb_drm_private, crtc)
+
+#define ICAM_MMIO		0x3b100000
+#define ICAM_LCD_OFFSET		0x1080
+#define ICAM_MMIO_SIZE		0x2000
+struct kmb_drm_private {
+	struct drm_device		drm;
+	void __iomem			*lcd_mmio;
+	void __iomem			*mipi_mmio;
+	void __iomem			*msscam_mmio;
+	void __iomem                    *icamlcd_mmio;
+	unsigned char			n_layers;
+	struct clk			*clk;
+	struct drm_crtc			crtc;
+	struct kmb_plane		*plane;
+	struct drm_atomic_state		*state;
+	spinlock_t			irq_lock;
+	int				irq_lcd;
+	int				irq_mipi;
+	int				sys_clk_mhz;
+	dma_addr_t			fb_addr;
+};
+
+static inline struct kmb_drm_private *to_kmb(const struct drm_device *dev)
+{
+	return container_of(dev, struct kmb_drm_private, drm);
+}
+
+struct blt_layer_config {
+	unsigned char layer_format;
+};
+
+static inline void kmb_write_lcd(struct kmb_drm_private *dev_p,
+				 unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->lcd_mmio + reg));
+}
+
+static inline void kmb_write_mipi(struct kmb_drm_private *dev_p,
+				  unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->mipi_mmio + reg));
+}
+
+static inline void kmb_write_msscam(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->msscam_mmio + reg));
+}
+
+static inline u32 kmb_read_msscam(struct kmb_drm_private *dev_p,
+				  unsigned int reg)
+{
+	return readl(dev_p->msscam_mmio + reg);
+}
+
+static inline void kmb_set_bitmask_msscam(struct kmb_drm_private *dev_p,
+					  unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_msscam(dev_p, reg);
+
+	kmb_write_msscam(dev_p, reg, (reg_val | mask));
+}
+
+static inline u32 kmb_read_lcd(struct kmb_drm_private *dev_p, unsigned int reg)
+{
+	return readl(dev_p->lcd_mmio + reg);
+}
+
+static inline void kmb_set_bitmask_lcd(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_lcd(dev_p, reg);
+
+	kmb_write_lcd(dev_p, reg, (reg_val | mask));
+}
+
+static inline void kmb_clr_bitmask_lcd(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_lcd(dev_p, reg);
+
+	kmb_write_lcd(dev_p, reg, (reg_val & (~mask)));
+}
+
+static inline u32 kmb_read_mipi(struct kmb_drm_private *dev_p, unsigned int reg)
+{
+	return readl(dev_p->mipi_mmio + reg);
+}
+
+static inline void kmb_write_bits_mipi(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 offset,
+				       u32 num_bits, u32 value)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+	u32 mask = (1 << num_bits) - 1;
+
+	value &= mask;
+	mask <<= offset;
+	reg_val &= (~mask);
+	reg_val |= (value << offset);
+#ifdef DEBUG
+	if (reg == DPHY_FREQ_CTRL0_3 + 4) {
+		DRM_INFO("%s : %d  reg=0x%x offset=%d num_bits=%d val=0x%x\n",
+			 __func__, __LINE__, reg, offset, num_bits,
+			 reg_val);
+	}
+#endif
+	kmb_write_mipi(dev_p, reg, reg_val);
+}
+
+static inline void kmb_set_bit_mipi(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 offset)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, reg_val | (1 << offset));
+}
+
+static inline void kmb_clr_bit_mipi(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 offset)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, reg_val & (~(1 << offset)));
+}
+
+static inline void kmb_set_bitmask_mipi(struct kmb_drm_private *dev_p,
+					unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, (reg_val | mask));
+}
+
+static inline void kmb_clr_bitmask_mipi(struct kmb_drm_private *dev_p,

drivers/gpu/drm/kmb/kmb_drv.h line 165

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +10 -0
+					unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, (reg_val & (~mask)));
+}
+
+int kmb_setup_crtc(struct drm_device *dev);
+void kmb_set_scanout(struct kmb_drm_private *lcd);
+#endif /* __KMB_DRV_H__ */

All the kmb_dsi looks like it should be implmented as a real bridge driver. And it should use the modern bridge interface - so the connectro creation should be part of the display driver and not the bridge.

See for example adv5511 for an example.

As I expect the parts where I can review will change I skipped this file for now.

Quoted 22 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +16 -0
new file mode 100644
index 0000000..eaddf20
@@ -0,0 +1,1833 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright © 2019-2020 Intel Corporation
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_edid.h>
+#include <drm/drm_mipi_dsi.h>

drivers/gpu/drm/kmb/kmb_dsi.c line 26

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include "kmb_drv.h"
+#include "kmb_dsi.h"
+#include "kmb_regs.h"
+
+static int hw_initialized;
+//#define MIPI_TX_TEST_PATTERN_GENERATION
+//#define DPHY_GET_FSM
+//#define DPHY_READ_TESTCODE

Debug stuff - delete?

drivers/gpu/drm/kmb/kmb_dsi.c line 29

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +3 -0
+
+static struct mipi_dsi_host *dsi_host;
+static struct mipi_dsi_device *dsi_device;

Should be in an advxxxx struct that is allocated in the probe() function of the bridge driver.

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 2,657 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +1804 -0
+
+/* Default setting is 1080p, 4 lanes */
+#define IMG_HEIGHT_LINES  1080
+#define IMG_WIDTH_PX      1920
+#define MIPI_TX_ACTIVE_LANES 4
+
+struct mipi_tx_frame_section_cfg mipi_tx_frame0_sect_cfg = {
+	.width_pixels = IMG_WIDTH_PX,
+	.height_lines = IMG_HEIGHT_LINES,
+	.data_type = DSI_LP_DT_PPS_RGB888_24B,
+	.data_mode = MIPI_DATA_MODE1,
+	.dma_packed = 0
+};
+
+struct mipi_tx_frame_cfg mipitx_frame0_cfg = {
+	.sections[0] = &mipi_tx_frame0_sect_cfg,
+	.sections[1] = NULL,
+	.sections[2] = NULL,
+	.sections[3] = NULL,
+	.vsync_width = 5,
+	.v_backporch = 36,
+	.v_frontporch = 4,
+	.hsync_width = 44,
+	.h_backporch = 148,
+	.h_frontporch = 88
+};
+
+struct mipi_tx_dsi_cfg mipitx_dsi_cfg = {
+	.hfp_blank_en = 0,
+	.eotp_en = 0,
+	.lpm_last_vfp_line = 0,
+	.lpm_first_vsa_line = 0,
+	.sync_pulse_eventn = DSI_VIDEO_MODE_NO_BURST_EVENT,
+	.hfp_blanking = SEND_BLANK_PACKET,
+	.hbp_blanking = SEND_BLANK_PACKET,
+	.hsa_blanking = SEND_BLANK_PACKET,
+	.v_blanking = SEND_BLANK_PACKET,
+};
+
+struct mipi_ctrl_cfg mipi_tx_init_cfg = {
+	.index = MIPI_CTRL6,
+	.type = MIPI_DSI,
+	.dir = MIPI_TX,
+	.active_lanes = MIPI_TX_ACTIVE_LANES,
+	.lane_rate_mbps = MIPI_TX_LANE_DATA_RATE_MBPS,
+	.ref_clk_khz = MIPI_TX_REF_CLK_KHZ,
+	.cfg_clk_khz = MIPI_TX_CFG_CLK_KHZ,
+	.data_if = MIPI_IF_PARALLEL,
+	.tx_ctrl_cfg = {
+			.frames[0] = &mipitx_frame0_cfg,
+			.frames[1] = NULL,
+			.frames[2] = NULL,
+			.frames[3] = NULL,
+			.tx_dsi_cfg = &mipitx_dsi_cfg,
+			.line_sync_pkt_en = 0,
+			.line_counter_active = 0,
+			.frame_counter_active = 0,
+			.tx_always_use_hact = 1,
+			.tx_hact_wait_stop = 1,
+			}
+};
+
+struct  mipi_hs_freq_range_cfg {
+	uint16_t default_bit_rate_mbps;
+	uint8_t hsfreqrange_code;
+};
+
+struct vco_params {
+	u32 freq;
+	u32 range;
+	u32 divider;
+};
+
+static struct vco_params vco_table[] = {
+	{52, 0x3f, 8},
+	{80, 0x39, 8},
+	{105, 0x2f, 4},
+	{160, 0x29, 4},
+	{210, 0x1f, 2},
+	{320, 0x19, 2},
+	{420, 0x0f, 1},
+	{630, 0x09, 1},
+	{1100, 0x03, 1},
+	{0xffff, 0x01, 1},
+};
+
+static struct mipi_hs_freq_range_cfg
+mipi_hs_freq_range[MIPI_DPHY_DEFAULT_BIT_RATES] = {
+	{.default_bit_rate_mbps = 80, .hsfreqrange_code = 0x00},
+	{.default_bit_rate_mbps = 90, .hsfreqrange_code = 0x10},
+	{.default_bit_rate_mbps = 100, .hsfreqrange_code = 0x20},
+	{.default_bit_rate_mbps = 110, .hsfreqrange_code = 0x30},
+	{.default_bit_rate_mbps = 120, .hsfreqrange_code = 0x01},
+	{.default_bit_rate_mbps = 130, .hsfreqrange_code = 0x11},
+	{.default_bit_rate_mbps = 140, .hsfreqrange_code = 0x21},
+	{.default_bit_rate_mbps = 150, .hsfreqrange_code = 0x31},
+	{.default_bit_rate_mbps = 160, .hsfreqrange_code = 0x02},
+	{.default_bit_rate_mbps = 170, .hsfreqrange_code = 0x12},
+	{.default_bit_rate_mbps = 180, .hsfreqrange_code = 0x22},
+	{.default_bit_rate_mbps = 190, .hsfreqrange_code = 0x32},
+	{.default_bit_rate_mbps = 205, .hsfreqrange_code = 0x03},
+	{.default_bit_rate_mbps = 220, .hsfreqrange_code = 0x13},
+	{.default_bit_rate_mbps = 235, .hsfreqrange_code = 0x23},
+	{.default_bit_rate_mbps = 250, .hsfreqrange_code = 0x33},
+	{.default_bit_rate_mbps = 275, .hsfreqrange_code = 0x04},
+	{.default_bit_rate_mbps = 300, .hsfreqrange_code = 0x14},
+	{.default_bit_rate_mbps = 325, .hsfreqrange_code = 0x25},
+	{.default_bit_rate_mbps = 350, .hsfreqrange_code = 0x35},
+	{.default_bit_rate_mbps = 400, .hsfreqrange_code = 0x05},
+	{.default_bit_rate_mbps = 450, .hsfreqrange_code = 0x16},
+	{.default_bit_rate_mbps = 500, .hsfreqrange_code = 0x26},
+	{.default_bit_rate_mbps = 550, .hsfreqrange_code = 0x37},
+	{.default_bit_rate_mbps = 600, .hsfreqrange_code = 0x07},
+	{.default_bit_rate_mbps = 650, .hsfreqrange_code = 0x18},
+	{.default_bit_rate_mbps = 700, .hsfreqrange_code = 0x28},
+	{.default_bit_rate_mbps = 750, .hsfreqrange_code = 0x39},
+	{.default_bit_rate_mbps = 800, .hsfreqrange_code = 0x09},
+	{.default_bit_rate_mbps = 850, .hsfreqrange_code = 0x19},
+	{.default_bit_rate_mbps = 900, .hsfreqrange_code = 0x29},
+	{.default_bit_rate_mbps = 1000, .hsfreqrange_code = 0x0A},
+	{.default_bit_rate_mbps = 1050, .hsfreqrange_code = 0x1A},
+	{.default_bit_rate_mbps = 1100, .hsfreqrange_code = 0x2A},
+	{.default_bit_rate_mbps = 1150, .hsfreqrange_code = 0x3B},
+	{.default_bit_rate_mbps = 1200, .hsfreqrange_code = 0x0B},
+	{.default_bit_rate_mbps = 1250, .hsfreqrange_code = 0x1B},
+	{.default_bit_rate_mbps = 1300, .hsfreqrange_code = 0x2B},
+	{.default_bit_rate_mbps = 1350, .hsfreqrange_code = 0x3C},
+	{.default_bit_rate_mbps = 1400, .hsfreqrange_code = 0x0C},
+	{.default_bit_rate_mbps = 1450, .hsfreqrange_code = 0x1C},
+	{.default_bit_rate_mbps = 1500, .hsfreqrange_code = 0x2C},
+	{.default_bit_rate_mbps = 1550, .hsfreqrange_code = 0x3D},
+	{.default_bit_rate_mbps = 1600, .hsfreqrange_code = 0x0D},
+	{.default_bit_rate_mbps = 1650, .hsfreqrange_code = 0x1D},
+	{.default_bit_rate_mbps = 1700, .hsfreqrange_code = 0x2E},
+	{.default_bit_rate_mbps = 1750, .hsfreqrange_code = 0x3E},
+	{.default_bit_rate_mbps = 1800, .hsfreqrange_code = 0x0E},
+	{.default_bit_rate_mbps = 1850, .hsfreqrange_code = 0x1E},
+	{.default_bit_rate_mbps = 1900, .hsfreqrange_code = 0x2F},
+	{.default_bit_rate_mbps = 1950, .hsfreqrange_code = 0x3F},
+	{.default_bit_rate_mbps = 2000, .hsfreqrange_code = 0x0F},
+	{.default_bit_rate_mbps = 2050, .hsfreqrange_code = 0x40},
+	{.default_bit_rate_mbps = 2100, .hsfreqrange_code = 0x41},
+	{.default_bit_rate_mbps = 2150, .hsfreqrange_code = 0x42},
+	{.default_bit_rate_mbps = 2200, .hsfreqrange_code = 0x43},
+	{.default_bit_rate_mbps = 2250, .hsfreqrange_code = 0x44},
+	{.default_bit_rate_mbps = 2300, .hsfreqrange_code = 0x45},
+	{.default_bit_rate_mbps = 2350, .hsfreqrange_code = 0x46},
+	{.default_bit_rate_mbps = 2400, .hsfreqrange_code = 0x47},
+	{.default_bit_rate_mbps = 2450, .hsfreqrange_code = 0x48},
+	{.default_bit_rate_mbps = 2500, .hsfreqrange_code = 0x49}
+};
+
+union mipi_irq_cfg int_cfg = {
+	.irq_cfg.frame_done = 1,
+	.irq_cfg.ctrl_error = 1,
+};
+
+static enum drm_mode_status
+kmb_dsi_mode_valid(struct drm_connector *connector,
+		   struct drm_display_mode *mode)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_mode_config *mode_config = &dev->mode_config;
+
+	if (mode->hdisplay < mode_config->min_width ||
+			mode->hdisplay > mode_config->max_width)
+		return MODE_BAD_HVALUE;
+
+	if (mode->vdisplay < mode_config->min_height ||
+			mode->vdisplay > mode_config->max_height)
+		return MODE_BAD_VVALUE;
+
+	return MODE_OK;
+}
+
+static int kmb_dsi_get_modes(struct drm_connector *connector)
+{
+	int num_modes = 0;
+
+	num_modes = drm_add_modes_noedid(connector,
+			 connector->dev->mode_config.max_width,
+			 connector->dev->mode_config.max_height);
+
+	DRM_INFO("width=%d height=%d\n",
+		 connector->dev->mode_config.max_width,
+		 connector->dev->mode_config.max_height);
+	DRM_INFO("num modes=%d\n", num_modes);
+
+	return num_modes;
+}
+
+void kmb_dsi_host_unregister(void)
+{
+	mipi_dsi_host_unregister(dsi_host);
+	kfree(dsi_host);
+}
+
+static void kmb_dsi_connector_destroy(struct drm_connector *connector)
+{
+	struct kmb_connector *kmb_connector = to_kmb_connector(connector);
+
+	drm_connector_cleanup(connector);
+	kfree(kmb_connector);
+}
+
+static void kmb_dsi_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct kmb_dsi *kmb_dsi = to_kmb_dsi(encoder);
+
+	if (!kmb_dsi)
+		return;
+
+	kfree(kmb_dsi->dsi_host);
+
+	drm_encoder_cleanup(encoder);
+
+	kmb_dsi_connector_destroy(&kmb_dsi->attached_connector->base);
+
+	kfree(kmb_dsi);
+	if (!dsi_device)
+		kfree(dsi_device);
+}
+
+static const struct drm_encoder_funcs kmb_dsi_funcs = {
+	.destroy = kmb_dsi_encoder_destroy,
+};
+
+static const struct
+drm_connector_helper_funcs kmb_dsi_connector_helper_funcs = {
+	.get_modes = kmb_dsi_get_modes,
+	.mode_valid = kmb_dsi_mode_valid,
+};
+
+static const struct drm_connector_funcs kmb_dsi_connector_funcs = {
+	.destroy = kmb_dsi_connector_destroy,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.reset = drm_atomic_helper_connector_reset,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+};
+
+static ssize_t kmb_dsi_host_transfer(struct mipi_dsi_host *host,
+				     const struct mipi_dsi_msg *msg)
+{
+	return 0;
+}
+
+static int kmb_dsi_host_attach(struct mipi_dsi_host *host,
+			       struct mipi_dsi_device *dev)
+{
+	return 0;
+}
+
+static int kmb_dsi_host_detach(struct mipi_dsi_host *host,
+			       struct mipi_dsi_device *dev)
+{
+	return 0;
+}
+
+static const struct mipi_dsi_host_ops kmb_dsi_host_ops = {
+	.attach = kmb_dsi_host_attach,
+	.detach = kmb_dsi_host_detach,
+	.transfer = kmb_dsi_host_transfer,
+};
+
+static struct kmb_dsi_host *kmb_dsi_host_init(struct drm_device *drm,
+					      struct kmb_dsi *kmb_dsi)
+{
+	struct kmb_dsi_host *host;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->base = dsi_host;
+	host->base->ops = &kmb_dsi_host_ops;
+	host->kmb_dsi = kmb_dsi;
+
+	host->base->dev = drm->dev;
+
+	dsi_device->host = host->base;
+	host->device = dsi_device;
+	return host;
+}
+
+struct drm_bridge *kmb_dsi_host_bridge_init(struct device *dev)
+{
+	struct drm_bridge *bridge = NULL;
+	struct device_node *encoder_node;
+
+	/* Create and register MIPI DSI host */
+	if (!dsi_host) {
+		dsi_host = kzalloc(sizeof(*dsi_host), GFP_KERNEL);
+		if (!dsi_host)
+			return ERR_PTR(-ENOMEM);
+
+		dsi_host->ops = &kmb_dsi_host_ops;
+
+		if (!dsi_device) {
+			dsi_device = kzalloc(sizeof(*dsi_device), GFP_KERNEL);
+			if (!dsi_device) {
+				kfree(dsi_host);
+				return ERR_PTR(-ENOMEM);
+			}
+		}
+
+		dsi_host->dev = dev;
+		mipi_dsi_host_register(dsi_host);
+	}
+	/* Find ADV7535 node and initialize it */
+	encoder_node = of_parse_phandle(dev->of_node, "encoder-slave", 0);
+
+	if (!encoder_node) {
+		DRM_ERROR("Failed to get bridge info from DT\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* Locate drm bridge from the hdmi encoder DT node */
+	bridge = of_drm_find_bridge(encoder_node);
+	of_node_put(encoder_node);
+	if (!bridge) {
+		DRM_INFO("Wait for external bridge driver DT\n");
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+	return bridge;
+}
+
+u32 mipi_get_datatype_params(u32 data_type, u32 data_mode,
+			     struct mipi_data_type_params *params)
+{
+	struct mipi_data_type_params data_type_param;
+
+	switch (data_type) {
+	case DSI_LP_DT_PPS_YCBCR420_12B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 3;
+		switch (data_mode) {
+			/* Case 0 not supported according to MDK */
+		case 1:
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 24;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_YCBCR422_16B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 4;
+		switch (data_mode) {
+			/* Case 0 and 1 not supported according
+			 * to MDK
+			 */
+		case 2:
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 16;
+			break;
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 32;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_LPPS_YCBCR422_20B:
+	case DSI_LP_DT_PPS_YCBCR422_24B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 6;
+		switch (data_mode) {
+			/* Case 0 not supported according to MDK */
+		case 1:
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 24;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_RGB565_16B:
+		data_type_param.size_constraint_pixels = 1;
+		data_type_param.size_constraint_bytes = 2;
+		switch (data_mode) {
+		case 0:
+		case 1:
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 16;
+			break;
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 32;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_RGB666_18B:
+		data_type_param.size_constraint_pixels = 4;
+		data_type_param.size_constraint_bytes = 9;
+		data_type_param.bits_per_pclk = 18;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	case DSI_LP_DT_LPPS_RGB666_18B:
+	case DSI_LP_DT_PPS_RGB888_24B:
+		data_type_param.size_constraint_pixels = 1;
+		data_type_param.size_constraint_bytes = 3;
+		data_type_param.bits_per_pclk = 24;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	case DSI_LP_DT_PPS_RGB101010_30B:
+		data_type_param.size_constraint_pixels = 4;
+		data_type_param.size_constraint_bytes = 15;
+		data_type_param.bits_per_pclk = 30;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	default:
+		DRM_ERROR("DSI: Invalid data_type %d\n", data_type);
+		return -EINVAL;
+	};
+
+	*params = data_type_param;
+	return 0;
+}
+
+static u32 compute_wc(u32 width_px, u8 size_constr_p, u8 size_constr_b)
+{
+	/* Calculate the word count for each long packet */
+	return (((width_px / size_constr_p) * size_constr_b) & 0xffff);
+}
+
+static u32 compute_unpacked_bytes(u32 wc, u8 bits_per_pclk)
+{
+	/* Number of PCLK cycles needed to transfer a line
+	 * with each PCLK cycle, 4 Bytes are sent through the PPL module
+	 */
+	return ((wc * 8) / bits_per_pclk) * 4;
+}
+
+static u32 mipi_tx_fg_section_cfg_regs(struct kmb_drm_private *dev_p,
+				       u8 frame_id, u8 section,
+				       u32 height_lines, u32 unpacked_bytes,
+				       struct mipi_tx_frame_sect_phcfg *ph_cfg)
+{
+	u32 cfg = 0;
+	u32 ctrl_no = MIPI_CTRL6;
+	u32 reg_adr;
+
+	/* Frame section packet header */
+	/* Word count bits [15:0] */
+	cfg = (ph_cfg->wc & MIPI_TX_SECT_WC_MASK) << 0;
+
+	/* Data type (bits [21:16]) */
+	cfg |= ((ph_cfg->data_type & MIPI_TX_SECT_DT_MASK)
+		<< MIPI_TX_SECT_DT_SHIFT);
+
+	/* Virtual channel (bits [23:22]) */
+	cfg |= ((ph_cfg->vchannel & MIPI_TX_SECT_VC_MASK)
+		<< MIPI_TX_SECT_VC_SHIFT);
+
+	/* Data mode (bits [24:25]) */
+	cfg |= ((ph_cfg->data_mode & MIPI_TX_SECT_DM_MASK)
+		<< MIPI_TX_SECT_DM_SHIFT);
+	if (ph_cfg->dma_packed)
+		cfg |= MIPI_TX_SECT_DMA_PACKED;
+
+	drm_dbg(&dev_p->drm,
+		 "ctrl=%d frame_id=%d section=%d cfg=%x packed=%d\n",
+		  ctrl_no, frame_id, section, cfg, ph_cfg->dma_packed);
+	kmb_write_mipi(dev_p,
+		       (MIPI_TXm_HS_FGn_SECTo_PH(ctrl_no, frame_id, section)),
+		       cfg);
+
+	/* Unpacked bytes */
+
+	/* There are 4 frame generators and each fg has 4 sections
+	 * There are 2 registers for unpacked bytes (# bytes each
+	 * section occupies in memory)
+	 * REG_UNPACKED_BYTES0: [15:0]-BYTES0, [31:16]-BYTES1
+	 * REG_UNPACKED_BYTES1: [15:0]-BYTES2, [31:16]-BYTES3
+	 */
+	reg_adr =
+	    MIPI_TXm_HS_FGn_SECT_UNPACKED_BYTES0(ctrl_no,
+						 frame_id) + (section / 2) * 4;
+	kmb_write_bits_mipi(dev_p, reg_adr, (section % 2) * 16, 16,
+			    unpacked_bytes);
+	drm_dbg(&dev_p->drm,
+		 "unpacked_bytes = %d, wordcount = %d\n", unpacked_bytes,
+		  ph_cfg->wc);
+
+	/* Line config */
+	reg_adr = MIPI_TXm_HS_FGn_SECTo_LINE_CFG(ctrl_no, frame_id, section);
+	kmb_write_mipi(dev_p, reg_adr, height_lines);
+	return 0;
+}
+
+static u32 mipi_tx_fg_section_cfg(struct kmb_drm_private *dev_p,
+				  u8 frame_id, u8 section,
+				  struct mipi_tx_frame_section_cfg *frame_scfg,
+				  u32 *bits_per_pclk, u32 *wc)
+{
+	u32 ret = 0;
+	u32 unpacked_bytes;
+	struct mipi_data_type_params data_type_parameters;
+	struct mipi_tx_frame_sect_phcfg ph_cfg;
+
+	ret = mipi_get_datatype_params(frame_scfg->data_type,
+				       frame_scfg->data_mode,
+				       &data_type_parameters);
+	if (ret)
+		return ret;
+
+	/* Packet width has to be a multiple of the minimum packet width
+	 * (in pixels) set for each data type
+	 */
+	if (frame_scfg->width_pixels %
+	    data_type_parameters.size_constraint_pixels != 0)
+		return -EINVAL;
+
+	*wc = compute_wc(frame_scfg->width_pixels,
+			 data_type_parameters.size_constraint_pixels,
+			 data_type_parameters.size_constraint_bytes);
+	unpacked_bytes = compute_unpacked_bytes(*wc,
+					data_type_parameters.bits_per_pclk);
+	ph_cfg.wc = *wc;
+	ph_cfg.data_mode = frame_scfg->data_mode;
+	ph_cfg.data_type = frame_scfg->data_type;
+	ph_cfg.dma_packed = frame_scfg->dma_packed;
+	ph_cfg.vchannel = frame_id;
+
+	mipi_tx_fg_section_cfg_regs(dev_p, frame_id, section,
+				    frame_scfg->height_lines,
+				    unpacked_bytes, &ph_cfg);
+
+	/* Caller needs bits_per_clk for additional caluclations */
+	*bits_per_pclk = data_type_parameters.bits_per_pclk;
+
+	return 0;
+}
+
+static void mipi_tx_fg_cfg_regs(struct kmb_drm_private *dev_p, u8 frame_gen,
+				struct mipi_tx_frame_timing_cfg *fg_cfg)
+{
+	u32 sysclk;
+	u32 ppl_llp_ratio;
+	u32 ctrl_no = MIPI_CTRL6, reg_adr, val, offset;
+
+	/* 500 Mhz system clock minus 50 to account for the difference in
+	 * MIPI clock speed in RTL tests
+	 */
+	sysclk = dev_p->sys_clk_mhz - 50;
+
+	/* PPL-Pixel Packing Layer, LLP-Low Level Protocol
+	 * Frame genartor timing parameters are clocked on the system clock,
+	 * whereas as the equivalent parameters in the LLP blocks are clocked
+	 * on LLP Tx clock from the D-PHY - BYTE clock
+	 */
+
+	/* Multiply by 1000 to maintain precision */
+	ppl_llp_ratio = ((fg_cfg->bpp / 8) * sysclk * 1000) /
+	    ((fg_cfg->lane_rate_mbps / 8) * fg_cfg->active_lanes);
+
+	drm_dbg(&dev_p->drm, "ppl_llp_ratio=%d\n", ppl_llp_ratio);
+	drm_dbg(&dev_p->drm, "bpp=%d sysclk=%d lane-rate=%d activ-lanes=%d\n",
+		 fg_cfg->bpp, sysclk, fg_cfg->lane_rate_mbps,
+		 fg_cfg->active_lanes);
+
+	/* Frame generator number of lines */
+	reg_adr = MIPI_TXm_HS_FGn_NUM_LINES(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->v_active);
+
+	/* vsync width
+	 * There are 2 registers for vsync width (VSA in lines for
+	 * channels 0-3)
+	 * REG_VSYNC_WIDTH0: [15:0]-VSA for channel0, [31:16]-VSA for channel1
+	 * REG_VSYNC_WIDTH1: [15:0]-VSA for channel2, [31:16]-VSA for channel3
+	 */
+	offset = (frame_gen % 2) * 16;
+	reg_adr = MIPI_TXm_HS_VSYNC_WIDTHn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->vsync_width);
+
+	/* vertical backporch (vbp) */
+	reg_adr = MIPI_TXm_HS_V_BACKPORCHESn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_backporch);
+
+	/* vertical frontporch (vfp) */
+	reg_adr = MIPI_TXm_HS_V_FRONTPORCHESn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_frontporch);
+
+	/* vertical active (vactive) */
+	reg_adr = MIPI_TXm_HS_V_ACTIVEn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_active);
+
+	/* hsync width */
+	reg_adr = MIPI_TXm_HS_HSYNC_WIDTHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->hsync_width * ppl_llp_ratio) / 1000);
+
+	/* horizontal backporch (hbp) */
+	reg_adr = MIPI_TXm_HS_H_BACKPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->h_backporch * ppl_llp_ratio) / 1000);
+
+	/* horizontal frontporch (hfp) */
+	reg_adr = MIPI_TXm_HS_H_FRONTPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->h_frontporch * ppl_llp_ratio) / 1000);
+
+	/* horizontal active (ha) */
+	reg_adr = MIPI_TXm_HS_H_ACTIVEn(ctrl_no, frame_gen);
+
+	/* convert h_active which is wc in bytes to cycles */
+	val = (fg_cfg->h_active * sysclk * 1000) /
+	    ((fg_cfg->lane_rate_mbps / 8) * fg_cfg->active_lanes);
+	val /= 1000;
+	kmb_write_mipi(dev_p, reg_adr, val);
+
+	/* llp hsync width */
+	reg_adr = MIPI_TXm_HS_LLP_HSYNC_WIDTHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->hsync_width * (fg_cfg->bpp / 8));
+
+	/* llp h backporch */
+	reg_adr = MIPI_TXm_HS_LLP_H_BACKPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->h_backporch * (fg_cfg->bpp / 8));
+
+	/* llp h frontporch */
+	reg_adr = MIPI_TXm_HS_LLP_H_FRONTPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       fg_cfg->h_frontporch * (fg_cfg->bpp / 8));
+}
+
+static void mipi_tx_fg_cfg(struct kmb_drm_private *dev_p, u8 frame_gen,
+			   u8 active_lanes, u32 bpp, u32 wc,
+			   u32 lane_rate_mbps, struct mipi_tx_frame_cfg *fg_cfg)
+{
+	u32 i, fg_num_lines = 0;
+	struct mipi_tx_frame_timing_cfg fg_t_cfg;
+
+	/* Calculate the total frame generator number of
+	 * lines based on it's active sections
+	 */
+	for (i = 0; i < MIPI_TX_FRAME_GEN_SECTIONS; i++) {
+		if (fg_cfg->sections[i] != NULL)
+			fg_num_lines += fg_cfg->sections[i]->height_lines;
+	}
+
+	fg_t_cfg.bpp = bpp;
+	fg_t_cfg.lane_rate_mbps = lane_rate_mbps;
+	fg_t_cfg.hsync_width = fg_cfg->hsync_width;
+	fg_t_cfg.h_backporch = fg_cfg->h_backporch;
+	fg_t_cfg.h_frontporch = fg_cfg->h_frontporch;
+	fg_t_cfg.h_active = wc;
+	fg_t_cfg.vsync_width = fg_cfg->vsync_width;
+	fg_t_cfg.v_backporch = fg_cfg->v_backporch;
+	fg_t_cfg.v_frontporch = fg_cfg->v_frontporch;
+	fg_t_cfg.v_active = fg_num_lines;
+	fg_t_cfg.active_lanes = active_lanes;
+
+	/* Apply frame generator timing setting */
+	mipi_tx_fg_cfg_regs(dev_p, frame_gen, &fg_t_cfg);
+}
+
+static void mipi_tx_multichannel_fifo_cfg(struct kmb_drm_private *dev_p,
+					  u8 active_lanes, u8 vchannel_id)
+{
+	u32 fifo_size, fifo_rthreshold;
+	u32 ctrl_no = MIPI_CTRL6;
+
+	/* Clear all mc fifo channel sizes and thresholds */
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CTRL_EN, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CHAN_ALLOC0, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CHAN_ALLOC1, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_RTHRESHOLD0, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_RTHRESHOLD1, 0);
+
+	fifo_size = ((active_lanes > MIPI_D_LANES_PER_DPHY) ?
+		     MIPI_CTRL_4LANE_MAX_MC_FIFO_LOC :
+		     MIPI_CTRL_2LANE_MAX_MC_FIFO_LOC) - 1;
+
+	/* MC fifo size for virtual channels 0-3
+	 * REG_MC_FIFO_CHAN_ALLOC0: [8:0]-channel0, [24:16]-channel1
+	 * REG_MC_FIFO_CHAN_ALLOC1: [8:0]-2, [24:16]-channel3
+	 */
+	SET_MC_FIFO_CHAN_ALLOC(dev_p, ctrl_no, vchannel_id, fifo_size);
+
+	/* Set threshold to half the fifo size, actual size=size*16 */
+	fifo_rthreshold = ((fifo_size) * 8) & BIT_MASK_16;
+	SET_MC_FIFO_RTHRESHOLD(dev_p, ctrl_no, vchannel_id, fifo_rthreshold);
+
+	/* Enable the MC FIFO channel corresponding to the Virtual Channel */
+	kmb_set_bit_mipi(dev_p, MIPI_TXm_HS_MC_FIFO_CTRL_EN(ctrl_no),
+			 vchannel_id);
+}
+
+static void mipi_tx_ctrl_cfg(struct kmb_drm_private *dev_p, u8 fg_id,
+			     struct mipi_ctrl_cfg *ctrl_cfg)
+{
+	u32 sync_cfg = 0, ctrl = 0, fg_en;
+	u32 ctrl_no = MIPI_CTRL6;
+
+	/* MIPI_TX_HS_SYNC_CFG */
+	if (ctrl_cfg->tx_ctrl_cfg.line_sync_pkt_en)
+		sync_cfg |= LINE_SYNC_PKT_ENABLE;
+	if (ctrl_cfg->tx_ctrl_cfg.frame_counter_active)
+		sync_cfg |= FRAME_COUNTER_ACTIVE;
+	if (ctrl_cfg->tx_ctrl_cfg.line_counter_active)
+		sync_cfg |= LINE_COUNTER_ACTIVE;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->v_blanking)
+		sync_cfg |= DSI_V_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hsa_blanking)
+		sync_cfg |= DSI_HSA_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hbp_blanking)
+		sync_cfg |= DSI_HBP_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hfp_blanking)
+		sync_cfg |= DSI_HFP_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->sync_pulse_eventn)
+		sync_cfg |= DSI_SYNC_PULSE_EVENTN;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->lpm_first_vsa_line)
+		sync_cfg |= DSI_LPM_FIRST_VSA_LINE;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->lpm_last_vfp_line)
+		sync_cfg |= DSI_LPM_LAST_VFP_LINE;
+
+	/* Enable frame generator */
+	fg_en = 1 << fg_id;
+	sync_cfg |= FRAME_GEN_EN(fg_en);
+
+	if (ctrl_cfg->tx_ctrl_cfg.tx_always_use_hact)
+		sync_cfg |= ALWAYS_USE_HACT(fg_en);
+	if (ctrl_cfg->tx_ctrl_cfg.tx_hact_wait_stop)
+		sync_cfg |= HACT_WAIT_STOP(fg_en);
+
+	drm_dbg(&dev_p->drm, "sync_cfg=%d fg_en=%d\n", sync_cfg, fg_en);
+
+	/* MIPI_TX_HS_CTRL */
+
+	/* type:DSI, source:LCD */
+	ctrl = HS_CTRL_EN | TX_SOURCE;
+	ctrl |= LCD_VC(fg_id);
+	ctrl |= ACTIVE_LANES(ctrl_cfg->active_lanes - 1);
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->eotp_en)
+		ctrl |= DSI_EOTP_EN;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hfp_blank_en)
+		ctrl |= DSI_CMD_HFP_EN;
+
+	/*67 ns stop time */
+	ctrl |= HSEXIT_CNT(0x43);
+
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_SYNC_CFG(ctrl_no), sync_cfg);
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_CTRL(ctrl_no), ctrl);
+}
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+static void mipi_tx_hs_tp_gen(struct kmb_drm_private *dev_p, int vc,
+			      int tp_sel, u32 stripe_width, u32 color0,
+			      u32 color1, u32 ctrl_no)
+{
+	int val = 0;
+
+	/* Select test pattern mode on the virtual channel */
+	val = TP_SEL_VCm(vc, tp_sel);
+
+	/* Configure test pattern colors */
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR0(ctrl_no), color0);
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR1(ctrl_no), color1);
+
+	/* Enable test pattern generation on the virtual channel */
+	val |= TP_EN_VCm(vc);
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_CTRL(ctrl_no), val);
+
+}
+#endif
+
+static u32 mipi_tx_init_cntrl(struct kmb_drm_private *dev_p,
+			      struct mipi_ctrl_cfg *ctrl_cfg)
+{
+	u32 ret = 0;
+	u8 active_vchannels = 0;
+	u8 frame_id, sect;
+	u32 bits_per_pclk = 0;
+	u32 word_count = 0;
+	struct mipi_tx_frame_cfg *frame;
+
+	/* This is the order to initialize MIPI TX:
+	 * 1. set frame section parameters
+	 * 2. set frame specific parameters
+	 * 3. connect lcd to mipi
+	 * 4. multi channel fifo cfg
+	 * 5. set mipitxcctrlcfg
+	 */
+
+	for (frame_id = 0; frame_id < 4; frame_id++) {
+		frame = ctrl_cfg->tx_ctrl_cfg.frames[frame_id];
+
+		/* Find valid frame, assume only one valid frame */
+		if (frame == NULL)
+			continue;
+
+		/* Frame Section configuration */
+		/* TODO - assume there is only one valid section in a frame,
+		 * so bits_per_pclk and word_count are only set once
+		 */
+		for (sect = 0; sect < MIPI_CTRL_VIRTUAL_CHANNELS; sect++) {
+			if (frame->sections[sect] == NULL)
+				continue;
+
+			ret = mipi_tx_fg_section_cfg(dev_p, frame_id, sect,
+						     frame->sections[sect],
+						     &bits_per_pclk,
+						     &word_count);
+			if (ret)
+				return ret;
+
+		}
+
+		/* Set frame specific parameters */
+		mipi_tx_fg_cfg(dev_p, frame_id, ctrl_cfg->active_lanes,
+			       bits_per_pclk, word_count,
+			       ctrl_cfg->lane_rate_mbps, frame);
+
+		active_vchannels++;
+
+		/* Stop iterating as only one virtual channel
+		 * shall be used for LCD connection
+		 */
+		break;
+	}
+
+	if (active_vchannels == 0)
+		return -EINVAL;
+	/* Multi-Channel FIFO Configuration */
+	mipi_tx_multichannel_fifo_cfg(dev_p, ctrl_cfg->active_lanes, frame_id);
+
+	/* Frame Generator Enable */
+	mipi_tx_ctrl_cfg(dev_p, frame_id, ctrl_cfg);
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+	mipi_tx_hs_tp_gen(dev_p, 0, MIPI_TX_HS_TP_V_STRIPES,
+			  0x8, 0xff, 0xff00, MIPI_CTRL6);
+#endif
+
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		  GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+
+	return ret;
+}
+
+#ifdef DPHY_READ_TESTCODE
+int dphy_read_testcode(struct kmb_drm_private *dev_p, int dphy_sel,
+		       int test_code)
+{
+	u32 reg_wr_data;
+	u32 reg_rd_data;
+	int data;
+
+	reg_wr_data = dphy_sel;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = 0;
+	reg_wr_data = 0;
+	reg_rd_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = (dphy_sel | dphy_sel << 12);
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel << 12;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = test_code >> 8 & 0xf;
+	reg_wr_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = test_code & 0xff;
+	reg_wr_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = (dphy_sel | dphy_sel << 12);
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel << 12;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT0_3);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT4_7);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT8_9);
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		data = reg_rd_data >> 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		data = reg_rd_data >> 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		data = reg_rd_data >> 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		data = reg_rd_data >> 24;
+
+	return data;
+}
+#endif
+
+static void test_mode_send(struct kmb_drm_private *dev_p, u32 dphy_no,
+			   u32 test_code, u32 test_data)
+{
+	if (test_code != TEST_CODE_FSM_CONTROL)
+		drm_dbg(&dev_p->drm,
+			"test_code = %02x, test_data = %08x\n", test_code,
+			 test_data);
+	/* Steps to send test code:
+	 * - set testclk HIGH
+	 * - set testdin with test code
+	 * - set testen HIGH
+	 * - set testclk LOW
+	 * - set testen LOW
+	 */
+
+	/* Set testclk high */
+	SET_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+	/* Set testdin */
+	SET_TEST_DIN0_3(dev_p, dphy_no, test_code);
+
+	/* Set testen high */
+	SET_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+	/* Set testclk low */
+	CLR_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+	/* Set testen low */
+	CLR_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+	if (test_code) {
+		/*  Steps to send test data:
+		 * - set testen LOW
+		 * - set testclk LOW
+		 * - set testdin with data
+		 * - set testclk HIGH
+		 */
+
+		/* Set testen low */
+		CLR_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+		/* Set testclk low */
+		CLR_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+		/* Set data in testdin */
+		kmb_write_mipi(dev_p,
+			       DPHY_TEST_DIN0_3 + ((dphy_no / 0x4) * 0x4),
+			       test_data << ((dphy_no % 4) * 8));
+
+		/* Set testclk high */
+		SET_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+	}
+}
+
+static inline void set_test_mode_src_osc_freq_target_low_bits(struct
+							      kmb_drm_private
+							      *dev_p,
+							      u32 dphy_no,
+							      u32 freq)
+{
+	/* Typical rise/fall time=166, refer Table 1207 databook,
+	 * sr_osc_freq_target[7:0]
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_SLEW_RATE_DDL_CYCLES,
+		       (freq & 0x7f));
+}
+
+static inline void set_test_mode_src_osc_freq_target_hi_bits(struct
+							     kmb_drm_private
+							     *dev_p,
+							     u32 dphy_no,
+							     u32 freq)
+{
+	u32 data;
+
+	/* Flag this as high nibble */
+	data = ((freq >> 6) & 0x1f) | (1 << 7);
+
+	/* Typical rise/fall time=166, refer Table 1207 databook,
+	 * sr_osc_freq_target[11:7]
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_SLEW_RATE_DDL_CYCLES, data);
+}
+
+static void mipi_tx_get_vco_params(struct vco_params *vco)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(vco_table); i++) {
+		if (vco->freq < vco_table[i].freq) {
+			*vco = vco_table[i];
+			return;
+		}
+	}
+
+	WARN_ONCE(1, "Invalid vco freq = %u for PLL setup\n", vco->freq);
+}
+
+static void mipi_tx_pll_setup(struct kmb_drm_private *dev_p, u32 dphy_no,
+			      u32 ref_clk_mhz, u32 target_freq_mhz)
+{
+	u32 best_n = 0, best_m = 0;
+	u32 n = 0, m = 0, div = 0, delta, freq = 0, t_freq;
+	u32 best_freq_delta = 3000;
+
+	/* pll_ref_clk: - valid range: 2~64 MHz; Typically 24 MHz
+	 * Fvco: - valid range: 320~1250 MHz (Gen3 D-PHY)
+	 * Fout: - valid range: 40~1250 MHz (Gen3 D-PHY)
+	 * n: - valid range [0 15]
+	 * N: - N = n + 1
+	 *      -valid range: [1 16]
+	 *      -conditions: - (pll_ref_clk / N) >= 2 MHz
+	 *              -(pll_ref_clk / N) <= 8 MHz
+	 * m: valid range [62 623]
+	 * M: - M = m + 2
+	 *      -valid range [64 625]
+	 *      -Fvco = (M/N) * pll_ref_clk
+	 */
+	struct vco_params vco_p = {
+		.range = 0,
+		.divider = 1,
+	};
+
+	vco_p.freq = target_freq_mhz;
+	mipi_tx_get_vco_params(&vco_p);
+
+	/* Search pll n parameter */
+	for (n = PLL_N_MIN; n <= PLL_N_MAX; n++) {
+		/* Calculate the pll input frequency division ratio
+		 * multiply by 1000 for precision -
+		 * no floating point, add n for rounding
+		 */
+		div = ((ref_clk_mhz * 1000) + n) / (n + 1);
+
+		/* Found a valid n parameter */
+		if ((div < 2000 || div > 8000))
+			continue;
+
+		/* Search pll m parameter */
+		for (m = PLL_M_MIN; m <= PLL_M_MAX; m++) {
+			/* Calculate the Fvco(DPHY PLL output frequency)
+			 * using the current n,m params
+			 */
+			freq = div * (m + 2);
+			freq /= 1000;
+
+			/* Trim the potential pll freq to max supported */
+			if (freq > PLL_FVCO_MAX)
+				continue;
+
+			delta = abs(freq - target_freq_mhz);
+
+			/* Select the best (closest to target pll freq)
+			 * n,m parameters so far
+			 */
+			if (delta < best_freq_delta) {
+				best_n = n;
+				best_m = m;
+				best_freq_delta = delta;
+			}
+		}
+	}
+
+	/* Program vco_cntrl parameter
+	 * PLL_VCO_Control[5:0] = pll_vco_cntrl_ovr,
+	 * PLL_VCO_Control[6]   = pll_vco_cntrl_ovr_en
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_VCO_CTRL, (vco_p.range
+								| (1 << 6)));
+
+	/* Program m, n pll parameters */
+	drm_dbg(&dev_p->drm, "m = %d n = %d\n", best_m, best_n);
+
+	/* PLL_Input_Divider_Ratio[3:0] = pll_n_ovr */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_INPUT_DIVIDER,
+		       (best_n & 0x0f));
+
+	/* m - low nibble PLL_Loop_Divider_Ratio[4:0]
+	 * pll_m_ovr[4:0]
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_FEEDBACK_DIVIDER,
+		       (best_m & 0x1f));
+
+	/* m - high nibble PLL_Loop_Divider_Ratio[4:0]
+	 * pll_m_ovr[9:5]
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_FEEDBACK_DIVIDER,
+		       ((best_m >> 5) & 0x1f) | PLL_FEEDBACK_DIVIDER_HIGH);
+
+	/* Enable overwrite of n,m parameters :pll_n_ovr_en, pll_m_ovr_en */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_OUTPUT_CLK_SEL,
+		       (PLL_N_OVR_EN | PLL_M_OVR_EN));
+
+	/* Program Charge-Pump parameters */
+
+	/* pll_prop_cntrl-fixed values for prop_cntrl from DPHY doc */
+	t_freq = target_freq_mhz * vco_p.divider;
+	test_mode_send(dev_p, dphy_no,
+		       TEST_CODE_PLL_PROPORTIONAL_CHARGE_PUMP_CTRL,
+		       ((t_freq > 1150) ? 0x0C : 0x0B));
+
+	/* pll_int_cntrl-fixed value for int_cntrl from DPHY doc */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_INTEGRAL_CHARGE_PUMP_CTRL,
+		       0x00);
+
+	/* pll_gmp_cntrl-fixed value for gmp_cntrl from DPHY doci */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_GMP_CTRL, 0x10);
+
+	/* pll_cpbias_cntrl-fixed value for cpbias_cntrl from DPHY doc */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_CHARGE_PUMP_BIAS, 0x10);
+
+	/* pll_th1 -Lock Detector Phase error threshold,
+	 * document gives fixed value
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_PHASE_ERR_CTRL, 0x02);
+
+	/* PLL Lock Configuration */
+
+	/* pll_th2 - Lock Filter length, document gives fixed value */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_LOCK_FILTER, 0x60);
+
+	/* pll_th3- PLL Unlocking filter, document gives fixed value */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_UNLOCK_FILTER, 0x03);
+
+	/* pll_lock_sel-PLL Lock Detector Selection,
+	 * document gives fixed value
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_LOCK_DETECTOR, 0x02);
+}
+
+#ifdef DPHY_GET_FSM
+static void dphy_get_fsm(struct kmb_drm_private *dev_p, u32 dphy_no)
+{
+	test_mode_send(dev_p, dphy_no, TEST_CODE_FSM_CONTROL, 0x80);
+
+	drm_dbg(&dev_p->drm, "dphy %d fsm_state = 0%x\n", dphy_no,
+		 kmb_read_mipi(dev_p, DPHY_TEST_DOUT4_7));
+}
+#endif
+
+static void dphy_init_sequence(struct kmb_drm_private *dev_p,
+			       struct mipi_ctrl_cfg *cfg, u32 dphy_no,
+			       int active_lanes, enum dphy_mode mode)
+{
+	u32 test_code = 0, test_data = 0, val;
+	int i = 0;
+
+	drm_info(&dev_p->drm,
+		"dphy=%d mode=%d active_lanes=%d\n", dphy_no, mode,
+		 active_lanes);
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	/* Set D-PHY in shutdown mode */
+	/* Assert RSTZ signal */
+	CLR_DPHY_INIT_CTRL0(dev_p, dphy_no, RESETZ);
+
+	/* Assert SHUTDOWNZ signal */
+	CLR_DPHY_INIT_CTRL0(dev_p, dphy_no, SHUTDOWNZ);
+	val = kmb_read_mipi(dev_p, DPHY_INIT_CTRL0);
+
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL0 = 0x%x\n", val);
+
+	/* Init D-PHY_n
+	 * Pulse testclear signal to make sure the d-phy configuration
+	 * starts from a clean base
+	 */
+	CLR_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+	SET_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+	CLR_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+
+	drm_dbg(&dev_p->drm, "DPHY_TEST_CTRL0=0x%x\n",
+		  kmb_read_mipi(dev_p, DPHY_TEST_CTRL0));
+
+	/* Set mastermacro bit - Master or slave mode */
+	test_code = TEST_CODE_MULTIPLE_PHY_CTRL;
+
+	/* DPHY has its own clock lane enabled (master) */
+	if (mode == MIPI_DPHY_MASTER)
+		test_data = 0x01;
+	else
+		test_data = 0x00;
+
+	/* Send the test code and data */
+	test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	/* Set the lane data rate */
+	for (i = 0; i < MIPI_DPHY_DEFAULT_BIT_RATES; i++) {
+		if (mipi_hs_freq_range[i].default_bit_rate_mbps <
+		    cfg->lane_rate_mbps)
+			continue;
+
+		/* Send the test code and data */
+		/* bit[6:0] = hsfreqrange_ovr bit[7] = hsfreqrange_ovr_en */
+		test_code = TEST_CODE_HS_FREQ_RANGE_CFG;
+		test_data = (mipi_hs_freq_range[i].hsfreqrange_code & 0x7f) |
+		    (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+		break;
+	}
+
+	/* High-Speed Tx Slew Rate Calibration
+	 * BitRate: > 1.5 Gbps && <= 2.5 Gbps: slew rate control OFF
+	 */
+	if (cfg->lane_rate_mbps > 1500) {
+		/* Bypass slew rate calibration algorithm
+		 * bits[1:0} srcal_en_ovr_en, srcal_en_ovr
+		 */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = 0x02;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Disable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x00;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+	} else if (cfg->lane_rate_mbps > 1000) {
+		/* BitRate: > 1 Gbps && <= 1.5 Gbps: - slew rate control ON
+		 * typical rise/fall times: 166 ps
+		 */
+
+		/* Do not bypass slew rate calibration algorithm
+		 * bits[1:0}=srcal_en_ovr_en, srcal_en_ovr, bit[6]=sr_range
+		 */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = (0x03 | (1 << 6));
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Enable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[6:0] low nibble
+		 * typical rise/fall time=166, refer Table 1207 databook
+		 */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = (0x72f & 0x7f);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[11:7] high nibble
+		 * Typical rise/fall time=166, refer Table 1207 databook
+		 */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = ((0x72f >> 6) & 0x1f) | (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+	} else {
+		/* lane_rate_mbps <= 1000 Mbps
+		 * BitRate:  <= 1 Gbps:
+		 * - slew rate control ON
+		 * - typical rise/fall times: 225 ps
+		 */
+
+		/* Do not bypass slew rate calibration algorithm */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = (0x03 | (1 << 6));
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Enable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Typical rise/fall time=255, refer Table 1207 databook */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = (0x523 & 0x7f);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[11:7] high nibble */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = ((0x523 >> 6) & 0x1f) | (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	}
+
+	/* Set cfgclkfreqrange */
+	val = (((cfg->cfg_clk_khz / 1000) - 17) * 4) & 0x3f;
+	SET_DPHY_FREQ_CTRL0_3(dev_p, dphy_no, val);
+
+	drm_dbg(&dev_p->drm, "DPHY_FREQ = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_FREQ_CTRL0_3 + 4));
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	/* Enable config clk for the corresponding d-phy */
+	kmb_set_bit_mipi(dev_p, DPHY_CFG_CLK_EN, dphy_no);
+
+	drm_dbg(&dev_p->drm, "DPHY_CFG_CLK_EN = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_CFG_CLK_EN));
+
+	/* PLL setup */
+	if (mode == MIPI_DPHY_MASTER) {
+		/*Set PLL regulator in bypass */
+		test_code = TEST_CODE_PLL_ANALOG_PROG;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* PLL Parameters Setup */
+		mipi_tx_pll_setup(dev_p, dphy_no, cfg->ref_clk_khz / 1000,
+				  cfg->lane_rate_mbps / 2);
+
+		/* Set clksel */
+		kmb_write_bits_mipi(dev_p, DPHY_INIT_CTRL1,
+				    PLL_CLKSEL_0, 2, 0x01);
+
+		/* Set pll_shadow_control */
+		kmb_set_bit_mipi(dev_p, DPHY_INIT_CTRL1, PLL_SHADOW_CTRL);
+
+		drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL1 = 0x%x\n",
+			 kmb_read_mipi(dev_p, DPHY_INIT_CTRL1));
+	}
+
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+//#define MIPI_TX_FORCE_VOD
+#ifdef MIPI_TX_FORCE_VOD
+#define MIPI_TX_VOD_LVL	450
+#define TEST_CODE_BANDGAP 0x24
+	/* Set bandgap/VOD level */
+	switch (MIPI_TX_VOD_LVL) {
+	case 200:
+		test_data = 0x00;
+		break;
+	case 300:
+		test_data = 0x20;
+		break;
+	case 350:
+		test_data = 0x40;
+		break;
+	case 450:
+		test_data = 0x60;
+		break;
+	case 400:
+	default:
+		test_data = 0x70;
+		break;
+	}
+	test_mode_send(dev_p, dphy_no, TEST_CODE_BANDGAP, test_data);
+#endif
+
+	/*Send NORMAL OPERATION test code */
+	test_code = 0x0;
+	test_data = 0x0;
+	test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	/* Configure BASEDIR for data lanes
+	 * NOTE: basedir only applies to LANE_0 of each D-PHY.
+	 * The other lanes keep their direction based on the D-PHY type,
+	 * either Rx or Tx.
+	 * bits[5:0]  - BaseDir: 1 = Rx
+	 * bits[9:6] - BaseDir: 0 = Tx
+	 */
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	kmb_write_bits_mipi(dev_p, DPHY_INIT_CTRL2, 0, 9, 0x03f);
+	ndelay(15);
+
+	/* Enable CLOCK LANE
+	 * Clock lane should be enabled regardless of the direction
+	 * set for the D-PHY (Rx/Tx)
+	 */
+	kmb_set_bit_mipi(dev_p, DPHY_INIT_CTRL2, 12 + dphy_no);
+
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL2 = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_INIT_CTRL2));
+
+	/* Enable DATA LANES */
+	kmb_write_bits_mipi(dev_p, DPHY_ENABLE, dphy_no * 2, 2,
+			    ((1 << active_lanes) - 1));
+
+	drm_dbg(&dev_p->drm,
+		"DPHY_ENABLE = 0x%x\n", kmb_read_mipi(dev_p, DPHY_ENABLE));
+	ndelay(15);
+
+	/* Take D-PHY out of shutdown mode */
+	/* Deassert SHUTDOWNZ signal */
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		 kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+	SET_DPHY_INIT_CTRL0(dev_p, dphy_no, SHUTDOWNZ);
+	ndelay(15);
+
+	/* Deassert RSTZ signal */
+	SET_DPHY_INIT_CTRL0(dev_p, dphy_no, RESETZ);
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL0 = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_INIT_CTRL0));
+}
+
+static void dphy_wait_fsm(struct kmb_drm_private *dev_p, u32 dphy_no,
+			  enum dphy_tx_fsm fsm_state)
+{
+	enum dphy_tx_fsm val = DPHY_TX_POWERDWN;
+	int i = 0;
+	int status = 1;
+
+	do {
+		test_mode_send(dev_p, dphy_no, TEST_CODE_FSM_CONTROL, 0x80);
+
+		val = GET_TEST_DOUT4_7(dev_p, dphy_no);
+		i++;
+		if (i > TIMEOUT) {
+			status = 0;
+			break;
+		}
+	} while (val != fsm_state);
+
+	drm_dbg(&dev_p->drm, "%s: dphy %d val = %x\n", __func__, dphy_no, val);
+	drm_info(&dev_p->drm, "********** DPHY %d WAIT_FSM %s **********\n",
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static void wait_init_done(struct kmb_drm_private *dev_p, u32 dphy_no,
+			   u32 active_lanes)
+{
+	u32 stopstatedata = 0;
+	u32 data_lanes = (1 << active_lanes) - 1;
+	int i = 0, val;
+	int status = 1;
+
+	drm_dbg(&dev_p->drm, "dphy=%d active_lanes=%d data_lanes=%d\n", dphy_no,
+		 active_lanes, data_lanes);
+
+	do {
+		val = kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7);
+		stopstatedata = GET_STOPSTATE_DATA(dev_p, dphy_no) & data_lanes;
+
+		/* TODO-need to add a time out and return failure */
+		i++;
+
+		if (i > TIMEOUT) {
+			status = 0;
+
+			drm_info(&dev_p->drm,
+				"! WAIT_INIT_DONE: TIMING OUT!(err_stat=%d)",
+				 kmb_read_mipi(dev_p, MIPI_DPHY_ERR_STAT6_7));
+			drm_dbg(&dev_p->drm,
+				"MIPI_DPHY_STAT0_4_7 = 0x%x)\n", val);
+			drm_dbg(&dev_p->drm,
+				"stopdata = 0x%x data_lanes=0x%x\n",
+				 stopstatedata, data_lanes);
+
+			break;
+		}
+
+		if (i < 3) {
+			drm_dbg(&dev_p->drm,
+				"stopdata = 0x%x data_lanes=0x%x\n",
+				 stopstatedata, data_lanes);
+			drm_dbg(&dev_p->drm,
+				"MIPI_DPHY_STAT0_4_7 = 0x%x)\n", val);
+		}
+	} while (stopstatedata != data_lanes);
+
+	drm_info(&dev_p->drm, "********** DPHY %d INIT - %s **********\n",
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static void wait_pll_lock(struct kmb_drm_private *dev_p, u32 dphy_no)
+{
+	int i = 0;
+	int status = 1;
+
+	do {
+		/* TODO-need to add a time out and return failure */
+		i++;
+		if (i > TIMEOUT) {
+			status = 0;
+
+			drm_info(&dev_p->drm, "%s: timing out", __func__);
+			drm_dbg(&dev_p->drm,
+				"%s : PLL_LOCK = 0x%x ", __func__,
+				kmb_read_mipi(dev_p, DPHY_PLL_LOCK));
+
+			break;
+		}
+
+		if ((i % 100) == 0)
+			drm_dbg(&dev_p->drm,
+				"%s : PLL_LOCK = 0x%x\n", __func__,
+				kmb_read_mipi(dev_p, DPHY_PLL_LOCK));
+	} while (!GET_PLL_LOCK(dev_p, dphy_no));
+
+	drm_info(&dev_p->drm, "***** PLL Locked for DPHY %d - %s *****\n",
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static u32 mipi_tx_init_dphy(struct kmb_drm_private *dev_p,
+			     struct mipi_ctrl_cfg *cfg)
+{
+	u32 dphy_no = MIPI_DPHY6;
+
+	drm_info(&dev_p->drm,
+		"active_lanes=%d lane_rate=%d\n", cfg->active_lanes,
+		MIPI_TX_LANE_DATA_RATE_MBPS);
+
+	/* Multiple D-PHYs needed */
+	if (cfg->active_lanes > MIPI_DPHY_D_LANES) {
+		/*
+		 *Initialization for Tx aggregation mode is done according to
+		 *http://dub30.ir.intel.com/bugzilla/show_bug.cgi?id=27785#c12:
+		 *a. start init PHY1
+		 *b. poll for PHY1 FSM state LOCK
+		 *   b1. reg addr 0x03[3:0] - state_main[3:0] == 5 (LOCK)
+		 *c. poll for PHY1 calibrations done :
+		 *   c1. termination calibration lower section: addr 0x22[5]
+		 *   - rescal_done
+		 *   c2. slewrate calibration (if data rate < = 1500 Mbps):
+		 *     addr 0xA7[3:2] - srcal_done, sr_finished
+		 *d. start init PHY0
+		 *e. poll for PHY0 stopstate
+		 *f. poll for PHY1 stopstate
+		 */
+		/*PHY #N+1 ('slave') */
+
+		dphy_init_sequence(dev_p, cfg, dphy_no + 1,
+				   (cfg->active_lanes - MIPI_DPHY_D_LANES),
+				   MIPI_DPHY_SLAVE);
+		dphy_wait_fsm(dev_p, dphy_no + 1, DPHY_TX_LOCK);
+
+		/* PHY #N master */
+		dphy_init_sequence(dev_p, cfg, dphy_no, MIPI_DPHY_D_LANES,
+				   MIPI_DPHY_MASTER);
+
+		/* Wait for DPHY init to complete */
+		wait_init_done(dev_p, dphy_no, MIPI_DPHY_D_LANES);
+		wait_init_done(dev_p, dphy_no + 1,
+			       cfg->active_lanes - MIPI_DPHY_D_LANES);
+		wait_pll_lock(dev_p, dphy_no);
+		wait_pll_lock(dev_p, dphy_no + 1);
+		dphy_wait_fsm(dev_p, dphy_no, DPHY_TX_IDLE);
+	} else {		/* Single DPHY */
+		dphy_init_sequence(dev_p, cfg, dphy_no, cfg->active_lanes,
+				   MIPI_DPHY_MASTER);
+		dphy_wait_fsm(dev_p, dphy_no, DPHY_TX_IDLE);
+		wait_init_done(dev_p, dphy_no, cfg->active_lanes);
+		wait_pll_lock(dev_p, dphy_no);
+	}
+
+	return 0;
+}
+
+void connect_lcd_to_mipi(struct kmb_drm_private *dev_p)
+{
+	/* DISABLE MIPI->CIF CONNECTION */
+	kmb_write_msscam(dev_p, MSS_MIPI_CIF_CFG, 0);
+
+	/* ENABLE LCD->MIPI CONNECTION */
+	kmb_write_msscam(dev_p, MSS_LCD_MIPI_CFG, 1);
+
+	/* DISABLE LCD->CIF LOOPBACK */
+	kmb_write_msscam(dev_p, MSS_LOOPBACK_CFG, 0);
+}
+
+int kmb_dsi_hw_init(struct drm_device *dev, struct drm_display_mode *mode)
+{
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+	u64 data_rate;
+
+	mipi_tx_init_cfg.active_lanes = MIPI_TX_ACTIVE_LANES;
+
+	if (mode != NULL) {
+		mipi_tx_frame0_sect_cfg.width_pixels = mode->crtc_hdisplay;
+		mipi_tx_frame0_sect_cfg.height_lines = mode->crtc_vdisplay;
+		mipitx_frame0_cfg.vsync_width =
+		    mode->crtc_vsync_end - mode->crtc_vsync_start;
+		mipitx_frame0_cfg.v_backporch =
+		    mode->crtc_vtotal - mode->crtc_vsync_end;
+		mipitx_frame0_cfg.v_frontporch =
+		    mode->crtc_vsync_start - mode->crtc_vdisplay;
+		mipitx_frame0_cfg.hsync_width =
+		    mode->crtc_hsync_end - mode->crtc_hsync_start;
+		mipitx_frame0_cfg.h_backporch =
+		    mode->crtc_htotal - mode->crtc_hsync_end;
+		mipitx_frame0_cfg.h_frontporch =
+		    mode->crtc_hsync_start - mode->crtc_hdisplay;
+
+		/* Lane rate = (vtotal*htotal*fps*bpp)/4 / 1000000
+		 * to convert to Mbps
+		 */
+		data_rate = ((((u32) mode->crtc_vtotal *
+				(u32) mode->crtc_htotal) *
+				(u32)(drm_mode_vrefresh(mode)) *
+			      MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) /
+		    1000000;
+
+		drm_info(&dev_p->drm, "htotal=%d vtotal=%d refresh=%d\n",
+			 mode->crtc_htotal, mode->crtc_vtotal,
+			 drm_mode_vrefresh(mode));
+		drm_info(&dev_p->drm, "data_rate=%u active_lanes=%d\n",
+			 (u32) data_rate, mipi_tx_init_cfg.active_lanes);
+
+		/* When late rate < 800, modeset fails with 4 lanes,
+		 * so switch to 2 lanes
+		 */
+		if (data_rate < 800) {
+			mipi_tx_init_cfg.active_lanes = 2;
+			mipi_tx_init_cfg.lane_rate_mbps = data_rate * 2;
+		} else {
+			mipi_tx_init_cfg.lane_rate_mbps = data_rate;
+		}
+		drm_info(&dev_p->drm,
+			"lane rate=%d\n", mipi_tx_init_cfg.lane_rate_mbps);
+		drm_dbg(&dev_p->drm,
+		     "vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d hsync_len=%d lane-rate=%d",
+		     mipitx_frame0_cfg.v_frontporch,
+		     mipitx_frame0_cfg.v_backporch,
+		     mipitx_frame0_cfg.vsync_width,
+		     mipitx_frame0_cfg.h_frontporch,
+		     mipitx_frame0_cfg.h_backporch,
+		     mipitx_frame0_cfg.hsync_width,
+		     mipi_tx_init_cfg.lane_rate_mbps);
+
+	}
+
+	if (hw_initialized)
+		return 0;
+
+	kmb_write_mipi(dev_p, DPHY_ENABLE, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL0, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL1, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL2, 0);
+
+	/* Initialize mipi controller */
+	mipi_tx_init_cntrl(dev_p, &mipi_tx_init_cfg);
+
+	/* Dphy initialization */
+	mipi_tx_init_dphy(dev_p, &mipi_tx_init_cfg);
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		 GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+
+	connect_lcd_to_mipi(dev_p);
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+	mipi_tx_hs_tp_gen(dev_p, 0, MIPI_TX_HS_TP_V_STRIPES,
+			  0x15, 0xff, 0xff00, MIPI_CTRL6);
+
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		 GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+#endif //MIPI_TX_TEST_PATTERN_GENERATION
+
+	hw_initialized = true;
+
+	drm_dbg(&dev_p->drm, "MIPI_TXm_HS_CTRL = 0x%x\n",
+		 kmb_read_mipi(dev_p, MIPI_TXm_HS_CTRL(6)));
+	drm_dbg(&dev_p->drm, "MIPI LOOP BACK = %x\n",
+		 kmb_read_mipi(dev_p, MIPI_CTRL_DIG_LOOPBACK));
+	drm_info(&dev_p->drm, "mipi hw_initialized = %d\n", hw_initialized);
+
+	return 0;
+}
+
+int kmb_dsi_init(struct drm_device *dev, struct drm_bridge *bridge)
+{
+	struct kmb_dsi *kmb_dsi;
+	struct drm_encoder *encoder;
+	struct kmb_connector *kmb_connector;
+	struct drm_connector *connector;
+	struct kmb_dsi_host *host;
+	int ret = 0;
+
+	kmb_dsi = kzalloc(sizeof(*kmb_dsi), GFP_KERNEL);
+	if (!kmb_dsi) {
+		DRM_ERROR("failed to allocate kmb_dsi\n");
+		return -ENOMEM;
+	}
+
+	kmb_connector = kzalloc(sizeof(*kmb_connector), GFP_KERNEL);
+	if (!kmb_connector) {
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/kmb/kmb_dsi.h new file +370 -0
new file mode 100644
index 0000000..d2beaf4

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/kmb/kmb_plane.c new file +471 -0
new file mode 100644
index 0000000..55aef5c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

From a lifetime persepctive I *think* drmm_kzalloc() is the right choice here.

Quoted 925 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +44 -0

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/kmb/kmb_plane.h new file +124 -0
new file mode 100644
index 0000000..48f237f

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/kmb/kmb_regs.h new file +738 -0
new file mode 100644
index 0000000..089e42d

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Part of the diff is not shown here. View the raw message.

author maintainer
#3 lore raw

RE: [PATCH v3] drm/kmb: Add support for KeemBay Display

Hi Sam,
Thanks for your detailed review, please see my comments/questions in line. I have made the review changes and I am sending v4 soon.

Thanks,
Anitha

Quoted 109 lines

-----Original Message-----
From: Sam Ravnborg <[email protected]>
Sent: Saturday, July 18, 2020 6:08 AM
To: Chrisanthus, Anitha <[email protected]>
Cc: [email protected]; Paauwe, Bob J <[email protected]>; Dea, Edmund J <[email protected]>; Vetter, Daniel <[email protected]>; [email protected]; Vivi, Rodrigo <[email protected]>
Subject: Re: [PATCH v3] drm/kmb: Add support for KeemBay Display

Hi Anitha.

Quoted 8 lines · Anitha Chrisanthus

This is a basic KMS atomic modesetting display driver for KeemBay family of SOCs. Driver has no 2D or 3D graphics.It calls into the ADV bridge driver at the connector level.

Single CRTC with LCD controller->mipi DSI-> ADV bridge

Only 1080p resolution and single plane is supported at this time.

Quoted 7 lines

v2: moved extern to .h, removed license text
use drm_dev_init, upclassed dev_private, removed HAVE_IRQ.

v3: Squashed all 59 commits to one

This was much easier to look into with it all squashed together. See comments scattered in the following.

The only major feedback is that kmb_dsi really looks like something that should be implemented as a real bridge driver.
Lots of small details to bring the driver up to the current standard. And other bits I noted while browsing the code.

Sam

Quoted 10 lines
---
 drivers/gpu/drm/Kconfig         |    2 +
 drivers/gpu/drm/Makefile        |    1 +
 drivers/gpu/drm/kmb/Kconfig     |   12 +
 drivers/gpu/drm/kmb/Makefile    |    2 +
 drivers/gpu/drm/kmb/kmb_crtc.c  |  219 +++++
 drivers/gpu/drm/kmb/kmb_crtc.h  |   41 +
 drivers/gpu/drm/kmb/kmb_drv.c   |  759 ++++++++++++++++
 drivers/gpu/drm/kmb/kmb_drv.h   |  165 ++++
 drivers/gpu/drm/kmb/kmb_dsi.c   | 1833

+++++++++++++++++++++++++++++++++++++++

Quoted 58 lines
 drivers/gpu/drm/kmb/kmb_dsi.h   |  370 ++++++++
 drivers/gpu/drm/kmb/kmb_plane.c |  515 +++++++++++
 drivers/gpu/drm/kmb/kmb_plane.h |  124 +++
 drivers/gpu/drm/kmb/kmb_regs.h  |  738 ++++++++++++++++
 13 files changed, 4781 insertions(+)
 create mode 100644 drivers/gpu/drm/kmb/Kconfig
 create mode 100644 drivers/gpu/drm/kmb/Makefile
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_crtc.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_drv.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.c
 create mode 100644 drivers/gpu/drm/kmb/kmb_plane.h
 create mode 100644 drivers/gpu/drm/kmb/kmb_regs.h
drivers/gpu/drm/Kconfig +2 -0
index c4fd57d..5292574 100644
@@ -275,6 +275,8 @@ source "drivers/gpu/drm/nouveau/Kconfig"
 
 source "drivers/gpu/drm/i915/Kconfig"
 
+source "drivers/gpu/drm/kmb/Kconfig"
+
 config DRM_VGEM
 	tristate "Virtual GEM provider"
 	depends on DRM
drivers/gpu/drm/Makefile +1 -0
index 2c0e5a7..bdbdc63 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
 obj-$(CONFIG_DRM_MGA)	+= mga/
 obj-$(CONFIG_DRM_I810)	+= i810/
 obj-$(CONFIG_DRM_I915)	+= i915/
+obj-$(CONFIG_DRM_KMB_DISPLAY)  += kmb/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
drivers/gpu/drm/kmb/Kconfig new file +10 -0
new file mode 100644
index 0000000..005a9962
@@ -0,0 +1,12 @@
+config DRM_KMB_DISPLAY
+	tristate "KEEMBAY DISPLAY"
+	depends on DRM && OF && (ARM || ARM64)
+	depends on COMMON_CLK
+	select DRM_KMS_HELPER
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	help
+	Choose this option if you have an KEEMBAY DISPLAY controller.
Quoted 8 lines

drivers/gpu/drm/kmb/Kconfig line 12

Quoted 2 lines
drivers/gpu/drm/kmb/Kconfig new file +2 -0
+
+	If M is selected the module will be called kmb-display.

It would be good if you could elaborate just a bit more here. Just so users knows a bit more what it is. For example I think most users will not know this is something from Intel.
Also I think the module is not named kmb-display, so this needs to be addressed.

Will add more details

Quoted 32 lines

Review

Quoted 10 lines
drivers/gpu/drm/kmb/Makefile new file +2 -0
new file mode 100644
index 0000000..527d737
@@ -0,0 +1,2 @@
+kmb-drm-y := kmb_crtc.o kmb_drv.o kmb_plane.o kmb_dsi.o
+obj-$(CONFIG_DRM_KMB_DISPLAY)	+= kmb-drm.o
(quoted diff) +0 -0

b/drivers/gpu/drm/kmb/kmb_crtc.c

Quoted 21 lines

new file mode 100644
index 0000000..570d46e

drivers/gpu/drm/kmb/kmb_crtc.c new file +16 -0
@@ -0,0 +1,219 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2018-2020 Intel Corporation
+ */
+
+#include <linux/clk.h>
+#include <linux/of_graph.h>
+#include <linux/platform_data/simplefb.h>
+#include <video/videomode.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 23

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +7 -0
+#include <drm/drm_of.h>
+#include <drm/drm_plane_helper.h>
+#include "kmb_crtc.h"
+#include "kmb_drv.h"
+#include "kmb_plane.h"
+#include "kmb_regs.h"
+#include "kmb_dsi.h"

Almost OK - an empty line between each block would be appreciated.

Will do

Quoted 11 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 31

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +8 -0
+
+static void kmb_crtc_cleanup(struct drm_crtc *crtc)
+{
+	struct kmb_crtc *l_crtc = to_kmb_crtc(crtc);
+
+	drm_crtc_cleanup(crtc);
+	kfree(l_crtc);
+}

I cannot find where kmb_crtc is allocated - is this a left-over from some old code and it is no longer used/relevant?

You're right - will remove it.

Quoted 10 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 36

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +5 -0
+
+static int kmb_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);

bikeshedding...
general comment.
s/dev_p/kmb - it is a pointer to kmb_drm_private - so name it kmb to better reflect this. Bikeshedding - feel free to ignore.

Will change name to kmb

Quoted 6 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 38

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +2 -0
+
+	/*clear interrupt */

General comment. Include whitespace after "/*" and start with a capital letter.
Not a big deal, but this steal focus when not followed.

Will change

Quoted 63 lines
Quoted 8 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +7 -0
+	kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);
+	/*set which interval to generate vertical interrupt */
+	kmb_write_lcd(dev_p, LCD_VSTATUS_COMPARE,
+		      LCD_VSTATUS_COMPARE_VSYNC);
+	/* enable vertical interrupt */
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);

drivers/gpu/drm/kmb/kmb_crtc.c line 55

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+	return 0;
+}
+
+static void kmb_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	/*clear interrupt */
+	kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_VERT_COMP);

I had expected you should clear the interrupt _after_ disabling the interrupt. But I guess this is no big deal as interrupt may occur also just before the disable.

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +11 -0
+	/* disable vertical interrupt */
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			LCD_INT_VERT_COMP);
+}
+
+static const struct drm_crtc_funcs kmb_crtc_funcs = {
+	.destroy = kmb_crtc_cleanup,
+	.set_config = drm_atomic_helper_set_config,
+	.page_flip = drm_atomic_helper_page_flip,
+	.reset = drm_atomic_helper_crtc_reset,
+	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,

drivers/gpu/drm/kmb/kmb_crtc.c line 76

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+	.enable_vblank = kmb_crtc_enable_vblank,
+	.disable_vblank = kmb_crtc_disable_vblank,
+};
+
+static void kmb_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_display_mode *m = &crtc->state->adjusted_mode;
+	struct videomode vm;

videomode should not be required here.

drivers/gpu/drm/kmb/kmb_crtc.c

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +9 -0
+	int vsync_start_offset;
+	int vsync_end_offset;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+	unsigned int val = 0;
+
+	/* initialize mipi */
+	kmb_dsi_hw_init(dev, m);
+	drm_info(dev,
+		"vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d

hsync_len=%d\n",

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +9 -0
+		 m->crtc_vsync_start - m->crtc_vdisplay,
+		 m->crtc_vtotal - m->crtc_vsync_end,
+		 m->crtc_vsync_end - m->crtc_vsync_start,
+		 m->crtc_hsync_start - m->crtc_hdisplay,
+		 m->crtc_htotal - m->crtc_hsync_end,
+		 m->crtc_hsync_end - m->crtc_hsync_start);
+	val = kmb_read_lcd(dev_p, LCD_INT_ENABLE);
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE, val);
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR, ~0x0);
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 100

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +6 -0
+	vm.vfront_porch = 2;
+	vm.vback_porch = 2;
+	vm.vsync_len = 8;
+	vm.hfront_porch = 0;
+	vm.hback_porch = 0;
+	vm.hsync_len = 28;

This looks like values that should come from the panel - and not values hardcoded in the driver.

The panel timings are used in the mipi dsi programming. The above values are the optimal values for LCD controller for 1080p resolution. Here the LCD controller reads the frame buffer through DMA transfer and passes it on to mipi dsi controller which adds the panel's exact timings. I will add a comment in the code describing this.

Quoted 4 lines

The use of struct videomode should be avoid IMO. videomode balongs to fbdev time, use display_timing is you need something like it.

Will add a new struct for this.

Quoted 43 lines

drivers/gpu/drm/kmb/kmb_crtc.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +5 -0
+
+	vsync_start_offset =  m->crtc_vsync_start -  m->crtc_hsync_start;
+	vsync_end_offset =  m->crtc_vsync_end - m->crtc_hsync_end;
+
+	drm_dbg(dev, "%s : %dactive height= %d vbp=%d vfp=%d vsync-w=%d h-

active=%d h-bp=%d h-fp=%d hysnc-l=%d",

Quoted 16 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +16 -0
+			__func__, __LINE__,
+			m->crtc_vdisplay, vm.vback_porch, vm.vfront_porch,
+			vm.vsync_len, m->crtc_hdisplay, vm.hback_porch,
+			vm.hfront_porch, vm.hsync_len);
+	kmb_write_lcd(dev_p, LCD_V_ACTIVEHEIGHT,
+			m->crtc_vdisplay - 1);
+	kmb_write_lcd(dev_p, LCD_V_BACKPORCH, vm.vback_porch);
+	kmb_write_lcd(dev_p, LCD_V_FRONTPORCH, vm.vfront_porch);
+	kmb_write_lcd(dev_p, LCD_VSYNC_WIDTH, vm.vsync_len - 1);
+	kmb_write_lcd(dev_p, LCD_H_ACTIVEWIDTH,
+			m->crtc_hdisplay - 1);
+	kmb_write_lcd(dev_p, LCD_H_BACKPORCH, vm.hback_porch);
+	kmb_write_lcd(dev_p, LCD_H_FRONTPORCH, vm.hfront_porch);
+	kmb_write_lcd(dev_p, LCD_HSYNC_WIDTH, vm.hsync_len - 1);
+	/*this is hardcoded as 0 in the Myriadx code */
+	kmb_write_lcd(dev_p, LCD_VSYNC_START, 0);

drivers/gpu/drm/kmb/kmb_crtc.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +10 -0
+	kmb_write_lcd(dev_p, LCD_VSYNC_END, 0);
+	/* back ground color */
+	kmb_write_lcd(dev_p, LCD_BG_COLOUR_LS, 0x4);
+	if (m->flags == DRM_MODE_FLAG_INTERLACE) {
+		kmb_write_lcd(dev_p,
+			      LCD_VSYNC_WIDTH_EVEN, vm.vsync_len - 1);
+		kmb_write_lcd(dev_p,
+				LCD_V_BACKPORCH_EVEN, vm.vback_porch);
+		kmb_write_lcd(dev_p,
+				LCD_V_FRONTPORCH_EVEN,

vm.vfront_porch);

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +8 -0
+		kmb_write_lcd(dev_p, LCD_V_ACTIVEHEIGHT_EVEN,
+			      m->crtc_vdisplay - 1);
+		/*this is hardcoded as 10 in the Myriadx code */
+		kmb_write_lcd(dev_p, LCD_VSYNC_START_EVEN, 10);
+		kmb_write_lcd(dev_p, LCD_VSYNC_END_EVEN, 10);
+	}
+	kmb_write_lcd(dev_p, LCD_TIMING_GEN_TRIG, ENABLE);
+	kmb_set_bitmask_lcd(dev_p, LCD_CONTROL, LCD_CTRL_ENABLE);
Quoted 3 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 140

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.c new file +1 -0
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE, val);

Is LCD_INT_ENABLE, really a readable register? val is assigned the value from LCD_INT_ENABLE, before.

Yes it's a readable register, val is saving its enabled bits - we disable the interrupts before programming the lcd timing and then enable it after.

Quoted 60 lines
Quoted 60 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +58 -0
+	/* TBD */
+	/* set clocks here */
+}
+
+static void kmb_crtc_atomic_enable(struct drm_crtc *crtc,
+				   struct drm_crtc_state *old_state)
+{
+	struct kmb_drm_private *lcd = crtc_to_kmb_priv(crtc);
+
+	clk_prepare_enable(lcd->clk);
+	kmb_crtc_mode_set_nofb(crtc);
+	drm_crtc_vblank_on(crtc);
+}
+
+static void kmb_crtc_atomic_disable(struct drm_crtc *crtc,
+				    struct drm_crtc_state *old_state)
+{
+	struct kmb_drm_private *lcd = crtc_to_kmb_priv(crtc);
+
+	/* always disable planes on the CRTC that is being turned off */
+	drm_atomic_helper_disable_planes_on_crtc(old_state, false);
+
+	drm_crtc_vblank_off(crtc);
+	clk_disable_unprepare(lcd->clk);
+}
+
+static void kmb_crtc_atomic_begin(struct drm_crtc *crtc,
+				  struct drm_crtc_state *state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);
+}
+
+static void kmb_crtc_atomic_flush(struct drm_crtc *crtc,
+				  struct drm_crtc_state *state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			    LCD_INT_VERT_COMP);
+
+	spin_lock_irq(&crtc->dev->event_lock);
+	if (crtc->state->event)
+		drm_crtc_send_vblank_event(crtc, crtc->state->event);
+	crtc->state->event = NULL;
+	spin_unlock_irq(&crtc->dev->event_lock);
+}
+
+static const struct drm_crtc_helper_funcs kmb_crtc_helper_funcs = {
+	.atomic_begin = kmb_crtc_atomic_begin,
+	.atomic_enable = kmb_crtc_atomic_enable,
+	.atomic_disable = kmb_crtc_atomic_disable,
+	.atomic_flush = kmb_crtc_atomic_flush,
+};
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_crtc.c line 202

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +4 -0
+
+int kmb_setup_crtc(struct drm_device *drm)
+{
+	struct kmb_drm_private *lcd = to_kmb(drm);

General comment.
It makes code more read-able if the same local name is used all over. Right now there is lcd and dev_p (and then I went agead and suggested kmb as a third name - sigh).

Will change to kmb everywhere.

Quoted 54 lines

Review

Quoted 20 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +8 -0
+	struct kmb_plane *primary;
+	int ret;
+
+	primary = kmb_plane_init(drm);
+	if (IS_ERR(primary))
+		return PTR_ERR(primary);
+
+	ret = drm_crtc_init_with_planes(drm, &lcd->crtc, &primary-

base_plane,

drivers/gpu/drm/kmb/kmb_crtc.c new file +9 -0
+					NULL, &kmb_crtc_funcs, NULL);
+	if (ret) {
+		kmb_plane_destroy(&primary->base_plane);
+		return ret;
+	}
+
+	drm_crtc_helper_add(&lcd->crtc, &kmb_crtc_helper_funcs);
+	return 0;
+}
(quoted diff) +0 -0

b/drivers/gpu/drm/kmb/kmb_crtc.h

Quoted 22 lines

new file mode 100644
index 0000000..51a0a39

drivers/gpu/drm/kmb/kmb_crtc.h new file +17 -0
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (c) 2018-2020 Intel Corporation
+ */
+
+#ifndef __KMB_CRTC_H__
+#define __KMB_CRTC_H__
+
+#include <linux/clk.h>
+#include <linux/of_graph.h>
+#include <linux/platform_data/simplefb.h>
+#include <video/videomode.h>
+#include <drm/drm_debugfs.h>
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_file.h>

drivers/gpu/drm/kmb/kmb_crtc.h line 27

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +10 -0
+#include <drm/drm_fourcc.h>
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include <drm/drm_vblank.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+#include <linux/wait.h>
+#include "kmb_drv.h"
+
+#define to_kmb_crtc_state(x) container_of(x, struct kmb_crtc_state,

crtc_base)

Quoted 7 lines

drivers/gpu/drm/kmb/kmb_crtc.h line 33

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +6 -0
+#define to_kmb_crtc(x) container_of(x, struct kmb_crtc, crtc_base)
+
+struct kmb_crtc {
+	struct drm_crtc crtc_base;
+	struct kmb_drm_private kmb_dev;
+};

This struct looks unused - delete it.

ok

Quoted 6 lines

drivers/gpu/drm/kmb/kmb_crtc.h line 37

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +4 -0
+
+struct kmb_crtc_state {
+	struct drm_crtc_state crtc_base;
+};

This struct looks unused - delete it.

ok

Quoted 6 lines

drivers/gpu/drm/kmb/kmb_crtc.h line 39

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_crtc.h new file +2 -0
+
+extern void kmb_plane_destroy(struct drm_plane *plane);

General comment - drop extern in fron of prototypes in .h files. kmb_plane_destroy is declared in another .h file - so drop this.

Quoted 6 lines

drivers/gpu/drm/kmb/kmb_crtc.h line 40

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.h new file +1 -0
+extern struct kmb_plane *kmb_plane_init(struct drm_device *drm);

This is likewise decalred in another .h file - drop it.

drivers/gpu/drm/kmb/kmb_crtc.h line 41

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.h new file +1 -0
+#endif /* __KMB_CRTC_H__ */

kmb_setup_crtc() is decalred in mkb_drv.h - so there i s no need for this header file anymore - delete it.

ok

Quoted 42 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/kmb/kmb_drv.c

Quoted 27 lines

new file mode 100644
index 0000000..159f36a

drivers/gpu/drm/kmb/kmb_drv.c new file +22 -0
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2018-2020 Intel Corporation
+ */
+
+#include <linux/clk.h>
+#include <linux/console.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/of_graph.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/pm_runtime.h>
+#include <linux/spinlock.h>
+#include <drm/drm.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_ioctl.h>

drivers/gpu/drm/kmb/kmb_drv.c line 32

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+#include <drm/drm_irq.h>
+#include <drm/drm_of.h>
+#include <drm/drm_probe_helper.h>
+#include "kmb_crtc.h"
+#include "kmb_drv.h"
+#include "kmb_dsi.h"
+#include "kmb_plane.h"
+#include "kmb_regs.h"
+
+//#define DEBUG

No // comments (not may rule, but some people request them removed)

Quoted 3 lines

drivers/gpu/drm/kmb/kmb_drv.c line 34

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+/* IRQ handler */
+static irqreturn_t kmb_isr(int irq, void *arg);

No need for this prototype - drop it.

ok

Quoted 9 lines

drivers/gpu/drm/kmb/kmb_drv.c line 41

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+
+int kmb_under_flow = 0, kmb_flush_done = 0, layer_no = 0;
+static struct clk *clk_lcd;
+static struct clk *clk_mipi;
+static struct clk *clk_mipi_ecfg;
+static struct clk *clk_mipi_cfg;
+static struct clk *clk_pll0;

Why are they not all part of kmb_drm_private?

Its local to kmb_drv.c will create a struct for these.

Quoted 4 lines

drivers/gpu/drm/kmb/kmb_drv.c line 43

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+struct drm_bridge *adv_bridge;

Same here?

Its called before drm is allocated.

Quoted 4 lines

drivers/gpu/drm/kmb/kmb_drv.c line 45

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+int kmb_display_clk_enable(void)

pass kmb_drm_private so drm_* can be used for logging.

ok

Quoted 69 lines
Quoted 18 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +17 -0
+{
+	int ret = 0;
+
+	ret = clk_prepare_enable(clk_lcd);
+	if (ret) {
+		DRM_ERROR("Failed to enable LCD clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi);
+	if (ret) {
+		DRM_ERROR("Failed to enable MIPI clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi_ecfg);
+	if (ret) {

drivers/gpu/drm/kmb/kmb_drv.c line 72

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		DRM_ERROR("Failed to enable MIPI_ECFG clock: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(clk_mipi_cfg);
+	if (ret) {
+		DRM_ERROR("Failed to enable MIPI_CFG clock: %d\n", ret);
+		return ret;
+	}
+	DRM_INFO("SUCCESS : enabled LCD MIPI clocks\n");

Consider using an array for the clocks - simpler code.

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+	return 0;
+}
+
+static int kmb_display_clk_disable(void)
+{
+	if (clk_lcd)
+		clk_disable_unprepare(clk_lcd);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	if (clk_mipi)
+		clk_disable_unprepare(clk_mipi);
+	if (clk_mipi_ecfg)
+		clk_disable_unprepare(clk_mipi_ecfg);
+	if (clk_mipi_cfg)
+		clk_disable_unprepare(clk_mipi_cfg);
+	return 0;
+}
+
+static void __iomem *kmb_map_mmio(struct platform_device *pdev, char

*name)

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +6 -0
+{
+	struct resource *res;
+	u32 size;
+	void __iomem *mem;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

name);

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +13 -0
+	if (!res) {
+		DRM_ERROR("failed to get resource for %s\n", name);
+		return ERR_PTR(-ENOMEM);
+	}
+	size = resource_size(res);
+	if (!request_mem_region(res->start, size, name)) {
+		DRM_ERROR("failed to reserve %s registers\n", name);
+		return ERR_PTR(-ENOMEM);
+	}
+	mem = ioremap(res->start, size);
+	if (!mem) {
+		DRM_ERROR("failed to ioremap %s registers\n", name);
+		release_mem_region(res->start, size);
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_drv.c line 112

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +4 -0
+		return ERR_PTR(-ENOMEM);
+	}
+	return mem;
+}

Error handling when calling kmb_map_mmio() looks wrong. The best way to fix it up would be to introduce the devm_ variants so this gets cleaned up automatically.
I think devm_ioremap_resource() will ct it - did not check it.

ok

Quoted 5 lines

drivers/gpu/drm/kmb/kmb_drv.c line 114

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+
+//#define ICAM_LCD_QOS

Some debug left over that should be dropped?

ok

Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +21 -0
+static int kmb_load(struct drm_device *drm, unsigned long flags)
+{
+	struct kmb_drm_private *dev_p = to_kmb(drm);
+	struct platform_device *pdev = to_platform_device(drm->dev);
+	int irq_lcd;
+	int ret = 0;
+	unsigned long clk;
+#ifdef ICAM_LCD_QOS
+	int val = 0;
+#endif
+	struct device_node *vpu_dev;
+
+	/* Map MIPI MMIO registers */
+	dev_p->mipi_mmio = kmb_map_mmio(pdev, "mipi_regs");
+	if (IS_ERR(dev_p->mipi_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MIPI registers\n");
+		iounmap(dev_p->lcd_mmio);
+		return -ENOMEM;
+	}
+
+	/* Map LCD MMIO registers */
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_drv.c line 140

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+	dev_p->lcd_mmio = kmb_map_mmio(pdev, "lcd_regs");
+	if (IS_ERR(dev_p->lcd_mmio)) {
+		drm_err(&dev_p->drm, "failed to map LCD registers\n");
+		return -ENOMEM;
+	}

Here is the broken error handling.
Fails to iounmap dev_p->mipi_mmio when lcd_mmio fails. And a few lines up lcd_mmio is unmapped before it is mapped.

Good catch! Was introduced inadvertently during code cleanup.

Quoted 22 lines
Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+	/* This is only for MIPI_TX_MSS_LCD_MIPI_CFG and
+	 * MSS_CAM_CLK_CTRL register
+	 */
+	dev_p->msscam_mmio = kmb_map_mmio(pdev, "msscam_regs");
+	if (IS_ERR(dev_p->msscam_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MSSCAM registers\n");
+		iounmap(dev_p->lcd_mmio);
+		iounmap(dev_p->mipi_mmio);
+		return -ENOMEM;

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	}
+
+	if (IS_ERR(dev_p->msscam_mmio)) {
+		drm_err(&dev_p->drm, "failed to map MSSCAM registers\n");
+		iounmap(dev_p->lcd_mmio);
+		iounmap(dev_p->mipi_mmio);
+		return -ENOMEM;
+	}
+#ifdef ICAM_LCD_QOS
+	dev_p->icamlcd_mmio = ioremap_nocache(ICAM_MMIO,

ICAM_MMIO_SIZE);

Quoted 8 lines

drivers/gpu/drm/kmb/kmb_drv.c line 165

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+	if (IS_ERR(dev_p->icamlcd_mmio)) {
+		drm_err(&dev_p->drm, "failed to map ICAM registers\n");
+		return -ENOMEM;
+	}
+#endif

The function is already long enough.
Consider pulling clock stuff out ini a helper function.

ok

Quoted 207 lines
Quoted 45 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +44 -0
+	/* Enable display clocks */
+	clk_lcd = clk_get(&pdev->dev, "clk_lcd");
+	if (IS_ERR(clk_lcd)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_lcd\n");
+		goto setup_fail;
+	}
+
+	clk_mipi = clk_get(&pdev->dev, "clk_mipi");
+	if (IS_ERR(clk_mipi)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi\n");
+		goto setup_fail;
+	}
+
+	clk_mipi_ecfg = clk_get(&pdev->dev, "clk_mipi_ecfg");
+	if (IS_ERR(clk_mipi_ecfg)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi_ecfg\n");
+		goto setup_fail;
+	}
+
+	clk_mipi_cfg = clk_get(&pdev->dev, "clk_mipi_cfg");
+	if (IS_ERR(clk_mipi_cfg)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_mipi_cfg\n");
+		goto setup_fail;
+	}
+	vpu_dev = of_find_node_by_path("/soc/vpu-ipc");
+	clk_pll0 = of_clk_get_by_name(vpu_dev, "pll_0_out_0");
+	if (IS_ERR(clk_pll0)) {
+		drm_err(&dev_p->drm, "clk_get() failed clk_pll0 ");
+		goto setup_fail;
+	}
+	dev_p->sys_clk_mhz = clk_get_rate(clk_pll0)/1000000;
+	drm_info(&dev_p->drm, "system clk = %d Mhz", dev_p->sys_clk_mhz);
+
+	/* Set LCD clock to 200 Mhz */
+	ret = clk_set_rate(clk_lcd, KMB_LCD_DEFAULT_CLK);
+	if (clk_get_rate(clk_lcd) != KMB_LCD_DEFAULT_CLK) {
+		drm_err(&dev_p->drm, "failed to set to clk_lcd to %d\n",
+			  KMB_LCD_DEFAULT_CLK);
+	}
+	drm_info(&dev_p->drm, "clk_lcd = %ld\n", clk_get_rate(clk_lcd));
+
+	/* Set MIPI clock to 24 Mhz */
+	ret = clk_set_rate(clk_mipi, KMB_MIPI_DEFAULT_CLK);
+	if (clk_get_rate(clk_mipi) != KMB_MIPI_DEFAULT_CLK) {

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		drm_err(&dev_p->drm, "failed to set to clk_mipi to %d\n",
+			  KMB_MIPI_DEFAULT_CLK);
+		goto setup_fail;
+	}
+	drm_info(&dev_p->drm, "clk_mipi = %ld\n", clk_get_rate(clk_mipi));
+
+	clk = clk_get_rate(clk_mipi_ecfg);
+	if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+		/* Set MIPI_ECFG clock to 24 Mhz */
+		ret = clk_set_rate(clk_mipi_ecfg,

KMB_MIPI_DEFAULT_CFG_CLK);

Quoted 25 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +25 -0
+		clk = clk_get_rate(clk_mipi_ecfg);
+		if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+			drm_err(&dev_p->drm,
+				"failed to set to clk_mipi_ecfg to %d\n",
+				 KMB_MIPI_DEFAULT_CFG_CLK);
+			goto setup_fail;
+		}
+
+		drm_info(&dev_p->drm, "clk_mipi_ecfg after set = %ld\n", clk);
+	}
+
+	clk = clk_get_rate(clk_mipi_cfg);
+	if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+		/* Set MIPI_CFG clock to 24 Mhz */
+		ret = clk_set_rate(clk_mipi_cfg, 24000000);
+		clk = clk_get_rate(clk_mipi_cfg);
+		if (clk != KMB_MIPI_DEFAULT_CFG_CLK) {
+			drm_err(&dev_p->drm,
+					"failed to set clk_mipi_cfg to %d\n",
+				  KMB_MIPI_DEFAULT_CFG_CLK);
+			goto setup_fail;
+		}
+		drm_info(&dev_p->drm,
+				"Get clk_mipi_cfg after set = %ld\n", clk);
+	}

drivers/gpu/drm/kmb/kmb_drv.c line 254

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+	ret = kmb_display_clk_enable();
+
+	/* Enable MSS_CAM_CLK_CTRL for MIPI TX and LCD */
+	kmb_set_bitmask_msscam(dev_p, MSS_CAM_CLK_CTRL, 0x1fff);
+	kmb_set_bitmask_msscam(dev_p, MSS_CAM_RSTN_CTRL, 0xffffffff);
+
+	/* Register irqs here - section 17.3 in databook
+	 * lists LCD at 79 and 82 for MIPI under MSS CPU -
+	 * firmware has redirected  79 to A53 IRQ 33

extra space

Quoted 33 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +33 -0
+	 */
+
+	/* Allocate LCD interrupt resources, enable interrupt line,
+	 * and setup IRQ handling
+	 */
+	irq_lcd = platform_get_irq_byname(pdev, "irq_lcd");
+	if (irq_lcd < 0) {
+		drm_err(&dev_p->drm, "irq_lcd not found");
+		goto setup_fail;
+	}
+
+	/* Get the optional framebuffer memory resource */
+	ret = of_reserved_mem_device_init(drm->dev);
+	if (ret && ret != -ENODEV)
+		return ret;
+
+	spin_lock_init(&dev_p->irq_lock);
+
+	ret = kmb_setup_crtc(drm);
+	if (ret < 0) {
+		drm_err(&dev_p->drm, "failed to create crtc\n");
+		goto setup_fail;
+	}
+
+	/* Initialize MIPI DSI */
+	ret = kmb_dsi_init(drm, adv_bridge);
+	if (ret) {
+		drm_err(&dev_p->drm, "failed to initialize DSI\n");
+		goto setup_fail;
+	}
+
+	ret = drm_irq_install(drm, irq_lcd);
+	if (ret < 0) {

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		drm_err(&dev_p->drm, "failed to install IRQ handler\n");
+		goto irq_fail;
+	}
+
+	dev_p->irq_lcd = irq_lcd;
+
+	/* icam tests */
+#ifdef ICAM_LCD_QOS
+	/*generator mode = 0 fixed mode=1 limiter */
+	writel(1, (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET +

LCD_QOS_MODE));

drivers/gpu/drm/kmb/kmb_drv.c line 299

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+	/* b/w */
+	writel(0x60, (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET +

LCD_QOS_BW));

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+
+	/* set priority.p1 */
+	val = readl(dev_p->icamlcd_mmio + ICAM_LCD_OFFSET +

LCD_QOS_PRORITY);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+	val &= ~(0x700);
+	writel(val | 0x100,
+	       (dev_p->icamlcd_mmio + ICAM_LCD_OFFSET +

LCD_QOS_PRORITY));

Quoted 15 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +15 -0
+
+	drm_info(&dev_p->drm,
+			"ICAM mode = 0x%x, priority = 0x%x bandwidth=0x%x",
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_MODE),
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_PRORITY),
+		 readl(dev_p->icamlcd_mmio + 0x1080 + LCD_QOS_BW));
+#endif
+	return 0;
+
+ irq_fail:
+	drm_crtc_cleanup(&dev_p->crtc);
+ setup_fail:
+	of_reserved_mem_device_release(drm->dev);
+
+	return ret;

drivers/gpu/drm/kmb/kmb_drv.c line 330

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+}
+
+int kmb_atomic_helper_check(struct drm_device *dev,
+			    struct drm_atomic_state *state)
+{
+	if (!state)
+		return 0;
+
+	return drm_atomic_helper_check(dev, state);
+}

I do not think this "if (!state)" gives us something extra - I think we are guranteed it is set here?
Daniel?

drivers/gpu/drm/kmb/kmb_drv.c line 340

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+static const struct drm_mode_config_funcs kmb_mode_config_funcs = {
+	.fb_create = drm_gem_fb_create,
+	.atomic_check = kmb_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
+
+static void kmb_setup_mode_config(struct drm_device *drm)
+{
+	drm_mode_config_init(drm);

Use drmm_mode_config - this will also simplify cleanup.

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+	drm->mode_config.min_width = KMB_MIN_WIDTH;
+	drm->mode_config.min_height = KMB_MIN_HEIGHT;
+	drm->mode_config.max_width = KMB_MAX_WIDTH;
+	drm->mode_config.max_height = KMB_MAX_HEIGHT;
+	drm->mode_config.funcs = &kmb_mode_config_funcs;
+}
+

drivers/gpu/drm/kmb/kmb_drv.c line 357

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+static irqreturn_t handle_lcd_irq(struct drm_device *dev)
+{
+	unsigned long status, val, val1;
+	int plane_id, dma0_state, dma1_state;
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+
+	status = kmb_read_lcd(dev_p, LCD_INT_STATUS);
+
+	if (status & LCD_INT_EOF) {
+		/* TODO - handle EOF interrupt? */

Is this TODO still valid?

Quoted 12 lines

drivers/gpu/drm/kmb/kmb_drv.c line 368

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +11 -0
+
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_EOF);
+
+		/* When disabling/enabling LCD layers, the change takes effect
+		 * immediately and does not wait for EOF (end of frame).
+		 * When kmb_plane_atomic_disable is called, mark the plane as
+		 * disabled but actually disable the plane when EOF irq is
+		 * being handled.
+		 */
+		for (plane_id = LAYER_0;
+				plane_id < KMB_MAX_PLANES; plane_id++) {

dev_p->n_layers and not KMB_MAX_PLANES?

Yeah - it's the same, but will change

Quoted 239 lines
Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +6 -0
+			if (plane_status[plane_id].disable) {
+				kmb_clr_bitmask_lcd(dev_p,
+						    LCD_LAYERn_DMA_CFG
+						    (plane_id),
+						    LCD_DMA_LAYER_ENABLE);
+

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+				kmb_clr_bitmask_lcd(dev_p, LCD_CONTROL,
+					    plane_status[plane_id].ctrl);
+
+				plane_status[plane_id].disable = false;
+			}
+		}
+		if (kmb_under_flow) {
+			/*DMA Recovery after underflow */
+			dma0_state = (layer_no == 0) ?
+			    LCD_VIDEO0_DMA0_STATE :

LCD_VIDEO1_DMA0_STATE;

drivers/gpu/drm/kmb/kmb_drv.c line 386

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+			dma1_state = (layer_no == 0) ?
+			    LCD_VIDEO0_DMA1_STATE :

LCD_VIDEO1_DMA1_STATE;

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+
+			do {
+				kmb_write_lcd(dev_p, LCD_FIFO_FLUSH, 1);
+				val = kmb_read_lcd(dev_p, dma0_state)
+				    & LCD_DMA_STATE_ACTIVE;
+				val1 = kmb_read_lcd(dev_p, dma1_state)
+				    & LCD_DMA_STATE_ACTIVE;
+			} while ((val || val1));
+			/*disable dma */
+			kmb_clr_bitmask_lcd(dev_p,

LCD_LAYERn_DMA_CFG(layer_no),

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +11 -0
+					    LCD_DMA_LAYER_ENABLE);
+			kmb_write_lcd(dev_p, LCD_FIFO_FLUSH, 1);
+			kmb_flush_done = 1;
+			kmb_under_flow = 0;
+		}
+
+	}
+
+	if (status & LCD_INT_LINE_CMP) {
+		/* clear line compare interrupt */
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_LINE_CMP);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	}
+
+	if (status & LCD_INT_VERT_COMP) {
+		/* Read VSTATUS */
+		val = kmb_read_lcd(dev_p, LCD_VSTATUS);
+		val = (val & LCD_VSTATUS_VERTICAL_STATUS_MASK);
+		switch (val) {
+		case LCD_VSTATUS_COMPARE_VSYNC:
+			/* Clear vertical compare interrupt */
+			kmb_write_lcd(dev_p, LCD_INT_CLEAR,

LCD_INT_VERT_COMP);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +13 -0
+			if (kmb_flush_done) {
+				kmb_set_bitmask_lcd(dev_p,
+						    LCD_LAYERn_DMA_CFG
+						    (layer_no),
+						    LCD_DMA_LAYER_ENABLE);
+				kmb_flush_done = 0;
+			}
+			drm_handle_vblank(dev, 0);
+			break;
+		case LCD_VSTATUS_COMPARE_BACKPORCH:
+		case LCD_VSTATUS_COMPARE_ACTIVE:
+		case LCD_VSTATUS_COMPARE_FRONT_PORCH:
+			kmb_write_lcd(dev_p, LCD_INT_CLEAR,

LCD_INT_VERT_COMP);

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +4 -0
+			break;
+		}
+	}
+	if (status & LCD_INT_DMA_ERR) {

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		val =
+		    (status & LCD_INT_DMA_ERR &
+		     kmb_read_lcd(dev_p, LCD_INT_ENABLE));
+		/* LAYER0 - VL0 */
+		if (val & (LAYER0_DMA_FIFO_UNDERFLOW |
+			   LAYER0_DMA_CB_FIFO_UNDERFLOW |
+			   LAYER0_DMA_CR_FIFO_UNDERFLOW)) {
+			kmb_under_flow++;
+			drm_info(&dev_p->drm,
+			    "!LAYER0:VL0 DMA UNDERFLOW val =

0x%lx,under_flow=%d",

drivers/gpu/drm/kmb/kmb_drv.c line 460

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+			     val, kmb_under_flow);
+			/*disable underflow inerrupt */
+			kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+					    LAYER0_DMA_FIFO_UNDERFLOW |
+

LAYER0_DMA_CB_FIFO_UNDERFLOW |

drivers/gpu/drm/kmb/kmb_drv.c line 450

Quoted 1 line
drivers/gpu/drm/kmb/kmb_drv.c new file +1 -0
+

LAYER0_DMA_CR_FIFO_UNDERFLOW);

drivers/gpu/drm/kmb/kmb_drv.c line 452

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+			kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR,
+

LAYER0_DMA_CB_FIFO_UNDERFLOW |

drivers/gpu/drm/kmb/kmb_drv.c line 454

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+					    LAYER0_DMA_FIFO_UNDERFLOW |
+

LAYER0_DMA_CR_FIFO_UNDERFLOW);

drivers/gpu/drm/kmb/kmb_drv.c line 456

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+			/*disable auto restart mode */
+			kmb_clr_bitmask_lcd(dev_p,

LCD_LAYERn_DMA_CFG(0),

drivers/gpu/drm/kmb/kmb_drv.c line 457

Quoted 1 line
drivers/gpu/drm/kmb/kmb_drv.c new file +1 -0
+

LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +6 -0
+			layer_no = 0;
+		}
+
+		if (val & LAYER0_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER0_DMA_CB_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA CB OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER0_DMA_CR_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER0:VL0 DMA CR OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +8 -0
+
+		/* LAYER1 - VL1 */
+		if (val & (LAYER1_DMA_FIFO_UNDERFLOW |
+			   LAYER1_DMA_CB_FIFO_UNDERFLOW |
+			   LAYER1_DMA_CR_FIFO_UNDERFLOW)) {
+			kmb_under_flow++;
+			drm_info(&dev_p->drm,
+			    "!LAYER1:VL1 DMA UNDERFLOW val = 0x%lx,

under_flow=%d",

drivers/gpu/drm/kmb/kmb_drv.c line 493

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+			     val, kmb_under_flow);
+			/*disable underflow inerrupt */
+			kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+					    LAYER1_DMA_FIFO_UNDERFLOW |
+

LAYER1_DMA_CB_FIFO_UNDERFLOW |

drivers/gpu/drm/kmb/kmb_drv.c line 483

Quoted 1 line
drivers/gpu/drm/kmb/kmb_drv.c new file +1 -0
+

LAYER1_DMA_CR_FIFO_UNDERFLOW);

drivers/gpu/drm/kmb/kmb_drv.c line 485

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+			kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR,
+

LAYER1_DMA_CB_FIFO_UNDERFLOW |

drivers/gpu/drm/kmb/kmb_drv.c line 487

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+					    LAYER1_DMA_FIFO_UNDERFLOW |
+

LAYER1_DMA_CR_FIFO_UNDERFLOW);

drivers/gpu/drm/kmb/kmb_drv.c line 489

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +2 -0
+			/*disable auto restart mode */
+			kmb_clr_bitmask_lcd(dev_p,

LCD_LAYERn_DMA_CFG(1),

drivers/gpu/drm/kmb/kmb_drv.c line 490

Quoted 1 line
drivers/gpu/drm/kmb/kmb_drv.c new file +1 -0
+

LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +7 -0
+			layer_no = 1;
+		}
+
+		/* LAYER1 - VL1 */
+		if (val & LAYER1_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER1_DMA_CB_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA CB OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER1_DMA_CR_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER1:VL1 DMA CR OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+
+		/* LAYER2 - GL0 */
+		if (val & LAYER2_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER2:GL0 DMA UNDERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER2_DMA_FIFO_OVERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER2:GL0 DMA OVERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +5 -0
+
+		/* LAYER3 - GL1 */
+		if (val & LAYER3_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER3:GL1 DMA UNDERFLOW val = 0x%lx",

val);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +3 -0
+		if (val & LAYER3_DMA_FIFO_UNDERFLOW)
+			drm_info(&dev_p->drm,
+				"LAYER3:GL1 DMA OVERFLOW val = 0x%lx",

val);

Quoted 34 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +34 -0
+	}
+
+	if (status & LCD_INT_LAYER) {
+		/* Clear layer interrupts */
+		kmb_write_lcd(dev_p, LCD_INT_CLEAR, LCD_INT_LAYER);
+	}
+
+	/* Clear all interrupts */
+	kmb_set_bitmask_lcd(dev_p, LCD_INT_CLEAR, 1);
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t kmb_isr(int irq, void *arg)
+{
+	struct drm_device *dev = (struct drm_device *)arg;
+	irqreturn_t ret = IRQ_NONE;
+
+	ret = handle_lcd_irq(dev);
+	return ret;
+}
+
+static void kmb_irq_reset(struct drm_device *drm)
+{
+	kmb_write_lcd(to_kmb(drm), LCD_INT_CLEAR, 0xFFFF);
+	kmb_write_lcd(to_kmb(drm), LCD_INT_ENABLE, 0);
+}
+
+DEFINE_DRM_GEM_CMA_FOPS(fops);
+
+static struct drm_driver kmb_driver = {
+	.driver_features = DRIVER_GEM |
+	    DRIVER_MODESET | DRIVER_ATOMIC,
+	.irq_handler = kmb_isr,
+	.irq_preinstall = kmb_irq_reset,

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	.irq_uninstall = kmb_irq_reset,
+	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_vm_ops = &drm_gem_cma_vm_ops,
+	.dumb_create = drm_gem_cma_dumb_create,
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table =

drm_gem_cma_prime_import_sg_table,

drivers/gpu/drm/kmb/kmb_drv.c line 573

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	.gem_prime_vmap = drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap = drm_gem_cma_prime_mmap,
+	.fops = &fops,
+	.name = "kmb-drm",
+	.desc = "KEEMBAY DISPLAY DRIVER ",
+	.date = "20190122",
+	.major = 1,
+	.minor = 0,
+};

kmb_driver needs a diet.
As a minimum introduce DRM_GEM_CMA_VMAP_DRIVER_OPS

Quoted 3 lines

gem_free_object_unlocked is deprecated - check drm_drv.h gem_prime_export likewise.
Check them all.

Done

Quoted 68 lines
Quoted 22 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +21 -0
+
+static void kmb_drm_unload(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *dev_p = to_kmb(drm);
+
+#ifdef DEBUG
+	dump_stack();
+#endif
+	drm_dev_unregister(drm);
+	drm_kms_helper_poll_fini(drm);
+	of_node_put(dev_p->crtc.port);
+	dev_p->crtc.port = NULL;
+	pm_runtime_get_sync(drm->dev);
+	drm_irq_uninstall(drm);
+	pm_runtime_put_sync(drm->dev);
+	pm_runtime_disable(drm->dev);
+
+	if (dev_p->lcd_mmio) {
+		iounmap(dev_p->lcd_mmio);
+		release_mem_region(LCD_BASE_ADDR, LCD_MMIO_SIZE);

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	}
+
+	if (dev_p->mipi_mmio) {
+		iounmap(dev_p->mipi_mmio);
+		release_mem_region(MIPI_BASE_ADDR, MIPI_MMIO_SIZE);
+	}
+
+	if (dev_p->msscam_mmio) {
+		iounmap(dev_p->msscam_mmio);
+		release_mem_region(MSS_CAM_BASE_ADDR,

MSS_CAM_MMIO_SIZE);

Quoted 35 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +35 -0
+	}
+
+	of_reserved_mem_device_release(drm->dev);
+	drm_mode_config_cleanup(drm);
+
+	/* Release clks */
+	kmb_display_clk_disable();
+	clk_put(clk_lcd);
+	clk_put(clk_mipi);
+
+	dev_set_drvdata(dev, NULL);
+
+	/* Unregister DSI host */
+	kmb_dsi_host_unregister();
+}
+
+static int kmb_probe(struct platform_device *pdev)
+{
+	struct device *dev = get_device(&pdev->dev);
+	struct kmb_drm_private *dev_p;
+	int ret = 0;
+
+	/* The bridge (ADV 7535) will return -EPROBE_DEFER until it
+	 * has a mipi_dsi_host to register its device to. So, we
+	 * first register the DSI host during probe time, and then return
+	 * -EPROBE_DEFER until the bridge is loaded. Probe will be called again
+	 *  and then the rest of the driver initialization can procees
+	 *  afterwards and the bridge can be successfully attached.
+	 */
+	adv_bridge = kmb_dsi_host_bridge_init(dev);
+
+	if (adv_bridge == ERR_PTR(-EPROBE_DEFER))
+		return -EPROBE_DEFER;
+	else if (IS_ERR(adv_bridge)) {
+		DRM_ERROR("probe failed to initialize DSI host bridge\n");
Quoted 8 lines

drivers/gpu/drm/kmb/kmb_drv.c line 645

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +6 -0
+		return PTR_ERR(adv_bridge);
+	}
+
+	/* Create DRM device */
+	dev_p = devm_drm_dev_alloc(dev, &kmb_driver,
+			struct kmb_drm_private, drm);

Use devm_drm_dev_init()
See example in drm_drv.c for more info.

Correct me if I am wrong, __devm_drm_dev_alloc() calls devm_drm_dev_init()

Quoted 6 lines

drivers/gpu/drm/kmb/kmb_drv.c line 649

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +4 -0
+	if (IS_ERR(dev_p))
+		return PTR_ERR(dev_p);
+
+	dev_p->drm.dev_private = dev_p;

dev_private is deprecated - drop it.

ok

Quoted 296 lines
Quoted 56 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +17 -0
+	dev_set_drvdata(dev, &dev_p->drm);
+
+	kmb_setup_mode_config(&dev_p->drm);
+	dev_set_drvdata(dev, &dev_p->drm);
+
+	/* Load driver */
+	dev_p->n_layers = KMB_MAX_PLANES;
+	ret = kmb_load(&dev_p->drm, 0);
+	if (ret == -EPROBE_DEFER) {
+		drm_info(&dev_p->drm, "wait for external bridge driver DT\n");
+		return -EPROBE_DEFER;
+	} else if (ret)
+		goto err_free;
+
+	/* Set the CRTC's port so that the encoder component can find it */
+	dev_p->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);
+	ret = drm_vblank_init(&dev_p->drm, dev_p-

drm.mode_config.num_crtc);

drivers/gpu/drm/kmb/kmb_drv.c new file +37 -0
+	drm_info(&dev_p->drm, "mode_config.num_crtc=%d\n",
+			dev_p->drm.mode_config.num_crtc);
+	if (ret < 0) {
+		drm_err(&dev_p->drm, "failed to initialize vblank\n");
+		goto err_vblank;
+	}
+
+	drm_mode_config_reset(&dev_p->drm);
+	drm_kms_helper_poll_init(&dev_p->drm);
+
+	/* Register graphics device with the kernel */
+	ret = drm_dev_register(&dev_p->drm, 0);
+
+	if (ret)
+		goto err_register;
+
+	return 0;
+
+ err_register:
+	drm_kms_helper_poll_fini(&dev_p->drm);
+ err_vblank:
+	pm_runtime_disable(dev_p->drm.dev);
+ err_free:
+	drm_mode_config_cleanup(&dev_p->drm);
+	dev_set_drvdata(dev, NULL);
+	kmb_dsi_host_unregister();
+
+	return ret;
+}
+
+static int kmb_remove(struct platform_device *pdev)
+{
+	kmb_drm_unload(&pdev->dev);
+	return 0;
+}
+
+static const struct of_device_id kmb_of_match[] = {

drivers/gpu/drm/kmb/kmb_drv.c line 713

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+	{.compatible = "intel,kmb_display"},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, kmb_of_match);
+
+static int __maybe_unused kmb_pm_suspend(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *lcd = drm ? drm->dev_private : NULL;

Use of dev_private is deprecated - drop it.

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +9 -0
+
+	if (!lcd)
+		return 0;
+
+	drm_kms_helper_poll_disable(drm);
+
+	lcd->state = drm_atomic_helper_suspend(drm);
+	if (IS_ERR(lcd->state)) {
+		drm_kms_helper_poll_enable(drm);

drivers/gpu/drm/kmb/kmb_drv.c line 732

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +10 -0
+		return PTR_ERR(lcd->state);
+	}
+
+	return 0;
+}
+
+static int __maybe_unused kmb_pm_resume(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+	struct kmb_drm_private *lcd = drm ? drm->dev_private : NULL;

Use of dev_private is deprecated - drop it.

drivers/gpu/drm/kmb/kmb_drv.c

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +11 -0
+
+	if (!lcd)
+		return 0;
+
+	drm_atomic_helper_resume(drm, lcd->state);
+	drm_kms_helper_poll_enable(drm);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(kmb_pm_ops, kmb_pm_suspend,

kmb_pm_resume);

Review

Quoted 17 lines
drivers/gpu/drm/kmb/kmb_drv.c new file +16 -0
+
+static struct platform_driver kmb_platform_driver = {
+	.probe = kmb_probe,
+	.remove = kmb_remove,
+	.driver = {
+		   .name = "kmb-drm",
+		   .pm = &kmb_pm_ops,
+		   .of_match_table = kmb_of_match,
+		   },
+};
+
+module_platform_driver(kmb_platform_driver);
+
+MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION("Keembay Display driver");
+MODULE_LICENSE("GPL v2");
(quoted diff) +0 -0

b/drivers/gpu/drm/kmb/kmb_drv.h

Quoted 79 lines

new file mode 100644
index 0000000..3bc07bc

drivers/gpu/drm/kmb/kmb_drv.h new file +74 -0
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (c) 2018-2020 Intel Corporation
+ */
+
+#ifndef __KMB_DRV_H__
+#define __KMB_DRV_H__
+
+#include "kmb_regs.h"
+
+#define KMB_MAX_WIDTH			1920 /*max width in pixels */
+#define KMB_MAX_HEIGHT			1080 /*max height in pixels */
+#define KMB_MIN_WIDTH                   1920 /*max width in pixels */
+#define KMB_MIN_HEIGHT                  1080 /*max height in pixels */
+#define KMB_LCD_DEFAULT_CLK		200000000
+#define KMB_MIPI_DEFAULT_CLK		24000000
+#define KMB_MIPI_DEFAULT_CFG_CLK	24000000
+#define KMB_SYS_CLK_MHZ			500
+
+#define crtc_to_kmb_priv(x)	container_of(x, struct kmb_drm_private, crtc)
+
+#define ICAM_MMIO		0x3b100000
+#define ICAM_LCD_OFFSET		0x1080
+#define ICAM_MMIO_SIZE		0x2000
+struct kmb_drm_private {
+	struct drm_device		drm;
+	void __iomem			*lcd_mmio;
+	void __iomem			*mipi_mmio;
+	void __iomem			*msscam_mmio;
+	void __iomem                    *icamlcd_mmio;
+	unsigned char			n_layers;
+	struct clk			*clk;
+	struct drm_crtc			crtc;
+	struct kmb_plane		*plane;
+	struct drm_atomic_state		*state;
+	spinlock_t			irq_lock;
+	int				irq_lcd;
+	int				irq_mipi;
+	int				sys_clk_mhz;
+	dma_addr_t			fb_addr;
+};
+
+static inline struct kmb_drm_private *to_kmb(const struct drm_device *dev)
+{
+	return container_of(dev, struct kmb_drm_private, drm);
+}
+
+struct blt_layer_config {
+	unsigned char layer_format;
+};
+
+static inline void kmb_write_lcd(struct kmb_drm_private *dev_p,
+				 unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->lcd_mmio + reg));
+}
+
+static inline void kmb_write_mipi(struct kmb_drm_private *dev_p,
+				  unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->mipi_mmio + reg));
+}
+
+static inline void kmb_write_msscam(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 value)
+{
+	writel(value, (dev_p->msscam_mmio + reg));
+}
+
+static inline u32 kmb_read_msscam(struct kmb_drm_private *dev_p,
+				  unsigned int reg)
+{
+	return readl(dev_p->msscam_mmio + reg);
+}

drivers/gpu/drm/kmb/kmb_drv.h line 84

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +10 -0
+
+static inline void kmb_set_bitmask_msscam(struct kmb_drm_private *dev_p,
+					  unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_msscam(dev_p, reg);
+
+	kmb_write_msscam(dev_p, reg, (reg_val | mask));
+}
+
+static inline u32 kmb_read_lcd(struct kmb_drm_private *dev_p, unsigned int

reg)

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +11 -0
+{
+	return readl(dev_p->lcd_mmio + reg);
+}
+
+static inline void kmb_set_bitmask_lcd(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_lcd(dev_p, reg);
+
+	kmb_write_lcd(dev_p, reg, (reg_val | mask));
+}

drivers/gpu/drm/kmb/kmb_drv.h

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +10 -0
+
+static inline void kmb_clr_bitmask_lcd(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_lcd(dev_p, reg);
+
+	kmb_write_lcd(dev_p, reg, (reg_val & (~mask)));
+}
+
+static inline u32 kmb_read_mipi(struct kmb_drm_private *dev_p, unsigned int

reg)

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +8 -0
+{
+	return readl(dev_p->mipi_mmio + reg);
+}
+
+static inline void kmb_write_bits_mipi(struct kmb_drm_private *dev_p,
+				       unsigned int reg, u32 offset,
+				       u32 num_bits, u32 value)
+{

drivers/gpu/drm/kmb/kmb_drv.h

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +10 -0
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+	u32 mask = (1 << num_bits) - 1;
+
+	value &= mask;
+	mask <<= offset;
+	reg_val &= (~mask);
+	reg_val |= (value << offset);
+#ifdef DEBUG
+	if (reg == DPHY_FREQ_CTRL0_3 + 4) {
+		DRM_INFO("%s : %d  reg=0x%x offset=%d num_bits=%d

val=0x%x\n",

Quoted 32 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +32 -0
+			 __func__, __LINE__, reg, offset, num_bits,
+			 reg_val);
+	}
+#endif
+	kmb_write_mipi(dev_p, reg, reg_val);
+}
+
+static inline void kmb_set_bit_mipi(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 offset)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, reg_val | (1 << offset));
+}
+
+static inline void kmb_clr_bit_mipi(struct kmb_drm_private *dev_p,
+				    unsigned int reg, u32 offset)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, reg_val & (~(1 << offset)));
+}
+
+static inline void kmb_set_bitmask_mipi(struct kmb_drm_private *dev_p,
+					unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, (reg_val | mask));
+}
+
+static inline void kmb_clr_bitmask_mipi(struct kmb_drm_private *dev_p,

drivers/gpu/drm/kmb/kmb_drv.h line 165

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_drv.h new file +10 -0
+					unsigned int reg, u32 mask)
+{
+	u32 reg_val = kmb_read_mipi(dev_p, reg);
+
+	kmb_write_mipi(dev_p, reg, (reg_val & (~mask)));
+}
+
+int kmb_setup_crtc(struct drm_device *dev);
+void kmb_set_scanout(struct kmb_drm_private *lcd);
+#endif /* __KMB_DRV_H__ */

All the kmb_dsi looks like it should be implmented as a real bridge driver. And it should use the modern bridge interface - so the connectro creation should be part of the display driver and not the bridge.

Quoted 5 lines

See for example adv5511 for an example.

As I expect the parts where I can review will change I skipped this file
for now.
Like I had said in the beginning, mipi dsi is part of the soc and its programming is closely linked with that of the LCD controller(it's very timing sensitive). It cannot be a bridge driver.

Let's keep it as connector.

Quoted 3,826 lines
Quoted 22 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +16 -0
new file mode 100644
index 0000000..eaddf20
@@ -0,0 +1,1833 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2019-2020 Intel Corporation
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_edid.h>
+#include <drm/drm_mipi_dsi.h>

drivers/gpu/drm/kmb/kmb_dsi.c line 26

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include "kmb_drv.h"
+#include "kmb_dsi.h"
+#include "kmb_regs.h"
+
+static int hw_initialized;
+//#define MIPI_TX_TEST_PATTERN_GENERATION
+//#define DPHY_GET_FSM
+//#define DPHY_READ_TESTCODE

Debug stuff - delete?

drivers/gpu/drm/kmb/kmb_dsi.c line 29

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +3 -0
+
+static struct mipi_dsi_host *dsi_host;
+static struct mipi_dsi_device *dsi_device;

Should be in an advxxxx struct that is allocated in the probe() function of the bridge driver.

Quoted 190 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +190 -0
+
+/* Default setting is 1080p, 4 lanes */
+#define IMG_HEIGHT_LINES  1080
+#define IMG_WIDTH_PX      1920
+#define MIPI_TX_ACTIVE_LANES 4
+
+struct mipi_tx_frame_section_cfg mipi_tx_frame0_sect_cfg = {
+	.width_pixels = IMG_WIDTH_PX,
+	.height_lines = IMG_HEIGHT_LINES,
+	.data_type = DSI_LP_DT_PPS_RGB888_24B,
+	.data_mode = MIPI_DATA_MODE1,
+	.dma_packed = 0
+};
+
+struct mipi_tx_frame_cfg mipitx_frame0_cfg = {
+	.sections[0] = &mipi_tx_frame0_sect_cfg,
+	.sections[1] = NULL,
+	.sections[2] = NULL,
+	.sections[3] = NULL,
+	.vsync_width = 5,
+	.v_backporch = 36,
+	.v_frontporch = 4,
+	.hsync_width = 44,
+	.h_backporch = 148,
+	.h_frontporch = 88
+};
+
+struct mipi_tx_dsi_cfg mipitx_dsi_cfg = {
+	.hfp_blank_en = 0,
+	.eotp_en = 0,
+	.lpm_last_vfp_line = 0,
+	.lpm_first_vsa_line = 0,
+	.sync_pulse_eventn = DSI_VIDEO_MODE_NO_BURST_EVENT,
+	.hfp_blanking = SEND_BLANK_PACKET,
+	.hbp_blanking = SEND_BLANK_PACKET,
+	.hsa_blanking = SEND_BLANK_PACKET,
+	.v_blanking = SEND_BLANK_PACKET,
+};
+
+struct mipi_ctrl_cfg mipi_tx_init_cfg = {
+	.index = MIPI_CTRL6,
+	.type = MIPI_DSI,
+	.dir = MIPI_TX,
+	.active_lanes = MIPI_TX_ACTIVE_LANES,
+	.lane_rate_mbps = MIPI_TX_LANE_DATA_RATE_MBPS,
+	.ref_clk_khz = MIPI_TX_REF_CLK_KHZ,
+	.cfg_clk_khz = MIPI_TX_CFG_CLK_KHZ,
+	.data_if = MIPI_IF_PARALLEL,
+	.tx_ctrl_cfg = {
+			.frames[0] = &mipitx_frame0_cfg,
+			.frames[1] = NULL,
+			.frames[2] = NULL,
+			.frames[3] = NULL,
+			.tx_dsi_cfg = &mipitx_dsi_cfg,
+			.line_sync_pkt_en = 0,
+			.line_counter_active = 0,
+			.frame_counter_active = 0,
+			.tx_always_use_hact = 1,
+			.tx_hact_wait_stop = 1,
+			}
+};
+
+struct  mipi_hs_freq_range_cfg {
+	uint16_t default_bit_rate_mbps;
+	uint8_t hsfreqrange_code;
+};
+
+struct vco_params {
+	u32 freq;
+	u32 range;
+	u32 divider;
+};
+
+static struct vco_params vco_table[] = {
+	{52, 0x3f, 8},
+	{80, 0x39, 8},
+	{105, 0x2f, 4},
+	{160, 0x29, 4},
+	{210, 0x1f, 2},
+	{320, 0x19, 2},
+	{420, 0x0f, 1},
+	{630, 0x09, 1},
+	{1100, 0x03, 1},
+	{0xffff, 0x01, 1},
+};
+
+static struct mipi_hs_freq_range_cfg
+mipi_hs_freq_range[MIPI_DPHY_DEFAULT_BIT_RATES] = {
+	{.default_bit_rate_mbps = 80, .hsfreqrange_code = 0x00},
+	{.default_bit_rate_mbps = 90, .hsfreqrange_code = 0x10},
+	{.default_bit_rate_mbps = 100, .hsfreqrange_code = 0x20},
+	{.default_bit_rate_mbps = 110, .hsfreqrange_code = 0x30},
+	{.default_bit_rate_mbps = 120, .hsfreqrange_code = 0x01},
+	{.default_bit_rate_mbps = 130, .hsfreqrange_code = 0x11},
+	{.default_bit_rate_mbps = 140, .hsfreqrange_code = 0x21},
+	{.default_bit_rate_mbps = 150, .hsfreqrange_code = 0x31},
+	{.default_bit_rate_mbps = 160, .hsfreqrange_code = 0x02},
+	{.default_bit_rate_mbps = 170, .hsfreqrange_code = 0x12},
+	{.default_bit_rate_mbps = 180, .hsfreqrange_code = 0x22},
+	{.default_bit_rate_mbps = 190, .hsfreqrange_code = 0x32},
+	{.default_bit_rate_mbps = 205, .hsfreqrange_code = 0x03},
+	{.default_bit_rate_mbps = 220, .hsfreqrange_code = 0x13},
+	{.default_bit_rate_mbps = 235, .hsfreqrange_code = 0x23},
+	{.default_bit_rate_mbps = 250, .hsfreqrange_code = 0x33},
+	{.default_bit_rate_mbps = 275, .hsfreqrange_code = 0x04},
+	{.default_bit_rate_mbps = 300, .hsfreqrange_code = 0x14},
+	{.default_bit_rate_mbps = 325, .hsfreqrange_code = 0x25},
+	{.default_bit_rate_mbps = 350, .hsfreqrange_code = 0x35},
+	{.default_bit_rate_mbps = 400, .hsfreqrange_code = 0x05},
+	{.default_bit_rate_mbps = 450, .hsfreqrange_code = 0x16},
+	{.default_bit_rate_mbps = 500, .hsfreqrange_code = 0x26},
+	{.default_bit_rate_mbps = 550, .hsfreqrange_code = 0x37},
+	{.default_bit_rate_mbps = 600, .hsfreqrange_code = 0x07},
+	{.default_bit_rate_mbps = 650, .hsfreqrange_code = 0x18},
+	{.default_bit_rate_mbps = 700, .hsfreqrange_code = 0x28},
+	{.default_bit_rate_mbps = 750, .hsfreqrange_code = 0x39},
+	{.default_bit_rate_mbps = 800, .hsfreqrange_code = 0x09},
+	{.default_bit_rate_mbps = 850, .hsfreqrange_code = 0x19},
+	{.default_bit_rate_mbps = 900, .hsfreqrange_code = 0x29},
+	{.default_bit_rate_mbps = 1000, .hsfreqrange_code = 0x0A},
+	{.default_bit_rate_mbps = 1050, .hsfreqrange_code = 0x1A},
+	{.default_bit_rate_mbps = 1100, .hsfreqrange_code = 0x2A},
+	{.default_bit_rate_mbps = 1150, .hsfreqrange_code = 0x3B},
+	{.default_bit_rate_mbps = 1200, .hsfreqrange_code = 0x0B},
+	{.default_bit_rate_mbps = 1250, .hsfreqrange_code = 0x1B},
+	{.default_bit_rate_mbps = 1300, .hsfreqrange_code = 0x2B},
+	{.default_bit_rate_mbps = 1350, .hsfreqrange_code = 0x3C},
+	{.default_bit_rate_mbps = 1400, .hsfreqrange_code = 0x0C},
+	{.default_bit_rate_mbps = 1450, .hsfreqrange_code = 0x1C},
+	{.default_bit_rate_mbps = 1500, .hsfreqrange_code = 0x2C},
+	{.default_bit_rate_mbps = 1550, .hsfreqrange_code = 0x3D},
+	{.default_bit_rate_mbps = 1600, .hsfreqrange_code = 0x0D},
+	{.default_bit_rate_mbps = 1650, .hsfreqrange_code = 0x1D},
+	{.default_bit_rate_mbps = 1700, .hsfreqrange_code = 0x2E},
+	{.default_bit_rate_mbps = 1750, .hsfreqrange_code = 0x3E},
+	{.default_bit_rate_mbps = 1800, .hsfreqrange_code = 0x0E},
+	{.default_bit_rate_mbps = 1850, .hsfreqrange_code = 0x1E},
+	{.default_bit_rate_mbps = 1900, .hsfreqrange_code = 0x2F},
+	{.default_bit_rate_mbps = 1950, .hsfreqrange_code = 0x3F},
+	{.default_bit_rate_mbps = 2000, .hsfreqrange_code = 0x0F},
+	{.default_bit_rate_mbps = 2050, .hsfreqrange_code = 0x40},
+	{.default_bit_rate_mbps = 2100, .hsfreqrange_code = 0x41},
+	{.default_bit_rate_mbps = 2150, .hsfreqrange_code = 0x42},
+	{.default_bit_rate_mbps = 2200, .hsfreqrange_code = 0x43},
+	{.default_bit_rate_mbps = 2250, .hsfreqrange_code = 0x44},
+	{.default_bit_rate_mbps = 2300, .hsfreqrange_code = 0x45},
+	{.default_bit_rate_mbps = 2350, .hsfreqrange_code = 0x46},
+	{.default_bit_rate_mbps = 2400, .hsfreqrange_code = 0x47},
+	{.default_bit_rate_mbps = 2450, .hsfreqrange_code = 0x48},
+	{.default_bit_rate_mbps = 2500, .hsfreqrange_code = 0x49}
+};
+
+union mipi_irq_cfg int_cfg = {
+	.irq_cfg.frame_done = 1,
+	.irq_cfg.ctrl_error = 1,
+};
+
+static enum drm_mode_status
+kmb_dsi_mode_valid(struct drm_connector *connector,
+		   struct drm_display_mode *mode)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_mode_config *mode_config = &dev->mode_config;
+
+	if (mode->hdisplay < mode_config->min_width ||
+			mode->hdisplay > mode_config->max_width)
+		return MODE_BAD_HVALUE;
+
+	if (mode->vdisplay < mode_config->min_height ||
+			mode->vdisplay > mode_config->max_height)
+		return MODE_BAD_VVALUE;
+
+	return MODE_OK;
+}
+
+static int kmb_dsi_get_modes(struct drm_connector *connector)
+{
+	int num_modes = 0;
+
+	num_modes = drm_add_modes_noedid(connector,
+			 connector->dev->mode_config.max_width,
+			 connector->dev->mode_config.max_height);
+
+	DRM_INFO("width=%d height=%d\n",
+		 connector->dev->mode_config.max_width,
+		 connector->dev->mode_config.max_height);
+	DRM_INFO("num modes=%d\n", num_modes);
+
+	return num_modes;
+}

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+void kmb_dsi_host_unregister(void)
+{
+	mipi_dsi_host_unregister(dsi_host);
+	kfree(dsi_host);
+}
+
+static void kmb_dsi_connector_destroy(struct drm_connector *connector)
+{
+	struct kmb_connector *kmb_connector =

to_kmb_connector(connector);

Quoted 29 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +29 -0
+
+	drm_connector_cleanup(connector);
+	kfree(kmb_connector);
+}
+
+static void kmb_dsi_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct kmb_dsi *kmb_dsi = to_kmb_dsi(encoder);
+
+	if (!kmb_dsi)
+		return;
+
+	kfree(kmb_dsi->dsi_host);
+
+	drm_encoder_cleanup(encoder);
+
+	kmb_dsi_connector_destroy(&kmb_dsi->attached_connector->base);
+
+	kfree(kmb_dsi);
+	if (!dsi_device)
+		kfree(dsi_device);
+}
+
+static const struct drm_encoder_funcs kmb_dsi_funcs = {
+	.destroy = kmb_dsi_encoder_destroy,
+};
+
+static const struct
+drm_connector_helper_funcs kmb_dsi_connector_helper_funcs = {

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+	.get_modes = kmb_dsi_get_modes,
+	.mode_valid = kmb_dsi_mode_valid,
+};
+
+static const struct drm_connector_funcs kmb_dsi_connector_funcs = {
+	.destroy = kmb_dsi_connector_destroy,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.reset = drm_atomic_helper_connector_reset,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.atomic_duplicate_state =

drm_atomic_helper_connector_duplicate_state,

Quoted 97 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +97 -0
+};
+
+static ssize_t kmb_dsi_host_transfer(struct mipi_dsi_host *host,
+				     const struct mipi_dsi_msg *msg)
+{
+	return 0;
+}
+
+static int kmb_dsi_host_attach(struct mipi_dsi_host *host,
+			       struct mipi_dsi_device *dev)
+{
+	return 0;
+}
+
+static int kmb_dsi_host_detach(struct mipi_dsi_host *host,
+			       struct mipi_dsi_device *dev)
+{
+	return 0;
+}
+
+static const struct mipi_dsi_host_ops kmb_dsi_host_ops = {
+	.attach = kmb_dsi_host_attach,
+	.detach = kmb_dsi_host_detach,
+	.transfer = kmb_dsi_host_transfer,
+};
+
+static struct kmb_dsi_host *kmb_dsi_host_init(struct drm_device *drm,
+					      struct kmb_dsi *kmb_dsi)
+{
+	struct kmb_dsi_host *host;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->base = dsi_host;
+	host->base->ops = &kmb_dsi_host_ops;
+	host->kmb_dsi = kmb_dsi;
+
+	host->base->dev = drm->dev;
+
+	dsi_device->host = host->base;
+	host->device = dsi_device;
+	return host;
+}
+
+struct drm_bridge *kmb_dsi_host_bridge_init(struct device *dev)
+{
+	struct drm_bridge *bridge = NULL;
+	struct device_node *encoder_node;
+
+	/* Create and register MIPI DSI host */
+	if (!dsi_host) {
+		dsi_host = kzalloc(sizeof(*dsi_host), GFP_KERNEL);
+		if (!dsi_host)
+			return ERR_PTR(-ENOMEM);
+
+		dsi_host->ops = &kmb_dsi_host_ops;
+
+		if (!dsi_device) {
+			dsi_device = kzalloc(sizeof(*dsi_device), GFP_KERNEL);
+			if (!dsi_device) {
+				kfree(dsi_host);
+				return ERR_PTR(-ENOMEM);
+			}
+		}
+
+		dsi_host->dev = dev;
+		mipi_dsi_host_register(dsi_host);
+	}
+	/* Find ADV7535 node and initialize it */
+	encoder_node = of_parse_phandle(dev->of_node, "encoder-slave", 0);
+
+	if (!encoder_node) {
+		DRM_ERROR("Failed to get bridge info from DT\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* Locate drm bridge from the hdmi encoder DT node */
+	bridge = of_drm_find_bridge(encoder_node);
+	of_node_put(encoder_node);
+	if (!bridge) {
+		DRM_INFO("Wait for external bridge driver DT\n");
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+	return bridge;
+}
+
+u32 mipi_get_datatype_params(u32 data_type, u32 data_mode,
+			     struct mipi_data_type_params *params)
+{
+	struct mipi_data_type_params data_type_param;
+
+	switch (data_type) {
+	case DSI_LP_DT_PPS_YCBCR420_12B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 3;

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		switch (data_mode) {
+			/* Case 0 not supported according to MDK */
+		case 1:
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 24;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n",

data_mode);

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_YCBCR422_16B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 4;
+		switch (data_mode) {
+			/* Case 0 and 1 not supported according
+			 * to MDK
+			 */

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		case 2:
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 16;
+			break;
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 32;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n",

data_mode);

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +7 -0
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_LPPS_YCBCR422_20B:
+	case DSI_LP_DT_PPS_YCBCR422_24B:
+		data_type_param.size_constraint_pixels = 2;
+		data_type_param.size_constraint_bytes = 6;

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		switch (data_mode) {
+			/* Case 0 not supported according to MDK */
+		case 1:
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 24;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n",

data_mode);

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +9 -0
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_RGB565_16B:
+		data_type_param.size_constraint_pixels = 1;
+		data_type_param.size_constraint_bytes = 2;
+		switch (data_mode) {
+		case 0:
+		case 1:

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+			data_type_param.pixels_per_pclk = 1;
+			data_type_param.bits_per_pclk = 16;
+			break;
+		case 2:
+		case 3:
+			data_type_param.pixels_per_pclk = 2;
+			data_type_param.bits_per_pclk = 32;
+			break;
+		default:
+			DRM_ERROR("DSI: Invalid data_mode %d\n",

data_mode);

Quoted 88 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +88 -0
+			return -EINVAL;
+		};
+		break;
+	case DSI_LP_DT_PPS_RGB666_18B:
+		data_type_param.size_constraint_pixels = 4;
+		data_type_param.size_constraint_bytes = 9;
+		data_type_param.bits_per_pclk = 18;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	case DSI_LP_DT_LPPS_RGB666_18B:
+	case DSI_LP_DT_PPS_RGB888_24B:
+		data_type_param.size_constraint_pixels = 1;
+		data_type_param.size_constraint_bytes = 3;
+		data_type_param.bits_per_pclk = 24;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	case DSI_LP_DT_PPS_RGB101010_30B:
+		data_type_param.size_constraint_pixels = 4;
+		data_type_param.size_constraint_bytes = 15;
+		data_type_param.bits_per_pclk = 30;
+		data_type_param.pixels_per_pclk = 1;
+		break;
+	default:
+		DRM_ERROR("DSI: Invalid data_type %d\n", data_type);
+		return -EINVAL;
+	};
+
+	*params = data_type_param;
+	return 0;
+}
+
+static u32 compute_wc(u32 width_px, u8 size_constr_p, u8 size_constr_b)
+{
+	/* Calculate the word count for each long packet */
+	return (((width_px / size_constr_p) * size_constr_b) & 0xffff);
+}
+
+static u32 compute_unpacked_bytes(u32 wc, u8 bits_per_pclk)
+{
+	/* Number of PCLK cycles needed to transfer a line
+	 * with each PCLK cycle, 4 Bytes are sent through the PPL module
+	 */
+	return ((wc * 8) / bits_per_pclk) * 4;
+}
+
+static u32 mipi_tx_fg_section_cfg_regs(struct kmb_drm_private *dev_p,
+				       u8 frame_id, u8 section,
+				       u32 height_lines, u32 unpacked_bytes,
+				       struct mipi_tx_frame_sect_phcfg *ph_cfg)
+{
+	u32 cfg = 0;
+	u32 ctrl_no = MIPI_CTRL6;
+	u32 reg_adr;
+
+	/* Frame section packet header */
+	/* Word count bits [15:0] */
+	cfg = (ph_cfg->wc & MIPI_TX_SECT_WC_MASK) << 0;
+
+	/* Data type (bits [21:16]) */
+	cfg |= ((ph_cfg->data_type & MIPI_TX_SECT_DT_MASK)
+		<< MIPI_TX_SECT_DT_SHIFT);
+
+	/* Virtual channel (bits [23:22]) */
+	cfg |= ((ph_cfg->vchannel & MIPI_TX_SECT_VC_MASK)
+		<< MIPI_TX_SECT_VC_SHIFT);
+
+	/* Data mode (bits [24:25]) */
+	cfg |= ((ph_cfg->data_mode & MIPI_TX_SECT_DM_MASK)
+		<< MIPI_TX_SECT_DM_SHIFT);
+	if (ph_cfg->dma_packed)
+		cfg |= MIPI_TX_SECT_DMA_PACKED;
+
+	drm_dbg(&dev_p->drm,
+		 "ctrl=%d frame_id=%d section=%d cfg=%x packed=%d\n",
+		  ctrl_no, frame_id, section, cfg, ph_cfg->dma_packed);
+	kmb_write_mipi(dev_p,
+		       (MIPI_TXm_HS_FGn_SECTo_PH(ctrl_no, frame_id, section)),
+		       cfg);
+
+	/* Unpacked bytes */
+
+	/* There are 4 frame generators and each fg has 4 sections
+	 * There are 2 registers for unpacked bytes (# bytes each
+	 * section occupies in memory)
+	 * REG_UNPACKED_BYTES0: [15:0]-BYTES0, [31:16]-BYTES1
+	 * REG_UNPACKED_BYTES1: [15:0]-BYTES2, [31:16]-BYTES3
+	 */
+	reg_adr =

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+	    MIPI_TXm_HS_FGn_SECT_UNPACKED_BYTES0(ctrl_no,
+						 frame_id) + (section / 2) * 4;
+	kmb_write_bits_mipi(dev_p, reg_adr, (section % 2) * 16, 16,
+			    unpacked_bytes);
+	drm_dbg(&dev_p->drm,
+		 "unpacked_bytes = %d, wordcount = %d\n", unpacked_bytes,
+		  ph_cfg->wc);
+
+	/* Line config */
+	reg_adr = MIPI_TXm_HS_FGn_SECTo_LINE_CFG(ctrl_no, frame_id,

section);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +7 -0
+	kmb_write_mipi(dev_p, reg_adr, height_lines);
+	return 0;
+}
+
+static u32 mipi_tx_fg_section_cfg(struct kmb_drm_private *dev_p,
+				  u8 frame_id, u8 section,
+				  struct mipi_tx_frame_section_cfg

*frame_scfg,

Quoted 32 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +32 -0
+				  u32 *bits_per_pclk, u32 *wc)
+{
+	u32 ret = 0;
+	u32 unpacked_bytes;
+	struct mipi_data_type_params data_type_parameters;
+	struct mipi_tx_frame_sect_phcfg ph_cfg;
+
+	ret = mipi_get_datatype_params(frame_scfg->data_type,
+				       frame_scfg->data_mode,
+				       &data_type_parameters);
+	if (ret)
+		return ret;
+
+	/* Packet width has to be a multiple of the minimum packet width
+	 * (in pixels) set for each data type
+	 */
+	if (frame_scfg->width_pixels %
+	    data_type_parameters.size_constraint_pixels != 0)
+		return -EINVAL;
+
+	*wc = compute_wc(frame_scfg->width_pixels,
+			 data_type_parameters.size_constraint_pixels,
+			 data_type_parameters.size_constraint_bytes);
+	unpacked_bytes = compute_unpacked_bytes(*wc,
+					data_type_parameters.bits_per_pclk);
+	ph_cfg.wc = *wc;
+	ph_cfg.data_mode = frame_scfg->data_mode;
+	ph_cfg.data_type = frame_scfg->data_type;
+	ph_cfg.dma_packed = frame_scfg->dma_packed;
+	ph_cfg.vchannel = frame_id;
+
+	mipi_tx_fg_section_cfg_regs(dev_p, frame_id, section,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+				    frame_scfg->height_lines,
+				    unpacked_bytes, &ph_cfg);
+
+	/* Caller needs bits_per_clk for additional caluclations */
+	*bits_per_pclk = data_type_parameters.bits_per_pclk;
+
+	return 0;
+}
+
+static void mipi_tx_fg_cfg_regs(struct kmb_drm_private *dev_p, u8

frame_gen,

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +13 -0
+				struct mipi_tx_frame_timing_cfg *fg_cfg)
+{
+	u32 sysclk;
+	u32 ppl_llp_ratio;
+	u32 ctrl_no = MIPI_CTRL6, reg_adr, val, offset;
+
+	/* 500 Mhz system clock minus 50 to account for the difference in
+	 * MIPI clock speed in RTL tests
+	 */
+	sysclk = dev_p->sys_clk_mhz - 50;
+
+	/* PPL-Pixel Packing Layer, LLP-Low Level Protocol
+	 * Frame genartor timing parameters are clocked on the system clock,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+	 * whereas as the equivalent parameters in the LLP blocks are clocked
+	 * on LLP Tx clock from the D-PHY - BYTE clock
+	 */
+
+	/* Multiply by 1000 to maintain precision */
+	ppl_llp_ratio = ((fg_cfg->bpp / 8) * sysclk * 1000) /
+	    ((fg_cfg->lane_rate_mbps / 8) * fg_cfg->active_lanes);
+
+	drm_dbg(&dev_p->drm, "ppl_llp_ratio=%d\n", ppl_llp_ratio);
+	drm_dbg(&dev_p->drm, "bpp=%d sysclk=%d lane-rate=%d activ-

lanes=%d\n",

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +11 -0
+		 fg_cfg->bpp, sysclk, fg_cfg->lane_rate_mbps,
+		 fg_cfg->active_lanes);
+
+	/* Frame generator number of lines */
+	reg_adr = MIPI_TXm_HS_FGn_NUM_LINES(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->v_active);
+
+	/* vsync width
+	 * There are 2 registers for vsync width (VSA in lines for
+	 * channels 0-3)
+	 * REG_VSYNC_WIDTH0: [15:0]-VSA for channel0, [31:16]-VSA for

channel1

drivers/gpu/drm/kmb/kmb_dsi.c line 613

Quoted 1 line
drivers/gpu/drm/kmb/kmb_dsi.c new file +1 -0
+	 * REG_VSYNC_WIDTH1: [15:0]-VSA for channel2, [31:16]-VSA for

channel3

Quoted 34 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +34 -0
+	 */
+	offset = (frame_gen % 2) * 16;
+	reg_adr = MIPI_TXm_HS_VSYNC_WIDTHn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->vsync_width);
+
+	/* vertical backporch (vbp) */
+	reg_adr = MIPI_TXm_HS_V_BACKPORCHESn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_backporch);
+
+	/* vertical frontporch (vfp) */
+	reg_adr = MIPI_TXm_HS_V_FRONTPORCHESn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_frontporch);
+
+	/* vertical active (vactive) */
+	reg_adr = MIPI_TXm_HS_V_ACTIVEn(ctrl_no, frame_gen / 2);
+	kmb_write_bits_mipi(dev_p, reg_adr, offset, 16, fg_cfg->v_active);
+
+	/* hsync width */
+	reg_adr = MIPI_TXm_HS_HSYNC_WIDTHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->hsync_width * ppl_llp_ratio) / 1000);
+
+	/* horizontal backporch (hbp) */
+	reg_adr = MIPI_TXm_HS_H_BACKPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->h_backporch * ppl_llp_ratio) / 1000);
+
+	/* horizontal frontporch (hfp) */
+	reg_adr = MIPI_TXm_HS_H_FRONTPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       (fg_cfg->h_frontporch * ppl_llp_ratio) / 1000);
+
+	/* horizontal active (ha) */
+	reg_adr = MIPI_TXm_HS_H_ACTIVEn(ctrl_no, frame_gen);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	/* convert h_active which is wc in bytes to cycles */
+	val = (fg_cfg->h_active * sysclk * 1000) /
+	    ((fg_cfg->lane_rate_mbps / 8) * fg_cfg->active_lanes);
+	val /= 1000;
+	kmb_write_mipi(dev_p, reg_adr, val);
+
+	/* llp hsync width */
+	reg_adr = MIPI_TXm_HS_LLP_HSYNC_WIDTHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->hsync_width * (fg_cfg->bpp /

8));

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +4 -0
+
+	/* llp h backporch */
+	reg_adr = MIPI_TXm_HS_LLP_H_BACKPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr, fg_cfg->h_backporch * (fg_cfg->bpp /

8));

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	/* llp h frontporch */
+	reg_adr = MIPI_TXm_HS_LLP_H_FRONTPORCHn(ctrl_no, frame_gen);
+	kmb_write_mipi(dev_p, reg_adr,
+		       fg_cfg->h_frontporch * (fg_cfg->bpp / 8));
+}
+
+static void mipi_tx_fg_cfg(struct kmb_drm_private *dev_p, u8 frame_gen,
+			   u8 active_lanes, u32 bpp, u32 wc,
+			   u32 lane_rate_mbps, struct mipi_tx_frame_cfg

*fg_cfg)

Quoted 44 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +44 -0
+{
+	u32 i, fg_num_lines = 0;
+	struct mipi_tx_frame_timing_cfg fg_t_cfg;
+
+	/* Calculate the total frame generator number of
+	 * lines based on it's active sections
+	 */
+	for (i = 0; i < MIPI_TX_FRAME_GEN_SECTIONS; i++) {
+		if (fg_cfg->sections[i] != NULL)
+			fg_num_lines += fg_cfg->sections[i]->height_lines;
+	}
+
+	fg_t_cfg.bpp = bpp;
+	fg_t_cfg.lane_rate_mbps = lane_rate_mbps;
+	fg_t_cfg.hsync_width = fg_cfg->hsync_width;
+	fg_t_cfg.h_backporch = fg_cfg->h_backporch;
+	fg_t_cfg.h_frontporch = fg_cfg->h_frontporch;
+	fg_t_cfg.h_active = wc;
+	fg_t_cfg.vsync_width = fg_cfg->vsync_width;
+	fg_t_cfg.v_backporch = fg_cfg->v_backporch;
+	fg_t_cfg.v_frontporch = fg_cfg->v_frontporch;
+	fg_t_cfg.v_active = fg_num_lines;
+	fg_t_cfg.active_lanes = active_lanes;
+
+	/* Apply frame generator timing setting */
+	mipi_tx_fg_cfg_regs(dev_p, frame_gen, &fg_t_cfg);
+}
+
+static void mipi_tx_multichannel_fifo_cfg(struct kmb_drm_private *dev_p,
+					  u8 active_lanes, u8 vchannel_id)
+{
+	u32 fifo_size, fifo_rthreshold;
+	u32 ctrl_no = MIPI_CTRL6;
+
+	/* Clear all mc fifo channel sizes and thresholds */
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CTRL_EN, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CHAN_ALLOC0, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_CHAN_ALLOC1, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_RTHRESHOLD0, 0);
+	kmb_write_mipi(dev_p, MIPI_TX_HS_MC_FIFO_RTHRESHOLD1, 0);
+
+	fifo_size = ((active_lanes > MIPI_D_LANES_PER_DPHY) ?
+		     MIPI_CTRL_4LANE_MAX_MC_FIFO_LOC :
+		     MIPI_CTRL_2LANE_MAX_MC_FIFO_LOC) - 1;

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	/* MC fifo size for virtual channels 0-3
+	 * REG_MC_FIFO_CHAN_ALLOC0: [8:0]-channel0, [24:16]-channel1
+	 * REG_MC_FIFO_CHAN_ALLOC1: [8:0]-2, [24:16]-channel3
+	 */
+	SET_MC_FIFO_CHAN_ALLOC(dev_p, ctrl_no, vchannel_id, fifo_size);
+
+	/* Set threshold to half the fifo size, actual size=size*16 */
+	fifo_rthreshold = ((fifo_size) * 8) & BIT_MASK_16;
+	SET_MC_FIFO_RTHRESHOLD(dev_p, ctrl_no, vchannel_id,

fifo_rthreshold);

Quoted 65 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +65 -0
+
+	/* Enable the MC FIFO channel corresponding to the Virtual Channel */
+	kmb_set_bit_mipi(dev_p, MIPI_TXm_HS_MC_FIFO_CTRL_EN(ctrl_no),
+			 vchannel_id);
+}
+
+static void mipi_tx_ctrl_cfg(struct kmb_drm_private *dev_p, u8 fg_id,
+			     struct mipi_ctrl_cfg *ctrl_cfg)
+{
+	u32 sync_cfg = 0, ctrl = 0, fg_en;
+	u32 ctrl_no = MIPI_CTRL6;
+
+	/* MIPI_TX_HS_SYNC_CFG */
+	if (ctrl_cfg->tx_ctrl_cfg.line_sync_pkt_en)
+		sync_cfg |= LINE_SYNC_PKT_ENABLE;
+	if (ctrl_cfg->tx_ctrl_cfg.frame_counter_active)
+		sync_cfg |= FRAME_COUNTER_ACTIVE;
+	if (ctrl_cfg->tx_ctrl_cfg.line_counter_active)
+		sync_cfg |= LINE_COUNTER_ACTIVE;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->v_blanking)
+		sync_cfg |= DSI_V_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hsa_blanking)
+		sync_cfg |= DSI_HSA_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hbp_blanking)
+		sync_cfg |= DSI_HBP_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hfp_blanking)
+		sync_cfg |= DSI_HFP_BLANKING;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->sync_pulse_eventn)
+		sync_cfg |= DSI_SYNC_PULSE_EVENTN;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->lpm_first_vsa_line)
+		sync_cfg |= DSI_LPM_FIRST_VSA_LINE;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->lpm_last_vfp_line)
+		sync_cfg |= DSI_LPM_LAST_VFP_LINE;
+
+	/* Enable frame generator */
+	fg_en = 1 << fg_id;
+	sync_cfg |= FRAME_GEN_EN(fg_en);
+
+	if (ctrl_cfg->tx_ctrl_cfg.tx_always_use_hact)
+		sync_cfg |= ALWAYS_USE_HACT(fg_en);
+	if (ctrl_cfg->tx_ctrl_cfg.tx_hact_wait_stop)
+		sync_cfg |= HACT_WAIT_STOP(fg_en);
+
+	drm_dbg(&dev_p->drm, "sync_cfg=%d fg_en=%d\n", sync_cfg, fg_en);
+
+	/* MIPI_TX_HS_CTRL */
+
+	/* type:DSI, source:LCD */
+	ctrl = HS_CTRL_EN | TX_SOURCE;
+	ctrl |= LCD_VC(fg_id);
+	ctrl |= ACTIVE_LANES(ctrl_cfg->active_lanes - 1);
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->eotp_en)
+		ctrl |= DSI_EOTP_EN;
+	if (ctrl_cfg->tx_ctrl_cfg.tx_dsi_cfg->hfp_blank_en)
+		ctrl |= DSI_CMD_HFP_EN;
+
+	/*67 ns stop time */
+	ctrl |= HSEXIT_CNT(0x43);
+
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_SYNC_CFG(ctrl_no), sync_cfg);
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_CTRL(ctrl_no), ctrl);
+}
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+static void mipi_tx_hs_tp_gen(struct kmb_drm_private *dev_p, int vc,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+			      int tp_sel, u32 stripe_width, u32 color0,
+			      u32 color1, u32 ctrl_no)
+{
+	int val = 0;
+
+	/* Select test pattern mode on the virtual channel */
+	val = TP_SEL_VCm(vc, tp_sel);
+
+	/* Configure test pattern colors */
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR0(ctrl_no),

color0);

drivers/gpu/drm/kmb/kmb_dsi.c line 801

Quoted 1 line
drivers/gpu/drm/kmb/kmb_dsi.c new file +1 -0
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR1(ctrl_no),

color1);

Quoted 57 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +57 -0
+
+	/* Enable test pattern generation on the virtual channel */
+	val |= TP_EN_VCm(vc);
+	kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_CTRL(ctrl_no), val);
+
+}
+#endif
+
+static u32 mipi_tx_init_cntrl(struct kmb_drm_private *dev_p,
+			      struct mipi_ctrl_cfg *ctrl_cfg)
+{
+	u32 ret = 0;
+	u8 active_vchannels = 0;
+	u8 frame_id, sect;
+	u32 bits_per_pclk = 0;
+	u32 word_count = 0;
+	struct mipi_tx_frame_cfg *frame;
+
+	/* This is the order to initialize MIPI TX:
+	 * 1. set frame section parameters
+	 * 2. set frame specific parameters
+	 * 3. connect lcd to mipi
+	 * 4. multi channel fifo cfg
+	 * 5. set mipitxcctrlcfg
+	 */
+
+	for (frame_id = 0; frame_id < 4; frame_id++) {
+		frame = ctrl_cfg->tx_ctrl_cfg.frames[frame_id];
+
+		/* Find valid frame, assume only one valid frame */
+		if (frame == NULL)
+			continue;
+
+		/* Frame Section configuration */
+		/* TODO - assume there is only one valid section in a frame,
+		 * so bits_per_pclk and word_count are only set once
+		 */
+		for (sect = 0; sect < MIPI_CTRL_VIRTUAL_CHANNELS; sect++) {
+			if (frame->sections[sect] == NULL)
+				continue;
+
+			ret = mipi_tx_fg_section_cfg(dev_p, frame_id, sect,
+						     frame->sections[sect],
+						     &bits_per_pclk,
+						     &word_count);
+			if (ret)
+				return ret;
+
+		}
+
+		/* Set frame specific parameters */
+		mipi_tx_fg_cfg(dev_p, frame_id, ctrl_cfg->active_lanes,
+			       bits_per_pclk, word_count,
+			       ctrl_cfg->lane_rate_mbps, frame);
+
+		active_vchannels++;
+

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		/* Stop iterating as only one virtual channel
+		 * shall be used for LCD connection
+		 */
+		break;
+	}
+
+	if (active_vchannels == 0)
+		return -EINVAL;
+	/* Multi-Channel FIFO Configuration */
+	mipi_tx_multichannel_fifo_cfg(dev_p, ctrl_cfg->active_lanes,

frame_id);

Quoted 200 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +200 -0
+
+	/* Frame Generator Enable */
+	mipi_tx_ctrl_cfg(dev_p, frame_id, ctrl_cfg);
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+	mipi_tx_hs_tp_gen(dev_p, 0, MIPI_TX_HS_TP_V_STRIPES,
+			  0x8, 0xff, 0xff00, MIPI_CTRL6);
+#endif
+
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		  GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+
+	return ret;
+}
+
+#ifdef DPHY_READ_TESTCODE
+int dphy_read_testcode(struct kmb_drm_private *dev_p, int dphy_sel,
+		       int test_code)
+{
+	u32 reg_wr_data;
+	u32 reg_rd_data;
+	int data;
+
+	reg_wr_data = dphy_sel;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = 0;
+	reg_wr_data = 0;
+	reg_rd_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = (dphy_sel | dphy_sel << 12);
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel << 12;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = test_code >> 8 & 0xf;
+	reg_wr_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	data = test_code & 0xff;
+	reg_wr_data = 0;
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		reg_wr_data |= data << 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		reg_wr_data |= data << 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		reg_wr_data |= data << 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		reg_wr_data |= data << 24;
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN0_3, reg_wr_data);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN4_7, reg_wr_data);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		kmb_write_mipi(dev_p, DPHY_TEST_DIN8_9, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = (dphy_sel | dphy_sel << 12);
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	reg_wr_data = dphy_sel << 12;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	reg_wr_data = 0;
+	kmb_write_mipi(dev_p, DPHY_TEST_CTRL1, reg_wr_data);
+
+	if ((dphy_sel >> 0 & 0xf) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT0_3);
+	if ((dphy_sel >> 4 & 0xf) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT4_7);
+	if ((dphy_sel >> 8 & 0x3) > 0)
+		reg_rd_data = kmb_read_mipi(dev_p, DPHY_TEST_DOUT8_9);
+
+	if (((dphy_sel >> 0 & 0x1) == 1) | ((dphy_sel >> 4 & 0x1) == 1) |
+	    ((dphy_sel >> 8 & 0x1) == 1))
+		data = reg_rd_data >> 0;
+	if (((dphy_sel >> 1 & 0x1) == 1) | ((dphy_sel >> 5 & 0x1) == 1) |
+	    ((dphy_sel >> 9 & 0x1) == 1))
+		data = reg_rd_data >> 8;
+	if (((dphy_sel >> 2 & 0x1) == 1) | ((dphy_sel >> 6 & 0x1) == 1) |
+	    ((dphy_sel >> 10 & 0x1) == 1))
+		data = reg_rd_data >> 16;
+	if (((dphy_sel >> 3 & 0x1) == 1) | ((dphy_sel >> 7 & 0x1) == 1) |
+	    ((dphy_sel >> 11 & 0x1) == 1))
+		data = reg_rd_data >> 24;
+
+	return data;
+}
+#endif
+
+static void test_mode_send(struct kmb_drm_private *dev_p, u32 dphy_no,
+			   u32 test_code, u32 test_data)
+{
+	if (test_code != TEST_CODE_FSM_CONTROL)
+		drm_dbg(&dev_p->drm,
+			"test_code = %02x, test_data = %08x\n", test_code,
+			 test_data);
+	/* Steps to send test code:
+	 * - set testclk HIGH
+	 * - set testdin with test code
+	 * - set testen HIGH
+	 * - set testclk LOW
+	 * - set testen LOW
+	 */
+
+	/* Set testclk high */
+	SET_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+	/* Set testdin */
+	SET_TEST_DIN0_3(dev_p, dphy_no, test_code);
+
+	/* Set testen high */
+	SET_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+	/* Set testclk low */
+	CLR_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+	/* Set testen low */
+	CLR_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+	if (test_code) {
+		/*  Steps to send test data:
+		 * - set testen LOW
+		 * - set testclk LOW
+		 * - set testdin with data
+		 * - set testclk HIGH
+		 */
+
+		/* Set testen low */
+		CLR_DPHY_TEST_CTRL1_EN(dev_p, dphy_no);
+
+		/* Set testclk low */
+		CLR_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+
+		/* Set data in testdin */
+		kmb_write_mipi(dev_p,
+			       DPHY_TEST_DIN0_3 + ((dphy_no / 0x4) * 0x4),
+			       test_data << ((dphy_no % 4) * 8));
+
+		/* Set testclk high */
+		SET_DPHY_TEST_CTRL1_CLK(dev_p, dphy_no);
+	}
+}
+

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+static inline void set_test_mode_src_osc_freq_target_low_bits(struct
+							      kmb_drm_private
+							      *dev_p,
+							      u32 dphy_no,
+							      u32 freq)
+{
+	/* Typical rise/fall time=166, refer Table 1207 databook,
+	 * sr_osc_freq_target[7:0]
+	 */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_SLEW_RATE_DDL_CYCLES,

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +8 -0
+		       (freq & 0x7f));
+}
+
+static inline void set_test_mode_src_osc_freq_target_hi_bits(struct
+							     kmb_drm_private
+							     *dev_p,
+							     u32 dphy_no,
+							     u32 freq)

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+{
+	u32 data;
+
+	/* Flag this as high nibble */
+	data = ((freq >> 6) & 0x1f) | (1 << 7);
+
+	/* Typical rise/fall time=166, refer Table 1207 databook,
+	 * sr_osc_freq_target[11:7]
+	 */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_SLEW_RATE_DDL_CYCLES, data);

Quoted 76 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +76 -0
+}
+
+static void mipi_tx_get_vco_params(struct vco_params *vco)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(vco_table); i++) {
+		if (vco->freq < vco_table[i].freq) {
+			*vco = vco_table[i];
+			return;
+		}
+	}
+
+	WARN_ONCE(1, "Invalid vco freq = %u for PLL setup\n", vco->freq);
+}
+
+static void mipi_tx_pll_setup(struct kmb_drm_private *dev_p, u32 dphy_no,
+			      u32 ref_clk_mhz, u32 target_freq_mhz)
+{
+	u32 best_n = 0, best_m = 0;
+	u32 n = 0, m = 0, div = 0, delta, freq = 0, t_freq;
+	u32 best_freq_delta = 3000;
+
+	/* pll_ref_clk: - valid range: 2~64 MHz; Typically 24 MHz
+	 * Fvco: - valid range: 320~1250 MHz (Gen3 D-PHY)
+	 * Fout: - valid range: 40~1250 MHz (Gen3 D-PHY)
+	 * n: - valid range [0 15]
+	 * N: - N = n + 1
+	 *      -valid range: [1 16]
+	 *      -conditions: - (pll_ref_clk / N) >= 2 MHz
+	 *              -(pll_ref_clk / N) <= 8 MHz
+	 * m: valid range [62 623]
+	 * M: - M = m + 2
+	 *      -valid range [64 625]
+	 *      -Fvco = (M/N) * pll_ref_clk
+	 */
+	struct vco_params vco_p = {
+		.range = 0,
+		.divider = 1,
+	};
+
+	vco_p.freq = target_freq_mhz;
+	mipi_tx_get_vco_params(&vco_p);
+
+	/* Search pll n parameter */
+	for (n = PLL_N_MIN; n <= PLL_N_MAX; n++) {
+		/* Calculate the pll input frequency division ratio
+		 * multiply by 1000 for precision -
+		 * no floating point, add n for rounding
+		 */
+		div = ((ref_clk_mhz * 1000) + n) / (n + 1);
+
+		/* Found a valid n parameter */
+		if ((div < 2000 || div > 8000))
+			continue;
+
+		/* Search pll m parameter */
+		for (m = PLL_M_MIN; m <= PLL_M_MAX; m++) {
+			/* Calculate the Fvco(DPHY PLL output frequency)
+			 * using the current n,m params
+			 */
+			freq = div * (m + 2);
+			freq /= 1000;
+
+			/* Trim the potential pll freq to max supported */
+			if (freq > PLL_FVCO_MAX)
+				continue;
+
+			delta = abs(freq - target_freq_mhz);
+
+			/* Select the best (closest to target pll freq)
+			 * n,m parameters so far
+			 */
+			if (delta < best_freq_delta) {
+				best_n = n;
+				best_m = m;

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+				best_freq_delta = delta;
+			}
+		}
+	}
+
+	/* Program vco_cntrl parameter
+	 * PLL_VCO_Control[5:0] = pll_vco_cntrl_ovr,
+	 * PLL_VCO_Control[6]   = pll_vco_cntrl_ovr_en
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_VCO_CTRL,

(vco_p.range

drivers/gpu/drm/kmb/kmb_dsi.c line 1212

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +13 -0
+								| (1 << 6)));
+
+	/* Program m, n pll parameters */
+	drm_dbg(&dev_p->drm, "m = %d n = %d\n", best_m, best_n);
+
+	/* PLL_Input_Divider_Ratio[3:0] = pll_n_ovr */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_INPUT_DIVIDER,
+		       (best_n & 0x0f));
+
+	/* m - low nibble PLL_Loop_Divider_Ratio[4:0]
+	 * pll_m_ovr[4:0]
+	 */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_PLL_FEEDBACK_DIVIDER,

drivers/gpu/drm/kmb/kmb_dsi.c line 1212

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +6 -0
+		       (best_m & 0x1f));
+
+	/* m - high nibble PLL_Loop_Divider_Ratio[4:0]
+	 * pll_m_ovr[9:5]
+	 */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_PLL_FEEDBACK_DIVIDER,

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +6 -0
+		       ((best_m >> 5) & 0x1f) | PLL_FEEDBACK_DIVIDER_HIGH);
+
+	/* Enable overwrite of n,m parameters :pll_n_ovr_en, pll_m_ovr_en */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_OUTPUT_CLK_SEL,
+		       (PLL_N_OVR_EN | PLL_M_OVR_EN));
+

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+	/* Program Charge-Pump parameters */
+
+	/* pll_prop_cntrl-fixed values for prop_cntrl from DPHY doc */
+	t_freq = target_freq_mhz * vco_p.divider;
+	test_mode_send(dev_p, dphy_no,
+		       TEST_CODE_PLL_PROPORTIONAL_CHARGE_PUMP_CTRL,
+		       ((t_freq > 1150) ? 0x0C : 0x0B));
+
+	/* pll_int_cntrl-fixed value for int_cntrl from DPHY doc */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_PLL_INTEGRAL_CHARGE_PUMP_CTRL,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 7 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +7 -0
+		       0x00);
+
+	/* pll_gmp_cntrl-fixed value for gmp_cntrl from DPHY doci */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_GMP_CTRL, 0x10);
+
+	/* pll_cpbias_cntrl-fixed value for cpbias_cntrl from DPHY doc */
+	test_mode_send(dev_p, dphy_no,

TEST_CODE_PLL_CHARGE_PUMP_BIAS, 0x10);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +5 -0
+
+	/* pll_th1 -Lock Detector Phase error threshold,
+	 * document gives fixed value
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_PHASE_ERR_CTRL,

0x02);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +5 -0
+
+	/* PLL Lock Configuration */
+
+	/* pll_th2 - Lock Filter length, document gives fixed value */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_LOCK_FILTER,

0x60);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +3 -0
+
+	/* pll_th3- PLL Unlocking filter, document gives fixed value */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_UNLOCK_FILTER,

0x03);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +5 -0
+
+	/* pll_lock_sel-PLL Lock Detector Selection,
+	 * document gives fixed value
+	 */
+	test_mode_send(dev_p, dphy_no, TEST_CODE_PLL_LOCK_DETECTOR,

0x02);

Quoted 172 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +172 -0
+}
+
+#ifdef DPHY_GET_FSM
+static void dphy_get_fsm(struct kmb_drm_private *dev_p, u32 dphy_no)
+{
+	test_mode_send(dev_p, dphy_no, TEST_CODE_FSM_CONTROL, 0x80);
+
+	drm_dbg(&dev_p->drm, "dphy %d fsm_state = 0%x\n", dphy_no,
+		 kmb_read_mipi(dev_p, DPHY_TEST_DOUT4_7));
+}
+#endif
+
+static void dphy_init_sequence(struct kmb_drm_private *dev_p,
+			       struct mipi_ctrl_cfg *cfg, u32 dphy_no,
+			       int active_lanes, enum dphy_mode mode)
+{
+	u32 test_code = 0, test_data = 0, val;
+	int i = 0;
+
+	drm_info(&dev_p->drm,
+		"dphy=%d mode=%d active_lanes=%d\n", dphy_no, mode,
+		 active_lanes);
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	/* Set D-PHY in shutdown mode */
+	/* Assert RSTZ signal */
+	CLR_DPHY_INIT_CTRL0(dev_p, dphy_no, RESETZ);
+
+	/* Assert SHUTDOWNZ signal */
+	CLR_DPHY_INIT_CTRL0(dev_p, dphy_no, SHUTDOWNZ);
+	val = kmb_read_mipi(dev_p, DPHY_INIT_CTRL0);
+
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL0 = 0x%x\n", val);
+
+	/* Init D-PHY_n
+	 * Pulse testclear signal to make sure the d-phy configuration
+	 * starts from a clean base
+	 */
+	CLR_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+	SET_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+	CLR_DPHY_TEST_CTRL0(dev_p, dphy_no);
+	ndelay(15);
+
+	drm_dbg(&dev_p->drm, "DPHY_TEST_CTRL0=0x%x\n",
+		  kmb_read_mipi(dev_p, DPHY_TEST_CTRL0));
+
+	/* Set mastermacro bit - Master or slave mode */
+	test_code = TEST_CODE_MULTIPLE_PHY_CTRL;
+
+	/* DPHY has its own clock lane enabled (master) */
+	if (mode == MIPI_DPHY_MASTER)
+		test_data = 0x01;
+	else
+		test_data = 0x00;
+
+	/* Send the test code and data */
+	test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	/* Set the lane data rate */
+	for (i = 0; i < MIPI_DPHY_DEFAULT_BIT_RATES; i++) {
+		if (mipi_hs_freq_range[i].default_bit_rate_mbps <
+		    cfg->lane_rate_mbps)
+			continue;
+
+		/* Send the test code and data */
+		/* bit[6:0] = hsfreqrange_ovr bit[7] = hsfreqrange_ovr_en */
+		test_code = TEST_CODE_HS_FREQ_RANGE_CFG;
+		test_data = (mipi_hs_freq_range[i].hsfreqrange_code & 0x7f) |
+		    (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+		break;
+	}
+
+	/* High-Speed Tx Slew Rate Calibration
+	 * BitRate: > 1.5 Gbps && <= 2.5 Gbps: slew rate control OFF
+	 */
+	if (cfg->lane_rate_mbps > 1500) {
+		/* Bypass slew rate calibration algorithm
+		 * bits[1:0} srcal_en_ovr_en, srcal_en_ovr
+		 */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = 0x02;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Disable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x00;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+	} else if (cfg->lane_rate_mbps > 1000) {
+		/* BitRate: > 1 Gbps && <= 1.5 Gbps: - slew rate control ON
+		 * typical rise/fall times: 166 ps
+		 */
+
+		/* Do not bypass slew rate calibration algorithm
+		 * bits[1:0}=srcal_en_ovr_en, srcal_en_ovr, bit[6]=sr_range
+		 */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = (0x03 | (1 << 6));
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Enable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[6:0] low nibble
+		 * typical rise/fall time=166, refer Table 1207 databook
+		 */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = (0x72f & 0x7f);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[11:7] high nibble
+		 * Typical rise/fall time=166, refer Table 1207 databook
+		 */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = ((0x72f >> 6) & 0x1f) | (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+	} else {
+		/* lane_rate_mbps <= 1000 Mbps
+		 * BitRate:  <= 1 Gbps:
+		 * - slew rate control ON
+		 * - typical rise/fall times: 225 ps
+		 */
+
+		/* Do not bypass slew rate calibration algorithm */
+		test_code = TEST_CODE_SLEW_RATE_OVERRIDE_CTRL;
+		test_data = (0x03 | (1 << 6));
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Enable slew rate calibration */
+		test_code = TEST_CODE_SLEW_RATE_DDL_LOOP_CTRL;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Typical rise/fall time=255, refer Table 1207 databook */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = (0x523 & 0x7f);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+		/* Set sr_osc_freq_target[11:7] high nibble */
+		test_code = TEST_CODE_SLEW_RATE_DDL_CYCLES;
+		test_data = ((0x523 >> 6) & 0x1f) | (1 << 7);
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	}
+
+	/* Set cfgclkfreqrange */
+	val = (((cfg->cfg_clk_khz / 1000) - 17) * 4) & 0x3f;
+	SET_DPHY_FREQ_CTRL0_3(dev_p, dphy_no, val);
+
+	drm_dbg(&dev_p->drm, "DPHY_FREQ = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_FREQ_CTRL0_3 + 4));
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	/* Enable config clk for the corresponding d-phy */
+	kmb_set_bit_mipi(dev_p, DPHY_CFG_CLK_EN, dphy_no);
+
+	drm_dbg(&dev_p->drm, "DPHY_CFG_CLK_EN = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_CFG_CLK_EN));
+
+	/* PLL setup */
+	if (mode == MIPI_DPHY_MASTER) {
+		/*Set PLL regulator in bypass */
+		test_code = TEST_CODE_PLL_ANALOG_PROG;
+		test_data = 0x01;
+		test_mode_send(dev_p, dphy_no, test_code, test_data);
+

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		/* PLL Parameters Setup */
+		mipi_tx_pll_setup(dev_p, dphy_no, cfg->ref_clk_khz / 1000,
+				  cfg->lane_rate_mbps / 2);
+
+		/* Set clksel */
+		kmb_write_bits_mipi(dev_p, DPHY_INIT_CTRL1,
+				    PLL_CLKSEL_0, 2, 0x01);
+
+		/* Set pll_shadow_control */
+		kmb_set_bit_mipi(dev_p, DPHY_INIT_CTRL1,

PLL_SHADOW_CTRL);

Quoted 57 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +57 -0
+
+		drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL1 = 0x%x\n",
+			 kmb_read_mipi(dev_p, DPHY_INIT_CTRL1));
+	}
+
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+//#define MIPI_TX_FORCE_VOD
+#ifdef MIPI_TX_FORCE_VOD
+#define MIPI_TX_VOD_LVL	450
+#define TEST_CODE_BANDGAP 0x24
+	/* Set bandgap/VOD level */
+	switch (MIPI_TX_VOD_LVL) {
+	case 200:
+		test_data = 0x00;
+		break;
+	case 300:
+		test_data = 0x20;
+		break;
+	case 350:
+		test_data = 0x40;
+		break;
+	case 450:
+		test_data = 0x60;
+		break;
+	case 400:
+	default:
+		test_data = 0x70;
+		break;
+	}
+	test_mode_send(dev_p, dphy_no, TEST_CODE_BANDGAP, test_data);
+#endif
+
+	/*Send NORMAL OPERATION test code */
+	test_code = 0x0;
+	test_data = 0x0;
+	test_mode_send(dev_p, dphy_no, test_code, test_data);
+
+	/* Configure BASEDIR for data lanes
+	 * NOTE: basedir only applies to LANE_0 of each D-PHY.
+	 * The other lanes keep their direction based on the D-PHY type,
+	 * either Rx or Tx.
+	 * bits[5:0]  - BaseDir: 1 = Rx
+	 * bits[9:6] - BaseDir: 0 = Tx
+	 */
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		  kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+
+	kmb_write_bits_mipi(dev_p, DPHY_INIT_CTRL2, 0, 9, 0x03f);
+	ndelay(15);
+
+	/* Enable CLOCK LANE
+	 * Clock lane should be enabled regardless of the direction
+	 * set for the D-PHY (Rx/Tx)
+	 */
+	kmb_set_bit_mipi(dev_p, DPHY_INIT_CTRL2, 12 + dphy_no);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL2 = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_INIT_CTRL2));
+
+	/* Enable DATA LANES */
+	kmb_write_bits_mipi(dev_p, DPHY_ENABLE, dphy_no * 2, 2,
+			    ((1 << active_lanes) - 1));
+
+	drm_dbg(&dev_p->drm,
+		"DPHY_ENABLE = 0x%x\n", kmb_read_mipi(dev_p,

DPHY_ENABLE));

Quoted 14 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +14 -0
+	ndelay(15);
+
+	/* Take D-PHY out of shutdown mode */
+	/* Deassert SHUTDOWNZ signal */
+	drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+		 kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));
+	SET_DPHY_INIT_CTRL0(dev_p, dphy_no, SHUTDOWNZ);
+	ndelay(15);
+
+	/* Deassert RSTZ signal */
+	SET_DPHY_INIT_CTRL0(dev_p, dphy_no, RESETZ);
+	drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL0 = 0x%x\n",
+		 kmb_read_mipi(dev_p, DPHY_INIT_CTRL0));
+}

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+static void dphy_wait_fsm(struct kmb_drm_private *dev_p, u32 dphy_no,
+			  enum dphy_tx_fsm fsm_state)
+{
+	enum dphy_tx_fsm val = DPHY_TX_POWERDWN;
+	int i = 0;
+	int status = 1;
+
+	do {
+		test_mode_send(dev_p, dphy_no, TEST_CODE_FSM_CONTROL,

0x80);

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+		val = GET_TEST_DOUT4_7(dev_p, dphy_no);
+		i++;
+		if (i > TIMEOUT) {
+			status = 0;
+			break;
+		}
+	} while (val != fsm_state);
+
+	drm_dbg(&dev_p->drm, "%s: dphy %d val = %x\n", __func__, dphy_no,

val);

drivers/gpu/drm/kmb/kmb_dsi.c line 1526

Quoted 1 line
drivers/gpu/drm/kmb/kmb_dsi.c new file +1 -0
+	drm_info(&dev_p->drm, "********** DPHY %d WAIT_FSM %s

**********\n",

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 12 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +12 -0
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static void wait_init_done(struct kmb_drm_private *dev_p, u32 dphy_no,
+			   u32 active_lanes)
+{
+	u32 stopstatedata = 0;
+	u32 data_lanes = (1 << active_lanes) - 1;
+	int i = 0, val;
+	int status = 1;
+
+	drm_dbg(&dev_p->drm, "dphy=%d active_lanes=%d data_lanes=%d\n",

dphy_no,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +5 -0
+		 active_lanes, data_lanes);
+
+	do {
+		val = kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7);
+		stopstatedata = GET_STOPSTATE_DATA(dev_p, dphy_no) &

data_lanes;

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +9 -0
+
+		/* TODO-need to add a time out and return failure */
+		i++;
+
+		if (i > TIMEOUT) {
+			status = 0;
+
+			drm_info(&dev_p->drm,
+				"! WAIT_INIT_DONE: TIMING

OUT!(err_stat=%d)",

drivers/gpu/drm/kmb/kmb_dsi.c line 1553

Quoted 1 line
drivers/gpu/drm/kmb/kmb_dsi.c new file +1 -0
+				 kmb_read_mipi(dev_p,

MIPI_DPHY_ERR_STAT6_7));

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +9 -0
+			drm_dbg(&dev_p->drm,
+				"MIPI_DPHY_STAT0_4_7 = 0x%x)\n", val);
+			drm_dbg(&dev_p->drm,
+				"stopdata = 0x%x data_lanes=0x%x\n",
+				 stopstatedata, data_lanes);
+
+			break;
+		}
+

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		if (i < 3) {
+			drm_dbg(&dev_p->drm,
+				"stopdata = 0x%x data_lanes=0x%x\n",
+				 stopstatedata, data_lanes);
+			drm_dbg(&dev_p->drm,
+				"MIPI_DPHY_STAT0_4_7 = 0x%x)\n", val);
+		}
+	} while (stopstatedata != data_lanes);
+
+	drm_info(&dev_p->drm, "********** DPHY %d INIT - %s

**********\n",

Quoted 36 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +36 -0
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static void wait_pll_lock(struct kmb_drm_private *dev_p, u32 dphy_no)
+{
+	int i = 0;
+	int status = 1;
+
+	do {
+		/* TODO-need to add a time out and return failure */
+		i++;
+		if (i > TIMEOUT) {
+			status = 0;
+
+			drm_info(&dev_p->drm, "%s: timing out", __func__);
+			drm_dbg(&dev_p->drm,
+				"%s : PLL_LOCK = 0x%x ", __func__,
+				kmb_read_mipi(dev_p, DPHY_PLL_LOCK));
+
+			break;
+		}
+
+		if ((i % 100) == 0)
+			drm_dbg(&dev_p->drm,
+				"%s : PLL_LOCK = 0x%x\n", __func__,
+				kmb_read_mipi(dev_p, DPHY_PLL_LOCK));
+	} while (!GET_PLL_LOCK(dev_p, dphy_no));
+
+	drm_info(&dev_p->drm, "***** PLL Locked for DPHY %d - %s *****\n",
+		 dphy_no, status ? "SUCCESS" : "FAILED");
+}
+
+static u32 mipi_tx_init_dphy(struct kmb_drm_private *dev_p,
+			     struct mipi_ctrl_cfg *cfg)
+{
+	u32 dphy_no = MIPI_DPHY6;

drivers/gpu/drm/kmb/kmb_dsi.c line 1632

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	drm_info(&dev_p->drm,
+		"active_lanes=%d lane_rate=%d\n", cfg->active_lanes,
+		MIPI_TX_LANE_DATA_RATE_MBPS);
+
+	/* Multiple D-PHYs needed */
+	if (cfg->active_lanes > MIPI_DPHY_D_LANES) {
+		/*
+		 *Initialization for Tx aggregation mode is done according to
+

*http://dub30.ir.intel.com/bugzilla/show_bug.cgi?id=27785#c12:

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +11 -0
+		 *a. start init PHY1
+		 *b. poll for PHY1 FSM state LOCK
+		 *   b1. reg addr 0x03[3:0] - state_main[3:0] == 5 (LOCK)
+		 *c. poll for PHY1 calibrations done :
+		 *   c1. termination calibration lower section: addr 0x22[5]
+		 *   - rescal_done
+		 *   c2. slewrate calibration (if data rate < = 1500 Mbps):
+		 *     addr 0xA7[3:2] - srcal_done, sr_finished
+		 *d. start init PHY0
+		 *e. poll for PHY0 stopstate
+		 *f. poll for PHY1 stopstate

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		 */
+		/*PHY #N+1 ('slave') */
+
+		dphy_init_sequence(dev_p, cfg, dphy_no + 1,
+				   (cfg->active_lanes - MIPI_DPHY_D_LANES),
+				   MIPI_DPHY_SLAVE);
+		dphy_wait_fsm(dev_p, dphy_no + 1, DPHY_TX_LOCK);
+
+		/* PHY #N master */
+		dphy_init_sequence(dev_p, cfg, dphy_no,

MIPI_DPHY_D_LANES,

Quoted 23 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +23 -0
+				   MIPI_DPHY_MASTER);
+
+		/* Wait for DPHY init to complete */
+		wait_init_done(dev_p, dphy_no, MIPI_DPHY_D_LANES);
+		wait_init_done(dev_p, dphy_no + 1,
+			       cfg->active_lanes - MIPI_DPHY_D_LANES);
+		wait_pll_lock(dev_p, dphy_no);
+		wait_pll_lock(dev_p, dphy_no + 1);
+		dphy_wait_fsm(dev_p, dphy_no, DPHY_TX_IDLE);
+	} else {		/* Single DPHY */
+		dphy_init_sequence(dev_p, cfg, dphy_no, cfg->active_lanes,
+				   MIPI_DPHY_MASTER);
+		dphy_wait_fsm(dev_p, dphy_no, DPHY_TX_IDLE);
+		wait_init_done(dev_p, dphy_no, cfg->active_lanes);
+		wait_pll_lock(dev_p, dphy_no);
+	}
+
+	return 0;
+}
+
+void connect_lcd_to_mipi(struct kmb_drm_private *dev_p)
+{
+	/* DISABLE MIPI->CIF CONNECTION */

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+	kmb_write_msscam(dev_p, MSS_MIPI_CIF_CFG, 0);
+
+	/* ENABLE LCD->MIPI CONNECTION */
+	kmb_write_msscam(dev_p, MSS_LCD_MIPI_CFG, 1);
+
+	/* DISABLE LCD->CIF LOOPBACK */
+	kmb_write_msscam(dev_p, MSS_LOOPBACK_CFG, 0);
+}
+
+int kmb_dsi_hw_init(struct drm_device *dev, struct drm_display_mode

*mode)

Quoted 40 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +40 -0
+{
+	struct kmb_drm_private *dev_p = to_kmb(dev);
+	u64 data_rate;
+
+	mipi_tx_init_cfg.active_lanes = MIPI_TX_ACTIVE_LANES;
+
+	if (mode != NULL) {
+		mipi_tx_frame0_sect_cfg.width_pixels = mode->crtc_hdisplay;
+		mipi_tx_frame0_sect_cfg.height_lines = mode->crtc_vdisplay;
+		mipitx_frame0_cfg.vsync_width =
+		    mode->crtc_vsync_end - mode->crtc_vsync_start;
+		mipitx_frame0_cfg.v_backporch =
+		    mode->crtc_vtotal - mode->crtc_vsync_end;
+		mipitx_frame0_cfg.v_frontporch =
+		    mode->crtc_vsync_start - mode->crtc_vdisplay;
+		mipitx_frame0_cfg.hsync_width =
+		    mode->crtc_hsync_end - mode->crtc_hsync_start;
+		mipitx_frame0_cfg.h_backporch =
+		    mode->crtc_htotal - mode->crtc_hsync_end;
+		mipitx_frame0_cfg.h_frontporch =
+		    mode->crtc_hsync_start - mode->crtc_hdisplay;
+
+		/* Lane rate = (vtotal*htotal*fps*bpp)/4 / 1000000
+		 * to convert to Mbps
+		 */
+		data_rate = ((((u32) mode->crtc_vtotal *
+				(u32) mode->crtc_htotal) *
+				(u32)(drm_mode_vrefresh(mode)) *
+			      MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) /
+		    1000000;
+
+		drm_info(&dev_p->drm, "htotal=%d vtotal=%d refresh=%d\n",
+			 mode->crtc_htotal, mode->crtc_vtotal,
+			 drm_mode_vrefresh(mode));
+		drm_info(&dev_p->drm, "data_rate=%u active_lanes=%d\n",
+			 (u32) data_rate, mipi_tx_init_cfg.active_lanes);
+
+		/* When late rate < 800, modeset fails with 4 lanes,
+		 * so switch to 2 lanes
+		 */

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+		if (data_rate < 800) {
+			mipi_tx_init_cfg.active_lanes = 2;
+			mipi_tx_init_cfg.lane_rate_mbps = data_rate * 2;
+		} else {
+			mipi_tx_init_cfg.lane_rate_mbps = data_rate;
+		}
+		drm_info(&dev_p->drm,
+			"lane rate=%d\n", mipi_tx_init_cfg.lane_rate_mbps);
+		drm_dbg(&dev_p->drm,
+		     "vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d

hsync_len=%d lane-rate=%d",

Quoted 76 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +76 -0
+		     mipitx_frame0_cfg.v_frontporch,
+		     mipitx_frame0_cfg.v_backporch,
+		     mipitx_frame0_cfg.vsync_width,
+		     mipitx_frame0_cfg.h_frontporch,
+		     mipitx_frame0_cfg.h_backporch,
+		     mipitx_frame0_cfg.hsync_width,
+		     mipi_tx_init_cfg.lane_rate_mbps);
+
+	}
+
+	if (hw_initialized)
+		return 0;
+
+	kmb_write_mipi(dev_p, DPHY_ENABLE, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL0, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL1, 0);
+	kmb_write_mipi(dev_p, DPHY_INIT_CTRL2, 0);
+
+	/* Initialize mipi controller */
+	mipi_tx_init_cntrl(dev_p, &mipi_tx_init_cfg);
+
+	/* Dphy initialization */
+	mipi_tx_init_dphy(dev_p, &mipi_tx_init_cfg);
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		 GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+
+	connect_lcd_to_mipi(dev_p);
+
+#ifdef MIPI_TX_TEST_PATTERN_GENERATION
+	mipi_tx_hs_tp_gen(dev_p, 0, MIPI_TX_HS_TP_V_STRIPES,
+			  0x15, 0xff, 0xff00, MIPI_CTRL6);
+
+	drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+		 GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));
+#endif //MIPI_TX_TEST_PATTERN_GENERATION
+
+	hw_initialized = true;
+
+	drm_dbg(&dev_p->drm, "MIPI_TXm_HS_CTRL = 0x%x\n",
+		 kmb_read_mipi(dev_p, MIPI_TXm_HS_CTRL(6)));
+	drm_dbg(&dev_p->drm, "MIPI LOOP BACK = %x\n",
+		 kmb_read_mipi(dev_p, MIPI_CTRL_DIG_LOOPBACK));
+	drm_info(&dev_p->drm, "mipi hw_initialized = %d\n", hw_initialized);
+
+	return 0;
+}
+
+int kmb_dsi_init(struct drm_device *dev, struct drm_bridge *bridge)
+{
+	struct kmb_dsi *kmb_dsi;
+	struct drm_encoder *encoder;
+	struct kmb_connector *kmb_connector;
+	struct drm_connector *connector;
+	struct kmb_dsi_host *host;
+	int ret = 0;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

drivers/gpu/drm/kmb/kmb_dsi.c line 1787

Quoted 10 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +10 -0
+
+	kmb_dsi = kzalloc(sizeof(*kmb_dsi), GFP_KERNEL);
+	if (!kmb_dsi) {
+		DRM_ERROR("failed to allocate kmb_dsi\n");
+		return -ENOMEM;
+	}
+
+	kmb_connector = kzalloc(sizeof(*kmb_connector), GFP_KERNEL);
+	if (!kmb_connector) {
+		kfree(kmb_dsi);
[… more lines in the raw message]

DRM_MODE_ENCODER_DSI,

drivers/gpu/drm/kmb/kmb_dsi.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +6 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

&kmb_dsi_connector_helper_funcs);

Review

Quoted 20 lines
drivers/gpu/drm/kmb/kmb_dsi.c new file +19 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/gpu/drm/kmb/kmb_dsi.h

drivers/gpu/drm/kmb/kmb_dsi.h

Quoted 319 lines

new file mode 100644
index 0000000..d2beaf4

drivers/gpu/drm/kmb/kmb_dsi.h new file +314 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*sections[MIPI_TX_FRAME_GEN_SECTIONS];

drivers/gpu/drm/kmb/kmb_dsi.h

Quoted 55 lines
drivers/gpu/drm/kmb/kmb_dsi.h new file +55 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*mode);

Review

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_dsi.h new file +1 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/gpu/drm/kmb/kmb_plane.c

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 62 lines

new file mode 100644
index 0000000..55aef5c

drivers/gpu/drm/kmb/kmb_plane.c new file +57 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

KMB_MAX_HEIGHT)

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

KMB_MIN_HEIGHT)

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 36 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +36 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_PLANAR_STORAGE

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 12 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_BGR_ORDER;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +6 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_BGR_ORDER;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +6 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_BGR_ORDER;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 18 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +18 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_BGR_ORDER;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +6 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_BGR_ORDER;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 45 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +45 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[0]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[1]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[2]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[3]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[4]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[5]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[6]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[7]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[8]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[9]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[10]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

csc_coef_lcd[11]);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 32 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +32 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

returning");

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 19 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +10 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

flags=0x%x\n",

drivers/gpu/drm/kmb/kmb_plane.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

dma_len);

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 14 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +14 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_CB_LINE_VSTRIDE(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_CB_LINE_WIDTH(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_START_CR_ADR(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_START_CB_ADR(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_CR_LINE_VSTRIDE(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +13 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_START_CB_ADR(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYERn_DMA_START_CR_ADR(plane_id),

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 56 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +56 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

|

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_DMA_LAYER_AXI_BURST_16;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

dma_cfg,

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 32 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +32 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*plane)

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 29 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +17 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

state);

drivers/gpu/drm/kmb/kmb_plane.c new file +11 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

DRM_MODE_ROTATE_0;

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 27 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +27 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

From a lifetime persepctive I *think* drmm_kzalloc() is the right choice here.

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 18 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +18 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

&kmb_plane_funcs,

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.c new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

num_plane_formats,

drivers/gpu/drm/kmb/kmb_plane.c

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(ret=%d)",

Review

Quoted 23 lines
drivers/gpu/drm/kmb/kmb_plane.c new file +22 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/gpu/drm/kmb/kmb_plane.h

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 33 lines

new file mode 100644
index 0000000..48f237f

drivers/gpu/drm/kmb/kmb_plane.h new file +28 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LAYER2_DMA_FIFO_UNDERFLOW)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LAYER3_DMA_FIFO_UNDERFLOW)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_INT_VL0_ERR)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_INT_VL1_ERR)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_INT_GL0_ERR)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_plane.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_INT_GL1_ERR)

drivers/gpu/drm/kmb/kmb_plane.h

Quoted 39 lines
drivers/gpu/drm/kmb/kmb_plane.h new file +39 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*/

Review

Quoted 53 lines
drivers/gpu/drm/kmb/kmb_plane.h new file +52 -0

Lines of this file are not shown. View the raw message.

(quoted diff) +0 -0

The rest of this diff is not shown. View the raw message.

b/drivers/gpu/drm/kmb/kmb_regs.h

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 21 lines

new file mode 100644
index 0000000..089e42d

drivers/gpu/drm/kmb/kmb_regs.h new file +16 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0x10000)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

+/***************************************************************
************

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*****************************************************************
**********/

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 93 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +92 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

+/***************************************************************
*************

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*****************************************************************
***********

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(LCD_LAYER_SCALE_H | \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(LCD_LAYER_ALPHA_STATIC | \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_LAYER_ALPHA_EMBED)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 57 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +57 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_INV_COLOUR_LS + (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_INV_COLOUR_MS + (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_TRANS_COLOUR_LS + (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_TRANS_COLOUR_MS + (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

+ (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_CFG + (0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(LCD_DMA_LAYER_AUTO_UPDATE \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

LCD_DMA_LAYER_CONT_UPDATE)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 21 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +21 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_ADR \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_SHADOW \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_LEN + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_LEN_SHADOW + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_STATUS + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_LINE_WIDTH + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_LINE_VSTRIDE +\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_FIFO_STATUS + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(0x400*N))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_CB_ADR + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_CB_SHADOW\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_CB_LINE_WIDTH +\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_CB_LINE_VSTRIDE\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_CR_ADR + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_START_CR_SHADOW\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_CR_LINE_WIDTH +\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(LCD_LAYER0_DMA_CR_LINE_VSTRIDE\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 11 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +10 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

+/***************************************************************
*************

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

*****************************************************************
***********/

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 80 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +79 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

+/***************************************************************
************

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

***********************************************i***************** ***********/

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0x400)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 14 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +14 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(MIPI_TX_HS_SYNC_CFG \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 18 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +18 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(MIPI_TX0_HS_FG0_SECT0_PH + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(8*O))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 12 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(MIPI_TX_HS_FG0_SECT_UNPACKED_BYTES0 \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +8 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 4 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +4 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 5 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +5 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M) \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

vc/2), \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 9 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +9 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

1-10 */

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 12 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

\

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

M+N)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 14 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +14 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(MIPI_TX_HS_IRQ_STATUS + \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	MIPI_TX_HS_IRQ_STATUSm(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 17 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +17 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(1<<17)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	(1<<20)

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 23 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +23 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

| \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

	MIPI_TX_HS_IRQ_LLP_REQUEST_QUEUE_ERROR | \

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 29 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +29 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 1 line
drivers/gpu/drm/kmb/kmb_regs.h new file +1 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

0x04))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 6 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +6 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 3 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +3 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

HS_OFFSET(M))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 12 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +12 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(dphy+offset))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 2 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +2 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(dphy+offset))

drivers/gpu/drm/kmb/kmb_regs.h

Quoted 16 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +16 -0

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

(dphy/4)*4)) \

Quoted 62 lines
drivers/gpu/drm/kmb/kmb_regs.h new file +59 -1

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

2.7.4

Quoted 4 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Part of the diff is not shown here. View the raw message.

#4 lore raw

Re: [PATCH v3] drm/kmb: Add support for KeemBay Display

In reply to Anitha Chrisanthus

Hi Anitha.

A few extra details.

drivers/gpu/drm/kmb/kmb_crtc.c line 7

Quoted 13 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +7 -0
new file mode 100644
index 0000000..570d46e
@@ -0,0 +1,219 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright © 2018-2020 Intel Corporation
+ */
+
+#include <linux/clk.h>
+#include <linux/of_graph.h>

Not used, can be dropped. Gos for all includes except the one in kmb_drv.c

drivers/gpu/drm/kmb/kmb_crtc.c line 8

Quoted 1 line
drivers/gpu/drm/kmb/kmb_crtc.c new file +1 -0
+#include <linux/platform_data/simplefb.h>

Not used, can be dropped. Goes for all include of this file.

drivers/gpu/drm/kmb/kmb_crtc.c line 63

Quoted 8 lines
drivers/gpu/drm/kmb/kmb_crtc.c new file +8 -0
+	/* disable vertical interrupt */
+	kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+			LCD_INT_VERT_COMP);
+}
+
+static const struct drm_crtc_funcs kmb_crtc_funcs = {
+	.destroy = kmb_crtc_cleanup,
+	.set_config = drm_atomic_helper_set_config,

From the description of set_config:

* Drivers implementing atomic modeset should use
* drm_atomic_helper_set_config() to implement this hook.

Sam
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/kmb: Add support for KeemBay Display

In reply to Anitha Chrisanthus
== Series Details ==

== Series Details ==

Series: drm/kmb: Add support for KeemBay Display
URL : https://patchwork.freedesktop.org/series/79615/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
09ff5d4b7f4c drm/kmb: Add support for KeemBay Display
-:48: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#48: 
new file mode 100644

-:136: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #136: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:58:
+ kmb_clr_bitmask_lcd(dev_p, LCD_INT_ENABLE,
+ LCD_INT_VERT_COMP);

-:163: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #163: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:85:
+ drm_info(dev,
+ "vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d hsync_len=%d\n",

-:184: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #184: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:106:
+ drm_dbg(dev, "%s : %dactive height= %d vbp=%d vfp=%d vsync-w=%d h-active=%d h-bp=%d h-fp=%d hysnc-l=%d",
+ __func__, __LINE__,

-:189: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #189: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:111:
+ kmb_write_lcd(dev_p, LCD_V_ACTIVEHEIGHT,
+ m->crtc_vdisplay - 1);

-:194: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #194: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:116:
+ kmb_write_lcd(dev_p, LCD_H_ACTIVEWIDTH,
+ m->crtc_hdisplay - 1);

-:207: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #207: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:129:
+ kmb_write_lcd(dev_p,
+ LCD_V_BACKPORCH_EVEN, vm.vback_porch);

-:209: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #209: FILE: drivers/gpu/drm/kmb/kmb_crtc.c:131:
+ kmb_write_lcd(dev_p,
+ LCD_V_FRONTPORCH_EVEN, vm.vfront_porch);

-:342: CHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files #342: FILE: drivers/gpu/drm/kmb/kmb_crtc.h:39:
+extern void kmb_plane_destroy(struct drm_plane *plane);

-:343: CHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files #343: FILE: drivers/gpu/drm/kmb/kmb_crtc.h:40:
+extern struct kmb_plane *kmb_plane_init(struct drm_device *drm);

-:546: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #546: FILE: drivers/gpu/drm/kmb/kmb_drv.c:196:
+ dev_p->sys_clk_mhz = clk_get_rate(clk_pll0)/1000000;
^

-:553: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #553: FILE: drivers/gpu/drm/kmb/kmb_drv.c:203:
+ drm_err(&dev_p->drm, "failed to set to clk_lcd to %d\n",
+ KMB_LCD_DEFAULT_CLK);

-:561: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #561: FILE: drivers/gpu/drm/kmb/kmb_drv.c:211:
+ drm_err(&dev_p->drm, "failed to set to clk_mipi to %d\n",
+ KMB_MIPI_DEFAULT_CLK);

-:588: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #588: FILE: drivers/gpu/drm/kmb/kmb_drv.c:238:
+ drm_err(&dev_p->drm,
+ "failed to set clk_mipi_cfg to %d\n",

-:593: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #593: FILE: drivers/gpu/drm/kmb/kmb_drv.c:243:
+ drm_info(&dev_p->drm,
+ "Get clk_mipi_cfg after set = %ld\n", clk);

-:658: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #658: FILE: drivers/gpu/drm/kmb/kmb_drv.c:308:
+ drm_info(&dev_p->drm,
+ "ICAM mode = 0x%x, priority = 0x%x bandwidth=0x%x",

-:721: CHECK:CAMELCASE: Avoid CamelCase: <LCD_LAYERn_DMA_CFG> #721: FILE: drivers/gpu/drm/kmb/kmb_drv.c:371:
+ LCD_LAYERn_DMA_CFG

-:726: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #726: FILE: drivers/gpu/drm/kmb/kmb_drv.c:376:
+ kmb_clr_bitmask_lcd(dev_p, LCD_CONTROL,
+ plane_status[plane_id].ctrl);

-:753: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #753: FILE: drivers/gpu/drm/kmb/kmb_drv.c:403:
+
+ }

-:794: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #794: FILE: drivers/gpu/drm/kmb/kmb_drv.c:444:
+ drm_info(&dev_p->drm,
+ "!LAYER0:VL0 DMA UNDERFLOW val = 0x%lx,under_flow=%d",

-:807: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #807: FILE: drivers/gpu/drm/kmb/kmb_drv.c:457:
+ kmb_clr_bitmask_lcd(dev_p, LCD_LAYERn_DMA_CFG(0),
+ LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);

-:813: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #813: FILE: drivers/gpu/drm/kmb/kmb_drv.c:463:
+ drm_info(&dev_p->drm,
+ "LAYER0:VL0 DMA OVERFLOW val = 0x%lx", val);

-:816: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #816: FILE: drivers/gpu/drm/kmb/kmb_drv.c:466:
+ drm_info(&dev_p->drm,
+ "LAYER0:VL0 DMA CB OVERFLOW val = 0x%lx", val);

-:819: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #819: FILE: drivers/gpu/drm/kmb/kmb_drv.c:469:
+ drm_info(&dev_p->drm,
+ "LAYER0:VL0 DMA CR OVERFLOW val = 0x%lx", val);

-:827: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #827: FILE: drivers/gpu/drm/kmb/kmb_drv.c:477:
+ drm_info(&dev_p->drm,
+ "!LAYER1:VL1 DMA UNDERFLOW val = 0x%lx, under_flow=%d",

-:840: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #840: FILE: drivers/gpu/drm/kmb/kmb_drv.c:490:
+ kmb_clr_bitmask_lcd(dev_p, LCD_LAYERn_DMA_CFG(1),
+ LCD_DMA_LAYER_CONT_PING_PONG_UPDATE);

-:847: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #847: FILE: drivers/gpu/drm/kmb/kmb_drv.c:497:
+ drm_info(&dev_p->drm,
+ "LAYER1:VL1 DMA OVERFLOW val = 0x%lx", val);

-:850: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #850: FILE: drivers/gpu/drm/kmb/kmb_drv.c:500:
+ drm_info(&dev_p->drm,
+ "LAYER1:VL1 DMA CB OVERFLOW val = 0x%lx", val);

-:853: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #853: FILE: drivers/gpu/drm/kmb/kmb_drv.c:503:
+ drm_info(&dev_p->drm,
+ "LAYER1:VL1 DMA CR OVERFLOW val = 0x%lx", val);

-:858: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #858: FILE: drivers/gpu/drm/kmb/kmb_drv.c:508:
+ drm_info(&dev_p->drm,
+ "LAYER2:GL0 DMA UNDERFLOW val = 0x%lx", val);

-:861: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #861: FILE: drivers/gpu/drm/kmb/kmb_drv.c:511:
+ drm_info(&dev_p->drm,
+ "LAYER2:GL0 DMA OVERFLOW val = 0x%lx", val);

-:866: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #866: FILE: drivers/gpu/drm/kmb/kmb_drv.c:516:
+ drm_info(&dev_p->drm,
+ "LAYER3:GL1 DMA UNDERFLOW val = 0x%lx", val);

-:869: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #869: FILE: drivers/gpu/drm/kmb/kmb_drv.c:519:
+ drm_info(&dev_p->drm,
+ "LAYER3:GL1 DMA OVERFLOW val = 0x%lx", val);

-:986: CHECK:BRACES: braces {} should be used on all arms of this statement #986: FILE: drivers/gpu/drm/kmb/kmb_drv.c:636:
+ if (adv_bridge == ERR_PTR(-EPROBE_DEFER))
[...]
+ else if (IS_ERR(adv_bridge)) {
[...]

-:995: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #995: FILE: drivers/gpu/drm/kmb/kmb_drv.c:645:
+ dev_p = devm_drm_dev_alloc(dev, &kmb_driver,
+ struct kmb_drm_private, drm);

-:1008: CHECK:BRACES: braces {} should be used on all arms of this statement #1008: FILE: drivers/gpu/drm/kmb/kmb_drv.c:658:
+ if (ret == -EPROBE_DEFER) {
[...]
+ } else if (ret)
[...]

-:1018: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1018: FILE: drivers/gpu/drm/kmb/kmb_drv.c:668:
+ drm_info(&dev_p->drm, "mode_config.num_crtc=%d\n",
+ dev_p->drm.mode_config.num_crtc);

-:1054: WARNING:UNDOCUMENTED_DT_STRING: DT compatible string "intel,kmb_display" appears un-documented -- check ./Documentation/devicetree/bindings/ #1054: FILE: drivers/gpu/drm/kmb/kmb_drv.c:704:
+ {.compatible = "intel,kmb_display"},

-:1151: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment #1151: FILE: drivers/gpu/drm/kmb/kmb_drv.h:36:
+ spinlock_t irq_lock;

-:1379: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #1379: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:93:
+ uint16_t default_bit_rate_mbps;

-:1380: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #1380: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:94:
+ uint8_t hsfreqrange_code;

-:1481: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1481: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:195:
+ if (mode->hdisplay < mode_config->min_width ||
+ mode->hdisplay > mode_config->max_width)

-:1485: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1485: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:199:
+ if (mode->vdisplay < mode_config->min_height ||
+ mode->vdisplay > mode_config->max_height)

-:1496: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1496: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:210:
+ num_modes = drm_add_modes_noedid(connector,
+ connector->dev->mode_config.max_width,

-:1791: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1791: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:505:
+ drm_dbg(&dev_p->drm,
+ "ctrl=%d frame_id=%d section=%d cfg=%x packed=%d\n",

-:1794: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_FGn_SECTo_PH> #1794: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:508:
+ (MIPI_TXm_HS_FGn_SECTo_PH(ctrl_no, frame_id, section)),

-:1806: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_FGn_SECT_UNPACKED_BYTES0> #1806: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:520:
+ MIPI_TXm_HS_FGn_SECT_UNPACKED_BYTES0(ctrl_no,

-:1811: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1811: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:525:
+ drm_dbg(&dev_p->drm,
+ "unpacked_bytes = %d, wordcount = %d\n", unpacked_bytes,

-:1815: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_FGn_SECTo_LINE_CFG> #1815: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:529:
+ reg_adr = MIPI_TXm_HS_FGn_SECTo_LINE_CFG(ctrl_no, frame_id, section);

-:1847: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1847: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:561:
+ unpacked_bytes = compute_unpacked_bytes(*wc,
+ data_type_parameters.bits_per_pclk);

-:1888: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1888: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:602:
+ drm_dbg(&dev_p->drm, "bpp=%d sysclk=%d lane-rate=%d activ-lanes=%d\n",
+ fg_cfg->bpp, sysclk, fg_cfg->lane_rate_mbps,

-:1892: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_FGn_NUM_LINES> #1892: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:606:
+ reg_adr = MIPI_TXm_HS_FGn_NUM_LINES(ctrl_no, frame_gen);

-:1902: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_VSYNC_WIDTHn> #1902: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:616:
+ reg_adr = MIPI_TXm_HS_VSYNC_WIDTHn(ctrl_no, frame_gen / 2);

-:1906: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_V_BACKPORCHESn> #1906: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:620:
+ reg_adr = MIPI_TXm_HS_V_BACKPORCHESn(ctrl_no, frame_gen / 2);

-:1910: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_V_FRONTPORCHESn> #1910: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:624:
+ reg_adr = MIPI_TXm_HS_V_FRONTPORCHESn(ctrl_no, frame_gen / 2);

-:1914: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_V_ACTIVEn> #1914: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:628:
+ reg_adr = MIPI_TXm_HS_V_ACTIVEn(ctrl_no, frame_gen / 2);

-:1918: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_HSYNC_WIDTHn> #1918: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:632:
+ reg_adr = MIPI_TXm_HS_HSYNC_WIDTHn(ctrl_no, frame_gen);

-:1923: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_H_BACKPORCHn> #1923: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:637:
+ reg_adr = MIPI_TXm_HS_H_BACKPORCHn(ctrl_no, frame_gen);

-:1928: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_H_FRONTPORCHn> #1928: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:642:
+ reg_adr = MIPI_TXm_HS_H_FRONTPORCHn(ctrl_no, frame_gen);

-:1933: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_H_ACTIVEn> #1933: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:647:
+ reg_adr = MIPI_TXm_HS_H_ACTIVEn(ctrl_no, frame_gen);

-:1942: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_LLP_HSYNC_WIDTHn> #1942: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:656:
+ reg_adr = MIPI_TXm_HS_LLP_HSYNC_WIDTHn(ctrl_no, frame_gen);

-:1946: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_LLP_H_BACKPORCHn> #1946: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:660:
+ reg_adr = MIPI_TXm_HS_LLP_H_BACKPORCHn(ctrl_no, frame_gen);

-:1950: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_LLP_H_FRONTPORCHn> #1950: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:664:
+ reg_adr = MIPI_TXm_HS_LLP_H_FRONTPORCHn(ctrl_no, frame_gen);

-:1966: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "fg_cfg->sections[i]" #1966: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:680:
+ if (fg_cfg->sections[i] != NULL)

-:2014: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_MC_FIFO_CTRL_EN> #2014: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:728:
+ kmb_set_bit_mipi(dev_p, MIPI_TXm_HS_MC_FIFO_CTRL_EN(ctrl_no),

-:2071: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_SYNC_CFG> #2071: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:785:
+ kmb_write_mipi(dev_p, MIPI_TXm_HS_SYNC_CFG(ctrl_no), sync_cfg);

-:2072: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_CTRL> #2072: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:786:
+ kmb_write_mipi(dev_p, MIPI_TXm_HS_CTRL(ctrl_no), ctrl);

-:2083: CHECK:CAMELCASE: Avoid CamelCase: <TP_SEL_VCm> #2083: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:797:
+ val = TP_SEL_VCm(vc, tp_sel);

-:2086: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_TEST_PAT_COLOR0> #2086: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:800:
+ kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR0(ctrl_no), color0);

-:2087: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_TEST_PAT_COLOR1> #2087: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:801:
+ kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_COLOR1(ctrl_no), color1);

-:2090: CHECK:CAMELCASE: Avoid CamelCase: <TP_EN_VCm> #2090: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:804:
+ val |= TP_EN_VCm(vc);

-:2091: CHECK:CAMELCASE: Avoid CamelCase: <MIPI_TXm_HS_TEST_PAT_CTRL> #2091: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:805:
+ kmb_write_mipi(dev_p, MIPI_TXm_HS_TEST_PAT_CTRL(ctrl_no), val);

-:2093: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #2093: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:807:
+
+}

-:2118: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!frame" #2118: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:832:
+ if (frame == NULL)

-:2126: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!frame->sections[sect]" #2126: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:840:
+ if (frame->sections[sect] == NULL)

-:2136: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #2136: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:850:
+
+ }

-:2165: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2165: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:879:
+ drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+ GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));

-:2357: CHECK:SPACING: spaces preferred around that '*' (ctx:ExV) #2357: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1071:
+ *dev_p,
^

-:2370: CHECK:SPACING: spaces preferred around that '*' (ctx:ExV) #2370: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1084:
+ *dev_p,
^

-:2537: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2537: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1251:
+ drm_dbg(&dev_p->drm, "dphy %d fsm_state = 0%x\n", dphy_no,
+ kmb_read_mipi(dev_p, DPHY_TEST_DOUT4_7));

-:2549: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2549: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1263:
+ drm_info(&dev_p->drm,
+ "dphy=%d mode=%d active_lanes=%d\n", dphy_no, mode,

-:2552: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2552: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1266:
+ drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+ kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));

-:2576: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2576: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1290:
+ drm_dbg(&dev_p->drm, "DPHY_TEST_CTRL0=0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_TEST_CTRL0));

-:2677: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #2677: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1391:
+
+ }

-:2684: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2684: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1398:
+ drm_dbg(&dev_p->drm, "DPHY_FREQ = 0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_FREQ_CTRL0_3 + 4));

-:2686: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2686: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1400:
+ drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+ kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));

-:2692: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2692: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1406:
+ drm_dbg(&dev_p->drm, "DPHY_CFG_CLK_EN = 0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_CFG_CLK_EN));

-:2713: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2713: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1427:
+ drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL1 = 0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_INIT_CTRL1));

-:2717: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2717: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1431:
+ drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+ kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));

-:2758: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2758: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1472:
+ drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+ kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));

-:2770: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2770: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1484:
+ drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL2 = 0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_INIT_CTRL2));

-:2783: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2783: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1497:
+ drm_dbg(&dev_p->drm, "MIPI_DPHY_STAT0_4_7 = 0x%x)\n",
+ kmb_read_mipi(dev_p, MIPI_DPHY_STAT4_7));

-:2790: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2790: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1504:
+ drm_dbg(&dev_p->drm, "DPHY_INIT_CTRL0 = 0x%x\n",
+ kmb_read_mipi(dev_p, DPHY_INIT_CTRL0));

-:2825: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2825: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1539:
+ drm_dbg(&dev_p->drm, "dphy=%d active_lanes=%d data_lanes=%d\n", dphy_no,
+ active_lanes, data_lanes);

-:2838: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2838: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1552:
+ drm_info(&dev_p->drm,
+ "! WAIT_INIT_DONE: TIMING OUT!(err_stat=%d)",

-:2897: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2897: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1611:
+ drm_info(&dev_p->drm,
+ "active_lanes=%d lane_rate=%d\n", cfg->active_lanes,

-:2965: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "mode" #2965: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1679:
+ if (mode != NULL) {

-:2984: CHECK:SPACING: No space is necessary after a cast #2984: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1698:
+ data_rate = ((((u32) mode->crtc_vtotal *

-:2985: CHECK:SPACING: No space is necessary after a cast #2985: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1699:
+ (u32) mode->crtc_htotal) *

-:2994: CHECK:SPACING: No space is necessary after a cast #2994: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1708:
+ (u32) data_rate, mipi_tx_init_cfg.active_lanes);

-:3006: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3006: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1720:
+ drm_info(&dev_p->drm,
+ "lane rate=%d\n", mipi_tx_init_cfg.lane_rate_mbps);

-:3008: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3008: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1722:
+ drm_dbg(&dev_p->drm,
+ "vfp= %d vbp= %d vsyc_len=%d hfp=%d hbp=%d hsync_len=%d lane-rate=%d",

-:3017: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #3017: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1731:
+
+ }

-:3033: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3033: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1747:
+ drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+ GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));

-:3042: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3042: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1756:
+ drm_dbg(&dev_p->drm, "IRQ_STATUS = 0x%x\n",
+ GET_MIPI_TX_HS_IRQ_STATUS(dev_p, MIPI_CTRL6));

-:3048: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3048: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1762:
+ drm_dbg(&dev_p->drm, "MIPI_TXm_HS_CTRL = 0x%x\n",
+ kmb_read_mipi(dev_p, MIPI_TXm_HS_CTRL(6)));

-:3050: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3050: FILE: drivers/gpu/drm/kmb/kmb_dsi.c:1764:
+ drm_dbg(&dev_p->drm, "MIPI LOOP BACK = %x\n",
+ kmb_read_mipi(dev_p, MIPI_CTRL_DIG_LOOPBACK));

-:3382: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3382: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:257:
+ uint8_t size_constraint_pixels;

-:3383: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3383: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:258:
+ uint8_t size_constraint_bytes;

-:3384: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3384: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:259:
+ uint8_t pixels_per_pclk;

-:3385: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3385: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:260:
+ uint8_t bits_per_pclk;

-:3389: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3389: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:264:
+ uint8_t hfp_blank_en; /*horizontal front porch blanking enable */

-:3390: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3390: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:265:
+ uint8_t eotp_en; /*End of transmission packet enable */

-:3392: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3392: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:267:
+ uint8_t lpm_last_vfp_line;

-:3394: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3394: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:269:
+ uint8_t lpm_first_vsa_line;

-:3395: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3395: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:270:
+ uint8_t sync_pulse_eventn; /*sync type */

-:3396: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3396: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:271:
+ uint8_t hfp_blanking; /*horizontal front porch blanking mode */

-:3397: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3397: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:272:
+ uint8_t hbp_blanking; /*horizontal back porch blanking mode */

-:3398: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3398: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:273:
+ uint8_t hsa_blanking; /*horizontal sync active blanking mode */

-:3399: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3399: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:274:
+ uint8_t v_blanking; /*vertical timing blanking mode */

-:3403: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3403: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:278:
+ uint32_t dma_v_stride;

-:3404: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3404: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:279:
+ uint16_t dma_v_scale_cfg;

-:3405: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3405: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:280:
+ uint16_t width_pixels;

-:3406: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3406: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:281:
+ uint16_t height_lines;

-:3407: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3407: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:282:
+ uint8_t dma_packed;

-:3408: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3408: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:283:
+ uint8_t bpp;

-:3409: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3409: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:284:
+ uint8_t bpp_unpacked;

-:3410: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3410: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:285:
+ uint8_t dma_h_stride;

-:3411: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3411: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:286:
+ uint8_t data_type;

-:3412: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3412: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:287:
+ uint8_t data_mode;

-:3413: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3413: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:288:
+ uint8_t dma_flip_rotate_sel;

-:3417: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3417: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:292:
+ uint32_t bpp;

-:3418: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3418: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:293:
+ uint32_t lane_rate_mbps;

-:3419: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3419: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:294:
+ uint32_t hsync_width;

-:3420: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3420: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:295:
+ uint32_t h_backporch;

-:3421: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3421: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:296:
+ uint32_t h_frontporch;

-:3422: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3422: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:297:
+ uint32_t h_active;

-:3423: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3423: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:298:
+ uint16_t vsync_width;

-:3424: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3424: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:299:
+ uint16_t v_backporch;

-:3425: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3425: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:300:
+ uint16_t v_frontporch;

-:3426: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3426: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:301:
+ uint16_t v_active;

-:3427: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3427: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:302:
+ uint8_t active_lanes;

-:3431: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3431: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:306:
+ uint32_t wc;

-:3434: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3434: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:309:
+ uint8_t vchannel;

-:3435: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3435: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:310:
+ uint8_t dma_packed;

-:3440: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3440: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:315:
+ uint32_t hsync_width; /*in pixels */

-:3441: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3441: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:316:
+ uint32_t h_backporch; /*in pixels */

-:3442: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3442: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:317:
+ uint32_t h_frontporch; /*in pixels */

-:3443: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3443: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:318:
+ uint16_t vsync_width; /*in lines */

-:3444: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3444: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:319:
+ uint16_t v_backporch; /*in lines */

-:3445: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u16' over 'uint16_t' #3445: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:320:
+ uint16_t v_frontporch; /*in lines */

-:3451: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3451: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:326:
+ uint8_t line_sync_pkt_en;

-:3452: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3452: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:327:
+ uint8_t line_counter_active;

-:3453: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3453: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:328:
+ uint8_t frame_counter_active;

-:3454: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3454: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:329:
+ uint8_t tx_hsclkkidle_cnt;

-:3455: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3455: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:330:
+ uint8_t tx_hsexit_cnt;

-:3456: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3456: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:331:
+ uint8_t tx_crc_en;

-:3457: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3457: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:332:
+ uint8_t tx_hact_wait_stop;

-:3458: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3458: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:333:
+ uint8_t tx_always_use_hact;

-:3459: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3459: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:334:
+ uint8_t tx_wait_trig;

-:3460: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3460: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:335:
+ uint8_t tx_wait_all_sect;

-:3466: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3466: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:341:
+ uint8_t index;

-:3467: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3467: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:342:
+ uint8_t type; /* controller type : MIPI_DSI */

-:3468: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3468: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:343:
+ uint8_t dir; /* controller direction : MIPI_TX */

-:3469: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u8' over 'uint8_t' #3469: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:344:
+ uint8_t active_lanes; /* # active lanes per controller 2/4 */

-:3470: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t' #3470: FILE: drivers/gpu/drm/kmb/kmb_dsi.h:345:
+ ui

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/kmb: Add support for KeemBay Display

In reply to Anitha Chrisanthus
== Series Details ==

== Series Details ==

Series: drm/kmb: Add support for KeemBay Display
URL : https://patchwork.freedesktop.org/series/79615/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8761 -> Patchwork_18208
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/index.html

Known issues
------------

Here are the changes found in Patchwork_18208 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_suspend@basic-s0:
- fi-tgl-u2: [PASS][1] -> [FAIL][2] ([i915#1888])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-tgl-u2/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-tgl-u2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@b-edp1:
- fi-icl-u2: [PASS][3] -> [DMESG-WARN][4] ([i915#1982]) +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-icl-u2/igt@kms_flip@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-icl-u2/igt@kms_flip@[email protected]

* igt@vgem_basic@mmap:
- fi-tgl-y: [PASS][5] -> [DMESG-WARN][6] ([i915#402]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-tgl-y/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-tgl-y/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-bsw-kefka: [DMESG-WARN][7] ([i915#1982]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-bsw-kefka/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-bsw-kefka/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-kbl-guc: [FAIL][9] ([i915#138]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-kbl-guc/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-kbl-guc/igt@[email protected]

* igt@i915_selftest@live@execlists:
- fi-cfl-8700k: [INCOMPLETE][11] ([i915#2089]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-cfl-8700k/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-cfl-8700k/igt@i915_selftest@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-icl-u2: [DMESG-WARN][13] ([i915#1982]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-icl-u2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-icl-u2/igt@[email protected]
- {fi-tgl-dsi}: [DMESG-WARN][15] ([i915#1982]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-tgl-dsi/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-tgl-dsi/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
- fi-tgl-u2: [DMESG-WARN][17] ([i915#402]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-tgl-u2/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-tgl-u2/igt@[email protected]

* igt@prime_self_import@basic-with_two_bos:
- fi-tgl-y: [DMESG-WARN][19] ([i915#402]) -> [PASS][20] +1 similar issue
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-tgl-y/igt@prime_self_import@basic-with_two_bos.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-tgl-y/igt@prime_self_import@basic-with_two_bos.html

#### Warnings ####

* igt@debugfs_test@read_all_entries:
- fi-kbl-x1275: [DMESG-WARN][21] ([i915#62] / [i915#92]) -> [DMESG-WARN][22] ([i915#62] / [i915#92] / [i915#95]) +3 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-kbl-x1275/igt@debugfs_test@read_all_entries.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-kbl-x1275/igt@debugfs_test@read_all_entries.html

* igt@kms_force_connector_basic@force-edid:
- fi-kbl-x1275: [DMESG-WARN][23] ([i915#62] / [i915#92] / [i915#95]) -> [DMESG-WARN][24] ([i915#62] / [i915#92]) +3 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/fi-kbl-x1275/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/fi-kbl-x1275/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#138]: https://gitlab.freedesktop.org/drm/intel/issues/138
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2089]: https://gitlab.freedesktop.org/drm/intel/issues/2089
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#92]: https://gitlab.freedesktop.org/drm/intel/issues/92
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95

Participating hosts (47 -> 40)
------------------------------

Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_8761 -> Patchwork_18208

CI-20190529: 20190529
CI_DRM_8761: b665aabc40b8c7e86f10a74171d3d3fd71251781 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5739: 9b964d7359db9799f2b5b905403dda668ae28c87 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_18208: 09ff5d4b7f4c89cda75065728d647b676cbc43ed @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

09ff5d4b7f4c drm/kmb: Add support for KeemBay Display

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

[Intel-gfx] ✗ Fi.CI.IGT: failure for drm/kmb: Add support for KeemBay Display

In reply to Anitha Chrisanthus
== Series Details ==

== Series Details ==

Series: drm/kmb: Add support for KeemBay Display
URL : https://patchwork.freedesktop.org/series/79615/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8761_full -> Patchwork_18208_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_18208_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_18208_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_18208_full:

### IGT changes ###

#### Possible regressions ####

* igt@gem_ctx_persistence@legacy-engines-hang@render:
- shard-iclb: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-iclb1/igt@gem_ctx_persistence@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-iclb7/igt@gem_ctx_persistence@[email protected]
- shard-tglb: [PASS][3] -> [FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb3/igt@gem_ctx_persistence@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb5/igt@gem_ctx_persistence@[email protected]

* igt@gem_eio@hibernate:
- shard-iclb: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-iclb2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-iclb1/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_18208_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@preservation-s3@vecs0:
- shard-skl: [PASS][7] -> [INCOMPLETE][8] ([i915#198])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl10/igt@gem_ctx_isolation@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl8/igt@gem_ctx_isolation@[email protected]

* igt@gem_ctx_persistence@legacy-engines-mixed-process@bsd:
- shard-skl: [PASS][9] -> [FAIL][10] ([i915#1528])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl8/igt@gem_ctx_persistence@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl1/igt@gem_ctx_persistence@[email protected]

* igt@gem_exec_fence@parallel@bcs0:
- shard-glk: [PASS][11] -> [DMESG-WARN][12] ([i915#118] / [i915#95])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-glk7/igt@gem_exec_fence@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-glk2/igt@gem_exec_fence@[email protected]

* igt@gem_softpin@noreloc-s3:
- shard-kbl: [PASS][13] -> [INCOMPLETE][14] ([i915#1959])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl7/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl1/igt@[email protected]

* igt@kms_big_fb@x-tiled-64bpp-rotate-180:
- shard-glk: [PASS][15] -> [DMESG-FAIL][16] ([i915#118] / [i915#95]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-glk3/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-glk8/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic:
- shard-skl: [PASS][17] -> [DMESG-WARN][18] ([i915#1982]) +9 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl4/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl1/igt@[email protected]

* igt@kms_flip@2x-wf_vblank-ts-check-interruptible@ab-vga1-hdmi-a1:
- shard-hsw: [PASS][19] -> [DMESG-WARN][20] ([i915#1982])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-hsw6/igt@kms_flip@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-hsw6/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible@a-dp1:
- shard-kbl: [PASS][21] -> [DMESG-WARN][22] ([i915#180]) +4 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl3/igt@kms_flip@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl6/igt@kms_flip@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-shrfb-plflip-blt:
- shard-kbl: [PASS][23] -> [DMESG-WARN][24] ([i915#1982])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl6/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl7/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-modesetfrombusy:
- shard-tglb: [PASS][25] -> [DMESG-WARN][26] ([i915#1982]) +1 similar issue
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb5/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb7/igt@[email protected]

* igt@kms_hdr@bpc-switch-suspend:
- shard-skl: [PASS][27] -> [FAIL][28] ([i915#1188])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl6/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl4/igt@[email protected]

* igt@kms_plane@plane-panning-bottom-right-pipe-b-planes:
- shard-skl: [PASS][29] -> [FAIL][30] ([i915#1036])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl5/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl3/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
- shard-skl: [PASS][31] -> [FAIL][32] ([fdo#108145] / [i915#265]) +1 similar issue
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl8/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl1/igt@[email protected]

* igt@kms_psr2_su@page_flip:
- shard-iclb: [PASS][33] -> [SKIP][34] ([fdo#109642] / [fdo#111068])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-iclb2/igt@kms_psr2_su@page_flip.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-iclb5/igt@kms_psr2_su@page_flip.html

* igt@kms_psr@psr2_sprite_mmap_gtt:
- shard-iclb: [PASS][35] -> [SKIP][36] ([fdo#109441]) +1 similar issue
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-iclb5/igt@kms_psr@psr2_sprite_mmap_gtt.html

* igt@kms_setmode@basic:
- shard-kbl: [PASS][37] -> [FAIL][38] ([i915#31])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl2/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl2/igt@[email protected]

* igt@kms_vblank@pipe-b-ts-continuation-suspend:
- shard-tglb: [PASS][39] -> [DMESG-WARN][40] ([i915#402])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb3/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb5/igt@[email protected]

* igt@perf_pmu@semaphore-busy@rcs0:
- shard-kbl: [PASS][41] -> [FAIL][42] ([i915#1820])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl3/igt@perf_pmu@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl6/igt@perf_pmu@[email protected]

#### Possible fixes ####

* igt@gem_eio@in-flight-contexts-10ms:
- shard-hsw: [TIMEOUT][43] ([i915#1958] / [i915#1976] / [i915#2119]) -> [PASS][44]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-hsw2/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-hsw4/igt@[email protected]

* igt@gem_exec_balancer@bonded-early:
- shard-kbl: [FAIL][45] ([i915#2079]) -> [PASS][46]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl4/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl4/igt@[email protected]

* igt@gem_exec_create@madvise:
- shard-glk: [DMESG-WARN][47] ([i915#118] / [i915#95]) -> [PASS][48] +2 similar issues
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-glk9/igt@[email protected]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-glk5/igt@[email protected]

* igt@gen9_exec_parse@allowed-all:
- shard-apl: [DMESG-WARN][49] ([i915#1436] / [i915#1635] / [i915#716]) -> [PASS][50]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-apl8/igt@[email protected]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-apl8/igt@[email protected]

* igt@i915_module_load@reload:
- shard-tglb: [DMESG-WARN][51] ([i915#402]) -> [PASS][52] +1 similar issue
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb5/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb7/igt@[email protected]

* igt@i915_selftest@mock@requests:
- shard-skl: [INCOMPLETE][53] ([i915#198] / [i915#2110]) -> [PASS][54]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl8/igt@i915_selftest@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl7/igt@i915_selftest@[email protected]

* igt@kms_big_fb@linear-64bpp-rotate-180:
- shard-glk: [DMESG-FAIL][55] ([i915#118] / [i915#95]) -> [PASS][56]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-glk8/igt@[email protected]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-glk5/igt@[email protected]

* igt@kms_cursor_legacy@cursor-vs-flip-atomic-transitions-varying-size:
- shard-skl: [DMESG-WARN][57] ([i915#1982]) -> [PASS][58] +5 similar issues
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl7/igt@kms_cursor_legacy@cursor-vs-flip-atomic-transitions-varying-size.html
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl6/igt@kms_cursor_legacy@cursor-vs-flip-atomic-transitions-varying-size.html

* igt@kms_flip@flip-vs-panning@b-edp1:
- shard-tglb: [INCOMPLETE][59] -> [PASS][60]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb6/igt@kms_flip@[email protected]
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb8/igt@kms_flip@[email protected]

* igt@kms_flip@plain-flip-ts-check@c-hdmi-a1:
- shard-glk: [FAIL][61] ([i915#2122]) -> [PASS][62]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-glk3/igt@kms_flip@[email protected]
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-glk1/igt@kms_flip@[email protected]

* igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-mmap-wc:
- shard-tglb: [DMESG-WARN][63] ([i915#1982]) -> [PASS][64] +1 similar issue
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-tglb8/igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-mmap-wc.html
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-tglb7/igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-mmap-wc.html

* igt@kms_hdr@bpc-switch-suspend:
- shard-kbl: [DMESG-WARN][65] ([i915#180]) -> [PASS][66] +7 similar issues
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-kbl7/igt@[email protected]
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-kbl4/igt@[email protected]

* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: [SKIP][67] ([fdo#109441]) -> [PASS][68] +2 similar issues
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-iclb7/igt@kms_psr@psr2_primary_mmap_cpu.html
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

#### Warnings ####

* igt@runner@aborted:
- shard-apl: ([FAIL][69], [FAIL][70], [FAIL][71]) ([fdo#109271] / [i915#1610] / [i915#1635] / [i915#2110] / [i915#716]) -> [FAIL][72] ([i915#1635] / [i915#2110])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-apl8/igt@[email protected]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-apl6/igt@[email protected]
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-apl2/igt@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-apl4/igt@[email protected]
- shard-skl: ([FAIL][73], [FAIL][74]) ([i915#2110]) -> [FAIL][75] ([i915#1611])
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl8/igt@[email protected]
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8761/shard-skl10/igt@[email protected]
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/shard-skl3/igt@[email protected]

[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[i915#1036]: https://gitlab.freedesktop.org/drm/intel/issues/1036
[i915#118]: https://gitlab.freedesktop.org/drm/intel/issues/118
[i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#1528]: https://gitlab.freedesktop.org/drm/intel/issues/1528
[i915#1610]: https://gitlab.freedesktop.org/drm/intel/issues/1610
[i915#1611]: https://gitlab.freedesktop.org/drm/intel/issues/1611
[i915#1635]: https://gitlab.freedesktop.org/drm/intel/issues/1635
[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#1820]: https://gitlab.freedesktop.org/drm/intel/issues/1820
[i915#1958]: https://gitlab.freedesktop.org/drm/intel/issues/1958
[i915#1959]: https://gitlab.freedesktop.org/drm/intel/issues/1959
[i915#1976]: https://gitlab.freedesktop.org/drm/intel/issues/1976
[i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2079]: https://gitlab.freedesktop.org/drm/intel/issues/2079
[i915#2110]: https://gitlab.freedesktop.org/drm/intel/issues/2110
[i915#2119]: https://gitlab.freedesktop.org/drm/intel/issues/2119
[i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
[i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
[i915#31]: https://gitlab.freedesktop.org/drm/intel/issues/31
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
[i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95

Participating hosts (10 -> 10)
------------------------------

No changes in participating hosts

Build changes
-------------

* Linux: CI_DRM_8761 -> Patchwork_18208

CI-20190529: 20190529
CI_DRM_8761: b665aabc40b8c7e86f10a74171d3d3fd71251781 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5739: 9b964d7359db9799f2b5b905403dda668ae28c87 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_18208: 09ff5d4b7f4c89cda75065728d647b676cbc43ed @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18208/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx