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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDEB3C6FA8E for ; Sun, 26 Feb 2023 18:21:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 81FCA85950; Sun, 26 Feb 2023 19:20:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MeBlTtcq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6632385938; Sun, 26 Feb 2023 19:20:36 +0100 (CET) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 221108567B for ; Sun, 26 Feb 2023 19:20:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-lf1-x12a.google.com with SMTP id n2so5652223lfb.12 for ; Sun, 26 Feb 2023 10:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q3JO0p2Us6D/69FfE/4dqo2a/n8t2pRcJYyAopJVmWg=; b=MeBlTtcqif+ngzes30d+hqUAwJP/baMnZpAb0zKWbNfB4gqIVUdPf9ba+orAD6Clmn XCoyn/SdMI7Sd94Jysor5PQIR01+dX5DN9/QT0mWwcvQZJELsoX4uH7EhD5IO9I1JO5C JzkPIqB/xiPal4HMr8tiEupJg4pADTlPANX0P3gqr9etzmxmu43HUwmAcVvRSmACHxqY wmq6g8e0kHhsSSQzRwBr2WoL1nnfBBNoAOKDXgrTbkYoqTTXazy6VOKURia2feEVvKKe Hpfu/f05ouRZFPsxTSlhYe0lrRruIK7AzDKd4um+GZGYVvxvA1YPkGNXZjK0p9WWpWxh 7YHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q3JO0p2Us6D/69FfE/4dqo2a/n8t2pRcJYyAopJVmWg=; b=P+h+30wLwkTnQG408U7Ll3HdQo82Aqa+DPkkEtBEBBz7kYLf3ImqMryjZWQDNer3+r CKoTCh7b4t/BSiUk3bUYf6Jx7ZTkXPyXBXXpHZrRzKCteugHZ2MZmRXN/Cj4mTWbEDHX cDaEb1cxNIQAoGPEx2A9zDFgOiqW9b9trp/PmQgoCJBXHb5KbfT5/5s5n3pFXBJOn1xS kbhcQgd99uMzzmCtaXk/CEztS0DMMVNvjGYpvcrDYdEBLJ9DN0Oe6rOyBT7k1ZDyFD1Y HhsndWlWgc2WYftnjVp4shAiFslVeeqnGZ4zsgdvLa3w0LQJgdCiBY+pnyt5R2E+f4++ +zaA== X-Gm-Message-State: AO0yUKV0nmpPHjH2Tgugpy4bU8a/DC5A/w4xlRVGwPIqGwUziP73xEBt FnxShQ0ow70yeeHErxwJvdU= X-Google-Smtp-Source: AK7set8pBfEXvAVZjjaDyj2I65ZfmH2EolBjE1wpsZDwhUdVHZGvmbsHiQ1aOvuXRCy0LxhsKqigpw== X-Received: by 2002:ac2:4ac9:0:b0:4de:7b5b:f16f with SMTP id m9-20020ac24ac9000000b004de7b5bf16fmr1686194lfp.7.1677435632404; Sun, 26 Feb 2023 10:20:32 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id x25-20020ac259d9000000b004dc4d984911sm619421lfn.271.2023.02.26.10.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 10:20:32 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , Anatolij Gustschin , Simon Glass , Svyatoslav Ryhel , Marcel Ziswiler , Thierry Reding , Maxim Schwalm , Dmitry Osipenko , Nicolas Chauvet Cc: u-boot@lists.denx.de Subject: [PATCH v2 03/11] video: tegra-dc: get clocks from device tree Date: Sun, 26 Feb 2023 20:19:57 +0200 Message-Id: <20230226182005.27291-4-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230226182005.27291-1-clamor95@gmail.com> References: <20230226182005.27291-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean DISP1 clock may use PLLP, PLLC and PLLD as parents. Instead of hardcoding, lets pass clock and its parent from device tree. Default parent is PLLP. Tested-by: Robert Eckelmann # ASUS TF101 T20 Tested-by: Nicolas Chauvet # Paz00 Tested-by: Andreas Westman Dorcsak # ASUS TF T30 Tested-by: Svyatoslav Ryhel # HTC One X T30 Signed-off-by: Svyatoslav Ryhel --- drivers/video/tegra20/tegra-dc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/video/tegra20/tegra-dc.c b/drivers/video/tegra20/tegra-dc.c index 5e3f6bf029..ff67cc8989 100644 --- a/drivers/video/tegra20/tegra-dc.c +++ b/drivers/video/tegra20/tegra-dc.c @@ -36,6 +36,7 @@ struct tegra_lcd_priv { struct disp_ctlr *disp; /* Display controller to use */ fdt_addr_t frame_buffer; /* Address of frame buffer */ unsigned pixel_clock; /* Pixel clock in Hz */ + int dc_clk[2]; /* Contains clk and its parent */ }; enum { @@ -134,7 +135,7 @@ static int update_display_mode(struct dc_disp_reg *disp, * the display clock (typically 600MHz) to the pixel clock. We round * up or down as requried. */ - rate = clock_get_periph_rate(PERIPH_ID_DISP1, CLOCK_ID_CGENERAL); + rate = clock_get_periph_rate(priv->dc_clk[0], priv->dc_clk[1]); div = ((rate * 2 + priv->pixel_clock / 2) / priv->pixel_clock) - 2; debug("Display clock %lu, divider %lu\n", rate, div); @@ -269,20 +270,27 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv, { struct disp_ctl_win window; struct dc_ctlr *dc; + unsigned long rate = clock_get_rate(priv->dc_clk[1]); priv->frame_buffer = (u32)default_lcd_base; dc = (struct dc_ctlr *)priv->disp; /* - * A header file for clock constants was NAKed upstream. - * TODO: Put this into the FDT and fdt_lcd struct when we have clock - * support there + * We halve the rate if DISP1 paret is PLLD, since actual parent + * is plld_out0 which is PLLD divided by 2. */ - clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_PERIPH, - 144 * 1000000); - clock_start_periph_pll(PERIPH_ID_DISP1, CLOCK_ID_CGENERAL, - 600 * 1000000); + if (priv->dc_clk[1] == CLOCK_ID_DISPLAY) + rate /= 2; + + /* + * HOST1X is init by default at 150MHz with PLLC as parent + */ + clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL, + 150 * 1000000); + clock_start_periph_pll(priv->dc_clk[0], priv->dc_clk[1], + rate); + basic_init(&dc->cmd); basic_init_timer(&dc->disp); rgb_enable(&dc->com); @@ -358,6 +366,13 @@ static int tegra_lcd_of_to_plat(struct udevice *dev) return -EINVAL; } + ret = clock_decode_pair(dev, priv->dc_clk); + if (ret < 0) { + debug("%s: Cannot decode clocks for '%s' (ret = %d)\n", + __func__, dev->name, ret); + return -EINVAL; + } + rgb = fdt_subnode_offset(blob, node, "rgb"); if (rgb < 0) { debug("%s: Cannot find rgb subnode for '%s' (ret=%d)\n", -- 2.37.2