From patchwork Wed Jan 25 21:09:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13116252 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 23239C54E94 for ; Wed, 25 Jan 2023 21:24:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D347D10E8BC; Wed, 25 Jan 2023 21:24:35 +0000 (UTC) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F3FA10E122 for ; Wed, 25 Jan 2023 21:09:19 +0000 (UTC) Received: by mail-qt1-x836.google.com with SMTP id m26so7507395qtp.9 for ; Wed, 25 Jan 2023 13:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fUjI7H8s1MYo6Cc+S/e5j/o7dI4Q79O1EcwP8gpHRPk=; b=WmRJE2Mq3Y+K4158GTsOqdZvqf33NCVXb6of19VtyNo0PcicmQNERhsu7pw2PcRyMm Vz1utLmAmbd1YPUFxI8pDqWLvZqh8Rpe1qY5VMxVQb9rjYMgI7FGlHWwb5OwFCQUxtU9 gu6GkH6MCUev7XYvuuPwgWfw3yYbBZ8wPe3KKpEmp2INlv+S5MxtUFVPluSh9Yehpeag lneKEXSp4XmuqFuwtRRRSQ3tDAivnOQDLNvK7BnK6XYRICC/GTej7dWLLc05kpFbk5KH WXiJxzmzgQ7fLEVaV4LSzo52layZX7CYhG/CEYGDr4J6GI8rIwa4ihRSPRq0LRgQbMLq q3qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fUjI7H8s1MYo6Cc+S/e5j/o7dI4Q79O1EcwP8gpHRPk=; b=gLXKO3dzULIbFHZzj42KP5CZ56km2qerXF2dwVcVP+1z+9fR8wu9iE3mL2GSvGty8G 7uTI64/vTucP6+7+kjEpnA9cY+g+BtHYnAfRhMVKkMje8LXSkAHCRHwES1Sso/cn1vnQ odgVtFXeO7MBZjfzxXt9adYT53Wgbk6nhwrNma3VUaS7A7c+Q9VMwH0dyPZfBngBrDj3 ImzZoTkFKPo84nV03R+LHUExJlFJtDwpcbmYO1jdX8e+BJH/8D30iyaui0hxUBXFhqEt icHGm5Nm4hGYBuvIA9SVKtpupQ6AvjQF155xj2qIPgws083qVgNM2wW8ykseWko+fGH5 q0vw== X-Gm-Message-State: AO0yUKV9gSjcRKwsN/kq895w9g+PrIdDf206fFHYu4QQ6DS88DQjjIO2 iwAbN6czA2czxL1KvoUN7O6qjw== X-Google-Smtp-Source: AK7set/LFwRd97nXfvUIMK9E+mfcx8BXRdqiOH5s3Omo2pLcZSQ1uH9j29+CP3CpGJkFx/IsNFZRpA== X-Received: by 2002:a05:622a:494:b0:3b6:4249:bbca with SMTP id p20-20020a05622a049400b003b64249bbcamr7001049qtx.55.1674680958298; Wed, 25 Jan 2023 13:09:18 -0800 (PST) Received: from [127.0.1.1] (static-72-90-70-109.syrcny.fios.verizon.net. [72.90.70.109]) by smtp.gmail.com with ESMTPSA id q196-20020a3743cd000000b0070736988c10sm4177090qka.110.2023.01.25.13.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:09:17 -0800 (PST) From: Jonathan Cormier Date: Wed, 25 Jan 2023 16:09:09 -0500 Subject: [PATCH 1/4] dt-bindings: display: bridge: tfp410: Add tfp410 i2c example MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v1-1-66a4d4e390b7@criticallink.com> References: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Tomi Valkeinen , Jyri Sarha X-Mailer: b4 0.11.3-dev-d001f X-Developer-Signature: v=1; a=openpgp-sha256; l=1541; i=jcormier@criticallink.com; h=from:subject:message-id; bh=Ne8kM0iOMcS7U5BkEx6jIQptCk+Yyk87jfs/YUNCJd4=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj0Zp7UF8IgNYOldWOmS1L7oYJE1M9wa/rtzY7bwpg As8z5cOJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY9GaewAKCRDc1/0uCzbrqqg7EA C2dSK8WyTKgvw8F11qy4Z57FlvkXXc96GXak0aeWgH2SeRpR5VeUg//WoWgoLALeN+yr8Zer8VbHx9 pYkAJzmmmSA3eym1PtscHMdHF6EY79tufpY5cBN7TZAtRI5TJ5aX8zLzKKeEzQ7DZfhCrUuNKnqoND FzpVO+M3yYubTnp1tqgWPQz3zhGVnTTlXkYcyXs50CBDXj7R/1sJlpgCvspkPXynYobaS6cGzv5D3Z TDStjQmbbYqb0x7jyiR0SjoHeLlNB+1rnzGJ16Ez857rqo/A8kibojKWUxFcytWROpT8kHrDOh8LIb LWFBy2WZMsvU0kxCD9bjy7TQ4g7CgSOeRa9effsX1yAMQiAOQ4TUUpDRdVwCGusV5DKnfNRn+xEVpl 6cY4jSTz3SkG4GgX66jGvQv5xgrML5TV+cCRyQVx4TkiW9PB71nZkVn7STWc8dZRlNh+OMuhU0R/zU lCp3ZAoa1vwnPuHy5tKYxjgjEruwsMWN56zPS/J6SQz5nh4IAZzQL0DstS4g9r1LvGcnDFzX1Nlh6d mC1V41L9Om+BYLIQSv9pVWG1+GniW/s1W+jLE8JzWBJxeGnIwYwC7seD/IdE3VL5IVK6Hcez1jypOk 1PEqO9BLxE1tU6fzFaddvLptinwdYV3oJ/GuSZc2zaLglaY7AUgCyNn2tAjw== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA X-Mailman-Approved-At: Wed, 25 Jan 2023 21:21:46 +0000 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: , Cc: Jonathan Cormier , devicetree@vger.kernel.org, Bob Duke , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Williamson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a i2c example with HDMI connector Signed-off-by: Jonathan Cormier --- .../bindings/display/bridge/ti,tfp410.yaml | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Documentation/devicetree/bindings/display/bridge/ti,tfp410.yaml b/Documentation/devicetree/bindings/display/bridge/ti,tfp410.yaml index 4c5dd8ec2951..456214f14b47 100644 --- a/Documentation/devicetree/bindings/display/bridge/ti,tfp410.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ti,tfp410.yaml @@ -116,4 +116,46 @@ examples: }; }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + hdmi_encoder: tfp410@38 { + compatible = "ti,tfp410"; + reg = <0x38>; + + ports { + address-cells = <1>; + size-cells = <0>; + + port@0 { + reg = <0>; + tfp410_in: endpoint { + remote-endpoint = <&dpi1_out>; + }; + }; + + port@1 { + reg = <1>; + tfp410_out: endpoint { + remote-endpoint = <&hdmi_connector_in>; + }; + }; + }; + }; + }; + + hdmi: hdmi_connector { + compatible = "hdmi-connector"; + label = "hdmi"; + type = "a"; + ddc-i2c-bus = <&i2c1>; + port { + hdmi_connector_in: endpoint { + remote-endpoint = <&tfp410_out>; + }; + }; + }; + ... From patchwork Wed Jan 25 21:09:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13116212 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 A47A1C27C76 for ; Wed, 25 Jan 2023 21:22:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A192E10E8A6; Wed, 25 Jan 2023 21:21:53 +0000 (UTC) Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4C9010E122 for ; Wed, 25 Jan 2023 21:09:20 +0000 (UTC) Received: by mail-vs1-xe32.google.com with SMTP id 3so21076767vsq.7 for ; Wed, 25 Jan 2023 13:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CoORX2qT8KsLgQJjE1ct6lyWG6kv2kixmCqMoh8qJXo=; b=QcLgSlHdcDxGf+qpVByR8C773P04A4qpawKGwbw4ewGUlB453uQc5keHWWpTCUV9Cv DVnng/U6kCWLhfaw/IxmUX9r+r5Nlx38R0yqBnB0XMGHYdXo3mQX8vMvjOmxJp3sqjJq pyPK/9b9mna03B8eDIPIVoEYEyxxJDaZgmD9UzqTBEqtBYnBj4dmG3/MewhhNfdOAyMS NsR2Wk4YWPXEig7BZaGL60ClS6qKPN5LtJ4T84HJI6zfmp3lcs87prOvBSOZ0kfdOoqv 5nYto+pO/Cb4lC4VE17xyNAEw3bl0i0VXgfj1rqZS1qKK14vaxmQIvPSTMVgj/lkLn2Q /oQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CoORX2qT8KsLgQJjE1ct6lyWG6kv2kixmCqMoh8qJXo=; b=mQHcrDZDOYsTXT6prf3XRK0ErlXOXkWu7zyxc0pypgibruPQsSqj775zD3xd2a2NEg sQ3HTQzjRijX6HJNs4SdFyR7w4dhR+wyJ98Edo8Xr6sE7l5IWdtobIgXG5xD3goFG2j8 vpYgvlIouRVxkGmTfMwZurr0/Y8RFjcVgbqVJ5sCCQbDsW8Ykpw3QIfB6BA0BcPpoRUs UVC+eHOMIOPbD1W6wJC0DkPMfqRdWLewxzt2FQB7fY9UFtBeBE/an0tSHkeZ8gE6uo02 KqBjrd1vsdd3831P4MlWDmCrkUKApGHyfkg5I9XBmUBtC362miWmh1uWJLcBhDmbv6tv lpWQ== X-Gm-Message-State: AO0yUKV35EJ3XkVAv222huwSBudCriq8G5u644lAPWwGvEInUo3eq4yt Snn+cOzQ/rtVJe59AcsVgcodsw== X-Google-Smtp-Source: AK7set88rgKkpeUswsyGDOnBmgdF7dY8MzczVQYBpyLGr9q23x/8MYN337gCq+EwerC8IQYquiNgDA== X-Received: by 2002:a05:6102:94d:b0:3e8:152e:3cf9 with SMTP id a13-20020a056102094d00b003e8152e3cf9mr4606692vsi.23.1674680959800; Wed, 25 Jan 2023 13:09:19 -0800 (PST) Received: from [127.0.1.1] (static-72-90-70-109.syrcny.fios.verizon.net. [72.90.70.109]) by smtp.gmail.com with ESMTPSA id q196-20020a3743cd000000b0070736988c10sm4177090qka.110.2023.01.25.13.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:09:18 -0800 (PST) From: Jonathan Cormier Date: Wed, 25 Jan 2023 16:09:10 -0500 Subject: [PATCH 2/4] DRM: BRIDGE: TFP410: Support basic I2C interface MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v1-2-66a4d4e390b7@criticallink.com> References: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Tomi Valkeinen , Jyri Sarha X-Mailer: b4 0.11.3-dev-d001f X-Developer-Signature: v=1; a=openpgp-sha256; l=6795; i=jcormier@criticallink.com; h=from:subject:message-id; bh=3CSuTbFCeCLVpZgKlKSDCr9WJDIrZoWYhYxHZvRNRcc=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj0Zp7qUtXiXM4ecobzuoX+GaBUQancmttiP/Mov+2 PQxtnX+JAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY9GaewAKCRDc1/0uCzbrqk/qEA CE+Ihd65TsFnyYoy2u6/qk6K/p4qt57q5raMWzL0s71WDzwhjHJWCld/C23OdbvloCHLEut+OYqggp tEikXqd6jWS2OJgbyVpUyXmXq/Z539fFn5zvt+A8lRNWJ9s7txT5kqGah72B2i3Q/LCExS3fGprJV4 VOal7eM3DrDR7QI3rPfKR0s2cPKRW7hNFF2uJLcyMBfMmvi63piuN7UIu//ATaOZtaR6JtviFU5Dgh SyHyf02GB6ARF6gONql2r+sswDFv92vyJUYkE2bKx/ggQKip7cKFTH30VJ9tL3NqLyvSytciPYsLpg PVX8rJHhjTmb3yZBUeeynIb6SfTHBQmwaD7udHxN//fYmmkcb1RLbwdqwcftrZCsb2Rqrp5vOTmbiL Hz6WkNatXdSR/EU2Z3jZY9XOQLjKMHAY0GENyBw3tzfJ2bfeY0F5ZEk5T1R/A/UVD5TPCglzwl6BZp Jk8GnrDps1UNFRTGPLevUZDMipX+Bj6RaIfFx6vjeClJgzeMBD+CJ85Z5JkpNmyuE5BlP2tapQaZDC TaY5Ma3pb1KoT/5Xq02HlXQtP6AS3AKL/T7rllwEeuUVWeZedgrP/UXsbWcYaKjGJSUetBz5OQmq3a TAj3gW1QyA3EDXX+9hJZ2/ta1vJ/IDD3JnwyyznuvWiFnsE3ohdkE+iaZ+NQ== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA X-Mailman-Approved-At: Wed, 25 Jan 2023 21:21:46 +0000 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: , Cc: Jonathan Cormier , devicetree@vger.kernel.org, Bob Duke , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Williamson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Michael Williamson The TFP410 driver does not support I2C. As such, the device remains in Power Down if the I2C is enabled by the bootstrap pins. Add basic support for the I2C interface, and provide support to take the device out of power down when enabled. Also read the bootstrap mode pins via the CTL_1_MODE register when using the I2C bus. Signed-off-by: Michael Williamson Signed-off-by: Jonathan Cormier --- drivers/gpu/drm/bridge/ti-tfp410.c | 95 +++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index b9635abbad16..323a6d9ed188 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -21,6 +22,20 @@ #define HOTPLUG_DEBOUNCE_MS 1100 +#define TFP410_REG_CTL_1_MODE 0x08 +#define TFP410_BIT_PD BIT(0) +#define TFP410_BIT_EDGE BIT(1) +#define TFP410_BIT_BSEL BIT(2) +#define TFP410_BIT_DSEL BIT(3) + +static const struct regmap_config tfp410_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = 0xff, + .cache_type = REGCACHE_NONE, +}; + struct tfp410 { struct drm_bridge bridge; struct drm_connector connector; @@ -33,6 +48,8 @@ struct tfp410 { struct drm_bridge *next_bridge; struct device *dev; + struct i2c_client *i2c; + struct regmap *regmap; }; static inline struct tfp410 * @@ -183,6 +200,9 @@ static void tfp410_enable(struct drm_bridge *bridge) { struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); + if (dvi->i2c) + regmap_set_bits(dvi->regmap, TFP410_REG_CTL_1_MODE, TFP410_BIT_PD); + gpiod_set_value_cansleep(dvi->powerdown, 0); } @@ -190,6 +210,9 @@ static void tfp410_disable(struct drm_bridge *bridge) { struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); + if (dvi->i2c) + regmap_clear_bits(dvi->regmap, TFP410_REG_CTL_1_MODE, TFP410_BIT_PD); + gpiod_set_value_cansleep(dvi->powerdown, 1); } @@ -221,38 +244,48 @@ static const struct drm_bridge_timings tfp410_default_timings = { .hold_time_ps = 1300, }; -static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) +static int tfp410_parse_timings(struct tfp410 *dvi) { struct drm_bridge_timings *timings = &dvi->timings; struct device_node *ep; u32 pclk_sample = 0; u32 bus_width = 24; u32 deskew = 0; + unsigned int val = 0; + int ret = 0; /* Start with defaults. */ *timings = tfp410_default_timings; - if (i2c) + if (dvi->i2c) { /* - * In I2C mode timings are configured through the I2C interface. - * As the driver doesn't support I2C configuration yet, we just - * go with the defaults (BSEL=1, DSEL=1, DKEN=0, EDGE=1). + * For now, assume settings are latched from pins on reset / power up. + * Should add options to optionally set them out of DT properties. */ - return 0; - - /* - * In non-I2C mode, timings are configured through the BSEL, DSEL, DKEN - * and EDGE pins. They are specified in DT through endpoint properties - * and vendor-specific properties. - */ - ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 0, 0); - if (!ep) - return -EINVAL; - - /* Get the sampling edge from the endpoint. */ - of_property_read_u32(ep, "pclk-sample", &pclk_sample); - of_property_read_u32(ep, "bus-width", &bus_width); - of_node_put(ep); + ret = regmap_read(dvi->regmap, TFP410_REG_CTL_1_MODE, &val); + if (ret) { + dev_err(dvi->dev, "Read failed on CTL_1_MODE\n"); + return ret; + } + pclk_sample = (val & TFP410_BIT_EDGE) ? 1 : 0; + bus_width = (val & TFP410_BIT_BSEL) ? 24 : 12; + dev_dbg(dvi->dev, "(0x%02X) : detected %d bus width, %s edge sampling\n", + val, bus_width, pclk_sample ? "positive" : "negative"); + } else { + /* + * In non-I2C mode, timings are configured through the BSEL, DSEL, DKEN + * and EDGE pins. They are specified in DT through endpoint properties + * and vendor-specific properties. + */ + ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 0, 0); + if (!ep) + return -EINVAL; + + /* Get the sampling edge from the endpoint. */ + of_property_read_u32(ep, "pclk-sample", &pclk_sample); + of_property_read_u32(ep, "bus-width", &bus_width); + of_node_put(ep); + } timings->input_bus_flags = DRM_BUS_FLAG_DE_HIGH; @@ -291,7 +324,7 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) return 0; } -static int tfp410_init(struct device *dev, bool i2c) +static int tfp410_init(struct device *dev, struct i2c_client *i2c) { struct device_node *node; struct tfp410 *dvi; @@ -313,15 +346,24 @@ static int tfp410_init(struct device *dev, bool i2c) dvi->bridge.of_node = dev->of_node; dvi->bridge.timings = &dvi->timings; dvi->bridge.type = DRM_MODE_CONNECTOR_DVID; + dvi->i2c = i2c; + + if (i2c) { + dvi->regmap = devm_regmap_init_i2c(i2c, &tfp410_regmap_config); + if (IS_ERR(dvi->regmap)) + return PTR_ERR(dvi->regmap); + } - ret = tfp410_parse_timings(dvi, i2c); + ret = tfp410_parse_timings(dvi); if (ret) return ret; /* Get the next bridge, connected to port@1. */ node = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!node) + if (!node) { + dev_err(dev, "Could not find remote node\n"); return -ENODEV; + } dvi->next_bridge = of_drm_find_bridge(node); of_node_put(node); @@ -352,7 +394,7 @@ static void tfp410_fini(struct device *dev) static int tfp410_probe(struct platform_device *pdev) { - return tfp410_init(&pdev->dev, false); + return tfp410_init(&pdev->dev, NULL); } static int tfp410_remove(struct platform_device *pdev) @@ -378,7 +420,6 @@ static struct platform_driver tfp410_platform_driver = { }; #if IS_ENABLED(CONFIG_I2C) -/* There is currently no i2c functionality. */ static int tfp410_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -391,7 +432,7 @@ static int tfp410_i2c_probe(struct i2c_client *client, return -ENXIO; } - return tfp410_init(&client->dev, true); + return tfp410_init(&client->dev, client); } static void tfp410_i2c_remove(struct i2c_client *client) @@ -408,7 +449,7 @@ MODULE_DEVICE_TABLE(i2c, tfp410_i2c_ids); static struct i2c_driver tfp410_i2c_driver = { .driver = { .name = "tfp410", - .of_match_table = of_match_ptr(tfp410_match), + .of_match_table = tfp410_match, }, .id_table = tfp410_i2c_ids, .probe = tfp410_i2c_probe, From patchwork Wed Jan 25 21:09:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13116207 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 81EF3C54EED for ; Wed, 25 Jan 2023 21:22:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 215F410E28F; Wed, 25 Jan 2023 21:21:49 +0000 (UTC) Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE3DD10E122 for ; Wed, 25 Jan 2023 21:09:21 +0000 (UTC) Received: by mail-yb1-xb30.google.com with SMTP id u72so4049984ybi.7 for ; Wed, 25 Jan 2023 13:09:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XIlJ/2ukO6pHCtcdtpAJK3BuzsSI7aObU3Ceo8jzibo=; b=hew6/wHKEd2bSIYdB1oHJMVs4Dh0UL2iunLR9fGVFeuNT9f+eNsW0gL1ll0pyq9X8j 2alTe/LUx9cu6iTqeImb7gXJrLJk1wR1mGBNQnYh+S6JH2al1ZmeMV+MkLs/xYs5v6tQ 7FwZzHh5Y5CpCVIkujsvjAHRu/VIhC+qT/G5G9UKyXPgoZJdWr3TXEBsvMNDYpAbtWzn u0F0BzqV5cL/amlthcvrEZEP1PkzDsI8bo++CKYyjy24F123kDayKBnG9K/ukDUJjdJl q41rS96FN4zKqzITWnzfo4/6Wb9n6UxAKFF+mVqlXSPdwvK12glyXIi/roOK2dIROrZ9 5oVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XIlJ/2ukO6pHCtcdtpAJK3BuzsSI7aObU3Ceo8jzibo=; b=Ujw93LUq5IehW38/8KQYzdwqFSs9xHZlRQ9jNgGNMOAja16eMuaIAHsVFKR8p6ybom 4LpjTArHKmKNtXL0QAh9LX1eKlCeprgd0F4f+Ylwi0E9bi8/pSLK/xyh3m9G7YpJj0jb DAG1h9BSphgdB4vk5Htmjbhpdl1WRhFn3ar92zULkJCm0pcwqN6TAnf5mSqIxsJKPOtL 31v6f/M7mOZCpGk8McTuGIEb6qZo2aBM9+gzzsuxgGVvhIy6lVjliU9qYD8PCtAPQsKa xHlT/bfdUZrkALAhDUDASK29icPoJdCic5Oyp9AAbFK9Z4vA0O5cnqTD/4+Ow95OgImU ecKw== X-Gm-Message-State: AFqh2kr6bleokaqnhterv8OGaQgvKojOMTA0YHDmgZmj/yZWoOR8dGtq G0G3htwZktXLs9ZYaEHcbxsAMw== X-Google-Smtp-Source: AMrXdXuwelH5a8jOV8LQT5Lv8Wy+AN1a2r4YXqXenm+tK/4agPeqKvYOSp87jnGCYes7X1ENx66aKw== X-Received: by 2002:a25:4d55:0:b0:6c9:c534:d91f with SMTP id a82-20020a254d55000000b006c9c534d91fmr20790518ybb.10.1674680961086; Wed, 25 Jan 2023 13:09:21 -0800 (PST) Received: from [127.0.1.1] (static-72-90-70-109.syrcny.fios.verizon.net. [72.90.70.109]) by smtp.gmail.com with ESMTPSA id q196-20020a3743cd000000b0070736988c10sm4177090qka.110.2023.01.25.13.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:09:20 -0800 (PST) From: Jonathan Cormier Date: Wed, 25 Jan 2023 16:09:11 -0500 Subject: [PATCH 3/4] DRM: BRIDGE: TFP410: Fix logic to configured polled HPD MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v1-3-66a4d4e390b7@criticallink.com> References: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Tomi Valkeinen , Jyri Sarha X-Mailer: b4 0.11.3-dev-d001f X-Developer-Signature: v=1; a=openpgp-sha256; l=1011; i=jcormier@criticallink.com; h=from:subject:message-id; bh=8yPmLc4MapEEF5TA4azj668v9knGK86XMIMeNijF8zA=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj0Zp7jQtFzb/QD4rwpxlFkn3rgUOVtazLT1vpJcQy ZQGYCw6JAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY9GaewAKCRDc1/0uCzbrqv/ZD/ 9d20xQAe/I+AxKXbgTpc3ZqHdekbCzul+TQfOMxr/CXNaJoL0quQlxyo/HkWH2N8iJE7juctDYyvek DpWpBtbJDip3JmPY3zPMwo4vXSYz8ClK0rm7QrbgbjnE2P7HtAr/z4Ra6LrqwETr8KN9dOSQU4UtWL R1w48hMc7B8vGcdbKDIp1Eh4eyh1glKqeoIShAWxqOpbZh0pYhweUH8/bZ+nXuVEfbUSWhLOWYda0S XSW51z5ESc+oYrh+qMdrRstQDtOK98AWPjiP3uiIrNeVYzhx5QSNvq6DCcF1tYvoCTW2jx3WJQWFht 6e6hYwGwrMy2VIKJO6HJNvIZUf62nGYhFHCLIa+pm9LWQZgQWBmbA+KJ0jYgbAKUGPOj5kuoV4iy+k OQQUO8mnN5BG/iEPEu7BJsgzk0jl8/5bFYwZM5zFny/piLG3FeBmXGWfU9GIPwRDE5PBHSiHiab0+L ykWUisXADPOmgKeJ6t1F9mCOdYYFVtFs81u06yPMh1J9SZjxo0EA7F2wq6mVFDgFbnOZwMzS4s1xMb uOBEQ9bJ/Y3QuhTPl6+Dol6DK24NskNAeyeoD7QJkB5eOTUxhsmS+eFY66nyhjD+BsHL4IIosdLbFg seWimd7mB/SKtNpL2tVb7/byl9Tkyvwi/JU55FQEXfMcUVHkYXzBEMwbzRrA== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA X-Mailman-Approved-At: Wed, 25 Jan 2023 21:21:46 +0000 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: , Cc: Jonathan Cormier , devicetree@vger.kernel.org, Bob Duke , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Williamson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Michael Williamson The logic to configure polling (vs async/irq notification) of hot-plug events was not correct. If the connected bridge requires polling, then inform the upstream bridge we also require polling. Signed-off-by: Michael Williamson Signed-off-by: Jonathan Cormier --- drivers/gpu/drm/bridge/ti-tfp410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index 323a6d9ed188..837e1f81a0ff 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -155,7 +155,7 @@ static int tfp410_attach(struct drm_bridge *bridge, return -ENODEV; } - if (dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT) + if (dvi->next_bridge->ops & DRM_BRIDGE_OP_HPD) dvi->connector.polled = DRM_CONNECTOR_POLL_HPD; else dvi->connector.polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; From patchwork Wed Jan 25 21:09:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13116251 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 5160AC54EED for ; Wed, 25 Jan 2023 21:24:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F010310E8BB; Wed, 25 Jan 2023 21:24:34 +0000 (UTC) Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E63E10E185 for ; Wed, 25 Jan 2023 21:09:22 +0000 (UTC) Received: by mail-vs1-xe32.google.com with SMTP id 3so21076918vsq.7 for ; Wed, 25 Jan 2023 13:09:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9RJJ/n41zzX+saTp2LNncjY8Fypt3NmL9yEutFB4n1s=; b=WOHm/saIG3Dr4q+24Z7G6SYdxWckEwYZ2OiPVUiQlFDjk9J/GGH5G2lPCp9nPBdUM6 NKLPG74xTyEwESMRZGQkeobMfCP0xvhk5dxc/hF9opSrydqXNm+bgs4xusEtsuqt6ZTj erM0lCjFlt1FjkKoN2A0doFteQq1lyRdmHVl5KpF63lOurZ1mSrCtIHL8WCuWLQTVOdQ f57HcEWpr7rvKo71D5asNmYTOkr2yKFiuCioq2hGejao5f7Z1Lr2hfTb0FQGrA4rgB2Z r62S/gRt3R3/7qHDmBiWTdJj+fteUohtw1NfX3myqFn9sBC4hrsY1vkKe36xcZhRDijK IetA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9RJJ/n41zzX+saTp2LNncjY8Fypt3NmL9yEutFB4n1s=; b=rHpAncUVB3CYntelazAvPFobQkDN/j+3heMcZjwUpcSyA01jFTXw2iqz1auWQHmiz0 yniRmGFXx8X3WVSlDjTWKSGHTcwWPf+L9qiZ5fVyZqAvM1U7N6UIDhvELX2InerxnrfB FrjYtq6vmF84pgM4KmsRr5aOmHHoL7PyIIfUoHvj3AEYEl5Rtp5N690uTAj/6WE9cA/D eZD4WAXNqC8QTwyZU7GZDedT5tMaw9KhcPO0E3SRM7yns5Gsf83/Ew+2glpKp9V/04pj MYOpxG7tCb2iIz1/1tCAY7V78JliPJqHsZSzelbMJm54GWS/Ss8jhPcdbris27WPYTu5 VvGQ== X-Gm-Message-State: AO0yUKVrgfK8LPxaMG+JcjW3lBMU6wLOfWo6rgleEvWrgDlpZE6RdpNQ 82T7Up2sXGwUbAO+wWy03ELE4g== X-Google-Smtp-Source: AK7set9bH4FlpCkV+Z+7rYCaPzI9wpMh7X7Sa4ITkX7oLz7viTzX4t7Ud2ygznpBXw4WanAYEKE8aw== X-Received: by 2002:a67:7284:0:b0:3e9:93fa:140c with SMTP id n126-20020a677284000000b003e993fa140cmr1644589vsc.9.1674680962198; Wed, 25 Jan 2023 13:09:22 -0800 (PST) Received: from [127.0.1.1] (static-72-90-70-109.syrcny.fios.verizon.net. [72.90.70.109]) by smtp.gmail.com with ESMTPSA id q196-20020a3743cd000000b0070736988c10sm4177090qka.110.2023.01.25.13.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 13:09:21 -0800 (PST) From: Jonathan Cormier Date: Wed, 25 Jan 2023 16:09:12 -0500 Subject: [PATCH 4/4] DRM: BRIDGE: TFP410: If connected, use I2C for polled HPD status. MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v1-4-66a4d4e390b7@criticallink.com> References: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v1-0-66a4d4e390b7@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Tomi Valkeinen , Jyri Sarha X-Mailer: b4 0.11.3-dev-d001f X-Developer-Signature: v=1; a=openpgp-sha256; l=1533; i=jcormier@criticallink.com; h=from:subject:message-id; bh=dbb6ec7CfpiriM2pWdSl9OaXPVL9sCebyFiqEYEERQk=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj0Zp8UY3oOfu1sE+y2VZfLN0nj6Zb8gpmkZWoxYPV wM1zUW2JAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY9GafAAKCRDc1/0uCzbrqly9EA CPJlnlwhTnKovCKXXIx14LdNjTl14R/C5jZyKgskM3kkTsxuPRLUWuniHgeDEO7fhbZx3FwtW1QUp/ Zn9RnwRza3ZKJEyHv0elltxnjisj/WTR0Z3NGL2xHIQXP8MxyGFBYtvJZoQHQ3rpmu9bOkhCIvD+fG 7MenhcEfyBVbKBnIiK7AraSXgAMBWt5lGo6o8ZBbVHBVgol/iU5lkMs4Od1hCEmfWDyiGAbvvQnCGc XSo2TauNuwCKaDxFtgPUmxx9OEN5ng5G72LWN9H3o32YN7zWBHJsArkqExSVXGMn/BlK/rsjzKIwg5 BQp91qTt4vHztKSR7ekaU6ikv8dQ8kG6f39xSrLXYOxt3IXaIauH6JtqkjeqnsaqxUDi3fR8sVjIW4 6CU4mgt8wLdSt6qR7kSYMmqg6BDRRrKjvNd5HvlG1AYTs/aIXXxos80/58TJ+n/PqtROGGKAEPDDli oYJ6lkB/1H7pHV9ZfrvCTz9Ws4egquII/R3G7FOyp+kEMFTZQy7jIPfvmXHSdIIo8XSf8fg9pOz8IG j4k9CKHz3e699zCre/Yi7JazXyKpcJ3nedEX6XbrDIgXwqx7jShjt0rl2A/sdXuOQSR7Lfg1Ckqqmd X3/+eF32C7gtCmaP6ZLHcb0F93Y//74lDL+IYvGiTXMqEz+qFfntvOV1Q+Xw== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA X-Mailman-Approved-At: Wed, 25 Jan 2023 21:21:46 +0000 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: , Cc: Jonathan Cormier , devicetree@vger.kernel.org, Bob Duke , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Williamson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Michael Williamson If the I2C bus is connected on the TFP410, then use the register status bit to determine connection state. This is needed, in particular, for polling the state when the Hot Plug detect is not connected to a controlling CPU via GPIO/IRQ lane. Signed-off-by: Michael Williamson Signed-off-by: Jonathan Cormier --- drivers/gpu/drm/bridge/ti-tfp410.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index 837e1f81a0ff..ac216eaec3c8 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -28,6 +28,9 @@ #define TFP410_BIT_BSEL BIT(2) #define TFP410_BIT_DSEL BIT(3) +#define TFP410_REG_CTL_2_MODE 0x09 +#define TFP410_BIT_HTPLG BIT(1) + static const struct regmap_config tfp410_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -105,6 +108,16 @@ static enum drm_connector_status tfp410_connector_detect(struct drm_connector *connector, bool force) { struct tfp410 *dvi = drm_connector_to_tfp410(connector); + u32 val; + unsigned int ret; + + if (dvi->i2c) { + ret = regmap_test_bits(dvi->regmap, TFP410_REG_CTL_2_MODE, TFP410_BIT_HTPLG); + if (ret < 0) + dev_err(dvi->dev, "%s failed to read HTPLG bit : %d\n", __func__, ret); + else + return ret ? connector_status_connected : connector_status_disconnected; + } return drm_bridge_detect(dvi->next_bridge); }