Skip to contentSkip to conversation

rockchip: video: Use ofnode_decode_display_timing() to parse timing

PATCH New Kever Yang 2 participants 6 messages Mar 26, 2020 – Mar 29, 2020

Subsystems (2)
lore
Share & tools
lore

Kever Yang

author
#0 lore raw

PATCH v2 1/2 rockchip: video: Use ofnode_decode_display_timing() to parse timing

Use ofnode_decode_display_timing() instead of fdtdec_decode_display_timing() to parse display timing, so that we can support live DT.

---

Changes in v2: None

 drivers/video/rockchip/rk_lvds.c | 3 +--
 drivers/video/rockchip/rk_mipi.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/video/rockchip/rk_lvds.c +1 -2
index cf5c0439b1..cae8bada32 100644
@@ -160,8 +160,7 @@ int rk_lvds_enable(struct udevice *dev, int panel_bpp,
 
 int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
 {
-	if (fdtdec_decode_display_timing
-	    (gd->fdt_blob, dev_of_offset(dev), 0, timing)) {
+	if (ofnode_decode_display_timing(dev_ofnode(dev), 0, timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);
 		return -EINVAL;
 	}
drivers/video/rockchip/rk_mipi.c +1 -2
index f9280e8607..a77bdfd24d 100644
@@ -29,8 +29,7 @@ int rk_mipi_read_timing(struct udevice *dev,
 {
 	int ret;
 
-	ret = fdtdec_decode_display_timing(gd->fdt_blob, dev_of_offset(dev),
-					 0, timing);
+	ret = ofnode_decode_display_timing(dev_ofnode(dev), 0, timing);
 	if (ret) {
 		debug("%s: Failed to decode display timing (ret=%d)\n",
 		      __func__, ret);
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 2/2 rockchip: video: Convert to use APIs which support live DT

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

Changes in v2:
- use dev_read_s32() instead of dev_read_s32_default();

 drivers/video/rockchip/rk3288_mipi.c |  1 -
 drivers/video/rockchip/rk3399_mipi.c |  1 -
 drivers/video/rockchip/rk_edp.c      |  2 +-
 drivers/video/rockchip/rk_lvds.c     | 28 +++++++++-------------------
 drivers/video/rockchip/rk_mipi.c     | 11 +++++------
 5 files changed, 15 insertions(+), 28 deletions(-)
drivers/video/rockchip/rk3288_mipi.c +0 -1
index f4444b9c34..71d3faf169 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
drivers/video/rockchip/rk3399_mipi.c +0 -1
index 74ebe770a9..cfaa37797e 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
drivers/video/rockchip/rk_edp.c +1 -1
index 8703df0ec0..842034c77c 100644
@@ -996,7 +996,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
 {
 	struct rk_edp_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
+	priv->regs = dev_read_addr_ptr(dev);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
 	return 0;
drivers/video/rockchip/rk_lvds.c +9 -19
index cae8bada32..a11d793135 100644
@@ -171,32 +171,22 @@ int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
 static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
 {
 	struct rk_lvds_priv *priv = dev_get_priv(dev);
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	int ret;
-	priv->regs = (void *)devfdt_get_addr(dev);
+
+	priv->regs = dev_read_addr_ptr(dev);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
-	ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
-	if (ret != -1) {
-		priv->output = ret;
-		debug("LVDS output : %d\n", ret);
-	} else {
-		/* default set it as output rgb */
+	if (!dev_read_s32(dev, "rockchip,output", &priv->output))
+		debug("LVDS output : %d\n", priv->output);
+	else /* default set it as output rgb */
 		priv->output = LVDS_OUTPUT_RGB;
-	}
 
-	ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1);
-	if (ret != -1) {
-		priv->format = ret;
-		debug("LVDS data-mapping : %d\n", ret);
-	} else {
-		/* default set it as format jeida */
+	if (!dev_read_s32(dev, "rockchip,data-mapping", &priv->format))
+		debug("LVDS data-mapping : %d\n", priv->format);
+	else /* default set it as format jeida */
 		priv->format = LVDS_FORMAT_JEIDA;
-	}
 
-	ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1);
-	if (ret != -1) {
+	if (!dev_read_s32(dev, "rockchip,data-width", &ret)) {
 		debug("LVDS data-width : %d\n", ret);
 		if (ret == 24) {
 			priv->format |= LVDS_24BIT;
drivers/video/rockchip/rk_mipi.c +5 -6
index a77bdfd24d..f1c21bb8d7 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
@@ -76,7 +75,7 @@ static void rk_mipi_dsi_write(uintptr_t regs, u32 reg, u32 val)
 int rk_mipi_dsi_enable(struct udevice *dev,
 		       const struct display_timing *timing)
 {
-	int node, timing_node;
+	ofnode node, timing_node;
 	int val;
 	struct rk_mipi_priv *priv = dev_get_priv(dev);
 	uintptr_t regs = priv->regs;
@@ -119,10 +118,10 @@ int rk_mipi_dsi_enable(struct udevice *dev,
 	rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
 	/* Set dpi color coding depth 24 bit */
-	timing_node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
-									 "display-timings");
-	node = fdt_first_subnode(gd->fdt_blob, timing_node);
-	val = fdtdec_get_int(gd->fdt_blob, node, "bits-per-pixel", -1);
+	timing_node = ofnode_find_subnode(dev->node, "display-timings");
+	node = ofnode_first_subnode(timing_node);
+
+	val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
 	switch (val) {
 	case 16:
 		rk_mipi_dsi_write(regs, DPI_COLOR_CODING, DPI_16BIT_CFG_1);
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/2 rockchip: video: Convert to use APIs which support live DT

Hi Kever,

Quoted 70 lines · Kever Yang

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

Changes in v2:
- use dev_read_s32() instead of dev_read_s32_default();

 drivers/video/rockchip/rk3288_mipi.c |  1 -
 drivers/video/rockchip/rk3399_mipi.c |  1 -
 drivers/video/rockchip/rk_edp.c      |  2 +-
 drivers/video/rockchip/rk_lvds.c     | 28 +++++++++-------------------
 drivers/video/rockchip/rk_mipi.c     | 11 +++++------
 5 files changed, 15 insertions(+), 28 deletions(-)
drivers/video/rockchip/rk3288_mipi.c +0 -1
index f4444b9c34..71d3faf169 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
drivers/video/rockchip/rk3399_mipi.c +0 -1
index 74ebe770a9..cfaa37797e 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
drivers/video/rockchip/rk_edp.c +1 -1
index 8703df0ec0..842034c77c 100644
@@ -996,7 +996,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
 {
        struct rk_edp_priv *priv = dev_get_priv(dev);
 
-       priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
+       priv->regs = dev_read_addr_ptr(dev);
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
        return 0;
drivers/video/rockchip/rk_lvds.c +2 -3
index cae8bada32..a11d793135 100644
@@ -171,32 +171,22 @@ int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
 static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
 {
        struct rk_lvds_priv *priv = dev_get_priv(dev);
-       const void *blob = gd->fdt_blob;
-       int node = dev_of_offset(dev);
        int ret;
-       priv->regs = (void *)devfdt_get_addr(dev);
+
+       priv->regs = dev_read_addr_ptr(dev);
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 

drivers/video/rockchip/rk_lvds.c int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing) · line 182

Quoted 10 lines
drivers/video/rockchip/rk_lvds.c +3 -6
-       ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
-       if (ret != -1) {
-               priv->output = ret;
-               debug("LVDS output : %d\n", ret);
-       } else {
-               /* default set it as output rgb */
+       if (!dev_read_s32(dev, "rockchip,output", &priv->output))
+               debug("LVDS output : %d\n", priv->output);
+       else /* default set it as output rgb */
                priv->output = LVDS_OUTPUT_RGB;

Can you use dev_read_u32_default() ?

also below.

Quoted 57 lines
drivers/video/rockchip/rk_lvds.c +4 -10
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1);
-       if (ret != -1) {
-               priv->format = ret;
-               debug("LVDS data-mapping : %d\n", ret);
-       } else {
-               /* default set it as format jeida */
+       if (!dev_read_s32(dev, "rockchip,data-mapping", &priv->format))
+               debug("LVDS data-mapping : %d\n", priv->format);
+       else /* default set it as format jeida */
                priv->format = LVDS_FORMAT_JEIDA;
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1);
-       if (ret != -1) {
+       if (!dev_read_s32(dev, "rockchip,data-width", &ret)) {
                debug("LVDS data-width : %d\n", ret);
                if (ret == 24) {
                        priv->format |= LVDS_24BIT;
drivers/video/rockchip/rk_mipi.c +5 -7
index a77bdfd24d..f1c21bb8d7 100644
@@ -8,7 +8,6 @@
 #include <clk.h>
 #include <display.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <panel.h>
 #include <regmap.h>
 #include "rk_mipi.h"
@@ -76,7 +75,7 @@ static void rk_mipi_dsi_write(uintptr_t regs, u32 reg, u32 val)
 int rk_mipi_dsi_enable(struct udevice *dev,
                       const struct display_timing *timing)
 {
-       int node, timing_node;
+       ofnode node, timing_node;
        int val;
        struct rk_mipi_priv *priv = dev_get_priv(dev);
        uintptr_t regs = priv->regs;
@@ -119,10 +118,10 @@ int rk_mipi_dsi_enable(struct udevice *dev,
        rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
        /* Set dpi color coding depth 24 bit */
-       timing_node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
-                                                                        "display-timings");
-       node = fdt_first_subnode(gd->fdt_blob, timing_node);
-       val = fdtdec_get_int(gd->fdt_blob, node, "bits-per-pixel", -1);
+       timing_node = ofnode_find_subnode(dev->node, "display-timings");
+       node = ofnode_first_subnode(timing_node);
+
+       val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
        switch (val) {
        case 16:
                rk_mipi_dsi_write(regs, DPI_COLOR_CODING, DPI_16BIT_CFG_1);
--
Quoted 4 lines

2.17.1

Regards,
Simon

author
#3 lore raw

PATCH v2 2/2 rockchip: video: Convert to use APIs which support live DT

Hi Simon,

Quoted 11 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

Changes in v2:
- use dev_read_s32() instead of dev_read_s32_default();

[...]

Quoted 61 lines
Quoted 61 lines
  drivers/video/rockchip/rk3288_mipi.c |  1 -
  drivers/video/rockchip/rk3399_mipi.c |  1 -
  drivers/video/rockchip/rk_edp.c      |  2 +-
  drivers/video/rockchip/rk_lvds.c     | 28 +++++++++-------------------
  drivers/video/rockchip/rk_mipi.c     | 11 +++++------
  5 files changed, 15 insertions(+), 28 deletions(-)
drivers/video/rockchip/rk3288_mipi.c +0 -1
index f4444b9c34..71d3faf169 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
drivers/video/rockchip/rk3399_mipi.c +0 -1
index 74ebe770a9..cfaa37797e 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
drivers/video/rockchip/rk_edp.c +1 -1
index 8703df0ec0..842034c77c 100644
@@ -996,7 +996,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
  {
         struct rk_edp_priv *priv = dev_get_priv(dev);
 
-       priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
+       priv->regs = dev_read_addr_ptr(dev);
         priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
         return 0;
drivers/video/rockchip/rk_lvds.c +2 -3
index cae8bada32..a11d793135 100644
@@ -171,32 +171,22 @@ int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
  static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
  {
         struct rk_lvds_priv *priv = dev_get_priv(dev);
-       const void *blob = gd->fdt_blob;
-       int node = dev_of_offset(dev);
         int ret;
-       priv->regs = (void *)devfdt_get_addr(dev);
+
+       priv->regs = dev_read_addr_ptr(dev);
         priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
Quoted 11 lines

drivers/video/rockchip/rk_lvds.c int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing) · line 182

Quoted 10 lines
drivers/video/rockchip/rk_lvds.c +3 -6
-       ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
-       if (ret != -1) {
-               priv->output = ret;
-               debug("LVDS output : %d\n", ret);
-       } else {
-               /* default set it as output rgb */
+       if (!dev_read_s32(dev, "rockchip,output", &priv->output))
+               debug("LVDS output : %d\n", priv->output);
+       else /* default set it as output rgb */
                 priv->output = LVDS_OUTPUT_RGB;

Can you use dev_read_u32_default() ?

Could you share the point about which API should be used? It's both OK to me and I think

it's up to user to decide which is more convenient for them.

The main update of this version for this patch is update to use dev_read_s32() instead of

dev_read_u32_default() as your request.? Maybe you can take V1 patch[0]?

Thanks,

- Kever

[0] http://patchwork.ozlabs.org/patch/1240459/

Quoted 67 lines

also below.

Quoted 57 lines
drivers/video/rockchip/rk_lvds.c +4 -10
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1);
-       if (ret != -1) {
-               priv->format = ret;
-               debug("LVDS data-mapping : %d\n", ret);
-       } else {
-               /* default set it as format jeida */
+       if (!dev_read_s32(dev, "rockchip,data-mapping", &priv->format))
+               debug("LVDS data-mapping : %d\n", priv->format);
+       else /* default set it as format jeida */
                 priv->format = LVDS_FORMAT_JEIDA;
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1);
-       if (ret != -1) {
+       if (!dev_read_s32(dev, "rockchip,data-width", &ret)) {
                 debug("LVDS data-width : %d\n", ret);
                 if (ret == 24) {
                         priv->format |= LVDS_24BIT;
drivers/video/rockchip/rk_mipi.c +5 -7
index a77bdfd24d..f1c21bb8d7 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
@@ -76,7 +75,7 @@ static void rk_mipi_dsi_write(uintptr_t regs, u32 reg, u32 val)
  int rk_mipi_dsi_enable(struct udevice *dev,
                        const struct display_timing *timing)
  {
-       int node, timing_node;
+       ofnode node, timing_node;
         int val;
         struct rk_mipi_priv *priv = dev_get_priv(dev);
         uintptr_t regs = priv->regs;
@@ -119,10 +118,10 @@ int rk_mipi_dsi_enable(struct udevice *dev,
         rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
         /* Set dpi color coding depth 24 bit */
-       timing_node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
-                                                                        "display-timings");
-       node = fdt_first_subnode(gd->fdt_blob, timing_node);
-       val = fdtdec_get_int(gd->fdt_blob, node, "bits-per-pixel", -1);
+       timing_node = ofnode_find_subnode(dev->node, "display-timings");
+       node = ofnode_first_subnode(timing_node);
+
+       val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
         switch (val) {
         case 16:
                 rk_mipi_dsi_write(regs, DPI_COLOR_CODING, DPI_16BIT_CFG_1);
--
Quoted 4 lines

2.17.1

Regards,
Simon

#4 lore raw

PATCH v2 2/2 rockchip: video: Convert to use APIs which support live DT

Hi Kever,

Quoted 94 lines · Kever Yang

Hi Simon,

Quoted 11 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

Changes in v2:
- use dev_read_s32() instead of dev_read_s32_default();

[...]

Quoted 61 lines
Quoted 61 lines
  drivers/video/rockchip/rk3288_mipi.c |  1 -
  drivers/video/rockchip/rk3399_mipi.c |  1 -
  drivers/video/rockchip/rk_edp.c      |  2 +-
  drivers/video/rockchip/rk_lvds.c     | 28 +++++++++-------------------
  drivers/video/rockchip/rk_mipi.c     | 11 +++++------
  5 files changed, 15 insertions(+), 28 deletions(-)
drivers/video/rockchip/rk3288_mipi.c +0 -1
index f4444b9c34..71d3faf169 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
drivers/video/rockchip/rk3399_mipi.c +0 -1
index 74ebe770a9..cfaa37797e 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
drivers/video/rockchip/rk_edp.c +1 -1
index 8703df0ec0..842034c77c 100644
@@ -996,7 +996,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
  {
         struct rk_edp_priv *priv = dev_get_priv(dev);
 
-       priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
+       priv->regs = dev_read_addr_ptr(dev);
         priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
         return 0;
drivers/video/rockchip/rk_lvds.c +2 -3
index cae8bada32..a11d793135 100644
@@ -171,32 +171,22 @@ int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
  static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
  {
         struct rk_lvds_priv *priv = dev_get_priv(dev);
-       const void *blob = gd->fdt_blob;
-       int node = dev_of_offset(dev);
         int ret;
-       priv->regs = (void *)devfdt_get_addr(dev);
+
+       priv->regs = dev_read_addr_ptr(dev);
         priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
Quoted 11 lines

drivers/video/rockchip/rk_lvds.c int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing) · line 182

Quoted 10 lines
drivers/video/rockchip/rk_lvds.c +3 -6
-       ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
-       if (ret != -1) {
-               priv->output = ret;
-               debug("LVDS output : %d\n", ret);
-       } else {
-               /* default set it as output rgb */
+       if (!dev_read_s32(dev, "rockchip,output", &priv->output))
+               debug("LVDS output : %d\n", priv->output);
+       else /* default set it as output rgb */
                 priv->output = LVDS_OUTPUT_RGB;

Can you use dev_read_u32_default() ?

Could you share the point about which API should be used? It's both OK to me and I think

Quoted 6 lines

it's up to user to decide which is more convenient for them.

The main update of this version for this patch is update to use dev_read_s32() instead of

dev_read_u32_default() as your request. Maybe you can take V1 patch[0]?

Yes that was better, sorry.

Regards,
Simon

Quoted 77 lines

Thanks,

- Kever

[0] http://patchwork.ozlabs.org/patch/1240459/

Quoted 67 lines

also below.

Quoted 57 lines
drivers/video/rockchip/rk_lvds.c +4 -10
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1);
-       if (ret != -1) {
-               priv->format = ret;
-               debug("LVDS data-mapping : %d\n", ret);
-       } else {
-               /* default set it as format jeida */
+       if (!dev_read_s32(dev, "rockchip,data-mapping", &priv->format))
+               debug("LVDS data-mapping : %d\n", priv->format);
+       else /* default set it as format jeida */
                 priv->format = LVDS_FORMAT_JEIDA;
-       }
 
-       ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1);
-       if (ret != -1) {
+       if (!dev_read_s32(dev, "rockchip,data-width", &ret)) {
                 debug("LVDS data-width : %d\n", ret);
                 if (ret == 24) {
                         priv->format |= LVDS_24BIT;
drivers/video/rockchip/rk_mipi.c +5 -7
index a77bdfd24d..f1c21bb8d7 100644
@@ -8,7 +8,6 @@
  #include <clk.h>
  #include <display.h>
  #include <dm.h>
-#include <fdtdec.h>
  #include <panel.h>
  #include <regmap.h>
  #include "rk_mipi.h"
@@ -76,7 +75,7 @@ static void rk_mipi_dsi_write(uintptr_t regs, u32 reg, u32 val)
  int rk_mipi_dsi_enable(struct udevice *dev,
                        const struct display_timing *timing)
  {
-       int node, timing_node;
+       ofnode node, timing_node;
         int val;
         struct rk_mipi_priv *priv = dev_get_priv(dev);
         uintptr_t regs = priv->regs;
@@ -119,10 +118,10 @@ int rk_mipi_dsi_enable(struct udevice *dev,
         rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
         /* Set dpi color coding depth 24 bit */
-       timing_node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
-                                                                        "display-timings");
-       node = fdt_first_subnode(gd->fdt_blob, timing_node);
-       val = fdtdec_get_int(gd->fdt_blob, node, "bits-per-pixel", -1);
+       timing_node = ofnode_find_subnode(dev->node, "display-timings");
+       node = ofnode_first_subnode(timing_node);
+
+       val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
         switch (val) {
         case 16:
                 rk_mipi_dsi_write(regs, DPI_COLOR_CODING, DPI_16BIT_CFG_1);
--
Quoted 4 lines

2.17.1

Regards,
Simon

#5 lore raw

PATCH v2 1/2 rockchip: video: Use ofnode_decode_display_timing() to parse timing

In reply to Kever Yang
Quoted 5 lines · Kever Yang

Use ofnode_decode_display_timing() instead of fdtdec_decode_display_timing() to parse display timing, so that we can support live DT.

Quoted 9 lines

---

Changes in v2: None

 drivers/video/rockchip/rk_lvds.c | 3 +--
 drivers/video/rockchip/rk_mipi.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)