From: Stephen Boyd <swboyd@chromium.org>
To: chrome-platform@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Douglas Anderson <dianders@chromium.org>,
Pin-yen Lin <treapking@chromium.org>,
Prashant Malani <pmalani@chromium.org>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>
Subject: [PATCH 17/22] platform/chrome: cros_typec_switch: Handle lack of HPD information
Date: Fri, 9 Feb 2024 23:09:28 -0800 [thread overview]
Message-ID: <20240210070934.2549994-18-swboyd@chromium.org> (raw)
In-Reply-To: <20240210070934.2549994-1-swboyd@chromium.org>
Some EC firmwares on Trogdor/Strongbad boards don't properly indicate
the state of DP HPD on a type-c port. Instead, the EC only indicates
that DP mode is entered or exited for a type-c port. To make matters
worse, on these firmwares the DP signal is muxed between two USB type-c
connectors, so we can't use the HPD state to figure out which type-c
port is actually displaying DP.
Read the state of the EC's analog mux from the hpd notification callback
to figure out which type-c port is displaying DP. This circumvents the
entire host command/message interface, because it doesn't work all the
time. Only do this when we have the mux-gpios property in DT, indicating
that we have to read the EC gpio state to figure this out. For now we
only support a single gpio "bit", so there can only be two USB type-c
ports.
Cc: Prashant Malani <pmalani@chromium.org>
Cc: Benson Leung <bleung@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: <chrome-platform@lists.linux.dev>
Cc: Pin-yen Lin <treapking@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
drivers/platform/chrome/cros_typec_switch.c | 33 ++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index c22c2531327a..edd628eab7da 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -8,6 +8,7 @@
#include <linux/acpi.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -26,6 +27,7 @@
struct cros_typec_dp_bridge {
/* TODO: Add mutex lock to protect active_port with respect to drm/typec framework calls */
struct cros_typec_port *active_port;
+ struct gpio_desc *mux_gpio;
struct cros_typec_switch_data *sdata;
size_t max_lanes;
bool hpd_enabled;
@@ -453,6 +455,29 @@ static void cros_typec_dp_bridge_hpd_disable(struct drm_bridge *bridge)
typec_dp_bridge->hpd_enabled = false;
}
+static void cros_typec_dp_bridge_hpd_notify(struct drm_bridge *bridge,
+ enum drm_connector_status status)
+{
+ struct cros_typec_dp_bridge *typec_dp_bridge;
+ struct cros_typec_switch_data *sdata;
+ struct gpio_desc *mux_gpio;
+ int mux_val;
+
+ typec_dp_bridge = bridge_to_cros_typec_dp_bridge(bridge);
+ mux_gpio = typec_dp_bridge->mux_gpio;
+
+ /*
+ * Some ECs don't notify AP when HPD goes high or low so we have to
+ * read the EC GPIO that controls the mux to figure out which type-c
+ * port is connected to DP.
+ */
+ if (mux_gpio) {
+ sdata = typec_dp_bridge->sdata;
+ mux_val = gpiod_get_value_cansleep(mux_gpio);
+ typec_dp_bridge->active_port = sdata->ports[mux_val];
+ }
+}
+
static const struct drm_bridge_funcs cros_typec_dp_bridge_funcs = {
.attach = cros_typec_dp_bridge_attach,
.atomic_check = cros_typec_dp_bridge_atomic_check,
@@ -461,6 +486,7 @@ static const struct drm_bridge_funcs cros_typec_dp_bridge_funcs = {
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
.hpd_enable = cros_typec_dp_bridge_hpd_enable,
.hpd_disable = cros_typec_dp_bridge_hpd_disable,
+ .hpd_notify = cros_typec_dp_bridge_hpd_notify,
};
static int cros_typec_register_dp_bridge(struct cros_typec_switch_data *sdata,
@@ -478,6 +504,10 @@ static int cros_typec_register_dp_bridge(struct cros_typec_switch_data *sdata,
typec_dp_bridge->sdata = sdata;
sdata->typec_dp_bridge = typec_dp_bridge;
+ typec_dp_bridge->mux_gpio = devm_gpiod_get_optional(dev, "mux", 0);
+ if (IS_ERR(typec_dp_bridge->mux_gpio))
+ return PTR_ERR(typec_dp_bridge->mux_gpio);
+
num_lanes = fwnode_property_count_u32(fwnode, "data-lanes");
if (num_lanes < 0)
num_lanes = 4;
@@ -488,7 +518,8 @@ static int cros_typec_register_dp_bridge(struct cros_typec_switch_data *sdata,
bridge->funcs = &cros_typec_dp_bridge_funcs;
bridge->of_node = dev->of_node;
bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
- bridge->ops |= DRM_BRIDGE_OP_HPD;
+ if (!fwnode_property_present(dev_fwnode(dev), "no-hpd"))
+ bridge->ops |= DRM_BRIDGE_OP_HPD;
return devm_drm_bridge_add(dev, bridge);
}
--
https://chromeos.dev
next prev parent reply other threads:[~2024-02-10 7:10 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-10 7:09 [PATCH 00/22] platform/chrome: Add DT USB/DP muxing/topology to Trogdor Stephen Boyd
2024-02-10 7:09 ` [PATCH 01/22] dt-bindings: gpio: Add binding for ChromeOS EC GPIO controller Stephen Boyd
2024-02-11 13:26 ` Krzysztof Kozlowski
2024-02-15 0:44 ` Stephen Boyd
2024-02-15 14:06 ` Rob Herring
2024-02-15 22:00 ` Stephen Boyd
2024-02-10 7:09 ` [PATCH 02/22] gpio: Add ChromeOS EC GPIO driver Stephen Boyd
2024-02-13 17:57 ` Linus Walleij
2024-02-10 7:09 ` [PATCH 03/22] dt-bindings: usb: Add downstream facing ports to realtek binding Stephen Boyd
2024-02-10 11:29 ` Rob Herring
2024-02-10 7:09 ` [PATCH 04/22] usb: core: Set connect_type of ports based on DT node Stephen Boyd
2024-02-14 0:03 ` Doug Anderson
2024-02-14 23:51 ` Stephen Boyd
2024-02-10 7:09 ` [PATCH 05/22] drm/atomic-helper: Introduce lane remapping support to bridges Stephen Boyd
2024-02-10 7:09 ` [PATCH 06/22] drm/bridge: Verify lane assignment is going to work during atomic_check Stephen Boyd
2024-02-10 7:09 ` [PATCH 07/22] device property: Add remote endpoint to devcon matcher Stephen Boyd
2024-02-10 7:09 ` [PATCH 08/22] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Stephen Boyd
2024-02-10 7:09 ` [PATCH 09/22] platform/chrome: cros_typec_switch: Use read_poll_timeout helper Stephen Boyd
2024-02-10 7:09 ` [PATCH 10/22] platform/chrome: cros_typec_switch: Move port creation code to sub-function Stephen Boyd
2024-02-10 7:09 ` [PATCH 11/22] platform/chrome: cros_typec_switch: Use fwnode instead of ACPI APIs Stephen Boyd
2024-02-10 7:09 ` [PATCH 12/22] platform/chrome: cros_typec_switch: Use dev_err_probe() Stephen Boyd
2024-02-10 7:09 ` [PATCH 13/22] dt-bindings: chrome: Add google,cros-ec-typec-switch binding Stephen Boyd
2024-02-11 13:34 ` Krzysztof Kozlowski
2024-02-15 1:52 ` Stephen Boyd
2024-02-15 8:34 ` Krzysztof Kozlowski
2024-02-11 13:35 ` Krzysztof Kozlowski
2024-02-10 7:09 ` [PATCH 14/22] platform/chrome: cros_typec_switch: Add support for signaling HPD to drm_bridge Stephen Boyd
2024-02-10 14:10 ` Dmitry Baryshkov
2024-02-11 8:52 ` Stephen Boyd
2024-02-11 9:00 ` Dmitry Baryshkov
2024-02-10 7:09 ` [PATCH 15/22] platform/chrome: cros_typec_switch: Support DP muxing via DRM lane assignment Stephen Boyd
2024-02-10 7:09 ` [PATCH 16/22] platform/chrome: cros_typec_switch: Support orientation-switch Stephen Boyd
2024-02-10 7:09 ` Stephen Boyd [this message]
2024-02-10 7:09 ` [PATCH 18/22] dt-bindings: chrome: Add binding for ChromeOS Pogo pin connector Stephen Boyd
2024-02-11 13:39 ` Krzysztof Kozlowski
2024-02-15 0:07 ` Stephen Boyd
2024-02-15 8:39 ` Krzysztof Kozlowski
2024-02-14 1:17 ` Doug Anderson
2024-02-15 0:10 ` Stephen Boyd
2024-02-10 7:09 ` [PATCH 19/22] arm64: dts: qcom: sc7180: quackingstick: Disable instead of delete usb_c1 Stephen Boyd
2024-02-10 11:51 ` Dmitry Baryshkov
2024-02-13 23:24 ` Doug Anderson
2024-02-10 7:09 ` [PATCH 20/22] arm64: dts: qcom: sc7180: pazquel: Add missing comment header Stephen Boyd
2024-02-10 11:51 ` Dmitry Baryshkov
2024-02-13 23:24 ` Doug Anderson
2024-02-10 7:09 ` [PATCH 21/22] arm64: dts: qcom: sc7180-trogdor: Make clamshell/detachable fragments Stephen Boyd
2024-02-10 11:53 ` Dmitry Baryshkov
2024-02-13 23:34 ` Doug Anderson
2024-02-15 0:35 ` Stephen Boyd
2024-02-15 0:39 ` Doug Anderson
2024-02-10 7:09 ` [PATCH 22/22] arm64: dts: qcom: sc7180-trogdor: Wire up USB and DP to usb-c-connectors Stephen Boyd
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=20240210070934.2549994-18-swboyd@chromium.org \
--to=swboyd@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.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=pmalani@chromium.org \
--cc=treapking@chromium.org \
--cc=tzungbi@kernel.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