Re: [PATCH v4 08/16] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-21 Thread Laurent Pinchart
Hi Rob,

On Thursday, 22 February 2018 01:28:48 EET Rob Herring wrote:
> On Tue, Feb 20, 2018 at 5:10 PM, Laurent Pinchart wrote:
> > The internal LVDS encoders now have their own DT bindings. Before
> > switching the driver infrastructure to those new bindings, implement
> > backward-compatibility through live DT patching.
> > 
> > Patching is disabled and will be enabled along with support for the new
> > DT bindings in the DU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> 
> [...]
> 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
> > b/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts new file mode
> > 100644
> > index ..6ebb355b652a
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
> > @@ -0,0 +1,81 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * rcar_du_of_lvds_r8a7790.dts - Legacy LVDS DT bindings conversion for
> > R8A7790
> > + *
> > + * Copyright (C) 2018 Laurent Pinchart
> > 
> > + *
> > + * Based on work from Jyri Sarha 
> > + * Copyright (C) 2015 Texas Instruments
> > + */
> > +
> > +#include 
> 
> Doesn't seem to be used in any of these.

It's a leftover from a previous test. I'll remove it in all the .dts files.

> Otherwise,
> 
> Reviewed-by: Rob Herring 
> 
> > +
> > +/dts-v1/;
> > +/plugin/;
> > +/ {
> > +   fragment@0 {
> > +   target-path = "/";
> > +   __overlay__ {
> > +   #address-cells = <2>;
> > +   #size-cells = <2>;
> > +
> > +   lvds@feb9 {
> > +   compatible = "renesas,r8a7790-lvds";
> > +   reg = <0 0xfeb9 0 0x1c>;
> > +
> > +   ports {
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +
> > +   port@0 {
> > +   reg = <0>;
> > +   lvds0_input: endpoint {
> > +   };
> > +   };
> > +   port@1 {
> > +   reg = <1>;
> > +   lvds0_out: endpoint {
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > +   lvds@feb94000 {
> > +   compatible = "renesas,r8a7790-lvds";
> > +   reg = <0 0xfeb94000 0 0x1c>;
> > +
> > +   ports {
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +
> > +   port@0 {
> > +   reg = <0>;
> > +   lvds1_input: endpoint {
> > +   };
> > +   };
> > +   port@1 {
> > +   reg = <1>;
> > +   lvds1_out: endpoint {
> > +   };
> > +   };
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > +   fragment@1 {
> > +   target-path = "/display@feb0/ports";
> > +   __overlay__ {
> > +   port@1 {
> > +   endpoint {
> > +   remote-endpoint = <_input>;
> > +   };
> > +   };
> > +   port@2 {
> > +   endpoint {
> > +   remote-endpoint = <_input>;
> > +   };
> > +   };
> > +   };
> > +   };
> > +};

-- 
Regards,

Laurent Pinchart



Re: [PATCH v4 08/16] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-21 Thread Rob Herring
On Tue, Feb 20, 2018 at 5:10 PM, Laurent Pinchart
 wrote:
> The internal LVDS encoders now have their own DT bindings. Before
> switching the driver infrastructure to those new bindings, implement
> backward-compatibility through live DT patching.
>
> Patching is disabled and will be enabled along with support for the new
> DT bindings in the DU driver.
>
> Signed-off-by: Laurent Pinchart 
> ---

[...]

> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts 
> b/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
> new file mode 100644
> index ..6ebb355b652a
> --- /dev/null
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
> @@ -0,0 +1,81 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * rcar_du_of_lvds_r8a7790.dts - Legacy LVDS DT bindings conversion for 
> R8A7790
> + *
> + * Copyright (C) 2018 Laurent Pinchart 
> + *
> + * Based on work from Jyri Sarha 
> + * Copyright (C) 2015 Texas Instruments
> + */
> +
> +#include 

Doesn't seem to be used in any of these.

Otherwise,

Reviewed-by: Rob Herring 

> +
> +/dts-v1/;
> +/plugin/;
> +/ {
> +   fragment@0 {
> +   target-path = "/";
> +   __overlay__ {
> +   #address-cells = <2>;
> +   #size-cells = <2>;
> +
> +   lvds@feb9 {
> +   compatible = "renesas,r8a7790-lvds";
> +   reg = <0 0xfeb9 0 0x1c>;
> +
> +   ports {
> +   #address-cells = <1>;
> +   #size-cells = <0>;
> +
> +   port@0 {
> +   reg = <0>;
> +   lvds0_input: endpoint {
> +   };
> +   };
> +   port@1 {
> +   reg = <1>;
> +   lvds0_out: endpoint {
> +   };
> +   };
> +   };
> +   };
> +
> +   lvds@feb94000 {
> +   compatible = "renesas,r8a7790-lvds";
> +   reg = <0 0xfeb94000 0 0x1c>;
> +
> +   ports {
> +   #address-cells = <1>;
> +   #size-cells = <0>;
> +
> +   port@0 {
> +   reg = <0>;
> +   lvds1_input: endpoint {
> +   };
> +   };
> +   port@1 {
> +   reg = <1>;
> +   lvds1_out: endpoint {
> +   };
> +   };
> +   };
> +   };
> +   };
> +   };
> +
> +   fragment@1 {
> +   target-path = "/display@feb0/ports";
> +   __overlay__ {
> +   port@1 {
> +   endpoint {
> +   remote-endpoint = <_input>;
> +   };
> +   };
> +   port@2 {
> +   endpoint {
> +   remote-endpoint = <_input>;
> +   };
> +   };
> +   };
> +   };
> +};


[PATCH v4 08/16] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoders now have their own DT bindings. Before
switching the driver infrastructure to those new bindings, implement
backward-compatibility through live DT patching.

Patching is disabled and will be enabled along with support for the new
DT bindings in the DU driver.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Use the OF changeset API
- Use of_graph_get_endpoint_by_regs()
- Replace hardcoded constants by sizeof()

Changes since v2:

- Update the SPDX headers to use C-style comments in header files
- Removed the manually created __local_fixups__ node
- Perform manual fixups on live DT instead of overlay

Changes since v1:

- Select OF_FLATTREE
- Compile LVDS DT bindings patch code when DRM_RCAR_LVDS is selected
- Update the SPDX headers to use GPL-2.0 instead of GPL-2.0-only
- Turn __dtb_rcar_du_of_lvds_(begin|end) from u8 to char
- Pass void begin and end pointers to rcar_du_of_get_overlay()
- Use of_get_parent() instead of accessing the parent pointer directly
- Find the LVDS endpoints nodes based on the LVDS node instead of the
  root of the overlay
- Update to the -lvds compatible string format
---
 drivers/gpu/drm/rcar-du/Kconfig|   2 +
 drivers/gpu/drm/rcar-du/Makefile   |   7 +-
 drivers/gpu/drm/rcar-du/rcar_du_of.c   | 307 +
 drivers/gpu/drm/rcar-du/rcar_du_of.h   |  20 ++
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts|  81 ++
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts|  55 
 9 files changed, 636 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 5d0b4b7119af..3f83352a7313 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -22,6 +22,8 @@ config DRM_RCAR_LVDS
bool "R-Car DU LVDS Encoder Support"
depends on DRM_RCAR_DU
select DRM_PANEL
+   select OF_FLATTREE
+   select OF_OVERLAY
help
  Enable support for the R-Car Display Unit embedded LVDS encoders.
 
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 0cf5c11030e8..86b337b4be5d 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -8,7 +8,12 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_plane.o
 
 rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o
-
+rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_of.o \
+  rcar_du_of_lvds_r8a7790.dtb.o \
+  rcar_du_of_lvds_r8a7791.dtb.o \
+  rcar_du_of_lvds_r8a7793.dtb.o \
+  rcar_du_of_lvds_r8a7795.dtb.o \
+  rcar_du_of_lvds_r8a7796.dtb.o
 rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o
 
 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c 
b/drivers/gpu/drm/rcar-du/rcar_du_of.c
new file mode 100644
index ..12fae8814309
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
@@ -0,0 +1,307 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * rcar_du_of.c - Legacy DT bindings compatibility
+ *
+ * Copyright (C) 2018 Laurent Pinchart 
+ *
+ * Based on work from Jyri Sarha 
+ * Copyright (C) 2015 Texas Instruments
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rcar_du_crtc.h"
+#include "rcar_du_drv.h"
+
+/* 
-
+ * Generic Overlay Handling
+ */
+
+struct rcar_du_of_overlay {
+   const char *compatible;
+   void *begin;
+   void *end;
+};
+
+#define RCAR_DU_OF_DTB(type, soc)  \
+   extern char __dtb_rcar_du_of_##type##_##soc##_begin[];  \
+   extern char __dtb_rcar_du_of_##type##_##soc##_end[]
+
+#define RCAR_DU_OF_OVERLAY(type, soc)  \
+   {   \
+   .compatible = "renesas,du-" #soc,   \
+   .begin =