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: 13786315 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 397AD13D51C for ; Sun, 1 Sep 2024 04:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163644; cv=none; b=tPNYbWXGl4U1iu51jS+RJOhwO5kl5GaS8suTXWmmCVsYhYDNyA6ZtCzKL7OBNnSO0UqJUsYbcC6xqY+FbWpFMvk0F17sCZFZVzwd3D78nq3xCZ2/Ll1JcdUrhvemwgIeLhFgMxtIQ335Y0hks2iOtF6hqFxlQQz/IdcD/Nf7NQU= 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=S8zuDPVT; arc=none smtp.client-ip=209.85.216.49 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="S8zuDPVT" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2d8818337a5so1040888a91.1 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=vger.kernel.org; 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=S8zuDPVTyNgTPBT5xmfI7JnkR2MPpsEBl2aSzyDE28ke/BJctB9C+R3KUIzEUoWGUt XI0UJIUY3OyfFvoCmNKyUgywIoKuAtPmfSetjKg7LNCcoCbLbPqmy4v2Q6g87Z/gahH0 innRoIpzlwKiIR7BfhtrYZgB5dxmVQ7rQ0EDE= 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=dHTDORBJpCMiEm7yymMD5oN1xu+QZTkKESZ/FL12fBqpuyfd92CH/kiVIB4iNh+sNP cJooSRTjpM3vGgFNhhCRJRX0jh2uFmsXJ9CWyCTqB7Ubk6Ln8pacpOn1FUc6NIZ9zkfg SWOI0PBeB9OzZXMjNuDhap6mmu1pfVgijd9hfCVda9EoSrOXvQXlZWAMDZIG/qBATCm/ sNHTMSQQ8c4SGmbblUk3s43f3/T9y/TvwY4chSDXzVOZPH3m2dkMFsS1Q2w+oewGh+5I UtTaw9VDWc5w/4RHaG6QJk2zCaGJ/n+a9C4EBuq1ZjPPL9u4azR4SGf3pBayNTd8Wz8a c+WA== X-Forwarded-Encrypted: i=1; AJvYcCXA5T5njCFWk/aKp7Sn4y8udzsDDZSTXhogcosj4rThWWMvvHvNEAedfr4ql4OOKKp/jkIgezOBKaw=@vger.kernel.org X-Gm-Message-State: AOJu0YwOf+Cpts7exU3ZYamn63krvWmhfBq7sPyJrKeIQsn82BtuBXvg i17zk8TO5HNzgdhTzPfWpFuQnz0BpilFdFgsYQdhXzaDL2LNsICLrzmWzi9HCQ== 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: linux-usb@vger.kernel.org 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) {