From patchwork Wed May 18 23:36:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854281 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 7DDC3C433F5 for ; Wed, 18 May 2022 23:36:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51A6F10EA94; Wed, 18 May 2022 23:36:27 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8A3410EA94 for ; Wed, 18 May 2022 23:36:25 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7994883B46; Thu, 19 May 2022 01:36:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652916983; bh=OTghdqOx7JNAymlUAzuOnYDTk4dqIYnAqyVbpJHr7pU=; h=From:To:Cc:Subject:Date:From; b=Px87mgPlv4u7jl0VMjTYB9aQAh2M/0Myjb3FVxcAxzJLdZBOJSd7lGyvMunEZzlGS b1CpePvl5HxxLcQcx8HiYMu+9FaG0tegaqp2OqR9VnsBvAgd6zuvF4ab8V1bvMDMSp NoweViBIxEEbBtsLVDZpJxA8qPTgsKgleEJIy0h6LgQTU+JUyTS9/96iMDeC4KkbZ5 s3LIOIs2OoHgcMwbNdQsz+9m3k79gAfaw5K1FlUtFKfu7/0ma142QS6ZU0aL/lLQL4 wIUux4/3l55tGzs3TnxyzNNhnrV7v5sqzovmIXDS+hNBBONBm17J7wsJro/Tb4erfN eCStoLkIRN1hQ== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/bridge: tc358767: Handle dsi_lanes == 0 as invalid Date: Thu, 19 May 2022 01:36:00 +0200 Message-Id: <20220518233602.248185-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , Jonas Karlman , Neil Armstrong , robert.foss@linaro.org, Maxime Ripard , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Handle empty data-lanes = < >; property, which translates to dsi_lanes = 0 as invalid. Fixes: bbfd3190b6562 ("drm/bridge: tc358767: Add DSI-to-DPI mode support") Signed-off-by: Marek Vasut Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Lucas Stach Cc: Marek Vasut Cc: Maxime Ripard Cc: Neil Armstrong Cc: Robert Foss Cc: Sam Ravnborg Reviewed-by: Andrzej Hajda Reviewed-by: Lucas Stach --- drivers/gpu/drm/bridge/tc358767.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 7366968dd7b21..84e6b5aa8dd1f 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1902,7 +1902,7 @@ static int tc_mipi_dsi_host_attach(struct tc_data *tc) of_node_put(host_node); of_node_put(endpoint); - if (dsi_lanes < 0 || dsi_lanes > 4) + if (dsi_lanes <= 0 || dsi_lanes > 4) return -EINVAL; if (!host) From patchwork Wed May 18 23:36:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854282 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 7EA1DC433F5 for ; Wed, 18 May 2022 23:36:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 241DB10EBB8; Wed, 18 May 2022 23:36:28 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B51210EA94 for ; Wed, 18 May 2022 23:36:26 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 14D7F83B63; Thu, 19 May 2022 01:36:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652916984; bh=CwQOPcaWGh71awRXsPO8GV0BmF0+XwUw7n+g+BZAkZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxK2mYn330IerRLNFKBfoaFonx1uVT84dpteDNJDcTG383mOLscqn1bK/kCojVW0R IyoCGUdRrzAQry8Xrc1yj9WNTk1/tUwuJbFHmfkS6IrOZUBjOa1u3ErWRzvlNV21io cwCPsMLtG8t73YkQO0urOz4N9RXxFSYYEj8jS5YSwJYyBQNVUeOMvaEqOdhECFOTBh R7b11rAHKS7h9cvh89eterUaPgi5dtmO2KsYRRpNjJtAovPip2IwN/eTPiFnp1rbEw oHBFRlS10NCgYs4PbQTT/vhG5inmjwd5zuAiH1xcxHDDHHLS2NlGMr1cAONRNJft91 rd+QlSRKWhscg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/bridge: tc358767: Report DSI-to-(e)DP as supported Date: Thu, 19 May 2022 01:36:01 +0200 Message-Id: <20220518233602.248185-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518233602.248185-1-marex@denx.de> References: <20220518233602.248185-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , Jonas Karlman , Neil Armstrong , robert.foss@linaro.org, Maxime Ripard , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DSI-to-e(DP) mode is now supported, update the driver comment to reflect this. No functional change. Fixes: 3080c21a043ab ("drm/bridge: tc358767: Add DSI-to-(e)DP mode support") Signed-off-by: Marek Vasut Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Lucas Stach Cc: Marek Vasut Cc: Maxime Ripard Cc: Neil Armstrong Cc: Robert Foss Cc: Sam Ravnborg Reviewed-by: Andrzej Hajda Reviewed-by: Lucas Stach --- drivers/gpu/drm/bridge/tc358767.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 84e6b5aa8dd1f..a8bb6de9e600a 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -6,7 +6,7 @@ * The following modes are supported: * DPI->(e)DP -- supported * DSI->DPI .... supported - * DSI->(e)DP .. NOT supported + * DSI->(e)DP .. supported * * Copyright (C) 2016 CogentEmbedded Inc * Author: Andrey Gusakov From patchwork Wed May 18 23:36:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854283 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 69CEBC433F5 for ; Wed, 18 May 2022 23:36:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2CC210EC7F; Wed, 18 May 2022 23:36:33 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 913FE10EB28 for ; Wed, 18 May 2022 23:36:26 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 8B29083C01; Thu, 19 May 2022 01:36:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652916985; bh=AX59G+EPYeE8a2vIvPCXCxbnuyZJA8H59V6RmalLsJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iu3hHOHVPey8kvxGFIcTwXdmuEaQGuv/PlfMcRgbk5sWh0SKThRRxnSilIIixL1wu PBrwkv8M+qoXtJZIE76xrI8QDt3WPGtlfF+QCtpZlO4UBiWTyNGueMs2avXCOo0ENa HOXdjvwXTpAD8Swu0z53eQD+1uBPyE4LuX8cMvBJwh/DMw/D2pxI5Zn9Mv8wkHYaMV jxAZtQsGAm7GHQSjurdba7llGZbcZkWKEGPCXknTnstyeJTapOqiykAt/wJ5trcbWW iWa43PDrSrgGHJvGHUI8k/0z6/B/SCrleZcZ6UaWCaH4ko1X/8P86Du4LlG3XCbXrD 0VvPq3KaW7lVg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/bridge: tc358767: Make sure Refclk clock are enabled Date: Thu, 19 May 2022 01:36:02 +0200 Message-Id: <20220518233602.248185-3-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518233602.248185-1-marex@denx.de> References: <20220518233602.248185-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , Jonas Karlman , Neil Armstrong , robert.foss@linaro.org, Maxime Ripard , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Refclk may be supplied by SoC clock output instead of crystal oscillator, make sure the clock are enabled before any other action is performed with the bridge chip, otherwise it may either fail to operate at all, or miss reset GPIO toggle. Fixes: 7caff0fc4296e ("drm/bridge: tc358767: Add DPI to eDP bridge driver") Signed-off-by: Marek Vasut Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Lucas Stach Cc: Marek Vasut Cc: Maxime Ripard Cc: Neil Armstrong Cc: Robert Foss Cc: Sam Ravnborg --- drivers/gpu/drm/bridge/tc358767.c | 51 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index a8bb6de9e600a..4b15acbc73c4e 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -2055,10 +2055,24 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) if (ret) return ret; + tc->refclk = devm_clk_get(dev, "ref"); + if (IS_ERR(tc->refclk)) { + ret = PTR_ERR(tc->refclk); + dev_err(dev, "Failed to get refclk: %d\n", ret); + return ret; + } + + clk_prepare_enable(tc->refclk); + + /* tRSTW = 100 cycles , at 13 MHz that is ~7.69 us */ + usleep_range(10, 15); + /* Shut down GPIO is optional */ tc->sd_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); - if (IS_ERR(tc->sd_gpio)) - return PTR_ERR(tc->sd_gpio); + if (IS_ERR(tc->sd_gpio)) { + ret = PTR_ERR(tc->sd_gpio); + goto err_clk; + } if (tc->sd_gpio) { gpiod_set_value_cansleep(tc->sd_gpio, 0); @@ -2067,26 +2081,21 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Reset GPIO is optional */ tc->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(tc->reset_gpio)) - return PTR_ERR(tc->reset_gpio); + if (IS_ERR(tc->reset_gpio)) { + ret = PTR_ERR(tc->reset_gpio); + goto err_clk; + } if (tc->reset_gpio) { gpiod_set_value_cansleep(tc->reset_gpio, 1); usleep_range(5000, 10000); } - tc->refclk = devm_clk_get(dev, "ref"); - if (IS_ERR(tc->refclk)) { - ret = PTR_ERR(tc->refclk); - dev_err(dev, "Failed to get refclk: %d\n", ret); - return ret; - } - tc->regmap = devm_regmap_init_i2c(client, &tc_regmap_config); if (IS_ERR(tc->regmap)) { ret = PTR_ERR(tc->regmap); dev_err(dev, "Failed to initialize regmap: %d\n", ret); - return ret; + goto err_clk; } ret = of_property_read_u32(dev->of_node, "toshiba,hpd-pin", @@ -2096,7 +2105,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) } else { if (tc->hpd_pin < 0 || tc->hpd_pin > 1) { dev_err(dev, "failed to parse HPD number\n"); - return ret; + goto err_clk; } } @@ -2110,7 +2119,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) "tc358767-irq", tc); if (ret) { dev_err(dev, "failed to register dp interrupt\n"); - return ret; + goto err_clk; } tc->have_irq = true; @@ -2119,12 +2128,13 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) ret = regmap_read(tc->regmap, TC_IDREG, &tc->rev); if (ret) { dev_err(tc->dev, "can not read device ID: %d\n", ret); - return ret; + goto err_clk; } if ((tc->rev != 0x6601) && (tc->rev != 0x6603)) { dev_err(tc->dev, "invalid device ID: 0x%08x\n", tc->rev); - return -EINVAL; + ret = -EINVAL; + goto err_clk; } tc->assr = (tc->rev == 0x6601); /* Enable ASSR for eDP panels */ @@ -2164,7 +2174,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) if (tc->bridge.type != DRM_MODE_CONNECTOR_DPI) { /* (e)DP output */ ret = tc_aux_link_setup(tc); if (ret) - return ret; + goto err_clk; } tc->bridge.of_node = dev->of_node; @@ -2176,11 +2186,15 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) ret = tc_mipi_dsi_host_attach(tc); if (ret) { drm_bridge_remove(&tc->bridge); - return ret; + goto err_clk; } } return 0; + +err_clk: + clk_disable_unprepare(tc->refclk); + return ret; } static int tc_remove(struct i2c_client *client) @@ -2188,6 +2202,7 @@ static int tc_remove(struct i2c_client *client) struct tc_data *tc = i2c_get_clientdata(client); drm_bridge_remove(&tc->bridge); + clk_disable_unprepare(tc->refclk); return 0; }