summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-02-24 08:02:17 -0500
committerTom Rini <trini@konsulko.com>2018-02-24 08:02:17 -0500
commit0bb430c8494e26e8d258cf6957cdd39d2ce4f309 (patch)
tree64a043dbcaea96f023129cf9ec588fbb82d54f8f
parentba8bf9481b0854fa7d48b0e9ed913c639f187c7d (diff)
parent3f56552227d1b711cf7dcae986ae0a3f2a91e8d7 (diff)
downloadu-boot-0bb430c8494e26e8d258cf6957cdd39d2ce4f309.tar.gz
Merge git://git.denx.de/u-boot-video
-rw-r--r--MAINTAINERS1
-rw-r--r--drivers/core/ofnode.c27
-rw-r--r--drivers/video/rockchip/rk_hdmi.c2
-rw-r--r--drivers/video/rockchip/rk_vop.c85
-rw-r--r--include/dm/ofnode.h16
5 files changed, 102 insertions, 29 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index d2f8c513e0..077828cf1d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -163,6 +163,7 @@ F: drivers/misc/rockchip-efuse.c
F: drivers/pinctrl/rockchip/
F: drivers/ram/rockchip/
F: drivers/sysreset/sysreset_rockchip.c
+F: drivers/video/rockchip/
F: tools/rkcommon.c
F: tools/rkcommon.h
F: tools/rkimage.c
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 98f4b539ea..d0bdea08df 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -165,6 +165,20 @@ ofnode ofnode_next_subnode(ofnode node)
fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
}
+ofnode ofnode_get_parent(ofnode node)
+{
+ ofnode parent;
+
+ assert(ofnode_valid(node));
+ if (ofnode_is_np(node))
+ parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
+ else
+ parent.of_offset = fdt_parent_offset(gd->fdt_blob,
+ ofnode_to_offset(node));
+
+ return parent;
+}
+
const char *ofnode_get_name(ofnode node)
{
assert(ofnode_valid(node));
@@ -174,6 +188,19 @@ const char *ofnode_get_name(ofnode node)
return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
}
+ofnode ofnode_get_by_phandle(uint phandle)
+{
+ ofnode node;
+
+ if (of_live_active())
+ node = np_to_ofnode(of_find_node_by_phandle(phandle));
+ else
+ node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
+ phandle);
+
+ return node;
+}
+
int ofnode_read_size(ofnode node, const char *propname)
{
int len;
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index a9c8fba7e4..b55b397f34 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -84,7 +84,7 @@ int rk_hdmi_ofdata_to_platdata(struct udevice *dev)
struct rk_hdmi_priv *priv = dev_get_priv(dev);
struct dw_hdmi *hdmi = &priv->hdmi;
- hdmi->ioaddr = (ulong)devfdt_get_addr(dev);
+ hdmi->ioaddr = (ulong)dev_read_addr(dev);
hdmi->mpll_cfg = rockchip_mpll_cfg;
hdmi->phy_cfg = rockchip_phy_config;
diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index c979049b5b..1288608207 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -218,41 +218,67 @@ static void rkvop_mode_set(struct udevice *dev,
* node within the VOP's 'port' list.
* @return 0 if OK, -ve if something went wrong
*/
-static int rk_display_init(struct udevice *dev, ulong fbbase, int ep_node)
+static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
{
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
- const void *blob = gd->fdt_blob;
struct rk_vop_priv *priv = dev_get_priv(dev);
int vop_id, remote_vop_id;
struct rk3288_vop *regs = priv->regs;
struct display_timing timing;
struct udevice *disp;
- int ret, remote, i, offset;
+ int ret;
+ u32 remote_phandle;
struct display_plat *disp_uc_plat;
struct clk clk;
enum video_log2_bpp l2bpp;
+ ofnode remote;
- vop_id = fdtdec_get_int(blob, ep_node, "reg", -1);
+ debug("%s(%s, %lu, %s)\n", __func__,
+ dev_read_name(dev), fbbase, ofnode_get_name(ep_node));
+
+ vop_id = ofnode_read_s32_default(ep_node, "reg", -1);
debug("vop_id=%d\n", vop_id);
- remote = fdtdec_lookup_phandle(blob, ep_node, "remote-endpoint");
- if (remote < 0)
- return -EINVAL;
- remote_vop_id = fdtdec_get_int(blob, remote, "reg", -1);
- debug("remote vop_id=%d\n", remote_vop_id);
+ ret = ofnode_read_u32(ep_node, "remote-endpoint", &remote_phandle);
+ if (ret)
+ return ret;
- for (i = 0, offset = remote; i < 3 && offset > 0; i++)
- offset = fdt_parent_offset(blob, offset);
- if (offset < 0) {
- debug("%s: Invalid remote-endpoint position\n", dev->name);
+ remote = ofnode_get_by_phandle(remote_phandle);
+ if (!ofnode_valid(remote))
return -EINVAL;
- }
+ remote_vop_id = ofnode_read_u32_default(remote, "reg", -1);
+ debug("remote vop_id=%d\n", remote_vop_id);
- ret = uclass_find_device_by_of_offset(UCLASS_DISPLAY, offset, &disp);
- if (ret) {
- debug("%s: device '%s' display not found (ret=%d)\n", __func__,
- dev->name, ret);
- return ret;
- }
+ /*
+ * The remote-endpoint references into a subnode of the encoder
+ * (i.e. HDMI, MIPI, etc.) with the DTS looking something like
+ * the following (assume 'hdmi_in_vopl' to be referenced):
+ *
+ * hdmi: hdmi@ff940000 {
+ * ports {
+ * hdmi_in: port {
+ * hdmi_in_vopb: endpoint@0 { ... };
+ * hdmi_in_vopl: endpoint@1 { ... };
+ * }
+ * }
+ * }
+ *
+ * The original code had 3 steps of "walking the parent", but
+ * a much better (as in: less likely to break if the DTS
+ * changes) way of doing this is to "find the enclosing device
+ * of UCLASS_DISPLAY".
+ */
+ while (ofnode_valid(remote)) {
+ remote = ofnode_get_parent(remote);
+ if (!ofnode_valid(remote)) {
+ debug("%s(%s): no UCLASS_DISPLAY for remote-endpoint\n",
+ __func__, dev_read_name(dev));
+ return -EINVAL;
+ }
+
+ uclass_find_device_by_ofnode(UCLASS_DISPLAY, remote, &disp);
+ if (disp)
+ break;
+ };
disp_uc_plat = dev_get_uclass_platdata(disp);
debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat);
@@ -334,16 +360,15 @@ void rk_vop_probe_regulators(struct udevice *dev,
int rk_vop_probe(struct udevice *dev)
{
struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
- const void *blob = gd->fdt_blob;
struct rk_vop_priv *priv = dev_get_priv(dev);
int ret = 0;
- int port, node;
+ ofnode port, node;
/* Before relocation we don't need to do anything */
if (!(gd->flags & GD_FLG_RELOC))
return 0;
- priv->regs = (struct rk3288_vop *)devfdt_get_addr(dev);
+ priv->regs = (struct rk3288_vop *)dev_read_addr(dev);
/*
* Try all the ports until we find one that works. In practice this
@@ -353,12 +378,16 @@ int rk_vop_probe(struct udevice *dev)
* clock so it is currently not possible to use more than one display
* device simultaneously.
*/
- port = fdt_subnode_offset(blob, dev_of_offset(dev), "port");
- if (port < 0)
+ port = dev_read_subnode(dev, "port");
+ if (!ofnode_valid(port)) {
+ debug("%s(%s): 'port' subnode not found\n",
+ __func__, dev_read_name(dev));
return -EINVAL;
- for (node = fdt_first_subnode(blob, port);
- node > 0;
- node = fdt_next_subnode(blob, node)) {
+ }
+
+ for (node = ofnode_first_subnode(port);
+ ofnode_valid(node);
+ node = dev_read_next_subnode(node)) {
ret = rk_display_init(dev, plat->base, node);
if (ret)
debug("Device failed: ret=%d\n", ret);
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index c359a60f95..0d008404f9 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -302,6 +302,14 @@ ofnode ofnode_first_subnode(ofnode node);
ofnode ofnode_next_subnode(ofnode node);
/**
+ * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode)
+ *
+ * @node: valid node to look up
+ * @return ofnode reference of the parent node
+ */
+ofnode ofnode_get_parent(ofnode node);
+
+/**
* ofnode_get_name() - get the name of a node
*
* @node: valid node to look up
@@ -310,6 +318,14 @@ ofnode ofnode_next_subnode(ofnode node);
const char *ofnode_get_name(ofnode node);
/**
+ * ofnode_get_by_phandle() - get ofnode from phandle
+ *
+ * @phandle: phandle to look up
+ * @return ofnode reference to the phandle
+ */
+ofnode ofnode_get_by_phandle(uint phandle);
+
+/**
* ofnode_read_size() - read the size of a property
*
* @node: node to check