Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-13 Thread Sandy Huang



在 2017/8/11 22:44, Sean Paul 写道:

On Fri, Aug 11, 2017 at 10:15:16AM +0800, Sandy Huang wrote:



在 2017/8/11 2:05, Sean Paul 写道:

On Thu, Aug 10, 2017 at 05:35:52PM +0800, Sandy Huang wrote:

Hi Sean Paul,
  Thanks for your review.

在 2017/8/10 3:58, Sean Paul 写道:

On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:

This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
drivers/gpu/drm/rockchip/Kconfig |   9 +
drivers/gpu/drm/rockchip/Makefile|   1 +
drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 
+++
drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
4 files changed, 856 insertions(+)
create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h






diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c





+   lvds->drm_dev = drm_dev;
+   port = of_graph_get_port_by_id(dev->of_node, 1);
+   if (!port) {
+   dev_err(dev, "can't found port point, please init lvds panel 
port!\n");
+   return -EINVAL;
+   }
+
+   for_each_child_of_node(port, endpoint) {
+   remote = of_graph_get_remote_port_parent(endpoint);
+   if (!remote) {
+   dev_err(dev, "can't found panel node, please init!\n");
+   ret = -EINVAL;
+   goto err_put_port;
+   }
+   if (!of_device_is_available(remote)) {
+   of_node_put(remote);
+   remote = NULL;
+   continue;
+   }
+   break;
+   }
+   if (!remote) {
+   dev_err(dev, "can't found remote node, please init!\n");
+   ret = -EINVAL;
+   goto err_put_port;
+   }
+
+   lvds->panel = of_drm_find_panel(remote);
+   if (!lvds->panel)
+   lvds->bridge = of_drm_find_bridge(remote);


drm_of_find_panel_or_bridge()



because the lvds ports maybe connect to lvds-panel or connect to
rk1000(which is convert RGB to CVBS output), so i have to get the remote
port parent and check the status, and final get the active remote point.






lvds_panel: lvds-panel {
status = "disabled";
ports {
panel_in_lvds: endpoint {
remote-endpoint = <_out_panel>;
};
};
};

rk1000: rk1000@0xff00 {
status = "okay";
ports {
rk1000_in_lvds: endpoint {
remote-endpoint = <_out_panel>;
};
};
};

 {
status = "okay";
ports {
lvds_out: port@1 {
reg = <1>;
lvds_out_panel: endpoint@0 {
reg = <0>;
remote-endpoint = <_in_lvds>;
};
lvds_out_rk1000: endpoint@1 {
reg = <1>;
remote-endpoint = <_in_lvds>;
};
};

};
};


Hi Sandy,
Forgive me, this is probably a stupid question. I don't see how this usecase is
unique from the other users of drm_of_find_panel_or_bridge. Couldn't you change
your devicetree bindings to conform to something drm_of_find_panel_or_bridge()
can work with?

Thank you,


Hi sean,
 Maybe i can use the following method to use
drm_of_find_panel_or_bridge() and no need to change my DT, but there is
another question:
 The LVDS output format(rockchip,output、rockchip,data-mapping etc.)
depend on different panel, so it should be put under remote panel point.
If use drm_of_find_panel_or_bridge(), this just return panel or bridge, so
i have to back to get remote panel point and get the output format.


This should be easy since you can grab dev->of_node from panel or bridge once
it's found.


ok, thanks.


ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, >panel,
   >bridge);
if (ret)
 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 1, >panel,
   >bridge);


Would be easier to read in a for loop.

Sean


ok, thanks.


