From: Leonardo Costa <[email protected]> Some simple bridges, such as a resistor ladder DAC, may include a data-enable input that must be driven at a specific polarity.
Read the data-enable-active property from the input endpoint and fill the bridge's input bus flags accordingly, so the upstream encoder drives DE with the required polarity. The property is applied only if the bridge doesn't provide its own timings struct. Signed-off-by: Leonardo Costa <[email protected]> --- drivers/gpu/drm/bridge/simple-bridge.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 848c2df2a276..c5301295658a 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -183,6 +183,9 @@ static int simple_bridge_probe(struct platform_device *pdev) { struct simple_bridge *sbridge; struct device_node *remote; + struct device_node *ep; + bool de_present; + u32 de; sbridge = devm_drm_bridge_alloc(&pdev->dev, struct simple_bridge, bridge, &simple_bridge_bridge_funcs); @@ -220,10 +223,26 @@ static int simple_bridge_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(sbridge->enable), "Unable to retrieve enable GPIO\n"); - /* Register the bridge. */ sbridge->bridge.of_node = pdev->dev.of_node; sbridge->bridge.timings = sbridge->info->timings; + ep = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1); + de_present = !of_property_read_u32(ep, "data-enable-active", &de); + of_node_put(ep); + + if (de_present && !sbridge->bridge.timings) { + struct drm_bridge_timings *timings; + + timings = devm_kzalloc(&pdev->dev, sizeof(*timings), GFP_KERNEL); + if (!timings) + return -ENOMEM; + + timings->input_bus_flags = de ? DRM_BUS_FLAG_DE_HIGH : + DRM_BUS_FLAG_DE_LOW; + sbridge->bridge.timings = timings; + } + + /* Register the bridge. */ return devm_drm_bridge_add(&pdev->dev, &sbridge->bridge); } -- 2.43.0
