From patchwork Fri Nov 3 23:03:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DDAAC4167B for ; Fri, 3 Nov 2023 23:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7VH7Vf4i+DZHtvyZWBzKOddPkjCa+lMH9MbvB4MgUfg=; b=hZpHEgCqz31HfO mBUIwWIRAtpyDlleKTWzwMI0Hq+SYo8wFPKNC+qbYiN6xxTJP/a29RzYvLh7ctEdxt3o4rfcJhFo2 Sacrtyx5In/m0EbmsrbVQATDiFohE4VbHB1GDTBw46YmWYf/RtRJDQ3umBHLzxkxAH9UeXYPdjO8M Z9CkWA0cQ2OhbkZVQKF665/xse7q26T+hF2F8yfZkgdjen/YUHmGsIoc+w6uAX/XOOJGjcQzZMpXa x0rSnbn5jqQKy86iNAsJa0mvHUHvsoOc5xq/5ir4HXlqes31rrTUaosKxAh0UOerkNinBULeF0iQZ sN1Uy2+5FJ16MQbceO0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DC-00CIKO-2a; Fri, 03 Nov 2023 23:04:22 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3D9-00CII5-33 for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:21 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507a29c7eefso3219290e87.1 for ; Fri, 03 Nov 2023 16:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052656; x=1699657456; darn=lists.infradead.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=sArdhuc4iKCJ+mSoLILv4KY0dReGLNYPv+iFk9YYQww=; b=McJL3d+ZrPm5X9hSzYsMJFk0QBPk899QaGGoO5Q1b783HR6VucooGCYRZzWmeYmVEK nCR2ecIOVKv1bHr8hlqg8azga4pXHIT+kj/2Ss96Sa76heqL/2O+MSRYsClobgqeUvYD ehhKjmkIoy3nvSOnYlLm3eguPnBSD12JU/JeN2p2z4HSM4wKgTlAvd0pLxbBZmBeF6lk z0Gi6LGUYVu71dGiJsouf5lZXjmx4keWHGumnuM6eGYyQUjMwIJRaoQsUV2yUota51a2 JNx3kym2SDpvgnSxydnYUWqHwqjmV+NYaLC81sDT4Y41KoAWK1+Ag5DkhlSKE6CfigVL VfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052656; x=1699657456; 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=sArdhuc4iKCJ+mSoLILv4KY0dReGLNYPv+iFk9YYQww=; b=V2b+wILdmMLfhLiB0tjlFfPzEMCmo0KS/9y4ki5UL9EcLdrA3Ge+uab/Y1tFZKg3RU a6KModzzg5r/vpwWl/IZwslBcTEumOLK8XHFH8+TosK8LLlIKzzrtohYocTsQHDrEfOu olyg4wLuG4eIuDKIJPRaHZt65kq/BxP49Eq2oMERNHjoplQGpgRYekbG9bzKL5QtfbUq JdA6mk+q0UPMPCCF2X19BedLScZ1X7flq7Tj1+PCf9jZQjqyOnjlERLbHQlhQwwVurLH vCT6qHjhny0yXqeAOj7hUl4sGeRPrcAtnKRAusNKjss1Pb4cXskhV+Fo5HETclRm3OmV YNIA== X-Gm-Message-State: AOJu0Yx5K7ADIOY+ZhVagdjX7ldJIpVXo0CryUzgRJlY/Gfx3W2JSJUm jV7NVgRDWauQ3sK35Uy7t0elYA== X-Google-Smtp-Source: AGHT+IE9dnjxZxbeV8kKqyR5qa4QpyGPBUa0tjpEKAQyAG5+VEh3n3NzA5xd3h4myvqQJzJxne+4cA== X-Received: by 2002:a05:6512:3d17:b0:509:4b04:6345 with SMTP id d23-20020a0565123d1700b005094b046345mr5207600lfv.0.1699052655785; Fri, 03 Nov 2023 16:04:15 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:15 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 1/6] drm/bridge: add transparent bridge helper Date: Sat, 4 Nov 2023 01:03:04 +0200 Message-ID: <20231103230414.1483428-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160420_040385_0115F603 X-CRM114-Status: GOOD ( 20.14 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Define a helper for creating simple transparent bridges which serve the only purpose of linking devices into the bridge chain up to the last bridge representing the connector. This is especially useful for DP/USB-C bridge chains, which can span across several devices, but do not require any additional functionality from the intermediate bridges. Signed-off-by: Dmitry Baryshkov Reviewed-by: Neil Armstrong --- drivers/gpu/drm/bridge/Kconfig | 9 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/aux-bridge.c | 140 ++++++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 19 ++++ 4 files changed, 169 insertions(+) create mode 100644 drivers/gpu/drm/bridge/aux-bridge.c create mode 100644 include/drm/bridge/aux-bridge.h diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index ba82a1142adf..f12eab62799f 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -12,6 +12,15 @@ config DRM_PANEL_BRIDGE help DRM bridge wrapper of DRM panels +config DRM_AUX_BRIDGE + tristate + depends on DRM_BRIDGE && OF + select AUXILIARY_BUS + select DRM_PANEL_BRIDGE + help + Simple transparent bridge that is used by several non-DRM drivers to + build bridges chain. + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 2b892b7ed59e..918e3bfff079 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o obj-$(CONFIG_DRM_CHIPONE_ICN6211) += chipone-icn6211.o obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o diff --git a/drivers/gpu/drm/bridge/aux-bridge.c b/drivers/gpu/drm/bridge/aux-bridge.c new file mode 100644 index 000000000000..6245976b8fef --- /dev/null +++ b/drivers/gpu/drm/bridge/aux-bridge.c @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Linaro Ltd. + * + * Author: Dmitry Baryshkov + */ +#include +#include + +#include +#include + +static DEFINE_IDA(drm_aux_bridge_ida); + +static void drm_aux_bridge_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + + ida_free(&drm_aux_bridge_ida, adev->id); + + kfree(adev); +} + +static void drm_aux_bridge_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +/** + * drm_aux_bridge_register - Create a simple bridge device to link the chain + * @parent: device instance providing this bridge + * + * Creates a simple DRM bridge that doesn't implement any drm_bridge + * operations. Such bridges merely fill a place in the bridge chain linking + * surrounding DRM bridges. + * + * Return: zero on success, negative error code on failure + */ +int drm_aux_bridge_register(struct device *parent) +{ + struct auxiliary_device *adev; + int ret; + + adev = kzalloc(sizeof(*adev), GFP_KERNEL); + if (!adev) + return -ENOMEM; + + ret = ida_alloc(&drm_aux_bridge_ida, GFP_KERNEL); + if (ret < 0) { + kfree(adev); + return ret; + } + + adev->id = ret; + adev->name = "aux_bridge"; + adev->dev.parent = parent; + adev->dev.of_node = parent->of_node; + adev->dev.release = drm_aux_bridge_release; + + ret = auxiliary_device_init(adev); + if (ret) { + ida_free(&drm_aux_bridge_ida, adev->id); + kfree(adev); + return ret; + } + + ret = auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(parent, drm_aux_bridge_unregister_adev, adev); +} +EXPORT_SYMBOL_GPL(drm_aux_bridge_register); + +struct drm_aux_bridge_data { + struct drm_bridge bridge; + struct drm_bridge *next_bridge; + struct device *dev; +}; + +static int drm_aux_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct drm_aux_bridge_data *data; + + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) + return -EINVAL; + + data = container_of(bridge, struct drm_aux_bridge_data, bridge); + + return drm_bridge_attach(bridge->encoder, data->next_bridge, bridge, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); +} + +static const struct drm_bridge_funcs drm_aux_bridge_funcs = { + .attach = drm_aux_bridge_attach, +}; + +static int drm_aux_bridge_probe(struct auxiliary_device *auxdev, + const struct auxiliary_device_id *id) +{ + struct drm_aux_bridge_data *data; + + data = devm_kzalloc(&auxdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->dev = &auxdev->dev; + data->next_bridge = devm_drm_of_get_bridge(&auxdev->dev, auxdev->dev.of_node, 0, 0); + if (IS_ERR(data->next_bridge)) + return dev_err_probe(&auxdev->dev, PTR_ERR(data->next_bridge), + "failed to acquire drm_bridge\n"); + + data->bridge.funcs = &drm_aux_bridge_funcs; + data->bridge.of_node = data->dev->of_node; + + return devm_drm_bridge_add(data->dev, &data->bridge); +} + +static const struct auxiliary_device_id drm_aux_bridge_table[] = { + { .name = KBUILD_MODNAME ".aux_bridge" }, + {}, +}; +MODULE_DEVICE_TABLE(auxiliary, drm_aux_bridge_table); + +static struct auxiliary_driver drm_aux_bridge_drv = { + .name = "aux_bridge", + .id_table = drm_aux_bridge_table, + .probe = drm_aux_bridge_probe, +}; +module_auxiliary_driver(drm_aux_bridge_drv); + +MODULE_AUTHOR("Dmitry Baryshkov "); +MODULE_DESCRIPTION("DRM transparent bridge"); +MODULE_LICENSE("GPL"); diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridge.h new file mode 100644 index 000000000000..441ab3f0e920 --- /dev/null +++ b/include/drm/bridge/aux-bridge.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Linaro Ltd. + * + * Author: Dmitry Baryshkov + */ +#ifndef DRM_AUX_BRIDGE_H +#define DRM_AUX_BRIDGE_H + +#if IS_ENABLED(CONFIG_DRM_AUX_BRIDGE) +int drm_aux_bridge_register(struct device *parent); +#else +static inline int drm_aux_bridge_register(struct device *parent) +{ + return 0; +} +#endif + +#endif From patchwork Fri Nov 3 23:03:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E46AC4332F for ; Fri, 3 Nov 2023 23:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g7jBEGG8+XOIgcTqGsZKtR//JLrEnj/5JPWbfrLKSAY=; b=2AwKNO+bn6ljv4 g911emRyKPgfetPielUySUSITz+0I3WP4wnnlAKcbwCHKw2e1Qm6dwnEhnpkx5o3czEL7+TheuLcO aeBqo/B9skyg2Yu8XcwmIMRSuiWkGSr50UXW3C0i076c0DaKiH8aaVKe7zWFkHEKfHXwVkLl+L+FR jfeoorzq3M1xi18vn3YW+gXNOtpykqzQDsarW/b1eo0c9aEfHQ3t808f8UdG8GpcmfxJia4hQ/Ngx aRtVusegPBU/05VQukUSykddCfuKLEY/Q5d7eTtoBIM2cVhbCwYgzpsbIk6B+hc0rMneTfq+TVYum knIRy6oLiihVXsWVAZVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DF-00CINC-0V; Fri, 03 Nov 2023 23:04:25 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DA-00CII7-2W for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:22 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-507b96095abso3207920e87.3 for ; Fri, 03 Nov 2023 16:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052657; x=1699657457; darn=lists.infradead.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=WpVPinR5JJuEeMOpQArxArU49/SliqoIXWUtACV29KQ=; b=yWEH/I1P3gQI8RzfdWojusaw8bry3rQR999NTA5KacpDVaHetZbOCkOcInkyCL5UyH bQoCgmt+zXV4mSrKQBdhEUnogPVVBZCZgc9iuTQTB+oIY26VD5nm+fvkcz1dUnCA0OeV TH1vfZ+vKaHVOAXV9vcH2PV/S3I1F6pna8NaF43n9zigo5+F2AjRrrqdlZRXSAb/qRoE SzEN2199GlU9DCIW9h4e93RF2LrQhyN7nCn107bLoxwZ4H+UQGyNmUAHSL2J4UhvgG3N d1THzta8CgoeY0iu/iv71iZWu4esAg3mM7T7bqZf5MsRpVU7Q+qEMEzY1k7Ndgx92NlR r18Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052657; x=1699657457; 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=WpVPinR5JJuEeMOpQArxArU49/SliqoIXWUtACV29KQ=; b=oFpgIP4XCz/FBfUZs++VmtSTkfKXe/dpfxW01K4XhyF23PAzvLbhEE+1qb+XBoXd2p ItBprc/WoSnUPtXHxj1qzWF7MzdIa6YEMrdvQpOQouhO5RjgbFJM17jZrF+hVO0/fnkO hGXui1KXi/vKICfoIZR1grFmIBr5BnrOChlmXSp8xM9OjImtLFYhvdfEC8pdPNX2EuYh oVRjWe7DhQitjiymXwXIK0gK3M8JZbHGc9rWaFiW5erJFJ0ZJsGwYUzqaOIrGI5TvdRu gEgpwGoWKqR/p576NQqvNECesUewmtK9a+UlArweqRulhdTbRntePBs5F/ejOz3r69f4 uCGA== X-Gm-Message-State: AOJu0Yx7i58sxve1GJW09JYP5jJy6WLap7WuKQwXFjxKN+OgXonL1mC+ TS1on+vIXHIo6su1SLaOOCUumQ== X-Google-Smtp-Source: AGHT+IHvsMcFRimtIqs70PogZv3pY0X/qrtJvG1Y/saD+HgZbSHLfL0rPV4GDrhn+e+zvvM+C5JD6A== X-Received: by 2002:ac2:5234:0:b0:509:49cc:aa35 with SMTP id i20-20020ac25234000000b0050949ccaa35mr4674865lfl.45.1699052656838; Fri, 03 Nov 2023 16:04:16 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:16 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 2/6] phy: qcom: qmp-combo: switch to DRM_AUX_BRIDGE Date: Sat, 4 Nov 2023 01:03:05 +0200 Message-ID: <20231103230414.1483428-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160420_822183_2CEAD9A6 X-CRM114-Status: GOOD ( 14.81 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Switch to using the new DRM_AUX_BRIDGE helper to create the transparent DRM bridge device instead of handcoding corresponding functionality. Acked-by: Vinod Koul Signed-off-by: Dmitry Baryshkov --- drivers/phy/qualcomm/Kconfig | 2 +- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 44 ++--------------------- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/drivers/phy/qualcomm/Kconfig b/drivers/phy/qualcomm/Kconfig index d891058b7c39..846f8c99547f 100644 --- a/drivers/phy/qualcomm/Kconfig +++ b/drivers/phy/qualcomm/Kconfig @@ -63,7 +63,7 @@ config PHY_QCOM_QMP_COMBO depends on DRM || DRM=n select GENERIC_PHY select MFD_SYSCON - select DRM_PANEL_BRIDGE if DRM + select DRM_AUX_BRIDGE if DRM_BRIDGE help Enable this to support the QMP Combo PHY transceiver that is used with USB3 and DisplayPort controllers on Qualcomm chips. diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 9c87845c78ec..f6c727249104 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include @@ -1419,8 +1419,6 @@ struct qmp_combo { struct clk_hw dp_link_hw; struct clk_hw dp_pixel_hw; - struct drm_bridge bridge; - struct typec_switch_dev *sw; enum typec_orientation orientation; }; @@ -3191,44 +3189,6 @@ static int qmp_combo_typec_switch_register(struct qmp_combo *qmp) } #endif -#if IS_ENABLED(CONFIG_DRM) -static int qmp_combo_bridge_attach(struct drm_bridge *bridge, - enum drm_bridge_attach_flags flags) -{ - struct qmp_combo *qmp = container_of(bridge, struct qmp_combo, bridge); - struct drm_bridge *next_bridge; - - if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) - return -EINVAL; - - next_bridge = devm_drm_of_get_bridge(qmp->dev, qmp->dev->of_node, 0, 0); - if (IS_ERR(next_bridge)) { - dev_err(qmp->dev, "failed to acquire drm_bridge: %pe\n", next_bridge); - return PTR_ERR(next_bridge); - } - - return drm_bridge_attach(bridge->encoder, next_bridge, bridge, - DRM_BRIDGE_ATTACH_NO_CONNECTOR); -} - -static const struct drm_bridge_funcs qmp_combo_bridge_funcs = { - .attach = qmp_combo_bridge_attach, -}; - -static int qmp_combo_dp_register_bridge(struct qmp_combo *qmp) -{ - qmp->bridge.funcs = &qmp_combo_bridge_funcs; - qmp->bridge.of_node = qmp->dev->of_node; - - return devm_drm_bridge_add(qmp->dev, &qmp->bridge); -} -#else -static int qmp_combo_dp_register_bridge(struct qmp_combo *qmp) -{ - return 0; -} -#endif - static int qmp_combo_parse_dt_lecacy_dp(struct qmp_combo *qmp, struct device_node *np) { struct device *dev = qmp->dev; @@ -3440,7 +3400,7 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) return ret; - ret = qmp_combo_dp_register_bridge(qmp); + ret = drm_aux_bridge_register(dev); if (ret) return ret; From patchwork Fri Nov 3 23:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2D8CC0018A for ; Fri, 3 Nov 2023 23:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zm0JAAizA/WCaHi25HdleXKZ0a+hbsVjtE1jmeBUFL8=; b=Gopy17NaOTxPtA AZa5ClNGYYhLGwkJA5wFs3pPi1jJrjVpIsqhMdVHRwy9PURgrsWRB26gbg/SB1w+8W7P4NTRMgUa4 c7R8nNAUdUwl56iL//txP14J4iM5uPDEYldc9KvN1wBL4sf/1FEDAs6l07semJoLl17n79vxOsj12 ROmXWMxC3UEx+iWGpcXljwl3WyMN62oJm8at0oYxaouggy1LA6ueSH9nw2VNNBhXDh9+MjNUKy7Eb hb29EaZNmowVrFqlli5gMIx1pk/Zp/ft85DgWZX5tbEyoYJNXVcnOPY/KhN75G/WUTAIGp9lBaIQ2 vJwg0SdkAP445wpJUpyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DF-00CINq-1T; Fri, 03 Nov 2023 23:04:25 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DA-00CIIe-30 for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:23 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c6ed1b9a1cso34518741fa.3 for ; Fri, 03 Nov 2023 16:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052658; x=1699657458; darn=lists.infradead.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=BbnyjLnhACt82EK09moKdpQ9JIR1p/S627vZZk1uJi8=; b=iBcqY5AuMVAAzYPUvz5bUQiGdijHg5MRRBpD5AQaoIh44cwtj3ynUMOSoACTUF8DvO OT6qDYVMxJnHHoNbGXweh4NcTcP3Vu4L4wyzF7PiJvRcrBEW2MKXNahkemqrkGWCiRiD eHM1emTyF9l2p4HjJDoVdVZNNVjchBoPdrRNrk6Nmtu0qwQ43xJWKIYZ3GsoVUqEUzvq E+rItdvB8DlnBbLEFciygxMKrU4wjz6APonzVwj8bILe6mz28rouJ0bIOCM3nm4nDAO3 LBsMagfpla67zBiucP1Tjjx7a78VLrM6n/ajMmHfXNGhUbFA4KGHny+SZWqIMtO/3kPb aXEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052658; x=1699657458; 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=BbnyjLnhACt82EK09moKdpQ9JIR1p/S627vZZk1uJi8=; b=Pu0Zbx6/QIlVJwAIZweEEIbwu0+c32wKc1J7F1HerdTe+7i09bsQmwJ/yob7XDOBaw UD5WAR0XM27HYPV6pUCXpwfyu7f+ntpKo6yz+XX/C2ggFbTSOoQoioXMjEHVFRQWps+V GFTsACx3BdZeKmq2QFy4cQ05p4sF3GUTFNabFJva0cgSHOrupzA1ZuI0+Yhizz9l8X3J OwrLSVIxwX7xPft1/rAjW4NkIq0sicKXcDN50KXJdodNWteML9vsjJ1YNlgxUAzCMLtx JCfrnOr3kLoIgq51+j8xhUar03uEuRZoSBdV7s8EM+gttMz6aIHxaae4km4NleWCZe68 k6Xw== X-Gm-Message-State: AOJu0YwdFiLsKgcskz+eyNO+5UxfMt1V6fUgT3LTbYou4IGEaF+f9PZQ NUAoxIjv+KMsE65AH6oVcnJJyA== X-Google-Smtp-Source: AGHT+IFqLlK/VkY8KRBbE5SnY0oiABjf4RxnnYmH4Ttg9LlJ/9dJpbi7xVLHM1tu4o89tmLTxoXKkA== X-Received: by 2002:ac2:47fb:0:b0:507:b8e1:76f0 with SMTP id b27-20020ac247fb000000b00507b8e176f0mr15445608lfp.22.1699052657967; Fri, 03 Nov 2023 16:04:17 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:17 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 3/6] usb: typec: nb7vpq904m: switch to DRM_AUX_BRIDGE Date: Sat, 4 Nov 2023 01:03:06 +0200 Message-ID: <20231103230414.1483428-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160420_968696_286A1C9E X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Switch to using the new DRM_AUX_BRIDGE helper to create the transparent DRM bridge device instead of handcoding corresponding functionality. Reviewed-by: Heikki Krogerus Acked-by: Greg Kroah-Hartman Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/mux/Kconfig | 2 +- drivers/usb/typec/mux/nb7vpq904m.c | 44 ++---------------------------- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index 65da61150ba7..07395161dd30 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -40,7 +40,7 @@ config TYPEC_MUX_NB7VPQ904M tristate "On Semiconductor NB7VPQ904M Type-C redriver driver" depends on I2C depends on DRM || DRM=n - select DRM_PANEL_BRIDGE if DRM + select DRM_AUX_BRIDGE if DRM_BRIDGE select REGMAP_I2C help Say Y or M if your system has a On Semiconductor NB7VPQ904M Type-C diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c index cda206cf0c38..b17826713753 100644 --- a/drivers/usb/typec/mux/nb7vpq904m.c +++ b/drivers/usb/typec/mux/nb7vpq904m.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -70,8 +70,6 @@ struct nb7vpq904m { bool swap_data_lanes; struct typec_switch *typec_switch; - struct drm_bridge bridge; - struct mutex lock; /* protect non-concurrent retimer & switch */ enum typec_orientation orientation; @@ -297,44 +295,6 @@ static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_re return ret; } -#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE) -static int nb7vpq904m_bridge_attach(struct drm_bridge *bridge, - enum drm_bridge_attach_flags flags) -{ - struct nb7vpq904m *nb7 = container_of(bridge, struct nb7vpq904m, bridge); - struct drm_bridge *next_bridge; - - if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) - return -EINVAL; - - next_bridge = devm_drm_of_get_bridge(&nb7->client->dev, nb7->client->dev.of_node, 0, 0); - if (IS_ERR(next_bridge)) { - dev_err(&nb7->client->dev, "failed to acquire drm_bridge: %pe\n", next_bridge); - return PTR_ERR(next_bridge); - } - - return drm_bridge_attach(bridge->encoder, next_bridge, bridge, - DRM_BRIDGE_ATTACH_NO_CONNECTOR); -} - -static const struct drm_bridge_funcs nb7vpq904m_bridge_funcs = { - .attach = nb7vpq904m_bridge_attach, -}; - -static int nb7vpq904m_register_bridge(struct nb7vpq904m *nb7) -{ - nb7->bridge.funcs = &nb7vpq904m_bridge_funcs; - nb7->bridge.of_node = nb7->client->dev.of_node; - - return devm_drm_bridge_add(&nb7->client->dev, &nb7->bridge); -} -#else -static int nb7vpq904m_register_bridge(struct nb7vpq904m *nb7) -{ - return 0; -} -#endif - static const struct regmap_config nb7_regmap = { .max_register = 0x1f, .reg_bits = 8, @@ -461,7 +421,7 @@ static int nb7vpq904m_probe(struct i2c_client *client) gpiod_set_value(nb7->enable_gpio, 1); - ret = nb7vpq904m_register_bridge(nb7); + ret = drm_aux_bridge_register(dev); if (ret) goto err_disable_gpio; From patchwork Fri Nov 3 23:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14955C001DB for ; Fri, 3 Nov 2023 23:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XNW6pyjfmi4zTPmSxXOnilkQgTLK5qVziEAIPtWcKHA=; b=MIsNcxW0J00kle YaMD01bW31g8p1oduLEC/Kg4qTor9SNDC9Jtd1zJtXBNbvaVudSob+gvHy6TWvIkNx/xWJp/41smK l/cwF9NejyZ+i2IuYM+CgAGMLm7oSUSAHFzurpP3RnAUjS47ELOGYPt5CyIKrK3mVa3IqJ7LmNfiT eZ1ABMt2ukOKB+8af5m2HtZmKcjYWdNHbe1nYZqaIVDHrWk0gB2SW5e6eVa+pK6FAyiFHlvCwwuKA c8Br0gwyevUe5d1rBnFvhonCmIXnAf34vvlZ1WJCzN/2IMOtWzuPX5OXep5K5vM4+HJVziTokQHhb s+g08gtaNhfBG4eMMx+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DF-00CIO7-2L; Fri, 03 Nov 2023 23:04:25 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DB-00CIIf-2E for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:23 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507e85ebf50so3204090e87.1 for ; Fri, 03 Nov 2023 16:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052659; x=1699657459; darn=lists.infradead.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=t20kdXXv84EK8irW7PHnDkzRUl4Wv7sjdKwURqJ7HrM=; b=DBg7VrJrf26rgvvf2eZwhmFD6Dkz9MkJQi3exuTaw9EkTgqwN0rNZpPHGglORvqsBi lTScL3u6WohXSdaZ7qMPSgpGyxk3E/r/+cTd3paWUqfW3WDt20rqXjKGRSp0MtanlHJH 4117ru3jUYVElvKawxw+VvnKTaDtI9RCFMLklxl++otguTtCsY4Gxu6E72Rh+eKnau8g XvxMX+Eg9OoPS1AEp7zVGTW86P7CHV7KSnaGgJpybyOWuzNe6IUTVbz/M7i37X3Esl8P iv1g8T7OQT1g0Ke2siwj1d/S+C5WfbmhaAimr4OwMUun2WIxD7W4gGUQNaTAy0mOmatC Yd8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052659; x=1699657459; 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=t20kdXXv84EK8irW7PHnDkzRUl4Wv7sjdKwURqJ7HrM=; b=BSd4JscV4GW33cn13g5LOp8KRN2iQPZA7PkemoBrB3uCOgDYudkuIlN+W99nlnNU4a 5L/fKDhkJCWhDJQNDEa9Lx+5DxUO/QpdLG218H0YZsYLLsW4b2fuUIUXiZFWi3c1SpLA CYaQsfsEZ5kjQT0sbyDJABPKqwLi+GZvRaR3lHr+f774mVMDPy3VCxJjqcY8UPVjRBj3 t9LRAhnmyJ4MAwIfjNEZQcjyxyd7ucCRKNGKzXD6W8AmPfUyggSPBE3InVfmnmMkgVq6 FKzqh/JD7haANFRDEvqWO7QXDMC8uhhfpsqGvlh5e42g5ZvdZOr3bsLv9APXS7yxhp4L ZhNQ== X-Gm-Message-State: AOJu0Ywf1uI31EK7JwajAm7jcMC/dAITUMSZRXRZplu2awbK3ca17+ai h7cSVlK3jhVrpsHwWs3FqGPzrg== X-Google-Smtp-Source: AGHT+IF0NEtoumWg6KgXjtKUt6sYnXp2MuvJDU1ivJBmtVDvLmuldT6Rb4cov9w2rp5X6xYpWOXEhg== X-Received: by 2002:a05:6512:308e:b0:509:4b8a:b65f with SMTP id z14-20020a056512308e00b005094b8ab65fmr5566312lfd.60.1699052658785; Fri, 03 Nov 2023 16:04:18 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:18 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 4/6] drm/bridge: implement generic DP HPD bridge Date: Sat, 4 Nov 2023 01:03:07 +0200 Message-ID: <20231103230414.1483428-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160421_748710_D77803B5 X-CRM114-Status: GOOD ( 19.74 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Several USB-C controllers implement a pretty simple DRM bridge which implements just the HPD notification operations. Add special helper for creating such simple bridges. Signed-off-by: Dmitry Baryshkov Acked-by: Neil Armstrong --- drivers/gpu/drm/bridge/Kconfig | 8 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/aux-hpd-bridge.c | 164 ++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 18 +++ 4 files changed, 191 insertions(+) create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index f12eab62799f..19d2dc05c397 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -21,6 +21,14 @@ config DRM_AUX_BRIDGE Simple transparent bridge that is used by several non-DRM drivers to build bridges chain. +config DRM_AUX_HPD_BRIDGE + tristate + depends on DRM_BRIDGE && OF + select AUXILIARY_BUS + help + Simple bridge that terminates the bridge chain and provides HPD + support. + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 918e3bfff079..017b5832733b 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o +obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o obj-$(CONFIG_DRM_CHIPONE_ICN6211) += chipone-icn6211.o obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c new file mode 100644 index 000000000000..4defac8ec63f --- /dev/null +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Linaro Ltd. + * + * Author: Dmitry Baryshkov + */ +#include +#include +#include + +#include +#include + +static DEFINE_IDA(drm_aux_hpd_bridge_ida); + +struct drm_aux_hpd_bridge_data { + struct drm_bridge bridge; + struct device *dev; +}; + +static void drm_aux_hpd_bridge_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + + ida_free(&drm_aux_hpd_bridge_ida, adev->id); + + of_node_put(adev->dev.platform_data); + + kfree(adev); +} + +static void drm_aux_hpd_bridge_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +/** + * drm_dp_hpd_bridge_register - Create a simple HPD DisplayPort bridge + * @parent: device instance providing this bridge + * @np: device node pointer corresponding to this bridge instance + * + * Creates a simple DRM bridge with the type set to + * DRM_MODE_CONNECTOR_DisplayPort, which terminates the bridge chain and is + * able to send the HPD events. + * + * Return: device instance that will handle created bridge or an error code + * encoded into the pointer. + */ +struct device *drm_dp_hpd_bridge_register(struct device *parent, + struct device_node *np) +{ + struct auxiliary_device *adev; + int ret; + + adev = kzalloc(sizeof(*adev), GFP_KERNEL); + if (!adev) + return ERR_PTR(-ENOMEM); + + 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_hpd_bridge"; + adev->dev.parent = parent; + adev->dev.of_node = parent->of_node; + adev->dev.release = drm_aux_hpd_bridge_release; + adev->dev.platform_data = np; + + ret = auxiliary_device_init(adev); + if (ret) { + ida_free(&drm_aux_hpd_bridge_ida, adev->id); + kfree(adev); + return ERR_PTR(ret); + } + + ret = auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ERR_PTR(ret); + } + + ret = devm_add_action_or_reset(parent, drm_aux_hpd_bridge_unregister_adev, adev); + if (ret) + return ERR_PTR(ret); + + return &adev->dev; + +} +EXPORT_SYMBOL_GPL(drm_dp_hpd_bridge_register); + +/** + * drm_aux_hpd_bridge_notify - notify hot plug detection events + * @dev: device created for the HPD bridge + * @status: output connection status + * + * A wrapper around drm_bridge_hpd_notify() that is used to report hot plug + * detection events for bridges created via drm_dp_hpd_bridge_register(). + * + * This function shall be called in a context that can sleep. + */ +void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + struct drm_aux_hpd_bridge_data *data = auxiliary_get_drvdata(adev); + + if (!data) + return; + + drm_bridge_hpd_notify(&data->bridge, status); +} +EXPORT_SYMBOL_GPL(drm_aux_hpd_bridge_notify); + +static int drm_aux_hpd_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; +} + +static const struct drm_bridge_funcs drm_aux_hpd_bridge_funcs = { + .attach = drm_aux_hpd_bridge_attach, +}; + +static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev, + const struct auxiliary_device_id *id) +{ + struct drm_aux_hpd_bridge_data *data; + + data = devm_kzalloc(&auxdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + 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; + + auxiliary_set_drvdata(auxdev, data); + + return devm_drm_bridge_add(data->dev, &data->bridge); +} + +static const struct auxiliary_device_id drm_aux_hpd_bridge_table[] = { + { .name = KBUILD_MODNAME ".dp_hpd_bridge", .driver_data = DRM_MODE_CONNECTOR_DisplayPort, }, + {}, +}; +MODULE_DEVICE_TABLE(auxiliary, drm_aux_hpd_bridge_table); + +static struct auxiliary_driver drm_aux_hpd_bridge_drv = { + .name = "aux_hpd_bridge", + .id_table = drm_aux_hpd_bridge_table, + .probe = drm_aux_hpd_bridge_probe, +}; +module_auxiliary_driver(drm_aux_hpd_bridge_drv); + +MODULE_AUTHOR("Dmitry Baryshkov "); +MODULE_DESCRIPTION("DRM HPD bridge"); +MODULE_LICENSE("GPL"); diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridge.h index 441ab3f0e920..33adaf4e4daa 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -7,6 +7,8 @@ #ifndef DRM_AUX_BRIDGE_H #define DRM_AUX_BRIDGE_H +#include + #if IS_ENABLED(CONFIG_DRM_AUX_BRIDGE) int drm_aux_bridge_register(struct device *parent); #else @@ -16,4 +18,20 @@ static inline int drm_aux_bridge_register(struct device *parent) } #endif +#if IS_ENABLED(CONFIG_DRM_AUX_HPD_BRIDGE) +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); +#else +static inline struct device *drm_dp_hpd_bridge_register(struct device *parent, + struct device_node *np) +{ + return 0; +} + +static inline void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status) +{ +} +#endif + #endif From patchwork Fri Nov 3 23:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53559C001B0 for ; Fri, 3 Nov 2023 23:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qHEajgZCPU6nBD8IbLQUP4W7Zp182fHyQD/xumHA4bg=; b=hdCv/ZWo8BS7hJ S+meb6WaJNzctkFGh1B7MYsJ9CMCWYl9bnupKihyPRhMGD0dZQryh/Dv2H4CGRJyJM/5OCsDokama kUxUDOnU32a9+pA5PfymVu2TpLXIK1xOqb79cQ2fYhL7An9FLWsh1vxO3EJ4imcukxteYkuj3gaZb KBYMs4t6GR9MraWvyTYyZ07o6A7/lNmhP6MyO6SlCF58C+aFHIVnij1PI6G6YI1473Q/+4K6zjCxf a7damh+3p9O+oq/3Mss41nfT5c2F+f88TlR6qMNe5j5VGE6MZR+qDAduv6d7fJ+PvS+zYFzcAXPJK YEgBgqkejsO7vCX4pkuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DG-00CIOJ-05; Fri, 03 Nov 2023 23:04:26 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DC-00CIJC-3B for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:24 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5079f9ec8d9so2785682e87.0 for ; Fri, 03 Nov 2023 16:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052660; x=1699657460; darn=lists.infradead.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=QARkaW3YAHrIEHRWT+FmbK4DkLcRgyf7kmgHichP+rw=; b=DBwLnr5M6nTyilI9O/4AJ4KWH3rNbRr6raF1KKWEoEfLyX4YplnZK1v5aEa04oCByT Luc85XB3u5Eq1Cdn4mxt0UDt21zn/XPARil9d3AMTwQiEXACLJY5Q17u+b18NZb2LrUK I7+o4YpLZei67K0h35fmoerApM6JUYhieSZNtKciZ901qEIW3OojekpLnpPl7cxTEr/a 03uDrel8YtWBQ+6J3NHMirpSmOhzdPDHu9CzaVyHz4ic1jUQYqGeHYEtv0a8X1Ajzgdb 3UuTso+iKXIO5abCt0tn7qp3nfRykz4SrLex9BEfEL6Z/Z15vuaZ+Wa7WyzZjJ7CSwll tUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052660; x=1699657460; 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=QARkaW3YAHrIEHRWT+FmbK4DkLcRgyf7kmgHichP+rw=; b=MdYzfk/NHCZ7Ocf3VmT2sURNN3zCzlGsz2QRR24ZzCnnaxjSR/zbuWkb36LRtxLd/E pn9iMq1azhnRMHbRON3IinFo9Bg1NsrghgadxTO+HBCMfxH88WN8QqF6v9lVvdzePjua n0Ti6MVQeMpk0XDc6XchBjCaaMQr3+qd2EfC/tdU7cgFb33xeoICAvnzfSuzA/xY6z8r Tc3kOs1NKexYsMNuD6I49sy/thjcT6lvkPubTCZY5xkzJwg8q1W7lsIDzCwLU76chc/O wZ82YAqplbCwq056y//yPIiIyI4I0ZBDszx2o1+Xus0/aQi2Pin4yJSY2xyZu/IjIXHy yfRw== X-Gm-Message-State: AOJu0YxWsXh00exjTdSCUUCXlwzK/fnMM98iU9/SZnEOEM4wY08hvQeU /NiF5qcZIzF16BIinYJVH/xh/w== X-Google-Smtp-Source: AGHT+IHxZ3SwBOE6PCX0jYjbOHiWg1mHD/29WBAeYOQpW39iEwAyMKXLx8WJMBpsaR9rgdUOupSWJA== X-Received: by 2002:a19:8c41:0:b0:500:c00e:8f15 with SMTP id i1-20020a198c41000000b00500c00e8f15mr1391304lfj.16.1699052659811; Fri, 03 Nov 2023 16:04:19 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:19 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 5/6] soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE Date: Sat, 4 Nov 2023 01:03:08 +0200 Message-ID: <20231103230414.1483428-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160423_025727_0FCA9E3D X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Use the freshly defined DRM_AUX_HPD_BRIDGE instead of open-coding the same functionality for the DRM bridge chain termination. Reviewed-by: Bjorn Andersson Acked-by: Bjorn Andersson Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/pmic_glink_altmode.c | 33 ++++++++------------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index b3634e10f6f5..c954001ae79e 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -86,6 +86,7 @@ config QCOM_PMIC_GLINK depends on OF select AUXILIARY_BUS select QCOM_PDR_HELPERS + select DRM_AUX_HPD_BRIDGE help The Qualcomm PMIC GLINK driver provides access, over GLINK, to the USB and battery firmware running on one of the coprocessors in diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c index 6f8b2f7ae3cc..cb0db362447c 100644 --- a/drivers/soc/qcom/pmic_glink_altmode.c +++ b/drivers/soc/qcom/pmic_glink_altmode.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -76,7 +76,7 @@ struct pmic_glink_altmode_port { struct work_struct work; - struct drm_bridge bridge; + struct device *bridge; enum typec_orientation orientation; u16 svid; @@ -230,10 +230,10 @@ static void pmic_glink_altmode_worker(struct work_struct *work) else pmic_glink_altmode_enable_usb(altmode, alt_port); - if (alt_port->hpd_state) - drm_bridge_hpd_notify(&alt_port->bridge, connector_status_connected); - else - drm_bridge_hpd_notify(&alt_port->bridge, connector_status_disconnected); + drm_aux_hpd_bridge_notify(alt_port->bridge, + alt_port->hpd_state ? + connector_status_connected : + connector_status_disconnected); pmic_glink_altmode_request(altmode, ALTMODE_PAN_ACK, alt_port->index); }; @@ -365,16 +365,6 @@ static void pmic_glink_altmode_callback(const void *data, size_t len, void *priv } } -static int pmic_glink_altmode_attach(struct drm_bridge *bridge, - enum drm_bridge_attach_flags flags) -{ - return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; -} - -static const struct drm_bridge_funcs pmic_glink_altmode_bridge_funcs = { - .attach = pmic_glink_altmode_attach, -}; - static void pmic_glink_altmode_put_retimer(void *data) { typec_retimer_put(data); @@ -464,15 +454,10 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, alt_port->index = port; INIT_WORK(&alt_port->work, pmic_glink_altmode_worker); - alt_port->bridge.funcs = &pmic_glink_altmode_bridge_funcs; - alt_port->bridge.of_node = to_of_node(fwnode); - alt_port->bridge.ops = DRM_BRIDGE_OP_HPD; - alt_port->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; - - ret = devm_drm_bridge_add(dev, &alt_port->bridge); - if (ret) { + alt_port->bridge = drm_dp_hpd_bridge_register(dev, to_of_node(fwnode)); + if (IS_ERR(alt_port->bridge)) { fwnode_handle_put(fwnode); - return ret; + return PTR_ERR(alt_port->bridge); } alt_port->dp_alt.svid = USB_TYPEC_DP_SID; From patchwork Fri Nov 3 23:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13445210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1D95C00A5A for ; Fri, 3 Nov 2023 23:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W0+n2Zv+toKWkEb8N0wqU2zasKsOoB/Xtir8Ftga56U=; b=sCbRg+MV9Vf2JY ES+bq2NgIocSXOMFPFilkqr7Ko2rMWUknr3YuveiXg2CMDxZjQtSu6TAE53HNjSeWBc6TMVNHPuUi J3xWKRoCkUdkcyLHM/gPQWodxGkeD+it4KxQLhhMQPn4XCfi+7sNrlRtyYmI0nyCuKKYM+fuOvjui cUI3M1F927CMDWitOMTk2Fv7N91Jr96svi/YB/K56ydcEbL7nBYXcFsFBtTct3bjT24EwSGg8VL29 OrLh0sp9bffuNhMHIPTM//eskMeH6aA8ijLBzvITFKFz+fbCJK6axsKU9LwTlfbROCQxIZez6Qcm2 GXN0Xkviy7JWy29zLQwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DG-00CIOc-15; Fri, 03 Nov 2023 23:04:26 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qz3DD-00CIJe-1S for linux-phy@lists.infradead.org; Fri, 03 Nov 2023 23:04:24 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c6ed1b9a1cso34519051fa.3 for ; Fri, 03 Nov 2023 16:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699052660; x=1699657460; darn=lists.infradead.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=RMc9DJrhHFukjQ0QSTQddBGYIHrkhtn026KunSVyHrs=; b=JK6sX6AOaNrtZXusF4yql11FhQkOu9aVGpPHdCTKnI8/MWJh19xH0bvkBE4cc4FsrF tYiauyoewEKnq7AvJkUPW2QhqTBjTpfjRMXdKjwxQzlTKy2/6Qgo0qqgLfI7jSpP+hTy z02Fu5OxYBPDhKBDNWU+oGfIRAeAdR9g1LQMXTjAtlkkWFpw6NfQeOutI7nx1DEFyHcd AaStOUGbrKH3Pho/UqorhpGjyP+GL92AkS0qhsotELRzkuWLR+lSa5R8UkHIPc2xRbpH otmDUcvhW1yXjwSsZHE/m0zQY6DKHBLgNmeItyymbQvp8h0w/J6GCGS9I7g1MnuLDYIv w4Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699052660; x=1699657460; 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=RMc9DJrhHFukjQ0QSTQddBGYIHrkhtn026KunSVyHrs=; b=r3nhTqKBnv9TNNTRcshRB9chwr8K/XZBTB9avm40K1uP+7QYahv9tsobjkjzwYgNED AAeY1fHpycRDxMRCM6UK0t1rk5oIKw6QI08RmFLKOzvcKeDdXowjxPEElyDc6yFXHp/k J8I8r4wCsZBEvpxkyMipkCewAMVLNe7VVj4tpKWTd3MBWxHNQ3pBus87LHymXAktjU9y 2HPx4otVLuOKUSAhqbf421P9Pjc9awXfx9uOUybT50ahNMevAbFIWNRJF0+N/HzVnnTi WPDZdyJnEXMYazlq4lPEVoBEOQH1g6WaAILhsvoE8veduHhw/lntej4J4FcUZ8G8P738 y32Q== X-Gm-Message-State: AOJu0Ywe5jqOtXAFwG9WleIxa+TdkoJr069jda3Uen9YURqcfwlRQbCj aRfP3mSBxYGxhmTV/v/zrfgTSw== X-Google-Smtp-Source: AGHT+IFZ7oB8PJ8HIVCwttUFOTPFsyuly9xwudtCOZ+IkVYj1zJZPMykPCji5igqCU5JxU9LfDeAiw== X-Received: by 2002:a19:5206:0:b0:507:adc9:a739 with SMTP id m6-20020a195206000000b00507adc9a739mr18412890lfb.37.1699052660610; Fri, 03 Nov 2023 16:04:20 -0700 (PDT) Received: from eriador.lan (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id s16-20020ac24650000000b00504211d2a7bsm329919lfo.297.2023.11.03.16.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 16:04:20 -0700 (PDT) From: Dmitry Baryshkov To: David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Heikki Krogerus , Greg Kroah-Hartman Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v6 6/6] usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE Date: Sat, 4 Nov 2023 01:03:09 +0200 Message-ID: <20231103230414.1483428-7-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> References: <20231103230414.1483428-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_160423_490181_09E3F5E7 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Use the freshly defined DRM_AUX_HPD_BRIDGE instead of open-coding the same functionality for the DRM bridge chain termination. Signed-off-by: Dmitry Baryshkov Acked-by: Bryan O'Donoghue --- drivers/usb/typec/tcpm/Kconfig | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 41 +++---------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig index 0b2993fef564..64d5421c69e6 100644 --- a/drivers/usb/typec/tcpm/Kconfig +++ b/drivers/usb/typec/tcpm/Kconfig @@ -80,6 +80,7 @@ config TYPEC_QCOM_PMIC tristate "Qualcomm PMIC USB Type-C Port Controller Manager driver" depends on ARCH_QCOM || COMPILE_TEST depends on DRM || DRM=n + select DRM_AUX_HPD_BRIDGE if DRM_BRIDGE help A Type-C port and Power Delivery driver which aggregates two discrete pieces of silicon in the PM8150b PMIC block: the diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c index 581199d37b49..1a2b4bddaa97 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include "qcom_pmic_typec_pdphy.h" #include "qcom_pmic_typec_port.h" @@ -36,7 +36,6 @@ struct pmic_typec { struct pmic_typec_port *pmic_typec_port; bool vbus_enabled; struct mutex lock; /* VBUS state serialization */ - struct drm_bridge bridge; }; #define tcpc_to_tcpm(_tcpc_) container_of(_tcpc_, struct pmic_typec, tcpc) @@ -150,35 +149,6 @@ static int qcom_pmic_typec_init(struct tcpc_dev *tcpc) return 0; } -#if IS_ENABLED(CONFIG_DRM) -static int qcom_pmic_typec_attach(struct drm_bridge *bridge, - enum drm_bridge_attach_flags flags) -{ - return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; -} - -static const struct drm_bridge_funcs qcom_pmic_typec_bridge_funcs = { - .attach = qcom_pmic_typec_attach, -}; - -static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm) -{ - tcpm->bridge.funcs = &qcom_pmic_typec_bridge_funcs; -#ifdef CONFIG_OF - tcpm->bridge.of_node = of_get_child_by_name(tcpm->dev->of_node, "connector"); -#endif - tcpm->bridge.ops = DRM_BRIDGE_OP_HPD; - tcpm->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; - - return devm_drm_bridge_add(tcpm->dev, &tcpm->bridge); -} -#else -static int qcom_pmic_typec_init_drm(struct pmic_typec *tcpm) -{ - return 0; -} -#endif - static int qcom_pmic_typec_probe(struct platform_device *pdev) { struct pmic_typec *tcpm; @@ -186,6 +156,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; const struct pmic_typec_resources *res; struct regmap *regmap; + struct device *bridge_dev; u32 base[2]; int ret; @@ -241,14 +212,14 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) mutex_init(&tcpm->lock); platform_set_drvdata(pdev, tcpm); - ret = qcom_pmic_typec_init_drm(tcpm); - if (ret) - return ret; - tcpm->tcpc.fwnode = device_get_named_child_node(tcpm->dev, "connector"); if (!tcpm->tcpc.fwnode) return -EINVAL; + bridge_dev = drm_dp_hpd_bridge_register(tcpm->dev, to_of_node(tcpm->tcpc.fwnode)); + if (IS_ERR(bridge_dev)) + return PTR_ERR(bridge_dev); + tcpm->tcpm_port = tcpm_register_port(tcpm->dev, &tcpm->tcpc); if (IS_ERR(tcpm->tcpm_port)) { ret = PTR_ERR(tcpm->tcpm_port);