if (ret) {
 DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
 ret  = -EPROBE_DEFER;
 goto err_put_remote;
}






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


Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-11 Thread Sean Paul
On Fri, Aug 11, 2017 at 10:15:16AM +0800, Sandy Huang wrote:
> 
> 
> 在 2017/8/11 2:05, Sean Paul 写道:
> > On Thu, Aug 10, 2017 at 05:35:52PM +0800, Sandy Huang wrote:
> > > Hi Sean Paul,
> > >  Thanks for your review.
> > > 
> > > 在 2017/8/10 3:58, Sean Paul 写道:
> > > > On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:
> > > > > This adds support for Rockchip soc lvds found on rk3288
> > > > > Based on the patches from Mark yao and Heiko Stuebner
> > > > > 
> > > > > Signed-off-by: Sandy Huang 
> > > > > Signed-off-by: Mark yao 
> > > > > Signed-off-by: Heiko Stuebner 
> > > > > ---
> > > > >drivers/gpu/drm/rockchip/Kconfig |   9 +
> > > > >drivers/gpu/drm/rockchip/Makefile|   1 +
> > > > >drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 
> > > > > +++
> > > > >drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
> > > > >4 files changed, 856 insertions(+)
> > > > >create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
> > > > >create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h
> > > > > 
> > 
> > 
> > 
> > > > > diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
> > > > > b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> > > > > new file mode 100644
> > > > > index 000..a4ad3f0
> > > > > --- /dev/null
> > > > > +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> > 
> > 
> > 
> > > > > + lvds->drm_dev = drm_dev;
> > > > > + port = of_graph_get_port_by_id(dev->of_node, 1);
> > > > > + if (!port) {
> > > > > + dev_err(dev, "can't found port point, please init lvds 
> > > > > panel port!\n");
> > > > > + return -EINVAL;
> > > > > + }
> > > > > +
> > > > > + for_each_child_of_node(port, endpoint) {
> > > > > + remote = of_graph_get_remote_port_parent(endpoint);
> > > > > + if (!remote) {
> > > > > + dev_err(dev, "can't found panel node, please 
> > > > > init!\n");
> > > > > + ret = -EINVAL;
> > > > > + goto err_put_port;
> > > > > + }
> > > > > + if (!of_device_is_available(remote)) {
> > > > > + of_node_put(remote);
> > > > > + remote = NULL;
> > > > > + continue;
> > > > > + }
> > > > > + break;
> > > > > + }
> > > > > + if (!remote) {
> > > > > + dev_err(dev, "can't found remote node, please init!\n");
> > > > > + ret = -EINVAL;
> > > > > + goto err_put_port;
> > > > > + }
> > > > > +
> > > > > + lvds->panel = of_drm_find_panel(remote);
> > > > > + if (!lvds->panel)
> > > > > + lvds->bridge = of_drm_find_bridge(remote);
> > > > 
> > > > drm_of_find_panel_or_bridge()
> > > > 
> > > 
> > > because the lvds ports maybe connect to lvds-panel or connect to
> > > rk1000(which is convert RGB to CVBS output), so i have to get the remote
> > > port parent and check the status, and final get the active remote point.
> > > 
> > 
> > 
> > 
> > > lvds_panel: lvds-panel {
> > >   status = "disabled";
> > >   ports {
> > >   panel_in_lvds: endpoint {
> > >   remote-endpoint = <_out_panel>;
> > >   };
> > >   };
> > > };
> > > 
> > > rk1000: rk1000@0xff00 {
> > >   status = "okay";
> > >   ports {
> > >   rk1000_in_lvds: endpoint {
> > >   remote-endpoint = <_out_panel>;
> > >   };
> > >   };
> > > };
> > > 
> > >  {
> > >   status = "okay";
> > >   ports {
> > >   lvds_out: port@1 {
> > >   reg = <1>;
> > >   lvds_out_panel: endpoint@0 {
> > >   reg = <0>;
> > >   remote-endpoint = <_in_lvds>;
> > >   };
> > >   lvds_out_rk1000: endpoint@1 {
> > >   reg = <1>;
> > >   remote-endpoint = <_in_lvds>;
> > >   };
> > >   };
> > > 
> > >   };
> > > };
> > 
> > Hi Sandy,
> > Forgive me, this is probably a stupid question. I don't see how this 
> > usecase is
> > unique from the other users of drm_of_find_panel_or_bridge. Couldn't you 
> > change
> > your devicetree bindings to conform to something 
> > drm_of_find_panel_or_bridge()
> > can work with?
> > 
> > Thank you,
> > 
> Hi sean,
> Maybe i can use the following method to use
> drm_of_find_panel_or_bridge() and no need to change my DT, but there is
> another question:
> The LVDS output format(rockchip,output、rockchip,data-mapping etc.)
> depend on different panel, so it should be put under remote panel point.
> If use drm_of_find_panel_or_bridge(), this just return panel or bridge, so
> i have to back to get remote panel point and get the output format.

This should be easy since you can grab dev->of_node from panel or bridge once
it's found.

> 
> ret 

Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-10 Thread Sandy Huang



在 2017/8/11 2:05, Sean Paul 写道:

On Thu, Aug 10, 2017 at 05:35:52PM +0800, Sandy Huang wrote:

Hi Sean Paul,
 Thanks for your review.

在 2017/8/10 3:58, Sean Paul 写道:

On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:

This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
   drivers/gpu/drm/rockchip/Kconfig |   9 +
   drivers/gpu/drm/rockchip/Makefile|   1 +
   drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 
+++
   drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
   4 files changed, 856 insertions(+)
   create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
   create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h






diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c





+   lvds->drm_dev = drm_dev;
+   port = of_graph_get_port_by_id(dev->of_node, 1);
+   if (!port) {
+   dev_err(dev, "can't found port point, please init lvds panel 
port!\n");
+   return -EINVAL;
+   }
+
+   for_each_child_of_node(port, endpoint) {
+   remote = of_graph_get_remote_port_parent(endpoint);
+   if (!remote) {
+   dev_err(dev, "can't found panel node, please init!\n");
+   ret = -EINVAL;
+   goto err_put_port;
+   }
+   if (!of_device_is_available(remote)) {
+   of_node_put(remote);
+   remote = NULL;
+   continue;
+   }
+   break;
+   }
+   if (!remote) {
+   dev_err(dev, "can't found remote node, please init!\n");
+   ret = -EINVAL;
+   goto err_put_port;
+   }
+
+   lvds->panel = of_drm_find_panel(remote);
+   if (!lvds->panel)
+   lvds->bridge = of_drm_find_bridge(remote);


drm_of_find_panel_or_bridge()



because the lvds ports maybe connect to lvds-panel or connect to
rk1000(which is convert RGB to CVBS output), so i have to get the remote
port parent and check the status, and final get the active remote point.






lvds_panel: lvds-panel {
status = "disabled";
ports {
panel_in_lvds: endpoint {
remote-endpoint = <_out_panel>;
};
};
};

rk1000: rk1000@0xff00 {
status = "okay";
ports {
rk1000_in_lvds: endpoint {
remote-endpoint = <_out_panel>;
};
};
};

 {
status = "okay";
ports {
lvds_out: port@1 {
reg = <1>;
lvds_out_panel: endpoint@0 {
reg = <0>;
remote-endpoint = <_in_lvds>;
};
lvds_out_rk1000: endpoint@1 {
reg = <1>;
remote-endpoint = <_in_lvds>;
};
};

};
};


Hi Sandy,
Forgive me, this is probably a stupid question. I don't see how this usecase is
unique from the other users of drm_of_find_panel_or_bridge. Couldn't you change
your devicetree bindings to conform to something drm_of_find_panel_or_bridge()
can work with?

Thank you,


Hi sean,
Maybe i can use the following method to use 
drm_of_find_panel_or_bridge() and no need to change my DT, but there is 
another question:

The LVDS output format(rockchip,output、rockchip,data-mapping etc.)
depend on different panel, so it should be put under remote panel point.
If use drm_of_find_panel_or_bridge(), this just return panel or bridge, 
so i have to back to get remote panel point and get the output format.


ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, >panel,
  >bridge);
if (ret)
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 1, >panel,
  >bridge);
if (ret) {
DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
ret  = -EPROBE_DEFER;
goto err_put_remote;
}


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


Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-10 Thread Sean Paul
On Thu, Aug 10, 2017 at 05:35:52PM +0800, Sandy Huang wrote:
> Hi Sean Paul,
> Thanks for your review.
> 
> 在 2017/8/10 3:58, Sean Paul 写道:
> > On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:
> > > This adds support for Rockchip soc lvds found on rk3288
> > > Based on the patches from Mark yao and Heiko Stuebner
> > > 
> > > Signed-off-by: Sandy Huang 
> > > Signed-off-by: Mark yao 
> > > Signed-off-by: Heiko Stuebner 
> > > ---
> > >   drivers/gpu/drm/rockchip/Kconfig |   9 +
> > >   drivers/gpu/drm/rockchip/Makefile|   1 +
> > >   drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 
> > > +++
> > >   drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
> > >   4 files changed, 856 insertions(+)
> > >   create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
> > >   create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h
> > > 



> > > diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
> > > b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> > > new file mode 100644
> > > index 000..a4ad3f0
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c



> > > + lvds->drm_dev = drm_dev;
> > > + port = of_graph_get_port_by_id(dev->of_node, 1);
> > > + if (!port) {
> > > + dev_err(dev, "can't found port point, please init lvds panel 
> > > port!\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + for_each_child_of_node(port, endpoint) {
> > > + remote = of_graph_get_remote_port_parent(endpoint);
> > > + if (!remote) {
> > > + dev_err(dev, "can't found panel node, please init!\n");
> > > + ret = -EINVAL;
> > > + goto err_put_port;
> > > + }
> > > + if (!of_device_is_available(remote)) {
> > > + of_node_put(remote);
> > > + remote = NULL;
> > > + continue;
> > > + }
> > > + break;
> > > + }
> > > + if (!remote) {
> > > + dev_err(dev, "can't found remote node, please init!\n");
> > > + ret = -EINVAL;
> > > + goto err_put_port;
> > > + }
> > > +
> > > + lvds->panel = of_drm_find_panel(remote);
> > > + if (!lvds->panel)
> > > + lvds->bridge = of_drm_find_bridge(remote);
> > 
> > drm_of_find_panel_or_bridge()
> > 
> 
> because the lvds ports maybe connect to lvds-panel or connect to
> rk1000(which is convert RGB to CVBS output), so i have to get the remote
> port parent and check the status, and final get the active remote point.
> 



> lvds_panel: lvds-panel {
>   status = "disabled";
>   ports {
>   panel_in_lvds: endpoint {
>   remote-endpoint = <_out_panel>;
>   };
>   };
> };
> 
> rk1000: rk1000@0xff00 {
>   status = "okay";
>   ports {
>   rk1000_in_lvds: endpoint {
>   remote-endpoint = <_out_panel>;
>   };
>   };
> };
> 
>  {
>   status = "okay";
>   ports {
>   lvds_out: port@1 {
>   reg = <1>;
>   lvds_out_panel: endpoint@0 {
>   reg = <0>;
>   remote-endpoint = <_in_lvds>;
>   };
>   lvds_out_rk1000: endpoint@1 {
>   reg = <1>;
>   remote-endpoint = <_in_lvds>;
>   };
>   };
> 
>   };
> };

Hi Sandy,
Forgive me, this is probably a stupid question. I don't see how this usecase is
unique from the other users of drm_of_find_panel_or_bridge. Couldn't you change
your devicetree bindings to conform to something drm_of_find_panel_or_bridge()
can work with?

Thank you,

Sean



> > > -- 
> > > 2.7.4
> > > 
> > > 
> > > ___
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> 
> -- 
> Best Regard
> 
> 黄家钗
> Sandy Huang
> 福州瑞芯微电子股份有限公司-图形与显示系统部门
> Fuzhou Rockchip Electronics Co.Ltd - Graphics & Display Dept.
> Addr: 福州市鼓楼区铜盘路软件大道89号福州软件园A区21号楼(350003)
>  No. 21 Building, A District, No.89,software Boulevard
> Fuzhou,Fujian,PRC
> Tel:+86 0591-87884919  8690
> E-mail:h...@rock-chips.com
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-10 Thread Sandy Huang

sorry, it's a wrong email, send the v1 patch ,please ignore.

在 2017/8/10 17:49, Sandy Huang 写道:

This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
  drivers/gpu/drm/rockchip/Kconfig |   9 +
  drivers/gpu/drm/rockchip/Makefile|   1 +
  drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 +++
  drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
  4 files changed, 856 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 50c41c0..80672f4 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -59,3 +59,12 @@ config ROCKCHIP_INNO_HDMI
  This selects support for Rockchip SoC specific extensions
  for the Innosilicon HDMI driver. If you want to enable
  HDMI on RK3036 based SoC, you should select this option.
+
+config ROCKCHIP_LVDS
+   bool "Rockchip LVDS support"
+   depends on DRM_ROCKCHIP
+   help
+ Choose this option to enable support for Rockchip LVDS controllers.
+ Rockchip rk3288 SoC has LVDS TX Controller can be used, and it
+ support LVDS, rgb, dual LVDS output mode. say Y to enable its
+ driver.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index fa8dc9d..a881d2c 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -12,5 +12,6 @@ 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_INNO_HDMI) += inno_hdmi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
  
  obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o

diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author:
+ *  Mark Yao 
+ *  Sandy huang 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+#include "rockchip_lvds.h"
+
+#define DISPLAY_OUTPUT_RGB 0
+#define DISPLAY_OUTPUT_LVDS1
+#define DISPLAY_OUTPUT_DUAL_LVDS   2
+
+#define connector_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, connector)
+
+#define encoder_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, encoder)
+#define LVDS_CHIP(lvds)((lvds)->soc_data->chip_type)
+
+/*
+ * @grf_offset: offset inside the grf regmap for setting the rockchip lvds
+ */
+struct rockchip_lvds_soc_data {
+   int chip_type;
+   int grf_soc_con6;
+   int grf_soc_con7;
+
+   bool has_vop_sel;
+};
+
+struct rockchip_lvds {
+   void *base;
+   struct device *dev;
+   void __iomem *regs;
+   struct regmap *grf;
+   struct clk *pclk;
+   const struct rockchip_lvds_soc_data *soc_data;
+
+   int output;
+   int format;
+
+   struct drm_device *drm_dev;
+   struct drm_panel *panel;
+   struct drm_bridge *bridge;
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+
+   struct mutex suspend_lock;
+   int suspend;
+   struct dev_pin_info *pins;
+   struct drm_display_mode mode;
+};
+
+static inline void lvds_writel(struct rockchip_lvds *lvds, u32 offset, u32 val)
+{
+   writel_relaxed(val, lvds->regs + offset);
+   if ((lvds->output != DISPLAY_OUTPUT_LVDS) &&
+(LVDS_CHIP(lvds) == RK3288_LVDS))
+   writel_relaxed(val,
+  lvds->regs + offset + RK3288_LVDS_CH1_OFFSET);
+}
+
+static inline int lvds_name_to_format(const char *s)
+{
+   if (!s)
+   return -EINVAL;
+
+   if (strncmp(s, "jeida", 6) == 0)
+   return LVDS_FORMAT_JEIDA;
+   else if (strncmp(s, "vesa", 5) == 0)
+  

[PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-10 Thread Sandy Huang
This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
 drivers/gpu/drm/rockchip/Kconfig |   9 +
 drivers/gpu/drm/rockchip/Makefile|   1 +
 drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 +++
 drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
 4 files changed, 856 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 50c41c0..80672f4 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -59,3 +59,12 @@ config ROCKCHIP_INNO_HDMI
  This selects support for Rockchip SoC specific extensions
  for the Innosilicon HDMI driver. If you want to enable
  HDMI on RK3036 based SoC, you should select this option.
+
+config ROCKCHIP_LVDS
+   bool "Rockchip LVDS support"
+   depends on DRM_ROCKCHIP
+   help
+ Choose this option to enable support for Rockchip LVDS controllers.
+ Rockchip rk3288 SoC has LVDS TX Controller can be used, and it
+ support LVDS, rgb, dual LVDS output mode. say Y to enable its
+ driver.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index fa8dc9d..a881d2c 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -12,5 +12,6 @@ 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_INNO_HDMI) += inno_hdmi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
 
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author:
+ *  Mark Yao 
+ *  Sandy huang 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+#include "rockchip_lvds.h"
+
+#define DISPLAY_OUTPUT_RGB 0
+#define DISPLAY_OUTPUT_LVDS1
+#define DISPLAY_OUTPUT_DUAL_LVDS   2
+
+#define connector_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, connector)
+
+#define encoder_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, encoder)
+#define LVDS_CHIP(lvds)((lvds)->soc_data->chip_type)
+
+/*
+ * @grf_offset: offset inside the grf regmap for setting the rockchip lvds
+ */
+struct rockchip_lvds_soc_data {
+   int chip_type;
+   int grf_soc_con6;
+   int grf_soc_con7;
+
+   bool has_vop_sel;
+};
+
+struct rockchip_lvds {
+   void *base;
+   struct device *dev;
+   void __iomem *regs;
+   struct regmap *grf;
+   struct clk *pclk;
+   const struct rockchip_lvds_soc_data *soc_data;
+
+   int output;
+   int format;
+
+   struct drm_device *drm_dev;
+   struct drm_panel *panel;
+   struct drm_bridge *bridge;
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+
+   struct mutex suspend_lock;
+   int suspend;
+   struct dev_pin_info *pins;
+   struct drm_display_mode mode;
+};
+
+static inline void lvds_writel(struct rockchip_lvds *lvds, u32 offset, u32 val)
+{
+   writel_relaxed(val, lvds->regs + offset);
+   if ((lvds->output != DISPLAY_OUTPUT_LVDS) &&
+(LVDS_CHIP(lvds) == RK3288_LVDS))
+   writel_relaxed(val,
+  lvds->regs + offset + RK3288_LVDS_CH1_OFFSET);
+}
+
+static inline int lvds_name_to_format(const char *s)
+{
+   if (!s)
+   return -EINVAL;
+
+   if (strncmp(s, "jeida", 6) == 0)
+   return LVDS_FORMAT_JEIDA;
+   else if (strncmp(s, "vesa", 5) == 0)
+   return LVDS_FORMAT_VESA;
+
+   return -EINVAL;
+}
+
+static inline int lvds_name_to_output(const char *s)

Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-10 Thread Sandy Huang

Hi Sean Paul,
Thanks for your review.

在 2017/8/10 3:58, Sean Paul 写道:

On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:

This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
  drivers/gpu/drm/rockchip/Kconfig |   9 +
  drivers/gpu/drm/rockchip/Makefile|   1 +
  drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 +++
  drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
  4 files changed, 856 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 50c41c0..80672f4 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -59,3 +59,12 @@ config ROCKCHIP_INNO_HDMI
  This selects support for Rockchip SoC specific extensions
  for the Innosilicon HDMI driver. If you want to enable
  HDMI on RK3036 based SoC, you should select this option.
+
+config ROCKCHIP_LVDS
+   bool "Rockchip LVDS support"
+   depends on DRM_ROCKCHIP
+   help
+ Choose this option to enable support for Rockchip LVDS controllers.
+ Rockchip rk3288 SoC has LVDS TX Controller can be used, and it
+ support LVDS, rgb, dual LVDS output mode. say Y to enable its
+ driver.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index fa8dc9d..a881d2c 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -12,5 +12,6 @@ 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_INNO_HDMI) += inno_hdmi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
  
  obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o

diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author:
+ *  Mark Yao 
+ *  Sandy huang 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+#include "rockchip_lvds.h"
+
+#define DISPLAY_OUTPUT_RGB 0
+#define DISPLAY_OUTPUT_LVDS1
+#define DISPLAY_OUTPUT_DUAL_LVDS   2
+
+#define connector_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, connector)
+
+#define encoder_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, encoder)
+#define LVDS_CHIP(lvds)((lvds)->soc_data->chip_type)
+
+/*
+ * @grf_offset: offset inside the grf regmap for setting the rockchip lvds


You only document one member and it doesn't exist :(

I forgot to delete it, i will update at next version.



+ */
+struct rockchip_lvds_soc_data {
+   int chip_type;
+   int grf_soc_con6;
+   int grf_soc_con7;
+
+   bool has_vop_sel;
+};
+
+struct rockchip_lvds {
+   void *base;
+   struct device *dev;
+   void __iomem *regs;
+   struct regmap *grf;
+   struct clk *pclk;
+   const struct rockchip_lvds_soc_data *soc_data;
+
+   int output;
+   int format;
+
+   struct drm_device *drm_dev;
+   struct drm_panel *panel;
+   struct drm_bridge *bridge;
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+
+   struct mutex suspend_lock;
+   int suspend;
+   struct dev_pin_info *pins;
+   struct drm_display_mode mode;
+};
+
+static inline void lvds_writel(struct rockchip_lvds *lvds, u32 offset, u32 val)
+{
+   writel_relaxed(val, lvds->regs + offset);
+   if ((lvds->output != DISPLAY_OUTPUT_LVDS) &&
+(LVDS_CHIP(lvds) == RK3288_LVDS))


Given that you only support one chip right now, it seems premature to worry
about chip version. At any rate, it seems like it'd be more useful to store
RK3288_LVDS_CHI_OFFSET in soc_data and do:

if (lvds->output 

Re: [PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-09 Thread Sean Paul
On Wed, Aug 09, 2017 at 06:00:59PM +0800, Sandy Huang wrote:
> This adds support for Rockchip soc lvds found on rk3288
> Based on the patches from Mark yao and Heiko Stuebner
> 
> Signed-off-by: Sandy Huang 
> Signed-off-by: Mark yao 
> Signed-off-by: Heiko Stuebner 
> ---
>  drivers/gpu/drm/rockchip/Kconfig |   9 +
>  drivers/gpu/drm/rockchip/Makefile|   1 +
>  drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 
> +++
>  drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
>  4 files changed, 856 insertions(+)
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h
> 
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> index 50c41c0..80672f4 100644
> --- a/drivers/gpu/drm/rockchip/Kconfig
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -59,3 +59,12 @@ config ROCKCHIP_INNO_HDMI
> This selects support for Rockchip SoC specific extensions
> for the Innosilicon HDMI driver. If you want to enable
> HDMI on RK3036 based SoC, you should select this option.
> +
> +config ROCKCHIP_LVDS
> + bool "Rockchip LVDS support"
> + depends on DRM_ROCKCHIP
> + help
> +   Choose this option to enable support for Rockchip LVDS controllers.
> +   Rockchip rk3288 SoC has LVDS TX Controller can be used, and it
> +   support LVDS, rgb, dual LVDS output mode. say Y to enable its
> +   driver.
> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> index fa8dc9d..a881d2c 100644
> --- a/drivers/gpu/drm/rockchip/Makefile
> +++ b/drivers/gpu/drm/rockchip/Makefile
> @@ -12,5 +12,6 @@ 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_INNO_HDMI) += inno_hdmi.o
> +rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
>  
>  obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
> b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> new file mode 100644
> index 000..a4ad3f0
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -0,0 +1,734 @@
> +/*
> + * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
> + * Author:
> + *  Mark Yao 
> + *  Sandy huang 
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "rockchip_drm_drv.h"
> +#include "rockchip_drm_vop.h"
> +#include "rockchip_lvds.h"
> +
> +#define DISPLAY_OUTPUT_RGB   0
> +#define DISPLAY_OUTPUT_LVDS  1
> +#define DISPLAY_OUTPUT_DUAL_LVDS 2
> +
> +#define connector_to_lvds(c) \
> + container_of(c, struct rockchip_lvds, connector)
> +
> +#define encoder_to_lvds(c) \
> + container_of(c, struct rockchip_lvds, encoder)
> +#define LVDS_CHIP(lvds)  ((lvds)->soc_data->chip_type)
> +
> +/*
> + * @grf_offset: offset inside the grf regmap for setting the rockchip lvds

You only document one member and it doesn't exist :(

> + */
> +struct rockchip_lvds_soc_data {
> + int chip_type;
> + int grf_soc_con6;
> + int grf_soc_con7;
> +
> + bool has_vop_sel;
> +};
> +
> +struct rockchip_lvds {
> + void *base;
> + struct device *dev;
> + void __iomem *regs;
> + struct regmap *grf;
> + struct clk *pclk;
> + const struct rockchip_lvds_soc_data *soc_data;
> +
> + int output;
> + int format;
> +
> + struct drm_device *drm_dev;
> + struct drm_panel *panel;
> + struct drm_bridge *bridge;
> + struct drm_connector connector;
> + struct drm_encoder encoder;
> +
> + struct mutex suspend_lock;
> + int suspend;
> + struct dev_pin_info *pins;
> + struct drm_display_mode mode;
> +};
> +
> +static inline void lvds_writel(struct rockchip_lvds *lvds, u32 offset, u32 
> val)
> +{
> + writel_relaxed(val, lvds->regs + offset);
> + if ((lvds->output != DISPLAY_OUTPUT_LVDS) &&
> +  (LVDS_CHIP(lvds) == RK3288_LVDS))

Given that you only support one chip right now, it seems premature to worry
about chip version. At any rate, it seems like it'd be more useful to store

[PATCH 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-09 Thread Sandy Huang
This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark yao 
Signed-off-by: Heiko Stuebner 
---
 drivers/gpu/drm/rockchip/Kconfig |   9 +
 drivers/gpu/drm/rockchip/Makefile|   1 +
 drivers/gpu/drm/rockchip/rockchip_lvds.c | 734 +++
 drivers/gpu/drm/rockchip/rockchip_lvds.h | 112 +
 4 files changed, 856 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 50c41c0..80672f4 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -59,3 +59,12 @@ config ROCKCHIP_INNO_HDMI
  This selects support for Rockchip SoC specific extensions
  for the Innosilicon HDMI driver. If you want to enable
  HDMI on RK3036 based SoC, you should select this option.
+
+config ROCKCHIP_LVDS
+   bool "Rockchip LVDS support"
+   depends on DRM_ROCKCHIP
+   help
+ Choose this option to enable support for Rockchip LVDS controllers.
+ Rockchip rk3288 SoC has LVDS TX Controller can be used, and it
+ support LVDS, rgb, dual LVDS output mode. say Y to enable its
+ driver.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index fa8dc9d..a881d2c 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -12,5 +12,6 @@ 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_INNO_HDMI) += inno_hdmi.o
+rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
 
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c 
b/drivers/gpu/drm/rockchip/rockchip_lvds.c
new file mode 100644
index 000..a4ad3f0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author:
+ *  Mark Yao 
+ *  Sandy huang 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+#include "rockchip_lvds.h"
+
+#define DISPLAY_OUTPUT_RGB 0
+#define DISPLAY_OUTPUT_LVDS1
+#define DISPLAY_OUTPUT_DUAL_LVDS   2
+
+#define connector_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, connector)
+
+#define encoder_to_lvds(c) \
+   container_of(c, struct rockchip_lvds, encoder)
+#define LVDS_CHIP(lvds)((lvds)->soc_data->chip_type)
+
+/*
+ * @grf_offset: offset inside the grf regmap for setting the rockchip lvds
+ */
+struct rockchip_lvds_soc_data {
+   int chip_type;
+   int grf_soc_con6;
+   int grf_soc_con7;
+
+   bool has_vop_sel;
+};
+
+struct rockchip_lvds {
+   void *base;
+   struct device *dev;
+   void __iomem *regs;
+   struct regmap *grf;
+   struct clk *pclk;
+   const struct rockchip_lvds_soc_data *soc_data;
+
+   int output;
+   int format;
+
+   struct drm_device *drm_dev;
+   struct drm_panel *panel;
+   struct drm_bridge *bridge;
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+
+   struct mutex suspend_lock;
+   int suspend;
+   struct dev_pin_info *pins;
+   struct drm_display_mode mode;
+};
+
+static inline void lvds_writel(struct rockchip_lvds *lvds, u32 offset, u32 val)
+{
+   writel_relaxed(val, lvds->regs + offset);
+   if ((lvds->output != DISPLAY_OUTPUT_LVDS) &&
+(LVDS_CHIP(lvds) == RK3288_LVDS))
+   writel_relaxed(val,
+  lvds->regs + offset + RK3288_LVDS_CH1_OFFSET);
+}
+
+static inline int lvds_name_to_format(const char *s)
+{
+   if (!s)
+   return -EINVAL;
+
+   if (strncmp(s, "jeida", 6) == 0)
+   return LVDS_FORMAT_JEIDA;
+   else if (strncmp(s, "vesa", 5) == 0)
+   return LVDS_FORMAT_VESA;
+
+   return -EINVAL;
+}
+
+static inline int lvds_name_to_output(const char *s)