[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAE-0n51eQns8ifUzc36FNSSQJ7WFd_8hZ3JnNcFvgrTrvqRhow@mail.gmail.com>
Date: Tue, 29 Apr 2025 14:57:27 -0700
From: Stephen Boyd <swboyd@...omium.org>
To: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
Cc: Tzung-Bi Shih <tzungbi@...nel.org>, linux-kernel@...r.kernel.org,
patches@...ts.linux.dev, Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>, devicetree@...r.kernel.org,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Rob Herring <robh@...nel.org>, linux-arm-msm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, Conor Dooley <conor+dt@...nel.org>,
Benson Leung <bleung@...omium.org>, chrome-platform@...ts.linux.dev,
Pin-yen Lin <treapking@...omium.org>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>, Ćukasz Bartosik <ukaszb@...omium.org>,
Jameson Thies <jthies@...gle.com>, Andrei Kuchynski <akuchynski@...omium.org>
Subject: Re: [PATCH 6/7] platform/chrome: cros_ec_typec: Add support for DP
altmode via drm_bridge
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.
Powered by blists - more mailing lists