From patchwork Mon Jun 17 16:02:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13701003 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 AF33AC27C79 for ; Mon, 17 Jun 2024 16:09:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D22210E459; Mon, 17 Jun 2024 16:09:02 +0000 (UTC) Received: from ns.iliad.fr (ns.iliad.fr [212.27.33.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD1B310E456 for ; Mon, 17 Jun 2024 16:08:56 +0000 (UTC) Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id D500920527; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id BD0692029A; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) From: Marc Gonzalez Date: Mon, 17 Jun 2024 18:02:59 +0200 Subject: [PATCH 1/4] dt-bindings: display: simple-bridge: add ti,tdp158 MIME-Version: 1.0 Message-Id: <20240617-tdp158-v1-1-df98ef7dec6d@freebox.fr> References: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> In-Reply-To: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Arnaud Vrac , Pierre-Hugues Husson , Dmitry Baryshkov , Marc Gonzalez X-Mailer: b4 0.13.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In default mode, this device works transparently. Signed-off-by: Marc Gonzalez --- Documentation/devicetree/bindings/display/bridge/simple-bridge.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/display/bridge/simple-bridge.yaml b/Documentation/devicetree/bindings/display/bridge/simple-bridge.yaml index 43cf4df9811a5..5f0c9687538bf 100644 --- a/Documentation/devicetree/bindings/display/bridge/simple-bridge.yaml +++ b/Documentation/devicetree/bindings/display/bridge/simple-bridge.yaml @@ -31,6 +31,7 @@ properties: - ti,opa362 - ti,ths8134 - ti,ths8135 + - ti,tdp158 ports: $ref: /schemas/graph.yaml#/properties/ports @@ -52,6 +53,9 @@ properties: maxItems: 1 description: GPIO controlling bridge enable + vcc-supply: + description: Power supply for the bridge + vdd-supply: description: Power supply for the bridge From patchwork Mon Jun 17 16:03:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13700999 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 1B60DC2BA15 for ; Mon, 17 Jun 2024 16:08:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF86110E44D; Mon, 17 Jun 2024 16:08:57 +0000 (UTC) Received: from ns.iliad.fr (ns.iliad.fr [212.27.33.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id B381210E459 for ; Mon, 17 Jun 2024 16:08:56 +0000 (UTC) Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id E24252021F; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id CA054203D5; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) From: Marc Gonzalez Date: Mon, 17 Jun 2024 18:03:00 +0200 Subject: [PATCH 2/4] drm: bridge: simple-bridge: use dev pointer in probe MIME-Version: 1.0 Message-Id: <20240617-tdp158-v1-2-df98ef7dec6d@freebox.fr> References: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> In-Reply-To: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Arnaud Vrac , Pierre-Hugues Husson , Dmitry Baryshkov , Marc Gonzalez X-Mailer: b4 0.13.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Prepare to factorize probe function. Signed-off-by: Marc Gonzalez --- drivers/gpu/drm/bridge/simple-bridge.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 5813a2c4fc5ee..d672e34970e18 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -169,18 +169,19 @@ static const struct drm_bridge_funcs simple_bridge_bridge_funcs = { static int simple_bridge_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct simple_bridge *sbridge; struct device_node *remote; - sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL); + sbridge = devm_kzalloc(dev, sizeof(*sbridge), GFP_KERNEL); if (!sbridge) return -ENOMEM; platform_set_drvdata(pdev, sbridge); - sbridge->info = of_device_get_match_data(&pdev->dev); + sbridge->info = of_device_get_match_data(dev); /* Get the next bridge in the pipeline. */ - remote = of_graph_get_remote_node(pdev->dev.of_node, 1, -1); + remote = of_graph_get_remote_node(dev->of_node, 1, -1); if (!remote) return -EINVAL; @@ -188,29 +189,29 @@ static int simple_bridge_probe(struct platform_device *pdev) of_node_put(remote); if (!sbridge->next_bridge) { - dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n"); + dev_dbg(dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; } /* Get the regulator and GPIO resources. */ - sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd"); + sbridge->vdd = devm_regulator_get_optional(dev, "vdd"); if (IS_ERR(sbridge->vdd)) { int ret = PTR_ERR(sbridge->vdd); if (ret == -EPROBE_DEFER) return -EPROBE_DEFER; sbridge->vdd = NULL; - dev_dbg(&pdev->dev, "No vdd regulator found: %d\n", ret); + dev_dbg(dev, "No vdd regulator found: %d\n", ret); } - sbridge->enable = devm_gpiod_get_optional(&pdev->dev, "enable", + sbridge->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(sbridge->enable)) - return dev_err_probe(&pdev->dev, PTR_ERR(sbridge->enable), + return dev_err_probe(dev, PTR_ERR(sbridge->enable), "Unable to retrieve enable GPIO\n"); /* Register the bridge. */ sbridge->bridge.funcs = &simple_bridge_bridge_funcs; - sbridge->bridge.of_node = pdev->dev.of_node; + sbridge->bridge.of_node = dev->of_node; sbridge->bridge.timings = sbridge->info->timings; drm_bridge_add(&sbridge->bridge); From patchwork Mon Jun 17 16:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13701002 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 02909C2BA18 for ; Mon, 17 Jun 2024 16:09:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 070AC10E0E7; Mon, 17 Jun 2024 16:09:02 +0000 (UTC) Received: from ns.iliad.fr (ns.iliad.fr [212.27.33.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id A242D10E44F for ; Mon, 17 Jun 2024 16:08:56 +0000 (UTC) Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id 0A915203D5; Mon, 17 Jun 2024 18:03:14 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id D811E206BB; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) From: Marc Gonzalez Date: Mon, 17 Jun 2024 18:03:01 +0200 Subject: [PATCH 3/4] drm: bridge: simple-bridge: use only devm* in probe MIME-Version: 1.0 Message-Id: <20240617-tdp158-v1-3-df98ef7dec6d@freebox.fr> References: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> In-Reply-To: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Arnaud Vrac , Pierre-Hugues Husson , Dmitry Baryshkov , Marc Gonzalez X-Mailer: b4 0.13.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Once probe uses only devm functions, remove() becomes unnecessary. Signed-off-by: Marc Gonzalez Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/simple-bridge.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index d672e34970e18..f1e458a15882f 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -214,16 +214,7 @@ static int simple_bridge_probe(struct platform_device *pdev) sbridge->bridge.of_node = dev->of_node; sbridge->bridge.timings = sbridge->info->timings; - drm_bridge_add(&sbridge->bridge); - - return 0; -} - -static void simple_bridge_remove(struct platform_device *pdev) -{ - struct simple_bridge *sbridge = platform_get_drvdata(pdev); - - drm_bridge_remove(&sbridge->bridge); + return devm_drm_bridge_add(dev, &sbridge->bridge); } /* @@ -300,7 +291,6 @@ MODULE_DEVICE_TABLE(of, simple_bridge_match); static struct platform_driver simple_bridge_driver = { .probe = simple_bridge_probe, - .remove_new = simple_bridge_remove, .driver = { .name = "simple-bridge", .of_match_table = simple_bridge_match, From patchwork Mon Jun 17 16:03:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13701000 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 0D764C27C79 for ; Mon, 17 Jun 2024 16:09:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40E8610E455; Mon, 17 Jun 2024 16:09:01 +0000 (UTC) X-Greylist: delayed 340 seconds by postgrey-1.36 at gabe; Mon, 17 Jun 2024 16:08:56 UTC Received: from ns.iliad.fr (ns.iliad.fr [212.27.33.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id A03EF10E44D for ; Mon, 17 Jun 2024 16:08:56 +0000 (UTC) Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id 2E0022049C; Mon, 17 Jun 2024 18:03:14 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id 00BC32029A; Mon, 17 Jun 2024 18:03:13 +0200 (CEST) From: Marc Gonzalez Date: Mon, 17 Jun 2024 18:03:02 +0200 Subject: [PATCH 4/4] drm: bridge: simple-bridge: add tdp158 support MIME-Version: 1.0 Message-Id: <20240617-tdp158-v1-4-df98ef7dec6d@freebox.fr> References: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> In-Reply-To: <20240617-tdp158-v1-0-df98ef7dec6d@freebox.fr> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Arnaud Vrac , Pierre-Hugues Husson , Dmitry Baryshkov , Marc Gonzalez X-Mailer: b4 0.13.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The TI TDP158 is an AC-Coupled HDMI signal to TMDS Redriver supporting DVI 1.0 and HDMI 1.4b and 2.0b output signals. Signed-off-by: Marc Gonzalez --- drivers/gpu/drm/bridge/simple-bridge.c | 64 ++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index f1e458a15882f..745d253e55f7e 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -6,6 +6,8 @@ * Maxime Ripard */ +#include +#include #include #include #include @@ -32,6 +34,7 @@ struct simple_bridge { const struct simple_bridge_info *info; struct drm_bridge *next_bridge; + struct regulator *vcc; struct regulator *vdd; struct gpio_desc *enable; }; @@ -142,8 +145,16 @@ static void simple_bridge_enable(struct drm_bridge *bridge) struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge); int ret; + if (sbridge->vcc) { + ret = regulator_enable(sbridge->vcc); + msleep(100); + if (ret) + DRM_ERROR("Failed to enable vcc regulator: %d\n", ret); + } + if (sbridge->vdd) { ret = regulator_enable(sbridge->vdd); + msleep(100); if (ret) DRM_ERROR("Failed to enable vdd regulator: %d\n", ret); } @@ -159,6 +170,9 @@ static void simple_bridge_disable(struct drm_bridge *bridge) if (sbridge->vdd) regulator_disable(sbridge->vdd); + + if (sbridge->vcc) + regulator_disable(sbridge->vcc); } static const struct drm_bridge_funcs simple_bridge_bridge_funcs = { @@ -167,16 +181,14 @@ static const struct drm_bridge_funcs simple_bridge_bridge_funcs = { .disable = simple_bridge_disable, }; -static int simple_bridge_probe(struct platform_device *pdev) +static int common_probe(struct device *dev, struct simple_bridge **res) { - struct device *dev = &pdev->dev; struct simple_bridge *sbridge; struct device_node *remote; sbridge = devm_kzalloc(dev, sizeof(*sbridge), GFP_KERNEL); if (!sbridge) return -ENOMEM; - platform_set_drvdata(pdev, sbridge); sbridge->info = of_device_get_match_data(dev); @@ -203,6 +215,15 @@ static int simple_bridge_probe(struct platform_device *pdev) dev_dbg(dev, "No vdd regulator found: %d\n", ret); } + sbridge->vcc = devm_regulator_get_optional(dev, "vcc"); + if (IS_ERR(sbridge->vcc)) { + int ret = PTR_ERR(sbridge->vcc); + if (ret == -EPROBE_DEFER) + return -EPROBE_DEFER; + sbridge->vcc = NULL; + dev_dbg(dev, "No vcc regulator found: %d\n", ret); + } + sbridge->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(sbridge->enable)) @@ -213,10 +234,27 @@ static int simple_bridge_probe(struct platform_device *pdev) sbridge->bridge.funcs = &simple_bridge_bridge_funcs; sbridge->bridge.of_node = dev->of_node; sbridge->bridge.timings = sbridge->info->timings; + *res = sbridge; return devm_drm_bridge_add(dev, &sbridge->bridge); } +static int simple_bridge_probe(struct platform_device *pdev) +{ + struct simple_bridge *sbridge = NULL; + int err = common_probe(&pdev->dev, &sbridge); + platform_set_drvdata(pdev, sbridge); + return err; +} + +static int i2c_probe(struct i2c_client *client) +{ + struct simple_bridge *sbridge = NULL; + int err = common_probe(&client->dev, &sbridge); + i2c_set_clientdata(client, sbridge); + return err; +} + /* * We assume the ADV7123 DAC is the "default" for historical reasons * Information taken from the ADV7123 datasheet, revision D. @@ -298,6 +336,26 @@ static struct platform_driver simple_bridge_driver = { }; module_platform_driver(simple_bridge_driver); +static const struct of_device_id i2c_match_table[] = { + { + .compatible = "ti,tdp158", + .data = &(const struct simple_bridge_info) { + .connector_type = DRM_MODE_CONNECTOR_HDMIA, + }, + }, + { } +}; +MODULE_DEVICE_TABLE(of, i2c_match_table); + +static struct i2c_driver i2c_simple_bridge_driver = { + .probe = i2c_probe, + .driver = { + .name = "i2c-simple-bridge", + .of_match_table = i2c_match_table, + }, +}; +module_i2c_driver(i2c_simple_bridge_driver); + MODULE_AUTHOR("Maxime Ripard "); MODULE_DESCRIPTION("Simple DRM bridge driver"); MODULE_LICENSE("GPL");