From patchwork Mon Feb 20 22:10:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13147158 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 BC3DDC636D6 for ; Mon, 20 Feb 2023 22:10:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1912110E7D0; Mon, 20 Feb 2023 22:10:50 +0000 (UTC) Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5D5610E7CE for ; Mon, 20 Feb 2023 22:10:43 +0000 (UTC) Received: by mail-qv1-xf32.google.com with SMTP id ks17so2789760qvb.6 for ; Mon, 20 Feb 2023 14:10:43 -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=p2rA8r1vRndMpn7srMUnFhgGhzOj7xn+WluRQ5bsA4A=; b=mHzqauryxWqiJhsXX519qgC/XvVGPTToLbjIMDtRBIXlluucPcVrT4NSWn0dTQNRKc ohvzm1+5gQILppRAnJSmmTGiLyJxjIBpPBcRPMUB7+ub7ke4xCwq6Hdd0RapW5loHlyp KeGQf0HaEd6yjcWFIrHXr/iauKC3YI48KJcreUbNA65EPggcExzigbMdo6iB7UpOApm9 F4stavSuo+gKDZuqxygYDuS45PW4o6C5xiRAvFsfIHn7eKlZFDxDGflG0YM+n7ophqVo ZVHMZBiNUeZDXJprspDfQEMbC0QuWyb4f7JbvbA7Qy/OifikI66Ozl17BywWfCsw862m nRSA== 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=p2rA8r1vRndMpn7srMUnFhgGhzOj7xn+WluRQ5bsA4A=; b=TZkzAcRALUYXi7s+XhdzSJOvIEk4WEzOkvF+viIVe6xWdhGQvSNxZG6vfYm7n8Is7L bvYRjHaR2QG0c3atJHO0TxS80ulvxHb4RIrY8NeddfyDyYBaKT2HXuzZ3Q6TSPHrGl1e KcXlr3yrQq1NuOoejdSCHNRBGXITj1ZOmxm0IFJtCTMI5/DWEGuoTKG9I2Efbq0CtXy8 6c6ftD8zL4ADLPFhMMCYBEb00OvExksdToaOAnpWUuRBGKOLvtUQMDPXnRQ5ZbXNFPfM 8OCNsOjpV/B/VQ+a1N2egqDcaLFXsV9Jfw35G3F2JPe6hlTILKwitQe4Adzsez2dFYYn t7Nw== X-Gm-Message-State: AO0yUKWuLtO+hXToRMlj0UgoLFqM7nLon5zLSteD93HVZBxTkQdWNbED hlzQjD3n8BC+vWLLs3IVQrpUrdx1aKi8D/jD02Q= X-Google-Smtp-Source: AK7set/czFoeb6JnB9ReubAWJwYO5jY2BrfNQhvn7PFazujdE411zye5O68lhGjhi8fh2nldd78g/A== X-Received: by 2002:ad4:5d65:0:b0:56e:b4e0:1bfc with SMTP id fn5-20020ad45d65000000b0056eb4e01bfcmr6137166qvb.11.1676931042265; Mon, 20 Feb 2023 14:10:42 -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 q13-20020a05620a024d00b006f9ddaaf01esm9766986qkn.102.2023.02.20.14.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 14:10:41 -0800 (PST) From: Jonathan Cormier Date: Mon, 20 Feb 2023 17:10:33 -0500 Subject: [PATCH v3 1/3] drm/bridge: tfp410: Support basic I2C interface MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v3-1-a85d5f0f50f1@criticallink.com> References: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@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=6492; i=jcormier@criticallink.com; h=from:subject:message-id; bh=XWThcU4Z36mFj7a764RgSd+QtYAddWcIDsaMnqm/1io=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj8+/fbtGOndOyo0WswmdkokqdCTIFg5SdE1jlnh1q 6nYAEvSJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY/Pv3wAKCRDc1/0uCzbrqoBYD/ 9OavAPgKYdYrV1zvdJ/h+Ide2dnlgqfZPL18AN//wLzU1BabFk/duIci3N5Zjw8zlQcXbDSP2sptrk ZsQEkdqVLvDyVVfG+gmFIum4K+wyJIqhHFqBL1s5kTSFZCCcviodW9EfKXU7TpOhMjDRg04P+P9DEy 6haeKMJLnoG5y8UlfErBrIeH+sob0zm8fkdPYnSXMJnYGgPx0cgwwuFIyCbLn+Vv1BuDQuaacP1aRo 3TNL2l29HJw22mAX4XeFlqalc0MC7tSrZjYRt8uabgH+Q4BsqrUn6CKiXWKlRCGdeGHPz9biC27erL dI/rZvdHRFsI0gt2I1MH3NgL1kVrs7Ms+mDk+DYK4La/kgdigNzGumKz2SlwaP0ZAZ16xJvIYIf74m kKDhWg9Yeg7ZG1DX67K3+MBZIhodD+dsrki5fX5bUq6rX0K+1EDK7WyuESRK2Ax2cMGObe3J0+eKAn 1zi1SKVTVy+m8d9esDuALiyfpTYOIn3rECCYXrlep7rS4bZ+Z+vbYPqoTUp/OYBj5BdwJGq/RL/+9h wS3iR26RCRR3FEtVVesNx9lEZ2wC+HkRBLwhZKASeo3JkVLK/n+OYgA2UKVsnzeW/7shxXTHT2SQ7Y V0gdTH//bYrHogVDE71KkUHlgp8mzaDqO1Fbwgr4hahSGFrVQ3tWoTTLPxQA== 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 Signed-off-by: Jonathan Cormier Reviewed-by: Neil Armstrong --- 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 Mon Feb 20 22:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13147159 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 6D2E1C61DA3 for ; Mon, 20 Feb 2023 22:11:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5974C10E7D4; Mon, 20 Feb 2023 22:10:53 +0000 (UTC) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2A0010E7D0 for ; Mon, 20 Feb 2023 22:10:44 +0000 (UTC) Received: by mail-qv1-xf2d.google.com with SMTP id y12so2681216qvt.8 for ; Mon, 20 Feb 2023 14:10:44 -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=THHRayynm5AbgmOQpvB3lJW0friOEzmgv0B/wGzZtaA=; b=cd4XXa3fNnrg4LJTnbDxcbv3CN5vQu9dFW7K/yevG1ESO+5qoiYifACic1FvzLTahl 70UcW1Q8xLIUxahrwD9L377EfRLCR0pWCU2uAdgU42SY+ar3FPPzQ82ksKDUsmgOfys/ IbntLfDc5qgbr7YeEqCz4BOLKCAOqjoptTEp5cpYWumbWaSYLgUAlx3qC1irSU7kAso1 lfUCy0ei8319yKCts5WXcg3IHl13OvAH87QidFj9QXgrri/5mSp9e7voGdC5tU+DfFhH tSSObiPjVWneoPSyWLHE1OZWO5Wz308RjFowk7hzjgqlzzHyYOXuinnidDaVeDhYL4t9 dvXg== 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=THHRayynm5AbgmOQpvB3lJW0friOEzmgv0B/wGzZtaA=; b=yFWfxEaeTwDhlWBgStQtUOpz4QjoPEJsyVocS4TZaerdwsJPYJDVcf7KX5uEAjureN US8MAxqpO1ofzn8j19bGBaiEmpXnHV/Z4WdsQiFVkejoFMqbMA99y7ByeCnJQubRBBwQ XnJBQ96kMxsQxpTVj0+7TxwtBaU6eyU8JiQoXfYqSaJmTkXw5o/fg7v86cdDBvGcUHa3 Z4GAukZEfnKXJvyUiLJZpVWq3xDesanqVRGLJdrzD70cbaPHmJBs1IjiGQIKdWWmtLAx uXHh03rcZ1tOv54R+DWW6z4Ei7x43AHX8Ff9I8mjKrn5gOWkpMPBZdL7Rqh+ZJf5iNZY ewqg== X-Gm-Message-State: AO0yUKU820mT/NfINAoF2Kh3qNOYmEOa5lC9WSH1ejz1MxezR49K1mSC jKDWTzUPcyIG+pSwKF+ATuVIbRWXpmDsSdzcPpw= X-Google-Smtp-Source: AK7set9k8VGbxQBwp63BLeFM6sBGZ9Dgy6JIHVTflubD0lj+FqQd0anGtxp8/ti9qlstxkTSB7LYcw== X-Received: by 2002:a05:6214:400c:b0:570:ee5c:2953 with SMTP id kd12-20020a056214400c00b00570ee5c2953mr5529273qvb.11.1676931043469; Mon, 20 Feb 2023 14:10:43 -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 q13-20020a05620a024d00b006f9ddaaf01esm9766986qkn.102.2023.02.20.14.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 14:10:43 -0800 (PST) From: Jonathan Cormier Date: Mon, 20 Feb 2023 17:10:34 -0500 Subject: [PATCH v3 2/3] drm/bridge: tfp410: Fix logic to configured polled HPD MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v3-2-a85d5f0f50f1@criticallink.com> References: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@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=1011; i=jcormier@criticallink.com; h=from:subject:message-id; bh=mvqilqhA2ozv8fVrZmSQf6YxF7B70T7NT6GdEuGjaz8=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj8+/gQc8xd6ZnX+LNtCrbMa8giQdgnGzf3ueFThk4 LUUWk/CJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY/Pv4AAKCRDc1/0uCzbrqqiKEA CrUHS+hGQ+sFkAozQQYuVP4QYluZf5P9PCTtwe447h+TIRNyzmn2K5oc8gx5VNI4HAWreqeJoAsm8H A+4DbWgt+2ms6pIcgx4qiSrRWYxYjIT47n0HLdrwgZSGtlm94K8B72xhxZjf+3qD0b/xz73/6pgDtH IcfH+CZsGWuXNuxeDWK3S6YoqR5BUB3qrp78nJj/gajYET/ny5SfWja0R//ev6VCVP41cVL8az4LRi P58udsLnAufv/JcNxd24LfVhf6gaDbjYpI62vgzihCgRhL95hrWYW7KYRWkkRaS5BgcvIZiS9eyg6f 8XXkijOqjKykbMnTCPVFm5eTzANa8CHekSHZFpx3mL/coXKb249QMED+ug9Osuwes3Gj8KDRqVKUwj b2MiTbIouWH/5GVDm8BWsqkj/x3LVbeB8pXiKbRkOMP+mlr9s8jNuc0OScUp3f/IRzAYuJbTd/xorf 3ttPy7RS2QM2jYgZuZOzKh3dZ4fNqMo/GXY/T2n2sV6bEfxlYkIufxhoIradqG6nioT6Zn+9ebQ9AU 9UitqfVXvj2toe0IHPVu/Qh4cS+icyCBhJuQG+3RMeDFPrUrR9MCzQylUfXPhGfzuGS68VzwoNLfuq VvV3a/oAwQ86bi+J3vTeE0BGC7m005ilVTDoeNjE0fBX6Ot/DF6nuhyQV7Ag== 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. Signed-off-by: Michael Williamson Signed-off-by: Jonathan Cormier Reviewed-by: Neil Armstrong --- 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 Mon Feb 20 22:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Cormier X-Patchwork-Id: 13147160 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 C83D3C61DA3 for ; Mon, 20 Feb 2023 22:11:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A27D10E7D7; Mon, 20 Feb 2023 22:10:54 +0000 (UTC) Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7ED010E7D3 for ; Mon, 20 Feb 2023 22:10:45 +0000 (UTC) Received: by mail-qt1-x831.google.com with SMTP id d5so2840486qtn.13 for ; Mon, 20 Feb 2023 14:10:45 -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=7++FPNmCT11inHBtqfYJtM4/xAJgiLCvorUz1cWzIv4=; b=RLcaWVGFtPjStOXJrnuKglAddJFhMNvM6D2JJSDTT8hyU9jFMLqOJGEGk0ajfMoBrM PfC5atL0Ls1yLQ87fd0Ypl49U6ULpfyvMYtGWxUA1GlWMWK21gVi+JabNX4WNqVbRXKV JjEGjOASQTJNQOIjeY8p7eAqAAcdpIIWy6vb0Q7JFSEbN6dJPj+/tD0zvEPKzjtj0sWo hutyy7WBOYuXXo15XyY02NyWItQh+mM7JM7/d31A9LIx5r7kMeY6TlxfJ4oeaE3KxP5u P4GLYRCM8pR/f72Z2jhuAHQriYKsDM6fF+U8A18Rtp+SFLeBwfphtZT1nvPOQiPRWCiS UNIw== 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=7++FPNmCT11inHBtqfYJtM4/xAJgiLCvorUz1cWzIv4=; b=nvqBfRPElwzhdVUPjBUsyq8Me5q/lG1/YjUe4AliiUGIC+oV8GW/vzJPL8GUtElruh vfNKwg+V+Q89vhGYfGnDoqyaq7GopEOKW/ftaFQ8WsQdn1p/8qmfrtl0eRL3FINVVf9M H1n8taWeswF9PdyiXYbcbjAs5zTIs4GNjj3Bn/WONV4waSKHNr8PN5m7X2Hqp9N9X/9p ZeqD2Pxusitd3hkwq7WaVFZLouS8GZDKRHUlWEc+bIMUSazXOZgd8ZAuQ+PyzfS2q3m7 8MjswEJKEDuEFRyiyTrVH+/pw7XsJ1KBjYw+3do8sf/gTGI8ODbFsVmyc+P+6/YHYzB/ vq9Q== X-Gm-Message-State: AO0yUKUVRDOI0Rk+VnJQtGgoJTYIdLMJ6vb0ZPUvOLkekXSGqYwsr1Oj CDhz2ynZiP6Jya4zCzFM1FT6NRinnAmqFiLgCyE= X-Google-Smtp-Source: AK7set8+lN+ZdfMWj1HtD2SgZdImvXC1J5hpiQyovkTG9eYDIZ1UF3Sx07OaCz5yt6sO+mHlPAI9ZA== X-Received: by 2002:a05:622a:44f:b0:3ba:13dd:f253 with SMTP id o15-20020a05622a044f00b003ba13ddf253mr3677795qtx.7.1676931044624; Mon, 20 Feb 2023 14:10:44 -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 q13-20020a05620a024d00b006f9ddaaf01esm9766986qkn.102.2023.02.20.14.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 14:10:44 -0800 (PST) From: Jonathan Cormier Date: Mon, 20 Feb 2023 17:10:35 -0500 Subject: [PATCH v3 3/3] drm/bridge: tfp410: If connected, use I2C for polled HPD status. MIME-Version: 1.0 Message-Id: <20230125-tfp410_i2c-v3-3-a85d5f0f50f1@criticallink.com> References: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@criticallink.com> In-Reply-To: <20230125-tfp410_i2c-v3-0-a85d5f0f50f1@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=1511; i=jcormier@criticallink.com; h=from:subject:message-id; bh=mnMRLzTQ5OvUKpoF4H4mdtxVS/UwcOVTBoA/DdsbVck=; b=owEBbQKS/ZANAwAKAdzX/S4LNuuqAcsmYgBj8+/gbxbQIXcBj3r2SwiKKjNAonNiEYXuvWSNoLKp yrmAJ+KJAjMEAAEKAB0WIQT/MozqCeZtYxNnVN/c1/0uCzbrqgUCY/Pv4AAKCRDc1/0uCzbrqvBoD/ 4yR8Qxx7wDUg3SL3m4/8rA1G+JdIXlFJz5dcG8z5fkFfu0tsqWok3HvJqF0cWOzUbu9RZ8J2kys+xy zgUQisH1V64vHDi5YyytNoXTNRPEa+oJfpykZQt/0NFC5WtkKQC+RNxEXrG9vaO7uzLRnVCZbaCPLb 3QYld7UNCpbHgBqcY2AqJkWJzJNcx/piAG+3Z6vh40syyMfRJmWOuFh10H9+6OYicaGK9XJ7eDI08/ b6TRdpK0tMVULOhyua13no6DqO7njXz25b1d0dzUYgPZpWf2ryrolcyZoAs/jFlm6pNBsIs54Nv+kA 9N3AO6ahzlQ9VV+YebIyXiPT8DezpZ9lz/4QUOks1HHaMkXgUQHgB8ukQKErmChbSV/KlfVVRHy8ih ZDOXoMSE1S/9JMEyDFKZSynNCKZr+chwoLOlB0l86ewB0sL5YONu2Mz2qm7xhBNNxIAKmAzjBdTpqt BOw0EMZy+mJNG5ffljDHO8gkLZI6vUtkIObWqEs9ObQWJtHkakatQJQhkqUCyODFuXNcAgzGqy9FRY gNBqVt3HbTySwXkgYtQlOQh9cOB/k3yWv+0Txom0TH+CMr0QcVHJUQpkvPGLw8xYigWyMQqz4jRX94 vpDrBxgXVUoty24lmoQOLE/xRGryb0EO/zP52tX39J2Pma+DAHqTEntUkn4w== 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 Signed-off-by: Jonathan Cormier Reviewed-by: Neil Armstrong --- 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); }