Lines Matching +full:dual +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0+
8 #include <linux/media-bus-format.h>
23 #include <dt-bindings/firmware/imx/rsrc.h>
33 #define DRIVER_NAME "imx8qxp-pxl2dpi"
53 struct imx8qxp_pxl2dpi *p2d = bridge->driver_private; in imx8qxp_pxl2dpi_bridge_attach()
56 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_bridge_attach()
58 return -EINVAL; in imx8qxp_pxl2dpi_bridge_attach()
61 return drm_bridge_attach(bridge->encoder, in imx8qxp_pxl2dpi_bridge_attach()
62 p2d->next_bridge, bridge, in imx8qxp_pxl2dpi_bridge_attach()
72 struct imx8qxp_pxl2dpi *p2d = bridge->driver_private; in imx8qxp_pxl2dpi_bridge_atomic_check()
74 p2d->in_bus_format = bridge_state->input_bus_cfg.format; in imx8qxp_pxl2dpi_bridge_atomic_check()
75 p2d->out_bus_format = bridge_state->output_bus_cfg.format; in imx8qxp_pxl2dpi_bridge_atomic_check()
85 struct imx8qxp_pxl2dpi *p2d = bridge->driver_private; in imx8qxp_pxl2dpi_bridge_mode_set()
89 ret = pm_runtime_get_sync(p2d->dev); in imx8qxp_pxl2dpi_bridge_mode_set()
91 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_bridge_mode_set()
94 ret = imx_sc_misc_set_control(p2d->ipc_handle, p2d->sc_resource, in imx8qxp_pxl2dpi_bridge_mode_set()
95 IMX_SC_C_PXL_LINK_SEL, p2d->pl_sel); in imx8qxp_pxl2dpi_bridge_mode_set()
97 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_bridge_mode_set()
99 p2d->pl_sel, ret); in imx8qxp_pxl2dpi_bridge_mode_set()
101 switch (p2d->out_bus_format) { in imx8qxp_pxl2dpi_bridge_mode_set()
103 regmap_write(p2d->regmap, PXL2DPI_CTRL, CFG_24BIT); in imx8qxp_pxl2dpi_bridge_mode_set()
106 regmap_write(p2d->regmap, PXL2DPI_CTRL, CFG2_18BIT); in imx8qxp_pxl2dpi_bridge_mode_set()
109 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_bridge_mode_set()
111 p2d->out_bus_format); in imx8qxp_pxl2dpi_bridge_mode_set()
114 if (p2d->companion) { in imx8qxp_pxl2dpi_bridge_mode_set()
115 companion_p2d = bridge_to_p2d(p2d->companion); in imx8qxp_pxl2dpi_bridge_mode_set()
117 companion_p2d->in_bus_format = p2d->in_bus_format; in imx8qxp_pxl2dpi_bridge_mode_set()
118 companion_p2d->out_bus_format = p2d->out_bus_format; in imx8qxp_pxl2dpi_bridge_mode_set()
120 p2d->companion->funcs->mode_set(p2d->companion, mode, in imx8qxp_pxl2dpi_bridge_mode_set()
129 struct imx8qxp_pxl2dpi *p2d = bridge->driver_private; in imx8qxp_pxl2dpi_bridge_atomic_disable()
132 ret = pm_runtime_put(p2d->dev); in imx8qxp_pxl2dpi_bridge_atomic_disable()
134 DRM_DEV_ERROR(p2d->dev, "failed to put runtime PM: %d\n", ret); in imx8qxp_pxl2dpi_bridge_atomic_disable()
136 if (p2d->companion) in imx8qxp_pxl2dpi_bridge_atomic_disable()
137 p2d->companion->funcs->atomic_disable(p2d->companion, in imx8qxp_pxl2dpi_bridge_atomic_disable()
223 struct device_node *port, *ep; in imx8qxp_pxl2dpi_get_available_ep_from_port() local
226 port = of_graph_get_port_by_id(p2d->dev->of_node, port_id); in imx8qxp_pxl2dpi_get_available_ep_from_port()
227 if (!port) { in imx8qxp_pxl2dpi_get_available_ep_from_port()
228 DRM_DEV_ERROR(p2d->dev, "failed to get port@%u\n", port_id); in imx8qxp_pxl2dpi_get_available_ep_from_port()
229 return ERR_PTR(-ENODEV); in imx8qxp_pxl2dpi_get_available_ep_from_port()
232 ep_cnt = of_get_available_child_count(port); in imx8qxp_pxl2dpi_get_available_ep_from_port()
234 DRM_DEV_ERROR(p2d->dev, "no available endpoints of port@%u\n", in imx8qxp_pxl2dpi_get_available_ep_from_port()
236 ep = ERR_PTR(-ENODEV); in imx8qxp_pxl2dpi_get_available_ep_from_port()
239 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_get_available_ep_from_port()
240 "invalid available endpoints of port@%u\n", in imx8qxp_pxl2dpi_get_available_ep_from_port()
242 ep = ERR_PTR(-EINVAL); in imx8qxp_pxl2dpi_get_available_ep_from_port()
246 ep = of_get_next_available_child(port, NULL); in imx8qxp_pxl2dpi_get_available_ep_from_port()
248 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_get_available_ep_from_port()
249 "failed to get available endpoint of port@%u\n", in imx8qxp_pxl2dpi_get_available_ep_from_port()
251 ep = ERR_PTR(-ENODEV); in imx8qxp_pxl2dpi_get_available_ep_from_port()
255 of_node_put(port); in imx8qxp_pxl2dpi_get_available_ep_from_port()
274 DRM_DEV_ERROR(p2d->dev, "no available remote\n"); in imx8qxp_pxl2dpi_find_next_bridge()
275 next_bridge = ERR_PTR(-ENODEV); in imx8qxp_pxl2dpi_find_next_bridge()
277 } else if (!of_device_is_available(remote->parent)) { in imx8qxp_pxl2dpi_find_next_bridge()
278 DRM_DEV_ERROR(p2d->dev, "remote parent is not available\n"); in imx8qxp_pxl2dpi_find_next_bridge()
279 next_bridge = ERR_PTR(-ENODEV); in imx8qxp_pxl2dpi_find_next_bridge()
285 next_bridge = ERR_PTR(-EPROBE_DEFER); in imx8qxp_pxl2dpi_find_next_bridge()
307 DRM_DEV_ERROR(p2d->dev, in imx8qxp_pxl2dpi_set_pixel_link_sel()
308 "failed to parse endpoint of port@0: %d\n", ret); in imx8qxp_pxl2dpi_set_pixel_link_sel()
312 p2d->pl_sel = endpoint.id; in imx8qxp_pxl2dpi_set_pixel_link_sel()
322 struct device *dev = p2d->dev; in imx8qxp_pxl2dpi_parse_dt_companion()
329 /* Locate the companion PXL2DPI for dual-link operation, if any. */ in imx8qxp_pxl2dpi_parse_dt_companion()
330 companion = of_parse_phandle(dev->of_node, "fsl,companion-pxl2dpi", 0); in imx8qxp_pxl2dpi_parse_dt_companion()
336 ret = -ENODEV; in imx8qxp_pxl2dpi_parse_dt_companion()
344 match = of_match_device(dev->driver->of_match_table, dev); in imx8qxp_pxl2dpi_parse_dt_companion()
345 if (!of_device_is_compatible(companion, match->compatible)) { in imx8qxp_pxl2dpi_parse_dt_companion()
347 ret = -ENXIO; in imx8qxp_pxl2dpi_parse_dt_companion()
351 p2d->companion = of_drm_find_bridge(companion); in imx8qxp_pxl2dpi_parse_dt_companion()
352 if (!p2d->companion) { in imx8qxp_pxl2dpi_parse_dt_companion()
353 ret = -EPROBE_DEFER; in imx8qxp_pxl2dpi_parse_dt_companion()
354 DRM_DEV_DEBUG_DRIVER(p2d->dev, in imx8qxp_pxl2dpi_parse_dt_companion()
360 companion_p2d = bridge_to_p2d(p2d->companion); in imx8qxp_pxl2dpi_parse_dt_companion()
364 * dual-link mode. We do this by looking at the DT port nodes that in imx8qxp_pxl2dpi_parse_dt_companion()
368 port1 = of_graph_get_port_by_id(p2d->next_bridge->of_node, 1); in imx8qxp_pxl2dpi_parse_dt_companion()
369 port2 = of_graph_get_port_by_id(companion_p2d->next_bridge->of_node, 1); in imx8qxp_pxl2dpi_parse_dt_companion()
376 DRM_DEV_ERROR(dev, "failed to get dual link pixel order: %d\n", in imx8qxp_pxl2dpi_parse_dt_companion()
382 "dual-link configuration detected (companion bridge %pOF)\n", in imx8qxp_pxl2dpi_parse_dt_companion()
392 struct device *dev = &pdev->dev; in imx8qxp_pxl2dpi_bridge_probe()
393 struct device_node *np = dev->of_node; in imx8qxp_pxl2dpi_bridge_probe()
398 return -ENOMEM; in imx8qxp_pxl2dpi_bridge_probe()
400 p2d->regmap = syscon_node_to_regmap(np->parent); in imx8qxp_pxl2dpi_bridge_probe()
401 if (IS_ERR(p2d->regmap)) { in imx8qxp_pxl2dpi_bridge_probe()
402 ret = PTR_ERR(p2d->regmap); in imx8qxp_pxl2dpi_bridge_probe()
403 if (ret != -EPROBE_DEFER) in imx8qxp_pxl2dpi_bridge_probe()
408 ret = imx_scu_get_handle(&p2d->ipc_handle); in imx8qxp_pxl2dpi_bridge_probe()
410 if (ret != -EPROBE_DEFER) in imx8qxp_pxl2dpi_bridge_probe()
416 p2d->dev = dev; in imx8qxp_pxl2dpi_bridge_probe()
418 ret = of_property_read_u32(np, "fsl,sc-resource", &p2d->sc_resource); in imx8qxp_pxl2dpi_bridge_probe()
424 p2d->next_bridge = imx8qxp_pxl2dpi_find_next_bridge(p2d); in imx8qxp_pxl2dpi_bridge_probe()
425 if (IS_ERR(p2d->next_bridge)) { in imx8qxp_pxl2dpi_bridge_probe()
426 ret = PTR_ERR(p2d->next_bridge); in imx8qxp_pxl2dpi_bridge_probe()
427 if (ret != -EPROBE_DEFER) in imx8qxp_pxl2dpi_bridge_probe()
444 p2d->bridge.driver_private = p2d; in imx8qxp_pxl2dpi_bridge_probe()
445 p2d->bridge.funcs = &imx8qxp_pxl2dpi_bridge_funcs; in imx8qxp_pxl2dpi_bridge_probe()
446 p2d->bridge.of_node = np; in imx8qxp_pxl2dpi_bridge_probe()
448 drm_bridge_add(&p2d->bridge); in imx8qxp_pxl2dpi_bridge_probe()
457 drm_bridge_remove(&p2d->bridge); in imx8qxp_pxl2dpi_bridge_remove()
459 pm_runtime_disable(&pdev->dev); in imx8qxp_pxl2dpi_bridge_remove()
463 { .compatible = "fsl,imx8qxp-pxl2dpi", },