Skip to content

Commit 1904c3f

Browse files
quic-bjorandevinodkoul
authored andcommitted
phy: qcom-qmp-combo: Introduce drm_bridge
The QMP combo PHY sits in an of_graph connected between the DisplayPort controller and a USB Type-C connector (or possibly a redriver). The TCPM needs to be able to convey the HPD signal to the DisplayPort controller, but no directly link is provided by DeviceTree so the signal needs to "pass through" the QMP combo phy. Handle this by introducing a drm_bridge which upon initialization finds the next bridge (i.e. the usb-c-connector) and chain this together. This way HPD changes in the connector will propagate to the DisplayPort driver. The connector bridge is resolved lazily, as the TCPM is expected to be able to resolve the typec mux and switch at probe time, so the QMP combo phy will probe before the TCPM. Acked-by: Neil Armstrong <neil.armstrong@linaro.org> Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Tested-by: Abel Vesa <abel.vesa@linaro.org> Tested-by: Steev Klimaszewski <steev@kali.org> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on HDK8450 Tested-by: Johan Hovold <johan+linaro@kernel.org> # X13s Reviewed-by: Johan Hovold <johan+linaro@kernel.org> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> Link: https://lore.kernel.org/r/20230515032743.400170-7-quic_bjorande@quicinc.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 2851117 commit 1904c3f

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

drivers/phy/qualcomm/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ config PHY_QCOM_QMP_COMBO
6060
tristate "Qualcomm QMP Combo PHY Driver"
6161
default PHY_QCOM_QMP
6262
depends on TYPEC || TYPEC=n
63+
depends on DRM || DRM=n
6364
select GENERIC_PHY
6465
select MFD_SYSCON
66+
select DRM_PANEL_BRIDGE if DRM
6567
help
6668
Enable this to support the QMP Combo PHY transceiver that is used
6769
with USB3 and DisplayPort controllers on Qualcomm chips.

drivers/phy/qualcomm/phy-qcom-qmp-combo.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <linux/usb/typec.h>
2323
#include <linux/usb/typec_mux.h>
2424

25+
#include <drm/drm_bridge.h>
26+
2527
#include <dt-bindings/phy/phy-qcom-qmp.h>
2628

2729
#include "phy-qcom-qmp.h"
@@ -1332,6 +1334,8 @@ struct qmp_combo {
13321334
struct clk_hw dp_link_hw;
13331335
struct clk_hw dp_pixel_hw;
13341336

1337+
struct drm_bridge bridge;
1338+
13351339
struct typec_switch_dev *sw;
13361340
enum typec_orientation orientation;
13371341
};
@@ -3274,6 +3278,44 @@ static int qmp_combo_typec_switch_register(struct qmp_combo *qmp)
32743278
}
32753279
#endif
32763280

3281+
#if IS_ENABLED(CONFIG_DRM)
3282+
static int qmp_combo_bridge_attach(struct drm_bridge *bridge,
3283+
enum drm_bridge_attach_flags flags)
3284+
{
3285+
struct qmp_combo *qmp = container_of(bridge, struct qmp_combo, bridge);
3286+
struct drm_bridge *next_bridge;
3287+
3288+
if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
3289+
return -EINVAL;
3290+
3291+
next_bridge = devm_drm_of_get_bridge(qmp->dev, qmp->dev->of_node, 0, 0);
3292+
if (IS_ERR(next_bridge)) {
3293+
dev_err(qmp->dev, "failed to acquire drm_bridge: %pe\n", next_bridge);
3294+
return PTR_ERR(next_bridge);
3295+
}
3296+
3297+
return drm_bridge_attach(bridge->encoder, next_bridge, bridge,
3298+
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
3299+
}
3300+
3301+
static const struct drm_bridge_funcs qmp_combo_bridge_funcs = {
3302+
.attach = qmp_combo_bridge_attach,
3303+
};
3304+
3305+
static int qmp_combo_dp_register_bridge(struct qmp_combo *qmp)
3306+
{
3307+
qmp->bridge.funcs = &qmp_combo_bridge_funcs;
3308+
qmp->bridge.of_node = qmp->dev->of_node;
3309+
3310+
return devm_drm_bridge_add(qmp->dev, &qmp->bridge);
3311+
}
3312+
#else
3313+
static int qmp_combo_dp_register_bridge(struct qmp_combo *qmp)
3314+
{
3315+
return 0;
3316+
}
3317+
#endif
3318+
32773319
static int qmp_combo_parse_dt_lecacy_dp(struct qmp_combo *qmp, struct device_node *np)
32783320
{
32793321
struct device *dev = qmp->dev;
@@ -3478,6 +3520,10 @@ static int qmp_combo_probe(struct platform_device *pdev)
34783520
if (ret)
34793521
return ret;
34803522

3523+
ret = qmp_combo_dp_register_bridge(qmp);
3524+
if (ret)
3525+
return ret;
3526+
34813527
/* Check for legacy binding with child nodes. */
34823528
usb_np = of_get_child_by_name(dev->of_node, "usb3-phy");
34833529
if (usb_np) {

0 commit comments

Comments
 (0)