mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
rockchip: video: rk_vop: migrate to livetree
This migrates rk_vop (the shared functions used by multiple VOP mini-drivers) to be compatible with a live tree. Unfortunately, there's (i) a lot of tree traversal needed for a VOP (as each active VOP vnode references back to the endpoints in the encoders and vice versa) to configure the connection between VOPs and encoders; (ii) the DTS binding is not too sane and one needs to walk a node's parents (the original code just assumed that the device would live 3 levels above the property linked through a phandle) until a UCLASS_DISPLAY device can be found. As part of the migration, the code for finding the enclosing display device has been changed to not assume a specific depth of nesting (i.e. we walk until we reach the root or find a matching device) and to use the newly introduced (in the same series) ofnode_get_parent() function. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com> Reviewed-by: Anatolij Gustschin <agust@denx.de>
This commit is contained in:

committed by
Anatolij Gustschin

parent
18e48776a6
commit
5de0b5a36a
@ -218,41 +218,67 @@ static void rkvop_mode_set(struct udevice *dev,
|
|||||||
* node within the VOP's 'port' list.
|
* node within the VOP's 'port' list.
|
||||||
* @return 0 if OK, -ve if something went wrong
|
* @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);
|
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);
|
struct rk_vop_priv *priv = dev_get_priv(dev);
|
||||||
int vop_id, remote_vop_id;
|
int vop_id, remote_vop_id;
|
||||||
struct rk3288_vop *regs = priv->regs;
|
struct rk3288_vop *regs = priv->regs;
|
||||||
struct display_timing timing;
|
struct display_timing timing;
|
||||||
struct udevice *disp;
|
struct udevice *disp;
|
||||||
int ret, remote, i, offset;
|
int ret;
|
||||||
|
u32 remote_phandle;
|
||||||
struct display_plat *disp_uc_plat;
|
struct display_plat *disp_uc_plat;
|
||||||
struct clk clk;
|
struct clk clk;
|
||||||
enum video_log2_bpp l2bpp;
|
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);
|
debug("vop_id=%d\n", vop_id);
|
||||||
remote = fdtdec_lookup_phandle(blob, ep_node, "remote-endpoint");
|
ret = ofnode_read_u32(ep_node, "remote-endpoint", &remote_phandle);
|
||||||
if (remote < 0)
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
remote = ofnode_get_by_phandle(remote_phandle);
|
||||||
|
if (!ofnode_valid(remote))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
remote_vop_id = fdtdec_get_int(blob, remote, "reg", -1);
|
remote_vop_id = ofnode_read_u32_default(remote, "reg", -1);
|
||||||
debug("remote vop_id=%d\n", remote_vop_id);
|
debug("remote vop_id=%d\n", remote_vop_id);
|
||||||
|
|
||||||
for (i = 0, offset = remote; i < 3 && offset > 0; i++)
|
/*
|
||||||
offset = fdt_parent_offset(blob, offset);
|
* The remote-endpoint references into a subnode of the encoder
|
||||||
if (offset < 0) {
|
* (i.e. HDMI, MIPI, etc.) with the DTS looking something like
|
||||||
debug("%s: Invalid remote-endpoint position\n", dev->name);
|
* the following (assume 'hdmi_in_vopl' to be referenced):
|
||||||
return -EINVAL;
|
*
|
||||||
}
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
ret = uclass_find_device_by_of_offset(UCLASS_DISPLAY, offset, &disp);
|
uclass_find_device_by_ofnode(UCLASS_DISPLAY, remote, &disp);
|
||||||
if (ret) {
|
if (disp)
|
||||||
debug("%s: device '%s' display not found (ret=%d)\n", __func__,
|
break;
|
||||||
dev->name, ret);
|
};
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
disp_uc_plat = dev_get_uclass_platdata(disp);
|
disp_uc_plat = dev_get_uclass_platdata(disp);
|
||||||
debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat);
|
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)
|
int rk_vop_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct video_uc_platdata *plat = dev_get_uclass_platdata(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);
|
struct rk_vop_priv *priv = dev_get_priv(dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int port, node;
|
ofnode port, node;
|
||||||
|
|
||||||
/* Before relocation we don't need to do anything */
|
/* Before relocation we don't need to do anything */
|
||||||
if (!(gd->flags & GD_FLG_RELOC))
|
if (!(gd->flags & GD_FLG_RELOC))
|
||||||
return 0;
|
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
|
* 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
|
* clock so it is currently not possible to use more than one display
|
||||||
* device simultaneously.
|
* device simultaneously.
|
||||||
*/
|
*/
|
||||||
port = fdt_subnode_offset(blob, dev_of_offset(dev), "port");
|
port = dev_read_subnode(dev, "port");
|
||||||
if (port < 0)
|
if (!ofnode_valid(port)) {
|
||||||
|
debug("%s(%s): 'port' subnode not found\n",
|
||||||
|
__func__, dev_read_name(dev));
|
||||||
return -EINVAL;
|
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);
|
ret = rk_display_init(dev, plat->base, node);
|
||||||
if (ret)
|
if (ret)
|
||||||
debug("Device failed: ret=%d\n", ret);
|
debug("Device failed: ret=%d\n", ret);
|
||||||
|
Reference in New Issue
Block a user