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: 655176 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B6B3C61DA3 for ; Mon, 20 Feb 2023 22:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229885AbjBTWKq (ORCPT ); Mon, 20 Feb 2023 17:10:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbjBTWKo (ORCPT ); Mon, 20 Feb 2023 17:10:44 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51DDFBDDD for ; Mon, 20 Feb 2023 14:10:43 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id bo10so2011412qvb.12 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=aKxaYlfwa6U3q3vs24rNdMnMhZO2pY3g9xvBuvihcLLrM9dkShmepbyn4ziE3aFqrc n+pXdycTdhU5YRVLOo+FlqL+HdjmtZlA32eIiE7IyAXzqKmqF19nqTPtjE8PHhMOupp9 vYAEu5DtdcmbDMTyVvIzXHnsPJZ8N856Iad9yXnu3Vd1yvcpLkqNZDxe2YnrF3FTCLwh vVHpEgrxipdXRnyQ+rOsYiShbC/B+6ZTva5URWXSAlhGUEuUTL7UlTu3y0wLOxTmH7C0 r815IdzSFkfvpclJ8iPdoc2+ZhfIemOKrYI7BaegHULaCRqo1ZgkEWpbt87sGin/ncOg XXHg== X-Gm-Message-State: AO0yUKWykBaUHvxpBuzjOeCqOa+rkR4v8ZFomzfIF8gW/jC7d7ubl4d5 V0hegHRszY9tjk+/xyLFDlPJ9Q== 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 Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Williamson , Bob Duke , Jonathan Cormier 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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: 655548 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B7FC677F1 for ; Mon, 20 Feb 2023 22:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbjBTWKr (ORCPT ); Mon, 20 Feb 2023 17:10:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232572AbjBTWKp (ORCPT ); Mon, 20 Feb 2023 17:10:45 -0500 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D55BDE7 for ; Mon, 20 Feb 2023 14:10:44 -0800 (PST) Received: by mail-qv1-xf2e.google.com with SMTP id oj14so2918942qvb.0 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=RDA5pL1dvSuMwkolg+ue23Kuvl863WUoUbv+16Q5ef1SMw6dbF5m009aUbJHwqZbeX lvhmtXucXjj/bV3GnDZYBTOeNmT+h+FjM75YnaSXGp+/gBKnTjSxdWocKCbFkXcOYNvg taHHhDl7sracV/bn8O4DJ1Skhtw9g+S87X1lHZ4nGLX60947J2gVnnpFdm4oOcNAMbln IFX4vxHl/QHyaPsfAKQgtD2kVyWwEHxyuqK8FWKNSniyLqgfWIVUIUUKTDR7OETdoq2k BD6ropLuSAJ24giu+aydI4UjI6QLnZwGMLlEBVxAZacKlPfROx8uFF9JiUAMIcy2mLDp QnwQ== X-Gm-Message-State: AO0yUKUFFuazuezuThrGYL6HnKbiwXMUtMYn4Xqy/F9Srutfp3aEuLMp z22snijwmdRV3hNWgsscX+vMMA== 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 Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Williamson , Bob Duke , Jonathan Cormier 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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: 655175 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3044C636D6 for ; Mon, 20 Feb 2023 22:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232596AbjBTWKs (ORCPT ); Mon, 20 Feb 2023 17:10:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbjBTWKq (ORCPT ); Mon, 20 Feb 2023 17:10:46 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7D9FF23 for ; Mon, 20 Feb 2023 14:10:45 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id x1so3639427qtw.3 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=GPoRT827mTAxMQ0lbzJQPbLDf9/4LbwTQAZn7hWB6QmjTAQm7GniV9fy/v4o1PEsSa mAyoE8OTPmSUhN0T7fsHl3fx/L/uY+v4ghVqhzC7+wNWmzfi7zXnr414MNaL73+EFKuD rkbPlkHisFULD6Q/DqB1foKCZ0JYEOzUtNApBlI+a2EmCq2g/JHaGjRAplHj3Wg3afLg VZuZ/T4tvHqAqOqUfBoSC3Dr85o+NFzVqaSVHN/C7mv44+ZXLrNyJty8C98F6Vcn9keM OfGmt/WkUoYPvtOT1AyjAOB0OkE+GwHwKxpsjdmQfXKprVU9QahQ578KOybDqvAW2xMq PaAw== X-Gm-Message-State: AO0yUKWcCqcK+uYsYDPY/Js7C4lVdALH856o25xiZ82cEo92SsIyRLMo 7gmXyOzqKisyu84ocEgjErT6Cg== 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 Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Williamson , Bob Duke , Jonathan Cormier 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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); }