From patchwork Mon May 10 23:17:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DD64C43462 for ; Mon, 10 May 2021 23:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF8F761606 for ; Mon, 10 May 2021 23:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbhEJXSv (ORCPT ); Mon, 10 May 2021 19:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbhEJXSv (ORCPT ); Mon, 10 May 2021 19:18:51 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93230C06175F; Mon, 10 May 2021 16:17:45 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id o16so22857402ljp.3; Mon, 10 May 2021 16:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ofiUnTNVmdhSCPXFUakdrcB5fFxVu8qvsddsoETV6Zo=; b=gUffqzxATl2oik6ONK02R4SJ5LzvNgYO4w3dnADqSdtHcfAYUcZIWXCkmhGfAjrvww izPiCfdA7XxizmNI67BwdIMZY/nEeJQOXst2bdmDxESVYK2/C5gfYj5Sy885G9htEndw Yi6bN9RFn+CmUakQVlsfUkNYZS9En5t0I/CwzstTAIYNiFY8YSsaoXnecXqIqGUautO/ xEXkDkJ80lqZ3+sa0lboVt9NzjusMRyfGyJOuSpIAo1g68SmMiSCTavKQpVh2mMoYvW3 maZg9BKGmYoEav3yOD1mYLJu3dIKCyz8qUZ/ZAcuWMnDSHngTuOEuSQKhtF4rXZCjB81 dMWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ofiUnTNVmdhSCPXFUakdrcB5fFxVu8qvsddsoETV6Zo=; b=YeYhKk1fw+QrAmDxAZ8A8kPldJ/bFteCpA1q99cB0V16v8bAr7GZaO0KE8O3hAqipc v3rxcXHUlKiKEJ/l8lW6mCZage+1DjFUadQnZJ4gMMX5uVSXWdChGVMB02IcO3nbR70N YWXCtTEg+AVeu10K8ZKEXCEnUOtRyAk+xLiS/vIT4RzLgpPIDaxZ9I3xqJlpXoR4FNva Clp6EC9fFWFAfCazABdF3I15stEGyyakkO8OljxRss/Ueoy8BIvfrqEjVwgd+0bM+pHj cDqaEy845Cl7vBePnRsnvsIk326EqNVP5Ta4ZqqHyGGHLB7Au5qmf0m1Eydi2BMGYXgK 6oRA== X-Gm-Message-State: AOAM530XUj7zWMTqYigSx7ZGxXOeVC/1Bi67tlEDYUYU/anJiy+U3BLp eenz9m/rs7UjwVyfYS1LaUA= X-Google-Smtp-Source: ABdhPJwL/NoJu4Ja4OtcJfluGMhDwVunSTjW2qYHORtaM0C4q9p9+d6PpXqPzWd6NkV2G9QfDR/1qw== X-Received: by 2002:a2e:b819:: with SMTP id u25mr21906536ljo.105.1620688664139; Mon, 10 May 2021 16:17:44 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id k8sm2422254lfo.123.2021.05.10.16.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 16:17:43 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Rob Herring , =?utf-8?q?Micha=C5=82_Miros?= =?utf-8?q?=C5=82aw?= Cc: linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 1/8] clk: tegra30: Use 300MHz for video decoder by default Date: Tue, 11 May 2021 02:17:30 +0300 Message-Id: <20210510231737.30313-2-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510231737.30313-1-digetx@gmail.com> References: <20210510231737.30313-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The 600MHz is a too high clock rate for some SoC versions for the video decoder hardware and this may cause stability issues. Use 300MHz for the video decoder by default, which is supported by all hardware versions. Fixes: ed1a2459e20c ("clk: tegra: Add Tegra20/30 EMC clock implementation") Acked-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/clk/tegra/clk-tegra30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c index 16dbf83d2f62..a33688b2359e 100644 --- a/drivers/clk/tegra/clk-tegra30.c +++ b/drivers/clk/tegra/clk-tegra30.c @@ -1245,7 +1245,7 @@ static struct tegra_clk_init_table init_table[] __initdata = { { TEGRA30_CLK_GR3D, TEGRA30_CLK_PLL_C, 300000000, 0 }, { TEGRA30_CLK_GR3D2, TEGRA30_CLK_PLL_C, 300000000, 0 }, { TEGRA30_CLK_PLL_U, TEGRA30_CLK_CLK_MAX, 480000000, 0 }, - { TEGRA30_CLK_VDE, TEGRA30_CLK_PLL_C, 600000000, 0 }, + { TEGRA30_CLK_VDE, TEGRA30_CLK_PLL_C, 300000000, 0 }, { TEGRA30_CLK_SPDIF_IN_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 }, { TEGRA30_CLK_I2S0_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 }, { TEGRA30_CLK_I2S1_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 }, From patchwork Mon May 10 23:17:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9E2DC43619 for ; Mon, 10 May 2021 23:17:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDE7A6161C for ; Mon, 10 May 2021 23:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbhEJXSx (ORCPT ); Mon, 10 May 2021 19:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbhEJXSw (ORCPT ); Mon, 10 May 2021 19:18:52 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4839C06175F; Mon, 10 May 2021 16:17:46 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id b21so22801077ljf.11; Mon, 10 May 2021 16:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=99TMTkahJ4QCgWUEiSLbnT5JfgAic6E8hP6s4tmViRw=; b=vdnvIArSFwJWi5xtU+3Cxuq9ZSDmNVEUVq4qgO4DFQcoHdpRwbEj+bG/crq1fAPFBk bkEdTPZFWlHcehe4mA8gfe5TBgg+Cypivd8xXJ6PmDM8pVoov4sSV7z3l6FRN5IUdu0g 7h19bfTlETyV/qJMm4mO2PLlhb2YEtl+QX5/UCuMO3CpptoUl4grlrL8ObZHbmnHQMEO Lh4+KbEx/XPxb1s/GJTKAQo2QdQr5pZkZnFNW1lvCdzdfVriddUQkWRcSap16L7FnV5E IGlcMPd2YYP4pKOcsA2+E5R31ElwBPY5hciyOqiBrTO2kPhbl3kbz6AEwqtiN1qzhNpf qy3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=99TMTkahJ4QCgWUEiSLbnT5JfgAic6E8hP6s4tmViRw=; b=KlRiuycAUDWmkciTOa3APrpahw4uESRfNEIuW4ThUqM/NWKs3svXVLpG/b6VH3fBYV 7bjsIUCpEFDDfMQS9zv0p/1KWmhX70wqOerGSziatAiof1N0N/1JoysOZ4x33C50iClc o6lmErLvYQamT1Uthm2cPzwB0npZanzXD2fvYrexH+r+EtHUOMPyr7VBsitcWqWR0z+k lnFxQ5craDVVlPSWMZe3Js6y9zaFTZDWrBavjogUqdopHrRiZ7EyrJGmzAEu1uOYi98m 4hgJ8naPkvzz2Jc1ZFBKNklbqFWWYRHFqkAmYMELZnCyxrCpvGenXLt1ekY5eWDF6sDE gT/Q== X-Gm-Message-State: AOAM533IXkkd86/n++a5Ck8mKtmCk+EFZu75NvAccTJ26+eKT7cLsZSE dh6JTLPZTjK48sG48f3hC4k= X-Google-Smtp-Source: ABdhPJzrAibelYTcFBmnX7JrVnkHC6nTxhXtVeyiKMQXYnuzoPH+6VGXXN3ryQekx/qv/fjaQRDxRw== X-Received: by 2002:a2e:5c7:: with SMTP id 190mr21356059ljf.174.1620688665456; Mon, 10 May 2021 16:17:45 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id k8sm2422254lfo.123.2021.05.10.16.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 16:17:45 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Rob Herring , =?utf-8?q?Micha=C5=82_Miros?= =?utf-8?q?=C5=82aw?= Cc: linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 3/8] clk: tegra: Ensure that PLLU configuration is applied properly Date: Tue, 11 May 2021 02:17:32 +0300 Message-Id: <20210510231737.30313-4-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510231737.30313-1-digetx@gmail.com> References: <20210510231737.30313-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The PLLU (USB) consists of the PLL configuration itself and configuration of the PLLU outputs. The PLLU programming is inconsistent on T30 vs T114, where T114 immediately bails out if PLLU is enabled and T30 re-enables a potentially already enabled PLL (left after bootloader) and then fully reprograms it, which could be unsafe to do. The correct way should be to skip enabling of the PLL if it's already enabled and then apply configuration to the outputs. This patch doesn't fix any known problems, it's a minor improvement. Acked-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/clk/tegra/clk-pll.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c index 0193cebe8c5a..823a567f2adc 100644 --- a/drivers/clk/tegra/clk-pll.c +++ b/drivers/clk/tegra/clk-pll.c @@ -1131,7 +1131,8 @@ static int clk_pllu_enable(struct clk_hw *hw) if (pll->lock) spin_lock_irqsave(pll->lock, flags); - _clk_pll_enable(hw); + if (!clk_pll_is_enabled(hw)) + _clk_pll_enable(hw); ret = clk_pll_wait_for_lock(pll); if (ret < 0) @@ -1748,15 +1749,13 @@ static int clk_pllu_tegra114_enable(struct clk_hw *hw) return -EINVAL; } - if (clk_pll_is_enabled(hw)) - return 0; - input_rate = clk_hw_get_rate(__clk_get_hw(osc)); if (pll->lock) spin_lock_irqsave(pll->lock, flags); - _clk_pll_enable(hw); + if (!clk_pll_is_enabled(hw)) + _clk_pll_enable(hw); ret = clk_pll_wait_for_lock(pll); if (ret < 0) From patchwork Mon May 10 23:17:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA3C5C43462 for ; Mon, 10 May 2021 23:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA71561606 for ; Mon, 10 May 2021 23:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbhEJXS4 (ORCPT ); Mon, 10 May 2021 19:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbhEJXSx (ORCPT ); Mon, 10 May 2021 19:18:53 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F074C061760; Mon, 10 May 2021 16:17:48 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id i9so19288642lfe.13; Mon, 10 May 2021 16:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0JGz9I0bXsTqRTuktP7wK1Haki3njJOFWPxNugzWJw4=; b=rzRvKsi/RYRQ2PA0V7XiUatSJMWiYhZSsQYtzRFOJo+HywvFIR/No0Tt15xIU2QF1k +FxsDe47g1P8pOxiU2Ykw1v3EOFzX1M7rs2ZR2uKEv3VoR3llrPMxWfzCaVvxP1iWcsw YhGlnRgZTK1pTpOC0zp+nzaBkhtQvgB4hPRPEZfinmRSCOkleVjI8fvCvOfZWtrOy6V1 XR4m+ZbchdQm2gHEz23TmTZFx8u/WOwRs9Kf6IAx5gn4xsd8YKyFzCr6fp8FgWKfQSpx JXN93e1qgHC+GdkxFa55t9N59EYFDY1vWf8H27cjb+gaszGaIySdgfqdcaIRrp9dQNuU 7Vzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0JGz9I0bXsTqRTuktP7wK1Haki3njJOFWPxNugzWJw4=; b=JEjgRaXHsTfdc2SnEnGycF23YahJUQaOATuQZwYiuUpRDmJMugnVnarAP8LXBPNBy1 e23W/yNz2bTxehAYSMnnDyjV9ZrdhpqWTSYfsQJw0hcTv5yevqjXVitg4H53kKstPm4y /tMtRELkCPu7zntGLTtZacP+edDcCP9jP3pICQ7LcdIGIDwrGCydaLWMf0FL8hKISbUE pH+yuEWUtmIxUYEL51v71zZV3FpzsGKYJoe03iJaB53KvULJCmzglsoLoU4jHOurbUvH 7XzeVCP/XU4VM8BRGjK4HEfJuaSWw4Cj0ulC9RxT763cxgef/1olmTl2cSrlWJe/yHU4 xttw== X-Gm-Message-State: AOAM532g4gVyjqgJbYDuhkus3BTkk0zhhiHSXGDpTU1eiljclqkOFkj3 NHxLR6pSvc2yv3caishVKiI= X-Google-Smtp-Source: ABdhPJwjQ2lRT2oo6ibnYe9KjbGjElGXGNedNxC4RfYL3WZ+CH6P2F6PivjxZIxf4z5qN1mff8qpuQ== X-Received: by 2002:a05:6512:20c5:: with SMTP id u5mr18421398lfr.198.1620688666718; Mon, 10 May 2021 16:17:46 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id k8sm2422254lfo.123.2021.05.10.16.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 16:17:46 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Rob Herring , =?utf-8?q?Micha=C5=82_Miros?= =?utf-8?q?=C5=82aw?= Cc: linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 5/8] clk: tegra: Don't allow zero clock rate for PLLs Date: Tue, 11 May 2021 02:17:34 +0300 Message-Id: <20210510231737.30313-6-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510231737.30313-1-digetx@gmail.com> References: <20210510231737.30313-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Zero clock rate doesn't make sense for PLLs and tegra-clk driver enters into infinite loop on trying to calculate PLL parameters for zero rate. Make code to error out if requested rate is zero. Originally this trouble was found by Robert Yang while he was trying to bring up upstream kernel on Samsung Galaxy Tab, which happened due to a bug in Tegra DRM driver that erroneously sets PLL rate to zero. This issues came over again recently during of kernel bring up on ASUS TF700T. Signed-off-by: Dmitry Osipenko --- drivers/clk/tegra/clk-pll.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c index 823a567f2adc..eaa079c177c3 100644 --- a/drivers/clk/tegra/clk-pll.c +++ b/drivers/clk/tegra/clk-pll.c @@ -558,6 +558,9 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, u32 p_div = 0; int ret; + if (!rate) + return -EINVAL; + switch (parent_rate) { case 12000000: case 26000000: From patchwork Mon May 10 23:17:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09575C43616 for ; Mon, 10 May 2021 23:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E14966161C for ; Mon, 10 May 2021 23:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbhEJXS6 (ORCPT ); Mon, 10 May 2021 19:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbhEJXSy (ORCPT ); Mon, 10 May 2021 19:18:54 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEDD5C061574; Mon, 10 May 2021 16:17:48 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id c15so8312352ljr.7; Mon, 10 May 2021 16:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SNSJ4ltRZBGOKyLdYr1aZnAojr1HJgzV+2zSgbmIE8g=; b=hjwAZoA1vig0NnQOePkP2AsXPLSPZVjVqRyVtDOLbRXXuUr4lm0CeVNK5aQhEuqJK3 wl6A2eDYiH0BiIQLVfrZqwGhcM4I4c9lYHnkk2bfSNhI1XcUBJbaplaRkpPU68VPF5FZ lXJ7PdqSw5D5cou9rIPwIoncCaZ+5ypxwtTxuHoTjKY4p1SMKv+miLXxr2CZ55ibZxX2 CtbpOAFWlyBj4ajKWBlFSyRmkNOINCtX5hSvmVhDQ/H/mNH3KNfTx5A0Ml5IP7RC79Xm 0+iNTL/93bi7bPGbRNcY477kC6sc2qHFqPUC4Usx/nTN1B8RwKZpwKWoAI6D4MqW6abk PZQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SNSJ4ltRZBGOKyLdYr1aZnAojr1HJgzV+2zSgbmIE8g=; b=n+an6StTlkKmizAhWXdFDVYWZQzZYsAu1CDzR97mvegi2Tawh+hlp6XQyhGbPkSuco alquNYzcDTUyLYw+ELRQCX+ag0dpCZCKl+gozYmJocC/OTa3XLsyjJnk+SAjxdPIxDnk tj2BPXclCpB/m8sJFi+WIXO+SKYYCt6WNZYV237d0aFsYK+XakLMSF7EN9wJNeqEy5vJ ny9KoTIr00ozhAjYVThLgPPyPj+qUhNwQzZpkZgi9a+6V24y9/bJoCy52kdcNcMFnHdp M5iFeRN5Cxt55fgKsEd23aXoszMBlHqaPqnW9tFC5fnZFzHoCyxv/G+xuVHmTlZvDwvk 9dTw== X-Gm-Message-State: AOAM532isYYkhZHUogs2TrxX8h8bUanMC9UEIESkwTIuC/IFM2iiiSLu eyxvtN2c9Yu96ibS6PCvms4= X-Google-Smtp-Source: ABdhPJwPrpAuvtEI1bm7uqSmnY9Xn6Sc71p94sltgBiC1Cp3xiZstoeWAJ6ZpDOf6DqgiTcllpOzqA== X-Received: by 2002:a2e:92c6:: with SMTP id k6mr22715352ljh.94.1620688667407; Mon, 10 May 2021 16:17:47 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id k8sm2422254lfo.123.2021.05.10.16.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 16:17:47 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Rob Herring , =?utf-8?q?Micha=C5=82_Miros?= =?utf-8?q?=C5=82aw?= Cc: linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 6/8] clk: tegra: cclk: Handle thermal DIV2 CPU frequency throttling Date: Tue, 11 May 2021 02:17:35 +0300 Message-Id: <20210510231737.30313-7-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510231737.30313-1-digetx@gmail.com> References: <20210510231737.30313-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Check whether thermal DIV2 throttle is active in order to report the CPU frequency properly. This very useful for userspace tools like cpufreq-info which show actual frequency asserted from hardware. Signed-off-by: Dmitry Osipenko --- drivers/clk/tegra/clk-tegra-super-cclk.c | 16 ++++++++++++++-- drivers/clk/tegra/clk-tegra30.c | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/clk/tegra/clk-tegra-super-cclk.c b/drivers/clk/tegra/clk-tegra-super-cclk.c index a03119c30456..f75822b71d0e 100644 --- a/drivers/clk/tegra/clk-tegra-super-cclk.c +++ b/drivers/clk/tegra/clk-tegra-super-cclk.c @@ -25,6 +25,8 @@ #define SUPER_CDIV_ENB BIT(31) +#define TSENSOR_SLOWDOWN BIT(23) + static struct tegra_clk_super_mux *cclk_super; static bool cclk_on_pllx; @@ -47,10 +49,20 @@ static int cclk_super_set_rate(struct clk_hw *hw, unsigned long rate, static unsigned long cclk_super_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { + struct tegra_clk_super_mux *super = to_clk_super_mux(hw); + u32 val = readl_relaxed(super->reg); + unsigned int div2; + + /* check whether thermal throttling is active */ + if (val & TSENSOR_SLOWDOWN) + div2 = 2; + else + div2 = 1; + if (cclk_super_get_parent(hw) == PLLX_INDEX) - return parent_rate; + return parent_rate / div2; - return tegra_clk_super_ops.recalc_rate(hw, parent_rate); + return tegra_clk_super_ops.recalc_rate(hw, parent_rate) / div2; } static int cclk_super_determine_rate(struct clk_hw *hw, diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c index a33688b2359e..5b6bd138be84 100644 --- a/drivers/clk/tegra/clk-tegra30.c +++ b/drivers/clk/tegra/clk-tegra30.c @@ -930,7 +930,7 @@ static void __init tegra30_super_clk_init(void) /* CCLKG */ clk = tegra_clk_register_super_cclk("cclk_g", cclk_g_parents, ARRAY_SIZE(cclk_g_parents), - CLK_SET_RATE_PARENT, + CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, clk_base + CCLKG_BURST_POLICY, 0, NULL); clks[TEGRA30_CLK_CCLK_G] = clk;