From patchwork Tue Apr 4 16:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13200570 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 6B54FC77B60 for ; Tue, 4 Apr 2023 16:27:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 997FE10E703; Tue, 4 Apr 2023 16:27:15 +0000 (UTC) Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E4C010E71A for ; Tue, 4 Apr 2023 16:27:13 +0000 (UTC) Received: by mail-qt1-x830.google.com with SMTP id hf2so32088261qtb.3 for ; Tue, 04 Apr 2023 09:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; t=1680625632; 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=S11u5DTA9h019l0IrQX+AN9OVNLb/rYYX+LKhYQ8rHU=; b=RASK7vLMEox4wcrZx3WZ1lA9nJRdmq6+T1OSO7Vhf7DudPiE7VgGm2Tm1HvCrAkkqa llLuE3qdsEVHFfqrLAnYFSV7D9M2DeQ7+JybpsxxpOGfWNY9q7xDVsn0MgykC4jH+HBI BLrsWNgnPsWdfx5hKtAThkfL78drNr9HaC0s6AfqIHP7RJKp7VsLKtNwccbCZE3HxkWf nhAfsaI0qt0LEU7ZCnn7aASy/VozpUv8O/0OmpHi8uLJSK8b/nPNTkNUyhMCnRn+grNS gyKG/OEWOj/aXu2JMkCmhUQwO9+KEMsLigfCQ0VmVi7F2vZi3eVNK34GHJxA+/3oupZT TaPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680625632; 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=S11u5DTA9h019l0IrQX+AN9OVNLb/rYYX+LKhYQ8rHU=; b=R4nS8PB98+w4QOZCHttHPQzNJAaclaOyh7epdcrY3sQTUoJACBK4na259QUuJFW9XG kfVFy98f2zrCjipmvspDe6Jt6hrt5+eJjsPLLvjZ3bPoMCH+ioWUYoGxp7icojZ8u/J3 VcxeuTK/FlonwnOrVHvS/5c9Iz3lFjny5sm8gGP6RYS9vsRGL+NBYRTRSTOMVvvJUo9G x4UX9Jlr1KIgVGtLhdKfrPQTPsm8ZMo205Mlc7+i3twIlP+8yPeDcmvDAm6GHflXSpwW wT9tgmCaY7YG8N1yT9sVrFBWZFQtNjYpYX84MIGAUK2hk0yE3FqQfFfhbMt++6vrgJ8d jMBg== X-Gm-Message-State: AAQBX9fFbSF9t8FNGApLTDQeZbwJqgzwzH979+63oVHkrEUgd9nyif1/ ogRG0FXIGzCWR3TN7FizsrEkvA== X-Google-Smtp-Source: AKy350actmNHw+OyMbNEwx6gUmFQOFhGfhU/+Fzp3SZHvwL73rlPQnYRTsAzJaWkBS1Vay65lg3gjw== X-Received: by 2002:ac8:7fd5:0:b0:3e6:3929:e9ba with SMTP id b21-20020ac87fd5000000b003e63929e9bamr4362000qtk.66.1680625631766; Tue, 04 Apr 2023 09:27:11 -0700 (PDT) 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 m124-20020a375882000000b0073b8745fd39sm3699594qkb.110.2023.04.04.09.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 09:27:09 -0700 (PDT) From: Jonathan Cormier Date: Tue, 04 Apr 2023 12:26:48 -0400 Subject: [PATCH v4 1/3] drm/bridge: tfp410: Support basic I2C interface MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v4-1-f983bcef2df8@criticallink.com> References: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6549; i=jcormier@criticallink.com; h=from:subject:message-id; bh=21jXZ+7XjoAljy4+OPvocGx/SSsnd1AKvRiNCdogF0A=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBkLE/YFOKfMh9uwiFGyBNIIlSBVft4zR400ef4C0pF I+hykreJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCZCxP2AAKCRDc1/0uCzbrqqU5EA CAnTpvqp0nQNk60kh6QCPyzN2jqhlAAV/WBwd8awLa/p++tjdMpwZIUZq93gwe1TlYws64v2Cp0T2n ruuQugpUea1Ln+Df1rPys/YhMWnURAblLw9BATgxu+1oO8R+NisIOvlUA3NtiK8o2RM4x2Ai1D3qxA PfcPbwaWTZ4b/zrKGpfn9PTnxV8k6PGM8oLMvSZ4fOrDGJsi5BSEm9kkS+zZtCvxs4O+sGAPPNRNe6 56Le4k5D5f8U/Dx7rzG5KHpdARVABivIfQafNlVCDaeiQvc1isH/nZq9HEWH9oZpfvsUEC7pnOhbwv iKxISytMHft3XXDQxmKcfVIcDMxTkvqvuscFz88DGJ4kqwuDZDXlx4nHsQakB/Dr4Yw2gZE9uCJ8Wk Raph0G3xn01pe+EjvWmt8eM69TbQ6fHjIAJ1chqcWxMm2i2UrjeyIQkrpNB+KBVLcDHl/IOT+p0cR7 rrKgGaN0k+xDA7UtDl6Z3C99KqB+Whskxtdty8JwxKn2w4OxWYQMq1ieFGWhWaDONvr0sF7aHwqM01 st0i6ON3U6Md69Zh5bJWjVHV/8wKu97B2Os6X7BWrLRgtI72bRMlvzyCwZLtc1Xl5cpgnUyPdzL9n3 AdyMjXehj9EZs6ypXPVRfigvR5utZUtiXwusm8m9nOk7B/hbPQ1V9QU8N64g== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA 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 Reviewed-by: Neil Armstrong Signed-off-by: Jonathan Cormier --- drivers/gpu/drm/bridge/ti-tfp410.c | 93 +++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index b9635abbad16..bb3f8d0ff207 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) From patchwork Tue Apr 4 16:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13200571 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 82417C6FD1D for ; Tue, 4 Apr 2023 16:27:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFFBF10E705; Tue, 4 Apr 2023 16:27:20 +0000 (UTC) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by gabe.freedesktop.org (Postfix) with ESMTPS id C79B510E705 for ; Tue, 4 Apr 2023 16:27:19 +0000 (UTC) Received: by mail-qt1-x82b.google.com with SMTP id cn12so28738134qtb.8 for ; Tue, 04 Apr 2023 09:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; t=1680625638; 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=JhwrIjGdHvbP7iRYz+GF4I68rmmYmSv00IVMxjU1xN8=; b=ZtCNBHqKs8v2GxHBkp3iZsN1/Aj4WowcQaeTkud3ULyCdCXRN3419nTF4lYEw7JCVm lINN0tC7Q3eUE2If0tAq2MSpjL3+GB+oggPts/3PIm9kmHzBQEU9c7kqq3FhS+KRW7Pj g2zyaBRKwGVb22cEq8jh1O0D4XyxUuP42v+0HT5FeQ5Gi/67Rx5mNT0rEesrbN1OoTtw 4LWx2qQ8AJ+0p7cbYKm+9+AhMpibKe3nsn4MBkTLdnmS88PGkjgLw7rSDd51LadmyAW6 8J+ZXzFFxtlb4xt8nqoqw1+dV6pjLDjwGxbjGFJCDQLBjEOH+X3KeHS+rJbfRog0UUSX si+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680625638; 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=JhwrIjGdHvbP7iRYz+GF4I68rmmYmSv00IVMxjU1xN8=; b=sMOoNM4kImfa/5ffdY27JKXbND2vlaB1Yzmj/XnwLhBYtVTSneNIe9eOB9EReCuHih B2aENsOa3rNG2cJSbmfhC4bKua7Jns9koKOe0nDjyIEh5KktrXgZHfw+DdYLCML7Roci H/eAc9MKA4nTOQHK+XcHpRbECZuhEHx5Mwo0//jCdAk5fHWYEhZVBHr5Wuj6N3QA5iqs dyOV7vEWyVRlfw3dYZB5pIFyGK7vRjg2+CyIhchsDMApLir/xXPdGLpqtiO4EBoR1FIj Bt56XZXdwAyRlQlu0Y3hcMqR4YS1u5DGbA0JhkbaEoBr8MCIa/gSezai/nL0tz7zSXFD kRCg== X-Gm-Message-State: AAQBX9eb6gLO6Ym48+5tIi0E6YBvz0xIDapAirJ3gmw8+TSE3B+0Fg4J MGtjvNknfcc6H9h56ir6mFoRLQ== X-Google-Smtp-Source: AKy350ZaeXvGyJjLwmDXCGIwtx/7uoo3VUxwZm26dBp0mZ93D84vaD58lxabDqOzDSs7RSKv/rrIXg== X-Received: by 2002:ac8:57c3:0:b0:3e3:86d0:4ef8 with SMTP id w3-20020ac857c3000000b003e386d04ef8mr37879614qta.28.1680625638589; Tue, 04 Apr 2023 09:27:18 -0700 (PDT) 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 m124-20020a375882000000b0073b8745fd39sm3699594qkb.110.2023.04.04.09.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 09:27:12 -0700 (PDT) From: Jonathan Cormier Date: Tue, 04 Apr 2023 12:26:49 -0400 Subject: [PATCH v4 2/3] drm/bridge: tfp410: Fix logic to configured polled HPD MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v4-2-f983bcef2df8@criticallink.com> References: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1161; i=jcormier@criticallink.com; h=from:subject:message-id; bh=thTBke4adSbjQB+Az7ku6gTKJI14U3xmvadZhGFOYMw=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBkLE/YIu6HYilZxFWf+fAQXGrPc3NZJOHfU8IajFHX +WG0356JAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCZCxP2AAKCRDc1/0uCzbrqtx8D/ 9eYQrGQHYfDwF38dKrsTbYYGWQkO9RbvLizz2zK6sPjERuElcIyHb1tc87UgrdMz6oVwFvAf9gPSol mWEUPGff0hIoNlzeZtDvh+c33wxgQXejInX2eBcPryiU6jOsiQBbutNh9EKRBGa4vDDrxq/UfUiItn dHTY0jqxh+gSfWV7bWg0wMankS65kJtnm/wcNit00TMdbrYzjhmNnV9aLsZs2cXRG8InRC7w3db/Hc pwi7YQ2/AHR6YKnqvhOM7KTqWb9v2orkiFN6q9zZhaeEwWWgl0tBOR/OfGbdPfkE2uxbVdrAvWyc5Q aqd02xIaWKKqxIF2DJx4akESDUex5zzNb0w3wL5+PPenTYcbaHs1tMfvsO7Cgt+Bm5GDstY3BYtT+j ij8oaqxmJkK8++3tHCexC/uayQi7sExzN/5P7shgKGbIoi23AkiKjNw7tZ65lA6Vrh+nSNPMMbWVZb 34datHiI6xJ+spdB0tCALG/SD1s5ImkUXEozuXbh3d2pdZAo/0SOXfr4rYZxP0b1pWG1mUScY+5vcU Jm8dWe7KOOxB5DHu0GyzWskm69pu+ZPwUNDdCiYpgU2tBvTtvu4UIy0dwGcOenxLksEnFvjyET1yNV tfsUEG65wcUY0k1RqNwXJ7yJd6lOEoS9OBb14yEkjxebzUiOGI0Hgo275XOA== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA 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. Fixes: 5cafa0f1853b ("drm/bridge: tfp410: Replace manual connector handling with bridge") Signed-off-by: Michael Williamson Reviewed-by: Neil Armstrong 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 bb3f8d0ff207..41007d05d584 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 Tue Apr 4 16:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13200572 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 1D91CC6FD1D for ; Tue, 4 Apr 2023 16:27:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A9B310E707; Tue, 4 Apr 2023 16:27:24 +0000 (UTC) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91BA710E707 for ; Tue, 4 Apr 2023 16:27:22 +0000 (UTC) Received: by mail-qt1-x829.google.com with SMTP id n14so32080443qta.10 for ; Tue, 04 Apr 2023 09:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=criticallink.com; s=google; t=1680625641; 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=uCKZ9Mkz+RQ4mEYeEtL01DQSakeCQYik5lgGNcrvFgw=; b=gu8aDzW6mk7ndqQJ78eCYXkaMIcBflx9g1fcE0d0FuijriRXhfnU+AnBoaG8G96Ao6 4woLHIqo1G0iduPIi1uA2GwJUvshAoPxVcs43wl8YPmvnvOMrw9WXwIll1kpfbn9q7+N jSoBV/aRYVQ0vC3xsX1DKaagUy1y2NKXB8C12FbSAU7wirgtLPywwAAI6K0ExR/IMoCY br0DhHh7k1Jv2pbZMvlFHFMJlYYPmp49p1HAccZo6HoawFbG20Zq4chO9gJdRf9iTatF 5OEwjfIZQ+l1iV76f4Dm/7LHQUAqQyXT9fmfTXxajhx8Gkq2P9TcaFiMJC5czUuyJu0i yZSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680625641; 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=uCKZ9Mkz+RQ4mEYeEtL01DQSakeCQYik5lgGNcrvFgw=; b=oqHXosQxeAMpov5er30qLsREZmap7NkNx1dFnULtFqC/2K6aF2PrlRSuDrXZUaLfW6 gykPIWD7vnzNUL/P2YqbAvSJxOJGnb7oqlhj7vNRNMveidggIkDwLenfHwY+S8KH2U2E H1XcALm7HRmMWvFl1pHrWqPRcTCYUHywDiP0o67L6L7fVycYLk0G63gA4YF2eXnjM6TP B6IVgzhWn736f06Ae9BwauPl8GdbUCNYUye0+U2Ggmscp05qyVsMimcPEO+TJ/vJzSVT wP1aeObZtNYsi7jMGXwkSAxtt424dPlkpdIXEsbegiPOe52OEpJqy+d8Gb5u8gVHZ6gv AQJA== X-Gm-Message-State: AAQBX9eHVIbiF8TXvqjayFjGPD30Z0nvGLFLR7LivnUnRWURtCroktSH /CQJartS654EvU1N00ilP1GiOg== X-Google-Smtp-Source: AKy350YdHhxJHAWa7CVEDFiWfp5hB318UjAsQxTMa/B80zKTDxFrmS6y3Oanueas7lgNPYz88e1N8w== X-Received: by 2002:ac8:5716:0:b0:3e6:38cf:fc93 with SMTP id 22-20020ac85716000000b003e638cffc93mr92844qtw.19.1680625641325; Tue, 04 Apr 2023 09:27:21 -0700 (PDT) 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 m124-20020a375882000000b0073b8745fd39sm3699594qkb.110.2023.04.04.09.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 09:27:19 -0700 (PDT) From: Jonathan Cormier Date: Tue, 04 Apr 2023 12:26:50 -0400 Subject: [PATCH v4 3/3] drm/bridge: tfp410: If connected, use I2C for polled HPD status. MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v4-3-f983bcef2df8@criticallink.com> References: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v4-0-f983bcef2df8@criticallink.com> To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1568; i=jcormier@criticallink.com; h=from:subject:message-id; bh=e9amVn7Rg4sZ0MMr3Oo/rypthm9YpAHvIkIP258W2H4=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBkLE/Ys8NZkx1nbBAzJJRYhysKfHgmOTynPZlQqnaK +xQYoxuJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCZCxP2AAKCRDc1/0uCzbrqriqD/ 4utNSdB0l9Jcpc5ExxjWDxeRwX7gWcySy/fuRa5QdL4/fBkhyq2A9l9PemRNrlMkDVszzle+CrsOuC oO92O1c4jnZZiNNulaag7Gc8Cy1nL06MRXBjy8iRCc7Gi/WUGoqI3jQ3mq1hYaY1DD+NPdJxUUsa6n Q4cNA3k92DyW42TIAnN4JKA9JP0Wx76oe1Z61xj0V88QKShYFORoAc5c8h63u6o1zG1kkm2yjDnPRN dcCK5GFcbjJbThlo5N4oMUjfQyBvEfhAcF+7dReWngXVsKtVxchUU0gEO8X/12xYWGZ+qpuULguYZq 0mlb8FldXYcgurMFXN8B9d2AoNjidUez7XkNIm2KDfwy7cm+lK7IG0dJkTWh/BfrElcUSgWw0uu/jN W7kTsCyLXhZRi2Q+rgogE9yAwLJaKIUpjzVPbnyJSYvKcR1nwxBRVqN5RBkyJa6MpzI6TK/Q3vcTjJ tAKt/qI0Dk3MLXri1wMJi2dS4LKVNbUxMjX5rYafKK6nO9EKH+r/8jx+6GX6xSqwNrV4dMi9s471Ek xkaWUNjgLPbIdmnMotNEAKNC4Z7oNkCXQN9QHalvBptIc9wvvmf4qVsI05niR5MdN7JlPhhAqsKXFc YPJQbaYm1cpzfhOelWQqRc+OHjrXWcLIZfq/6L8JDV7VSRZvnQj6zke+L6iw== X-Developer-Key: i=jcormier@criticallink.com; a=openpgp; fpr=FF328CEA09E66D63136754DFDCD7FD2E0B36EBAA 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 Reviewed-by: Neil Armstrong Signed-off-by: Jonathan Cormier --- drivers/gpu/drm/bridge/ti-tfp410.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index 41007d05d584..eeb7202452aa 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,15 @@ static enum drm_connector_status tfp410_connector_detect(struct drm_connector *connector, bool force) { struct tfp410 *dvi = drm_connector_to_tfp410(connector); + 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); }