From patchwork Sun Sep 1 04:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 13786296 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8271F13A40F for ; Sun, 1 Sep 2024 04:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163644; cv=none; b=BHvxaJmH2AMU+h1LVHlvUZT9slmKKKPIYtxnTjurFOSB1xIJJOlE2Y2RH4EhFRGAbS0yePjvnFKCxBo9UxUGEmtMRMM7LgkhDFs9uQ0bx82a0hNyCFBbh3KEjbur2l5HoyDMCVFJyJL1QgWBCpdOKXleHWKCMLUlhhH+VIXnitE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163644; c=relaxed/simple; bh=gQLHbxZ7YqvGpXB1p1t8XiyRzrvBZDrPBVB81RgQmGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wc9pSC7MIFGvWf+3f8Hrln6E2uAq3EqZmwoJaeCfsRDodbTdYXZ+7iS4m/v5yb6RlmAMOw4W9efx9nJ9YAZZR5Rxdzo11zlmkpgCmSEoX9E4HgSAbYAhTdlCvkYmcAAJJ37VMyPJTLWq8aj1psw0NXs5p42TtA1OgSIqTKri4KQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Q7toou88; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Q7toou88" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2d5f5d8cc01so2162693a91.0 for ; Sat, 31 Aug 2024 21:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163641; x=1725768441; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7B0A+gjnynDK46J7Z91Ni0fcqv7iZd2DyUsBegaNPWE=; b=Q7toou88kyTarX4lg/8lfRdNZwX9UBrwq0COySO1CxYgltlW7BwHDM4kyqOCHlEMBb L8N6QPcrOsEUPDrWbXT/KCxUv8WOfJtti4yOiCm1/uUIsP95QhAUfo3LGQUB5Y7a/E/a 3NETWpY8Ava1fU4eh9cbZOPdcVEAg/Syqfnks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163641; x=1725768441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7B0A+gjnynDK46J7Z91Ni0fcqv7iZd2DyUsBegaNPWE=; b=Akozv8QKCQ5ecwA6S/kjH6qtDRWrelK8wxWF31O0OKbJdm1n9biWbDxb0ZI6CCNDnw r0OdESnAtVeovGU2K6pUjRW2yW334eWBlVeYNOEHmfQQHXiWTqQV33iQsBBVZLnW1iwg VFFK7xXV/63GwznD44StBc88kDSdpYL3/YhjvQtPHu1BD8/PhkWDG4VqleKx1XO7h5Pz CCOkdeTtXSMOi327uNNPyhdUq3i8XJKHTlEoNpAuDwbksFB7ZGAO25E+7N8B8MlHTsYX /aasNP91dt3WjKxDQNv42i2Ggnk9lWShH2tIh1PHmAbyKSsQ256xcT1En6y458llGEYD doyA== X-Gm-Message-State: AOJu0Yxsnyaiv8GjDEKBPhL4deFT0ApS+v7qbi/k8BjUdsyYH/4DoAHW 1J/LCaip2UZ4xx0YnAw78wiprHYbbkAyZ659kGUBGVB10L1L155I//RhOLe+YVN5q5OPPcP0OT8 = X-Google-Smtp-Source: AGHT+IGSmH/wnxTJNBBOPKMZLyVY9PSbNYj6DYaZsk5ViTxQvzorla6wmYK6YTGx9bSlm2MFyUGXzg== X-Received: by 2002:a17:90a:d310:b0:2cf:f860:f13b with SMTP id 98e67ed59e1d1-2d86b04e9eemr10621245a91.17.1725163641373; Sat, 31 Aug 2024 21:07:21 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d844611384sm8985683a91.27.2024.08.31.21.07.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:21 -0700 (PDT) From: Stephen Boyd To: chrome-platform@lists.linux.dev Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Andrzej Hajda , Benson Leung , Conor Dooley , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, Guenter Roeck , Jernej Skrabec , Jonas Karlman , Krzysztof Kozlowski , Laurent Pinchart , Lee Jones , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Prashant Malani , Robert Foss , Rob Herring , Thomas Zimmermann , Tzung-Bi Shih , Alexandre Belloni , Andy Shevchenko , Daniel Scally , Greg Kroah-Hartman , Heikki Krogerus , Ivan Orlov , linux-acpi@vger.kernel.org, linux-usb@vger.kernel.org, Mika Westerberg , "Rafael J . Wysocki" , Sakari Ailus , Vinod Koul Subject: [PATCH v4 09/18] drm/bridge: dp_typec: Allow users to hook hpd notify path Date: Sat, 31 Aug 2024 21:06:47 -0700 Message-ID: <20240901040658.157425-10-swboyd@chromium.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240901040658.157425-1-swboyd@chromium.org> References: <20240901040658.157425-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The previous patch added support for no-hpd to drm_dp_typec_bridge code. Allow users of this bridge to hook the HPD notification path of the bridge chain so that they can be made aware of the connector status changing. This helps HPD-less users of the bridge inject the HPD state into their code by using the connector status as a proxy for HPD being asserted or deasserted. In particular, this will help Trogdor/Strongbad boards that need to read the EC's analog mux which steers the DP signal to one or the other USB type-c ports to figure out which type-c port has HPD asserted. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Dmitry Baryshkov Signed-off-by: Stephen Boyd --- drivers/gpu/drm/bridge/aux-hpd-bridge.c | 31 +++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 9 +++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index 52db36aa190b..8ff8716b2630 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -93,6 +93,8 @@ struct drm_dp_typec_bridge_dev { struct auxiliary_device adev; size_t max_lanes; size_t num_typec_ports; + void (*hpd_notify)(void *data, enum drm_connector_status status); + void *hpd_data; }; static inline struct drm_dp_typec_bridge_dev * @@ -324,6 +326,21 @@ devm_drm_dp_typec_bridge_alloc(struct device *parent, struct device_node *np) } EXPORT_SYMBOL_GPL(devm_drm_dp_typec_bridge_alloc); +/** + * drm_dp_typec_bridge_add_hpd_notify: Register a callback called when the + * bridge chain hpd state changes + * @typec_bridge_dev: USB type-c DisplayPort bridge + * @hpd_notify: callback for bridge hot plug detect events + * @hpd_data: data passed to @hpd_notify callback + */ +void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_bridge_dev *typec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data) +{ + typec_bridge_dev->hpd_notify = hpd_notify; + typec_bridge_dev->hpd_data = hpd_data; +} +EXPORT_SYMBOL_GPL(drm_dp_typec_bridge_add_hpd_notify); + /** * devm_drm_dp_typec_bridge_add - register a USB type-c DisplayPort bridge * @dev: struct device to tie registration lifetime to @@ -363,6 +380,19 @@ void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status sta } EXPORT_SYMBOL_GPL(drm_aux_hpd_bridge_notify); +static void drm_dp_typec_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct drm_dp_typec_bridge_data *data; + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + + data = to_drm_dp_typec_bridge_data(bridge); + typec_bridge_dev = to_drm_dp_typec_bridge_dev(data->hpd_bridge.dev); + + if (typec_bridge_dev->hpd_notify) + typec_bridge_dev->hpd_notify(typec_bridge_dev->hpd_data, status); +} + static int drm_aux_hpd_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -520,6 +550,7 @@ static const struct drm_bridge_funcs drm_dp_typec_bridge_funcs = { .atomic_reset = drm_atomic_helper_bridge_reset, .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .hpd_notify = drm_dp_typec_bridge_hpd_notify, }; static int drm_dp_typec_bridge_orientation_set(struct typec_switch_dev *sw, diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridge.h index 73fc8582ec07..300f4a203a9b 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -22,6 +22,8 @@ static inline int drm_aux_bridge_register(struct device *parent) struct drm_dp_typec_bridge_dev; +typedef void (*hpd_notify_fn_t)(void *data, enum drm_connector_status status); + #if IS_ENABLED(CONFIG_DRM_AUX_HPD_BRIDGE) struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, struct device_node *np); int devm_drm_dp_hpd_bridge_add(struct device *dev, struct auxiliary_device *adev); @@ -30,6 +32,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status); struct drm_dp_typec_bridge_dev *devm_drm_dp_typec_bridge_alloc(struct device *parent, struct device_node *np); +void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_bridge_dev *typec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data); int devm_drm_dp_typec_bridge_add(struct device *dev, struct drm_dp_typec_bridge_dev *typec_bridge_dev); #else static inline struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, @@ -55,6 +59,11 @@ devm_drm_dp_typec_bridge_alloc(struct device *parent, struct device_node *np) return NULL; } +static inline void drm_dp_typec_bridge_add_hpd_notify(struct drm_dp_typec_bridge_dev *typec_bridge_dev, + hpd_notify_fn_t hpd_notify, void *hpd_data) +{ +} + static inline int devm_drm_dp_typec_bridge_add(struct device *dev, struct drm_dp_typec_bridge_dev *typec_bridge_dev) {