Skip to content

Commit

Permalink
usb: typec: qcom-pmic-typec: register drm_bridge
Browse files Browse the repository at this point in the history
[ Upstream commit 4b3cd78 ]

The current approach to handling DP on bridge-enabled platforms requires
a chain of DP bridges up to the USB-C connector. Register a last DRM
bridge for such chain.

Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230817150824.14371-3-dmitry.baryshkov@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
lumag authored and gregkh committed Sep 23, 2023
1 parent 2f3a124 commit 328d3fa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/usb/typec/tcpm/Kconfig
Expand Up @@ -79,6 +79,7 @@ config TYPEC_WCOVE
config TYPEC_QCOM_PMIC
tristate "Qualcomm PMIC USB Type-C Port Controller Manager driver"
depends on ARCH_QCOM || COMPILE_TEST
depends on DRM || DRM=n
help
A Type-C port and Power Delivery driver which aggregates two
discrete pieces of silicon in the PM8150b PMIC block: the
Expand Down
37 changes: 37 additions & 0 deletions drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
Expand Up @@ -17,6 +17,9 @@
#include <linux/usb/role.h>
#include <linux/usb/tcpm.h>
#include <linux/usb/typec_mux.h>

#include <drm/drm_bridge.h>

#include "qcom_pmic_typec_pdphy.h"
#include "qcom_pmic_typec_port.h"

Expand All @@ -33,6 +36,7 @@ struct pmic_typec {
struct pmic_typec_port *pmic_typec_port;
bool vbus_enabled;
struct mutex lock; /* VBUS state serialization */
struct drm_bridge bridge;
};

#define tcpc_to_tcpm(_tcpc_) container_of(_tcpc_, struct pmic_typec, tcpc)
Expand Down Expand Up @@ -146,6 +150,35 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc)
return 0;
}

#if IS_ENABLED(CONFIG_DRM)
static int qcom_pmic_typec_attach(struct drm_bridge *bridge,
enum drm_bridge_attach_flags flags)
{
return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL;
}

static const struct drm_bridge_funcs qcom_pmic_typec_bridge_funcs = {
.attach = qcom_pmic_typec_attach,
};

static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm)
{
tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs;
#ifdef CONFIG_OF
tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector");
#endif
tcpm->bridge.ops = DRM_BRIDGE_OP_HPD;
tcpm->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;

return devm_drm_bridge_add(tcpm->dev, &tcpm->bridge);
}
#else
static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm)
{
return 0;
}
#endif

static int qcom_pmic_typec_probe(struct platform_device *pdev)
{
struct pmic_typec *tcpm;
Expand Down Expand Up @@ -208,6 +241,10 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
mutex_init(&tcpm->lock);
platform_set_drvdata(pdev, tcpm);

ret = qcom_pmic_typec_init_drm(tcpm);
if (ret)
return ret;

tcpm->tcpc.fwnode = device_get_named_child_node(tcpm->dev, "connector");
if (!tcpm->tcpc.fwnode)
return -EINVAL;
Expand Down

0 comments on commit 328d3fa

Please sign in to comment.