Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-30 Thread Nickey Yang

Hi Matthias,


On 2017年11月29日 04:48, Matthias Kaehlcke wrote:

El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:


Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
MIPI DSI host controller bridge.

v2:
add err_pllref, remove unnecessary encoder.enable & disable
correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
fix typo, use of_device_get_match_data(),
change some ‘bind()’ logic into 'probe()'
add 'dev_set_drvdata()'

Signed-off-by: Nickey Yang 
---
  drivers/gpu/drm/rockchip/Kconfig|2 +-
  drivers/gpu/drm/rockchip/Makefile   |2 +-
  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 ---
  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
  6 files changed, 768 insertions(+), 1353 deletions(-)
  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 0ccc762..9eb4795 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP
select VIDEOMODE_HELPERS
select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
-   select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
+   select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
help
  Choose this option if you have a Rockchip soc chipset.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index a314e21..c05fe47 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
rockchip_drm_fbdev.o
  rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
  rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
  rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
-rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
  rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
  rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
  
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c

deleted file mode 100644
index b15755b..000
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/*
- * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rockchip_drm_drv.h"
-#include "rockchip_drm_vop.h"
-
-#define DRIVER_NAME"dw-mipi-dsi"
-
-#define RK3288_GRF_SOC_CON60x025c
-#define RK3288_DSI0_SEL_VOP_LITBIT(6)
-#define RK3288_DSI1_SEL_VOP_LITBIT(9)
-
-#define RK3399_GRF_SOC_CON20   0x6250
-#define RK3399_DSI0_SEL_VOP_LITBIT(0)
-#define RK3399_DSI1_SEL_VOP_LITBIT(4)
-
-/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
-#define RK3399_GRF_SOC_CON22   0x6258
-#define RK3399_GRF_DSI_MODE0x
-
-#define DSI_VERSION0x00
-#define DSI_PWR_UP 0x04
-#define RESET  0
-#define POWERUPBIT(0)
-
-#define DSI_CLKMGR_CFG 0x08
-#define TO_CLK_DIVIDSION(div)  (((div) & 0xff) << 8)
-#define TX_ESC_CLK_DIVIDSION(div)  (((div) & 0xff) << 0)
-
-#define DSI_DPI_VCID   0x0c
-#define DPI_VID(vid)   (((vid) & 0x3) << 0)
-
-#define DSI_DPI_COLOR_CODING   0x10
-#define EN18_LOOSELY   BIT(8)
-#define DPI_COLOR_CODING_16BIT_1   0x0
-#define DPI_COLOR_CODING_16BIT_2   0x1
-#define DPI_COLOR_CODING_16BIT_3   0x2
-#define DPI_COLOR_CODING_18BIT_1   0x3
-#define DPI_COLOR_CODING_18BIT_2   0x4
-#define DPI_COLOR_CODING_24BIT 0x5
-
-#define DSI_DPI_CFG_POL0x14
-#define COLORM_ACTIVE_LOW  BIT(4)
-#define SHUTD_ACTIVE_LOW   BIT(3)
-#define HSYNC_ACTIVE_LOW   BIT(2)
-#define VSYNC_ACTIVE_LOW   BIT(1)
-#define DATAEN_ACTIVE_LOW  BIT(0)
-
-#define DSI_DPI_LP_CMD_TIM 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-30 Thread Nickey Yang

Hi Matthias,


On 2017年11月29日 04:48, Matthias Kaehlcke wrote:

El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:


Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
MIPI DSI host controller bridge.

v2:
add err_pllref, remove unnecessary encoder.enable & disable
correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
fix typo, use of_device_get_match_data(),
change some ‘bind()’ logic into 'probe()'
add 'dev_set_drvdata()'

Signed-off-by: Nickey Yang 
---
  drivers/gpu/drm/rockchip/Kconfig|2 +-
  drivers/gpu/drm/rockchip/Makefile   |2 +-
  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 ---
  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
  6 files changed, 768 insertions(+), 1353 deletions(-)
  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 0ccc762..9eb4795 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP
select VIDEOMODE_HELPERS
select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
-   select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
+   select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
help
  Choose this option if you have a Rockchip soc chipset.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index a314e21..c05fe47 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
rockchip_drm_fbdev.o
  rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
  rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
  rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
-rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
  rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
  rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
  
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c

deleted file mode 100644
index b15755b..000
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/*
- * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rockchip_drm_drv.h"
-#include "rockchip_drm_vop.h"
-
-#define DRIVER_NAME"dw-mipi-dsi"
-
-#define RK3288_GRF_SOC_CON60x025c
-#define RK3288_DSI0_SEL_VOP_LITBIT(6)
-#define RK3288_DSI1_SEL_VOP_LITBIT(9)
-
-#define RK3399_GRF_SOC_CON20   0x6250
-#define RK3399_DSI0_SEL_VOP_LITBIT(0)
-#define RK3399_DSI1_SEL_VOP_LITBIT(4)
-
-/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
-#define RK3399_GRF_SOC_CON22   0x6258
-#define RK3399_GRF_DSI_MODE0x
-
-#define DSI_VERSION0x00
-#define DSI_PWR_UP 0x04
-#define RESET  0
-#define POWERUPBIT(0)
-
-#define DSI_CLKMGR_CFG 0x08
-#define TO_CLK_DIVIDSION(div)  (((div) & 0xff) << 8)
-#define TX_ESC_CLK_DIVIDSION(div)  (((div) & 0xff) << 0)
-
-#define DSI_DPI_VCID   0x0c
-#define DPI_VID(vid)   (((vid) & 0x3) << 0)
-
-#define DSI_DPI_COLOR_CODING   0x10
-#define EN18_LOOSELY   BIT(8)
-#define DPI_COLOR_CODING_16BIT_1   0x0
-#define DPI_COLOR_CODING_16BIT_2   0x1
-#define DPI_COLOR_CODING_16BIT_3   0x2
-#define DPI_COLOR_CODING_18BIT_1   0x3
-#define DPI_COLOR_CODING_18BIT_2   0x4
-#define DPI_COLOR_CODING_24BIT 0x5
-
-#define DSI_DPI_CFG_POL0x14
-#define COLORM_ACTIVE_LOW  BIT(4)
-#define SHUTD_ACTIVE_LOW   BIT(3)
-#define HSYNC_ACTIVE_LOW   BIT(2)
-#define VSYNC_ACTIVE_LOW   BIT(1)
-#define DATAEN_ACTIVE_LOW  BIT(0)
-
-#define DSI_DPI_LP_CMD_TIM 0x18
-#define 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-29 Thread Brian Norris
On Tue, Nov 28, 2017 at 6:02 PM, Sean Paul  wrote:
> On Tue, Nov 28, 2017 at 02:55:41PM -0800, Brian Norris wrote:
>> On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
>> > El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
>> >
>> > > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
>> > > MIPI DSI host controller bridge.
>> > >
>> > > v2:
>> > >add err_pllref, remove unnecessary encoder.enable & disable
>> > >correct spelling mistakes
>> > > v3:
>> > >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
>> > >fix typo, use of_device_get_match_data(),
>> > >change some ‘bind()’ logic into 'probe()'
>> > >add 'dev_set_drvdata()'
>>
>> I believe the changelog normally goes below the "---", so it gets
>> dropped when a maintainer applies a final version.
>>
>
> We're kind of different in drm land. Some prefer to keep the changelog above 
> the
> fold and attribute the changes to reviewers so they get recognition for their
> efforts.

Ah, now I remember reading that somewhere. Seems nice, I suppose. (And
hey, git logs are cheap.) I guess my "I don't review DRM patches much"
status is showing :)

> At any rate, I'm just happy to see changelogs.

Yep :)

Brian


Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-29 Thread Brian Norris
On Tue, Nov 28, 2017 at 6:02 PM, Sean Paul  wrote:
> On Tue, Nov 28, 2017 at 02:55:41PM -0800, Brian Norris wrote:
>> On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
>> > El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
>> >
>> > > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
>> > > MIPI DSI host controller bridge.
>> > >
>> > > v2:
>> > >add err_pllref, remove unnecessary encoder.enable & disable
>> > >correct spelling mistakes
>> > > v3:
>> > >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
>> > >fix typo, use of_device_get_match_data(),
>> > >change some ‘bind()’ logic into 'probe()'
>> > >add 'dev_set_drvdata()'
>>
>> I believe the changelog normally goes below the "---", so it gets
>> dropped when a maintainer applies a final version.
>>
>
> We're kind of different in drm land. Some prefer to keep the changelog above 
> the
> fold and attribute the changes to reviewers so they get recognition for their
> efforts.

Ah, now I remember reading that somewhere. Seems nice, I suppose. (And
hey, git logs are cheap.) I guess my "I don't review DRM patches much"
status is showing :)

> At any rate, I'm just happy to see changelogs.

Yep :)

Brian


Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Sean Paul
On Tue, Nov 28, 2017 at 02:55:41PM -0800, Brian Norris wrote:
> Hi Nickey,
> 
> On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
> > El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
> > 
> > > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> > > MIPI DSI host controller bridge.
> > > 
> > > v2:
> > >add err_pllref, remove unnecessary encoder.enable & disable
> > >correct spelling mistakes
> > > v3:
> > >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
> > >fix typo, use of_device_get_match_data(),
> > >change some ‘bind()’ logic into 'probe()'
> > >add 'dev_set_drvdata()'
> 
> I believe the changelog normally goes below the "---", so it gets
> dropped when a maintainer applies a final version.
> 

We're kind of different in drm land. Some prefer to keep the changelog above the
fold and attribute the changes to reviewers so they get recognition for their
efforts.

At any rate, I'm just happy to see changelogs.

> > > 
> > > Signed-off-by: Nickey Yang 
> > > ---
> > >  drivers/gpu/drm/rockchip/Kconfig|2 +-
> > >  drivers/gpu/drm/rockchip/Makefile   |2 +-
> > >  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> > > ---
> > >  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
> > >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
> > >  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
> > >  6 files changed, 768 insertions(+), 1353 deletions(-)
> > >  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > >  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > 
> 
> ...
> 
> > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> > > b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > > deleted file mode 100644
> > > index b15755b..000
> > > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > > +++ /dev/null
> > > @@ -1,1349 +0,0 @@
> 
> ...
> 
> > > -static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
> > > -struct mipi_dsi_device *device)
> > > -{
> > > - struct dw_mipi_dsi *dsi = host_to_dsi(host);
> > > -
> > > - if (device->lanes > dsi->pdata->max_data_lanes) {
> > > - DRM_DEV_ERROR(dsi->dev,
> > > -   "the number of data lanes(%u) is too many\n",
> > > -   device->lanes);
> > > - return -EINVAL;
> > > - }
> > > -
> > > - dsi->lanes = device->lanes;
> > > - dsi->channel = device->channel;
> > > - dsi->format = device->format;
> > > - dsi->mode_flags = device->mode_flags;
> > > - dsi->panel = of_drm_find_panel(device->dev.of_node);
> 
> IIUC, you're implicitly making a device tree binding change, because the
> original driver uses just of_drm_find_panel(), as above, but the common
> bridge driver is using drm_of_find_panel_or_bridge(), which puts a
> little more stringent requirements on the device tree.
> 
> I don't think that's necessarily a bad thing, and there isn't much in
> the way of "real" device trees that actually used the existing driver
> and binding (probably mostly test devices and prototypes), so maybe it's
> better to just make the switch and not worry about compatibility. But I
> just wanted to point that out, in case anyone else was interested or
> concerned.
> 
> > > - if (dsi->panel)
> > > - return drm_panel_attach(dsi->panel, >connector);
> > > -
> > > - return -EINVAL;
> > > -}
> > > -
> 
> ...
> 
> > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c 
> > > b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > new file mode 100644
> > > index 000..c682ed2
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > @@ -0,0 +1,764 @@
> 
> ...
> 
> > > +static int dw_mipi_dsi_phy_init(void *priv_data)
> > > +{
> > > + struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > > + int ret, i, vco;
> > > +
> > > + vco = (dsi->lane_mbps < 200) ? 0 : (dsi->lane_mbps + 100) / 200;
> > 
> > Please add a clarifying comment as requested by Sean on
> > https://chromium-review.googlesource.com/#/c/chromiumos/third_party/kernel/+/780120/
> 
> FWIW, that code was already in the existing driver. Would be nice to
> improve anyway, of course.
> 

Yeah, not a showstopper, but it'd be nice to know what's going on here.

> ...
> 
> > > +static int
> > > +dw_mipi_dsi_get_lane_mbps(void *priv_data, struct drm_display_mode *mode,
> > > +   unsigned long mode_flags, u32 lanes, u32 format,
> > > +   unsigned int *lane_mbps)
> > > +{
> > > + struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > > + int bpp;
> > > + unsigned long mpclk, tmp;
> > > + unsigned int target_mbps = 1000;
> > > + unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps;
> > > + unsigned long best_freq = 0;
> > > + unsigned long fvco_min, fvco_max, fin, fout;
> > > + unsigned int min_prediv, max_prediv;
> > > + unsigned 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Sean Paul
On Tue, Nov 28, 2017 at 02:55:41PM -0800, Brian Norris wrote:
> Hi Nickey,
> 
> On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
> > El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
> > 
> > > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> > > MIPI DSI host controller bridge.
> > > 
> > > v2:
> > >add err_pllref, remove unnecessary encoder.enable & disable
> > >correct spelling mistakes
> > > v3:
> > >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
> > >fix typo, use of_device_get_match_data(),
> > >change some ‘bind()’ logic into 'probe()'
> > >add 'dev_set_drvdata()'
> 
> I believe the changelog normally goes below the "---", so it gets
> dropped when a maintainer applies a final version.
> 

We're kind of different in drm land. Some prefer to keep the changelog above the
fold and attribute the changes to reviewers so they get recognition for their
efforts.

At any rate, I'm just happy to see changelogs.

> > > 
> > > Signed-off-by: Nickey Yang 
> > > ---
> > >  drivers/gpu/drm/rockchip/Kconfig|2 +-
> > >  drivers/gpu/drm/rockchip/Makefile   |2 +-
> > >  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> > > ---
> > >  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
> > >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
> > >  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
> > >  6 files changed, 768 insertions(+), 1353 deletions(-)
> > >  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > >  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > 
> 
> ...
> 
> > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> > > b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > > deleted file mode 100644
> > > index b15755b..000
> > > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > > +++ /dev/null
> > > @@ -1,1349 +0,0 @@
> 
> ...
> 
> > > -static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
> > > -struct mipi_dsi_device *device)
> > > -{
> > > - struct dw_mipi_dsi *dsi = host_to_dsi(host);
> > > -
> > > - if (device->lanes > dsi->pdata->max_data_lanes) {
> > > - DRM_DEV_ERROR(dsi->dev,
> > > -   "the number of data lanes(%u) is too many\n",
> > > -   device->lanes);
> > > - return -EINVAL;
> > > - }
> > > -
> > > - dsi->lanes = device->lanes;
> > > - dsi->channel = device->channel;
> > > - dsi->format = device->format;
> > > - dsi->mode_flags = device->mode_flags;
> > > - dsi->panel = of_drm_find_panel(device->dev.of_node);
> 
> IIUC, you're implicitly making a device tree binding change, because the
> original driver uses just of_drm_find_panel(), as above, but the common
> bridge driver is using drm_of_find_panel_or_bridge(), which puts a
> little more stringent requirements on the device tree.
> 
> I don't think that's necessarily a bad thing, and there isn't much in
> the way of "real" device trees that actually used the existing driver
> and binding (probably mostly test devices and prototypes), so maybe it's
> better to just make the switch and not worry about compatibility. But I
> just wanted to point that out, in case anyone else was interested or
> concerned.
> 
> > > - if (dsi->panel)
> > > - return drm_panel_attach(dsi->panel, >connector);
> > > -
> > > - return -EINVAL;
> > > -}
> > > -
> 
> ...
> 
> > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c 
> > > b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > new file mode 100644
> > > index 000..c682ed2
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > > @@ -0,0 +1,764 @@
> 
> ...
> 
> > > +static int dw_mipi_dsi_phy_init(void *priv_data)
> > > +{
> > > + struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > > + int ret, i, vco;
> > > +
> > > + vco = (dsi->lane_mbps < 200) ? 0 : (dsi->lane_mbps + 100) / 200;
> > 
> > Please add a clarifying comment as requested by Sean on
> > https://chromium-review.googlesource.com/#/c/chromiumos/third_party/kernel/+/780120/
> 
> FWIW, that code was already in the existing driver. Would be nice to
> improve anyway, of course.
> 

Yeah, not a showstopper, but it'd be nice to know what's going on here.

> ...
> 
> > > +static int
> > > +dw_mipi_dsi_get_lane_mbps(void *priv_data, struct drm_display_mode *mode,
> > > +   unsigned long mode_flags, u32 lanes, u32 format,
> > > +   unsigned int *lane_mbps)
> > > +{
> > > + struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > > + int bpp;
> > > + unsigned long mpclk, tmp;
> > > + unsigned int target_mbps = 1000;
> > > + unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps;
> > > + unsigned long best_freq = 0;
> > > + unsigned long fvco_min, fvco_max, fin, fout;
> > > + unsigned int min_prediv, max_prediv;
> > > + unsigned int _prediv, 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Brian Norris
Hi Nickey,

On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
> El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
> 
> > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> > MIPI DSI host controller bridge.
> > 
> > v2:
> >add err_pllref, remove unnecessary encoder.enable & disable
> >correct spelling mistakes
> > v3:
> >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
> >fix typo, use of_device_get_match_data(),
> >change some ‘bind()’ logic into 'probe()'
> >add 'dev_set_drvdata()'

I believe the changelog normally goes below the "---", so it gets
dropped when a maintainer applies a final version.

> > 
> > Signed-off-by: Nickey Yang 
> > ---
> >  drivers/gpu/drm/rockchip/Kconfig|2 +-
> >  drivers/gpu/drm/rockchip/Makefile   |2 +-
> >  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> > ---
> >  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
> >  6 files changed, 768 insertions(+), 1353 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > 

...

> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> > b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > deleted file mode 100644
> > index b15755b..000
> > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > +++ /dev/null
> > @@ -1,1349 +0,0 @@

...

> > -static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
> > -  struct mipi_dsi_device *device)
> > -{
> > -   struct dw_mipi_dsi *dsi = host_to_dsi(host);
> > -
> > -   if (device->lanes > dsi->pdata->max_data_lanes) {
> > -   DRM_DEV_ERROR(dsi->dev,
> > - "the number of data lanes(%u) is too many\n",
> > - device->lanes);
> > -   return -EINVAL;
> > -   }
> > -
> > -   dsi->lanes = device->lanes;
> > -   dsi->channel = device->channel;
> > -   dsi->format = device->format;
> > -   dsi->mode_flags = device->mode_flags;
> > -   dsi->panel = of_drm_find_panel(device->dev.of_node);

IIUC, you're implicitly making a device tree binding change, because the
original driver uses just of_drm_find_panel(), as above, but the common
bridge driver is using drm_of_find_panel_or_bridge(), which puts a
little more stringent requirements on the device tree.

I don't think that's necessarily a bad thing, and there isn't much in
the way of "real" device trees that actually used the existing driver
and binding (probably mostly test devices and prototypes), so maybe it's
better to just make the switch and not worry about compatibility. But I
just wanted to point that out, in case anyone else was interested or
concerned.

> > -   if (dsi->panel)
> > -   return drm_panel_attach(dsi->panel, >connector);
> > -
> > -   return -EINVAL;
> > -}
> > -

...

> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c 
> > b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > new file mode 100644
> > index 000..c682ed2
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > @@ -0,0 +1,764 @@

...

> > +static int dw_mipi_dsi_phy_init(void *priv_data)
> > +{
> > +   struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > +   int ret, i, vco;
> > +
> > +   vco = (dsi->lane_mbps < 200) ? 0 : (dsi->lane_mbps + 100) / 200;
> 
> Please add a clarifying comment as requested by Sean on
> https://chromium-review.googlesource.com/#/c/chromiumos/third_party/kernel/+/780120/

FWIW, that code was already in the existing driver. Would be nice to
improve anyway, of course.

...

> > +static int
> > +dw_mipi_dsi_get_lane_mbps(void *priv_data, struct drm_display_mode *mode,
> > + unsigned long mode_flags, u32 lanes, u32 format,
> > + unsigned int *lane_mbps)
> > +{
> > +   struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > +   int bpp;
> > +   unsigned long mpclk, tmp;
> > +   unsigned int target_mbps = 1000;
> > +   unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps;
> > +   unsigned long best_freq = 0;
> > +   unsigned long fvco_min, fvco_max, fin, fout;
> > +   unsigned int min_prediv, max_prediv;
> > +   unsigned int _prediv, uninitialized_var(best_prediv);
> > +   unsigned long _fbdiv, uninitialized_var(best_fbdiv);
> > +   unsigned long min_delta = ULONG_MAX;
> > +
> > +   dsi->format = format;
> > +   bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> > +   if (bpp < 0) {
> > +   DRM_DEV_ERROR(dsi->dev,
> > + "failed to get bpp for pixel format %d\n",
> > + dsi->format);
> > +   return bpp;
> > +   }
> > +
> > +   mpclk = DIV_ROUND_UP(mode->clock, MSEC_PER_SEC);
> > +   if (mpclk) {

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Brian Norris
Hi Nickey,

On Tue, Nov 28, 2017 at 12:48:43PM -0800, Matthias Kaehlcke wrote:
> El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:
> 
> > Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> > MIPI DSI host controller bridge.
> > 
> > v2:
> >add err_pllref, remove unnecessary encoder.enable & disable
> >correct spelling mistakes
> > v3:
> >call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
> >fix typo, use of_device_get_match_data(),
> >change some ‘bind()’ logic into 'probe()'
> >add 'dev_set_drvdata()'

I believe the changelog normally goes below the "---", so it gets
dropped when a maintainer applies a final version.

> > 
> > Signed-off-by: Nickey Yang 
> > ---
> >  drivers/gpu/drm/rockchip/Kconfig|2 +-
> >  drivers/gpu/drm/rockchip/Makefile   |2 +-
> >  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> > ---
> >  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
> >  6 files changed, 768 insertions(+), 1353 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > 

...

> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> > b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > deleted file mode 100644
> > index b15755b..000
> > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > +++ /dev/null
> > @@ -1,1349 +0,0 @@

...

> > -static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
> > -  struct mipi_dsi_device *device)
> > -{
> > -   struct dw_mipi_dsi *dsi = host_to_dsi(host);
> > -
> > -   if (device->lanes > dsi->pdata->max_data_lanes) {
> > -   DRM_DEV_ERROR(dsi->dev,
> > - "the number of data lanes(%u) is too many\n",
> > - device->lanes);
> > -   return -EINVAL;
> > -   }
> > -
> > -   dsi->lanes = device->lanes;
> > -   dsi->channel = device->channel;
> > -   dsi->format = device->format;
> > -   dsi->mode_flags = device->mode_flags;
> > -   dsi->panel = of_drm_find_panel(device->dev.of_node);

IIUC, you're implicitly making a device tree binding change, because the
original driver uses just of_drm_find_panel(), as above, but the common
bridge driver is using drm_of_find_panel_or_bridge(), which puts a
little more stringent requirements on the device tree.

I don't think that's necessarily a bad thing, and there isn't much in
the way of "real" device trees that actually used the existing driver
and binding (probably mostly test devices and prototypes), so maybe it's
better to just make the switch and not worry about compatibility. But I
just wanted to point that out, in case anyone else was interested or
concerned.

> > -   if (dsi->panel)
> > -   return drm_panel_attach(dsi->panel, >connector);
> > -
> > -   return -EINVAL;
> > -}
> > -

...

> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c 
> > b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > new file mode 100644
> > index 000..c682ed2
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> > @@ -0,0 +1,764 @@

...

> > +static int dw_mipi_dsi_phy_init(void *priv_data)
> > +{
> > +   struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > +   int ret, i, vco;
> > +
> > +   vco = (dsi->lane_mbps < 200) ? 0 : (dsi->lane_mbps + 100) / 200;
> 
> Please add a clarifying comment as requested by Sean on
> https://chromium-review.googlesource.com/#/c/chromiumos/third_party/kernel/+/780120/

FWIW, that code was already in the existing driver. Would be nice to
improve anyway, of course.

...

> > +static int
> > +dw_mipi_dsi_get_lane_mbps(void *priv_data, struct drm_display_mode *mode,
> > + unsigned long mode_flags, u32 lanes, u32 format,
> > + unsigned int *lane_mbps)
> > +{
> > +   struct dw_mipi_dsi_rockchip *dsi = priv_data;
> > +   int bpp;
> > +   unsigned long mpclk, tmp;
> > +   unsigned int target_mbps = 1000;
> > +   unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps;
> > +   unsigned long best_freq = 0;
> > +   unsigned long fvco_min, fvco_max, fin, fout;
> > +   unsigned int min_prediv, max_prediv;
> > +   unsigned int _prediv, uninitialized_var(best_prediv);
> > +   unsigned long _fbdiv, uninitialized_var(best_fbdiv);
> > +   unsigned long min_delta = ULONG_MAX;
> > +
> > +   dsi->format = format;
> > +   bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> > +   if (bpp < 0) {
> > +   DRM_DEV_ERROR(dsi->dev,
> > + "failed to get bpp for pixel format %d\n",
> > + dsi->format);
> > +   return bpp;
> > +   }
> > +
> > +   mpclk = DIV_ROUND_UP(mode->clock, MSEC_PER_SEC);
> > +   if (mpclk) {
> > +   /* take 1 / 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Matthias Kaehlcke
El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:

> Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> MIPI DSI host controller bridge.
> 
> v2:
>add err_pllref, remove unnecessary encoder.enable & disable
>correct spelling mistakes
> v3:
>call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
>fix typo, use of_device_get_match_data(),
>change some ‘bind()’ logic into 'probe()'
>add 'dev_set_drvdata()'
> 
> Signed-off-by: Nickey Yang 
> ---
>  drivers/gpu/drm/rockchip/Kconfig|2 +-
>  drivers/gpu/drm/rockchip/Makefile   |2 +-
>  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> ---
>  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
>  6 files changed, 768 insertions(+), 1353 deletions(-)
>  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> 
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> index 0ccc762..9eb4795 100644
> --- a/drivers/gpu/drm/rockchip/Kconfig
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -7,7 +7,7 @@ config DRM_ROCKCHIP
>   select VIDEOMODE_HELPERS
>   select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
>   select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
> - select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
> + select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
>   select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
>   help
> Choose this option if you have a Rockchip soc chipset.
> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> index a314e21..c05fe47 100644
> --- a/drivers/gpu/drm/rockchip/Makefile
> +++ b/drivers/gpu/drm/rockchip/Makefile
> @@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
> rockchip_drm_fbdev.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
> -rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
> +rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
>  
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> deleted file mode 100644
> index b15755b..000
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ /dev/null
> @@ -1,1349 +0,0 @@
> -/*
> - * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "rockchip_drm_drv.h"
> -#include "rockchip_drm_vop.h"
> -
> -#define DRIVER_NAME"dw-mipi-dsi"
> -
> -#define RK3288_GRF_SOC_CON6  0x025c
> -#define RK3288_DSI0_SEL_VOP_LIT  BIT(6)
> -#define RK3288_DSI1_SEL_VOP_LIT  BIT(9)
> -
> -#define RK3399_GRF_SOC_CON20 0x6250
> -#define RK3399_DSI0_SEL_VOP_LIT  BIT(0)
> -#define RK3399_DSI1_SEL_VOP_LIT  BIT(4)
> -
> -/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
> -#define RK3399_GRF_SOC_CON22 0x6258
> -#define RK3399_GRF_DSI_MODE  0x
> -
> -#define DSI_VERSION  0x00
> -#define DSI_PWR_UP   0x04
> -#define RESET0
> -#define POWERUP  BIT(0)
> -
> -#define DSI_CLKMGR_CFG   0x08
> -#define TO_CLK_DIVIDSION(div)(((div) & 0xff) << 8)
> -#define TX_ESC_CLK_DIVIDSION(div)(((div) & 0xff) << 0)
> -
> -#define DSI_DPI_VCID 0x0c
> -#define DPI_VID(vid) (((vid) & 0x3) << 0)
> -
> -#define DSI_DPI_COLOR_CODING 0x10
> -#define EN18_LOOSELY BIT(8)
> -#define DPI_COLOR_CODING_16BIT_1 0x0
> -#define DPI_COLOR_CODING_16BIT_2 0x1
> -#define DPI_COLOR_CODING_16BIT_3 0x2
> -#define DPI_COLOR_CODING_18BIT_1 0x3
> -#define DPI_COLOR_CODING_18BIT_2 0x4
> -#define DPI_COLOR_CODING_24BIT   0x5
> -
> -#define DSI_DPI_CFG_POL  0x14
> -#define COLORM_ACTIVE_LOWBIT(4)
> -#define SHUTD_ACTIVE_LOW BIT(3)
> -#define HSYNC_ACTIVE_LOW BIT(2)
> 

Re: [PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Matthias Kaehlcke
El Tue, Nov 28, 2017 at 07:20:05PM +0800 Nickey Yang ha dit:

> Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
> MIPI DSI host controller bridge.
> 
> v2:
>add err_pllref, remove unnecessary encoder.enable & disable
>correct spelling mistakes
> v3:
>call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
>fix typo, use of_device_get_match_data(),
>change some ‘bind()’ logic into 'probe()'
>add 'dev_set_drvdata()'
> 
> Signed-off-by: Nickey Yang 
> ---
>  drivers/gpu/drm/rockchip/Kconfig|2 +-
>  drivers/gpu/drm/rockchip/Makefile   |2 +-
>  drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 
> ---
>  drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
>  6 files changed, 768 insertions(+), 1353 deletions(-)
>  delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>  create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c
> 
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> index 0ccc762..9eb4795 100644
> --- a/drivers/gpu/drm/rockchip/Kconfig
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -7,7 +7,7 @@ config DRM_ROCKCHIP
>   select VIDEOMODE_HELPERS
>   select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
>   select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
> - select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
> + select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
>   select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
>   help
> Choose this option if you have a Rockchip soc chipset.
> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> index a314e21..c05fe47 100644
> --- a/drivers/gpu/drm/rockchip/Makefile
> +++ b/drivers/gpu/drm/rockchip/Makefile
> @@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
> rockchip_drm_fbdev.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
> -rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
> +rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
>  rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
>  
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> deleted file mode 100644
> index b15755b..000
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ /dev/null
> @@ -1,1349 +0,0 @@
> -/*
> - * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "rockchip_drm_drv.h"
> -#include "rockchip_drm_vop.h"
> -
> -#define DRIVER_NAME"dw-mipi-dsi"
> -
> -#define RK3288_GRF_SOC_CON6  0x025c
> -#define RK3288_DSI0_SEL_VOP_LIT  BIT(6)
> -#define RK3288_DSI1_SEL_VOP_LIT  BIT(9)
> -
> -#define RK3399_GRF_SOC_CON20 0x6250
> -#define RK3399_DSI0_SEL_VOP_LIT  BIT(0)
> -#define RK3399_DSI1_SEL_VOP_LIT  BIT(4)
> -
> -/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
> -#define RK3399_GRF_SOC_CON22 0x6258
> -#define RK3399_GRF_DSI_MODE  0x
> -
> -#define DSI_VERSION  0x00
> -#define DSI_PWR_UP   0x04
> -#define RESET0
> -#define POWERUP  BIT(0)
> -
> -#define DSI_CLKMGR_CFG   0x08
> -#define TO_CLK_DIVIDSION(div)(((div) & 0xff) << 8)
> -#define TX_ESC_CLK_DIVIDSION(div)(((div) & 0xff) << 0)
> -
> -#define DSI_DPI_VCID 0x0c
> -#define DPI_VID(vid) (((vid) & 0x3) << 0)
> -
> -#define DSI_DPI_COLOR_CODING 0x10
> -#define EN18_LOOSELY BIT(8)
> -#define DPI_COLOR_CODING_16BIT_1 0x0
> -#define DPI_COLOR_CODING_16BIT_2 0x1
> -#define DPI_COLOR_CODING_16BIT_3 0x2
> -#define DPI_COLOR_CODING_18BIT_1 0x3
> -#define DPI_COLOR_CODING_18BIT_2 0x4
> -#define DPI_COLOR_CODING_24BIT   0x5
> -
> -#define DSI_DPI_CFG_POL  0x14
> -#define COLORM_ACTIVE_LOWBIT(4)
> -#define SHUTD_ACTIVE_LOW BIT(3)
> -#define HSYNC_ACTIVE_LOW BIT(2)
> -#define VSYNC_ACTIVE_LOW 

[PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Nickey Yang
Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
MIPI DSI host controller bridge.

v2:
   add err_pllref, remove unnecessary encoder.enable & disable
   correct spelling mistakes
v3:
   call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
   fix typo, use of_device_get_match_data(),
   change some ‘bind()’ logic into 'probe()'
   add 'dev_set_drvdata()'

Signed-off-by: Nickey Yang 
---
 drivers/gpu/drm/rockchip/Kconfig|2 +-
 drivers/gpu/drm/rockchip/Makefile   |2 +-
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 ---
 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
 6 files changed, 768 insertions(+), 1353 deletions(-)
 delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
 create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 0ccc762..9eb4795 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP
select VIDEOMODE_HELPERS
select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
-   select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
+   select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
help
  Choose this option if you have a Rockchip soc chipset.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index a314e21..c05fe47 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
rockchip_drm_fbdev.o
 rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
 rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
-rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
 rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
 
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
deleted file mode 100644
index b15755b..000
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/*
- * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rockchip_drm_drv.h"
-#include "rockchip_drm_vop.h"
-
-#define DRIVER_NAME"dw-mipi-dsi"
-
-#define RK3288_GRF_SOC_CON60x025c
-#define RK3288_DSI0_SEL_VOP_LITBIT(6)
-#define RK3288_DSI1_SEL_VOP_LITBIT(9)
-
-#define RK3399_GRF_SOC_CON20   0x6250
-#define RK3399_DSI0_SEL_VOP_LITBIT(0)
-#define RK3399_DSI1_SEL_VOP_LITBIT(4)
-
-/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
-#define RK3399_GRF_SOC_CON22   0x6258
-#define RK3399_GRF_DSI_MODE0x
-
-#define DSI_VERSION0x00
-#define DSI_PWR_UP 0x04
-#define RESET  0
-#define POWERUPBIT(0)
-
-#define DSI_CLKMGR_CFG 0x08
-#define TO_CLK_DIVIDSION(div)  (((div) & 0xff) << 8)
-#define TX_ESC_CLK_DIVIDSION(div)  (((div) & 0xff) << 0)
-
-#define DSI_DPI_VCID   0x0c
-#define DPI_VID(vid)   (((vid) & 0x3) << 0)
-
-#define DSI_DPI_COLOR_CODING   0x10
-#define EN18_LOOSELY   BIT(8)
-#define DPI_COLOR_CODING_16BIT_1   0x0
-#define DPI_COLOR_CODING_16BIT_2   0x1
-#define DPI_COLOR_CODING_16BIT_3   0x2
-#define DPI_COLOR_CODING_18BIT_1   0x3
-#define DPI_COLOR_CODING_18BIT_2   0x4
-#define DPI_COLOR_CODING_24BIT 0x5
-
-#define DSI_DPI_CFG_POL0x14
-#define COLORM_ACTIVE_LOW  BIT(4)
-#define SHUTD_ACTIVE_LOW   BIT(3)
-#define HSYNC_ACTIVE_LOW   BIT(2)
-#define VSYNC_ACTIVE_LOW   BIT(1)
-#define DATAEN_ACTIVE_LOW  BIT(0)
-
-#define DSI_DPI_LP_CMD_TIM 0x18
-#define OUTVACT_LPCMD_TIME(p)  (((p) & 0xff) << 16)
-#define INVACT_LPCMD_TIME(p)   ((p) & 0xff)
-
-#define DSI_DBI_CFG 

[PATCH v3 4/5] drm/rockchip: Add ROCKCHIP DW MIPI DSI controller driver

2017-11-28 Thread Nickey Yang
Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare
MIPI DSI host controller bridge.

v2:
   add err_pllref, remove unnecessary encoder.enable & disable
   correct spelling mistakes
v3:
   call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind()
   fix typo, use of_device_get_match_data(),
   change some ‘bind()’ logic into 'probe()'
   add 'dev_set_drvdata()'

Signed-off-by: Nickey Yang 
---
 drivers/gpu/drm/rockchip/Kconfig|2 +-
 drivers/gpu/drm/rockchip/Makefile   |2 +-
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c  | 1349 ---
 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c |  764 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c |2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h |2 +-
 6 files changed, 768 insertions(+), 1353 deletions(-)
 delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
 create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi_rockchip.c

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 0ccc762..9eb4795 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP
select VIDEOMODE_HELPERS
select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP
select DRM_DW_HDMI if ROCKCHIP_DW_HDMI
-   select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
+   select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI
select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC
help
  Choose this option if you have a Rockchip soc chipset.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index a314e21..c05fe47 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
rockchip_drm_fbdev.o
 rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
 rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
-rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi_rockchip.o
 rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
 rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
 
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
deleted file mode 100644
index b15755b..000
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/*
- * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rockchip_drm_drv.h"
-#include "rockchip_drm_vop.h"
-
-#define DRIVER_NAME"dw-mipi-dsi"
-
-#define RK3288_GRF_SOC_CON60x025c
-#define RK3288_DSI0_SEL_VOP_LITBIT(6)
-#define RK3288_DSI1_SEL_VOP_LITBIT(9)
-
-#define RK3399_GRF_SOC_CON20   0x6250
-#define RK3399_DSI0_SEL_VOP_LITBIT(0)
-#define RK3399_DSI1_SEL_VOP_LITBIT(4)
-
-/* disable turnrequest, turndisable, forcetxstopmode, forcerxmode */
-#define RK3399_GRF_SOC_CON22   0x6258
-#define RK3399_GRF_DSI_MODE0x
-
-#define DSI_VERSION0x00
-#define DSI_PWR_UP 0x04
-#define RESET  0
-#define POWERUPBIT(0)
-
-#define DSI_CLKMGR_CFG 0x08
-#define TO_CLK_DIVIDSION(div)  (((div) & 0xff) << 8)
-#define TX_ESC_CLK_DIVIDSION(div)  (((div) & 0xff) << 0)
-
-#define DSI_DPI_VCID   0x0c
-#define DPI_VID(vid)   (((vid) & 0x3) << 0)
-
-#define DSI_DPI_COLOR_CODING   0x10
-#define EN18_LOOSELY   BIT(8)
-#define DPI_COLOR_CODING_16BIT_1   0x0
-#define DPI_COLOR_CODING_16BIT_2   0x1
-#define DPI_COLOR_CODING_16BIT_3   0x2
-#define DPI_COLOR_CODING_18BIT_1   0x3
-#define DPI_COLOR_CODING_18BIT_2   0x4
-#define DPI_COLOR_CODING_24BIT 0x5
-
-#define DSI_DPI_CFG_POL0x14
-#define COLORM_ACTIVE_LOW  BIT(4)
-#define SHUTD_ACTIVE_LOW   BIT(3)
-#define HSYNC_ACTIVE_LOW   BIT(2)
-#define VSYNC_ACTIVE_LOW   BIT(1)
-#define DATAEN_ACTIVE_LOW  BIT(0)
-
-#define DSI_DPI_LP_CMD_TIM 0x18
-#define OUTVACT_LPCMD_TIME(p)  (((p) & 0xff) << 16)
-#define INVACT_LPCMD_TIME(p)   ((p) & 0xff)
-
-#define DSI_DBI_CFG0x20
-#define