[v4,2/2] usb: typec: qcom-pmic-typec: register drm_bridge
Commit Message
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>
---
drivers/usb/typec/tcpm/Kconfig | 1 +
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 35 +++++++++++++++++++
2 files changed, 36 insertions(+)
Comments
On 7/28/23 04:09, Dmitry Baryshkov wrote:
> 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>
> ---
> drivers/usb/typec/tcpm/Kconfig | 1 +
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 35 +++++++++++++++++++
> 2 files changed, 36 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig
> index 5d393f520fc2..0b2993fef564 100644
> --- a/drivers/usb/typec/tcpm/Kconfig
> +++ b/drivers/usb/typec/tcpm/Kconfig
> @@ -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
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> index af44ee4e6e86..0ea7cc656089 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> @@ -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"
>
> @@ -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)
> @@ -146,6 +150,33 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc)
> return 0;
> }
>
> +#ifdef CONFIG_DRM
Sorry for not noticing earlier. This needs to be "#if IS_ENABLED(CONFIG_DRM)"
or otherwise would not catch DRM=m situations.
> +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;
> + tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector");
> + 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;
> @@ -208,6 +239,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;
Hi Dmitry,
kernel test robot noticed the following build errors:
[auto build test ERROR on usb/usb-linus]
[also build test ERROR on linus/master v6.5-rc5 next-20230808]
[cannot apply to usb/usb-testing usb/usb-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/usb-typec-altmodes-displayport-add-support-for-embedded-DP-cases/20230728-191207
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus
patch link: https://lore.kernel.org/r/20230728110942.485358-3-dmitry.baryshkov%40linaro.org
patch subject: [PATCH v4 2/2] usb: typec: qcom-pmic-typec: register drm_bridge
config: i386-buildonly-randconfig-r006-20230808 (https://download.01.org/0day-ci/archive/20230808/202308081918.CVuUdaXs-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081918.CVuUdaXs-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308081918.CVuUdaXs-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c:167:15: error: no member named 'of_node' in 'struct drm_bridge'
tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector");
~~~~~~~~~~~~ ^
1 error generated.
vim +167 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
163
164 static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm)
165 {
166 tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs;
> 167 tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector");
168 tcpm->bridge.ops = DRM_BRIDGE_OP_HPD;
169 tcpm->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
170
171 return devm_drm_bridge_add(tcpm->dev, &tcpm->bridge);
172 }
173 #else
174 static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm)
175 {
176 return 0;
177 }
178 #endif
179
@@ -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
@@ -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"
@@ -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)
@@ -146,6 +150,33 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc)
return 0;
}
+#ifdef 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;
+ tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector");
+ 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;
@@ -208,6 +239,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;