From: Stephen Boyd <swboyd@chromium.org>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: "Tzung-Bi Shih" <tzungbi@kernel.org>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
devicetree@vger.kernel.org,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Rob Herring" <robh@kernel.org>,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Conor Dooley" <conor+dt@kernel.org>,
"Benson Leung" <bleung@chromium.org>,
chrome-platform@lists.linux.dev,
"Pin-yen Lin" <treapking@chromium.org>,
"Abhishek Pandit-Subedi" <abhishekpandit@chromium.org>,
"Łukasz Bartosik" <ukaszb@chromium.org>,
"Jameson Thies" <jthies@google.com>,
"Andrei Kuchynski" <akuchynski@chromium.org>
Subject: Re: [PATCH 6/7] platform/chrome: cros_ec_typec: Add support for DP altmode via drm_bridge
Date: Tue, 29 Apr 2025 14:57:27 -0700 [thread overview]
Message-ID: <CAE-0n51eQns8ifUzc36FNSSQJ7WFd_8hZ3JnNcFvgrTrvqRhow@mail.gmail.com> (raw)
In-Reply-To: <npnpujjfonvzhf5c4upgajhx6hu5uqmerewmbqprvl7a3xrqgm@datubwgyucby>
Quoting Dmitry Baryshkov (2025-04-24 03:51:17)
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> > index 2cbe29f08064..27324cf0c0c6 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -337,6 +340,9 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> > u32 port_num = 0;
> >
> > nports = device_get_child_node_count(dev);
> > + /* Don't count any 'ports' child node */
> > + if (of_graph_is_present(dev->of_node))
> > + nports--;
>
> Should this be a separate commit?
>
> > if (nports == 0) {
> > dev_err(dev, "No port entries found.\n");
> > return -ENODEV;
> > @@ -350,6 +356,10 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> > /* DT uses "reg" to specify port number. */
> > port_prop = dev->of_node ? "reg" : "port-number";
> > device_for_each_child_node(dev, fwnode) {
> > + /* An OF graph isn't a connector */
> > + if (fwnode_name_eq(fwnode, "ports"))
> > + continue;
> > +
>
> ... together with this chunk.
I check for the of_graph being present below. It's all sorta related.
>
> > if (fwnode_property_read_u32(fwnode, port_prop, &port_num)) {
> > ret = -EINVAL;
> > dev_err(dev, "No port-number for port, aborting.\n");
> > @@ -417,6 +427,42 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> > return ret;
> > }
> >
> > +static int cros_typec_dp_bridge_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 cros_typec_dp_bridge_funcs = {
> > + .attach = cros_typec_dp_bridge_attach,
> > +};
> > +
> > +static int cros_typec_init_dp_bridge(struct cros_typec_data *typec)
> > +{
> > + struct device *dev = typec->dev;
> > + struct cros_typec_dp_bridge *dp_bridge;
> > + struct drm_bridge *bridge;
> > + struct device_node *np = dev->of_node;
> > +
> > + /* Not capable of DP altmode switching. Ignore. */
> > + if (!of_graph_is_present(np))
> > + return 0;
> > +
> > + dp_bridge = devm_kzalloc(dev, sizeof(*dp_bridge), GFP_KERNEL);
> > + if (!dp_bridge)
> > + return -ENOMEM;
> > + typec->dp_bridge = dp_bridge;
> > +
> > + bridge = &dp_bridge->bridge;
> > + bridge->funcs = &cros_typec_dp_bridge_funcs;
> > + bridge->of_node = np;
> > + bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
> > + if (!device_property_read_bool(dev, "no-hpd"))
> > + bridge->ops |= DRM_BRIDGE_OP_HPD;
> > +
> > + return devm_drm_bridge_add(dev, bridge);
>
> Could you please use aux-hpd-bridge instead?
I can extend that to call some function when hpd changes. If I make a
device node for the mux and the TCPCs then it may be possible to push
everything into aux-hpd-bridge and use it for all three of them.
>
> BTW: what is the usecase for the no-hpd handling here?
>
Looks like you figured it out. I want to capture the HPD state so I can
then go read the EC mux to figure out which way the mux is pointing. On
trogdor the EC doesn't tell us which typec port has HPD asserted so we
snoop the HPD state from the drm_bridge, read the mux when HPD changes,
and pick the right typec port while also injecting HPD into the state of
the port. The no-hpd property is used on Trogdor to indicate that the
bridge in the EC doesn't signal HPD properly, ensuring the previous
bridge handles the HPD detection.
next prev parent reply other threads:[~2025-04-29 21:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 0:02 [PATCH 0/7] platform/chrome: Support for USB DP altmode muxing w/ DT Stephen Boyd
2025-04-16 0:02 ` [PATCH 1/7] platform/chrome: cros_ec_typec: No pending status means attention Stephen Boyd
2025-04-22 13:38 ` Dmitry Baryshkov
2025-04-28 23:55 ` Stephen Boyd
2025-04-29 6:46 ` Dmitry Baryshkov
2025-04-16 0:02 ` [PATCH 2/7] platform/chrome: cros_ec_typec: Allow DP configure to work Stephen Boyd
2025-04-22 13:37 ` Dmitry Baryshkov
2025-04-29 6:46 ` Dmitry Baryshkov
2025-04-16 0:02 ` [PATCH 3/7] platform/chrome: cros_ec_typec: Support EC mode entry Stephen Boyd
2025-04-16 0:02 ` [PATCH 4/7] dt-bindings: Move google,cros-ec-typec binding to usb Stephen Boyd
2025-04-16 6:44 ` Lee Jones
2025-04-16 0:02 ` [PATCH 5/7] dt-bindings: usb: google,cros-ec-typec: Add ports for DP altmode Stephen Boyd
2025-04-22 12:18 ` Rob Herring
2025-04-29 5:01 ` Stephen Boyd
2025-04-24 11:10 ` Dmitry Baryshkov
2025-04-16 0:02 ` [PATCH 6/7] platform/chrome: cros_ec_typec: Add support for DP altmode via drm_bridge Stephen Boyd
2025-04-24 10:51 ` Dmitry Baryshkov
2025-04-29 21:57 ` Stephen Boyd [this message]
2025-04-16 0:02 ` [PATCH 7/7] platform/chrome: cros_ec_typec: Support DP muxing Stephen Boyd
2025-04-24 11:03 ` Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAE-0n51eQns8ifUzc36FNSSQJ7WFd_8hZ3JnNcFvgrTrvqRhow@mail.gmail.com \
--to=swboyd@chromium.org \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=andersson@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=jthies@google.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=robh@kernel.org \
--cc=treapking@chromium.org \
--cc=tzungbi@kernel.org \
--cc=ukaszb@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).