From patchwork Sun Sep 1 04:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824615 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 5F3A33BBC2 for ; Sun, 1 Sep 2024 04:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163629; cv=none; b=JnQNVTXbLtgkFpGD/yPlQXDKRZsWmpMdu8+XZUcJyPkI6Auu5I/cmtrMHfakthqs2oXYcjJqXHmFDetBTjGjuFsSruTaQ+SIto/YeHgj7OES9hHIcnLaxyQN2A7yyDPRWU0MZhmGuoXG7i6Sir/C8gLH2ty3l4T/Ms3GgBXdFuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163629; c=relaxed/simple; bh=pZ7ktacniNaKMda1L3Z6XilrG7hHXha97/67GYjaAzo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uu0FTUxeO8k5j0lHtEroXcGukQooYAHfQ/8JlgHXpEJDcaaqvABYfsEKpI1WbHR7Rm7Qwv2GIYoyvncbyQ85xtRH3BOI/ZMreNc22gPhjFTWi11EE1CguJMZPBhicPyOVQPev/1JBHN35OaXhkLs3fCzttJNjvza/bAtXDp6xMw= 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=aNzUSEg9; arc=none smtp.client-ip=209.85.161.47 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="aNzUSEg9" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5dfad5a9c21so1282564eaf.0 for ; Sat, 31 Aug 2024 21:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163626; x=1725768426; 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=bsT6Pyy4WdREZdfc6RLc4+Jmxiv/uouJ028bXKINCs8=; b=aNzUSEg9pnhOYvMbwY8uXM54dt3waMRYHfrCn1Q9WYJddI6w/2XUMqHZfn+hD7X/jM lQgdXnWHpGftkb9CtOPfsVrIiTuwcKPpYTmLqrggWePT5ix1sh8JfHbOteFezbhim9vZ 3IxaMeNrDJ1daKoVHjUtcGdi4q8V+zH4zzQpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163626; x=1725768426; 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=bsT6Pyy4WdREZdfc6RLc4+Jmxiv/uouJ028bXKINCs8=; b=wPjeJiaXxp1PBmMkv0oHKSa4xU9ebFZVFrxbxcXIuvBDXdI9ZOkAnG7AUipyO0+eqF jydh8l7AeBZCuLiDyuqf05uWpJLKlYLbdxaI3kLK30kO4blE2Eu9RNJIBKM5JuDqeUU6 YqddkhUMZ4PQolNpM64w4e19hj8273OYz1xopuD2AiXFfl9XiveEQzneHbfPBBrklI0J uWbb6OkrAb+7k/kLHzomIzr7Tegi6eDF3n7lSu6trnbFZFJWnfAvGtrIYEqJwfzmPG86 7+nEXv76ymvwlg2B3eXL8TRxC7Y76gE0qO6R1AgzHwS3MD3pGAe+ELxziasT+aVbQYKy SYnw== X-Forwarded-Encrypted: i=1; AJvYcCUv2jZWLNzfUb8hv8tSZYMjoyaN0V+Fqek/RTV0u8qseWH3rlbHsJPG+72d50yv0+n4n1uOmVtbM+eJ@vger.kernel.org X-Gm-Message-State: AOJu0Yz/vlHXqee2XfnkgTKR7I5gB2cIIgQfCVcTg9TmhJowWqCmdA5s JNEEVRs0aS1hjoxOZ8P+CphgcDH7DJ2BqcEYXPQ+WlJsAQWwbyjpb/+DnPIooQ== X-Google-Smtp-Source: AGHT+IHtz1LVfFf3gG+hTwV6UQ2tt7nrnC8wrXqjk3Bxp7NafXmwM2C1wRlTdUffnPNfcbRmXcHwSg== X-Received: by 2002:a05:6358:24aa:b0:1ac:65e7:919b with SMTP id e5c5f4694b2df-1b603beb8afmr1222369855d.6.1725163626398; Sat, 31 Aug 2024 21:07:06 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-715e56d78e4sm4847550b3a.163.2024.08.31.21.07.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:06 -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 02/18] drm/bridge: Verify lane assignment is going to work during atomic_check Date: Sat, 31 Aug 2024 21:06:40 -0700 Message-ID: <20240901040658.157425-3-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Verify during drm_atomic_bridge_check() that the lane assignment set in a bridge's atomic_check() callback is going to be satisfied by the previous bridge. If the next bridge is requiring something besides the default 1:1 lane assignment on its input then there must be an output lane assignment on the previous bridge's output. Otherwise the next bridge won't get the lanes assigned that it needs. Cc: Andrzej Hajda Cc: Neil Armstrong Cc: Robert Foss Cc: Laurent Pinchart Cc: Jonas Karlman Cc: Jernej Skrabec Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Cc: Pin-yen Lin Cc: Dmitry Baryshkov Signed-off-by: Stephen Boyd --- drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index bd18c1e91dee..e350248ba5c2 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -860,6 +860,10 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + u8 num_input_lanes, num_output_lanes = 0; + const struct drm_lane_cfg *input_lanes; + unsigned int i; + if (bridge->funcs->atomic_check) { struct drm_bridge_state *bridge_state; int ret; @@ -873,12 +877,25 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge, crtc_state, conn_state); if (ret) return ret; + num_output_lanes = bridge_state->output_bus_cfg.num_lanes; } else if (bridge->funcs->mode_fixup) { if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode, &crtc_state->adjusted_mode)) return -EINVAL; } + input_lanes = drm_bridge_next_bridge_lane_cfg(bridge, + crtc_state->state, + &num_input_lanes); + /* + * Ensure this bridge is aware that the next bridge wants to + * reassign lanes. + */ + for (i = 0; i < num_input_lanes; i++) { + if (i != input_lanes[i].logical && !num_output_lanes) + return -ENOTSUPP; + } + return 0; } From patchwork Sun Sep 1 04:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824614 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 BF15A3717F for ; Sun, 1 Sep 2024 04:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163633; cv=none; b=ihKMecSRRSZNtaAezGV08goXYNI02cjKNBkq77K+q6yw2lDkrFMofCCFnwdQHdCK1l3JYDxpu/rbNC1JBjNZxElLtiaFiLt8GyG0+L1s1TTyRmZoYWW/2eKV7Q3jtAt9ZYH878vI4kZNC/68R07PgnzdszgxVgid+ZToRtx4sAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163633; c=relaxed/simple; bh=lQuo9VmpRTMEUSypDAVnMcCD781MhPSwWoCv0Ud9eec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QjnBrpxxCxLRygqbQtLW/FbX7nYc3l3xt5212gIgAOIgoyM3OxH2Ohmqwk4ddR2BAvSU+94i3oX90ysR7k7lbyqacCDQGKYn32ikzyX67qB7Ol2omiJ+bXLl/f0I9/JEramQRDEcLs+MFrwY2yQV+IAEaTPVmzLOcVTxGGyrBns= 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=XXUBv+CG; arc=none smtp.client-ip=209.85.161.44 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="XXUBv+CG" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5dc93fa5639so1904604eaf.1 for ; Sat, 31 Aug 2024 21:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163631; x=1725768431; 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=2N8vS/njRh59NN9Hhbqh05Yl3HU3mcBshclMsZjbFEo=; b=XXUBv+CGuy3CD5Jb251OYi4bH6NRFL8hhKhRN+LccXoDWdaNtsaE7P7Os2YnehRkya LeblKHIvjH/dRZ/eSwOqRlZKRkvJXh1qTQSu+l5Gm8Htxk54v4f4gWXeZoCia305gNXh XyZUKfsI/VNTFC2iruBY195KOQqTKp8FEjpnY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163631; x=1725768431; 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=2N8vS/njRh59NN9Hhbqh05Yl3HU3mcBshclMsZjbFEo=; b=QckwgwipKeWCCm34Ujvmi3FRPBu5nZ8uBRsU4q0eSMermevEOsw1ioRIeumzhIGqak TG0TQB19HTB/SP89oYiArS8evHFJH0Vzg32SusBRhMua8uzc0z4qrAEW8COtL/zZZ67C OunDt6B0OC8h75IQE2v8kLILXbJiuCNm48//ki2rbu9EXQrbDpY4NaEI7vnASHMLjbqC FLExmtzLg4+uc2y39uDokWjXXcOsD9EJEGbU9AuVMepZk0rqzkC+CegZra8t0RTszql1 4njdT7swCHqY3zEd4WLJrCN1Jb9w86QCQqy6/Htyd8vZ7/p4ez6Do5pTtJObcA2KsO2Z Ly9A== X-Forwarded-Encrypted: i=1; AJvYcCXwxxIiVp4HADV8EJLDahe1wy9brfusODUB55uDuCR7Ee8oRSHIVYCKzNEMHGHajSYvHvU+55sbQ0f6@vger.kernel.org X-Gm-Message-State: AOJu0Ywh1RrS+nHKVKYlLNF9fy2LPdjDsDZ5r3z03xwRiqMpYTRWYouL hINT5qStDMdfIDMsDAYH8Cc4R9v5AA2jN5Ui5zkOxkjwiodLTnvaVtqMJR2lQQ== X-Google-Smtp-Source: AGHT+IGn0G5AiONQD8K5yi4LzBmU8yqa6VFEQOeNXV9U2Ho8xKtvyvDtSksQxtqrZ7RRI09TCw6qDQ== X-Received: by 2002:a05:6830:7310:b0:709:5601:abea with SMTP id 46e09a7af769-70f72bb320amr3883433a34.10.1725163630581; Sat, 31 Aug 2024 21:07:10 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7d22e77a7besm5341681a12.37.2024.08.31.21.07.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:10 -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 04/18] usb: typec: Add device managed typec_mux_register() Date: Sat, 31 Aug 2024 21:06:42 -0700 Message-ID: <20240901040658.157425-5-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify driver error paths by adding devm_typec_mux_register() which will unregister the typec mux when the parent device is unbound. Cc: Heikki Krogerus Cc: Greg Kroah-Hartman Cc: Cc: Pin-yen Lin Signed-off-by: Stephen Boyd --- drivers/usb/typec/mux.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/usb/typec_mux.h | 7 +++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 49926d6e72c7..db644bec862c 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -457,6 +457,41 @@ void typec_mux_unregister(struct typec_mux_dev *mux_dev) } EXPORT_SYMBOL_GPL(typec_mux_unregister); +static void devm_typec_mux_unregister(void *mux_dev) +{ + typec_mux_unregister(mux_dev); +} + +/** + * devm_typec_mux_register - resource managed typec_mux_register() + * @parent: Parent device + * @desc: Multiplexer description + * + * Register a typec mux and automatically unregister the typec mux + * when @parent is unbound from its driver. + * + * The arguments to this function are identical to typec_mux_register(). + * + * Return: the typec_mux_dev structure on success or error pointer on error. + */ +struct typec_mux_dev * +devm_typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) +{ + int ret; + struct typec_mux_dev *mux_dev; + + mux_dev = typec_mux_register(parent, desc); + if (IS_ERR(mux_dev)) + return mux_dev; + + ret = devm_add_action_or_reset(parent, devm_typec_mux_unregister, mux_dev); + if (ret) + return ERR_PTR(ret); + + return mux_dev; +} +EXPORT_SYMBOL_GPL(devm_typec_mux_register); + void typec_mux_set_drvdata(struct typec_mux_dev *mux_dev, void *data) { dev_set_drvdata(&mux_dev->dev, data); diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index efb5ed32b813..08431f0896d5 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -99,6 +99,8 @@ int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state); struct typec_mux_dev * typec_mux_register(struct device *parent, const struct typec_mux_desc *desc); +struct typec_mux_dev * +devm_typec_mux_register(struct device *parent, const struct typec_mux_desc *desc); void typec_mux_unregister(struct typec_mux_dev *mux); void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data); @@ -123,6 +125,11 @@ typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) { return ERR_PTR(-EOPNOTSUPP); } +static inline struct typec_mux_dev * +devm_typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) +{ + return typec_mux_register(parent, desc); +} static inline void typec_mux_unregister(struct typec_mux_dev *mux) {} static inline void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data) {} From patchwork Sun Sep 1 04:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824613 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 1997713A418 for ; Sun, 1 Sep 2024 04:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163638; cv=none; b=OE5TPWp3xxMrSxvRCInaLiBH/cmhyTbrFbduVjfXisC905SUv0lKfN41A05jtGUg9H5BRYg9WURMsw6+fUrnFXmNUbI4K8mURFPnKXXzLggvESK/7YTfHO3GL0tWEotZHg2EcG922q3RRk0PiTQPMEBpD0w3JhCz/icp7Ny+hBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163638; c=relaxed/simple; bh=wSeatNei0A7Ebd8UljCyLcHxVvUbnWOD9TWjcptS84U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dajqHP+HGVp3f4HFYQS4CzJvt7pGyoVdiYS46+Phgn91KnzEdvqye5Z9uD0sfSNWX6EQg8SD5sZUJ9OeBBamDHLFDtb0vhUR7ySNOZQhCeAmwlfw7LKgH0aluhzTFLJBMd6SLwp58gLzfoYctPN3tiQtPvLW3cxz/2KbY4HYkYI= 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=AKmdKUNh; arc=none smtp.client-ip=209.85.161.41 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="AKmdKUNh" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5d5c7f24372so1987354eaf.0 for ; Sat, 31 Aug 2024 21:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163635; x=1725768435; 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=DuEX+B1LPDkO0gwsNaxgdZWm0YsScz9kUEVqR8xaDPo=; b=AKmdKUNhkyggy8Wf50Fxl5z29mTkhy0vyYr9Y8BhjSE7iTzW+AZgxwF3FOSbtsIe6N mq/ApKxaNmCIoK42yYJo8ZmAULp76RJ9lCsLzYOk85/rwnqg4gpB9N5J5YtEiBTN8U0A i3EEjSCf34IHYTdjvL7v4rrWPuVxAN5BVqwlU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163635; x=1725768435; 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=DuEX+B1LPDkO0gwsNaxgdZWm0YsScz9kUEVqR8xaDPo=; b=ULF3ZyDdekouNxmbR0MoT/eMUulbk/E5DRgnKDRw3+7kORvSeM3XcWYjMqhQgLaKPO CydCPp2bWIZE6tbMsxgvWn1ybk6NijTX1bDK+UptDH3NYD+kPH/MBsK/v5TwI79RftW2 ooXD/1Dxb6Cuy6ewm7NTylHcKGCk4Mr6OUTFmBGgkb2d4aff9ayQGyGUwAMRWxii6/qD wFqiKEe8heUvsm4XJcCFcBOiYBVWhuQkZ+nDmxBboaVOzDtXqw05VHs5xwTWJg7lneng GDVpVN01EgpsI7BQcKViZOgFoYfDlYsvVWmyOtW6Ujc1bZjOVBun2QKmGc9sX8n/zYOa 6Xxw== X-Forwarded-Encrypted: i=1; AJvYcCV27T4l7V2DElF8VcuPWqNBJW/y00bXTy2ENDxJDBEEbI36u0Jm9+HXHK6QtLrm+6yUVdSSnZ/WHhQk@vger.kernel.org X-Gm-Message-State: AOJu0YxgnzVcRlszBGuc8I4EW5K66H9SpcRhTVSz33lTgQVMgH+N5dVL jD3bT+nmqlbWgK1yMQqPgx8c/hA2yXvXhnL1yAzAvTIPv0g2j884xMdVNw5SeA== X-Google-Smtp-Source: AGHT+IFhd/v0o75TM3Av0ILjq1OZC+BzETv/i1P77qiiQwfgv/wDUywsLFLtblWnZq5CeTacIW+EAQ== X-Received: by 2002:a05:6358:60cc:b0:1b5:fa48:5973 with SMTP id e5c5f4694b2df-1b7ef5fd67cmr625729455d.4.1725163634887; Sat, 31 Aug 2024 21:07:14 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d85b119c26sm6611649a91.14.2024.08.31.21.07.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:14 -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 06/18] drm/bridge: aux-hpd: Support USB Type-C DP altmodes via DRM lane assignment Date: Sat, 31 Aug 2024 21:06:44 -0700 Message-ID: <20240901040658.157425-7-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Extend the aux-hpd bridge driver to support assigning DP lanes to USB type-c pins based on typec mux state entry. Existing users of this driver only need the HPD signaling support, so leave that in place and wrap the code with a variant that supports more features of USB type-c DP altmode, i.e. pin configurations. Prefix that code with 'drm_dp_typec_bridge' to differentiate it from the existing 'drm_aux_hpd_bridge' code. Parse the struct typec_mux_state members to determine if DP altmode has been entered and if HPD is asserted or not. Signal HPD to the drm bridge chain when HPD is asserted. Similarly, parse the pin assignment and map the DP lanes to the usb-c output lanes, taking into account any lane remapping from the data-lanes endpoint property. Pass that lane mapping to the previous drm_bridge in the bridge chain during the atomic check phase. 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 | 483 +++++++++++++++++++++++- include/drm/bridge/aux-bridge.h | 17 + 2 files changed, 488 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index 6886db2d9e00..32565f88ade7 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -7,8 +7,14 @@ #include #include #include +#include +#include +#include +#include +#include #include +#include #include static DEFINE_IDA(drm_aux_hpd_bridge_ida); @@ -18,6 +24,80 @@ struct drm_aux_hpd_bridge_data { struct device *dev; }; +enum dp_lane { + DP_ML0 = 0, /* DP pins 1/3 */ + DP_ML1 = 1, /* DP pins 4/6 */ + DP_ML2 = 2, /* DP pins 7/9 */ + DP_ML3 = 3, /* DP pins 10/12 */ +}; + +#define NUM_DP_ML (DP_ML3 + 1) + +enum usb_ss_lane { + USB_SSRX1 = 0, /* Type-C pins B11/B10 */ + USB_SSTX1 = 1, /* Type-C pins A2/A3 */ + USB_SSTX2 = 2, /* Type-C pins A11/A10 */ + USB_SSRX2 = 3, /* Type-C pins B2/B3 */ +}; + +#define NUM_USB_SS (USB_SSRX2 + 1) + +struct drm_dp_typec_bridge_data; + +/** + * struct drm_dp_typec_bridge_typec_port - USB type-c port associated with DP bridge + * @lane_mapping: Physical (array index) to logical (array value) USB type-C lane mapping + * @mode_switch: DP altmode switch + * @typec_data: Back pointer to type-c bridge data + */ +struct drm_dp_typec_bridge_typec_port { + u32 lane_mapping[NUM_USB_SS]; + struct typec_mux_dev *mode_switch; + struct drm_dp_typec_bridge_data *typec_data; +}; + +/** + * struct drm_dp_typec_bridge_data - DP over USB type-c drm_bridge + * @dp_lanes: Physical (array value) to logical (array index) DP lane mapping + * @num_lanes: Number of valid lanes in @dp_lanes + * @hpd_bridge: hpd_bridge data + */ +struct drm_dp_typec_bridge_data { + u8 dp_lanes[NUM_DP_ML]; + size_t num_lanes; + struct drm_aux_hpd_bridge_data hpd_bridge; +}; + +static inline struct drm_dp_typec_bridge_data * +hpd_bridge_to_typec_bridge_data(struct drm_aux_hpd_bridge_data *hpd_data) +{ + return container_of(hpd_data, struct drm_dp_typec_bridge_data, hpd_bridge); +} + +static inline struct drm_dp_typec_bridge_data * +to_drm_dp_typec_bridge_data(struct drm_bridge *bridge) +{ + struct drm_aux_hpd_bridge_data *hpd_data; + + hpd_data = container_of(bridge, struct drm_aux_hpd_bridge_data, bridge); + + return hpd_bridge_to_typec_bridge_data(hpd_data); +} + +struct drm_dp_typec_bridge_dev { + struct auxiliary_device adev; + size_t max_lanes; + size_t num_typec_ports; +}; + +static inline struct drm_dp_typec_bridge_dev * +to_drm_dp_typec_bridge_dev(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + + return container_of(adev, struct drm_dp_typec_bridge_dev, adev); +} + static void drm_aux_hpd_bridge_release(struct device *dev) { struct auxiliary_device *adev = to_auxiliary_dev(dev); @@ -30,6 +110,22 @@ static void drm_aux_hpd_bridge_release(struct device *dev) kfree(adev); } +static void drm_dp_typec_bridge_release(struct device *dev) +{ + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + struct auxiliary_device *adev; + + typec_bridge_dev = to_drm_dp_typec_bridge_dev(dev); + adev = &typec_bridge_dev->adev; + + ida_free(&drm_aux_hpd_bridge_ida, adev->id); + + of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); + + kfree(typec_bridge_dev); +} + static void drm_aux_hpd_bridge_free_adev(void *_adev) { auxiliary_device_uninit(_adev); @@ -133,6 +229,111 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, struct device_n } EXPORT_SYMBOL_GPL(drm_dp_hpd_bridge_register); +/** + * devm_drm_dp_typec_bridge_alloc - Allocate a USB type-c DisplayPort bridge + * @parent: device instance providing this bridge + * @np: device node pointer corresponding to this bridge instance + * + * Creates a DRM bridge with the type set to DRM_MODE_CONNECTOR_DisplayPort, + * which terminates the bridge chain and is able to send the HPD events along + * with remap DP lanes to match USB type-c DP altmode pin assignments. + * + * Return: device instance that will handle created bridge or an error code + * encoded into the pointer. + */ +struct drm_dp_typec_bridge_dev * +devm_drm_dp_typec_bridge_alloc(struct device *parent, struct device_node *np) +{ + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + struct auxiliary_device *adev; + int ret, num_dp_lanes; + struct device_node *dp_ep __free(device_node) = NULL; + struct device_node *remote_ep; + struct device_node *ep_node; + struct of_endpoint ep; + + typec_bridge_dev = kzalloc(sizeof(*typec_bridge_dev), GFP_KERNEL); + if (!typec_bridge_dev) + return ERR_PTR(-ENOMEM); + adev = &typec_bridge_dev->adev; + + for_each_endpoint_of_node(np, ep_node) { + of_graph_parse_endpoint(ep_node, &ep); + /* Only consider available endpoints */ + if (!of_device_is_available(ep_node)) + continue; + /* Only consider connected nodes */ + remote_ep = of_graph_get_remote_endpoint(ep_node); + of_node_put(remote_ep); + if (!remote_ep) + continue; + + if (ep.port == 2) + dp_ep = of_node_get(ep_node); + else if (ep.port == 0) + typec_bridge_dev->num_typec_ports++; + } + + if (!typec_bridge_dev->num_typec_ports) { + kfree(adev); + return ERR_PTR(dev_err_probe(parent, -ENODEV, "Missing typec endpoint(s) port@0\n")); + } + + if (!dp_ep) { + kfree(adev); + return ERR_PTR(dev_err_probe(parent, -ENODEV, "Missing DP endpoint port@2\n")); + } + + num_dp_lanes = of_property_count_u32_elems(dp_ep, "data-lanes"); + if (num_dp_lanes < 0) + num_dp_lanes = NUM_DP_ML; + + typec_bridge_dev->max_lanes = num_dp_lanes; + + ret = ida_alloc(&drm_aux_hpd_bridge_ida, GFP_KERNEL); + if (ret < 0) { + kfree(adev); + return ERR_PTR(ret); + } + + adev->id = ret; + adev->name = "dp_typec_bridge"; + adev->dev.parent = parent; + adev->dev.of_node = of_node_get(parent->of_node); + adev->dev.release = drm_dp_typec_bridge_release; + adev->dev.platform_data = of_node_get(np); + ret = auxiliary_device_init(adev); + if (ret) { + of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); + ida_free(&drm_aux_hpd_bridge_ida, adev->id); + kfree(adev); + return ERR_PTR(ret); + } + + ret = devm_add_action_or_reset(parent, drm_aux_hpd_bridge_free_adev, adev); + if (ret) + return ERR_PTR(ret); + + return typec_bridge_dev; +} +EXPORT_SYMBOL_GPL(devm_drm_dp_typec_bridge_alloc); + +/** + * devm_drm_dp_typec_bridge_add - register a USB type-c DisplayPort bridge + * @dev: struct device to tie registration lifetime to + * @typec_bridge_dev: USB type-c DisplayPort bridge to be registered + * + * Returns: zero on success or a negative errno + */ +int devm_drm_dp_typec_bridge_add(struct device *dev, struct drm_dp_typec_bridge_dev *typec_bridge_dev) +{ + struct auxiliary_device *adev = &typec_bridge_dev->adev; + + return devm_drm_dp_hpd_bridge_add(dev, adev); +} +EXPORT_SYMBOL_GPL(devm_drm_dp_typec_bridge_add); + /** * drm_aux_hpd_bridge_notify - notify hot plug detection events * @dev: device created for the HPD bridge @@ -161,32 +362,290 @@ static int drm_aux_hpd_bridge_attach(struct drm_bridge *bridge, return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; } +static int dp_lane_to_typec_lane(enum dp_lane lane) +{ + switch (lane) { + case DP_ML0: + return USB_SSTX2; + case DP_ML1: + return USB_SSRX2; + case DP_ML2: + return USB_SSTX1; + case DP_ML3: + return USB_SSRX1; + } + + return -EINVAL; +} + +static int typec_to_dp_lane(enum usb_ss_lane lane) +{ + switch (lane) { + case USB_SSRX1: + return DP_ML3; + case USB_SSTX1: + return DP_ML2; + case USB_SSTX2: + return DP_ML0; + case USB_SSRX2: + return DP_ML1; + } + + return -EINVAL; +} + +/** + * drm_dp_typec_bridge_assign_pins - Assign DisplayPort (DP) lanes to USB type-c pins + * @typec_bridge_dev: USB type-c DisplayPort bridge + * @conf: DisplayPort altmode configure command VDO content + * @port: The USB type-c output port to assign pins to + * + * Assign DP lanes to the @port's USB type-c pins for the DP altmode + * configuration @conf, while taking into account the USB type-c lane_mapping. + * Future atomic checks on this bridge will request the lane assignment from + * the previous bridge so that the DP signal is sent to the assigned USB type-c + * pins. + * + * Return: 0 on success, negative value for failure. + */ +static int +drm_dp_typec_bridge_assign_pins(struct drm_dp_typec_bridge_dev *typec_bridge_dev, + u32 conf, + struct drm_dp_typec_bridge_typec_port *port) +{ + enum usb_ss_lane *lane_mapping = port->lane_mapping; + struct auxiliary_device *adev = &typec_bridge_dev->adev; + struct drm_aux_hpd_bridge_data *hpd_data = auxiliary_get_drvdata(adev); + struct drm_dp_typec_bridge_data *data; + u8 *dp_lanes; + size_t num_lanes, max_lanes; + int i, typec_lane; + u8 pin_assign; + + if (!hpd_data) + return -EINVAL; + + data = hpd_bridge_to_typec_bridge_data(hpd_data); + dp_lanes = data->dp_lanes; + + pin_assign = DP_CONF_GET_PIN_ASSIGN(conf); + if (pin_assign == DP_PIN_ASSIGN_D) + num_lanes = 2; + else + num_lanes = 4; + max_lanes = typec_bridge_dev->max_lanes; + data->num_lanes = num_lanes = min(num_lanes, max_lanes); + + for (i = 0; i < num_lanes; i++) { + /* Get physical type-c lane for DP lane */ + typec_lane = dp_lane_to_typec_lane(i); + if (typec_lane < 0) { + dev_err(&adev->dev, "Invalid type-c lane configuration at DP_ML%d\n", i); + return -EINVAL; + } + + /* Map physical to logical type-c lane */ + typec_lane = lane_mapping[typec_lane]; + + /* Map logical type-c lane to logical DP lane */ + dp_lanes[i] = typec_to_dp_lane(typec_lane); + } + + return 0; +} + +static int drm_dp_typec_bridge_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_dp_typec_bridge_data *data; + struct drm_lane_cfg *in_lanes; + u8 *dp_lanes; + size_t num_lanes; + int i; + + data = to_drm_dp_typec_bridge_data(bridge); + num_lanes = data->num_lanes; + if (!num_lanes) + return 0; + dp_lanes = data->dp_lanes; + + in_lanes = kcalloc(num_lanes, sizeof(*in_lanes), GFP_KERNEL); + if (!in_lanes) + return -ENOMEM; + + bridge_state->input_bus_cfg.lanes = in_lanes; + bridge_state->input_bus_cfg.num_lanes = num_lanes; + + for (i = 0; i < num_lanes; i++) + in_lanes[i].logical = dp_lanes[i]; + + return 0; +} + static const struct drm_bridge_funcs drm_aux_hpd_bridge_funcs = { .attach = drm_aux_hpd_bridge_attach, }; +static const struct drm_bridge_funcs drm_dp_typec_bridge_funcs = { + .attach = drm_aux_hpd_bridge_attach, + .atomic_check = drm_dp_typec_bridge_atomic_check, + .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, +}; + +static int +drm_dp_typec_bridge_mode_switch_set(struct typec_mux_dev *mode_switch, + struct typec_mux_state *state) +{ + struct drm_dp_typec_bridge_typec_port *port; + const struct typec_displayport_data *dp_data; + struct drm_dp_typec_bridge_data *typec_data; + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + struct device *dev; + int ret; + enum drm_connector_status status; + + port = typec_mux_get_drvdata(mode_switch); + typec_data = port->typec_data; + dev = typec_data->hpd_bridge.dev; + typec_bridge_dev = to_drm_dp_typec_bridge_dev(dev); + + if (state->mode == TYPEC_STATE_SAFE || state->mode == TYPEC_STATE_USB) { + drm_aux_hpd_bridge_notify(dev, connector_status_disconnected); + } else if (state->alt && state->alt->svid == USB_TYPEC_DP_SID) { + dp_data = state->data; + ret = drm_dp_typec_bridge_assign_pins(typec_bridge_dev, state->mode, port); + if (ret) + return ret; + + if (dp_data->status & DP_STATUS_HPD_STATE) + status = connector_status_connected; + else + status = connector_status_disconnected; + + drm_aux_hpd_bridge_notify(dev, status); + } + + return 0; +} + +static int +drm_dp_typec_bridge_probe_typec_ports(struct drm_dp_typec_bridge_data *typec_data, + struct drm_dp_typec_bridge_dev *typec_bridge_dev, + struct device_node *np) +{ + struct device *dev = &typec_bridge_dev->adev.dev; + struct device_node *typec_ep, *remote_ep; + struct of_endpoint ep; + const u32 mapping[] = { 0, 1, 2, 3 }; + struct drm_dp_typec_bridge_typec_port *port; + size_t num_ports = typec_bridge_dev->num_typec_ports; + struct typec_mux_desc mode_switch_desc = { }; + struct fwnode_handle *fwnode; + const char *name; + + port = devm_kcalloc(dev, num_ports, sizeof(*port), GFP_KERNEL); + if (!port) + return -ENOMEM; + + for_each_endpoint_of_node(np, typec_ep) { + of_graph_parse_endpoint(typec_ep, &ep); + /* Only look at the usbc output port (port@0) */ + if (ep.port != 0) + continue; + /* Only consider available endpoints */ + if (!of_device_is_available(typec_ep)) + continue; + /* Only consider connected nodes */ + remote_ep = of_graph_get_remote_endpoint(typec_ep); + of_node_put(remote_ep); + if (!remote_ep) + continue; + + port->typec_data = typec_data; + if (of_property_read_u32_array(ep.local_node, "data-lanes", + port->lane_mapping, + ARRAY_SIZE(port->lane_mapping))) { + memcpy(port->lane_mapping, mapping, sizeof(mapping)); + } + + fwnode = of_fwnode_handle(typec_ep); + name = kasprintf(GFP_KERNEL, "%s-%d", dev_name(dev), ep.id); + if (!name) + return -ENOMEM; + + mode_switch_desc.set = drm_dp_typec_bridge_mode_switch_set; + mode_switch_desc.fwnode = fwnode; + mode_switch_desc.name = name; + mode_switch_desc.drvdata = port; + port->mode_switch = devm_typec_mux_register(dev, &mode_switch_desc); + if (IS_ERR(port->mode_switch)) { + kfree(name); + return PTR_ERR(port->mode_switch); + } + + kfree(name); + port++; + } + + return 0; +} + +enum drm_aux_bridge_type { + DRM_AUX_HPD_BRIDGE, + DRM_AUX_TYPEC_BRIDGE, +}; + static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id) { - struct drm_aux_hpd_bridge_data *data; + struct device *dev = &auxdev->dev; + struct drm_aux_hpd_bridge_data *hpd_data; + struct drm_dp_typec_bridge_dev *typec_bridge_dev; + struct drm_dp_typec_bridge_data *typec_data; + struct drm_bridge *bridge; + struct device_node *np = dev_get_platdata(dev); + u8 dp_lanes[] = { DP_ML0, DP_ML1, DP_ML2, DP_ML3 }; + int ret; - data = devm_kzalloc(&auxdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; + if (id->driver_data == DRM_AUX_HPD_BRIDGE) { + hpd_data = devm_kzalloc(dev, sizeof(*hpd_data), GFP_KERNEL); + if (!hpd_data) + return -ENOMEM; + bridge = &hpd_data->bridge; + bridge->funcs = &drm_aux_hpd_bridge_funcs; + } else if (id->driver_data == DRM_AUX_TYPEC_BRIDGE) { + typec_data = devm_kzalloc(dev, sizeof(*typec_data), GFP_KERNEL); + if (!typec_data) + return -ENOMEM; + hpd_data = &typec_data->hpd_bridge; + bridge = &hpd_data->bridge; + bridge->funcs = &drm_dp_typec_bridge_funcs; + typec_bridge_dev = to_drm_dp_typec_bridge_dev(dev); + memcpy(typec_data->dp_lanes, dp_lanes, sizeof(typec_data->dp_lanes)); + ret = drm_dp_typec_bridge_probe_typec_ports(typec_data, typec_bridge_dev, np); + if (ret) + return ret; + } else { + return -ENODEV; + } - data->dev = &auxdev->dev; - data->bridge.funcs = &drm_aux_hpd_bridge_funcs; - data->bridge.of_node = dev_get_platdata(data->dev); - data->bridge.ops = DRM_BRIDGE_OP_HPD; - data->bridge.type = id->driver_data; + hpd_data->dev = dev; + bridge->of_node = dev_get_platdata(dev); + bridge->ops = DRM_BRIDGE_OP_HPD; + bridge->type = DRM_MODE_CONNECTOR_DisplayPort; - auxiliary_set_drvdata(auxdev, data); + auxiliary_set_drvdata(auxdev, hpd_data); - return devm_drm_bridge_add(data->dev, &data->bridge); + return devm_drm_bridge_add(dev, bridge); } static const struct auxiliary_device_id drm_aux_hpd_bridge_table[] = { - { .name = KBUILD_MODNAME ".dp_hpd_bridge", .driver_data = DRM_MODE_CONNECTOR_DisplayPort, }, + { .name = KBUILD_MODNAME ".dp_hpd_bridge", .driver_data = DRM_AUX_HPD_BRIDGE, }, + { .name = KBUILD_MODNAME ".dp_typec_bridge", .driver_data = DRM_AUX_TYPEC_BRIDGE, }, {}, }; MODULE_DEVICE_TABLE(auxiliary, drm_aux_hpd_bridge_table); diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridge.h index c2f5a855512f..73fc8582ec07 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -20,12 +20,17 @@ static inline int drm_aux_bridge_register(struct device *parent) } #endif +struct drm_dp_typec_bridge_dev; + #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); struct device *drm_dp_hpd_bridge_register(struct device *parent, struct device_node *np); 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); +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, struct device_node *np) @@ -44,6 +49,18 @@ static inline struct device *drm_dp_hpd_bridge_register(struct device *parent, return NULL; } +static inline struct drm_dp_typec_bridge_dev * +devm_drm_dp_typec_bridge_alloc(struct device *parent, struct device_node *np) +{ + return NULL; +} + +static inline int devm_drm_dp_typec_bridge_add(struct device *dev, + struct drm_dp_typec_bridge_dev *typec_bridge_dev) +{ + return 0; +} + static inline void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status) { } From patchwork Sun Sep 1 04:06:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824612 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 3DA4C3A8D8 for ; Sun, 1 Sep 2024 04:07:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163641; cv=none; b=gd98MVJuLn+SweCvQpshDZC+HoaM5131a75jcBS3qHN7ZfCl/iNPaF9hV9FdI9fV2Q9P+eLAEFtVkF9oudlj9cdcUAgLChlTbeU9hMrXA9fcVl6fkNZ30yK1UXX/2oKoMcGpaocZWBYp8uO4lzkLL3vMn+mf/ScsbSk3HL0HZyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163641; c=relaxed/simple; bh=K0vY/b3gdQJ7BbfGBTXVjSZjUjMpNMzLu+iBHhG2UV4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CvLMUEXHTuHI+MgxifvEppHUux+H2dFezqN//4JRGKXYHDIjZdQx62igtFjCMrDbXvcgcSyzze73hDBthQMevF5zOBWeAhGr8upPvjszrP+O/0dcohAu9q21joc1pWpTKS4n3SImJ5wLHHKVfIQLZI8lUq3EVas1XeGzOGylSOU= 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=Ral7CfPc; arc=none smtp.client-ip=209.85.215.180 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="Ral7CfPc" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-70b2421471aso1737289a12.0 for ; Sat, 31 Aug 2024 21:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163639; x=1725768439; 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=dihu8n2PjcWrFXOuwWbECc9MpTZcbkDtMAPCx56QCc0=; b=Ral7CfPcE6I6JLLwGDbrbf4VdCpLJLd5VBeL1JQx0Lv8LiHAedN3a7Bms6VpMfNzWc Kl1Wn9QeF8uuenIS2n7WiIOKf84cEXhFlfHq3jMkphgzxHRZKBv0exPUdxrgC/AFPz88 NcPU+uj3U3hGPuZC5zyaNGTqRdJ9vevZACJM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163639; x=1725768439; 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=dihu8n2PjcWrFXOuwWbECc9MpTZcbkDtMAPCx56QCc0=; b=rtMxTNmVuM2+JE2bYZvOYUTrGQQDj0QRnNL1nxbDbbdncxD12paqoXATz24MQAaf36 nHGagTU4UFjpkbMPlnYGUmSzRmwZ8Jtv1dUQ+q7L6X0SNzqeqYUK0+a4etfSpdWyg/8X /jd1yxzecjVqclg5uUXaavoPFhx0k0N5wGZsSDsEriFN0x6aTgFBkNdJ0ztRY3ZcTs2d O9qeZtgoi2umfOQjtM/xoUO4LmALVCcBhqTflbhULIttXBCFZw4uZ7/7aZmTIpsMG3ah eHIMWBSKvcJd6D7wMG1zkDOSP/MJfa3bM85m+9O89gxlrSsKJSjASmf9A2ezH5q4pXac HfZQ== X-Forwarded-Encrypted: i=1; AJvYcCVEv4inT4qHw9P64P6utFHIOHjKIx+UxniYNT21dQqZzdN7ClvhLbroYYxyc48gGULLku4wyVZKiZaZ@vger.kernel.org X-Gm-Message-State: AOJu0YzGfOjfdjI/WYBo7P7mmUqMi8Za52g5vieHp9GwaPNmDbFAKY8H ucPOkJN9axojL3wuTJYoOZsERuD3/r4uj58VHx6/t24azwoavCxZQSE5iow1Ag== X-Google-Smtp-Source: AGHT+IGUB6+86RHnw08wq757NS4DSJb/B5ixBOuB5HoLx7W2xOHzGQ0pL/7XrZLrWwYk0S+0GfQauw== X-Received: by 2002:a05:6a21:3213:b0:1c4:a8a6:a85f with SMTP id adf61e73a8af0-1ced62a2b24mr2056687637.30.1725163639331; Sat, 31 Aug 2024 21:07:19 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d8aba505bfsm1381042a91.8.2024.08.31.21.07.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:19 -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 08/18] drm/bridge: dp_typec: Add "no-hpd" support Date: Sat, 31 Aug 2024 21:06:46 -0700 Message-ID: <20240901040658.157425-9-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for HPD coming from somewhere else in the drm_bridge chain. Skip signaling HPD sate when "no-hpd" is present in the DT node backing the dp_typec bridge. Add this support because some EC firmwares on Trogdor/Strongbad boards don't properly indicate the state of the DP HPD level on a type-c port. The EC only indicates that DP mode is entered or exited for a type-c port. The HPD level is expressed to the DP controller via a pin on the AP that the EC drives high or low when the type-c port partner (i.e. monitor) asserts or deasserts HPD. 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index d2832e6481d7..52db36aa190b 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -22,6 +22,7 @@ static DEFINE_IDA(drm_aux_hpd_bridge_ida); struct drm_aux_hpd_bridge_data { struct drm_bridge bridge; struct device *dev; + bool no_hpd; }; enum dp_lane { @@ -355,6 +356,8 @@ void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status sta if (!data) return; + if (data->no_hpd) + return; drm_bridge_hpd_notify(&data->bridge, status); } @@ -672,6 +675,7 @@ static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev, return -ENOMEM; bridge = &hpd_data->bridge; bridge->funcs = &drm_aux_hpd_bridge_funcs; + bridge->ops = DRM_BRIDGE_OP_HPD; } else if (id->driver_data == DRM_AUX_TYPEC_BRIDGE) { typec_data = devm_kzalloc(dev, sizeof(*typec_data), GFP_KERNEL); if (!typec_data) @@ -680,6 +684,9 @@ static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev, bridge = &hpd_data->bridge; bridge->funcs = &drm_dp_typec_bridge_funcs; typec_bridge_dev = to_drm_dp_typec_bridge_dev(dev); + hpd_data->no_hpd = of_property_read_bool(np, "no-hpd"); + if (!hpd_data->no_hpd) + bridge->ops = DRM_BRIDGE_OP_HPD; memcpy(typec_data->dp_lanes, dp_lanes, sizeof(typec_data->dp_lanes)); ret = drm_dp_typec_bridge_probe_typec_ports(typec_data, typec_bridge_dev, np); if (ret) @@ -689,8 +696,7 @@ static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev, } hpd_data->dev = dev; - bridge->of_node = dev_get_platdata(dev); - bridge->ops = DRM_BRIDGE_OP_HPD; + bridge->of_node = np; bridge->type = DRM_MODE_CONNECTOR_DisplayPort; auxiliary_set_drvdata(auxdev, hpd_data); From patchwork Sun Sep 1 04:06:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824611 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 7E6B913D8AC for ; Sun, 1 Sep 2024 04:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163646; cv=none; b=fF3ZiFetyt5NTCVCQBv9ipkCYPXG6rel40jP2IRlp/hprXTj/L0YPgSXDd04YlVsLLI4IDGFpY5Q3PnA2/Fz3KZWf3taNVCYTxiAyXdtVFQ5MQiVvFDN46XFEsHNVQ5/YPLiMNeAB39Mbo/asTRXZEiG/03rRNa3iTG8igUARjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163646; c=relaxed/simple; bh=2tAlkjfeIOfQ7pqxJw2iSfNqPK9cXn4z7367eyq0Rjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U8FhhF5WfsD3krWfCebTQD0ulC2PsfAETjQ8/JFjWJ8xTytVwQBCkJUKF3DHLTY30FJx8L0U42gHDSaDXH31OVWPEVUiaJbKaJflH72M2/AJpoi8MGgqheYyk3TKeNaOwLhvIYjoktfbNoOfeIDW3VLQJSiWSPeVJgky1viLsqg= 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=b35c02Nz; arc=none smtp.client-ip=209.85.210.178 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="b35c02Nz" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71423704ef3so2376001b3a.3 for ; Sat, 31 Aug 2024 21:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163644; x=1725768444; 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=nad3jYq+zuMNkdjkLGBBGQbMhdXY1+s1WlyYMjA8ho4=; b=b35c02NzFzR6or7KCjz/JT3hJrf37zKeLbWgTGlp16fZ0Ts4DAduISZ+lmV220xwPN bSa3mYlBa13/Efam+Yz8CuMHwKTbi+yNX7kjy0Bu34WsSUFwTjH3Uh1qbN3a3A5OZ9dZ zzVSXn119IcN9TGua3ZOfMV3x8CbX762/j1vY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163644; x=1725768444; 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=nad3jYq+zuMNkdjkLGBBGQbMhdXY1+s1WlyYMjA8ho4=; b=iBaGue7Ob+KMR8cOl489TnIXcohJgMoCrKb7+zflMflZ4QsCB/bIlpBRP3zUb981Me 8eEHqhqOt1P+zWsuo9dv5yn0e9fVKkY3qTRNlotQvgMhwkIndsO1vf1NqzVExw1lNOgn uJgeGegZoZz2m5vCPZYAU58h1a417Vz+99BxIqDQyDdSDX8ziR4xM0e/v7U4vUTo1ST6 TigWsDNwr073sEf/wccsdLtB+zjV3deIIkL4KnVLfZPfjbela/Je4i+U5ILdGi0LoSU9 EKaegXZdJsmpq1LYZqNpvHxo9UjpFuHNXa6K8eJzt1JeqZMuvx+o2e9RNxqf5LoefBsU GKAA== X-Forwarded-Encrypted: i=1; AJvYcCXYoHyE8tUnXl1byiwAdkpDVGMV6XOkuKg/J1fGUNv0Od578H57C+GN2/cdpHIz5XsXXzHRS3HFMY0W@vger.kernel.org X-Gm-Message-State: AOJu0YxgPkSUFf9tJo14L/cHqICUE9s4YyoIP6LgwctElMLoxXPJ0AHi QmNvlMgXUwlQdKMNKG4nkZ19h5KA3000ZCH2G+fGP/dDSIDvU9NzOes+10ArzA== X-Google-Smtp-Source: AGHT+IE4gRNS1Wle0dhusZLk2Qf9YkMQZghXHbtMZ6oKKSwEP4ondmRftvf+lk7yL+f1D9vFEqjyTA== X-Received: by 2002:a05:6a00:91d8:b0:714:147c:1377 with SMTP id d2e1a72fcca58-7173b5c8556mr4671065b3a.7.1725163643536; Sat, 31 Aug 2024 21:07:23 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-715e569ef39sm4828452b3a.122.2024.08.31.21.07.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:23 -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 10/18] devcon property: Document devcon_match_fn_t Date: Sat, 31 Aug 2024 21:06:48 -0700 Message-ID: <20240901040658.157425-11-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The usage of this match function is hard to understand at a glance. Document the arguments and the return value so it is clear how to implement the function. Suggested-by: Andy Shevchenko Signed-off-by: Stephen Boyd --- include/linux/property.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/include/linux/property.h b/include/linux/property.h index 61fc20e5f81f..797b1eeda7d2 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -507,8 +507,25 @@ unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); -typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, const char *id, - void *data); +/** + * devcon_match_fn_t - device connection match function + * @fwnode: Remote connection's device node + * @con_id: Identifier for the connection + * @data: Match function caller specific data + * + * Implement a callback with this function signature to search a fwnode's + * connections for a match with a function like device_connection_find_match(). + * This function will be called possibly multiple times, once for each + * connection. The match function should inspect the @fwnode to look for a + * match. The @con_id and @data provided are the same as the @con_id and @data + * arguments passed to the functions that take a devcon_match_fn_t argument. + * + * Note: This function can be called multiple times. + * + * Return: Pointer to match or NULL if no match found. + */ +typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, + const char *con_id, void *data); void *fwnode_connection_find_match(const struct fwnode_handle *fwnode, const char *con_id, void *data, From patchwork Sun Sep 1 04:06:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824610 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (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 B45E3145A06 for ; Sun, 1 Sep 2024 04:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163651; cv=none; b=bSVjkyb7IADuSoNO332LS+vtnNFjkHuv+aPBSll6IXguftfTwt/wVjccxnUhONQ/3L/J/qzIgupEGvlL1seRo5Vz7yD75vVL1FVGCywwrNeywBspQhVo0CgaV5XiWaFa0hzcRGimw1y5pRabHbDNNSNQ0LwG+U2dDd3xxovXyw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163651; c=relaxed/simple; bh=aHxbXooyxcUO5JwBCTNyqni3GmuKJP5ay9S/7oeiMaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UHW4GmmgFkbpX47J00nRXTLnHXHX/SPuhls8fpaaVxCmFfzTx9K5N372CROdBFd5YX9NiPgoEQSvQTWpy27W7RWoIZXjfu6fCfAXr7pMCcaKDZBN43I1y6SIHh4hMkLRX7BU+Tj2COrUniI5D9j4ngZnxNWfaPksPPg0ykyq8ks= 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=jqDSt4Mz; arc=none smtp.client-ip=209.85.166.173 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="jqDSt4Mz" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-39f51371baeso2861995ab.3 for ; Sat, 31 Aug 2024 21:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163648; x=1725768448; 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=lVAbaFTBXgnW+fAYVEBW9D2cgqLAHsvQgjfJBzfAY3s=; b=jqDSt4Mz/biw9kj12Y2zxy1j2029nTuT14V9Hb6g5SLODgcCJDIGRQW8bH9n0OCQXV wjbMhdMDAmjjmSDPDiDQi1uapih5tpg6sMoVRNU/Gl9dQBx5JDx+ksRyPUEQup8nHyHj gVed2iWGCP0QwN2vTUCTW5TIdDbASSI2lVjX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163648; x=1725768448; 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=lVAbaFTBXgnW+fAYVEBW9D2cgqLAHsvQgjfJBzfAY3s=; b=NpiAoCrB846fzGkHS5BzPD2GhQAGST9o3i9hEyQ4q2ukDzUJSdmSuqdYPMn/DR2hfA Qe26EDMs770e83gMaUK+9VcQFkGqAZ7fcEUa+8AL+6z3u8YJB4JKF8QzFZgElm691R4m LeTOUU3pkGPS57UUdI5xkCOI+Ltb14rrkMu3MTr4OMQ3v6DervsctT3ljPtwgVUe6UMh jqGRuWVg8IRkxmQX7XlQWpxrMCHkT5MejQ0+4A0WnaIRhRaadByBe0wuqJI3kEV3lXz9 JvSW0pXrCt43WH5rgbnlQ8LKB9GenmWm9Rg4L2UyXVqYF3r/dYsYRcVi3arPMOO+BYbO oA7g== X-Forwarded-Encrypted: i=1; AJvYcCXoKy2Rmhu1DrF7xZj4d2dO5UcJh9qPCAjRQgZTSrlTf28tX2OvXfkOT7FA1gjdMV0B0jSbBLmrod5H@vger.kernel.org X-Gm-Message-State: AOJu0YxiUxlEGKfjOJG+mcsCLYs5ZIyFo6u2Is1G+/2BzYhMlCzHbIQv J+LUSeJ0Ek/Jq1LdDO1EHVjoQKa3DdJ7k9T8qBxrGFXh1ygdFmPokfy6cETm/g== X-Google-Smtp-Source: AGHT+IFsOTewMNJ0BJt0tAvMG/AJBfDBb9as9o8BHiOu5PQfrktxWGnHk+Ahlp9K/S8f1Bq4n28w/g== X-Received: by 2002:a05:6e02:1c42:b0:39f:5646:97da with SMTP id e9e14a558f8ab-39f56469978mr14867835ab.20.1725163647832; Sat, 31 Aug 2024 21:07:27 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7d22e9d77f2sm5333884a12.89.2024.08.31.21.07.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:27 -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 , "Rob Herring (Arm)" Subject: [PATCH v4 12/18] dt-bindings: usb-switch: Extract endpoints to defs Date: Sat, 31 Aug 2024 21:06:50 -0700 Message-ID: <20240901040658.157425-13-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the usb-switch endpoint bindings to defs so that they can be reused by other bindings. Future users of this binding will have more than one type-c output node when they're muxing a single DP signal to more than one usb-c-connector. Add an example to show how this binding can be used and accelerate binding checks. Reviewed-by: Rob Herring (Arm) Cc: Krzysztof Kozlowski Cc: Conor Dooley Cc: Benson Leung Cc: Guenter Roeck Cc: Prashant Malani Cc: Tzung-Bi Shih Cc: Cc: Cc: Pin-yen Lin Signed-off-by: Stephen Boyd --- .../devicetree/bindings/usb/usb-switch.yaml | 74 +++++++++++++++---- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-switch.yaml b/Documentation/devicetree/bindings/usb/usb-switch.yaml index da76118e73a5..f5dc7e23b134 100644 --- a/Documentation/devicetree/bindings/usb/usb-switch.yaml +++ b/Documentation/devicetree/bindings/usb/usb-switch.yaml @@ -35,9 +35,12 @@ properties: $ref: /schemas/graph.yaml#/properties/ports properties: port@0: - $ref: /schemas/graph.yaml#/properties/port - description: - Super Speed (SS) Output endpoint to the Type-C connector + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + + properties: + endpoint: + $ref: '#/$defs/usbc-out-endpoint' port@1: $ref: /schemas/graph.yaml#/$defs/port-base @@ -47,16 +50,7 @@ properties: properties: endpoint: - $ref: /schemas/graph.yaml#/$defs/endpoint-base - unevaluatedProperties: false - properties: - data-lanes: - $ref: /schemas/types.yaml#/definitions/uint32-array - minItems: 1 - maxItems: 8 - uniqueItems: true - items: - maximum: 8 + $ref: '#/$defs/usbc-in-endpoint' oneOf: - required: @@ -65,3 +59,57 @@ oneOf: - ports additionalProperties: true + +$defs: + usbc-out-endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + description: Super Speed (SS) output endpoint to a type-c connector + unevaluatedProperties: false + + usbc-in-endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + description: Super Speed (SS) input endpoint from the Super Speed PHY + unevaluatedProperties: false + properties: + data-lanes: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 8 + uniqueItems: true + items: + maximum: 8 + +examples: + # A USB orientation switch which flips the pin orientation + # for a usb-c-connector node. + - | + device { + orientation-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + endpoint { + remote-endpoint = <&usb_c_connector>; + }; + }; + + port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + endpoint { + remote-endpoint = <&usb_ss_phy>; + }; + }; + }; + }; + +... From patchwork Sun Sep 1 04:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824609 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 2415A149C6E for ; Sun, 1 Sep 2024 04:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163656; cv=none; b=nLiBOKcDDaN+OH/+ly7x99Aufnzjr/Gc8Gqk8fUm/VscA9+Qhaa3o02BJl9NTHJ+djIbVCBC9vBCih7ibWFFIrtqzNE6EEjFdDSFHmXAiGNsPaGD8SwKH4Qv3OWJQcHwUFmd/BfmujKp4OX8Lr42l8y09qEk+5qwpxhxIm9ZH68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163656; c=relaxed/simple; bh=bHSm/FEpQTjOcYpuqVvRWkTQn5fPAWRWSsjkb7Wydpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rsyza4fCPno0BnAonkLBqoKkcIhHONam3FdocEeIk+0G32ulFzNFVjTk7DSelmF/Dr1rgLdcwHv+sAFdLZk5w79VSwWiLXSjLOpujDZYt/sPF8qS4x1b43r0Sno9IPqM/QkvjAy1rYn1m+rlhDkWTSV6P0OGQhWHOSNanbVaHQw= 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=MtHlbcCl; arc=none smtp.client-ip=209.85.215.181 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="MtHlbcCl" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7ae3d7222d4so2275528a12.3 for ; Sat, 31 Aug 2024 21:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163652; x=1725768452; 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=bM6GJPpKkvUSSBy7VkQZRdWnaSLWrHTVpkTkbaZHopw=; b=MtHlbcCln3qEnn2YtZXv+ZqXeEHbB4jdFtfytehXtjGGEHJImtraFeHMN6oLL/exax r0/bqu2GH9wacI9D96XovObBerMDmkRKMisuIKjjJUh6tOMldqJy9eesKPPrbTMiliy+ g7rM0713DkY3N2+/GQc79Tw32l5uIQ3gs4xdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163652; x=1725768452; 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=bM6GJPpKkvUSSBy7VkQZRdWnaSLWrHTVpkTkbaZHopw=; b=pAl+SBiiVKFm8e5jxDj6AzvHeFOZg+sgBjhTkJaEBP8ei/p4Fj9SrKpC/mi7PHSAIc Bw++CnO3V5q6Mh9gHaVOvbto2SN6t/NpCxHtDly3ZzPcS41/smY4PaCgzY8oS5WTVP09 M0T9w2lSiVmTfsF3NPCsWGjFC5/pBlRO+SwPD6QFuNGIJ0/5qbpfHc6kQKXQIUVbniW9 l6iRN9sUQgxwHRt4J4N4a/bTPgtgrJQB5JBlstHQcJp4QKIM8Lez0yedAl5O7Co5ndIi nFbclHcGrCQdGBI2HMrbpKy9XbRJ6pH6M/pSTKwnfmm3AecgLP+rrzNATWxhehMarBEu 28zQ== X-Forwarded-Encrypted: i=1; AJvYcCV8ZONbDCe3BFUBp5nEVeMBB7neAeKQvPUlHWKZqOz5FyLaax0HioBICtT5MM8L9vsiiPVEoCeP8Kds@vger.kernel.org X-Gm-Message-State: AOJu0YwysYu+XBEzutJE4y342QKaNpTNRPkEtBXe+7gnp8vqfjG4MjRK Yya7O7JyUNu3zduhRJclFlNzJ6XzqD6ps/HIE2qWTHYYqxdcuyfAXo2znSNylw== X-Google-Smtp-Source: AGHT+IEBZFVJryLmpEcn+rd/P1ffgAono4nzaKo7Lu5B6szTV31kzRn9qLEAbPf1ik2MymYrUHGCHA== X-Received: by 2002:a17:903:41cf:b0:205:489d:2b22 with SMTP id d9443c01a7336-205489d2dd3mr38959905ad.23.1725163652216; Sat, 31 Aug 2024 21:07:32 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2056595564fsm3120865ad.229.2024.08.31.21.07.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:31 -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 , "Rob Herring (Arm)" , Krzysztof Kozlowski Subject: [PATCH v4 14/18] dt-bindings: Move google,cros-ec-typec binding to usb Date: Sat, 31 Aug 2024 21:06:52 -0700 Message-ID: <20240901040658.157425-15-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This binding is about USB type-c control. Move the binding to the usb directory as it's a better home than chrome. Reviewed-by: Rob Herring (Arm) Cc: Krzysztof Kozlowski Cc: Conor Dooley Cc: Lee Jones Cc: Benson Leung Cc: Guenter Roeck Cc: Prashant Malani Cc: Tzung-Bi Shih Cc: Cc: Cc: Pin-yen Lin Suggested-by: Krzysztof Kozlowski Signed-off-by: Stephen Boyd --- Documentation/devicetree/bindings/mfd/google,cros-ec.yaml | 2 +- .../bindings/{chrome => usb}/google,cros-ec-typec.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename Documentation/devicetree/bindings/{chrome => usb}/google,cros-ec-typec.yaml (90%) diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml index aac8819bd00b..c991626dc22b 100644 --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml @@ -99,7 +99,7 @@ properties: gpio-controller: true typec: - $ref: /schemas/chrome/google,cros-ec-typec.yaml# + $ref: /schemas/usb/google,cros-ec-typec.yaml# ec-pwm: $ref: /schemas/pwm/google,cros-ec-pwm.yaml# diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml similarity index 90% rename from Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml rename to Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml index 9f9816fbecbc..365523a63179 100644 --- a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +++ b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml @@ -1,10 +1,10 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/chrome/google,cros-ec-typec.yaml# +$id: http://devicetree.org/schemas/usb/google,cros-ec-typec.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Google Chrome OS EC(Embedded Controller) Type C port driver. +title: Google ChromeOS Embedded Controller (EC) USB type-c port driver maintainers: - Benson Leung From patchwork Sun Sep 1 04:06:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824608 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 4AFF0156F33 for ; Sun, 1 Sep 2024 04:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163660; cv=none; b=ThxvI0aRG6u6BwTUjiQ/cMvf7HcjUwOfwr58EnXdm6SmXXgUDQ0NMTHDsmvZV0iR2TcGbPHcQWLmE41LsROx1vzUxYWtNsyd7gyX2NQjTHFpmG2LtKTQS6ycYUZcEfWExL4CETjGXfyXbPQ+9fqhX/YY/YSXxYmanpjWons1auo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163660; c=relaxed/simple; bh=VrN82hoQt0wLVQI0aCC1SR5A2ibWGb0NJymP0pIp9xU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C2glKdOLKRpLq60cNccgoTNMirkbTv6pyBmG0Fim7dZVX4CPKNO1vFRfJ9+qcsnbslQohqsveJqZqxrtearcU0MROZaIcolGqIG85zFxNsi/UdlbP/YABbhbIMKC9Bv8iIuEvOh+ynBbupaCrZCXtOUgGDTk9TvpCj4MJki5nu4= 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=dNqWQ8Fv; arc=none smtp.client-ip=209.85.210.170 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="dNqWQ8Fv" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-714262f1bb4so2431414b3a.3 for ; Sat, 31 Aug 2024 21:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163656; x=1725768456; 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=lp4qb/KS90Tir3i25BqLGfP+MrbWuhnQKUX2LR6B8LU=; b=dNqWQ8FvRRcyt/vhqfHfNSL4Oo29DaIIRpF41DHFYeGRuH3GGDKyFx7zhZb1HOrFwk 4sKlTE0zPdh1UrkpNx0C4bCgAdHE/9Ga+o7FTWGw6b8hsITjURZbh/X1wzJgw7XZI2KV lQv8L/B+otZvjhKkmR/nuWpq+Q6JFoUbpPUnc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163656; x=1725768456; 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=lp4qb/KS90Tir3i25BqLGfP+MrbWuhnQKUX2LR6B8LU=; b=Bi1t3arv7deUqXPaoEVz9i94NnXDUv1vi9ccs/ftos1IHFjaRem/J+SMISs1Ugffrd heDuszQIiEQ1+B6hPcsd0F3965wVjz2akAFxzkfZXEgknWQBuYkVuvXcLXXR0s6FcOs2 RloIL4PGm1/051oZaCI3cu5QAmMAdpuvXOMkMtsA6Tgas1HOAIOhu+7Y1NahUwVy6f7Q WQ6KelpexKX+yHigM60vw5lISuQF6k7PUQwU6hnKXty/DShmAgVuOyqKqU40M57QpxAZ f8JrqZSyYyoVikyD5W5YDrrZZ+zfZ82udlIyrrZ1X8bEv3AIilO+NOLikb0401cPMWsa nGJQ== X-Forwarded-Encrypted: i=1; AJvYcCVzHCHwm6R/lYfXaZNs4fInX7qI1zy0gPsxdwSpIG39HtjpqJHQjXhol0YwCeHIDDD2ZlSHYE5cxb2s@vger.kernel.org X-Gm-Message-State: AOJu0Yzgnb2WiGgKZyiGdODT72Ciu5J2rRrhp/21JBJWin3IA3TQ+9P1 p1bEFBWOtGQZtviGUIP31AFKbLmNxt2gMuOH7t1/5vBPouqXuEC8ehMM0rTHog== X-Google-Smtp-Source: AGHT+IE8Kiz0yS+drOGbUHSHPEFKkSlIzC8nDgi3dGGbxuwIctLm8xLCZLhIj6Ez6yfo2U5IiO9Iyw== X-Received: by 2002:a05:6a21:3a93:b0:1c0:e49a:6900 with SMTP id adf61e73a8af0-1cece4d7233mr3894641637.7.1725163656376; Sat, 31 Aug 2024 21:07:36 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d8445d5ea9sm9130058a91.8.2024.08.31.21.07.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:36 -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 16/18] platform/chrome: cros_ec_typec: Add support for signaling DP HPD via drm_bridge Date: Sat, 31 Aug 2024 21:06:54 -0700 Message-ID: <20240901040658.157425-17-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We can imagine that logically the EC is a device that has some number of DisplayPort (DP) connector inputs, some number of USB3 connector inputs, and some number of USB type-c connector outputs. If you squint enough it looks like a USB type-c dock. Logically there's a crossbar pin assignment capability within the EC that can assign USB and DP lanes to USB type-c lanes in the connector (i.e. USB type-c pin configurations). In reality, the EC is a microcontroller that has some TCPCs and redrivers connected to it over something like i2c and DP/USB from the AP is wired directly to those ICs, not the EC. This design allows the EC to abstract many possible USB and DP hardware configurations away from the AP (kernel) so that the AP can largely deal with USB and DP without thinking about USB Type-C much at all. The DP and USB data originate in the AP, not the EC, so it helps to think that the EC takes the DP and USB data as input to mux onto USB type-c ports even if it really doesn't do that. With this split design, the EC forwards the DP HPD state to the DP hardware via a GPIO that's connected to the DP phy. Having that HPD state signaled directly to the DP phy uses precious hardware resources, a pin or two and a wire, and it also forces the TCPM to live on the EC. If we want to save costs and move more control of USB type-c to the kernel it's in our interest to get rid of the HPD pin entirely and signal HPD to the DP phy some other way. Luckily, the EC already exposes information about the USB Type-C stack to the kernel via the host command interface in the "google,cros-ec-typec" compatible driver, which parses EC messages related to USB type-c and effectively "replays" those messages to the kernel's USB typec subsystem. This includes the state of HPD, which can be interrogated and acted upon by registering a 'struct typec_mux_dev' with the typec subsystem or by hooking directly into this cros_ec_typec driver. On DT based systems, the DP display pipeline is abstracted via a 'struct drm_bridge'. If we want to signal HPD state from within the kernel we need to hook into the drm_bridge framework somehow to call drm_bridge_hpd_notify() when HPD state changes in the typec framework. Use the newly added drm_dp_typec_bridge code to do this. When the EC notifies AP of a type-c event, look at the port state and set the connector state to connected or disconnected based on the HPD level when the port is in DP mode. Luckily all this logic is already handled by the drm_dp_typec bridge. Register a bridge when this DT node has the 'mode-switch' property. When cros_typec_configure_mux() puts a port into DP mode, the mode switch registered in the drm_dp_typec bridge driver will signal HPD state to the drm_bridge chain because the typec subsystem will configure the usbc switches connected to the port with the data this driver provides. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Signed-off-by: Stephen Boyd Reviewed-by: Tzung-Bi Shih --- drivers/platform/chrome/Kconfig | 1 + drivers/platform/chrome/cros_ec_typec.c | 31 +++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.h | 1 + 3 files changed, 33 insertions(+) diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 7dbeb786352a..0aee8a77f1d6 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -231,6 +231,7 @@ config CROS_EC_TYPEC depends on MFD_CROS_EC_DEV && TYPEC depends on CROS_USBPD_NOTIFY depends on USB_ROLE_SWITCH + select DRM_AUX_HPD_BRIDGE if DRM_BRIDGE && OF default MFD_CROS_EC_DEV help If you say Y here, you get support for accessing Type C connector diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 4d305876ec08..a57053bdec18 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,8 @@ #include #include +#include + #include "cros_ec_typec.h" #include "cros_typec_vdm.h" @@ -334,6 +337,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--; if (nports == 0) { dev_err(dev, "No port entries found.\n"); return -ENODEV; @@ -347,6 +353,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; + if (fwnode_property_read_u32(fwnode, port_prop, &port_num)) { ret = -EINVAL; dev_err(dev, "No port-number for port, aborting.\n"); @@ -413,6 +423,23 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return ret; } +static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) +{ + struct device *dev = typec->dev; + struct drm_dp_typec_bridge_dev *dp_dev; + + /* Not capable of DP altmode switching. Ignore. */ + if (!fwnode_property_read_bool(dev_fwnode(dev), "mode-switch")) + return 0; + + dp_dev = devm_drm_dp_typec_bridge_alloc(dev, dev->of_node); + if (IS_ERR(dp_dev)) + return PTR_ERR(dp_dev); + typec->dp_bridge = dp_dev; + + return devm_drm_dp_typec_bridge_add(dev, dp_dev); +} + static int cros_typec_usb_safe_state(struct cros_typec_port *port) { int ret; @@ -1257,6 +1284,10 @@ static int cros_typec_probe(struct platform_device *pdev) typec->num_ports = EC_USB_PD_MAX_PORTS; } + ret = cros_typec_init_dp_bridge(typec); + if (ret < 0) + return ret; + ret = cros_typec_init_ports(typec); if (ret < 0) return ret; diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h index deda180a646f..eb816d30d880 100644 --- a/drivers/platform/chrome/cros_ec_typec.h +++ b/drivers/platform/chrome/cros_ec_typec.h @@ -35,6 +35,7 @@ struct cros_typec_data { unsigned int pd_ctrl_ver; /* Array of ports, indexed by port number. */ struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; + struct drm_dp_typec_bridge_dev *dp_bridge; struct notifier_block nb; struct work_struct port_work; bool typec_cmd_supported; From patchwork Sun Sep 1 04:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 824607 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 0989616EC1B for ; Sun, 1 Sep 2024 04:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163663; cv=none; b=ntgbPI+hrrF6J+018LHHIWTXCwPwjPOvGPJEXhxvNBm4a5t3quS2zIkwworbgi4o6FHSavSLuNDNkpU2+zn6nmaGfXzw/LC7NDes+cQjihZTfIHuNzQ5Ulo7cZBKUGS2G53Bb4BrVffHZbEl4uimv6vB8HIlnBfR0O2iqpkeKpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725163663; c=relaxed/simple; bh=P5j7Fr9LGu/zW4lsyx25BQTDaO9/OJeLxNTA5aeJAcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NlcPZdVDt0+lgXLs8G8xP41tMY72uAnFTSKNceknzFt5aQG0oh6HLfZ89Y5QS75UenN30oFTz8Jo5Yh/jx6L+7JJ3FOBhuxuLCvCkfkq8wnniPwz9M1r9bmgcRKgryjOw/X40MyB06UKNpyBuGiavf4WKH0cQ14yFal5iiUqaU0= 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=ee6LlgHa; arc=none smtp.client-ip=209.85.160.46 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="ee6LlgHa" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-277e4327c99so179416fac.0 for ; Sat, 31 Aug 2024 21:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725163660; x=1725768460; 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=YAnr/CInUuanIGWaUDroB3xFD+9prT3yLYHDcJ6D0Bo=; b=ee6LlgHaGVqQRT8JyDtXEOZvOfyLA0jJVUjmnBFK6A9W2slezUpeL06d7pwIc2Pba8 kl9w9ZDiOawTFfPRoyDGiq1ojlWyMV91zkuLYi03gkwlzmCAz7ob55upzZbnF1+fT25q n7/bFUWfyAOqFU/EldPqXJcBhl4CyhHBBnJXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725163660; x=1725768460; 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=YAnr/CInUuanIGWaUDroB3xFD+9prT3yLYHDcJ6D0Bo=; b=HM3PBK5uIksYxirYm9wCqyWWCUQZdwnA4s8+ZdpwZwPHIemR3JwHhRjtz0YCP7mYwX 66jU5216n6jvcG9A5rlxZu5oVBRaUGhJ1gqOV+yorwqixOlbNXOUvTW0yc8OxVoVFlIe AWRurC2Dt4HF7Ayz3MCbqzk3lnrBotIT9HMWqVV+zBtxnMQLT8zfjw1rMAlpDtrVEQqT /rEtQAVZoWverNG/MrFTjB9BCb0tAj9N1kHpg5V8q9qxoiTVKydmS+yfGfbBxqXVr+6y 6j+ms9ho4i1Ix5QdSigW4+FtCB9Gfn7567Psk384Wq3yWAD/pqevh5JN5twUnY9QhLJn Z9KA== X-Forwarded-Encrypted: i=1; AJvYcCVOtzbBX4iK5LzcnW9TKr2oBZPXl+b0YCtRh8u6NNUgFwT1B92QGYWMbk5BkG/n9yewOz1JMuwf9hFd@vger.kernel.org X-Gm-Message-State: AOJu0YxAqugcqOoBH8lJm7ix5ozdbhiEWVtZ3w9aELaqjnxuZW6C998+ b2JkqsnLmLB9C0+2hQlxisZlOP88tzNiutTYLYqpNvDM2yo0Bo7fMlG8NNMvpg== X-Google-Smtp-Source: AGHT+IEJat/MH0aH5PxrzEOzEVWfG27VMiaK42He6BskeDGxOOCnFMowYgglO9wA7c39ubb74K4njg== X-Received: by 2002:a05:6870:c14c:b0:25e:d62:f297 with SMTP id 586e51a60fabf-277d06c6446mr3278885fac.45.1725163660389; Sat, 31 Aug 2024 21:07:40 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-715e55aa11fsm4854824b3a.85.2024.08.31.21.07.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 21:07:40 -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 18/18] platform/chrome: cros_ec_typec: Handle lack of HPD information Date: Sat, 31 Aug 2024 21:06:56 -0700 Message-ID: <20240901040658.157425-19-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 a type-c port has entered or exited DP mode. To make matters worse, on these boards the DP signal is muxed between two USB type-c connectors, so we can't use the DP entry of a port to figure out which type-c port is actually displaying DP. Stash the HPD state in this case whenever the drm_bridge is notified of a connector status change and kick off the port worker so that the type-c port state can be re-evaluated. If an analog mux is in use, read the mux to figure out which type-c port signaled HPD. Once we know which port is actually signaling HPD, inject that state into the message received from the EC. This simplifies the rest of the logic as it can all stay the same with respect to picking the first port to assert HPD, etc. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_ec_typec.c | 74 +++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.h | 2 + 2 files changed, 76 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 57d1484ce1ef..731b485634af 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -423,6 +424,17 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return ret; } +static void cros_typec_dp_bridge_hpd_notify(void *data, enum drm_connector_status status) +{ + struct cros_typec_data *typec = data; + + /* Proxy the connector status as the HPD state to replay later. */ + typec->hpd_asserted = status == connector_status_connected; + + /* Refresh port state. */ + schedule_work(&typec->port_work); +} + static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) { struct device *dev = typec->dev; @@ -432,9 +444,17 @@ static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) if (!fwnode_property_read_bool(dev_fwnode(dev), "mode-switch")) return 0; + typec->mux_gpio = devm_gpiod_get_optional(dev, "mux", GPIOD_ASIS); + if (IS_ERR(typec->mux_gpio)) + return dev_err_probe(dev, PTR_ERR(typec->mux_gpio), "failed to get mux gpio\n"); + dp_dev = devm_drm_dp_typec_bridge_alloc(dev, dev->of_node); if (IS_ERR(dp_dev)) return PTR_ERR(dp_dev); + + if (fwnode_property_read_bool(dev_fwnode(dev), "no-hpd")) + drm_dp_typec_bridge_add_hpd_notify(dp_dev, cros_typec_dp_bridge_hpd_notify, typec); + typec->dp_bridge = dp_dev; return devm_drm_dp_typec_bridge_add(dev, dp_dev); @@ -635,6 +655,59 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec, return typec_mux_set(port->mux, &port->state); } +/* + * Some ECs don't notify AP when HPD goes high or low because their firmware is + * broken. Capture the state of HPD in cros_typec_dp_bridge_hpd_notify() and + * inject the asserted state into the EC's response (deasserted is the + * default). + */ +static void cros_typec_inject_hpd(struct cros_typec_data *typec, + struct ec_response_usb_pd_mux_info *resp, + struct cros_typec_port *port) +{ + struct gpio_desc *mux_gpio = typec->mux_gpio; + int val; + + /* Never registered a drm_bridge. Skip. */ + if (!typec->dp_bridge) + return; + + /* Don't need to inject HPD level when DP isn't enabled. */ + if (!(resp->flags & USB_PD_MUX_DP_ENABLED)) + return; + + /* + * The default setting is HPD deasserted. Ignore if nothing to inject. + */ + if (!typec->hpd_asserted) + return; + + /* + * Only read the mux GPIO setting if we need to change the active port. + * Otherwise, an active port is already set and HPD going high or low + * doesn't change the muxed port until DP mode is exited. + */ + if (!typec->active_dp_port) { + if (mux_gpio) { + val = gpiod_get_value_cansleep(mux_gpio); + if (val < 0) { + dev_err(typec->dev, "Failed to read mux gpio\n"); + return; + } + /* Ignore HPD changes for non-active port. */ + if (typec->ports[val] != port) + return; + } + } else if (port != typec->active_dp_port) { + /* Ignore HPD changes for non-active port. */ + return; + } + + /* Inject HPD from the GPIO state if EC firmware is broken. */ + if (typec->hpd_asserted) + resp->flags |= USB_PD_MUX_HPD_LVL; +} + static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, struct ec_response_usb_pd_control_v2 *pd_ctrl) { @@ -656,6 +729,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, port_num, ret); return ret; } + cros_typec_inject_hpd(typec, &resp, port); /* No change needs to be made, let's exit early. */ if (port->mux_flags == resp.flags && port->role == pd_ctrl->role) diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h index f3a2b67df07c..4ccd3d014aa6 100644 --- a/drivers/platform/chrome/cros_ec_typec.h +++ b/drivers/platform/chrome/cros_ec_typec.h @@ -37,6 +37,8 @@ struct cros_typec_data { struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; struct drm_dp_typec_bridge_dev *dp_bridge; struct cros_typec_port *active_dp_port; + struct gpio_desc *mux_gpio; + bool hpd_asserted; struct notifier_block nb; struct work_struct port_work; bool typec_cmd_supported;