From nobody Mon Apr 29 05:05:39 2024 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 F0F7EC32771 for ; Wed, 28 Sep 2022 15:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234398AbiI1Pzv (ORCPT ); Wed, 28 Sep 2022 11:55:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbiI1Pzg (ORCPT ); Wed, 28 Sep 2022 11:55:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA098FD72 for ; Wed, 28 Sep 2022 08:55:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7638BB8211A for ; Wed, 28 Sep 2022 15:55:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F31CC433D6; Wed, 28 Sep 2022 15:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380530; bh=qtQPDKCYZ/wlqIizvS08i9p0N53rArTptfBEo4YTjjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XtJko+sP0l0i1L7qt5nSiIXQ7KCikEp9nlQq1hW4glAT8r0Wrd/lFgQoTZvKAFltN +yTfMIWZvMGxdXhEjNencg4ev0p7eOzXg6ELU0/iVUCiqmhC5MHlJyMR4Uzho6Ino0 KxVIm51HDEoxEb+ZRPlzO5oEeu4OSkYQpu2TFsrnnb8YXG7x92quvl3Ql3Ly9JIrPM JVabcTgsJn1KlrrMe2W1EpWZHwimZUC1E5zZc9pJSFO6PeTqN/35XY7D1QUf3GMwsF pQnyt/FFcEqwCvnQRbiKBDHddDTMzOXyFdrfdxrVpqlmery+MejCnkHlCgDImM3Khc 9gJiiacg6YZWQ== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 1/8] soc: mediatek: mtk-svs: clean up platform probing Date: Wed, 28 Sep 2022 17:55:12 +0200 Message-Id: <20220928155519.31977-2-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger We only ever call the SoC specific probe function from svs_platform_probe. No need to carry that function in a global datastructure around. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 0469c9dfeb04..fd0f636e8644 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -319,7 +319,6 @@ static const u32 svs_regs_v2[] =3D { * @banks: svs banks that svs platform supports * @rst: svs platform reset control * @efuse_parsing: svs platform efuse parsing function pointer - * @probe: svs platform probe function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -336,7 +335,6 @@ struct svs_platform { struct svs_bank *banks; struct reset_control *rst; bool (*efuse_parsing)(struct svs_platform *svsp); - int (*probe)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2347,11 +2345,10 @@ static struct svs_platform *svs_platform_probe(stru= ct platform_device *pdev) svsp->name =3D svsp_data->name; svsp->banks =3D svsp_data->banks; svsp->efuse_parsing =3D svsp_data->efuse_parsing; - svsp->probe =3D svsp_data->probe; svsp->regs =3D svsp_data->regs; svsp->bank_max =3D svsp_data->bank_max; =20 - ret =3D svsp->probe(svsp); + ret =3D svsp_data->probe(svsp); if (ret) return ERR_PTR(ret); =20 --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 03471C04A95 for ; Wed, 28 Sep 2022 15:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234409AbiI1P4A (ORCPT ); Wed, 28 Sep 2022 11:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234261AbiI1Pzg (ORCPT ); Wed, 28 Sep 2022 11:55:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AEEA90190 for ; Wed, 28 Sep 2022 08:55:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 285F161F0C for ; Wed, 28 Sep 2022 15:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2CC5C433D7; Wed, 28 Sep 2022 15:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380532; bh=l7UiBfO3UBUpJjyUbjigXJWcDJxBC47DwLgzoIjb9LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VhJyaPwmhuiLzXMKUZYdCtsE01Tzi1rUzGRAt/TpvtkdOg4dESYEYnp6CXS+jM1bA +aQOoKv8Srf5vbqctuqXDvOmccgCcKJoDVSHdzSKenLXJOs862wKyfVWlyYoVGUOBi Cg0061wCbSGGNilC2RUUgo2EsaOkhtElYDXLG+TIB8t7R6Qej/g9hZe7Ap6wWyciYs 9YLRcKMPs7r2IcsTc8f/w6naFrazDPhFU0lv/RS5rkG9BcwS5OVKbUv1O8NrxiZ3Tz NCzEHB8dC9su112IuP8yyYbpqHsaYJMSxAWxGsFDiHoE6rOd9xDu8ZLMfL5+CoOtVi rXIbAj4NRpu9w== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 2/8] soc: mediatek: mtk-svs: improve readability of platform_probe Date: Wed, 28 Sep 2022 17:55:13 +0200 Message-Id: <20220928155519.31977-3-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger If a compatible misses a match data entry, then something is wrong in the development phase, we don't need to check for that at runtime. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index fd0f636e8644..52bb4f8bbe6d 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2332,10 +2332,6 @@ static struct svs_platform *svs_platform_probe(struc= t platform_device *pdev) int ret; =20 svsp_data =3D of_device_get_match_data(&pdev->dev); - if (!svsp_data) { - dev_err(&pdev->dev, "no svs platform data?\n"); - return ERR_PTR(-EPERM); - } =20 svsp =3D devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 330B4C04A95 for ; Wed, 28 Sep 2022 15:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234246AbiI1P4N (ORCPT ); Wed, 28 Sep 2022 11:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbiI1Pzk (ORCPT ); Wed, 28 Sep 2022 11:55:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3247F8C034 for ; Wed, 28 Sep 2022 08:55:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C0B661F11 for ; Wed, 28 Sep 2022 15:55:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 136FEC433C1; Wed, 28 Sep 2022 15:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380535; bh=a1LAVlDHkces/5MDyjvZevj2YKY09OrPDHZaF2N9pnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjSVvQHG6b9D4itNHwL1SG4xfd79oh//JrtvpPK1D3kaUsuXKvEQurdibHWlezXB8 LBlRnzdmzrQ1OhrvK7xmRIGoADyLNdbwSWP83T/p6Siy7Tdq+i+K88yB9vJV+C/fCy v4d94YYSn+VI3i3nCiIpIi/MSW791yjNUVr97BX/2iq4xoCewz+4knHzmxQxlxsGt1 zIxvZrUPWZ3TN0sgZ/Ojv52KiF4aPvkorkdiFcFc2p4SlPlOwA44HuDOZsqZdXyQw1 FU8fGA5G3S2gyvTOXem8BS3XpySetdvePLMdV81VfqD17xEGfv4x4Upa+01bW4RJeL FE2UwX/8guwVQ== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 3/8] soc: mediatek: mtk-svs: move svs_platform_probe into probe Date: Wed, 28 Sep 2022 17:55:14 +0200 Message-Id: <20220928155519.31977-4-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger Moving svs_platform_probe into driver probe function will allow us to reduce svs_platform members. This will be done in a follow-up patch. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 52bb4f8bbe6d..8342627f8dea 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2325,17 +2325,17 @@ static const struct of_device_id svs_of_match[] =3D= { }, }; =20 -static struct svs_platform *svs_platform_probe(struct platform_device *pde= v) +static int svs_probe(struct platform_device *pdev) { struct svs_platform *svsp; const struct svs_platform_data *svsp_data; - int ret; + int ret, svsp_irq; =20 svsp_data =3D of_device_get_match_data(&pdev->dev); =20 svsp =3D devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) - return ERR_PTR(-ENOMEM); + return -ENOMEM; =20 svsp->dev =3D &pdev->dev; svsp->name =3D svsp_data->name; @@ -2346,19 +2346,7 @@ static struct svs_platform *svs_platform_probe(struc= t platform_device *pdev) =20 ret =3D svsp_data->probe(svsp); if (ret) - return ERR_PTR(ret); - - return svsp; -} - -static int svs_probe(struct platform_device *pdev) -{ - struct svs_platform *svsp; - int svsp_irq, ret; - - svsp =3D svs_platform_probe(pdev); - if (IS_ERR(svsp)) - return PTR_ERR(svsp); + return ret; =20 if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 F38A4C32771 for ; Wed, 28 Sep 2022 15:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233955AbiI1P4Q (ORCPT ); Wed, 28 Sep 2022 11:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234345AbiI1Pzl (ORCPT ); Wed, 28 Sep 2022 11:55:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E3938E455 for ; Wed, 28 Sep 2022 08:55:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 096A461F12 for ; Wed, 28 Sep 2022 15:55:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E0BC43470; Wed, 28 Sep 2022 15:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380537; bh=YZMOjgTNeBBMbRzzxRhwTWgxRv9J8huLdzYrUxYy2S4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CDTZayabU/ZeTorlu4hi7Ad/PKqFked91GfMFoXSllA3SeMtQaU+YzGhjmRVAGfSp xSno8AB6nUj95qOxUEEyFCvOGXSmkp9ephJUkm7/MH1Nqr9DjX22PRaT/Bbx+HcUmO hRwQjJpRAl+/ghXII+VmJFuqmHeJ+Ot6ARqj9AAt5Qq/CZnUZudi2NIgm+9krrc9sj uAKfSHUCL0aY1fl75gOTzeYNW/zn+GtC+HrlfD719WNPXnKHGLpqmO2ADQDKW91pTi 38xCscCcrUoW2agjtQMPNJH/Y0GfikiztG/Ymqr6vmdo6/ER2/necguZMEWhFDLhLX ePuAzGMgqdbKg== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 4/8] soc: mediatek: mtk-svs: delete superfluous platform data entries Date: Wed, 28 Sep 2022 17:55:15 +0200 Message-Id: <20220928155519.31977-5-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 8342627f8dea..482cc8d7e7cf 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -311,14 +311,12 @@ static const u32 svs_regs_v2[] =3D { =20 /** * struct svs_platform - svs platform control - * @name: svs platform name * @base: svs platform register base * @dev: svs platform device * @main_clk: main clock for svs bank * @pbank: svs bank pointer needing to be protected by spin_lock section * @banks: svs banks that svs platform supports * @rst: svs platform reset control - * @efuse_parsing: svs platform efuse parsing function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -327,14 +325,12 @@ static const u32 svs_regs_v2[] =3D { * @tefuse: thermal efuse data received from NVMEM framework */ struct svs_platform { - char *name; void __iomem *base; struct device *dev; struct clk *main_clk; struct svs_bank *pbank; struct svs_bank *banks; struct reset_control *rst; - bool (*efuse_parsing)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2009,7 +2005,7 @@ static bool svs_is_efuse_data_correct(struct svs_plat= form *svsp) svsp->efuse_max /=3D sizeof(u32); nvmem_cell_put(cell); =20 - return svsp->efuse_parsing(svsp); + return true; } =20 static struct device *svs_get_subsys_device(struct svs_platform *svsp, @@ -2338,9 +2334,7 @@ static int svs_probe(struct platform_device *pdev) return -ENOMEM; =20 svsp->dev =3D &pdev->dev; - svsp->name =3D svsp_data->name; svsp->banks =3D svsp_data->banks; - svsp->efuse_parsing =3D svsp_data->efuse_parsing; svsp->regs =3D svsp_data->regs; svsp->bank_max =3D svsp_data->bank_max; =20 @@ -2351,6 +2345,12 @@ static int svs_probe(struct platform_device *pdev) if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); ret =3D -EPERM; + goto svs_probe_free_efuse; + } + + if (!svsp_data->efuse_parsing(svsp)) { + dev_notice(svsp->dev, "efuse data parsing failed\n"); + ret =3D -EPERM; goto svs_probe_free_resource; } =20 @@ -2367,7 +2367,7 @@ static int svs_probe(struct platform_device *pdev) } =20 ret =3D devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, - IRQF_ONESHOT, svsp->name, svsp); + IRQF_ONESHOT, svsp_data->name, svsp); if (ret) { dev_err(svsp->dev, "register irq(%d) failed: %d\n", svsp_irq, ret); @@ -2416,11 +2416,13 @@ static int svs_probe(struct platform_device *pdev) clk_disable_unprepare(svsp->main_clk); =20 svs_probe_free_resource: - if (!IS_ERR_OR_NULL(svsp->efuse)) - kfree(svsp->efuse); if (!IS_ERR_OR_NULL(svsp->tefuse)) kfree(svsp->tefuse); =20 +svs_probe_free_efuse: + if (!IS_ERR_OR_NULL(svsp->efuse)) + kfree(svsp->efuse); + return ret; } =20 --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 18C3CC04A95 for ; Wed, 28 Sep 2022 15:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234514AbiI1P4k (ORCPT ); Wed, 28 Sep 2022 11:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234420AbiI1P4H (ORCPT ); Wed, 28 Sep 2022 11:56:07 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF5F8DCEA6 for ; Wed, 28 Sep 2022 08:55:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 18713CE1EE2 for ; Wed, 28 Sep 2022 15:55:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E68E0C433C1; Wed, 28 Sep 2022 15:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380540; bh=+tGfcIhP3nFE6FsLjBv5CQN00EhkZzX5QDJfLFGFy3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo2EwnHaeT8lqeU1zq5OU91LEpqZDgyIPL5j+587h7pVWHMer/apX8mRkMqgqDo/9 7uFetMFR02fgLaSN5X3JRP3Ms9SO95WRJWO+WNCw4LagbHqfqXKdz/8MBYNuYPLz8y iuoWRsH0kx6ugUgvveqUzPbYQVtmIhC7DW/pmUKAY9JawQ+fU6udfy64UMVX8LJ3g9 XLNnY5DyS0nZQfLznvf+GGgOGSzc7Yw+kL3yptE00JyTUrr+5z5PPpil8nQouOo6s2 Kz9sPdYczbOGAErXY0VqkNZMnYvC58gRv0ILDIVuU53BWVZeXpHDWw5ie6ZuqUgtaK A8Nnm43dprwCw== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger , Philipp Zabel Subject: [PATCH 5/8] soc: mediatek: mtk-svs: Move SoC specific functions to new files Date: Wed, 28 Sep 2022 17:55:16 +0200 Message-Id: <20220928155519.31977-6-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger With every SoC added to the driver, it grows. Move SoC specific callbacks to a new source files. Signed-off-by: Matthias Brugger --- drivers/soc/mediatek/Makefile | 3 +- drivers/soc/mediatek/mt8183-svs.h | 113 ++++ drivers/soc/mediatek/mt8192-svs.h | 64 ++ drivers/soc/mediatek/mtk-svs-mt8183.c | 234 ++++++++ drivers/soc/mediatek/mtk-svs-mt8192.c | 100 ++++ drivers/soc/mediatek/mtk-svs.c | 831 ++------------------------ drivers/soc/mediatek/mtk-svs.h | 279 +++++++++ 7 files changed, 837 insertions(+), 787 deletions(-) create mode 100644 drivers/soc/mediatek/mt8183-svs.h create mode 100644 drivers/soc/mediatek/mt8192-svs.h create mode 100644 drivers/soc/mediatek/mtk-svs-mt8183.c create mode 100644 drivers/soc/mediatek/mtk-svs-mt8192.c create mode 100644 drivers/soc/mediatek/mtk-svs.h diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile index 0e9e703c931a..851131638644 100644 --- a/drivers/soc/mediatek/Makefile +++ b/drivers/soc/mediatek/Makefile @@ -7,4 +7,5 @@ obj-$(CONFIG_MTK_SCPSYS) +=3D mtk-scpsys.o obj-$(CONFIG_MTK_SCPSYS_PM_DOMAINS) +=3D mtk-pm-domains.o obj-$(CONFIG_MTK_MMSYS) +=3D mtk-mmsys.o obj-$(CONFIG_MTK_MMSYS) +=3D mtk-mutex.o -obj-$(CONFIG_MTK_SVS) +=3D mtk-svs.o +mtk_svs-objs :=3D mtk-svs.o mtk-svs-mt8183.o mtk-svs-mt8192.o +obj-$(CONFIG_MTK_SVS) +=3D mtk_svs.o diff --git a/drivers/soc/mediatek/mt8183-svs.h b/drivers/soc/mediatek/mt818= 3-svs.h new file mode 100644 index 000000000000..89c0deb9fb11 --- /dev/null +++ b/drivers/soc/mediatek/mt8183-svs.h @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DRV_SVS_MT8183_H +#define __DRV_SVS_MT8183_H + +static struct svs_bank svs_mt8183_banks[] =3D { + { + .sw_id =3D SVSB_CPU_LITTLE, + .set_freq_pct =3D svs_set_bank_freq_pct_v2, + .get_volts =3D svs_get_bank_volts_v2, + .cpu_id =3D 0, + .buck_name =3D "proc", + .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, + .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 1989000000, + .vboot =3D 0x30, + .volt_step =3D 6250, + .volt_base =3D 500000, + .vmax =3D 0x64, + .vmin =3D 0x18, + .age_config =3D 0x555555, + .dc_config =3D 0x555555, + .dvt_fixed =3D 0x7, + .vco =3D 0x10, + .chk_shift =3D 0x77, + .core_sel =3D 0x8fff0000, + .int_st =3D BIT(0), + .ctl0 =3D 0x00010001, + }, + { + .sw_id =3D SVSB_CPU_BIG, + .set_freq_pct =3D svs_set_bank_freq_pct_v2, + .get_volts =3D svs_get_bank_volts_v2, + .cpu_id =3D 4, + .buck_name =3D "proc", + .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, + .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 1989000000, + .vboot =3D 0x30, + .volt_step =3D 6250, + .volt_base =3D 500000, + .vmax =3D 0x58, + .vmin =3D 0x10, + .age_config =3D 0x555555, + .dc_config =3D 0x555555, + .dvt_fixed =3D 0x7, + .vco =3D 0x10, + .chk_shift =3D 0x77, + .core_sel =3D 0x8fff0001, + .int_st =3D BIT(1), + .ctl0 =3D 0x00000001, + }, + { + .sw_id =3D SVSB_CCI, + .set_freq_pct =3D svs_set_bank_freq_pct_v2, + .get_volts =3D svs_get_bank_volts_v2, + .buck_name =3D "proc", + .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, + .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 1196000000, + .vboot =3D 0x30, + .volt_step =3D 6250, + .volt_base =3D 500000, + .vmax =3D 0x64, + .vmin =3D 0x18, + .age_config =3D 0x555555, + .dc_config =3D 0x555555, + .dvt_fixed =3D 0x7, + .vco =3D 0x10, + .chk_shift =3D 0x77, + .core_sel =3D 0x8fff0002, + .int_st =3D BIT(2), + .ctl0 =3D 0x00100003, + }, + { + .sw_id =3D SVSB_GPU, + .set_freq_pct =3D svs_set_bank_freq_pct_v2, + .get_volts =3D svs_get_bank_volts_v2, + .buck_name =3D "mali", + .tzone_name =3D "tzts2", + .volt_flags =3D SVSB_INIT01_PD_REQ | + SVSB_INIT01_VOLT_INC_ONLY, + .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02 | + SVSB_MODE_MON, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 900000000, + .vboot =3D 0x30, + .volt_step =3D 6250, + .volt_base =3D 500000, + .vmax =3D 0x40, + .vmin =3D 0x14, + .age_config =3D 0x555555, + .dc_config =3D 0x555555, + .dvt_fixed =3D 0x3, + .vco =3D 0x10, + .chk_shift =3D 0x77, + .core_sel =3D 0x8fff0003, + .int_st =3D BIT(3), + .ctl0 =3D 0x00050001, + .tzone_htemp =3D 85000, + .tzone_htemp_voffset =3D 0, + .tzone_ltemp =3D 25000, + .tzone_ltemp_voffset =3D 3, + }, +}; + +bool svs_mt8183_efuse_parsing(struct svs_platform *svsp); +int svs_mt8183_platform_probe(struct svs_platform *svsp); + +#endif diff --git a/drivers/soc/mediatek/mt8192-svs.h b/drivers/soc/mediatek/mt819= 2-svs.h new file mode 100644 index 000000000000..6571ebcb2c0f --- /dev/null +++ b/drivers/soc/mediatek/mt8192-svs.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DRV_SVS_MT8192_H +#define __DRV_SVS_MT8192_H + +static struct svs_bank svs_mt8192_banks[] =3D { + { + .sw_id =3D SVSB_GPU, + .type =3D SVSB_LOW, + .set_freq_pct =3D svs_set_bank_freq_pct_v3, + .get_volts =3D svs_get_bank_volts_v3, + .volt_flags =3D SVSB_REMOVE_DVTFIXED_VOLT, + .mode_support =3D SVSB_MODE_INIT02, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 688000000, + .turn_freq_base =3D 688000000, + .volt_step =3D 6250, + .volt_base =3D 400000, + .vmax =3D 0x60, + .vmin =3D 0x1a, + .age_config =3D 0x555555, + .dc_config =3D 0x1, + .dvt_fixed =3D 0x1, + .vco =3D 0x18, + .chk_shift =3D 0x87, + .core_sel =3D 0x0fff0100, + .int_st =3D BIT(0), + .ctl0 =3D 0x00540003, + }, + { + .sw_id =3D SVSB_GPU, + .type =3D SVSB_HIGH, + .set_freq_pct =3D svs_set_bank_freq_pct_v3, + .get_volts =3D svs_get_bank_volts_v3, + .tzone_name =3D "gpu1", + .volt_flags =3D SVSB_REMOVE_DVTFIXED_VOLT | + SVSB_MON_VOLT_IGNORE, + .mode_support =3D SVSB_MODE_INIT02 | SVSB_MODE_MON, + .opp_count =3D MAX_OPP_ENTRIES, + .freq_base =3D 902000000, + .turn_freq_base =3D 688000000, + .volt_step =3D 6250, + .volt_base =3D 400000, + .vmax =3D 0x60, + .vmin =3D 0x1a, + .age_config =3D 0x555555, + .dc_config =3D 0x1, + .dvt_fixed =3D 0x6, + .vco =3D 0x18, + .chk_shift =3D 0x87, + .core_sel =3D 0x0fff0101, + .int_st =3D BIT(1), + .ctl0 =3D 0x00540003, + .tzone_htemp =3D 85000, + .tzone_htemp_voffset =3D 0, + .tzone_ltemp =3D 25000, + .tzone_ltemp_voffset =3D 7, + }, +}; + +bool svs_mt8192_efuse_parsing(struct svs_platform *svsp); +int svs_mt8192_platform_probe(struct svs_platform *svsp); + +#endif diff --git a/drivers/soc/mediatek/mtk-svs-mt8183.c b/drivers/soc/mediatek/m= tk-svs-mt8183.c new file mode 100644 index 000000000000..a97fcae59dd7 --- /dev/null +++ b/drivers/soc/mediatek/mtk-svs-mt8183.c @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include "mtk-svs.h" + +bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) +{ + struct svs_bank *svsb; + int format[6], x_roomt[6], o_vtsmcu[5], o_vtsabb, tb_roomt =3D 0; + int adc_ge_t, adc_oe_t, ge, oe, gain, degc_cali, adc_cali_en_t; + int o_slope, o_slope_sign, ts_id; + u32 idx, i, ft_pgm, mts, temp0, temp1, temp2; + int ret; + + for (i =3D 0; i < svsp->efuse_max; i++) + if (svsp->efuse[i]) + dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", + i, svsp->efuse[i]); + + if (!svsp->efuse[2]) { + dev_notice(svsp->dev, "svs_efuse[2] =3D 0x0?\n"); + return false; + } + + /* Svs efuse parsing */ + ft_pgm =3D (svsp->efuse[0] >> 4) & GENMASK(3, 0); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + + if (ft_pgm <=3D 1) + svsb->volt_flags |=3D SVSB_INIT01_VOLT_IGNORE; + + switch (svsb->sw_id) { + case SVSB_CPU_LITTLE: + svsb->bdes =3D svsp->efuse[16] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[16] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[16] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[16] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 10; + else + svsb->volt_od +=3D 2; + break; + case SVSB_CPU_BIG: + svsb->bdes =3D svsp->efuse[18] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[18] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[18] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[18] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D svsp->efuse[17] & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 15; + else + svsb->volt_od +=3D 12; + break; + case SVSB_CCI: + svsb->bdes =3D svsp->efuse[4] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[4] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[4] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[4] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D (svsp->efuse[5] >> 16) & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 10; + else + svsb->volt_od +=3D 2; + break; + case SVSB_GPU: + svsb->bdes =3D svsp->efuse[6] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[6] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[6] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[6] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D svsp->efuse[5] & GENMASK(7, 0); + + if (ft_pgm >=3D 2) { + svsb->freq_base =3D 800000000; /* 800MHz */ + svsb->dvt_fixed =3D 2; + } + break; + default: + dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); + return false; + } + } + + ret =3D svs_thermal_efuse_get_data(svsp); + if (ret) + return false; + + /* Thermal efuse parsing */ + adc_ge_t =3D (svsp->tefuse[1] >> 22) & GENMASK(9, 0); + adc_oe_t =3D (svsp->tefuse[1] >> 12) & GENMASK(9, 0); + + o_vtsmcu[0] =3D (svsp->tefuse[0] >> 17) & GENMASK(8, 0); + o_vtsmcu[1] =3D (svsp->tefuse[0] >> 8) & GENMASK(8, 0); + o_vtsmcu[2] =3D svsp->tefuse[1] & GENMASK(8, 0); + o_vtsmcu[3] =3D (svsp->tefuse[2] >> 23) & GENMASK(8, 0); + o_vtsmcu[4] =3D (svsp->tefuse[2] >> 5) & GENMASK(8, 0); + o_vtsabb =3D (svsp->tefuse[2] >> 14) & GENMASK(8, 0); + + degc_cali =3D (svsp->tefuse[0] >> 1) & GENMASK(5, 0); + adc_cali_en_t =3D svsp->tefuse[0] & BIT(0); + o_slope_sign =3D (svsp->tefuse[0] >> 7) & BIT(0); + + ts_id =3D (svsp->tefuse[1] >> 9) & BIT(0); + o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); + + if (adc_cali_en_t =3D=3D 1) { + if (!ts_id) + o_slope =3D 0; + + if (adc_ge_t < 265 || adc_ge_t > 758 || + adc_oe_t < 265 || adc_oe_t > 758 || + o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || + o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || + o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || + o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || + o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || + o_vtsabb < -8 || o_vtsabb > 484 || + degc_cali < 1 || degc_cali > 63) { + dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); + goto remove_mt8183_svsb_mon_mode; + } + } else { + dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); + goto remove_mt8183_svsb_mon_mode; + } + + ge =3D ((adc_ge_t - 512) * 10000) / 4096; + oe =3D (adc_oe_t - 512); + gain =3D (10000 + ge); + + format[0] =3D (o_vtsmcu[0] + 3350 - oe); + format[1] =3D (o_vtsmcu[1] + 3350 - oe); + format[2] =3D (o_vtsmcu[2] + 3350 - oe); + format[3] =3D (o_vtsmcu[3] + 3350 - oe); + format[4] =3D (o_vtsmcu[4] + 3350 - oe); + format[5] =3D (o_vtsabb + 3350 - oe); + + for (i =3D 0; i < 6; i++) + x_roomt[i] =3D (((format[i] * 10000) / 4096) * 10000) / gain; + + temp0 =3D (10000 * 100000 / gain) * 15 / 18; + + if (!o_slope_sign) + mts =3D (temp0 * 10) / (1534 + o_slope * 10); + else + mts =3D (temp0 * 10) / (1534 - o_slope * 10); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + svsb->mts =3D mts; + + switch (svsb->sw_id) { + case SVSB_CPU_LITTLE: + tb_roomt =3D x_roomt[3]; + break; + case SVSB_CPU_BIG: + tb_roomt =3D x_roomt[4]; + break; + case SVSB_CCI: + tb_roomt =3D x_roomt[3]; + break; + case SVSB_GPU: + tb_roomt =3D x_roomt[1]; + break; + default: + dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); + goto remove_mt8183_svsb_mon_mode; + } + + temp0 =3D (degc_cali * 10 / 2); + temp1 =3D ((10000 * 100000 / 4096 / gain) * + oe + tb_roomt * 10) * 15 / 18; + + if (!o_slope_sign) + temp2 =3D temp1 * 100 / (1534 + o_slope * 10); + else + temp2 =3D temp1 * 100 / (1534 - o_slope * 10); + + svsb->bts =3D (temp0 + temp2 - 250) * 4 / 10; + } + + return true; + +remove_mt8183_svsb_mon_mode: + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + svsb->mode_support &=3D ~SVSB_MODE_MON; + } + + return true; +} + +int svs_mt8183_platform_probe(struct svs_platform *svsp) +{ + struct device *dev; + struct svs_bank *svsb; + u32 idx; + + dev =3D svs_add_device_link(svsp, "thermal"); + if (IS_ERR(dev)) + return dev_err_probe(svsp->dev, PTR_ERR(dev), + "failed to get thermal device\n"); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + + switch (svsb->sw_id) { + case SVSB_CPU_LITTLE: + case SVSB_CPU_BIG: + svsb->opp_dev =3D get_cpu_device(svsb->cpu_id); + break; + case SVSB_CCI: + svsb->opp_dev =3D svs_add_device_link(svsp, "cci"); + break; + case SVSB_GPU: + svsb->opp_dev =3D svs_add_device_link(svsp, "gpu"); + break; + default: + dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); + return -EINVAL; + } + + if (IS_ERR(svsb->opp_dev)) + return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), + "failed to get OPP device for bank %d\n", + idx); + } + + return 0; +} diff --git a/drivers/soc/mediatek/mtk-svs-mt8192.c b/drivers/soc/mediatek/m= tk-svs-mt8192.c new file mode 100644 index 000000000000..838a94834741 --- /dev/null +++ b/drivers/soc/mediatek/mtk-svs-mt8192.c @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include "mtk-svs.h" + +bool svs_mt8192_efuse_parsing(struct svs_platform *svsp) +{ + struct svs_bank *svsb; + u32 idx, i, vmin, golden_temp; + int ret; + + for (i =3D 0; i < svsp->efuse_max; i++) + if (svsp->efuse[i]) + dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", + i, svsp->efuse[i]); + + if (!svsp->efuse[9]) { + dev_notice(svsp->dev, "svs_efuse[9] =3D 0x0?\n"); + return false; + } + + /* Svs efuse parsing */ + vmin =3D (svsp->efuse[19] >> 4) & GENMASK(1, 0); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + + if (vmin =3D=3D 0x1) + svsb->vmin =3D 0x1e; + + if (svsb->type =3D=3D SVSB_LOW) { + svsb->mtdes =3D svsp->efuse[10] & GENMASK(7, 0); + svsb->bdes =3D (svsp->efuse[10] >> 16) & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[10] >> 24) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[17]) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[17] >> 8) & GENMASK(7, 0); + } else if (svsb->type =3D=3D SVSB_HIGH) { + svsb->mtdes =3D svsp->efuse[9] & GENMASK(7, 0); + svsb->bdes =3D (svsp->efuse[9] >> 16) & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[9] >> 24) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[17] >> 24) & GENMASK(7, 0); + } + + svsb->vmax +=3D svsb->dvt_fixed; + } + + ret =3D svs_thermal_efuse_get_data(svsp); + if (ret) + return false; + + for (i =3D 0; i < svsp->tefuse_max; i++) + if (svsp->tefuse[i] !=3D 0) + break; + + if (i =3D=3D svsp->tefuse_max) + golden_temp =3D 50; /* All thermal efuse data are 0 */ + else + golden_temp =3D (svsp->tefuse[0] >> 24) & GENMASK(7, 0); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + svsb->mts =3D 500; + svsb->bts =3D (((500 * golden_temp + 250460) / 1000) - 25) * 4; + } + + return true; +} + +int svs_mt8192_platform_probe(struct svs_platform *svsp) +{ + struct device *dev; + struct svs_bank *svsb; + u32 idx; + + svsp->rst =3D devm_reset_control_get_optional(svsp->dev, "svs_rst"); + if (IS_ERR(svsp->rst)) + return dev_err_probe(svsp->dev, PTR_ERR(svsp->rst), + "cannot get svs reset control\n"); + + dev =3D svs_add_device_link(svsp, "lvts"); + if (IS_ERR(dev)) + return dev_err_probe(svsp->dev, PTR_ERR(dev), + "failed to get lvts device\n"); + + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + + if (svsb->type =3D=3D SVSB_HIGH) + svsb->opp_dev =3D svs_add_device_link(svsp, "mali"); + else if (svsb->type =3D=3D SVSB_LOW) + svsb->opp_dev =3D svs_get_subsys_device(svsp, "mali"); + + if (IS_ERR(svsb->opp_dev)) + return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), + "failed to get OPP device for bank %d\n", + idx); + } + + return 0; +} diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 482cc8d7e7cf..714eb93160f5 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -19,40 +18,19 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include #include =20 -/* svs bank 1-line software id */ -#define SVSB_CPU_LITTLE BIT(0) -#define SVSB_CPU_BIG BIT(1) -#define SVSB_CCI BIT(2) -#define SVSB_GPU BIT(3) - -/* svs bank 2-line type */ -#define SVSB_LOW BIT(8) -#define SVSB_HIGH BIT(9) - -/* svs bank mode support */ -#define SVSB_MODE_ALL_DISABLE 0 -#define SVSB_MODE_INIT01 BIT(1) -#define SVSB_MODE_INIT02 BIT(2) -#define SVSB_MODE_MON BIT(3) - -/* svs bank volt flags */ -#define SVSB_INIT01_PD_REQ BIT(0) -#define SVSB_INIT01_VOLT_IGNORE BIT(1) -#define SVSB_INIT01_VOLT_INC_ONLY BIT(2) -#define SVSB_MON_VOLT_IGNORE BIT(16) -#define SVSB_REMOVE_DVTFIXED_VOLT BIT(24) +#include "mtk-svs.h" +#include "mt8183-svs.h" +#include "mt8192-svs.h" =20 /* svs bank register fields and common configuration */ #define SVSB_PTPCONFIG_DETMAX GENMASK(15, 0) @@ -129,129 +107,12 @@ =20 /* svs bank related setting */ #define BITS8 8 -#define MAX_OPP_ENTRIES 16 #define REG_BYTES 4 #define SVSB_DC_SIGNED_BIT BIT(15) #define SVSB_DET_CLK_EN BIT(31) #define SVSB_TEMP_LOWER_BOUND 0xb2 #define SVSB_TEMP_UPPER_BOUND 0x64 =20 -static DEFINE_SPINLOCK(svs_lock); - -#define debug_fops_ro(name) \ - static int svs_##name##_debug_open(struct inode *inode, \ - struct file *filp) \ - { \ - return single_open(filp, svs_##name##_debug_show, \ - inode->i_private); \ - } \ - static const struct file_operations svs_##name##_debug_fops =3D { \ - .owner =3D THIS_MODULE, \ - .open =3D svs_##name##_debug_open, \ - .read =3D seq_read, \ - .llseek =3D seq_lseek, \ - .release =3D single_release, \ - } - -#define debug_fops_rw(name) \ - static int svs_##name##_debug_open(struct inode *inode, \ - struct file *filp) \ - { \ - return single_open(filp, svs_##name##_debug_show, \ - inode->i_private); \ - } \ - static const struct file_operations svs_##name##_debug_fops =3D { \ - .owner =3D THIS_MODULE, \ - .open =3D svs_##name##_debug_open, \ - .read =3D seq_read, \ - .write =3D svs_##name##_debug_write, \ - .llseek =3D seq_lseek, \ - .release =3D single_release, \ - } - -#define svs_dentry_data(name) {__stringify(name), &svs_##name##_debug_fops} - -/** - * enum svsb_phase - svs bank phase enumeration - * @SVSB_PHASE_ERROR: svs bank encounters unexpected condition - * @SVSB_PHASE_INIT01: svs bank basic init for data calibration - * @SVSB_PHASE_INIT02: svs bank can provide voltages to opp table - * @SVSB_PHASE_MON: svs bank can provide voltages with thermal effect - * @SVSB_PHASE_MAX: total number of svs bank phase (debug purpose) - * - * Each svs bank has its own independent phase and we enable each svs bank= by - * running their phase orderly. However, when svs bank encounters unexpect= ed - * condition, it will fire an irq (PHASE_ERROR) to inform svs software. - * - * svs bank general phase-enabled order: - * SVSB_PHASE_INIT01 -> SVSB_PHASE_INIT02 -> SVSB_PHASE_MON - */ -enum svsb_phase { - SVSB_PHASE_ERROR =3D 0, - SVSB_PHASE_INIT01, - SVSB_PHASE_INIT02, - SVSB_PHASE_MON, - SVSB_PHASE_MAX, -}; - -enum svs_reg_index { - DESCHAR =3D 0, - TEMPCHAR, - DETCHAR, - AGECHAR, - DCCONFIG, - AGECONFIG, - FREQPCT30, - FREQPCT74, - LIMITVALS, - VBOOT, - DETWINDOW, - CONFIG, - TSCALCS, - RUNCONFIG, - SVSEN, - INIT2VALS, - DCVALUES, - AGEVALUES, - VOP30, - VOP74, - TEMP, - INTSTS, - INTSTSRAW, - INTEN, - CHKINT, - CHKSHIFT, - STATUS, - VDESIGN30, - VDESIGN74, - DVT30, - DVT74, - AGECOUNT, - SMSTATE0, - SMSTATE1, - CTL0, - DESDETSEC, - TEMPAGESEC, - CTRLSPARE0, - CTRLSPARE1, - CTRLSPARE2, - CTRLSPARE3, - CORESEL, - THERMINTST, - INTST, - THSTAGE0ST, - THSTAGE1ST, - THSTAGE2ST, - THAHBST0, - THAHBST1, - SPARE0, - SPARE1, - SPARE2, - SPARE3, - THSLPEVEB, - SVS_REG_MAX, -}; - static const u32 svs_regs_v2[] =3D { [DESCHAR] =3D 0xc00, [TEMPCHAR] =3D 0xc04, @@ -309,35 +170,41 @@ static const u32 svs_regs_v2[] =3D { [THSLPEVEB] =3D 0xf30, }; =20 -/** - * struct svs_platform - svs platform control - * @base: svs platform register base - * @dev: svs platform device - * @main_clk: main clock for svs bank - * @pbank: svs bank pointer needing to be protected by spin_lock section - * @banks: svs banks that svs platform supports - * @rst: svs platform reset control - * @efuse_max: total number of svs efuse - * @tefuse_max: total number of thermal efuse - * @regs: svs platform registers map - * @bank_max: total number of svs banks - * @efuse: svs efuse data received from NVMEM framework - * @tefuse: thermal efuse data received from NVMEM framework - */ -struct svs_platform { - void __iomem *base; - struct device *dev; - struct clk *main_clk; - struct svs_bank *pbank; - struct svs_bank *banks; - struct reset_control *rst; - size_t efuse_max; - size_t tefuse_max; - const u32 *regs; - u32 bank_max; - u32 *efuse; - u32 *tefuse; -}; +static DEFINE_SPINLOCK(svs_lock); + +#define debug_fops_ro(name) \ + static int svs_##name##_debug_open(struct inode *inode, \ + struct file *filp) \ + { \ + return single_open(filp, svs_##name##_debug_show, \ + inode->i_private); \ + } \ + static const struct file_operations svs_##name##_debug_fops =3D { \ + .owner =3D THIS_MODULE, \ + .open =3D svs_##name##_debug_open, \ + .read =3D seq_read, \ + .llseek =3D seq_lseek, \ + .release =3D single_release, \ + } + +#define debug_fops_rw(name) \ + static int svs_##name##_debug_open(struct inode *inode, \ + struct file *filp) \ + { \ + return single_open(filp, svs_##name##_debug_show, \ + inode->i_private); \ + } \ + static const struct file_operations svs_##name##_debug_fops =3D { \ + .owner =3D THIS_MODULE, \ + .open =3D svs_##name##_debug_open, \ + .read =3D seq_read, \ + .write =3D svs_##name##_debug_write, \ + .llseek =3D seq_lseek, \ + .release =3D single_release, \ + } + +#define svs_dentry_data(name) {__stringify(name), &svs_##name##_debug_fops} + =20 struct svs_platform_data { char *name; @@ -348,127 +215,6 @@ struct svs_platform_data { u32 bank_max; }; =20 -/** - * struct svs_bank - svs bank representation - * @dev: bank device - * @opp_dev: device for opp table/buck control - * @init_completion: the timeout completion for bank init - * @buck: regulator used by opp_dev - * @tzd: thermal zone device for getting temperature - * @lock: mutex lock to protect voltage update process - * @set_freq_pct: function pointer to set bank frequency percent table - * @get_volts: function pointer to get bank voltages - * @name: bank name - * @buck_name: regulator name - * @tzone_name: thermal zone name - * @phase: bank current phase - * @volt_od: bank voltage overdrive - * @reg_data: bank register data in different phase for debug purpose - * @pm_runtime_enabled_count: bank pm runtime enabled count - * @mode_support: bank mode support. - * @freq_base: reference frequency for bank init - * @turn_freq_base: refenrece frequency for 2-line turn point - * @vboot: voltage request for bank init01 only - * @opp_dfreq: default opp frequency table - * @opp_dvolt: default opp voltage table - * @freq_pct: frequency percent table for bank init - * @volt: bank voltage table - * @volt_step: bank voltage step - * @volt_base: bank voltage base - * @volt_flags: bank voltage flags - * @vmax: bank voltage maximum - * @vmin: bank voltage minimum - * @age_config: bank age configuration - * @age_voffset_in: bank age voltage offset - * @dc_config: bank dc configuration - * @dc_voffset_in: bank dc voltage offset - * @dvt_fixed: bank dvt fixed value - * @vco: bank VCO value - * @chk_shift: bank chicken shift - * @core_sel: bank selection - * @opp_count: bank opp count - * @int_st: bank interrupt identification - * @sw_id: bank software identification - * @cpu_id: cpu core id for SVS CPU bank use only - * @ctl0: TS-x selection - * @temp: bank temperature - * @tzone_htemp: thermal zone high temperature threshold - * @tzone_htemp_voffset: thermal zone high temperature voltage offset - * @tzone_ltemp: thermal zone low temperature threshold - * @tzone_ltemp_voffset: thermal zone low temperature voltage offset - * @bts: svs efuse data - * @mts: svs efuse data - * @bdes: svs efuse data - * @mdes: svs efuse data - * @mtdes: svs efuse data - * @dcbdet: svs efuse data - * @dcmdet: svs efuse data - * @turn_pt: 2-line turn point tells which opp_volt calculated by high/low= bank - * @type: bank type to represent it is 2-line (high/low) bank or 1-line ba= nk - * - * Svs bank will generate suitalbe voltages by below general math equation - * and provide these voltages to opp voltage table. - * - * opp_volt[i] =3D (volt[i] * volt_step) + volt_base; - */ -struct svs_bank { - struct device *dev; - struct device *opp_dev; - struct completion init_completion; - struct regulator *buck; - struct thermal_zone_device *tzd; - struct mutex lock; /* lock to protect voltage update process */ - void (*set_freq_pct)(struct svs_platform *svsp); - void (*get_volts)(struct svs_platform *svsp); - char *name; - char *buck_name; - char *tzone_name; - enum svsb_phase phase; - s32 volt_od; - u32 reg_data[SVSB_PHASE_MAX][SVS_REG_MAX]; - u32 pm_runtime_enabled_count; - u32 mode_support; - u32 freq_base; - u32 turn_freq_base; - u32 vboot; - u32 opp_dfreq[MAX_OPP_ENTRIES]; - u32 opp_dvolt[MAX_OPP_ENTRIES]; - u32 freq_pct[MAX_OPP_ENTRIES]; - u32 volt[MAX_OPP_ENTRIES]; - u32 volt_step; - u32 volt_base; - u32 volt_flags; - u32 vmax; - u32 vmin; - u32 age_config; - u32 age_voffset_in; - u32 dc_config; - u32 dc_voffset_in; - u32 dvt_fixed; - u32 vco; - u32 chk_shift; - u32 core_sel; - u32 opp_count; - u32 int_st; - u32 sw_id; - u32 cpu_id; - u32 ctl0; - u32 temp; - u32 tzone_htemp; - u32 tzone_htemp_voffset; - u32 tzone_ltemp; - u32 tzone_ltemp_voffset; - u32 bts; - u32 mts; - u32 bdes; - u32 mdes; - u32 mtdes; - u32 dcbdet; - u32 dcmdet; - u32 turn_pt; - u32 type; -}; - static u32 percent(u32 numerator, u32 denominator) { /* If not divide 1000, "numerator * 100" will have data overflow. */ @@ -851,7 +597,7 @@ static u32 interpolate(u32 f0, u32 f1, u32 v0, u32 v1, = u32 fx) return DIV_ROUND_UP(vx, 100); } =20 -static void svs_get_bank_volts_v3(struct svs_platform *svsp) +void svs_get_bank_volts_v3(struct svs_platform *svsp) { struct svs_bank *svsb =3D svsp->pbank; u32 i, j, *vop, vop74, vop30, turn_pt =3D svsb->turn_pt; @@ -943,7 +689,7 @@ static void svs_get_bank_volts_v3(struct svs_platform *= svsp) svsb->volt[i] -=3D svsb->dvt_fixed; } =20 -static void svs_set_bank_freq_pct_v3(struct svs_platform *svsp) +void svs_set_bank_freq_pct_v3(struct svs_platform *svsp) { struct svs_bank *svsb =3D svsp->pbank; u32 i, j, *freq_pct, freq_pct74 =3D 0, freq_pct30 =3D 0; @@ -1026,7 +772,7 @@ static void svs_set_bank_freq_pct_v3(struct svs_platfo= rm *svsp) svs_writel_relaxed(svsp, freq_pct30, FREQPCT30); } =20 -static void svs_get_bank_volts_v2(struct svs_platform *svsp) +void svs_get_bank_volts_v2(struct svs_platform *svsp) { struct svs_bank *svsb =3D svsp->pbank; u32 temp, i; @@ -1060,7 +806,7 @@ static void svs_get_bank_volts_v2(struct svs_platform = *svsp) svsb->volt[i] +=3D svsb->volt_od; } =20 -static void svs_set_bank_freq_pct_v2(struct svs_platform *svsp) +void svs_set_bank_freq_pct_v2(struct svs_platform *svsp) { struct svs_bank *svsb =3D svsp->pbank; u32 freqpct74_val, freqpct30_val; @@ -1701,7 +1447,7 @@ static int svs_bank_resource_setup(struct svs_platfor= m *svsp) return 0; } =20 -static int svs_thermal_efuse_get_data(struct svs_platform *svsp) +int svs_thermal_efuse_get_data(struct svs_platform *svsp) { struct nvmem_cell *cell; =20 @@ -1726,262 +1472,6 @@ static int svs_thermal_efuse_get_data(struct svs_pl= atform *svsp) return 0; } =20 -static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp) -{ - struct svs_bank *svsb; - u32 idx, i, vmin, golden_temp; - int ret; - - for (i =3D 0; i < svsp->efuse_max; i++) - if (svsp->efuse[i]) - dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", - i, svsp->efuse[i]); - - if (!svsp->efuse[9]) { - dev_notice(svsp->dev, "svs_efuse[9] =3D 0x0?\n"); - return false; - } - - /* Svs efuse parsing */ - vmin =3D (svsp->efuse[19] >> 4) & GENMASK(1, 0); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - - if (vmin =3D=3D 0x1) - svsb->vmin =3D 0x1e; - - if (svsb->type =3D=3D SVSB_LOW) { - svsb->mtdes =3D svsp->efuse[10] & GENMASK(7, 0); - svsb->bdes =3D (svsp->efuse[10] >> 16) & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[10] >> 24) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[17]) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[17] >> 8) & GENMASK(7, 0); - } else if (svsb->type =3D=3D SVSB_HIGH) { - svsb->mtdes =3D svsp->efuse[9] & GENMASK(7, 0); - svsb->bdes =3D (svsp->efuse[9] >> 16) & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[9] >> 24) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[17] >> 24) & GENMASK(7, 0); - } - - svsb->vmax +=3D svsb->dvt_fixed; - } - - ret =3D svs_thermal_efuse_get_data(svsp); - if (ret) - return false; - - for (i =3D 0; i < svsp->tefuse_max; i++) - if (svsp->tefuse[i] !=3D 0) - break; - - if (i =3D=3D svsp->tefuse_max) - golden_temp =3D 50; /* All thermal efuse data are 0 */ - else - golden_temp =3D (svsp->tefuse[0] >> 24) & GENMASK(7, 0); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - svsb->mts =3D 500; - svsb->bts =3D (((500 * golden_temp + 250460) / 1000) - 25) * 4; - } - - return true; -} - -static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) -{ - struct svs_bank *svsb; - int format[6], x_roomt[6], o_vtsmcu[5], o_vtsabb, tb_roomt =3D 0; - int adc_ge_t, adc_oe_t, ge, oe, gain, degc_cali, adc_cali_en_t; - int o_slope, o_slope_sign, ts_id; - u32 idx, i, ft_pgm, mts, temp0, temp1, temp2; - int ret; - - for (i =3D 0; i < svsp->efuse_max; i++) - if (svsp->efuse[i]) - dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", - i, svsp->efuse[i]); - - if (!svsp->efuse[2]) { - dev_notice(svsp->dev, "svs_efuse[2] =3D 0x0?\n"); - return false; - } - - /* Svs efuse parsing */ - ft_pgm =3D (svsp->efuse[0] >> 4) & GENMASK(3, 0); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - - if (ft_pgm <=3D 1) - svsb->volt_flags |=3D SVSB_INIT01_VOLT_IGNORE; - - switch (svsb->sw_id) { - case SVSB_CPU_LITTLE: - svsb->bdes =3D svsp->efuse[16] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[16] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[16] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[16] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 10; - else - svsb->volt_od +=3D 2; - break; - case SVSB_CPU_BIG: - svsb->bdes =3D svsp->efuse[18] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[18] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[18] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[18] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D svsp->efuse[17] & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 15; - else - svsb->volt_od +=3D 12; - break; - case SVSB_CCI: - svsb->bdes =3D svsp->efuse[4] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[4] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[4] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[4] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D (svsp->efuse[5] >> 16) & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 10; - else - svsb->volt_od +=3D 2; - break; - case SVSB_GPU: - svsb->bdes =3D svsp->efuse[6] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[6] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[6] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[6] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D svsp->efuse[5] & GENMASK(7, 0); - - if (ft_pgm >=3D 2) { - svsb->freq_base =3D 800000000; /* 800MHz */ - svsb->dvt_fixed =3D 2; - } - break; - default: - dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); - return false; - } - } - - ret =3D svs_thermal_efuse_get_data(svsp); - if (ret) - return false; - - /* Thermal efuse parsing */ - adc_ge_t =3D (svsp->tefuse[1] >> 22) & GENMASK(9, 0); - adc_oe_t =3D (svsp->tefuse[1] >> 12) & GENMASK(9, 0); - - o_vtsmcu[0] =3D (svsp->tefuse[0] >> 17) & GENMASK(8, 0); - o_vtsmcu[1] =3D (svsp->tefuse[0] >> 8) & GENMASK(8, 0); - o_vtsmcu[2] =3D svsp->tefuse[1] & GENMASK(8, 0); - o_vtsmcu[3] =3D (svsp->tefuse[2] >> 23) & GENMASK(8, 0); - o_vtsmcu[4] =3D (svsp->tefuse[2] >> 5) & GENMASK(8, 0); - o_vtsabb =3D (svsp->tefuse[2] >> 14) & GENMASK(8, 0); - - degc_cali =3D (svsp->tefuse[0] >> 1) & GENMASK(5, 0); - adc_cali_en_t =3D svsp->tefuse[0] & BIT(0); - o_slope_sign =3D (svsp->tefuse[0] >> 7) & BIT(0); - - ts_id =3D (svsp->tefuse[1] >> 9) & BIT(0); - o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); - - if (adc_cali_en_t =3D=3D 1) { - if (!ts_id) - o_slope =3D 0; - - if (adc_ge_t < 265 || adc_ge_t > 758 || - adc_oe_t < 265 || adc_oe_t > 758 || - o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || - o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || - o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || - o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || - o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || - o_vtsabb < -8 || o_vtsabb > 484 || - degc_cali < 1 || degc_cali > 63) { - dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; - } - } else { - dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; - } - - ge =3D ((adc_ge_t - 512) * 10000) / 4096; - oe =3D (adc_oe_t - 512); - gain =3D (10000 + ge); - - format[0] =3D (o_vtsmcu[0] + 3350 - oe); - format[1] =3D (o_vtsmcu[1] + 3350 - oe); - format[2] =3D (o_vtsmcu[2] + 3350 - oe); - format[3] =3D (o_vtsmcu[3] + 3350 - oe); - format[4] =3D (o_vtsmcu[4] + 3350 - oe); - format[5] =3D (o_vtsabb + 3350 - oe); - - for (i =3D 0; i < 6; i++) - x_roomt[i] =3D (((format[i] * 10000) / 4096) * 10000) / gain; - - temp0 =3D (10000 * 100000 / gain) * 15 / 18; - - if (!o_slope_sign) - mts =3D (temp0 * 10) / (1534 + o_slope * 10); - else - mts =3D (temp0 * 10) / (1534 - o_slope * 10); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - svsb->mts =3D mts; - - switch (svsb->sw_id) { - case SVSB_CPU_LITTLE: - tb_roomt =3D x_roomt[3]; - break; - case SVSB_CPU_BIG: - tb_roomt =3D x_roomt[4]; - break; - case SVSB_CCI: - tb_roomt =3D x_roomt[3]; - break; - case SVSB_GPU: - tb_roomt =3D x_roomt[1]; - break; - default: - dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); - goto remove_mt8183_svsb_mon_mode; - } - - temp0 =3D (degc_cali * 10 / 2); - temp1 =3D ((10000 * 100000 / 4096 / gain) * - oe + tb_roomt * 10) * 15 / 18; - - if (!o_slope_sign) - temp2 =3D temp1 * 100 / (1534 + o_slope * 10); - else - temp2 =3D temp1 * 100 / (1534 - o_slope * 10); - - svsb->bts =3D (temp0 + temp2 - 250) * 4 / 10; - } - - return true; - -remove_mt8183_svsb_mon_mode: - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - svsb->mode_support &=3D ~SVSB_MODE_MON; - } - - return true; -} - static bool svs_is_efuse_data_correct(struct svs_platform *svsp) { struct nvmem_cell *cell; @@ -2008,7 +1498,7 @@ static bool svs_is_efuse_data_correct(struct svs_plat= form *svsp) return true; } =20 -static struct device *svs_get_subsys_device(struct svs_platform *svsp, +struct device *svs_get_subsys_device(struct svs_platform *svsp, const char *node_name) { struct platform_device *pdev; @@ -2032,7 +1522,7 @@ static struct device *svs_get_subsys_device(struct sv= s_platform *svsp, return &pdev->dev; } =20 -static struct device *svs_add_device_link(struct svs_platform *svsp, +struct device *svs_add_device_link(struct svs_platform *svsp, const char *node_name) { struct device *dev; @@ -2060,237 +1550,6 @@ static struct device *svs_add_device_link(struct sv= s_platform *svsp, return dev; } =20 -static int svs_mt8192_platform_probe(struct svs_platform *svsp) -{ - struct device *dev; - struct svs_bank *svsb; - u32 idx; - - svsp->rst =3D devm_reset_control_get_optional(svsp->dev, "svs_rst"); - if (IS_ERR(svsp->rst)) - return dev_err_probe(svsp->dev, PTR_ERR(svsp->rst), - "cannot get svs reset control\n"); - - dev =3D svs_add_device_link(svsp, "lvts"); - if (IS_ERR(dev)) - return dev_err_probe(svsp->dev, PTR_ERR(dev), - "failed to get lvts device\n"); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - - if (svsb->type =3D=3D SVSB_HIGH) - svsb->opp_dev =3D svs_add_device_link(svsp, "mali"); - else if (svsb->type =3D=3D SVSB_LOW) - svsb->opp_dev =3D svs_get_subsys_device(svsp, "mali"); - - if (IS_ERR(svsb->opp_dev)) - return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), - "failed to get OPP device for bank %d\n", - idx); - } - - return 0; -} - -static int svs_mt8183_platform_probe(struct svs_platform *svsp) -{ - struct device *dev; - struct svs_bank *svsb; - u32 idx; - - dev =3D svs_add_device_link(svsp, "thermal"); - if (IS_ERR(dev)) - return dev_err_probe(svsp->dev, PTR_ERR(dev), - "failed to get thermal device\n"); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - - switch (svsb->sw_id) { - case SVSB_CPU_LITTLE: - case SVSB_CPU_BIG: - svsb->opp_dev =3D get_cpu_device(svsb->cpu_id); - break; - case SVSB_CCI: - svsb->opp_dev =3D svs_add_device_link(svsp, "cci"); - break; - case SVSB_GPU: - svsb->opp_dev =3D svs_add_device_link(svsp, "gpu"); - break; - default: - dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); - return -EINVAL; - } - - if (IS_ERR(svsb->opp_dev)) - return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), - "failed to get OPP device for bank %d\n", - idx); - } - - return 0; -} - -static struct svs_bank svs_mt8192_banks[] =3D { - { - .sw_id =3D SVSB_GPU, - .type =3D SVSB_LOW, - .set_freq_pct =3D svs_set_bank_freq_pct_v3, - .get_volts =3D svs_get_bank_volts_v3, - .volt_flags =3D SVSB_REMOVE_DVTFIXED_VOLT, - .mode_support =3D SVSB_MODE_INIT02, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 688000000, - .turn_freq_base =3D 688000000, - .volt_step =3D 6250, - .volt_base =3D 400000, - .vmax =3D 0x60, - .vmin =3D 0x1a, - .age_config =3D 0x555555, - .dc_config =3D 0x1, - .dvt_fixed =3D 0x1, - .vco =3D 0x18, - .chk_shift =3D 0x87, - .core_sel =3D 0x0fff0100, - .int_st =3D BIT(0), - .ctl0 =3D 0x00540003, - }, - { - .sw_id =3D SVSB_GPU, - .type =3D SVSB_HIGH, - .set_freq_pct =3D svs_set_bank_freq_pct_v3, - .get_volts =3D svs_get_bank_volts_v3, - .tzone_name =3D "gpu1", - .volt_flags =3D SVSB_REMOVE_DVTFIXED_VOLT | - SVSB_MON_VOLT_IGNORE, - .mode_support =3D SVSB_MODE_INIT02 | SVSB_MODE_MON, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 902000000, - .turn_freq_base =3D 688000000, - .volt_step =3D 6250, - .volt_base =3D 400000, - .vmax =3D 0x60, - .vmin =3D 0x1a, - .age_config =3D 0x555555, - .dc_config =3D 0x1, - .dvt_fixed =3D 0x6, - .vco =3D 0x18, - .chk_shift =3D 0x87, - .core_sel =3D 0x0fff0101, - .int_st =3D BIT(1), - .ctl0 =3D 0x00540003, - .tzone_htemp =3D 85000, - .tzone_htemp_voffset =3D 0, - .tzone_ltemp =3D 25000, - .tzone_ltemp_voffset =3D 7, - }, -}; - -static struct svs_bank svs_mt8183_banks[] =3D { - { - .sw_id =3D SVSB_CPU_LITTLE, - .set_freq_pct =3D svs_set_bank_freq_pct_v2, - .get_volts =3D svs_get_bank_volts_v2, - .cpu_id =3D 0, - .buck_name =3D "proc", - .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, - .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 1989000000, - .vboot =3D 0x30, - .volt_step =3D 6250, - .volt_base =3D 500000, - .vmax =3D 0x64, - .vmin =3D 0x18, - .age_config =3D 0x555555, - .dc_config =3D 0x555555, - .dvt_fixed =3D 0x7, - .vco =3D 0x10, - .chk_shift =3D 0x77, - .core_sel =3D 0x8fff0000, - .int_st =3D BIT(0), - .ctl0 =3D 0x00010001, - }, - { - .sw_id =3D SVSB_CPU_BIG, - .set_freq_pct =3D svs_set_bank_freq_pct_v2, - .get_volts =3D svs_get_bank_volts_v2, - .cpu_id =3D 4, - .buck_name =3D "proc", - .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, - .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 1989000000, - .vboot =3D 0x30, - .volt_step =3D 6250, - .volt_base =3D 500000, - .vmax =3D 0x58, - .vmin =3D 0x10, - .age_config =3D 0x555555, - .dc_config =3D 0x555555, - .dvt_fixed =3D 0x7, - .vco =3D 0x10, - .chk_shift =3D 0x77, - .core_sel =3D 0x8fff0001, - .int_st =3D BIT(1), - .ctl0 =3D 0x00000001, - }, - { - .sw_id =3D SVSB_CCI, - .set_freq_pct =3D svs_set_bank_freq_pct_v2, - .get_volts =3D svs_get_bank_volts_v2, - .buck_name =3D "proc", - .volt_flags =3D SVSB_INIT01_VOLT_INC_ONLY, - .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 1196000000, - .vboot =3D 0x30, - .volt_step =3D 6250, - .volt_base =3D 500000, - .vmax =3D 0x64, - .vmin =3D 0x18, - .age_config =3D 0x555555, - .dc_config =3D 0x555555, - .dvt_fixed =3D 0x7, - .vco =3D 0x10, - .chk_shift =3D 0x77, - .core_sel =3D 0x8fff0002, - .int_st =3D BIT(2), - .ctl0 =3D 0x00100003, - }, - { - .sw_id =3D SVSB_GPU, - .set_freq_pct =3D svs_set_bank_freq_pct_v2, - .get_volts =3D svs_get_bank_volts_v2, - .buck_name =3D "mali", - .tzone_name =3D "tzts2", - .volt_flags =3D SVSB_INIT01_PD_REQ | - SVSB_INIT01_VOLT_INC_ONLY, - .mode_support =3D SVSB_MODE_INIT01 | SVSB_MODE_INIT02 | - SVSB_MODE_MON, - .opp_count =3D MAX_OPP_ENTRIES, - .freq_base =3D 900000000, - .vboot =3D 0x30, - .volt_step =3D 6250, - .volt_base =3D 500000, - .vmax =3D 0x40, - .vmin =3D 0x14, - .age_config =3D 0x555555, - .dc_config =3D 0x555555, - .dvt_fixed =3D 0x3, - .vco =3D 0x10, - .chk_shift =3D 0x77, - .core_sel =3D 0x8fff0003, - .int_st =3D BIT(3), - .ctl0 =3D 0x00050001, - .tzone_htemp =3D 85000, - .tzone_htemp_voffset =3D 0, - .tzone_ltemp =3D 25000, - .tzone_ltemp_voffset =3D 3, - }, -}; - static const struct svs_platform_data svs_mt8192_platform_data =3D { .name =3D "mt8192-svs", .banks =3D svs_mt8192_banks, diff --git a/drivers/soc/mediatek/mtk-svs.h b/drivers/soc/mediatek/mtk-svs.h new file mode 100644 index 000000000000..dca414181066 --- /dev/null +++ b/drivers/soc/mediatek/mtk-svs.h @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DRV_SVS_MTK_H +#define __DRV_SVS_MTK_H + +#include +#include +#include +#include + +/* svs bank 1-line software id */ +#define SVSB_CPU_LITTLE BIT(0) +#define SVSB_CPU_BIG BIT(1) +#define SVSB_CCI BIT(2) +#define SVSB_GPU BIT(3) + +/* svs bank 2-line type */ +#define SVSB_LOW BIT(8) +#define SVSB_HIGH BIT(9) + +/* svs bank mode support */ +#define SVSB_MODE_ALL_DISABLE 0 +#define SVSB_MODE_INIT01 BIT(1) +#define SVSB_MODE_INIT02 BIT(2) +#define SVSB_MODE_MON BIT(3) + +/* svs bank volt flags */ +#define SVSB_INIT01_PD_REQ BIT(0) +#define SVSB_INIT01_VOLT_IGNORE BIT(1) +#define SVSB_INIT01_VOLT_INC_ONLY BIT(2) +#define SVSB_MON_VOLT_IGNORE BIT(16) +#define SVSB_REMOVE_DVTFIXED_VOLT BIT(24) + +/** + * enum svsb_phase - svs bank phase enumeration + * @SVSB_PHASE_ERROR: svs bank encounters unexpected condition + * @SVSB_PHASE_INIT01: svs bank basic init for data calibration + * @SVSB_PHASE_INIT02: svs bank can provide voltages to opp table + * @SVSB_PHASE_MON: svs bank can provide voltages with thermal effect + * @SVSB_PHASE_MAX: total number of svs bank phase (debug purpose) + * + * Each svs bank has its own independent phase and we enable each svs bank= by + * running their phase orderly. However, when svs bank encounters unexpect= ed + * condition, it will fire an irq (PHASE_ERROR) to inform svs software. + * + * svs bank general phase-enabled order: + * SVSB_PHASE_INIT01 -> SVSB_PHASE_INIT02 -> SVSB_PHASE_MON + */ +enum svsb_phase { + SVSB_PHASE_ERROR =3D 0, + SVSB_PHASE_INIT01, + SVSB_PHASE_INIT02, + SVSB_PHASE_MON, + SVSB_PHASE_MAX, +}; + +enum svs_reg_index { + DESCHAR =3D 0, + TEMPCHAR, + DETCHAR, + AGECHAR, + DCCONFIG, + AGECONFIG, + FREQPCT30, + FREQPCT74, + LIMITVALS, + VBOOT, + DETWINDOW, + CONFIG, + TSCALCS, + RUNCONFIG, + SVSEN, + INIT2VALS, + DCVALUES, + AGEVALUES, + VOP30, + VOP74, + TEMP, + INTSTS, + INTSTSRAW, + INTEN, + CHKINT, + CHKSHIFT, + STATUS, + VDESIGN30, + VDESIGN74, + DVT30, + DVT74, + AGECOUNT, + SMSTATE0, + SMSTATE1, + CTL0, + DESDETSEC, + TEMPAGESEC, + CTRLSPARE0, + CTRLSPARE1, + CTRLSPARE2, + CTRLSPARE3, + CORESEL, + THERMINTST, + INTST, + THSTAGE0ST, + THSTAGE1ST, + THSTAGE2ST, + THAHBST0, + THAHBST1, + SPARE0, + SPARE1, + SPARE2, + SPARE3, + THSLPEVEB, + SVS_REG_MAX, +}; + +/** + * struct svs_platform - svs platform control + * @base: svs platform register base + * @dev: svs platform device + * @main_clk: main clock for svs bank + * @pbank: svs bank pointer needing to be protected by spin_lock section + * @banks: svs banks that svs platform supports + * @rst: svs platform reset control + * @efuse_max: total number of svs efuse + * @tefuse_max: total number of thermal efuse + * @regs: svs platform registers map + * @bank_max: total number of svs banks + * @efuse: svs efuse data received from NVMEM framework + * @tefuse: thermal efuse data received from NVMEM framework + */ +struct svs_platform { + void __iomem *base; + struct device *dev; + struct clk *main_clk; + struct svs_bank *pbank; + struct svs_bank *banks; + struct reset_control *rst; + size_t efuse_max; + size_t tefuse_max; + const u32 *regs; + u32 bank_max; + u32 *efuse; + u32 *tefuse; +}; + +#define MAX_OPP_ENTRIES 16 + +/** + * struct svs_bank - svs bank representation + * @dev: bank device + * @opp_dev: device for opp table/buck control + * @init_completion: the timeout completion for bank init + * @buck: regulator used by opp_dev + * @tzd: thermal zone device for getting temperature + * @lock: mutex lock to protect voltage update process + * @set_freq_pct: function pointer to set bank frequency percent table + * @get_volts: function pointer to get bank voltages + * @name: bank name + * @buck_name: regulator name + * @tzone_name: thermal zone name + * @phase: bank current phase + * @volt_od: bank voltage overdrive + * @reg_data: bank register data in different phase for debug purpose + * @pm_runtime_enabled_count: bank pm runtime enabled count + * @mode_support: bank mode support. + * @freq_base: reference frequency for bank init + * @turn_freq_base: refenrece frequency for 2-line turn point + * @vboot: voltage request for bank init01 only + * @opp_dfreq: default opp frequency table + * @opp_dvolt: default opp voltage table + * @freq_pct: frequency percent table for bank init + * @volt: bank voltage table + * @volt_step: bank voltage step + * @volt_base: bank voltage base + * @volt_flags: bank voltage flags + * @vmax: bank voltage maximum + * @vmin: bank voltage minimum + * @age_config: bank age configuration + * @age_voffset_in: bank age voltage offset + * @dc_config: bank dc configuration + * @dc_voffset_in: bank dc voltage offset + * @dvt_fixed: bank dvt fixed value + * @vco: bank VCO value + * @chk_shift: bank chicken shift + * @core_sel: bank selection + * @opp_count: bank opp count + * @int_st: bank interrupt identification + * @sw_id: bank software identification + * @cpu_id: cpu core id for SVS CPU bank use only + * @ctl0: TS-x selection + * @temp: bank temperature + * @tzone_htemp: thermal zone high temperature threshold + * @tzone_htemp_voffset: thermal zone high temperature voltage offset + * @tzone_ltemp: thermal zone low temperature threshold + * @tzone_ltemp_voffset: thermal zone low temperature voltage offset + * @bts: svs efuse data + * @mts: svs efuse data + * @bdes: svs efuse data + * @mdes: svs efuse data + * @mtdes: svs efuse data + * @dcbdet: svs efuse data + * @dcmdet: svs efuse data + * @turn_pt: 2-line turn point tells which opp_volt calculated by high/low= bank + * @type: bank type to represent it is 2-line (high/low) bank or 1-line ba= nk + * + * Svs bank will generate suitalbe voltages by below general math equation + * and provide these voltages to opp voltage table. + * + * opp_volt[i] =3D (volt[i] * volt_step) + volt_base; + */ +struct svs_bank { + struct device *dev; + struct device *opp_dev; + struct completion init_completion; + struct regulator *buck; + struct thermal_zone_device *tzd; + struct mutex lock; /* lock to protect voltage update process */ + void (*set_freq_pct)(struct svs_platform *svsp); + void (*get_volts)(struct svs_platform *svsp); + char *name; + char *buck_name; + char *tzone_name; + enum svsb_phase phase; + s32 volt_od; + u32 reg_data[SVSB_PHASE_MAX][SVS_REG_MAX]; + u32 pm_runtime_enabled_count; + u32 mode_support; + u32 freq_base; + u32 turn_freq_base; + u32 vboot; + u32 opp_dfreq[MAX_OPP_ENTRIES]; + u32 opp_dvolt[MAX_OPP_ENTRIES]; + u32 freq_pct[MAX_OPP_ENTRIES]; + u32 volt[MAX_OPP_ENTRIES]; + u32 volt_step; + u32 volt_base; + u32 volt_flags; + u32 vmax; + u32 vmin; + u32 age_config; + u32 age_voffset_in; + u32 dc_config; + u32 dc_voffset_in; + u32 dvt_fixed; + u32 vco; + u32 chk_shift; + u32 core_sel; + u32 opp_count; + u32 int_st; + u32 sw_id; + u32 cpu_id; + u32 ctl0; + u32 temp; + u32 tzone_htemp; + u32 tzone_htemp_voffset; + u32 tzone_ltemp; + u32 tzone_ltemp_voffset; + u32 bts; + u32 mts; + u32 bdes; + u32 mdes; + u32 mtdes; + u32 dcbdet; + u32 dcmdet; + u32 turn_pt; + u32 type; +}; + +struct device *svs_add_device_link(struct svs_platform *svsp, + const char *node_name); +struct device *svs_get_subsys_device(struct svs_platform *svsp, + const char *node_name); +int svs_thermal_efuse_get_data(struct svs_platform *svsp); + +void svs_get_bank_volts_v2(struct svs_platform *svsp); +void svs_set_bank_freq_pct_v2(struct svs_platform *svsp); + +void svs_get_bank_volts_v3(struct svs_platform *svsp); +void svs_set_bank_freq_pct_v3(struct svs_platform *svsp); +#endif --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 B6113C32771 for ; Wed, 28 Sep 2022 15:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234272AbiI1P4a (ORCPT ); Wed, 28 Sep 2022 11:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234397AbiI1Pzv (ORCPT ); Wed, 28 Sep 2022 11:55:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC6C8E982 for ; Wed, 28 Sep 2022 08:55:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5DDAF61F0D for ; Wed, 28 Sep 2022 15:55:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D925FC43140; Wed, 28 Sep 2022 15:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380542; bh=jBV3cFo8/FqKuJAoNK5rBtzqmrn/4Re6jDWfLVj3+OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEawa4AQdnoU3BNbSaCGJn37XgKksYRDbvOwRr22KLso/LgyBCsWiYjYsuW/C+0j+ XY9zxznPrZr8l38+KUEPsj0bN2biVPvrDu91/5mDIEO2XNNKlCSoP3bSW9MJj1wjVb btUeq7pIDW7L2Asm0lDaa+ri5xep9cwueqb9AVk+Sxilt48XzmDbmN5aQBHCeRNKiC G+3KPjA+8H3Y8OUx+lKKEqPSgwJc+vBo5Ft/t7Ngh21nJG/oMxtdl5ktxi3Vib7A1N HFMyrjez+XDLKJGEHnRrdd/rxpJtKf1cbTt0BEFjIclhEdb8DFb5o/QKGJ1aSoDr7l wRhd4+xh54gMw== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 6/8] soc: mtk-svs: mt8183: Move thermal parsing in new function Date: Wed, 28 Sep 2022 17:55:17 +0200 Message-Id: <20220928155519.31977-7-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger We jumpt to lable remove_mt8183_svsb_mon_mode from different error path in the code. Move the thermal parsing in a new function will allow us to refactor the code in a subsequent patch. No behavioural changes from this commit. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs-mt8183.c | 183 +++++++++++++------------- 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs-mt8183.c b/drivers/soc/mediatek/m= tk-svs-mt8183.c index a97fcae59dd7..4b538cdefc86 100644 --- a/drivers/soc/mediatek/mtk-svs-mt8183.c +++ b/drivers/soc/mediatek/mtk-svs-mt8183.c @@ -2,94 +2,14 @@ =20 #include "mtk-svs.h" =20 -bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) +static int svs_mt8183_efuse_thermal_parsing(struct svs_platform *svsp) { struct svs_bank *svsb; int format[6], x_roomt[6], o_vtsmcu[5], o_vtsabb, tb_roomt =3D 0; int adc_ge_t, adc_oe_t, ge, oe, gain, degc_cali, adc_cali_en_t; int o_slope, o_slope_sign, ts_id; - u32 idx, i, ft_pgm, mts, temp0, temp1, temp2; - int ret; - - for (i =3D 0; i < svsp->efuse_max; i++) - if (svsp->efuse[i]) - dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", - i, svsp->efuse[i]); - - if (!svsp->efuse[2]) { - dev_notice(svsp->dev, "svs_efuse[2] =3D 0x0?\n"); - return false; - } - - /* Svs efuse parsing */ - ft_pgm =3D (svsp->efuse[0] >> 4) & GENMASK(3, 0); - - for (idx =3D 0; idx < svsp->bank_max; idx++) { - svsb =3D &svsp->banks[idx]; - - if (ft_pgm <=3D 1) - svsb->volt_flags |=3D SVSB_INIT01_VOLT_IGNORE; + u32 idx, i, mts, temp0, temp1, temp2; =20 - switch (svsb->sw_id) { - case SVSB_CPU_LITTLE: - svsb->bdes =3D svsp->efuse[16] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[16] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[16] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[16] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 10; - else - svsb->volt_od +=3D 2; - break; - case SVSB_CPU_BIG: - svsb->bdes =3D svsp->efuse[18] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[18] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[18] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[18] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D svsp->efuse[17] & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 15; - else - svsb->volt_od +=3D 12; - break; - case SVSB_CCI: - svsb->bdes =3D svsp->efuse[4] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[4] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[4] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[4] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D (svsp->efuse[5] >> 16) & GENMASK(7, 0); - - if (ft_pgm <=3D 3) - svsb->volt_od +=3D 10; - else - svsb->volt_od +=3D 2; - break; - case SVSB_GPU: - svsb->bdes =3D svsp->efuse[6] & GENMASK(7, 0); - svsb->mdes =3D (svsp->efuse[6] >> 8) & GENMASK(7, 0); - svsb->dcbdet =3D (svsp->efuse[6] >> 16) & GENMASK(7, 0); - svsb->dcmdet =3D (svsp->efuse[6] >> 24) & GENMASK(7, 0); - svsb->mtdes =3D svsp->efuse[5] & GENMASK(7, 0); - - if (ft_pgm >=3D 2) { - svsb->freq_base =3D 800000000; /* 800MHz */ - svsb->dvt_fixed =3D 2; - } - break; - default: - dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); - return false; - } - } - - ret =3D svs_thermal_efuse_get_data(svsp); - if (ret) - return false; - - /* Thermal efuse parsing */ adc_ge_t =3D (svsp->tefuse[1] >> 22) & GENMASK(9, 0); adc_oe_t =3D (svsp->tefuse[1] >> 12) & GENMASK(9, 0); =20 @@ -121,11 +41,11 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *svs= p) o_vtsabb < -8 || o_vtsabb > 484 || degc_cali < 1 || degc_cali > 63) { dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; + return -1; } } else { dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; + return -1; } =20 ge =3D ((adc_ge_t - 512) * 10000) / 4096; @@ -168,7 +88,7 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) break; default: dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); - goto remove_mt8183_svsb_mon_mode; + return -1; } =20 temp0 =3D (degc_cali * 10 / 2); @@ -183,12 +103,99 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *sv= sp) svsb->bts =3D (temp0 + temp2 - 250) * 4 / 10; } =20 - return true; + return 0; +} + +bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) +{ + struct svs_bank *svsb; + u32 idx, i, ft_pgm; + int ret; + + for (i =3D 0; i < svsp->efuse_max; i++) + if (svsp->efuse[i]) + dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", + i, svsp->efuse[i]); + + if (!svsp->efuse[2]) { + dev_notice(svsp->dev, "svs_efuse[2] =3D 0x0?\n"); + return false; + } + + /* Svs efuse parsing */ + ft_pgm =3D (svsp->efuse[0] >> 4) & GENMASK(3, 0); =20 -remove_mt8183_svsb_mon_mode: for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; - svsb->mode_support &=3D ~SVSB_MODE_MON; + + if (ft_pgm <=3D 1) + svsb->volt_flags |=3D SVSB_INIT01_VOLT_IGNORE; + + switch (svsb->sw_id) { + case SVSB_CPU_LITTLE: + svsb->bdes =3D svsp->efuse[16] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[16] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[16] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[16] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 10; + else + svsb->volt_od +=3D 2; + break; + case SVSB_CPU_BIG: + svsb->bdes =3D svsp->efuse[18] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[18] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[18] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[18] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D svsp->efuse[17] & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 15; + else + svsb->volt_od +=3D 12; + break; + case SVSB_CCI: + svsb->bdes =3D svsp->efuse[4] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[4] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[4] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[4] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D (svsp->efuse[5] >> 16) & GENMASK(7, 0); + + if (ft_pgm <=3D 3) + svsb->volt_od +=3D 10; + else + svsb->volt_od +=3D 2; + break; + case SVSB_GPU: + svsb->bdes =3D svsp->efuse[6] & GENMASK(7, 0); + svsb->mdes =3D (svsp->efuse[6] >> 8) & GENMASK(7, 0); + svsb->dcbdet =3D (svsp->efuse[6] >> 16) & GENMASK(7, 0); + svsb->dcmdet =3D (svsp->efuse[6] >> 24) & GENMASK(7, 0); + svsb->mtdes =3D svsp->efuse[5] & GENMASK(7, 0); + + if (ft_pgm >=3D 2) { + svsb->freq_base =3D 800000000; /* 800MHz */ + svsb->dvt_fixed =3D 2; + } + break; + default: + dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); + return false; + } + } + + ret =3D svs_thermal_efuse_get_data(svsp); + if (ret) + return false; + + ret =3D svs_mt8183_efuse_thermal_parsing(svsp); + if (ret) { + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + svsb->mode_support &=3D ~SVSB_MODE_MON; + } } =20 return true; --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 07AD1C32771 for ; Wed, 28 Sep 2022 15:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234503AbiI1P4f (ORCPT ); Wed, 28 Sep 2022 11:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233840AbiI1P4H (ORCPT ); Wed, 28 Sep 2022 11:56:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89041DE0C9 for ; Wed, 28 Sep 2022 08:55:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C68A1B82114 for ; Wed, 28 Sep 2022 15:55:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DCAAC433D6; Wed, 28 Sep 2022 15:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380545; bh=rTxVsRSoNtBqk4DuZJ+tmhjE78RLJzMfTSqldv1r6/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ox+7ChwI3mXjsFhmBD4fmyZMHwVY2fWySreTHkOuzsPQrdskuITrhR1xioh0qD7a2 BpwKinWMeUQh2AoaNcRUySSMp2p3qUd6aigcV+ss6ECJ4k4iCGq3z0nkBnzV5B//KG 6SU9d6SwxAuPo5bZDQFlvohqMCBL/qNDa4TMSGKUnwfnSInwdtOmhENDuBFqHqscIl QbeS6uLxFEIN9wVnBfr0CcP8RwzW56wB1+nY928+YImUYpGG8WouAtjyTErEdSgBTK VfRetoKpTP0RssLig6b2zuHTxbL180tHKJ9YgYj8cAcBl5uGhmJE7pqHxWIKD3K1K3 Y6OQZTEYgog1w== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 7/8] soc: mtk-svs: mt8183: refactor o_slope calculation Date: Wed, 28 Sep 2022 17:55:18 +0200 Message-Id: <20220928155519.31977-8-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger The o_slope value is dependent of the o_slope_sign, refactor code to get rid of unnecessary if constructs. Signed-off-by: Matthias Brugger --- drivers/soc/mediatek/mtk-svs-mt8183.c | 54 ++++++++++++--------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs-mt8183.c b/drivers/soc/mediatek/m= tk-svs-mt8183.c index 4b538cdefc86..7f7d5cd6be35 100644 --- a/drivers/soc/mediatek/mtk-svs-mt8183.c +++ b/drivers/soc/mediatek/mtk-svs-mt8183.c @@ -25,26 +25,28 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_= platform *svsp) o_slope_sign =3D (svsp->tefuse[0] >> 7) & BIT(0); =20 ts_id =3D (svsp->tefuse[1] >> 9) & BIT(0); - o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); - - if (adc_cali_en_t =3D=3D 1) { - if (!ts_id) - o_slope =3D 0; - - if (adc_ge_t < 265 || adc_ge_t > 758 || - adc_oe_t < 265 || adc_oe_t > 758 || - o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || - o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || - o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || - o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || - o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || - o_vtsabb < -8 || o_vtsabb > 484 || - degc_cali < 1 || degc_cali > 63) { - dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); - return -1; - } - } else { - dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); + + if (!ts_id) + o_slope =3D 1534; + else { + o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); + if (!o_slope_sign) + o_slope =3D 1534 + o_slope * 10; + else + o_slope =3D 1534 - o_slope * 10; + } + + if (adc_cali_en_t =3D=3D 0 || + adc_ge_t < 265 || adc_ge_t > 758 || + adc_oe_t < 265 || adc_oe_t > 758 || + o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || + o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || + o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || + o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || + o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || + o_vtsabb < -8 || o_vtsabb > 484 || + degc_cali < 1 || degc_cali > 63) { + dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); return -1; } =20 @@ -63,11 +65,7 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_p= latform *svsp) x_roomt[i] =3D (((format[i] * 10000) / 4096) * 10000) / gain; =20 temp0 =3D (10000 * 100000 / gain) * 15 / 18; - - if (!o_slope_sign) - mts =3D (temp0 * 10) / (1534 + o_slope * 10); - else - mts =3D (temp0 * 10) / (1534 - o_slope * 10); + mts =3D (temp0 * 10) / o_slope; =20 for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; @@ -94,11 +92,7 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_p= latform *svsp) temp0 =3D (degc_cali * 10 / 2); temp1 =3D ((10000 * 100000 / 4096 / gain) * oe + tb_roomt * 10) * 15 / 18; - - if (!o_slope_sign) - temp2 =3D temp1 * 100 / (1534 + o_slope * 10); - else - temp2 =3D temp1 * 100 / (1534 - o_slope * 10); + temp2 =3D temp1 * 100 / o_slope; =20 svsb->bts =3D (temp0 + temp2 - 250) * 4 / 10; } --=20 2.37.3 From nobody Mon Apr 29 05:05:39 2024 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 EDBE9C54EE9 for ; Wed, 28 Sep 2022 15:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234444AbiI1P44 (ORCPT ); Wed, 28 Sep 2022 11:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234429AbiI1P4H (ORCPT ); Wed, 28 Sep 2022 11:56:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F6DDED51 for ; Wed, 28 Sep 2022 08:55:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D43DFB82107 for ; Wed, 28 Sep 2022 15:55:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A3AC433C1; Wed, 28 Sep 2022 15:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664380547; bh=AsSGtp1hkzL8NIS4nEw2a0/D7oTq6NL/9e+KpV8EKDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snJXPE22Q+fZfmdwH4NHVDl7njmUHnNXM2B7nQfKj+VFJqDIAtYYbJb23aY+eiKdN iIFRY0YgU5Ew78HtggwgHTTleUlLTRtbJNU7rBvgNciioeGXQRfPlR0k33nlwJjlUE GdNQGbDbFNKZjswPp26HRuyVcV+Rhhvhq2FZ3y9D+chLbtTu8278VzAgE2qNMOI2p3 Ewznlh4iFH1dGWHYXtLKng+3d2deAWB/14nFDC/xB5G6gk++bwFCqbv1ZFZrjcRN2r yUaAcMYBshpUrkwaF4iM07/ifllXNeb+OBst5cBwtNdWgK0ZO+6f6hTD6dk6zMyMWV Ko4p3fBaC92bw== From: matthias.bgg@kernel.org To: roger.lu@mediatek.com, jia-wei.chang@mediatek.com Cc: nfraprado@collabora.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com, Matthias Brugger Subject: [PATCH 8/8] soc: mtk-svs: mt8192: fix bank data Date: Wed, 28 Sep 2022 17:55:19 +0200 Message-Id: <20220928155519.31977-9-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928155519.31977-1-matthias.bgg@kernel.org> References: <20220928155519.31977-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Matthias Brugger Values vmax and dvt_fixed are not changed at runtime, set them as needed in the svs_banks struct. Signed-off-by: Matthias Brugger --- drivers/soc/mediatek/mt8192-svs.h | 4 ++-- drivers/soc/mediatek/mtk-svs-mt8192.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mt8192-svs.h b/drivers/soc/mediatek/mt819= 2-svs.h index 6571ebcb2c0f..bf8c6030428f 100644 --- a/drivers/soc/mediatek/mt8192-svs.h +++ b/drivers/soc/mediatek/mt8192-svs.h @@ -16,7 +16,7 @@ static struct svs_bank svs_mt8192_banks[] =3D { .turn_freq_base =3D 688000000, .volt_step =3D 6250, .volt_base =3D 400000, - .vmax =3D 0x60, + .vmax =3D 0x61, .vmin =3D 0x1a, .age_config =3D 0x555555, .dc_config =3D 0x1, @@ -41,7 +41,7 @@ static struct svs_bank svs_mt8192_banks[] =3D { .turn_freq_base =3D 688000000, .volt_step =3D 6250, .volt_base =3D 400000, - .vmax =3D 0x60, + .vmax =3D 0x66, .vmin =3D 0x1a, .age_config =3D 0x555555, .dc_config =3D 0x1, diff --git a/drivers/soc/mediatek/mtk-svs-mt8192.c b/drivers/soc/mediatek/m= tk-svs-mt8192.c index 838a94834741..183acf2829f0 100644 --- a/drivers/soc/mediatek/mtk-svs-mt8192.c +++ b/drivers/soc/mediatek/mtk-svs-mt8192.c @@ -40,8 +40,6 @@ bool svs_mt8192_efuse_parsing(struct svs_platform *svsp) svsb->dcbdet =3D (svsp->efuse[17] >> 16) & GENMASK(7, 0); svsb->dcmdet =3D (svsp->efuse[17] >> 24) & GENMASK(7, 0); } - - svsb->vmax +=3D svsb->dvt_fixed; } =20 ret =3D svs_thermal_efuse_get_data(svsp); --=20 2.37.3