* [PATCH 0/2] usb: typec: qcom-pmic-typec: enable DP support @ 2023-07-09 3:48 Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 1/2] usb: typec: altmodes/displayport: add support for embedded DP cases Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge Dmitry Baryshkov 0 siblings, 2 replies; 5+ messages in thread From: Dmitry Baryshkov @ 2023-07-09 3:48 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman, Bryan O'Donoghue, Guenter Roeck, Andy Gross, Bjorn Andersson, Konrad Dybcio Cc: linux-usb, linux-kernel, linux-arm-msm To enable DisplayPort on the platforms supported by qcom-pmic-typec driver, we need to register a corresponding drm_bridge for this device and also be able to send the OOB hotplug event to the corresponding DRM connector. All this is implemented by [1], but there is no direct dependency on that patchset. [1] https://patchwork.freedesktop.org/series/120393/ Dmitry Baryshkov (2): usb: typec: altmodes/displayport: add support for embedded DP cases usb: typec: qcom-pmic-typec: register drm_bridge drivers/usb/typec/altmodes/displayport.c | 5 +++- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) -- 2.39.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] usb: typec: altmodes/displayport: add support for embedded DP cases 2023-07-09 3:48 [PATCH 0/2] usb: typec: qcom-pmic-typec: enable DP support Dmitry Baryshkov @ 2023-07-09 3:48 ` Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge Dmitry Baryshkov 1 sibling, 0 replies; 5+ messages in thread From: Dmitry Baryshkov @ 2023-07-09 3:48 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman, Bryan O'Donoghue, Guenter Roeck, Andy Gross, Bjorn Andersson, Konrad Dybcio Cc: linux-usb, linux-kernel, linux-arm-msm In the embedded cases, the DisplayPort connector is handled by the TCPM itself. Fallback to the controller fwnode for HPD notifications to support such usecases without requiring additional DT properties. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/usb/typec/altmodes/displayport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index 4e5aa17ce4c8..699438c7755e 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -578,7 +578,10 @@ int dp_altmode_probe(struct typec_altmode *alt) alt->ops = &dp_altmode_ops; fwnode = dev_fwnode(alt->dev.parent->parent); /* typec_port fwnode */ - dp->connector_fwnode = fwnode_find_reference(fwnode, "displayport", 0); + if (fwnode_property_present(fwnode, "displayport")) + dp->connector_fwnode = fwnode_find_reference(fwnode, "displayport", 0); + else + dp->connector_fwnode = fwnode_handle_get(fwnode); /* embedded DP */ if (IS_ERR(dp->connector_fwnode)) dp->connector_fwnode = NULL; -- 2.39.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge 2023-07-09 3:48 [PATCH 0/2] usb: typec: qcom-pmic-typec: enable DP support Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 1/2] usb: typec: altmodes/displayport: add support for embedded DP cases Dmitry Baryshkov @ 2023-07-09 3:48 ` Dmitry Baryshkov 2023-07-09 11:25 ` Bryan O'Donoghue 1 sibling, 1 reply; 5+ messages in thread From: Dmitry Baryshkov @ 2023-07-09 3:48 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman, Bryan O'Donoghue, Guenter Roeck, Andy Gross, Bjorn Andersson, Konrad Dybcio Cc: linux-usb, linux-kernel, linux-arm-msm 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. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c index a905160dd860..ca832a28176e 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,16 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc) return 0; } +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_probe(struct platform_device *pdev) { struct pmic_typec *tcpm; @@ -208,6 +222,17 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) mutex_init(&tcpm->lock); platform_set_drvdata(pdev, tcpm); + tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs; +#if CONFIG_OF + tcpm->bridge.of_node = of_get_child_by_name(dev->of_node, "connector"); +#endif + tcpm->bridge.ops = DRM_BRIDGE_OP_HPD; + tcpm->bridge.type = DRM_MODE_CONNECTOR_USB; + + ret = devm_drm_bridge_add(dev, &tcpm->bridge); + if (ret) + return ret; + tcpm->tcpc.fwnode = device_get_named_child_node(tcpm->dev, "connector"); if (IS_ERR(tcpm->tcpc.fwnode)) return PTR_ERR(tcpm->tcpc.fwnode); -- 2.39.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge 2023-07-09 3:48 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge Dmitry Baryshkov @ 2023-07-09 11:25 ` Bryan O'Donoghue 2023-07-09 20:11 ` Dmitry Baryshkov 0 siblings, 1 reply; 5+ messages in thread From: Bryan O'Donoghue @ 2023-07-09 11:25 UTC (permalink / raw) To: Dmitry Baryshkov, Heikki Krogerus, Greg Kroah-Hartman, Guenter Roeck, Andy Gross, Bjorn Andersson, Konrad Dybcio Cc: linux-usb, linux-kernel, linux-arm-msm On 09/07/2023 04:48, 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. > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 25 +++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > index a905160dd860..ca832a28176e 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,16 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc) > return 0; > } > > +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; > +} Should that be -ENODEV instead ? > + > +static const struct drm_bridge_funcs qcom_pmic_typec_bridge_funcs = { > + .attach = qcom_pmic_typec_attach, > +}; > + > static int qcom_pmic_typec_probe(struct platform_device *pdev) > { > struct pmic_typec *tcpm; > @@ -208,6 +222,17 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) > mutex_init(&tcpm->lock); > platform_set_drvdata(pdev, tcpm); > > + tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs; > +#if CONFIG_OF > + tcpm->bridge.of_node = of_get_child_by_name(dev->of_node, "connector"); > +#endif > + tcpm->bridge.ops = DRM_BRIDGE_OP_HPD; > + tcpm->bridge.type = DRM_MODE_CONNECTOR_USB; > + > + ret = devm_drm_bridge_add(dev, &tcpm->bridge); I think you need to either Kconfig + depends on DRM or #if CONFIG_DRM https://www.spinics.net/lists/kernel/msg4773470.html Kconfig for preference --- bod ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge 2023-07-09 11:25 ` Bryan O'Donoghue @ 2023-07-09 20:11 ` Dmitry Baryshkov 0 siblings, 0 replies; 5+ messages in thread From: Dmitry Baryshkov @ 2023-07-09 20:11 UTC (permalink / raw) To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman, Guenter Roeck, Andy Gross, Bjorn Andersson, Konrad Dybcio Cc: linux-usb, linux-kernel, linux-arm-msm On 09/07/2023 14:25, Bryan O'Donoghue wrote: > On 09/07/2023 04:48, 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. >> >> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >> --- >> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 25 +++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c >> b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c >> index a905160dd860..ca832a28176e 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,16 @@ static int qcom_pmic_typec_init(struct tcpc_dev >> *tcpc) >> return 0; >> } >> +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; >> +} > > Should that be -ENODEV instead ? No. This bridge doesn't implement older bridge API, where the bridge had to create drm_connector itself. This implementation requires DRM_BRIDGE_ATTACH_NO_CONNECTOR and it is invalid to call it without this flag. Other bridges which have been converted to DRM_BRIDGE_ATTACH_NO_CONNECTOR implement the same semantics. > >> + >> +static const struct drm_bridge_funcs qcom_pmic_typec_bridge_funcs = { >> + .attach = qcom_pmic_typec_attach, >> +}; >> + >> static int qcom_pmic_typec_probe(struct platform_device *pdev) >> { >> struct pmic_typec *tcpm; >> @@ -208,6 +222,17 @@ static int qcom_pmic_typec_probe(struct >> platform_device *pdev) >> mutex_init(&tcpm->lock); >> platform_set_drvdata(pdev, tcpm); >> + tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs; >> +#if CONFIG_OF >> + tcpm->bridge.of_node = of_get_child_by_name(dev->of_node, >> "connector"); >> +#endif >> + tcpm->bridge.ops = DRM_BRIDGE_OP_HPD; >> + tcpm->bridge.type = DRM_MODE_CONNECTOR_USB; >> + >> + ret = devm_drm_bridge_add(dev, &tcpm->bridge); > > I think you need to either > > Kconfig + depends on DRM > > or > > #if CONFIG_DRM I guess I'm too used to always having DRM. This will need both Kconfig and source code parts. Will fix it in v2. > > https://www.spinics.net/lists/kernel/msg4773470.html > > Kconfig for preference > > --- > bod -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-09 20:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-07-09 3:48 [PATCH 0/2] usb: typec: qcom-pmic-typec: enable DP support Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 1/2] usb: typec: altmodes/displayport: add support for embedded DP cases Dmitry Baryshkov 2023-07-09 3:48 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: register drm_bridge Dmitry Baryshkov 2023-07-09 11:25 ` Bryan O'Donoghue 2023-07-09 20:11 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®