of_graph_get_remote_port

isp {
        compatible = "isp";
        core@0 {
            id = <0>;
            ports {
                #address-cells = <1>;
                #size-cells = <0>;
                port@0 {
                    reg = <0>;
                    isp_chan0_in: endpoint@0 {
                        remote-endpoint = <&csi0_out0>;
                    };
                };
                port@1 {
                    reg = <1>;
                    isp_chan1_in: endpoint@1 {
                        remote-endpoint = <&csi0_out1>;
                    };
                };
            };
        };

        core@1 {
            id = <1>;
            ports {
                #address-cells = <1>;
                #size-cells = <0>;
                port@2 {
                    reg = <0>;
                    isp_chan2_in: endpoint@2 {
                        remote-endpoint = <&csi1_out0>;
                    };
                };
                port@3 {
                    reg = <1>;
                    isp_chan3_in: endpoint@3 {
                        remote-endpoint = <&csi1_out1>;
                    };
                };

            };
        };
    }

csi@0 {
        compatible = "csi2";
        #address-cells = <1>;
        #size-cells = <0>;
        point-link {
            ports {
                port@0 {
                    csi0_in: endpoint@0{
                        remote-endpoint = <&deser0_out>;
                    };
                };
            };
        };
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
            port@0 {
                reg = <0>;
                csi0_out0: endpoint@0 {
                    remote-endpoint = <&isp_chan0_in>;
                };
            };
            port@1 {
                reg = <1>;
                csi0_out1: endpoint@1 {
                    remote-endpoint = <&isp_chan1_in>;
                };
            };
        };
    };

  csi@1 {
    compatible = "csi2";
        #address-cells = <1>;
        #size-cells = <0>;
        point-link {
            ports {
                port@0 {
                    csi_1_in: endpoint@0{
                        remote-endpoint = <&deser_1_out>;
                    };
                };
            };
        };
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
            port@0 {
                reg = <0>;
                csi1_out0: endpoint@0 {
                    remote-endpoint = <&isp_chan2_in>;
                };
            };
            port@1 {
                reg = <1>;
                csi1_out1: endpoint@1 {
                    remote-endpoint = <&isp_chan3_in>;
                };
            };
        };
    };

deser0 {
    compatible = "deser0";
    #address-cells = <1>;
    #size-cells = <0>;
    point-link {
        ports {
            port@0 {
                deser0_out: endpoint{
                    remote-endpoint = <&csi0_in>;
                };
            };
        };
    };

    ports {
        #address-cells = <1>;
        #size-cells = <0>;
        port@0 {
            reg = <0>;
            deser0_in0: endpoint@0{
                remote-endpoint = <&camera0_out>;
            };
        };
        port@1 {
            reg = <1>;
            deser0_in1: endpoint@1{
                remote-endpoint = <&camera1_out>;
            };
        };
    };
};

&i2c0 {
    camera0 {
        reg = <0x10>;
        port {
            camera0_out: endpoint@0 {
                remote-endpoint = <&deser0_in0>;
            };
        };
    };
/**
 * of_graph_get_next_endpoint() - get next endpoint node
 * @parent: pointer to the parent device node
 * @prev: previous endpoint node, or NULL to get first
 *
 * Return: An 'endpoint' node pointer with refcount incremented. Refcount
 * of the passed @prev node is decremented.
 */
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
                    struct device_node *prev)
{
    struct device_node *endpoint;
    struct device_node *port;

    if (!parent)
        return NULL;

    /*
     * Start by locating the port node. If no previous endpoint is specified
     * search for the first port node, otherwise get the previous endpoint
     * parent port node.
     */
    if (!prev) {
        struct device_node *node;

        node = of_get_child_by_name(parent, "ports");
        if (node)
            parent = node;

        port = of_get_child_by_name(parent, "port");
        of_node_put(node);

        if (!port) {
            pr_err("graph: no port node found in %pOF\n", parent);
            return NULL;
        }
    } else {
        port = of_get_parent(prev);
        if (WARN_ONCE(!port, "%s(): endpoint %pOF has no parent node\n",
                  __func__, prev))
            return NULL;
    }

    while (1) {
        /*
         * Now that we have a port node, get the next endpoint by
         * getting the next child. If the previous endpoint is NULL this
         * will return the first child.
         */
        endpoint = of_get_next_child(port, prev);
        if (endpoint) {
            of_node_put(port);
            return endpoint;
        }

        /* No more endpoints under this port, try the next one. */
        prev = NULL;

        do {
            port = of_get_next_child(parent, port);
            if (!port)
                return NULL;
        } while (of_node_cmp(port->name, "port"));
    }
}


struct device_node *of_graph_get_remote_port(const struct device_node *node)
{
    struct device_node *np;

    /* Get remote endpoint node. */
    np = of_graph_get_remote_endpoint(node);
    if (!np)
        return NULL;
    return of_get_next_parent(np);
}

struct device_node *of_graph_get_remote_endpoint(const struct device_node *node)
{
    /* Get remote endpoint node. */
    return of_parse_phandle(node, "remote-endpoint", 0);
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值