|
12 | 12 | #include <linux/clk.h>
|
13 | 13 | #include <linux/dma-mapping.h>
|
14 | 14 | #include <linux/module.h>
|
| 15 | +#include <linux/of_graph.h> |
15 | 16 | #include <linux/of_reserved_mem.h>
|
16 | 17 | #include <linux/platform_device.h>
|
17 | 18 | #include <linux/pm_runtime.h>
|
@@ -142,6 +143,55 @@ static int zynqmp_dpsub_init_clocks(struct zynqmp_dpsub *dpsub)
|
142 | 143 | return 0;
|
143 | 144 | }
|
144 | 145 |
|
| 146 | +static int zynqmp_dpsub_parse_dt(struct zynqmp_dpsub *dpsub) |
| 147 | +{ |
| 148 | + struct device_node *np; |
| 149 | + unsigned int i; |
| 150 | + |
| 151 | + /* |
| 152 | + * For backward compatibility with old device trees that don't contain |
| 153 | + * ports, consider that only the DP output port is connected if no |
| 154 | + * ports child no exists. |
| 155 | + */ |
| 156 | + np = of_get_child_by_name(dpsub->dev->of_node, "ports"); |
| 157 | + of_node_put(np); |
| 158 | + if (!np) { |
| 159 | + dev_warn(dpsub->dev, "missing ports, update DT bindings\n"); |
| 160 | + dpsub->connected_ports = BIT(ZYNQMP_DPSUB_PORT_OUT_DP); |
| 161 | + return 0; |
| 162 | + } |
| 163 | + |
| 164 | + /* Check which ports are connected. */ |
| 165 | + for (i = 0; i < ZYNQMP_DPSUB_NUM_PORTS; ++i) { |
| 166 | + struct device_node *np; |
| 167 | + |
| 168 | + np = of_graph_get_remote_node(dpsub->dev->of_node, i, -1); |
| 169 | + if (np) { |
| 170 | + dpsub->connected_ports |= BIT(i); |
| 171 | + of_node_put(np); |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + /* Sanity checks. */ |
| 176 | + if ((dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_LIVE_VIDEO)) || |
| 177 | + (dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_LIVE_GFX))) |
| 178 | + dev_warn(dpsub->dev, "live video unsupported, ignoring\n"); |
| 179 | + |
| 180 | + if (dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_LIVE_AUDIO)) |
| 181 | + dev_warn(dpsub->dev, "live audio unsupported, ignoring\n"); |
| 182 | + |
| 183 | + if ((dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_OUT_VIDEO)) || |
| 184 | + (dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_OUT_AUDIO))) |
| 185 | + dev_warn(dpsub->dev, "output to PL unsupported, ignoring\n"); |
| 186 | + |
| 187 | + if (!(dpsub->connected_ports & BIT(ZYNQMP_DPSUB_PORT_OUT_DP))) { |
| 188 | + dev_err(dpsub->dev, "DP output port not connected\n"); |
| 189 | + return -EINVAL; |
| 190 | + } |
| 191 | + |
| 192 | + return 0; |
| 193 | +} |
| 194 | + |
145 | 195 | void zynqmp_dpsub_release(struct zynqmp_dpsub *dpsub)
|
146 | 196 | {
|
147 | 197 | kfree(dpsub->disp);
|
@@ -171,6 +221,10 @@ static int zynqmp_dpsub_probe(struct platform_device *pdev)
|
171 | 221 | if (ret < 0)
|
172 | 222 | goto err_mem;
|
173 | 223 |
|
| 224 | + ret = zynqmp_dpsub_parse_dt(dpsub); |
| 225 | + if (ret < 0) |
| 226 | + goto err_mem; |
| 227 | + |
174 | 228 | pm_runtime_enable(&pdev->dev);
|
175 | 229 |
|
176 | 230 | /*
|
|
0 commit comments