Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1575697lqo; Sun, 12 May 2024 08:24:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDbeQQzKTw3FSoh5h+6M8Pn0+BLApvJvnyGeCYdwTVKY7bsXHVPx4/54LtVRdmzDvy/gqFJmVt5m3ZemBUKsmXfD2zDH3Rb5hZ13eCOw== X-Google-Smtp-Source: AGHT+IFjwKqkeYs5kjxtFF9/klSsw/dUkrmNewpRASUpXtxV3MuISuAoZZMy341deiFUxfbwPcMn X-Received: by 2002:a05:622a:44e:b0:43d:f553:7069 with SMTP id d75a77b69052e-43dfdd0b64bmr75239951cf.56.1715527447264; Sun, 12 May 2024 08:24:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715527447; cv=pass; d=google.com; s=arc-20160816; b=e1Uwzx4Dq07Kjmjt/OxYiIHr88u07/tuCOXeuzYs7Zj+e7HKTpY1OBqaf8FI4hJv8U y+KlHUfZNoBkKtxP6LaI6b6pZhicjAC4IrMLHdRZyJ7fctzMa4igd3Pavw4Baxip8dbG N8ApZ+YfDSxvSvW83ENePUdE+ixE4j9aX2HuCmfwleH4ai8jiWpJJ3+2/lvv0pID3c0r ldW5EHfWuMJN5LV1iT+PBcKsojTdimDLVvAZ7KCKyAOUoZhqZLNCWWcvUtbEMKA2OIQO q2xzM3onOYa0gmKOFvlbbuSjz0SLDOGnDiKRkbW4RWdzQe2fBU4sNXJtKZiwA72kjfhH mzxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=iPt9kUUsTlBAWuNAoPBMtkKgtnn+LDWAMV58Vn9IFvA=; fh=GpyVZODzC5TLturO4IWbmNffOEtKSEMvAO2gqRlvhzs=; b=p8H/g/0pCR0DU7MIedALWTMjcaSd7U5M2x9uozgE1B6pYkzUFde1+yqu2T3WiEPVOZ Su69q+45WCch9TcYTH+rqwVYN4DZqjuet3hckBOZ3gZDYt84SolzGfYj+ictRCbWDnRZ 8vJ1os5tb8hGQITZ6+X86PltP6Mg8McPNQ6XxUBdnKj3gjB+y81r/h2gIZIUHKq2pdzr n3oovIMimFcbIscQ+uN6zUf8rb5mclsGkggR8aie8FuOjighs9trApV6FUa4z9wefc+/ lkhBeWyg5HVJuX4gzySgCr+g9zkfq0BdomfdPVcmlCBKqIF8ylj7nOYpP53LIK43/ybV eEIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gDfarrKr; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-176914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df9463fc3si69477841cf.787.2024.05.12.08.24.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 08:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gDfarrKr; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-176914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EB9971C208D3 for ; Sun, 12 May 2024 15:24:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69B7A3F8F1; Sun, 12 May 2024 15:24:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="gDfarrKr" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 310792576E; Sun, 12 May 2024 15:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715527439; cv=none; b=pJ1vu8hYYwBwf/cIO94yYJ81W5YPgPgHCGEifGwQ9NkpQ+CNof40OYYk3goGCKiNIs6sv0rmk1HOpMguS0wNj2o0Qf8wlBlk1O0jZO4puo7ybeqe+gwJl2ayA3PX8C3wFEPuuY39suM50BoGXklXdTK3WxSYEQG2QAR2vShR+1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715527439; c=relaxed/simple; bh=1jDLyqkbOZ+d216VZJbeO6tJvvYjODjQOQifg08CX3M=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Zv4abbR2VoZsJ0gBmDSd/H5Q5TIUEEbAw3qL4YAnI8SbLj4eIRE91edFWzPNslGg5tf0lUunqPGA+KeBbIHBpcCNOb6AL6ipug+xOG+CNJz9IcLPNjrqPqnw2TKqWg4r58KOzVe3/IcdW4hkan20vnEdr7FJLlFfb18WPg+phy8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=gDfarrKr; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44CFNOLi104054; Sun, 12 May 2024 10:23:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715527404; bh=iPt9kUUsTlBAWuNAoPBMtkKgtnn+LDWAMV58Vn9IFvA=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=gDfarrKrX3LbWffw/cxWr8PUQ1no0AAh2nX2j/FMZVG6mNQ1MYrCN/N1oBL8wuTPC tSdNxtNLhQLXWIb2eLxBfiRxcG0vjj1ovcU605jREoeUuqFQPgVSSOU8ndwQPfrRlg Al+C8/6X8adOaWSS2kb8rj8iLWHz6sy1ShRdAf8w= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44CFNO90022407 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 12 May 2024 10:23:24 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sun, 12 May 2024 10:23:23 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sun, 12 May 2024 10:23:23 -0500 Received: from [10.249.131.75] ([10.249.131.75]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44CFNEba016476; Sun, 12 May 2024 10:23:15 -0500 Message-ID: Date: Sun, 12 May 2024 20:53:12 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] drm/tidss: Add OLDI bridge support To: Francesco Dolcini CC: Tomi Valkeinen , Jyri Sarha , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Neil Armstrong , Laurent Pinchart , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , DRI Development List , Devicetree List , Linux Kernel List , Nishanth Menon , Vignesh Raghavendra , Praneeth Bajjuri , Udit Kumar , Alexander Sverdlin , Randolph Sapp , Devarsh Thakkar , Jayesh Choudhary , Jai Luthra References: <20240511193055.1686149-1-a-bhatia1@ti.com> <20240511193055.1686149-5-a-bhatia1@ti.com> Content-Language: en-US From: Aradhya Bhatia In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Hi Francesco, On 12/05/24 17:18, Francesco Dolcini wrote: > Hello Aradhya, thanks for you patch, I should be able to test your patch on my > hardware in the coming days. That's appreciated. Thank you! =) > > On Sun, May 12, 2024 at 01:00:55AM +0530, Aradhya Bhatia wrote: >> Up till now, the OLDI support in tidss was integrated within the tidss dispc. >> This was fine till the OLDI was one-to-mapped with the DSS video-port (VP). >> The AM62 and AM62P SoCs have 2 OLDI TXes that can support dual-lvds / lvds-clone >> modes. >> >> Add OLDI TXes as separate DRM bridge entities to better support the new LVDS >> configurations. >> >> Signed-off-by: Aradhya Bhatia >> --- >> drivers/gpu/drm/tidss/Makefile | 3 +- >> drivers/gpu/drm/tidss/tidss_dispc.c | 11 +- >> drivers/gpu/drm/tidss/tidss_dispc.h | 4 + >> drivers/gpu/drm/tidss/tidss_drv.c | 13 +- >> drivers/gpu/drm/tidss/tidss_drv.h | 4 + >> drivers/gpu/drm/tidss/tidss_oldi.c | 568 ++++++++++++++++++++++++++++ >> drivers/gpu/drm/tidss/tidss_oldi.h | 73 ++++ >> 7 files changed, 673 insertions(+), 3 deletions(-) >> create mode 100644 drivers/gpu/drm/tidss/tidss_oldi.c >> create mode 100644 drivers/gpu/drm/tidss/tidss_oldi.h >> >> diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c >> index d15f836dca95..fd90e8498cc2 100644 >> --- a/drivers/gpu/drm/tidss/tidss_drv.c >> +++ b/drivers/gpu/drm/tidss/tidss_drv.c >> @@ -23,6 +23,7 @@ >> #include "tidss_drv.h" >> #include "tidss_kms.h" >> #include "tidss_irq.h" >> +#include "tidss_oldi.h" >> >> /* Power management */ >> >> @@ -140,10 +141,17 @@ static int tidss_probe(struct platform_device *pdev) >> >> spin_lock_init(&tidss->wait_lock); >> >> + ret = tidss_oldi_init(tidss); >> + if (ret) { >> + if (ret != -EPROBE_DEFER) >> + dev_err(dev, "failed to init OLDI (%d)\n", ret); >> + return ret; >> + } > > return dev_err_probe() > >> diff --git a/drivers/gpu/drm/tidss/tidss_oldi.c b/drivers/gpu/drm/tidss/tidss_oldi.c >> new file mode 100644 >> index 000000000000..fd96ca815542 >> --- /dev/null >> +++ b/drivers/gpu/drm/tidss/tidss_oldi.c >> @@ -0,0 +1,568 @@ > > ... > >> + ret = drm_of_find_panel_or_bridge(child, OLDI_OURPUT_PORT, -1, >> + &panel, &bridge); >> + if (ret) { >> + /* >> + * Either there was no OLDI sink in the devicetree, or >> + * the OLDI sink has not been added yet. In any case, >> + * return. >> + * We don't want to have an OLDI node connected to DSS >> + * but not to any sink. >> + */ >> + if (ret != -EPROBE_DEFER) >> + dev_err(tidss->dev, >> + "no panel/bridge for OLDI%d. Error %d\n", >> + oldi_instance, ret); > > just dev_err_probe > >> + goto err_put_node; >> + } > > ... > >> + if (IS_ERR(oldi->io_ctrl)) { >> + dev_err(oldi->dev, >> + "%s: oldi%d syscon_regmap_lookup_by_phandle failed %ld\n", >> + __func__, oldi_instance, PTR_ERR(oldi->io_ctrl)); >> + ret = PTR_ERR(oldi->io_ctrl); > > dev_err_probe > >> + goto err_put_node; >> + } >> + >> + oldi->s_clk = of_clk_get_by_name(child, "s_clk"); >> + if (IS_ERR(oldi->s_clk)) { >> + dev_err(oldi->dev, >> + "%s: oldi%d Failed to get s_clk: %ld\n", >> + __func__, oldi_instance, PTR_ERR(oldi->s_clk)); >> + ret = PTR_ERR(oldi->s_clk); > > dev_err_probe Got it. Will update in all the 4 places. > > In general, in this function, sometime you print an error and goto > err_put_node, sometime you just goto err_put_node. Not sure what's the > rationale on this. There hasn't been any real logic behind the prints, except that I have added them whenever there was something (specifc) to be explained. Other times, for example, if the error is -ENOMEM, or any other systemic API failure, there isn't any print required. If this function does exit in an error, however, tidss_probe will always throw a print (except in the case of -EPROBE_DEFER). > >> + goto err_put_node; >> + } >> + >> + /* Register the bridge. */ >> + oldi->bridge.of_node = child; >> + oldi->bridge.driver_private = oldi; >> + oldi->bridge.funcs = &tidss_oldi_bridge_funcs; >> + oldi->bridge.timings = &default_tidss_oldi_timings; >> + >> + tidss->oldis[tidss->num_oldis++] = oldi; >> + oldi->tidss = tidss; >> + >> + drm_bridge_add(&oldi->bridge); >> + } >> + >> +err_put_node: >> + of_node_put(child); >> + of_node_put(oldi_parent); >> + return ret; >> +} >> diff --git a/drivers/gpu/drm/tidss/tidss_oldi.h b/drivers/gpu/drm/tidss/tidss_oldi.h >> new file mode 100644 >> index 000000000000..5ad02ddea11a >> --- /dev/null >> +++ b/drivers/gpu/drm/tidss/tidss_oldi.h >> @@ -0,0 +1,73 @@ >> +/* SPDX-License-Identifier: GPL-2.0-or-later */ >> +/* >> + * Copyright (C) 2023 - Texas Instruments Incorporated >> + * >> + * Aradhya Bhatia >> + */ >> + >> +#ifndef __TIDSS_OLDI_H__ >> +#define __TIDSS_OLDI_H__ >> + >> +#include >> + >> +#include "tidss_drv.h" >> +#include "tidss_dispc.h" >> + >> +struct tidss_oldi; > > why do you need this here? So that struct tidss_device can store pointers to struct tidss_oldi instances. > >> + >> +/* OLDI Instances */ >> +#define OLDI(n) n >> + >> +/* OLDI PORTS */ >> +#define OLDI_INPUT_PORT 0 >> +#define OLDI_OURPUT_PORT 1 >> + >> +/* OLDI Config Bits */ >> +#define OLDI_ENABLE BIT(0) >> +#define OLDI_MAP (BIT(1) | BIT(2) | BIT(3)) >> +#define OLDI_SRC BIT(4) >> +#define OLDI_CLONE_MODE BIT(5) >> +#define OLDI_MASTERSLAVE BIT(6) >> +#define OLDI_DEPOL BIT(7) >> +#define OLDI_MSB BIT(8) >> +#define OLDI_LBEN BIT(9) >> +#define OLDI_LBDATA BIT(10) >> +#define OLDI_DUALMODESYNC BIT(11) >> +#define OLDI_SOFTRST BIT(12) >> +#define OLDI_TPATCFG BIT(13) >> + >> +/* Control MMR Register */ >> + >> +/* Register offsets */ >> +#define OLDI_PD_CTRL 0x100 >> +#define OLDI_LB_CTRL 0x104 >> + >> +/* Power control bits */ >> +#define OLDI_PWRDN_TX(n) BIT(n) >> + >> +/* LVDS Bandgap reference Enable/Disable */ >> +#define OLDI_PWRDN_BG BIT(8) >> + >> +#define OLDI_IDLE_CLK_HZ 25000000 /*25 MHz */ > this is used only on a single C files, move it there? > > I would consider this comment in general for this header file, > from a quick check most of this is used only in tidss_oldi.c. Apart from struct tidss_device being able to access struct tidss_oldi, there is no direct access to any of the above. Perhaps I can move the idle clock definition into the C file. However, before tidss_oldi.h, all the register definitions have been stored in tidss_dispc_regs.h. It just seemed right to keep them out in the header file and maintain the status quo. Regards Aradhya