From patchwork Thu Feb 22 03:02:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566679 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D02AC54788 for ; Thu, 22 Feb 2024 03:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XwTg+ToR6PUHnMJJJceBWJ7UiiKeEvk+3zfkOE1eYCw=; b=OuHSJBggqWwi8h LILc66ivz2AXZraLB0zcYcJoUeDADupopHpiXuu1FGjPyu4yRN4RnLLOYvYEOBhySEwFsOby9mvbO sjP7ibmUgOGR/SQWBbgk6M3re1AfFWwRbCpBkca3rIIM45dUGoDbECGQtB4sxzITHBW6zKu0aYMJF SsdlRxwchlHZJortSX7qOuRHlKulEjObeDJgGUtfXxqUzQ/5aVYBevthEBew6ne8qRlcJ/2R/fJ0r mZx8jj6H8yO37zFoy6JxO4IYrl+sXODHhFqOuyp2EQB6DdRC/7snwpXu5WiPb/JwKCiHW6roX6deG vBJx34/teuJG4f6sr2Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMI-00000003IlA-06dk; Thu, 22 Feb 2024 03:02:50 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM6-00000003IdR-1fq1 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:40 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-59a802ab9fdso1482981eaf.1 for ; Wed, 21 Feb 2024 19:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570957; x=1709175757; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tXl7epSj4Hm//gRuC/pavIVEpVVJtfwOYFt5D7t6v7c=; b=nR21JF6jm4BvEr4DFVKj6EZPsv3QjbunVgV917UeifaH5tcwWz1uWzLk8kP8J2ZyJQ XA7sh5/WVA95Tz7Ema3ANXzuMUhduWFLRC3n/JW0r3Giz2QFBdoGl41D9gHG4wKWvd2T f4M05MPnZiCAKR9O0qATRMHvlOMsD0SJZibxcZ9FZdBPb/HGH3gOQ0OgRdYqNoHXszI/ T58LHMo1y9wrY0Pw7zND8Uj0/3CZJfaetWweG/lwnpyxkbG1uNaoYsUFM+3RFnYQn6oT nNHsQ5yiUYPFkbTrwjQTRhpZi5TL9o+xOiQLsws0SQ8RpaPE++PAIhZkxTtmxtVspTZG RzQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570957; x=1709175757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tXl7epSj4Hm//gRuC/pavIVEpVVJtfwOYFt5D7t6v7c=; b=bC9RhRyn5xpqieNC3m2UVrzkLL60OZ9RKEO/x5b8c0pV0bQhbFJMPECOEf7s4wmZJ6 cAWVUQAR9Io+Wvf2LophZ1KsJNmFi6BnnZH9w+ctSQzhn6qowkd12o0hJcHbBBnIveib gJ89xs+MjuB6SUSQ37lOLroU3mTG3ApotdJMSHdT7WQ6d37PWsBNAsnc575uiqZJePWB FhlDPWANIFeIhbwRLp2ZdspFy20sQt0xnKwXtUlEQU0KW3RlMb9b08Jm1SHY9FWuseb5 EkSdPeZVG+OZIgj/I8zo1V1NvkUV/p+xyuaWQgwoFO+SnEQ3h6CrFaUXGbBLcMAssSEn LCuw== X-Forwarded-Encrypted: i=1; AJvYcCUws+AI64XZLhehVINcWvMeZG+MFavTmxM5RIXA0XdEX6n7+KLesGifeRzi4LcpBCA1KPyKSX4kpt7XPavVr96+a0NugM3qunHdA4caeUj914EscFE= X-Gm-Message-State: AOJu0YykoY7C/4j5vrpFHAPUJpIjnOmS9PmrlMAI6dRZPgHwSkmsbRco zbfELRmWIekbYAT2PVXxUZpVGIgPnEKajymNPqIeXanTzfCYJ3P7lWFbfBiJc5s= X-Google-Smtp-Source: AGHT+IFor9F+Hst3Q1Zd9o6WhSFN2bhosbD8FvCV9jhtbwUPENaicgSM1GOT6uXqgmRUV2DQ6L/2Aw== X-Received: by 2002:a4a:ea24:0:b0:5a0:e93:8f7 with SMTP id y4-20020a4aea24000000b005a00e9308f7mr3438031ood.8.1708570957001; Wed, 21 Feb 2024 19:02:37 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id z6-20020a9d7a46000000b006e43f8eac57sm1793089otm.50.2024.02.21.19.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:36 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/15] dt-bindings: clock: exynos850: Add CMU_CPUCLK0 and CMU_CPUCL1 Date: Wed, 21 Feb 2024 21:02:21 -0600 Message-Id: <20240222030235.27815-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190238_493549_C4D1B27B X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Document CPU clock management unit compatibles and add corresponding clock indices. Exynos850 has two CPU clusters (CL0 and CL1), each containing 4 Cortex-A55 cores. CPU PLLs are generating main CPU clocks for each cluster, and there are alternate ("switch") clocks that can be used temporarily while re-configuring the PLL for the new rate. ACLK, ATCLK, PCLKDBG and PERIPHCLK clocks are driving corresponding buses. CLK_CLUSTERx_SCLK are actual leaf CPU clocks and should be used to change CPU rates. Also some CoreSight clocks can be derived from DBG_USER (debug clock). Signed-off-by: Sam Protsenko --- Changes in v2: - none .../clock/samsung,exynos850-clock.yaml | 42 +++++++++++++++ include/dt-bindings/clock/exynos850.h | 54 +++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml b/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml index c752c8985a53..cdc5ded59fe5 100644 --- a/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml +++ b/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml @@ -36,6 +36,8 @@ properties: - samsung,exynos850-cmu-aud - samsung,exynos850-cmu-cmgp - samsung,exynos850-cmu-core + - samsung,exynos850-cmu-cpucl0 + - samsung,exynos850-cmu-cpucl1 - samsung,exynos850-cmu-dpu - samsung,exynos850-cmu-g3d - samsung,exynos850-cmu-hsi @@ -152,6 +154,46 @@ allOf: - const: dout_core_mmc_embd - const: dout_core_sss + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-cpucl0 + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: CPUCL0 switch clock (from CMU_TOP) + - description: CPUCL0 debug clock (from CMU_TOP) + + clock-names: + items: + - const: oscclk + - const: dout_cpucl0_switch + - const: dout_cpucl0_dbg + + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-cpucl1 + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: CPUCL1 switch clock (from CMU_TOP) + - description: CPUCL1 debug clock (from CMU_TOP) + + clock-names: + items: + - const: oscclk + - const: dout_cpucl1_switch + - const: dout_cpucl1_dbg + - if: properties: compatible: diff --git a/include/dt-bindings/clock/exynos850.h b/include/dt-bindings/clock/exynos850.h index bc15108aa3c2..7666241520f8 100644 --- a/include/dt-bindings/clock/exynos850.h +++ b/include/dt-bindings/clock/exynos850.h @@ -88,6 +88,18 @@ #define CLK_MOUT_G3D_SWITCH 76 #define CLK_GOUT_G3D_SWITCH 77 #define CLK_DOUT_G3D_SWITCH 78 +#define CLK_MOUT_CPUCL0_DBG 79 +#define CLK_MOUT_CPUCL0_SWITCH 80 +#define CLK_GOUT_CPUCL0_DBG 81 +#define CLK_GOUT_CPUCL0_SWITCH 82 +#define CLK_DOUT_CPUCL0_DBG 83 +#define CLK_DOUT_CPUCL0_SWITCH 84 +#define CLK_MOUT_CPUCL1_DBG 85 +#define CLK_MOUT_CPUCL1_SWITCH 86 +#define CLK_GOUT_CPUCL1_DBG 87 +#define CLK_GOUT_CPUCL1_SWITCH 88 +#define CLK_DOUT_CPUCL1_DBG 89 +#define CLK_DOUT_CPUCL1_SWITCH 90 /* CMU_APM */ #define CLK_RCO_I3C_PMIC 1 @@ -195,6 +207,48 @@ #define CLK_GOUT_CMGP_USI1_PCLK 14 #define CLK_GOUT_SYSREG_CMGP_PCLK 15 +/* CMU_CPUCL0 */ +#define CLK_FOUT_CPUCL0_PLL 1 +#define CLK_MOUT_PLL_CPUCL0 2 +#define CLK_MOUT_CPUCL0_SWITCH_USER 3 +#define CLK_MOUT_CPUCL0_DBG_USER 4 +#define CLK_MOUT_CPUCL0_PLL 5 +#define CLK_DOUT_CPUCL0_CPU 6 +#define CLK_DOUT_CPUCL0_CMUREF 7 +#define CLK_DOUT_CPUCL0_PCLK 8 +#define CLK_DOUT_CLUSTER0_ACLK 9 +#define CLK_DOUT_CLUSTER0_ATCLK 10 +#define CLK_DOUT_CLUSTER0_PCLKDBG 11 +#define CLK_DOUT_CLUSTER0_PERIPHCLK 12 +#define CLK_GOUT_CLUSTER0_ATCLK 13 +#define CLK_GOUT_CLUSTER0_PCLK 14 +#define CLK_GOUT_CLUSTER0_PERIPHCLK 15 +#define CLK_GOUT_CLUSTER0_SCLK 16 +#define CLK_GOUT_CPUCL0_CMU_CPUCL0_PCLK 17 +#define CLK_GOUT_CLUSTER0_CPU 18 +#define CLK_CLUSTER0_SCLK 19 + +/* CMU_CPUCL1 */ +#define CLK_FOUT_CPUCL1_PLL 1 +#define CLK_MOUT_PLL_CPUCL1 2 +#define CLK_MOUT_CPUCL1_SWITCH_USER 3 +#define CLK_MOUT_CPUCL1_DBG_USER 4 +#define CLK_MOUT_CPUCL1_PLL 5 +#define CLK_DOUT_CPUCL1_CPU 6 +#define CLK_DOUT_CPUCL1_CMUREF 7 +#define CLK_DOUT_CPUCL1_PCLK 8 +#define CLK_DOUT_CLUSTER1_ACLK 9 +#define CLK_DOUT_CLUSTER1_ATCLK 10 +#define CLK_DOUT_CLUSTER1_PCLKDBG 11 +#define CLK_DOUT_CLUSTER1_PERIPHCLK 12 +#define CLK_GOUT_CLUSTER1_ATCLK 13 +#define CLK_GOUT_CLUSTER1_PCLK 14 +#define CLK_GOUT_CLUSTER1_PERIPHCLK 15 +#define CLK_GOUT_CLUSTER1_SCLK 16 +#define CLK_GOUT_CPUCL1_CMU_CPUCL1_PCLK 17 +#define CLK_GOUT_CLUSTER1_CPU 18 +#define CLK_CLUSTER1_SCLK 19 + /* CMU_G3D */ #define CLK_FOUT_G3D_PLL 1 #define CLK_MOUT_G3D_PLL 2 From patchwork Thu Feb 22 03:02:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566680 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08CD1C48BF6 for ; Thu, 22 Feb 2024 03:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ANd7UKSG5zlSsBPhXRWlkrYX6v9fX3rX3kHQtRDfMgY=; b=HEL+3giIgIjPdY caTFdSXtl8JL70spCG+PFzgKjBtYX8p5ilOBOCQlpVMXVkyFFDbZMjH4rW4J1JjFPpLPxYbIBAgZ6 1s0jdYx4G01x31u6M9a6Zixwj+ddDSnLC9w+FK0jZWaK+y+q3eR2R6Lu5UXByYACogCeG1ViNhSD8 zsTtd6EA4gz0vVA7crfOqGxLROgxIQ6QciINSHlQt6iCJPzG2SkGMLvi4TsdptfMLIWuP8RB2Ip7p nBed7SPkN87IDbP+OWqs36yu+agS2Wcl1ikAuruol7SJJKn0DNct8kvSob7dXaqsc64dBtFc2AUMZ prYaqo9cPjXnOMyx69tQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMJ-00000003Ils-0MJG; Thu, 22 Feb 2024 03:02:51 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM7-00000003Idh-0ul3 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:40 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3bbb4806f67so4936571b6e.3 for ; Wed, 21 Feb 2024 19:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570958; x=1709175758; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h1pfBB+u8QXOb34PTpTkMpZc8xqCfgfeq0PGtHjjjvY=; b=rIaHW9uuPgqXOJvfZXupXIefuPHox6/lBg2oVXyr3tGSI1KzvBfrQX4DWIWI9OFJHZ IiSB7gr7ZETxvRmIQGzo22BmEdnHc21hK5zDXWgw9FXYVXmStWe86+zCDk+QjpJg7t5n 6yhQKls6wASvllp6CInS7SONookAbg7w9U9uRaGMN2F1zkyAs30oIrIj07+obRHQ1CQV +dNNdz5THyXzRBfxvceHTfrXRhvLhpFA0gXD/MsqbSV1q66rojnpqEy1FeK4bfEZmz3Y rhz06+ANONfbmDM71kK2bONxnP6S1Gfusqly7NsZECePWR8vBEvWO6QERhEpYYfVMQZn Eh7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570958; x=1709175758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h1pfBB+u8QXOb34PTpTkMpZc8xqCfgfeq0PGtHjjjvY=; b=XWG1dgXP4vGFLP/PdE7GqlGjoXO8tC1XIaeldd5BMzONV0fFXMFJJjQZo1C5o9vA23 +NOV2uhjPi01JnHcNPsSh/y/MWHCtGazupwOPQyFSVRv8jsNoHDtR68ZD+skUKHqXKKW SfFxbsmiZu64Ah6kP26EAFFzdErQ+E79llEhIzXR5dZTfMKkBAEAZK0wY3fuof0nLJBP lYeyRZpUJCWW4CEc/3PE7/qi2zlKObbkz6RtKFrLLbLLvwtSjNmFWbhHeydoEySobBkq Mhb1zg6TmfS/nPig90RMWnBjs5dRERhLg4gCXljEKMLoEogR/K6DYgv81nEkhWh0BhCt 8tGg== X-Forwarded-Encrypted: i=1; AJvYcCXKlaBrayHBNIprcXuC2VnlbEto/xKXvuHaEVau26r4KRNln8st2bipGFCJDXeMDsqVgQQxwDtvlsaVoenDD4o9P7msHITYrWqPmkDv5Y7Wl2PbmVI= X-Gm-Message-State: AOJu0YzQclrRAOpGxi9kF7hyv095Zaa9GsCJ63J3sbjlKrq4SX+eoags FVJjhlXbRdTQdIWc/Hp+cgH4UTNdNvI6PzTkfUX57jXG9ZTfNLXIb3g3JZNl/Ro= X-Google-Smtp-Source: AGHT+IFs7TI8/WNQwjC08imFX21rZ3Fe6t1Il+3aP48yWhxzOWcUVNG9WmsJflmZmKAh5mbvd2uhfQ== X-Received: by 2002:a05:6808:138f:b0:3c1:5515:2599 with SMTP id c15-20020a056808138f00b003c155152599mr14479119oiw.39.1708570957820; Wed, 21 Feb 2024 19:02:37 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id ct24-20020a056808361800b003c045697003sm1810987oib.41.2024.02.21.19.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:37 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/15] clk: samsung: Improve clk-cpu.c style Date: Wed, 21 Feb 2024 21:02:22 -0600 Message-Id: <20240222030235.27815-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190239_287771_AA8D36B6 X-CRM114-Status: GOOD ( 24.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org clk-cpu.c has numerous style issues reported by checkpatch and easily identified otherwise. Give it some love and fix those warnings where it makes sense. Also make stabilization time a named constant to get rid of the magic number in clk-cpu.c. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 65 ++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 3e62ade120c5..e02730776aaa 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -16,18 +16,18 @@ * of the SoC or supplied after the SoC characterization. * * The below implementation of the CPU clock allows the rate changes of the CPU - * clock and the corresponding rate changes of the auxillary clocks of the CPU + * clock and the corresponding rate changes of the auxiliary clocks of the CPU * domain. The platform clock driver provides a clock register configuration * for each configurable rate which is then used to program the clock hardware - * registers to acheive a fast co-oridinated rate change for all the CPU domain + * registers to achieve a fast coordinated rate change for all the CPU domain * clocks. * * On a rate change request for the CPU clock, the rate change is propagated - * upto the PLL supplying the clock to the CPU domain clock blocks. While the + * up to the PLL supplying the clock to the CPU domain clock blocks. While the * CPU domain PLL is reconfigured, the CPU domain clocks are driven using an * alternate clock source. If required, the alternate clock source is divided * down in order to keep the output clock rate within the previous OPP limits. -*/ + */ #include #include @@ -50,17 +50,19 @@ #define E5433_DIV_STAT_CPU0 0x500 #define E5433_DIV_STAT_CPU1 0x504 -#define E4210_DIV0_RATIO0_MASK 0x7 -#define E4210_DIV1_HPM_MASK (0x7 << 4) -#define E4210_DIV1_COPY_MASK (0x7 << 0) -#define E4210_MUX_HPM_MASK (1 << 20) +#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) +#define E4210_DIV1_HPM_MASK GENMASK(6, 4) +#define E4210_DIV1_COPY_MASK GENMASK(2, 0) +#define E4210_MUX_HPM_MASK BIT(20) #define E4210_DIV0_ATB_SHIFT 16 #define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT) +/* Divider stabilization time, msec */ +#define MAX_STAB_TIME 10 #define MAX_DIV 8 -#define DIV_MASK 7 -#define DIV_MASK_ALL 0xffffffff -#define MUX_MASK 7 +#define DIV_MASK GENMASK(2, 0) +#define DIV_MASK_ALL GENMASK(31, 0) +#define MUX_MASK GENMASK(2, 0) /* * Helper function to wait until divider(s) have stabilized after the divider @@ -68,7 +70,7 @@ */ static void wait_until_divider_stable(void __iomem *div_reg, unsigned long mask) { - unsigned long timeout = jiffies + msecs_to_jiffies(10); + unsigned long timeout = jiffies + msecs_to_jiffies(MAX_STAB_TIME); do { if (!(readl(div_reg) & mask)) @@ -86,9 +88,9 @@ static void wait_until_divider_stable(void __iomem *div_reg, unsigned long mask) * value was changed. */ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, - unsigned long mux_value) + unsigned long mux_value) { - unsigned long timeout = jiffies + msecs_to_jiffies(10); + unsigned long timeout = jiffies + msecs_to_jiffies(MAX_STAB_TIME); do { if (((readl(mux_reg) >> mux_pos) & MUX_MASK) == mux_value) @@ -101,18 +103,18 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, pr_err("%s: re-parenting mux timed-out\n", __func__); } -/* common round rate callback useable for all types of CPU clocks */ -static long exynos_cpuclk_round_rate(struct clk_hw *hw, - unsigned long drate, unsigned long *prate) +/* common round rate callback usable for all types of CPU clocks */ +static long exynos_cpuclk_round_rate(struct clk_hw *hw, unsigned long drate, + unsigned long *prate) { struct clk_hw *parent = clk_hw_get_parent(hw); *prate = clk_hw_round_rate(parent, drate); return *prate; } -/* common recalc rate callback useable for all types of CPU clocks */ +/* common recalc rate callback usable for all types of CPU clocks */ static unsigned long exynos_cpuclk_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) + unsigned long parent_rate) { /* * The CPU clock output (armclk) rate is the same as its parent @@ -135,7 +137,7 @@ static const struct clk_ops exynos_cpuclk_clk_ops = { * dividers to be programmed. */ static void exynos_set_safe_div(void __iomem *base, unsigned long div, - unsigned long mask) + unsigned long mask) { unsigned long div0; @@ -151,7 +153,6 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); - unsigned long alt_div = 0, alt_div_mask = DIV_MASK; unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -187,6 +188,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, */ if (alt_prate > ndata->old_rate || ndata->old_rate > ndata->new_rate) { unsigned long tmp_rate = min(ndata->old_rate, ndata->new_rate); + unsigned long alt_div, alt_div_mask = DIV_MASK; alt_div = DIV_ROUND_UP(alt_prate, tmp_rate) - 1; WARN_ON(alt_div >= MAX_DIV); @@ -215,7 +217,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, if (cpuclk->flags & CLK_CPU_HAS_DIV1) { writel(div1, base + E4210_DIV_CPU1); wait_until_divider_stable(base + E4210_DIV_STAT_CPU1, - DIV_MASK_ALL); + DIV_MASK_ALL); } spin_unlock_irqrestore(cpuclk->lock, flags); @@ -263,7 +265,7 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, * dividers to be programmed. */ static void exynos5433_set_safe_div(void __iomem *base, unsigned long div, - unsigned long mask) + unsigned long mask) { unsigned long div0; @@ -279,7 +281,6 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); - unsigned long alt_div = 0, alt_div_mask = DIV_MASK; unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -309,6 +310,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, */ if (alt_prate > ndata->old_rate || ndata->old_rate > ndata->new_rate) { unsigned long tmp_rate = min(ndata->old_rate, ndata->new_rate); + unsigned long alt_div, alt_div_mask = DIV_MASK; alt_div = DIV_ROUND_UP(alt_prate, tmp_rate) - 1; WARN_ON(alt_div >= MAX_DIV); @@ -358,7 +360,7 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, * notifications of the parent clock of cpuclk. */ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, - unsigned long event, void *data) + unsigned long event, void *data) { struct clk_notifier_data *ndata = data; struct exynos_cpuclk *cpuclk; @@ -381,7 +383,7 @@ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, * notifications of the parent clock of cpuclk. */ static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb, - unsigned long event, void *data) + unsigned long event, void *data) { struct clk_notifier_data *ndata = data; struct exynos_cpuclk *cpuclk; @@ -438,11 +440,10 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, else cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; - ret = clk_notifier_register(parent->clk, &cpuclk->clk_nb); if (ret) { pr_err("%s: failed to register clock notifier for %s\n", - __func__, name); + __func__, name); goto free_cpuclk; } @@ -454,7 +455,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, ret = clk_hw_register(NULL, &cpuclk->hw); if (ret) { - pr_err("%s: could not register cpuclk %s\n", __func__, name); + pr_err("%s: could not register cpuclk %s\n", __func__, name); goto free_cpuclk_data; } @@ -482,8 +483,8 @@ void __init samsung_clk_register_cpu(struct samsung_clk_provider *ctx, for (num_cfgs = 0; list->cfg[num_cfgs].prate != 0; ) num_cfgs++; - exynos_register_cpu_clock(ctx, list->id, list->name, hws[list->parent_id], - hws[list->alt_parent_id], list->offset, list->cfg, num_cfgs, - list->flags); + exynos_register_cpu_clock(ctx, list->id, list->name, + hws[list->parent_id], hws[list->alt_parent_id], + list->offset, list->cfg, num_cfgs, list->flags); } } From patchwork Thu Feb 22 03:02:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566681 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1F96C48BEB for ; Thu, 22 Feb 2024 03:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hmlzYnb9Kk5E/27DRjFESzARtQzJRsnQAVtzhUYGff0=; b=AYhQzW5sTZE65a YbngSqeLFudPZUjwNR+LHp4J9ltwDiQaWNlVp5WygnfEgwVt1kJRu3flha2Cq0vKJvNfZI847Ai9q bFMCUdjc6n+sapcbHtyV3xvxUly8Yk3wAxNatELpUlJr3yZ5O+kY7rWDw/0ArwFF/ZZVWpPrUwg1J KiZdVu5aQG/Fh8JEdVOy1UT5I8dWt0VcDYcWlIH3PtEuh7pidsAi1B8Nm7ycLA06lk6JUMC94bT9a nCVDZfKGmnGv3KHj5+qSTVfZ9rEJ13pzPfoE10TnT3WN5+4bFu9jTkAoiEndMM4v7LasPhrLT6N5l SMeN5N2i/H2O8XijEdew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMJ-00000003ImZ-44Pu; Thu, 22 Feb 2024 03:02:51 +0000 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM7-00000003IeE-3x8i for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:41 +0000 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-59fd69bab3bso1265584eaf.2 for ; Wed, 21 Feb 2024 19:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570958; x=1709175758; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zl+WacIm9QRXQC0Y5/uv+FIwM1YVxoD9Cr7x73AtUv0=; b=Br2Hv5hUE6KtKw8JQ6MUE2yEPLjJej7p+2Kx/p8ITYvE1IHgk/fnpx5sitJrtum/w+ ysax1mKvzCgyrxbvEDlrePxxTSstHE8MJAz7twcilZUz1ONwelY7Ojq5p5bqnMFrgv2y V6tkWeWWHOJ95sAcEs/m7EYi8oIFzvpxHi53vvvYZD0Y4DwOYxLHild4TXNc9vq7SWNu PUpcuLX6jlwWRixdmV2ryQ3ZcpetJMDRmT/xxeMvxJz7fDnNqR5efiNY8EjtUa+tXw2t C8ICGDErdYubSL6sQCAW+9qaqTLxBLTt3HGJu5i05KbCSEByxLe7/soo7gZYprOG1GWl 9o9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570958; x=1709175758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zl+WacIm9QRXQC0Y5/uv+FIwM1YVxoD9Cr7x73AtUv0=; b=VVvG122B2Vap0rCSz9ExhUT9vT1rV0tkX9B5aHF+6djPnC8bMlbU4WFh+je5Fro/BB FctUvpN7aHx0PwedxEBUYoKfpAka1eOo6RCghqGy//JIOAK6X62idLCYxp0XwXZ6jBs+ s/R87b7Tky5dh0yXoPQKOmpiJUZ0UM6N98yGURz+RrLSci41KpOlwq0MkExEXIRB37oO Gt2iiZsmSH5Ew9iuy+h7Z5aMc99lWfKlhC7nSmxIWNrVSh8WysOFe0r34WTDKQ04PRNb pLd4JhKjpmsmnZVMWXpDnCZEAziZuE+BmfSPjISkRhCD6vbTn2G3hWHIMoHNs09guFv2 Y2gg== X-Forwarded-Encrypted: i=1; AJvYcCUoXIyICuA6rJeSVuJxdmrrbJkvGzjFbfcw6TsULnKCPovfl5BcYvBPTkUg+rUhC2aKK2roGBwEpmxBA2ZKYhggWkPz/a529LvfOPGH27rUarMh1os= X-Gm-Message-State: AOJu0YxoIJVUnunWMuYxWo9LwY65VyObbHffHpfb6UtTo+BkDOEnSOCP Jmr99DKy8aUMqdkVPGNB0IlI1ltShf2ShK+adlp2kjoZDRB5F+arJynIARS+8tw= X-Google-Smtp-Source: AGHT+IH2HSioJXyNfPWhTv8Aki4+YIBLaNkslaAzYgx78hcG5wWTUzPaMZ6CmaxOILUiQ333qL2zzQ== X-Received: by 2002:a4a:6116:0:b0:5a0:294d:dca4 with SMTP id n22-20020a4a6116000000b005a0294ddca4mr458878ooc.8.1708570958584; Wed, 21 Feb 2024 19:02:38 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id k15-20020a056830168f00b006e12023de5fsm1900371otr.46.2024.02.21.19.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:38 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 03/15] clk: samsung: Pull struct exynos_cpuclk into clk-cpu.c Date: Wed, 21 Feb 2024 21:02:23 -0600 Message-Id: <20240222030235.27815-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190240_083507_F847368E X-CRM114-Status: GOOD ( 20.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce the scope of struct exynos_cpuclk, as it's only used in clk-cpu.c internally. All drivers using clk-pll.h already include clk.h as well, so this change doesn't break anything. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 29 +++++++++++++++++++++++++ drivers/clk/samsung/clk-cpu.h | 41 +++++------------------------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index e02730776aaa..6412fd2580e0 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -34,6 +34,8 @@ #include #include #include + +#include "clk.h" #include "clk-cpu.h" #define E4210_SRC_CPU 0x0 @@ -64,6 +66,33 @@ #define DIV_MASK_ALL GENMASK(31, 0) #define MUX_MASK GENMASK(2, 0) +/** + * struct exynos_cpuclk - information about clock supplied to a CPU core + * @hw: handle between CCF and CPU clock + * @alt_parent: alternate parent clock to use when switching the speed + * of the primary parent clock + * @ctrl_base: base address of the clock controller + * @lock: cpu clock domain register access lock + * @cfg: cpu clock rate configuration data + * @num_cfgs: number of array elements in @cfg array + * @clk_nb: clock notifier registered for changes in clock speed of the + * primary parent clock + * @flags: configuration flags for the CPU clock + * + * This structure holds information required for programming the CPU clock for + * various clock speeds. + */ +struct exynos_cpuclk { + struct clk_hw hw; + const struct clk_hw *alt_parent; + void __iomem *ctrl_base; + spinlock_t *lock; + const struct exynos_cpuclk_cfg_data *cfg; + const unsigned long num_cfgs; + struct notifier_block clk_nb; + unsigned long flags; +}; + /* * Helper function to wait until divider(s) have stabilized after the divider * value has changed. diff --git a/drivers/clk/samsung/clk-cpu.h b/drivers/clk/samsung/clk-cpu.h index 0164bd9ad021..ee57f3638fed 100644 --- a/drivers/clk/samsung/clk-cpu.h +++ b/drivers/clk/samsung/clk-cpu.h @@ -8,7 +8,12 @@ #ifndef __SAMSUNG_CLK_CPU_H #define __SAMSUNG_CLK_CPU_H -#include "clk.h" +/* The CPU clock registers have DIV1 configuration register */ +#define CLK_CPU_HAS_DIV1 BIT(0) +/* When ALT parent is active, debug clocks need safe divider values */ +#define CLK_CPU_NEEDS_DEBUG_ALT_DIV BIT(1) +/* The CPU clock registers have Exynos5433-compatible layout */ +#define CLK_CPU_HAS_E5433_REGS_LAYOUT BIT(2) /** * struct exynos_cpuclk_cfg_data - config data to setup cpu clocks @@ -28,38 +33,4 @@ struct exynos_cpuclk_cfg_data { unsigned long div1; }; -/** - * struct exynos_cpuclk - information about clock supplied to a CPU core - * @hw: handle between CCF and CPU clock - * @alt_parent: alternate parent clock to use when switching the speed - * of the primary parent clock - * @ctrl_base: base address of the clock controller - * @lock: cpu clock domain register access lock - * @cfg: cpu clock rate configuration data - * @num_cfgs: number of array elements in @cfg array - * @clk_nb: clock notifier registered for changes in clock speed of the - * primary parent clock - * @flags: configuration flags for the CPU clock - * - * This structure holds information required for programming the CPU clock for - * various clock speeds. - */ -struct exynos_cpuclk { - struct clk_hw hw; - const struct clk_hw *alt_parent; - void __iomem *ctrl_base; - spinlock_t *lock; - const struct exynos_cpuclk_cfg_data *cfg; - const unsigned long num_cfgs; - struct notifier_block clk_nb; - unsigned long flags; - -/* The CPU clock registers have DIV1 configuration register */ -#define CLK_CPU_HAS_DIV1 (1 << 0) -/* When ALT parent is active, debug clocks need safe divider values */ -#define CLK_CPU_NEEDS_DEBUG_ALT_DIV (1 << 1) -/* The CPU clock registers have Exynos5433-compatible layout */ -#define CLK_CPU_HAS_E5433_REGS_LAYOUT (1 << 2) -}; - #endif /* __SAMSUNG_CLK_CPU_H */ From patchwork Thu Feb 22 03:02:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566682 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F777C54798 for ; Thu, 22 Feb 2024 03:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EiQD1gkHhEDm3d54MnJpZCMToQDHc+t0tn8WfQyl6Cw=; b=d4tw0rlsthrq8s o7wKi8HIBHK/vZnSSDElMbsCcT73rplzbLlh4bgmHr25omMMqwzS7XyL/7ozJaxrlnjtJDYcj4YSS BD1iYqZvZA/qfgxcxE0G88iQjO3w/xd7Tqhm2vUHexW9XHFXCAJQS05H2wlN/Ag7h/IEP9vCvPm9q MsdiG0gPjvATtLjEPFTrTMusnxVB+T7vjz3GC5VzFqquKblNBbyU0IBaNC9tZNoHiM0z3PZAZDuQK oDlp4VQkNSzX2lBjyJCAC1WEASfivSeTpa2l3c6vOPxd45lTJl2Teele7JRXtDZT1Uib9Ru/FSca6 vFUPVExRvENXhX4FZ+gA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMK-00000003In9-3XnR; Thu, 22 Feb 2024 03:02:52 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM8-00000003Ieh-3qed for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:42 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5a0073ae310so1096143eaf.0 for ; Wed, 21 Feb 2024 19:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570959; x=1709175759; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ID9ZSTbHJR/LMatneT/X93cat75UpJiqh+CbEK1RNJ4=; b=UfBT7rD5g84rIbdjCqlVg3VniRLUjOBLfDxkx4TYwhWV/RJhocr1iy8IlHMftR2U3I p2Sf5zmA70BCYwFhJlvYL2n0b/R/XW8KuYbGz5dssaZX1vwie16Sz6InTozhdkOlemn2 mj2EOgnNwoMVPcPZl9yR63+kvE9e8bpZe7kCjSVKyfAgXJGrodRXN6Zm3zAd3Zy6s+Zk HXTvnsCS/42eJrFzWobuUlMzhfba399HgO87onQXYbUHOgxeLG2JWP/E0Ud4nJIFu1N8 DEuPO5latxpbbSS9Ts7pfM2saqahTSYjtIPjbogRRgGxtGqltyzK4+Akudl5xWeb4n/Z VW8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570959; x=1709175759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ID9ZSTbHJR/LMatneT/X93cat75UpJiqh+CbEK1RNJ4=; b=Rrz1ri9pb179ghkbPxiYdWE9uEq6M/xuHRD6FS31cUb+sVbHDD56tNdCRSKizpxMHK u9t/AEzJdlO3gowfXnBnwaww9XdIqMO5ioDfBJnakP/yb/yME+Ek2bg7p/fgJ2G6Tu71 V+NPPZQ/yc/cFhxmkXCSmGoosil91XdZAS5mCwSnQTnXdvIt2r+tfJ0gnqwTGdjWDKFc nTCgm56KQM2wKuv6y3cLJem5OMCUfgGtcYs93rLuLkYYWatbnTKl+Lmzn4DPLcF66EsU mYGcKiehcEUGcRnBDAu5iCpiGNID0NhpfSDoQIBXhfEO557lbC+CQaOdYOrs1WCReknT cpyQ== X-Forwarded-Encrypted: i=1; AJvYcCX/fTOzVLeC36VUbDc9lv7XYBIzYdjGq+4eLz6moVa+ADeOKEGcuhGLGShjw1zjJcJ3+Z6sTjSixxJMxXojhNXEBh0PkFWgc4rPStGoqfWaSbpamm8= X-Gm-Message-State: AOJu0YyQJOSj43qHgu5X45K+Z/vdle5m6aQYika2Bkdxvgv5Os3oEEXr o7V1XfjQzjqKueoC2/M4xw56Wpf5QkLvWnVRHAMUqe0id/0bbsupGRhXFY098Lo= X-Google-Smtp-Source: AGHT+IFOI2I/X/krm4AKtHSPidwLIM4wfZTExpCjliyiawzbQm1Fjl84HRe0rz4bKi2uvAxm8PLCAw== X-Received: by 2002:a4a:9d09:0:b0:59f:9910:45ed with SMTP id w9-20020a4a9d09000000b0059f991045edmr18355684ooj.1.1708570959437; Wed, 21 Feb 2024 19:02:39 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id l15-20020a4a350f000000b0059d7a60e4a6sm107750ooa.44.2024.02.21.19.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:39 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/15] clk: samsung: Reduce params count in exynos_register_cpu_clock() Date: Wed, 21 Feb 2024 21:02:24 -0600 Message-Id: <20240222030235.27815-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190240_982881_2A067CBA X-CRM114-Status: GOOD ( 18.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Pass CPU clock data structure to exynos_register_cpu_clock() instead of passing its fields separately there. That simplifies the signature of exynos_register_cpu_clock() and makes it easier to add more fields to struct samsung_cpu_clock later. This style follows the example of samsung_clk_register_pll(). No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 46 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 6412fd2580e0..7b6fd331a7ec 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -432,16 +432,19 @@ static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb, /* helper function to register a CPU clock */ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, - unsigned int lookup_id, const char *name, - const struct clk_hw *parent, const struct clk_hw *alt_parent, - unsigned long offset, const struct exynos_cpuclk_cfg_data *cfg, - unsigned long num_cfgs, unsigned long flags) + const struct samsung_cpu_clock *clk_data) { + const struct clk_hw *parent, *alt_parent; + struct clk_hw **hws; struct exynos_cpuclk *cpuclk; struct clk_init_data init; const char *parent_name; + unsigned int num_cfgs; int ret = 0; + hws = ctx->clk_data.hws; + parent = hws[clk_data->parent_id]; + alt_parent = hws[clk_data->alt_parent_id]; if (IS_ERR(parent) || IS_ERR(alt_parent)) { pr_err("%s: invalid parent clock(s)\n", __func__); return -EINVAL; @@ -453,7 +456,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, parent_name = clk_hw_get_name(parent); - init.name = name; + init.name = clk_data->name; init.flags = CLK_SET_RATE_PARENT; init.parent_names = &parent_name; init.num_parents = 1; @@ -461,10 +464,10 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->alt_parent = alt_parent; cpuclk->hw.init = &init; - cpuclk->ctrl_base = ctx->reg_base + offset; + cpuclk->ctrl_base = ctx->reg_base + clk_data->offset; cpuclk->lock = &ctx->lock; - cpuclk->flags = flags; - if (flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) + cpuclk->flags = clk_data->flags; + if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) cpuclk->clk_nb.notifier_call = exynos5433_cpuclk_notifier_cb; else cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; @@ -472,11 +475,16 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, ret = clk_notifier_register(parent->clk, &cpuclk->clk_nb); if (ret) { pr_err("%s: failed to register clock notifier for %s\n", - __func__, name); + __func__, clk_data->name); goto free_cpuclk; } - cpuclk->cfg = kmemdup(cfg, sizeof(*cfg) * num_cfgs, GFP_KERNEL); + /* Find count of configuration rates in cfg */ + for (num_cfgs = 0; clk_data->cfg[num_cfgs].prate != 0; ) + num_cfgs++; + + cpuclk->cfg = kmemdup(clk_data->cfg, sizeof(*clk_data->cfg) * num_cfgs, + GFP_KERNEL); if (!cpuclk->cfg) { ret = -ENOMEM; goto unregister_clk_nb; @@ -484,11 +492,12 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, ret = clk_hw_register(NULL, &cpuclk->hw); if (ret) { - pr_err("%s: could not register cpuclk %s\n", __func__, name); + pr_err("%s: could not register cpuclk %s\n", __func__, + clk_data->name); goto free_cpuclk_data; } - samsung_clk_add_lookup(ctx, &cpuclk->hw, lookup_id); + samsung_clk_add_lookup(ctx, &cpuclk->hw, clk_data->id); return 0; free_cpuclk_data: @@ -504,16 +513,7 @@ void __init samsung_clk_register_cpu(struct samsung_clk_provider *ctx, const struct samsung_cpu_clock *list, unsigned int nr_clk) { unsigned int idx; - unsigned int num_cfgs; - struct clk_hw **hws = ctx->clk_data.hws; - for (idx = 0; idx < nr_clk; idx++, list++) { - /* find count of configuration rates in cfg */ - for (num_cfgs = 0; list->cfg[num_cfgs].prate != 0; ) - num_cfgs++; - - exynos_register_cpu_clock(ctx, list->id, list->name, - hws[list->parent_id], hws[list->alt_parent_id], - list->offset, list->cfg, num_cfgs, list->flags); - } + for (idx = 0; idx < nr_clk; idx++) + exynos_register_cpu_clock(ctx, &list[idx]); } From patchwork Thu Feb 22 03:02:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566683 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19ADBC48BF6 for ; Thu, 22 Feb 2024 03:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i6ddOzfRXBBFrgiF7VxUO4ys8tgnebNV51AePz3xpnM=; b=d2drx2onevekx6 TpOCaYo+blkU7C5yVyRmgykRdqMe86CR6dl+SId1RUtyj3SFLqTWYEBifwXjHULBd9ek+387T2TIC n98RGND1zQ7SgiFx6OZ/RuKV5aPyBgf14pVGB125L5gILKyd1SC8E6HrR41feG3jAlmYxEvDtgi8x /BaLE++pA2kPspxzRsAP9hor1JhHXC2n52+JJKo6EpqcvdFcDzgLnawcgbkGrHH0XvzQ+KattjgLl 2loCbd7UGZcaJaPJwlfry4PS7+hsrsGj0b6m7OJkIEam1iXv6iRT9y+ZRFpHccsQNbPgy0KX32lY5 wbWBbb2eSXmy6h+LX6AQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMM-00000003IoW-1sGp; Thu, 22 Feb 2024 03:02:54 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM9-00000003IfF-2y15 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:43 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3c15bef14c3so2806567b6e.2 for ; Wed, 21 Feb 2024 19:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570960; x=1709175760; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jx74Vmc3ML2VKaMboMxLRhlCDqHuQQbgCrU7etXbl0w=; b=vkIShd8kXZu00YJU1zVZTxZNp9q6QfL3KE6hhAudDq7OUglgiXd/F1Rtiu5Yea7y3O Ow1AE+nVJHRTN9/C7RWg/30P5Ziua6jKDYGBB9TtWLCZjleAwoZw3o9Szc9HvGDMp7xl c0xdd7op/LJnAiigsfu/HRBU2sR7fn/Jn0uQHwZ6Uktp/LE2OLk0TxXb7vWjp7f2Jsoi zgxzKQu27LTMB80JguflyENVc5mjo1+jN9hCaRTDEqeOFYFUxpk3s1BiE69zRqvRnh/S L6aUYCnGlGPMMKCEwu5l+ACt4i9j+oLsQw4LBtpYtzVBbNiWMxlKrwu+cJBPVv26c6QQ 0mYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570960; x=1709175760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jx74Vmc3ML2VKaMboMxLRhlCDqHuQQbgCrU7etXbl0w=; b=AsPUPI+veNQzGH6XoskYrtOnbEFeW53Un6aCd+aQaTgA/fQgibibc+/7rifYLBKbQo fLnz32uubHHLYklaPPAc3Nuu66YgQbPRjo7eg6xMJI1x8gRTV6u56MxxTFxZ0aOj5C8z c60Jl6ZswvDc8NeHSzFmHoxSJbfwVKpfYWhIS/uiA8Irq5+szKifpUHE5GLk6LQX+AEB 43rXOtTvWFHTVkkKixkIb4AdOdNO90kH6ybbW3AhFSk8ZvseGFzdGTE8KgGKh0VMoVDX zH8RebDkjl7D+xflVjB/6AEglUYsMOq6beWa7wc5Tpb/gvqAEj66E8hDT76htvEuR3aQ efTw== X-Forwarded-Encrypted: i=1; AJvYcCXSaSy4yR836wKOGfSu3Fp4HAu2rEKEfZO2urSPlkWNerp0HwPFSxExS5gj+1XeDojS856fqDixasJ72BSsxk6NfC1BhzFXLPSj+hjSJ1WjDKluXhk= X-Gm-Message-State: AOJu0YzpO/vKwp0EnRowWcsauoS68Oa4KY/kvToYNlAwrTxQhjYxIHDb BkiB6M3097UdHHo9lpJiGQgQ6Lzt2wxYTwQJbcfABu5a9UPIVA7mlr9vcH+QxfE= X-Google-Smtp-Source: AGHT+IH47BpQcRmQc1o3nJPlrA+RSp/KKEQAD42GT4X1x7anS7rfqDG/zuyFMBuq9OuBvzNhE6sj1Q== X-Received: by 2002:a05:6808:3c4d:b0:3c1:783e:7825 with SMTP id gl13-20020a0568083c4d00b003c1783e7825mr1058478oib.33.1708570960250; Wed, 21 Feb 2024 19:02:40 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id u19-20020a056808001300b003c14520c78csm1794602oic.54.2024.02.21.19.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:39 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/15] clk: samsung: Use single CPU clock notifier callback for all chips Date: Wed, 21 Feb 2024 21:02:25 -0600 Message-Id: <20240222030235.27815-6-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190241_793624_93058556 X-CRM114-Status: GOOD ( 22.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce the code duplication by making all chips use a single version of exynos_cpuclk_notifier_cb() function. That will prevent the code bloat when adding new chips support too. Also don't pass base address to pre/post rate change functions, as it can be easily derived from already passed cpuclk param. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 63 ++++++++++++++++------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 7b6fd331a7ec..427018e8dd8c 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -66,6 +66,11 @@ #define DIV_MASK_ALL GENMASK(31, 0) #define MUX_MASK GENMASK(2, 0) +struct exynos_cpuclk; + +typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, + struct exynos_cpuclk *cpuclk); + /** * struct exynos_cpuclk - information about clock supplied to a CPU core * @hw: handle between CCF and CPU clock @@ -78,6 +83,8 @@ * @clk_nb: clock notifier registered for changes in clock speed of the * primary parent clock * @flags: configuration flags for the CPU clock + * @pre_rate_cb: callback to run before CPU clock rate change + * @post_rate_cb: callback to run after CPU clock rate change * * This structure holds information required for programming the CPU clock for * various clock speeds. @@ -91,6 +98,9 @@ struct exynos_cpuclk { const unsigned long num_cfgs; struct notifier_block clk_nb; unsigned long flags; + + exynos_rate_change_fn_t pre_rate_cb; + exynos_rate_change_fn_t post_rate_cb; }; /* @@ -178,9 +188,10 @@ static void exynos_set_safe_div(void __iomem *base, unsigned long div, /* handler for pre-rate change notification from parent clock */ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, - struct exynos_cpuclk *cpuclk, void __iomem *base) + struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + void __iomem *base = cpuclk->ctrl_base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -255,9 +266,10 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, /* handler for post-rate change notification from parent clock */ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, - struct exynos_cpuclk *cpuclk, void __iomem *base) + struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + void __iomem *base = cpuclk->ctrl_base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; unsigned long flags; @@ -306,9 +318,10 @@ static void exynos5433_set_safe_div(void __iomem *base, unsigned long div, /* handler for pre-rate change notification from parent clock */ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, - struct exynos_cpuclk *cpuclk, void __iomem *base) + struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + void __iomem *base = cpuclk->ctrl_base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -366,8 +379,9 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, /* handler for post-rate change notification from parent clock */ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, - struct exynos_cpuclk *cpuclk, void __iomem *base) + struct exynos_cpuclk *cpuclk) { + void __iomem *base = cpuclk->ctrl_base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; unsigned long flags; @@ -393,39 +407,14 @@ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, { struct clk_notifier_data *ndata = data; struct exynos_cpuclk *cpuclk; - void __iomem *base; int err = 0; cpuclk = container_of(nb, struct exynos_cpuclk, clk_nb); - base = cpuclk->ctrl_base; if (event == PRE_RATE_CHANGE) - err = exynos_cpuclk_pre_rate_change(ndata, cpuclk, base); + err = cpuclk->pre_rate_cb(ndata, cpuclk); else if (event == POST_RATE_CHANGE) - err = exynos_cpuclk_post_rate_change(ndata, cpuclk, base); - - return notifier_from_errno(err); -} - -/* - * This notifier function is called for the pre-rate and post-rate change - * notifications of the parent clock of cpuclk. - */ -static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb, - unsigned long event, void *data) -{ - struct clk_notifier_data *ndata = data; - struct exynos_cpuclk *cpuclk; - void __iomem *base; - int err = 0; - - cpuclk = container_of(nb, struct exynos_cpuclk, clk_nb); - base = cpuclk->ctrl_base; - - if (event == PRE_RATE_CHANGE) - err = exynos5433_cpuclk_pre_rate_change(ndata, cpuclk, base); - else if (event == POST_RATE_CHANGE) - err = exynos5433_cpuclk_post_rate_change(ndata, cpuclk, base); + err = cpuclk->post_rate_cb(ndata, cpuclk); return notifier_from_errno(err); } @@ -467,10 +456,14 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->ctrl_base = ctx->reg_base + clk_data->offset; cpuclk->lock = &ctx->lock; cpuclk->flags = clk_data->flags; - if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) - cpuclk->clk_nb.notifier_call = exynos5433_cpuclk_notifier_cb; - else - cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; + cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; + if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) { + cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change; + cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change; + } else { + cpuclk->pre_rate_cb = exynos_cpuclk_pre_rate_change; + cpuclk->post_rate_cb = exynos_cpuclk_post_rate_change; + } ret = clk_notifier_register(parent->clk, &cpuclk->clk_nb); if (ret) { From patchwork Thu Feb 22 03:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566684 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A00EDC54788 for ; Thu, 22 Feb 2024 03:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hlCgsIrFxXu/cfKjbl2pcoqtU8BCFGSwztTJkJPHXpQ=; b=2RnaZdYz9s0Ph+ iGtihVnSFmTwy+xEnSBtKaJ6UTIZpoV6e1bIoN8L7n3Opl4dzopAiklSMRyiRUsNfd6i9uVQuB9yp TDmAq1FASPlWK90/AZH2f+ZD9Dsz/QpCw4LnB9GgsLFjlaoaIta0DcbYCbYw1m//KEl7z67Q55Hq4 YrPULB7RQ7YrhIaIpUzqrq0cmKF4SYp3JpL4H1MeI6tfVurd2kqQiNIGVkZhbG0k1uUoyfJ7HSHK4 mzecqCZm/mGzYts71fm7e1GJIUugE7lZ5m6mRlRHOquhZDk8bBe7oagrkLoMFw9aHwbbqqcWytxEq xnwcJUzim2w215yg/6OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMO-00000003IqG-0sjd; Thu, 22 Feb 2024 03:02:56 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczM9-00000003Ifo-3ZF8 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:43 +0000 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3bba50cd318so5472912b6e.0 for ; Wed, 21 Feb 2024 19:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570961; x=1709175761; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dA8iJf/laPqQRe+Yi4M7uYUdy+5iI2o8j4rYPxsJ3iw=; b=Y0nbEknom77R408CnWQy1W0nEArT/QXWk0hCOwNJYl5CZbOpNPX+F3vBlFR5LEPgoA DsFXRWDA8SzMNi78R4AGC+hDP0/o2HUf1DTi2tmVK6W+MwKJjtjx+T3CxEpqPpPlHwZp Aq+IcNzAoVfb/FrPC0R9rIJr80LFAuLPiDq2/895VcRG8UihBNYLtUSaCs9VBCefleGQ /5wDRVqw+y+o1Q4vua6DthqI/0bMgjz0D9K1BrNdFSoSGkIs+kU0b++XDgUfaUsTg/5x fCybdno1Croi3UjelBqMgwTmI0LKknft/baNINkj/XVvvfQZq+0ZrPypJAX8kTKYt7cw sNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570961; x=1709175761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dA8iJf/laPqQRe+Yi4M7uYUdy+5iI2o8j4rYPxsJ3iw=; b=YXHQnUlTbR8E3laoUitEJADzSQYFSrqj37uXu6S+P+ya+eZp8X/naf0v9CGCvys1Cz UTnhz1oQtFp+7ir+f+SHfO9Q4qToRmqX0tKsvOYWmTw9pspT5kgOJCMfICs0ISXVYQ0/ sDA8of5/3DNDaO/aDNZIc0w4TuWb/sXZdoJQwEHwItAprze5LmSYBW/EA/ac+2lGukeD 9wMeWQ7fGh3zZiDdV5uoXvGkr6ewWBCwmD+1NjMV8HzAADus+R5Mst4AZJN8ESMzhFDw ASMro2xwjmi37iA0d7j4fVRV1YDoLAVE66EgjiCjWGxnEv2k/OrD0+XVUfXkAYTHHaDa xWYQ== X-Forwarded-Encrypted: i=1; AJvYcCXE3RiVSZvdhUnaDBhEBxCOooNPmPZ1z6pquJ6QAlPMGx/L2OfjvS5g2fwdHjZ16v56xL5C+3B6GXrx9+KEKc6+ehFkfdala5Asg9sWbYwWfC3ZkeU= X-Gm-Message-State: AOJu0YyrnXm/ZHUCmEo1capIC1weBv3pIAkkvv84a2hy2IY4aP3DfJs1 H0dkFG+rPhch2jPm5beVSkBvlNw3ILzxunurN7UgR1VCJ3zelkzAFsqO425Eqdo= X-Google-Smtp-Source: AGHT+IENe0nxuoXBYPaz1EEYdHcMjdNKSHKJGqYj4olutBXIBul4W86ca3W7naxV1nOe2/b2wwewHA== X-Received: by 2002:a05:6808:3195:b0:3c1:66ec:5aa with SMTP id cd21-20020a056808319500b003c166ec05aamr10457919oib.22.1708570961120; Wed, 21 Feb 2024 19:02:41 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 5-20020aca1205000000b003c133696f42sm1768433ois.29.2024.02.21.19.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:40 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 06/15] clk: samsung: Group CPU clock functions by chip Date: Wed, 21 Feb 2024 21:02:26 -0600 Message-Id: <20240222030235.27815-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190241_947611_FA43EADE X-CRM114-Status: GOOD ( 19.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org clk-cpu.c is going to get messy as new chips support is added. Restructure the code by pulling related functions and definitions together, grouping those by their relation to a particular chip or other categories, to simplify the code navigation. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 114 ++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 53 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 427018e8dd8c..d550a4bb632f 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -38,34 +38,6 @@ #include "clk.h" #include "clk-cpu.h" -#define E4210_SRC_CPU 0x0 -#define E4210_STAT_CPU 0x200 -#define E4210_DIV_CPU0 0x300 -#define E4210_DIV_CPU1 0x304 -#define E4210_DIV_STAT_CPU0 0x400 -#define E4210_DIV_STAT_CPU1 0x404 - -#define E5433_MUX_SEL2 0x008 -#define E5433_MUX_STAT2 0x208 -#define E5433_DIV_CPU0 0x400 -#define E5433_DIV_CPU1 0x404 -#define E5433_DIV_STAT_CPU0 0x500 -#define E5433_DIV_STAT_CPU1 0x504 - -#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) -#define E4210_DIV1_HPM_MASK GENMASK(6, 4) -#define E4210_DIV1_COPY_MASK GENMASK(2, 0) -#define E4210_MUX_HPM_MASK BIT(20) -#define E4210_DIV0_ATB_SHIFT 16 -#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT) - -/* Divider stabilization time, msec */ -#define MAX_STAB_TIME 10 -#define MAX_DIV 8 -#define DIV_MASK GENMASK(2, 0) -#define DIV_MASK_ALL GENMASK(31, 0) -#define MUX_MASK GENMASK(2, 0) - struct exynos_cpuclk; typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, @@ -103,6 +75,15 @@ struct exynos_cpuclk { exynos_rate_change_fn_t post_rate_cb; }; +/* ---- Common code --------------------------------------------------------- */ + +/* Divider stabilization time, msec */ +#define MAX_STAB_TIME 10 +#define MAX_DIV 8 +#define DIV_MASK GENMASK(2, 0) +#define DIV_MASK_ALL GENMASK(31, 0) +#define MUX_MASK GENMASK(2, 0) + /* * Helper function to wait until divider(s) have stabilized after the divider * value has changed. @@ -142,33 +123,21 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, pr_err("%s: re-parenting mux timed-out\n", __func__); } -/* common round rate callback usable for all types of CPU clocks */ -static long exynos_cpuclk_round_rate(struct clk_hw *hw, unsigned long drate, - unsigned long *prate) -{ - struct clk_hw *parent = clk_hw_get_parent(hw); - *prate = clk_hw_round_rate(parent, drate); - return *prate; -} +/* ---- Exynos 3/4/5 -------------------------------------------------------- */ -/* common recalc rate callback usable for all types of CPU clocks */ -static unsigned long exynos_cpuclk_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) -{ - /* - * The CPU clock output (armclk) rate is the same as its parent - * rate. Although there exist certain dividers inside the CPU - * clock block that could be used to divide the parent clock, - * the driver does not make use of them currently, except during - * frequency transitions. - */ - return parent_rate; -} +#define E4210_SRC_CPU 0x0 +#define E4210_STAT_CPU 0x200 +#define E4210_DIV_CPU0 0x300 +#define E4210_DIV_CPU1 0x304 +#define E4210_DIV_STAT_CPU0 0x400 +#define E4210_DIV_STAT_CPU1 0x404 -static const struct clk_ops exynos_cpuclk_clk_ops = { - .recalc_rate = exynos_cpuclk_recalc_rate, - .round_rate = exynos_cpuclk_round_rate, -}; +#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) +#define E4210_DIV1_HPM_MASK GENMASK(6, 4) +#define E4210_DIV1_COPY_MASK GENMASK(2, 0) +#define E4210_MUX_HPM_MASK BIT(20) +#define E4210_DIV0_ATB_SHIFT 16 +#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT) /* * Helper function to set the 'safe' dividers for the CPU clock. The parameters @@ -300,6 +269,15 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, return 0; } +/* ---- Exynos5433 ---------------------------------------------------------- */ + +#define E5433_MUX_SEL2 0x008 +#define E5433_MUX_STAT2 0x208 +#define E5433_DIV_CPU0 0x400 +#define E5433_DIV_CPU1 0x404 +#define E5433_DIV_STAT_CPU0 0x500 +#define E5433_DIV_STAT_CPU1 0x504 + /* * Helper function to set the 'safe' dividers for the CPU clock. The parameters * div and mask contain the divider value and the register bit mask of the @@ -398,6 +376,36 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, return 0; } +/* -------------------------------------------------------------------------- */ + +/* Common round rate callback usable for all types of CPU clocks */ +static long exynos_cpuclk_round_rate(struct clk_hw *hw, unsigned long drate, + unsigned long *prate) +{ + struct clk_hw *parent = clk_hw_get_parent(hw); + *prate = clk_hw_round_rate(parent, drate); + return *prate; +} + +/* Common recalc rate callback usable for all types of CPU clocks */ +static unsigned long exynos_cpuclk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + /* + * The CPU clock output (armclk) rate is the same as its parent + * rate. Although there exist certain dividers inside the CPU + * clock block that could be used to divide the parent clock, + * the driver does not make use of them currently, except during + * frequency transitions. + */ + return parent_rate; +} + +static const struct clk_ops exynos_cpuclk_clk_ops = { + .recalc_rate = exynos_cpuclk_recalc_rate, + .round_rate = exynos_cpuclk_round_rate, +}; + /* * This notifier function is called for the pre-rate and post-rate change * notifications of the parent clock of cpuclk. From patchwork Thu Feb 22 03:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566686 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00219C48BF6 for ; Thu, 22 Feb 2024 03:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=376Vqoi+cv9DrlXeP7cRC8Yb1siWNUG6AU2AWLgbCsM=; b=EU7Sx92kUI00Q8 0dKC4Hj+HuqE2uhoa6jVozMndeno6cTZ7Pkww0WFno4m5Tr+fGq0r8KUVsYH6OEoH27PvKvfK/7zL MPlUZ5nntcTapZJ+Sg9aZ8Jv0w9qNfdJ7OLVVczKJP2oS8aTJotiNKc5uT/FV+bDAb7RL8NMzLCtE YVFQX365JhFPo5fCLPLb2q6cRqHTpfh2/dlBrKh/4BTjKdIkVjhu/351UxGGI7UO9j5oxreTP7ZP0 RUWyDKzI0f2Zs3kFvqtZoQfvKHKpPc4/VvspOPdHowznHN/SZEkp8P2V8SXzfdGfdHIS8McUjwftV dWdrs8TDFVME3ji6MaRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMR-00000003Ist-373z; Thu, 22 Feb 2024 03:02:59 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMB-00000003Igh-1ib7 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:44 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-214c940145bso3897123fac.1 for ; Wed, 21 Feb 2024 19:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570962; x=1709175762; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TlZqe+IBPYU8+N8TDK4D7h8ZRV0c5/qpAc5EaWhxJSU=; b=VDJ/tVi9FxUMqTdOSOJAsfCJXrqrW1JsUQmYCXIaIKkRz50V+LXUqSm6530Ghq5shd eq73188igRxru6mOR9phRYctLOQB6QNe/O3OclSHhlPrIMv8HsFM8pJjykh6/enEuMSU aTr1UW0EM9PA/MONth3CxuLnsXzyG6oghfTOutAt7kS+et8ZMbqthoTA0/h4CzvUQRAC u8EHLef78mob67CmRHaOxZgp4AaYGQGAZaXDu2cLy9yoWoGcQDX+ku+AMITSsawDV7ag cL+6waxKv0n9gXaRUaVgtayw+rDi53iPI6O2uBLSliSPrEtNzRBMQdOo6QkX2w51UVFr o10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570962; x=1709175762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TlZqe+IBPYU8+N8TDK4D7h8ZRV0c5/qpAc5EaWhxJSU=; b=D4gtivLhw/E7sg1i3YsTTE8L2ZiJqJNKWhaUspd47fBNwRE5dR3G68Xrguupaaz+rN JDK9XnWjMECCltOlw9TG0V3CpbYTfk12BKOa4BnqBrgEr+cGHIv7M5JgoXEQ357phXVf WcBAvZg8cljQSfVISBiBPj239gykycDK528lRcA1uNXbWO0dc6fsPGweXSFXPj1EILd2 MQzqsRXe+39Ap34vTEepuyj3TlP3Vm9B30dCkLv9+7XV6VLBHMuFHX0ly4EiMEGMSGI0 oAd1uwg2FL62uyzbpbYpPIcpMxHCk1vtNm3KNZ/GI0A+L/PnVi+89A6hJ2E72q9YAqPH a7Ww== X-Forwarded-Encrypted: i=1; AJvYcCWj+eEqaHiXyF1ftQACQE+wpP+12tKbbbXMqpZh6BgY56zY/oIdtPBNbGQXUTtL6/R8t8hBq7rP6oC7ktf+9w+73yLJCwm2KGyJEJc1Z+IEKz5yvl8= X-Gm-Message-State: AOJu0YxS+hKWiFkyn3tYyqEDWq5/m5TIF6+c65s1NnYBMcG2gL6l4LEC tGcXSHB1OI+O70cW15rh4Cr5K7bK0ZUkrm7z/22tFmjGQ6nYrsIo3tC7WvKM/go= X-Google-Smtp-Source: AGHT+IEb5h7i4tepkzT7v/8OQGABNAtOaAUeDfz6YEpPehnVlCDcHu066DbDwq89xdcCfcSbsemFOQ== X-Received: by 2002:a05:6870:d208:b0:21e:f37d:9154 with SMTP id g8-20020a056870d20800b0021ef37d9154mr9382252oac.49.1708570961953; Wed, 21 Feb 2024 19:02:41 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id nx16-20020a056870be9000b0021e8840de86sm2635411oab.54.2024.02.21.19.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:41 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 07/15] clk: samsung: Pass actual CPU clock registers base to CPU_CLK() Date: Wed, 21 Feb 2024 21:02:27 -0600 Message-Id: <20240222030235.27815-8-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190243_516148_13CB2B56 X-CRM114-Status: GOOD ( 25.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The documentation for struct exynos_cpuclk says .ctrl_base field should contain the controller base address. There are two different problems with that: 1. All Exynos clock drivers are actually passing CPU_SRC register offset via CPU_CLK() macro, which in turn gets assigned to mentioned .ctrl_base field. Because CPU_SRC register usually already has 0x200 offset from controller's base, all other register offsets in clk-cpu.c (like DIVs and MUXes) are specified as offsets from CPU_SRC offset, and not from controller's base. That makes things confusing and inconsistent with register offsets provided in Exynos clock drivers, also breaking the contract for .ctrl_base field as described in struct exynos_cpuclk doc. 2. Furthermore, some Exynos chips have an additional offset for the start of CPU clock registers block (inside of the CMU). There might be different reasons for that, e.g.: - The CMU contains clocks for two different CPUs (like in Exynos5420) - The CMU contains also non-CPU clocks as well (like in Exynos4) - The CPU CMU exists as a dedicated hardware block in the SoC layout, but is modelled as a part of bigger CMU in the driver (like in case of Exynos3250) That means the .ctrl_base field is actually not a controller's base, but instead it's a start address of the CPU clock registers inside of the CMU. Rework all register offsets in clk-cpu.c to be actual offsets from the CPU clock register block start, and fix offsets provided to CPU_CLK() macro in all Exynos clock drivers. Also clarify the .ctrl_base field documentation and rename it to just .base, because it doesn't really contain the CMU base. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - Renamed .ctrl_base field to .base and fixed its documentation - Fixed typo in commit message: Exynis -> Exynos - Improved the commit message: mentioned that .ctrl_base is actually a start address of the CPU clock register block, not the CMU base drivers/clk/samsung/clk-cpu.c | 38 ++++++++++++++-------------- drivers/clk/samsung/clk-exynos3250.c | 2 +- drivers/clk/samsung/clk-exynos4.c | 9 ++++--- drivers/clk/samsung/clk-exynos5250.c | 4 +-- drivers/clk/samsung/clk-exynos5420.c | 16 ++++++------ drivers/clk/samsung/clk-exynos5433.c | 10 +++----- 6 files changed, 40 insertions(+), 39 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index d550a4bb632f..82d54b0c9040 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -48,7 +48,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, * @hw: handle between CCF and CPU clock * @alt_parent: alternate parent clock to use when switching the speed * of the primary parent clock - * @ctrl_base: base address of the clock controller + * @base: start address of the CPU clock registers block * @lock: cpu clock domain register access lock * @cfg: cpu clock rate configuration data * @num_cfgs: number of array elements in @cfg array @@ -64,7 +64,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, struct exynos_cpuclk { struct clk_hw hw; const struct clk_hw *alt_parent; - void __iomem *ctrl_base; + void __iomem *base; spinlock_t *lock; const struct exynos_cpuclk_cfg_data *cfg; const unsigned long num_cfgs; @@ -125,12 +125,12 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, /* ---- Exynos 3/4/5 -------------------------------------------------------- */ -#define E4210_SRC_CPU 0x0 -#define E4210_STAT_CPU 0x200 -#define E4210_DIV_CPU0 0x300 -#define E4210_DIV_CPU1 0x304 -#define E4210_DIV_STAT_CPU0 0x400 -#define E4210_DIV_STAT_CPU1 0x404 +#define E4210_SRC_CPU 0x200 +#define E4210_STAT_CPU 0x400 +#define E4210_DIV_CPU0 0x500 +#define E4210_DIV_CPU1 0x504 +#define E4210_DIV_STAT_CPU0 0x600 +#define E4210_DIV_STAT_CPU1 0x604 #define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) #define E4210_DIV1_HPM_MASK GENMASK(6, 4) @@ -160,7 +160,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; - void __iomem *base = cpuclk->ctrl_base; + void __iomem *base = cpuclk->base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -238,7 +238,7 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; - void __iomem *base = cpuclk->ctrl_base; + void __iomem *base = cpuclk->base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; unsigned long flags; @@ -271,12 +271,12 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, /* ---- Exynos5433 ---------------------------------------------------------- */ -#define E5433_MUX_SEL2 0x008 -#define E5433_MUX_STAT2 0x208 -#define E5433_DIV_CPU0 0x400 -#define E5433_DIV_CPU1 0x404 -#define E5433_DIV_STAT_CPU0 0x500 -#define E5433_DIV_STAT_CPU1 0x504 +#define E5433_MUX_SEL2 0x208 +#define E5433_MUX_STAT2 0x408 +#define E5433_DIV_CPU0 0x600 +#define E5433_DIV_CPU1 0x604 +#define E5433_DIV_STAT_CPU0 0x700 +#define E5433_DIV_STAT_CPU1 0x704 /* * Helper function to set the 'safe' dividers for the CPU clock. The parameters @@ -299,7 +299,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; - void __iomem *base = cpuclk->ctrl_base; + void __iomem *base = cpuclk->base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; unsigned long flags; @@ -359,7 +359,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { - void __iomem *base = cpuclk->ctrl_base; + void __iomem *base = cpuclk->base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; unsigned long flags; @@ -461,7 +461,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->alt_parent = alt_parent; cpuclk->hw.init = &init; - cpuclk->ctrl_base = ctx->reg_base + clk_data->offset; + cpuclk->base = ctx->reg_base + clk_data->offset; cpuclk->lock = &ctx->lock; cpuclk->flags = clk_data->flags; cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; diff --git a/drivers/clk/samsung/clk-exynos3250.c b/drivers/clk/samsung/clk-exynos3250.c index a02461667664..bf149fae04c3 100644 --- a/drivers/clk/samsung/clk-exynos3250.c +++ b/drivers/clk/samsung/clk-exynos3250.c @@ -775,7 +775,7 @@ static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = { static const struct samsung_cpu_clock exynos3250_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, - CLK_CPU_HAS_DIV1, 0x14200, e3250_armclk_d), + CLK_CPU_HAS_DIV1, 0x14000, e3250_armclk_d), }; static void __init exynos3_core_down_clock(void __iomem *reg_base) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 4ec41221e68f..d5b1e9f49d8b 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1252,17 +1252,20 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = { static const struct samsung_cpu_clock exynos4210_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_SCLK_MPLL, - CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4210_armclk_d), + CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, + e4210_armclk_d), }; static const struct samsung_cpu_clock exynos4212_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, - CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4212_armclk_d), + CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, + e4212_armclk_d), }; static const struct samsung_cpu_clock exynos4412_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, - CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4412_armclk_d), + CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, + e4412_armclk_d), }; /* register exynos4 clocks */ diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 8ebe6155d8b7..58df80de52ef 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -776,8 +776,8 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = { }; static const struct samsung_cpu_clock exynos5250_cpu_clks[] __initconst = { - CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL, CLK_CPU_HAS_DIV1, 0x200, - exynos5250_armclk_d), + CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL, + CLK_CPU_HAS_DIV1, 0x0, exynos5250_armclk_d), }; static const struct of_device_id ext_clk_match[] __initconst = { diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index 199843f12ae5..bd7b304d2c00 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1555,17 +1555,17 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = { }; static const struct samsung_cpu_clock exynos5420_cpu_clks[] __initconst = { - CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, 0x200, - exynos5420_eglclk_d), - CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, 0x28200, - exynos5420_kfcclk_d), + CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, + 0x0, exynos5420_eglclk_d), + CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, + 0x28000, exynos5420_kfcclk_d), }; static const struct samsung_cpu_clock exynos5800_cpu_clks[] __initconst = { - CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, 0x200, - exynos5800_eglclk_d), - CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, 0x28200, - exynos5420_kfcclk_d), + CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, + 0x0, exynos5800_eglclk_d), + CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, + 0x28000, exynos5420_kfcclk_d), }; static const struct of_device_id ext_clk_match[] __initconst = { diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index 6bfc5d0cd924..d3779eefb438 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -3700,9 +3700,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_apolloclk_d[] __initconst static const struct samsung_cpu_clock apollo_cpu_clks[] __initconst = { CPU_CLK(CLK_SCLK_APOLLO, "apolloclk", CLK_MOUT_APOLLO_PLL, - CLK_MOUT_BUS_PLL_APOLLO_USER, - CLK_CPU_HAS_E5433_REGS_LAYOUT, 0x200, - exynos5433_apolloclk_d), + CLK_MOUT_BUS_PLL_APOLLO_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT, + 0x0, exynos5433_apolloclk_d), }; static const struct samsung_cmu_info apollo_cmu_info __initconst = { @@ -3945,9 +3944,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_atlasclk_d[] __initconst = static const struct samsung_cpu_clock atlas_cpu_clks[] __initconst = { CPU_CLK(CLK_SCLK_ATLAS, "atlasclk", CLK_MOUT_ATLAS_PLL, - CLK_MOUT_BUS_PLL_ATLAS_USER, - CLK_CPU_HAS_E5433_REGS_LAYOUT, 0x200, - exynos5433_atlasclk_d), + CLK_MOUT_BUS_PLL_ATLAS_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT, + 0x0, exynos5433_atlasclk_d), }; static const struct samsung_cmu_info atlas_cmu_info __initconst = { From patchwork Thu Feb 22 03:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566685 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6039BC48BEB for ; Thu, 22 Feb 2024 03:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xCSdyq5r0eYL2p0AXVtnatxDZIuJPiqn60CW77nCNig=; b=bmyANrAFSrMzFa AkJWNHTyeIlEQvGdhZ6vwGAZoalkLmzhKWQWkFjhSqP5h544xFl1Yk3LZB90BH3q9WmqZLkh2HvuK g8cGbtkktACr8go7GKRsULhhCj9TSxd6R1eFrjk89MCzyVZ6V9NkozsxUDfmAv5Y0NfvzT7U1IXgX 5mTMEMuVwhvgPdslDPLyABgVXAkNiJSjT1A4Pxb1hf9P2TFGaYLNZFVaNl2LdXE61t0cMrXJzZdJA Gt7WnQmL6FTI78iXLRdBimRLjH/RdOWHUhsWNZ6t+ZGIql0HaqjmSKZkIj98NlMMeu1173O6dHDVQ tOxiP4lMY+VHihUh/yDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMU-00000003Ivr-2RYW; Thu, 22 Feb 2024 03:03:02 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMC-00000003Igv-0amU for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:45 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6e2edb28554so2447000a34.2 for ; Wed, 21 Feb 2024 19:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570963; x=1709175763; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iG1PQj122jNiRMr0F8KLnqdfj5gCk5jDX8J/tVmpchw=; b=Rg7kcW00dvvx8RuQUM2Mc866tD1TeeY7ztMXj7ByzabXGrP1HmAoCZjc9fX6o0agW5 XO5Bb+SP5VRAuvMCgB6YJVxYDx+kjv0ElGsYHUScQ/h/nNSJZpbeQjmh7Y4/dt8YF9XR guY376T3ysHRux2AEcRzw+Q3AM43tyq75ExiYOCofVImrU30MKMEbIWOh03QAht+wfq+ lTQaIFaZLvd0ca18UVRSXPayUl7oIf/0mkn3Q8tlTq1nbD2f3YqKcUcCeLGQbkvA0JLr LA/2fZEbZSkg8MXpNNqOmPIpb+XGAaQO/Cbj+K74talCuUVipF0TWXsncPiQwgn6Wz8w AciQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570963; x=1709175763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iG1PQj122jNiRMr0F8KLnqdfj5gCk5jDX8J/tVmpchw=; b=QRLH4xCEImZboa3hbEp/Tp79LaeFO9EEu/TwrM/fjLaDQhIrd2+EayrGTIVDMlJ9K/ EWNKEQv2tHzmAWlTIvB+drwpoBxY+aQiI6q33hAgPeI7EhlaYsLh4qcQjpJ+7TDX5oPP L5oNFUFe9CPLF/3Er2D7Zo0MljdMnPtRCNWQjRllLf/nccxtljtiYHbBQdfupktaxnXA Gx0pASplz4MvEZrNw78QJ/9cA8VXMI9ZSOKIm74aQ4w/q6LV//oADAX+iocKTbpaAE5i Mz5Udy1561OkscWWM6uJnJdW0t8gN96vVCjOCdzp+lUKul0H9naU4vxAiDbB+vqw9Vt5 BESg== X-Forwarded-Encrypted: i=1; AJvYcCV3d44B15KvotQoO30OEEgJ1PtxDwouiSf9XFDsFl35MO7N5Ur67+Fp68e3Hf7w8BlElgoWRNiMei3zV06nithUBxR73/z7wgOhnDqhBidQAMO/hZA= X-Gm-Message-State: AOJu0Yxoa/ReKMQK0sufOM4NT0iXKF3zFDvuY8o+rKv8eL5gBWHA8nBr MEoDJ/c8PO2NIoaImM/NFkGRpYxX+5xHt3ObBGgU1DAOXC4aJ2P59RWpLx1PCIc= X-Google-Smtp-Source: AGHT+IEs5NYL/AuYGD7E8JufLZL3rji4E+UyXCFLsbrEtvEPgAcEKX7sRQw9Wz45x+YFw0XTGdeD5g== X-Received: by 2002:a05:6830:104e:b0:6e2:f115:7d9e with SMTP id b14-20020a056830104e00b006e2f1157d9emr18908070otp.15.1708570962757; Wed, 21 Feb 2024 19:02:42 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id d7-20020a4a9187000000b0059d97d9f75fsm2115130ooh.14.2024.02.21.19.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:42 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/15] clk: samsung: Pass register layout type explicitly to CLK_CPU() Date: Wed, 21 Feb 2024 21:02:28 -0600 Message-Id: <20240222030235.27815-9-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190244_231858_CB735552 X-CRM114-Status: GOOD ( 23.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use a dedicated enum field to explicitly specify which register layout should be used for the CPU clock, instead of passing it as a bit flag. This way it would be possible to keep the chip-specific data in some array, where each chip structure could be accessed by its corresponding layout index. It prepares clk-cpu.c for adding new chips support, which might have different data for different CPU clusters. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - Improved the commit message: explained why enum is needed for specifying the layout (vs bit flag) - Included clk-cpu.h in clk.h as it uses enum exynos_cpuclk_layout from clk-cpu.h (it's needed because preceding patch adding headers was dropped) drivers/clk/samsung/clk-cpu.c | 2 +- drivers/clk/samsung/clk-cpu.h | 12 ++++++++++-- drivers/clk/samsung/clk-exynos3250.c | 2 +- drivers/clk/samsung/clk-exynos4.c | 6 +++--- drivers/clk/samsung/clk-exynos5250.c | 3 ++- drivers/clk/samsung/clk-exynos5420.c | 8 ++++---- drivers/clk/samsung/clk-exynos5433.c | 8 ++++---- drivers/clk/samsung/clk.h | 5 ++++- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 82d54b0c9040..635ab8cc54a2 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -465,7 +465,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->lock = &ctx->lock; cpuclk->flags = clk_data->flags; cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; - if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) { + if (clk_data->reg_layout == CPUCLK_LAYOUT_E5433) { cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change; cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change; } else { diff --git a/drivers/clk/samsung/clk-cpu.h b/drivers/clk/samsung/clk-cpu.h index ee57f3638fed..4382ab005ad3 100644 --- a/drivers/clk/samsung/clk-cpu.h +++ b/drivers/clk/samsung/clk-cpu.h @@ -12,8 +12,16 @@ #define CLK_CPU_HAS_DIV1 BIT(0) /* When ALT parent is active, debug clocks need safe divider values */ #define CLK_CPU_NEEDS_DEBUG_ALT_DIV BIT(1) -/* The CPU clock registers have Exynos5433-compatible layout */ -#define CLK_CPU_HAS_E5433_REGS_LAYOUT BIT(2) + +/** + * enum exynos_cpuclk_layout - CPU clock registers layout compatibility + * @CPUCLK_LAYOUT_E4210: Exynos4210 compatible layout + * @CPUCLK_LAYOUT_E5433: Exynos5433 compatible layout + */ +enum exynos_cpuclk_layout { + CPUCLK_LAYOUT_E4210, + CPUCLK_LAYOUT_E5433, +}; /** * struct exynos_cpuclk_cfg_data - config data to setup cpu clocks diff --git a/drivers/clk/samsung/clk-exynos3250.c b/drivers/clk/samsung/clk-exynos3250.c index bf149fae04c3..cd4fec323a42 100644 --- a/drivers/clk/samsung/clk-exynos3250.c +++ b/drivers/clk/samsung/clk-exynos3250.c @@ -775,7 +775,7 @@ static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = { static const struct samsung_cpu_clock exynos3250_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, - CLK_CPU_HAS_DIV1, 0x14000, e3250_armclk_d), + CLK_CPU_HAS_DIV1, 0x14000, CPUCLK_LAYOUT_E4210, e3250_armclk_d), }; static void __init exynos3_core_down_clock(void __iomem *reg_base) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index d5b1e9f49d8b..a026ccca7315 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1253,19 +1253,19 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = { static const struct samsung_cpu_clock exynos4210_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_SCLK_MPLL, CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, - e4210_armclk_d), + CPUCLK_LAYOUT_E4210, e4210_armclk_d), }; static const struct samsung_cpu_clock exynos4212_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, - e4212_armclk_d), + CPUCLK_LAYOUT_E4210, e4212_armclk_d), }; static const struct samsung_cpu_clock exynos4412_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C, CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000, - e4412_armclk_d), + CPUCLK_LAYOUT_E4210, e4412_armclk_d), }; /* register exynos4 clocks */ diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 58df80de52ef..e02e7c013f3d 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -777,7 +777,8 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = { static const struct samsung_cpu_clock exynos5250_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL, - CLK_CPU_HAS_DIV1, 0x0, exynos5250_armclk_d), + CLK_CPU_HAS_DIV1, 0x0, CPUCLK_LAYOUT_E4210, + exynos5250_armclk_d), }; static const struct of_device_id ext_clk_match[] __initconst = { diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index bd7b304d2c00..c630135c686b 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1556,16 +1556,16 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = { static const struct samsung_cpu_clock exynos5420_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, - 0x0, exynos5420_eglclk_d), + 0x0, CPUCLK_LAYOUT_E4210, exynos5420_eglclk_d), CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, - 0x28000, exynos5420_kfcclk_d), + 0x28000, CPUCLK_LAYOUT_E4210, exynos5420_kfcclk_d), }; static const struct samsung_cpu_clock exynos5800_cpu_clks[] __initconst = { CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, - 0x0, exynos5800_eglclk_d), + 0x0, CPUCLK_LAYOUT_E4210, exynos5800_eglclk_d), CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, - 0x28000, exynos5420_kfcclk_d), + 0x28000, CPUCLK_LAYOUT_E4210, exynos5420_kfcclk_d), }; static const struct of_device_id ext_clk_match[] __initconst = { diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index d3779eefb438..609d31a7aa52 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -3700,8 +3700,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_apolloclk_d[] __initconst static const struct samsung_cpu_clock apollo_cpu_clks[] __initconst = { CPU_CLK(CLK_SCLK_APOLLO, "apolloclk", CLK_MOUT_APOLLO_PLL, - CLK_MOUT_BUS_PLL_APOLLO_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT, - 0x0, exynos5433_apolloclk_d), + CLK_MOUT_BUS_PLL_APOLLO_USER, 0, 0x0, + CPUCLK_LAYOUT_E5433, exynos5433_apolloclk_d), }; static const struct samsung_cmu_info apollo_cmu_info __initconst = { @@ -3944,8 +3944,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_atlasclk_d[] __initconst = static const struct samsung_cpu_clock atlas_cpu_clks[] __initconst = { CPU_CLK(CLK_SCLK_ATLAS, "atlasclk", CLK_MOUT_ATLAS_PLL, - CLK_MOUT_BUS_PLL_ATLAS_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT, - 0x0, exynos5433_atlasclk_d), + CLK_MOUT_BUS_PLL_ATLAS_USER, 0, 0x0, + CPUCLK_LAYOUT_E5433, exynos5433_atlasclk_d), }; static const struct samsung_cmu_info atlas_cmu_info __initconst = { diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 516b716407e5..a763309e6f12 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -12,6 +12,7 @@ #include #include "clk-pll.h" +#include "clk-cpu.h" /** * struct samsung_clk_provider - information about clock provider @@ -282,10 +283,11 @@ struct samsung_cpu_clock { unsigned int alt_parent_id; unsigned long flags; int offset; + enum exynos_cpuclk_layout reg_layout; const struct exynos_cpuclk_cfg_data *cfg; }; -#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _cfg) \ +#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _layout, _cfg) \ { \ .id = _id, \ .name = _name, \ @@ -293,6 +295,7 @@ struct samsung_cpu_clock { .alt_parent_id = _apid, \ .flags = _flags, \ .offset = _offset, \ + .reg_layout = _layout, \ .cfg = _cfg, \ } From patchwork Thu Feb 22 03:02:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566687 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB6E7C48BF6 for ; Thu, 22 Feb 2024 03:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YCNyQ4am06kVo75Y6fVSfA1XxAwPcdWpLhwtAdkt3To=; b=Qa624VwR7yaXkc H9Qr720WOU7l87jxRnY4WSzGlY538k+trzoWFpEOfyL0sPM6Pwwws6zwH6qUiAzO3NnxWxiaPaw4U ZL+JFkizw+GvA8P38HI4A7gqwNDDU5pjrA8kA+N6RV2bM4Nie/KBAf43oB9YZARjhZLaiM7XsST57 vLt7xW5+1G2tgXzCQPnjxsHBUfT85iASUvA65HHb/LZ7KJEAqFFxT8Lws/GHnhTbKvwoQawnLGbiP sjxWyow2lSssa+UvGXfqOgvlwPY1/mBo1dnCUR1wzawnEKmlyEf7OEwn8mjJ6OjNxrVAbDyx6OOJ/ JpyRtTAHUXUfPAUDkpaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMa-00000003J17-0Bqj; Thu, 22 Feb 2024 03:03:08 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMC-00000003Ihd-3iHq for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:46 +0000 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6e2ddc5f31eso3219574a34.0 for ; Wed, 21 Feb 2024 19:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570963; x=1709175763; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PBk7Y8Ruz5aViv1yl0WFjUfmO2mXJGG1dqBCLaRT7+0=; b=HZ6mig7wByc84SRps9Z4NrbxMRBByV/O6Rc8JEcJ3ryvGsTGxRIVGcnKADlf0kO9Ha MhGqmcUqI154jO7QZK6oCYK8obV6LN8jXIZ/u0cSp2BlVzTwdjvsxbhhNQO581i0/1Fy gZFkovYnf1m0zVZcRKM4dSllHlSVkCuO6nrzYJc6tEirj/zpyJptNgoXjkQiRvIH0Su6 OwayT/CX+kEjOqJRFRamb39pF8rhf1PgIUJMksA8CUVQUhtcT9n5iHjJIcKiJL5vT9OL 4IoV0suza3AbiT9oirMEzxa7f3KUqn3yF5aaQ2R+YLxzgO07cb/M+elRffziM7xN3x3e 9vOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570963; x=1709175763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PBk7Y8Ruz5aViv1yl0WFjUfmO2mXJGG1dqBCLaRT7+0=; b=nchf+ccZpOZitxDIhXDEnzozl7/fiZdbwyoG7GPGimjXqNkKew1juIJ9BqqiUT4EbN GTaE9XPN06zrx7YxHoE8LIBrTcol+tM6GgQGG3516zcj47GBvGAZUBVkN+/IH0dhBl9a xeiJILC2Km+is87u93jvbW+Oqfa9grj02zKExxrMlDkU/X7xqb8U8euf9yScqkEnsx6o BbH9RdJ06qgNmGQddDhlzdlFiSxV11PToEDVvF+MLKX4tB9Sx2fkZ8eixziTJHc4kRhh eU+sNk4uBOXMU2cAziaRqAmYp1QNHNZaB9Ue2+iyL4s5b0rBF+QXUFHVSg3aO5TtykhR 4OJQ== X-Forwarded-Encrypted: i=1; AJvYcCWBswl903JePjxT9yuJWMG9GIoDwwMnmou/oxnilyIHBWflFRDe6Y5mMlMjxW3k8X6o1bDUs38GSsYsvLFjWsMMqnc0qFyCM9Teax2dMfWZfeDSu4U= X-Gm-Message-State: AOJu0YxWuFyqsWKsH7tJjW9+EyNGK2NwyAVyKGpns1alByXs+MxheuWn RJwynrpHYjVYqq9IAqNmMUZoAt7f2jr3U1/SKbL+956JgaMWej2yGUqght8KaQ0= X-Google-Smtp-Source: AGHT+IEduzc2fczveJzBJ6rRNR49n+itZJN7bKmoBb8MuqHWSNZ5QV0bRDVJtje0YdwBcLFuDSKAtw== X-Received: by 2002:a05:6871:3427:b0:21e:3ce4:6b68 with SMTP id nh39-20020a056871342700b0021e3ce46b68mr20322356oac.17.1708570963477; Wed, 21 Feb 2024 19:02:43 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id oh25-20020a0568702c9900b0021e7c192093sm2693888oab.27.2024.02.21.19.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:43 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/15] clk: samsung: Keep CPU clock chip specific data in a dedicated struct Date: Wed, 21 Feb 2024 21:02:29 -0600 Message-Id: <20240222030235.27815-10-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190245_026130_D2B0CBFB X-CRM114-Status: GOOD ( 20.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Keep chip specific data in the data structure, don't mix it with code. It makes it easier to add more chip specific data further. Having all chip specific data in the table eliminates possible code bloat when adding more rate handlers for new chips, and also makes it possible to keep some other chip related data in that array. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - Improved the commit message: explained why it's beneficial for new chips to keep chip-specific data in one table drivers/clk/samsung/clk-cpu.c | 40 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 635ab8cc54a2..eb2b67d08f89 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -43,6 +43,16 @@ struct exynos_cpuclk; typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk); +/** + * struct exynos_cpuclk_chip - Chip specific data for CPU clock + * @pre_rate_cb: callback to run before CPU clock rate change + * @post_rate_cb: callback to run after CPU clock rate change + */ +struct exynos_cpuclk_chip { + exynos_rate_change_fn_t pre_rate_cb; + exynos_rate_change_fn_t post_rate_cb; +}; + /** * struct exynos_cpuclk - information about clock supplied to a CPU core * @hw: handle between CCF and CPU clock @@ -55,8 +65,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, * @clk_nb: clock notifier registered for changes in clock speed of the * primary parent clock * @flags: configuration flags for the CPU clock - * @pre_rate_cb: callback to run before CPU clock rate change - * @post_rate_cb: callback to run after CPU clock rate change + * @chip: chip-specific data for the CPU clock * * This structure holds information required for programming the CPU clock for * various clock speeds. @@ -70,9 +79,7 @@ struct exynos_cpuclk { const unsigned long num_cfgs; struct notifier_block clk_nb; unsigned long flags; - - exynos_rate_change_fn_t pre_rate_cb; - exynos_rate_change_fn_t post_rate_cb; + const struct exynos_cpuclk_chip *chip; }; /* ---- Common code --------------------------------------------------------- */ @@ -420,13 +427,24 @@ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, cpuclk = container_of(nb, struct exynos_cpuclk, clk_nb); if (event == PRE_RATE_CHANGE) - err = cpuclk->pre_rate_cb(ndata, cpuclk); + err = cpuclk->chip->pre_rate_cb(ndata, cpuclk); else if (event == POST_RATE_CHANGE) - err = cpuclk->post_rate_cb(ndata, cpuclk); + err = cpuclk->chip->post_rate_cb(ndata, cpuclk); return notifier_from_errno(err); } +static const struct exynos_cpuclk_chip exynos_clkcpu_chips[] = { + [CPUCLK_LAYOUT_E4210] = { + .pre_rate_cb = exynos_cpuclk_pre_rate_change, + .post_rate_cb = exynos_cpuclk_post_rate_change, + }, + [CPUCLK_LAYOUT_E5433] = { + .pre_rate_cb = exynos5433_cpuclk_pre_rate_change, + .post_rate_cb = exynos5433_cpuclk_post_rate_change, + }, +}; + /* helper function to register a CPU clock */ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, const struct samsung_cpu_clock *clk_data) @@ -465,13 +483,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, cpuclk->lock = &ctx->lock; cpuclk->flags = clk_data->flags; cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb; - if (clk_data->reg_layout == CPUCLK_LAYOUT_E5433) { - cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change; - cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change; - } else { - cpuclk->pre_rate_cb = exynos_cpuclk_pre_rate_change; - cpuclk->post_rate_cb = exynos_cpuclk_post_rate_change; - } + cpuclk->chip = &exynos_clkcpu_chips[clk_data->reg_layout]; ret = clk_notifier_register(parent->clk, &cpuclk->clk_nb); if (ret) { From patchwork Thu Feb 22 03:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566690 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A625C48BF6 for ; Thu, 22 Feb 2024 03:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+20esHWxhovz9VyZAmAOmsxuZztNiJuO8FpP4Dvo6Dk=; b=FHpK5ekoH8ZYRG 7mr8b1pzKpk2d5ek59/mNk9BHO6M6MqybAcTIzO8vjLjCZ7SWD7YpH2dJSBLGKYgm6MKnUp2kpx4J 3Czb/nY5VOIfzTJpvzxcXw+2p1eF75gj3r5dmUTNgxESYVPu5h1pKza52xIKHo9fqGM0lQuRKLT6U DePvZKqT5VF7IQ3hYt7vtGxKPdnEBa6YUCqIqmLc8/2CgW+e+JD5F54Gx1oeCVCG51VxNPJkNgGtN 3P8/z3bPXRJ1osuAz21WKGBhVfl+Us8RYMcr8hVwpiPuJzEKjgAk66SFQJJ3Kto/xMvIWWsiHt56T p5duE4NNVw/Jf6uW7i9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMj-00000003J8b-1VHo; Thu, 22 Feb 2024 03:03:17 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMD-00000003IiG-3aNS for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:47 +0000 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3c1652613d3so1912336b6e.1 for ; Wed, 21 Feb 2024 19:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570964; x=1709175764; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WLV8v3CcYjUxTEWneEGvsrWUwTNHLYZ7N1DRE9MQk+A=; b=jsb+5IUbLpUoERUgR9JgMLSColrqhAv1ICfcE3WvXUV3PjfgC0QSHz1mRn22GeC2yN R7JzaT/WsHwmKPXEhdTG6uGtAAc2Zj+YKxBMAwz2AkqGqLVe9/9SVam4FB/QF8q37MLw rNJq2Q8OZMR3mcco+50Ds2rNxVyn6izWxfXqmuBAa7sDUykyf/17SeVDM9YLOKKEZKf0 n394rTR9GinX4PnTKTSfrvm4DbmsNeuMd46TbUi84dY+GnKwfUCv4ZYf+GaFEfqmgqww Iha7Vbwe/yZgkRQ1RUDDgXlehBwrzAC7Tk+oM6PkE6iN548LBeG1m1lNYsNS4uYK9sJi mOpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570964; x=1709175764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WLV8v3CcYjUxTEWneEGvsrWUwTNHLYZ7N1DRE9MQk+A=; b=G1c21ws5zqq3gsaj4gzszYb6tHQ7KluNUReB/6LNVB6Hw0/XE1+pmFOkwxqTcznBcf jZYUg6WyaE0uHCbVIzlssISiH7IEkNbdTw1WjaATrl/ulP0EGi5M+OnSYENaxaRy+gFt 1UgA/icCIMp9UCo2Q9N0Ff7Uo3OE318YZfF41IwIpsmDyV2tronyMBw2mrl3YO3oDSuB +sjVZ4cAMMnTal5W83s8w/XsYpyZqvR74979ZZ83f82cTx+c+ResmPJX2eQ65GImMMwm 5myrPinwy5HG7JxVQPaEQNAX9I/difmLvHvBUwZ0I0zyG8yZBNuYgT5P7wVOU7RD4b4H kOvw== X-Forwarded-Encrypted: i=1; AJvYcCUAHvHwSaeIKuf0B0IU7hjbtGDMXwDMsnUBV25qMLeaaMe79uKz13FnPzXu9ul5cj/40KlUOZLkjc/POFyY1sufo1jOZL1oiVtADLoZNBZkGPP8tjo= X-Gm-Message-State: AOJu0YxYSa1Z2QNDaiHCoVgwnWQmIYfy8tf9wel6NzjAo+yjW6r8qE8X OQfifZsOL4m7m/FAjlh0gdu4J4iu3+JUydu84/bH/Ib7vhVkVXAz1xEem/N3NKY= X-Google-Smtp-Source: AGHT+IFe5waa959GOw8PZleYdP90gu28MGZdSE3LmrZpyAIfrPV3sLmGJBJzt0a94Y6VJ2jzZGtcCQ== X-Received: by 2002:a05:6808:2207:b0:3c1:3a97:7be5 with SMTP id bd7-20020a056808220700b003c13a977be5mr23622514oib.21.1708570964405; Wed, 21 Feb 2024 19:02:44 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id c26-20020aca1c1a000000b003c03563cedesm1773341oic.28.2024.02.21.19.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:43 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/15] clk: samsung: Keep register offsets in chip specific structure Date: Wed, 21 Feb 2024 21:02:30 -0600 Message-Id: <20240222030235.27815-11-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190245_960469_C873C4F9 X-CRM114-Status: GOOD ( 23.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Abstract CPU clock registers by keeping their offsets in a dedicated chip specific structure to accommodate for oncoming Exynos850 support, which has different offsets for cluster 0 and cluster 1. This rework also makes it possible to use exynos_set_safe_div() for all chips, so exynos5433_set_safe_div() is removed here to reduce the code duplication. The ".regs" field has to be (void *) as different Exynos chips can have very different register layout, so this way it's possible for ".regs" to point to different structures, each representing its own chip's layout. No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - Improved the commit message: explained why .regs field has to be (void *) - Changed .ctrl_base field to .base to reflect changes in previous commits drivers/clk/samsung/clk-cpu.c | 156 +++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 70 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index eb2b67d08f89..93e961855875 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -45,12 +45,14 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata, /** * struct exynos_cpuclk_chip - Chip specific data for CPU clock + * @regs: register offsets for CPU related clocks * @pre_rate_cb: callback to run before CPU clock rate change * @post_rate_cb: callback to run after CPU clock rate change */ struct exynos_cpuclk_chip { - exynos_rate_change_fn_t pre_rate_cb; - exynos_rate_change_fn_t post_rate_cb; + const void * const regs; + exynos_rate_change_fn_t pre_rate_cb; + exynos_rate_change_fn_t post_rate_cb; }; /** @@ -91,6 +93,24 @@ struct exynos_cpuclk { #define DIV_MASK_ALL GENMASK(31, 0) #define MUX_MASK GENMASK(2, 0) +/** + * struct exynos_cpuclk_regs - Register offsets for CPU related clocks + * @mux_sel: offset of CPU MUX_SEL register (for selecting MUX clock parent) + * @mux_stat: offset of CPU MUX_STAT register (for checking MUX clock status) + * @div_cpu0: offset of CPU DIV0 register (for modifying divider values) + * @div_cpu1: offset of CPU DIV1 register (for modifying divider values) + * @div_stat_cpu0: offset of CPU DIV0_STAT register (for checking DIV status) + * @div_stat_cpu1: offset of CPU DIV1_STAT register (for checking DIV status) + */ +struct exynos_cpuclk_regs { + u32 mux_sel; + u32 mux_stat; + u32 div_cpu0; + u32 div_cpu1; + u32 div_stat_cpu0; + u32 div_stat_cpu1; +}; + /* * Helper function to wait until divider(s) have stabilized after the divider * value has changed. @@ -130,43 +150,48 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, pr_err("%s: re-parenting mux timed-out\n", __func__); } -/* ---- Exynos 3/4/5 -------------------------------------------------------- */ - -#define E4210_SRC_CPU 0x200 -#define E4210_STAT_CPU 0x400 -#define E4210_DIV_CPU0 0x500 -#define E4210_DIV_CPU1 0x504 -#define E4210_DIV_STAT_CPU0 0x600 -#define E4210_DIV_STAT_CPU1 0x604 - -#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) -#define E4210_DIV1_HPM_MASK GENMASK(6, 4) -#define E4210_DIV1_COPY_MASK GENMASK(2, 0) -#define E4210_MUX_HPM_MASK BIT(20) -#define E4210_DIV0_ATB_SHIFT 16 -#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT) - /* * Helper function to set the 'safe' dividers for the CPU clock. The parameters * div and mask contain the divider value and the register bit mask of the * dividers to be programmed. */ -static void exynos_set_safe_div(void __iomem *base, unsigned long div, +static void exynos_set_safe_div(struct exynos_cpuclk *cpuclk, unsigned long div, unsigned long mask) { + const struct exynos_cpuclk_regs * const regs = cpuclk->chip->regs; + void __iomem *base = cpuclk->base; unsigned long div0; - div0 = readl(base + E4210_DIV_CPU0); + div0 = readl(base + regs->div_cpu0); div0 = (div0 & ~mask) | (div & mask); - writel(div0, base + E4210_DIV_CPU0); - wait_until_divider_stable(base + E4210_DIV_STAT_CPU0, mask); + writel(div0, base + regs->div_cpu0); + wait_until_divider_stable(base + regs->div_stat_cpu0, mask); } +/* ---- Exynos 3/4/5 -------------------------------------------------------- */ + +#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0) +#define E4210_DIV1_HPM_MASK GENMASK(6, 4) +#define E4210_DIV1_COPY_MASK GENMASK(2, 0) +#define E4210_MUX_HPM_MASK BIT(20) +#define E4210_DIV0_ATB_SHIFT 16 +#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT) + +static const struct exynos_cpuclk_regs e4210_cpuclk_regs = { + .mux_sel = 0x200, + .mux_stat = 0x400, + .div_cpu0 = 0x500, + .div_cpu1 = 0x504, + .div_stat_cpu0 = 0x600, + .div_stat_cpu1 = 0x604, +}; + /* handler for pre-rate change notification from parent clock */ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + const struct exynos_cpuclk_regs * const regs = cpuclk->chip->regs; void __iomem *base = cpuclk->base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; @@ -189,8 +214,8 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, div0 = cfg_data->div0; if (cpuclk->flags & CLK_CPU_HAS_DIV1) { div1 = cfg_data->div1; - if (readl(base + E4210_SRC_CPU) & E4210_MUX_HPM_MASK) - div1 = readl(base + E4210_DIV_CPU1) & + if (readl(base + regs->mux_sel) & E4210_MUX_HPM_MASK) + div1 = readl(base + regs->div_cpu1) & (E4210_DIV1_HPM_MASK | E4210_DIV1_COPY_MASK); } @@ -217,22 +242,22 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, alt_div |= E4210_DIV0_ATB_MASK; alt_div_mask |= E4210_DIV0_ATB_MASK; } - exynos_set_safe_div(base, alt_div, alt_div_mask); + exynos_set_safe_div(cpuclk, alt_div, alt_div_mask); div0 |= alt_div; } /* select sclk_mpll as the alternate parent */ - mux_reg = readl(base + E4210_SRC_CPU); - writel(mux_reg | (1 << 16), base + E4210_SRC_CPU); - wait_until_mux_stable(base + E4210_STAT_CPU, 16, 2); + mux_reg = readl(base + regs->mux_sel); + writel(mux_reg | (1 << 16), base + regs->mux_sel); + wait_until_mux_stable(base + regs->mux_stat, 16, 2); /* alternate parent is active now. set the dividers */ - writel(div0, base + E4210_DIV_CPU0); - wait_until_divider_stable(base + E4210_DIV_STAT_CPU0, DIV_MASK_ALL); + writel(div0, base + regs->div_cpu0); + wait_until_divider_stable(base + regs->div_stat_cpu0, DIV_MASK_ALL); if (cpuclk->flags & CLK_CPU_HAS_DIV1) { - writel(div1, base + E4210_DIV_CPU1); - wait_until_divider_stable(base + E4210_DIV_STAT_CPU1, + writel(div1, base + regs->div_cpu1); + wait_until_divider_stable(base + regs->div_stat_cpu1, DIV_MASK_ALL); } @@ -245,6 +270,7 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + const struct exynos_cpuclk_regs * const regs = cpuclk->chip->regs; void __iomem *base = cpuclk->base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; @@ -262,50 +288,37 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, spin_lock_irqsave(cpuclk->lock, flags); /* select mout_apll as the alternate parent */ - mux_reg = readl(base + E4210_SRC_CPU); - writel(mux_reg & ~(1 << 16), base + E4210_SRC_CPU); - wait_until_mux_stable(base + E4210_STAT_CPU, 16, 1); + mux_reg = readl(base + regs->mux_sel); + writel(mux_reg & ~(1 << 16), base + regs->mux_sel); + wait_until_mux_stable(base + regs->mux_stat, 16, 1); if (cpuclk->flags & CLK_CPU_NEEDS_DEBUG_ALT_DIV) { div |= (cfg_data->div0 & E4210_DIV0_ATB_MASK); div_mask |= E4210_DIV0_ATB_MASK; } - exynos_set_safe_div(base, div, div_mask); + exynos_set_safe_div(cpuclk, div, div_mask); spin_unlock_irqrestore(cpuclk->lock, flags); return 0; } /* ---- Exynos5433 ---------------------------------------------------------- */ -#define E5433_MUX_SEL2 0x208 -#define E5433_MUX_STAT2 0x408 -#define E5433_DIV_CPU0 0x600 -#define E5433_DIV_CPU1 0x604 -#define E5433_DIV_STAT_CPU0 0x700 -#define E5433_DIV_STAT_CPU1 0x704 - -/* - * Helper function to set the 'safe' dividers for the CPU clock. The parameters - * div and mask contain the divider value and the register bit mask of the - * dividers to be programmed. - */ -static void exynos5433_set_safe_div(void __iomem *base, unsigned long div, - unsigned long mask) -{ - unsigned long div0; - - div0 = readl(base + E5433_DIV_CPU0); - div0 = (div0 & ~mask) | (div & mask); - writel(div0, base + E5433_DIV_CPU0); - wait_until_divider_stable(base + E5433_DIV_STAT_CPU0, mask); -} +static const struct exynos_cpuclk_regs e5433_cpuclk_regs = { + .mux_sel = 0x208, + .mux_stat = 0x408, + .div_cpu0 = 0x600, + .div_cpu1 = 0x604, + .div_stat_cpu0 = 0x700, + .div_stat_cpu1 = 0x704, +}; /* handler for pre-rate change notification from parent clock */ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + const struct exynos_cpuclk_regs * const regs = cpuclk->chip->regs; void __iomem *base = cpuclk->base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; @@ -342,21 +355,21 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, alt_div = DIV_ROUND_UP(alt_prate, tmp_rate) - 1; WARN_ON(alt_div >= MAX_DIV); - exynos5433_set_safe_div(base, alt_div, alt_div_mask); + exynos_set_safe_div(cpuclk, alt_div, alt_div_mask); div0 |= alt_div; } /* select the alternate parent */ - mux_reg = readl(base + E5433_MUX_SEL2); - writel(mux_reg | 1, base + E5433_MUX_SEL2); - wait_until_mux_stable(base + E5433_MUX_STAT2, 0, 2); + mux_reg = readl(base + regs->mux_sel); + writel(mux_reg | 1, base + regs->mux_sel); + wait_until_mux_stable(base + regs->mux_stat, 0, 2); /* alternate parent is active now. set the dividers */ - writel(div0, base + E5433_DIV_CPU0); - wait_until_divider_stable(base + E5433_DIV_STAT_CPU0, DIV_MASK_ALL); + writel(div0, base + regs->div_cpu0); + wait_until_divider_stable(base + regs->div_stat_cpu0, DIV_MASK_ALL); - writel(div1, base + E5433_DIV_CPU1); - wait_until_divider_stable(base + E5433_DIV_STAT_CPU1, DIV_MASK_ALL); + writel(div1, base + regs->div_cpu1); + wait_until_divider_stable(base + regs->div_stat_cpu1, DIV_MASK_ALL); spin_unlock_irqrestore(cpuclk->lock, flags); return 0; @@ -366,6 +379,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, struct exynos_cpuclk *cpuclk) { + const struct exynos_cpuclk_regs * const regs = cpuclk->chip->regs; void __iomem *base = cpuclk->base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; @@ -374,11 +388,11 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, spin_lock_irqsave(cpuclk->lock, flags); /* select apll as the alternate parent */ - mux_reg = readl(base + E5433_MUX_SEL2); - writel(mux_reg & ~1, base + E5433_MUX_SEL2); - wait_until_mux_stable(base + E5433_MUX_STAT2, 0, 1); + mux_reg = readl(base + regs->mux_sel); + writel(mux_reg & ~1, base + regs->mux_sel); + wait_until_mux_stable(base + regs->mux_stat, 0, 1); - exynos5433_set_safe_div(base, div, div_mask); + exynos_set_safe_div(cpuclk, div, div_mask); spin_unlock_irqrestore(cpuclk->lock, flags); return 0; } @@ -436,10 +450,12 @@ static int exynos_cpuclk_notifier_cb(struct notifier_block *nb, static const struct exynos_cpuclk_chip exynos_clkcpu_chips[] = { [CPUCLK_LAYOUT_E4210] = { + .regs = &e4210_cpuclk_regs, .pre_rate_cb = exynos_cpuclk_pre_rate_change, .post_rate_cb = exynos_cpuclk_post_rate_change, }, [CPUCLK_LAYOUT_E5433] = { + .regs = &e5433_cpuclk_regs, .pre_rate_cb = exynos5433_cpuclk_pre_rate_change, .post_rate_cb = exynos5433_cpuclk_post_rate_change, }, From patchwork Thu Feb 22 03:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566688 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFC41C48BEB for ; Thu, 22 Feb 2024 03:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uj9XZr3Iz4hwv+qcC1efgAWZQ0I5C9+yQYddebcSQXE=; b=vM3Ll8apEHKP4r SEKhUa5Nh1/flHly/e1ww9mRGEL9iCP5PmSF7TwPRhDzy59suHO/U+8YzSVRct2Q20h+45Ify8Jda ohSJrOGB2HaU+fC2X6JLLuDSfPUywq43HbouyxZGMQXbXrxOcab4+WZF8wgX08tt24MLC9ISHzdMW LN33eJTkVp2FivmD2gepBFFMbKQflNYKcxEymjWY9mhX0wQKRCCyBi8Kac3EH3ZErQ49Xgzw5th8o nDDfxJxg6MHwTKrKKcjyYAbUOhUsWOotUT4CcYgw+aMXVZP+8dJll5NbN/NUPv4AhNN/vcMavXIha px3cyD0k0cf6Ir2psn9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMe-00000003J4V-1uzX; Thu, 22 Feb 2024 03:03:12 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMD-00000003Iih-4Bn2 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:47 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3c03b92998eso5532931b6e.3 for ; Wed, 21 Feb 2024 19:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570965; x=1709175765; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gr/yHix3JzjuluFq1TtfZCC5Pd9Qq4G1cyD4GVYOtnc=; b=L/jpxJ4wwrgVk8JfytXbHtqXj9N610LUbhNOki12trG91w/wGLA/5xCOskaZ83WQXk onDtcLU8iQmQiwvSJzA75HeNKfeGh+vGxIasLfrzgzNurZGCoImc/kLm2iILCxgelx5m B4dDBw8dZterJWf7IasFQMggBD107myzvnjtz0CFL4ZE8jJv7qZlYpZ8XvsjgyNXPpw/ h+aGeoUkdAEqydl13gQHg95MbNnho7I/nv2xC58pzDtXKYlj1OH0QAnLgCRWjquO/I0+ aJvbd7PREBKVuWo5T+xPsdVn+Bwj7QBPmREh4b9M+Tz/NRuQzHPm1Cq4/7MqAkac2+b0 PkWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570965; x=1709175765; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gr/yHix3JzjuluFq1TtfZCC5Pd9Qq4G1cyD4GVYOtnc=; b=lRS7/Iyx3wMCXuX38NRGv7uY8SFYlo0YKD0xdbCMcHc/1BK4iciyuQEiHbLK5G135G kYB5b2XOxC+yZn23AEgSRMxQDRlzsHnesM2KYIa8PG2T4Pc2u91sGborVC/s1D0cQIP6 FjDbQ5U+8j5I74csAfvck8VhU4E3PRh2wI+T/wdFoVwFaxHIT9IrjqpD2TiAfcTH3wsW LABfXNnz+ucsZADfxQ6NUvxUG/pA28HbzUddhhHDcx3+zOkXrKHpAHdqgjx/HQNZ8/nC SaTxSjHOm3cWPbeLyul2co82LlntFJjMBk7HwKToApxuAYZ4eMSpl0d0doTHVd71dKQ5 XKOQ== X-Forwarded-Encrypted: i=1; AJvYcCVPA+XjVDfN/8GZef7SdUBiIn7zFJVHLxebDVMxDJRMlLsHLtDmCf575Wpt8xjlhRevC/JozHSlLc8u77u9f2QVNGKdmc36u9HSeBbQZ6kxm3KQFlg= X-Gm-Message-State: AOJu0Yw/7RIEiaWpVw4yCup/QeKbAUVoSed3W59ftDRh2OAElLL0JS4t RgxYp+/2QCZcUuh20hjT1ikQG4mrANoPmrR33d1h4gxu5tFUFiKu/fd4Qt+1m0Rwk53vstWg8lO s X-Google-Smtp-Source: AGHT+IFHuTnKt7JYDZvxQi+WgqtjmOJmqsoXRWbTXMzeK2gAjybtMBRv5ln2nAtoh8f1dwanim8zMA== X-Received: by 2002:a05:6871:1ca:b0:21e:635c:a5b8 with SMTP id q10-20020a05687101ca00b0021e635ca5b8mr17215407oad.26.1708570965242; Wed, 21 Feb 2024 19:02:45 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id sk14-20020a056871800e00b0021ec89a1a2asm1937031oab.32.2024.02.21.19.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:44 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 11/15] clk: samsung: Pass mask to wait_until_mux_stable() Date: Wed, 21 Feb 2024 21:02:31 -0600 Message-Id: <20240222030235.27815-12-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190246_088157_710B0DCA X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make it possible to use wait_until_mux_stable() for MUX registers where the mask is different from MUX_MASK (e.g. in upcoming CPU clock implementation for Exynos850). No functional change. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-cpu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 93e961855875..89b24fd5d0a9 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -135,16 +135,16 @@ static void wait_until_divider_stable(void __iomem *div_reg, unsigned long mask) * value was changed. */ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos, - unsigned long mux_value) + unsigned long mask, unsigned long mux_value) { unsigned long timeout = jiffies + msecs_to_jiffies(MAX_STAB_TIME); do { - if (((readl(mux_reg) >> mux_pos) & MUX_MASK) == mux_value) + if (((readl(mux_reg) >> mux_pos) & mask) == mux_value) return; } while (time_before(jiffies, timeout)); - if (((readl(mux_reg) >> mux_pos) & MUX_MASK) == mux_value) + if (((readl(mux_reg) >> mux_pos) & mask) == mux_value) return; pr_err("%s: re-parenting mux timed-out\n", __func__); @@ -249,7 +249,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, /* select sclk_mpll as the alternate parent */ mux_reg = readl(base + regs->mux_sel); writel(mux_reg | (1 << 16), base + regs->mux_sel); - wait_until_mux_stable(base + regs->mux_stat, 16, 2); + wait_until_mux_stable(base + regs->mux_stat, 16, MUX_MASK, 2); /* alternate parent is active now. set the dividers */ writel(div0, base + regs->div_cpu0); @@ -290,7 +290,7 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata, /* select mout_apll as the alternate parent */ mux_reg = readl(base + regs->mux_sel); writel(mux_reg & ~(1 << 16), base + regs->mux_sel); - wait_until_mux_stable(base + regs->mux_stat, 16, 1); + wait_until_mux_stable(base + regs->mux_stat, 16, MUX_MASK, 1); if (cpuclk->flags & CLK_CPU_NEEDS_DEBUG_ALT_DIV) { div |= (cfg_data->div0 & E4210_DIV0_ATB_MASK); @@ -362,7 +362,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, /* select the alternate parent */ mux_reg = readl(base + regs->mux_sel); writel(mux_reg | 1, base + regs->mux_sel); - wait_until_mux_stable(base + regs->mux_stat, 0, 2); + wait_until_mux_stable(base + regs->mux_stat, 0, MUX_MASK, 2); /* alternate parent is active now. set the dividers */ writel(div0, base + regs->div_cpu0); @@ -390,7 +390,7 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, /* select apll as the alternate parent */ mux_reg = readl(base + regs->mux_sel); writel(mux_reg & ~1, base + regs->mux_sel); - wait_until_mux_stable(base + regs->mux_stat, 0, 1); + wait_until_mux_stable(base + regs->mux_stat, 0, MUX_MASK, 1); exynos_set_safe_div(cpuclk, div, div_mask); spin_unlock_irqrestore(cpuclk->lock, flags); From patchwork Thu Feb 22 03:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566689 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6FC8C48BEB for ; Thu, 22 Feb 2024 03:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2YI7zLFumETOk4VRUNimXBX2ficYpo8A7S66LdlRuw4=; b=ezLPdwUII6J/5t w/s/dk6piT+bAwLEX7ntXgfJr6GwIHNNtmmOcZz4Zj4iY4QrvCMt7OI1/KwGK+IvfsmzQXa8Y/oNf XLxeu74dYY2XEPQFTSeKS9UxtL3/nqC0nXPLUH+fIzXzXwVIV1vdssPsPVOvkFBwCZDoR2PQxslBv TAZvyJUqvW9YzvF4uQafB/2iaW9l/ud2HNBec1gzGPuiUv1z81SRA4gQAANYKyoXsl1PsY/c/GBtx YSSbFi0ZVhlo0UAHzABITL6gZRtRaKyLKvJJs+gs6/bm0oacnShBFzSo7mlQC5rLJ/jJR8dhAj0FU R6YV7VCYZ/R8/IPwqiwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMn-00000003JCV-1mnX; Thu, 22 Feb 2024 03:03:21 +0000 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMF-00000003IjW-3PrN for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:49 +0000 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3c17ac08a38so83478b6e.1 for ; Wed, 21 Feb 2024 19:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570966; x=1709175766; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xu/V/yIxxPTU9BuvQgksMezTJmyKx+N2w/iRf/Kb/uE=; b=Q4gFcfuEItZg8zv9jokz7gCc/9JJPYH9MyLqoC4crT29LBwJzmlT7dhn2qIvnIAUwB TnOsS1JfH5X+tgu9HZCJ584GVcB/k9SlBYLeI1m/jI0EbsBGTCqRDTV4AtU/3bMNfLuG oPRT25MwPS+nEklkjTWO8xe0xKrb837fe/ZvqUgCUnVDsp5fqkkLPD+LGbW6URboBHDJ IXFLOdCUKlTxvomEmFivLWiWxVo9TFbIEyQyfmApMxsYt2BiUvTIEKnvK0IwHIQwUmoJ vd0zNYCrMWybdkHyygdJJHVCxKOJkyfU0HhndeYlLs804Hx6Ezs/Had9I0QfRa6t81Vt 9CUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570966; x=1709175766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xu/V/yIxxPTU9BuvQgksMezTJmyKx+N2w/iRf/Kb/uE=; b=LZVXMSnPLk5oq0Vd90MIvOrLkonYHJPnEBu8l6UXiSFXEcfkfYUBFLR7SZtIXxweGu 3BQjBkBgdR44BZLHzgWjNNYu+UzeEpPzQoyEcgHQlq1tXClk7wcEscA6G/Z1TiHnuS04 pxGQk6MF6n1SidG3S9a8fVZuf3jbjVrs+LKQRxDMiL6urFVoKQC6h5mC5r2DFH23Piax eEcR05g51kDw+MZQ/K9cwlOKuvmEXDTLv4+gKcHrxPRt3x4ffEoOM0L0lC+Co+K/8MLp wiJK8SZoZrb9tRWQIJk5hJSkRofdOyJn0D6rpBUTEyILYhWOMpPz5uZ0Onq++cUnPL3d 4zJQ== X-Forwarded-Encrypted: i=1; AJvYcCUYQdMErBgpR4MRNh7bv/YDS/2bCNTIRmbUmHeOZ0FOdiQKNRBVegOR1m8SFAT2TOBhHLdCHTczTa/7d7AUosD1OP+ZQyTnmSC+r5iz5EYeSf0Ztgs= X-Gm-Message-State: AOJu0Yx9zQopTsmBoFJAKQWpctEutbbfE86U1miTnLf2M2Pp9FE2UF7C yI21M6V+hpXo5YSwetgT8mYrafCFEPdc6yNYSyGNLs/b7ZBymoFRDpuRQD63Vgw= X-Google-Smtp-Source: AGHT+IHPfXGtwYRjqJtRE72B3DjWSJUtuvJRZsdgap9ekkYqdlVlAd1Lwfog12HtnZSLtW81xSOjAg== X-Received: by 2002:a05:6808:1642:b0:3c0:4d21:e62a with SMTP id az2-20020a056808164200b003c04d21e62amr24604480oib.31.1708570966119; Wed, 21 Feb 2024 19:02:46 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id d28-20020a05680808fc00b003c16c9977d5sm587777oic.21.2024.02.21.19.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:45 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/15] clk: samsung: Add CPU clock support for Exynos850 Date: Wed, 21 Feb 2024 21:02:32 -0600 Message-Id: <20240222030235.27815-13-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190247_942498_49E9F47E X-CRM114-Status: GOOD ( 33.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement CPU clock control for Exynos850 SoC. It follows the same procedure which is already implemented for other SoCs in clk-cpu.c: 1. Set the correct rate for the alternate parent (if needed) before switching to use it as the CPU clock 2. Switch to the alternate parent, so the CPU continues to get clocked while the PLL is being re-configured 3. Adjust the dividers for the CPU related buses (ACLK, ATCLK, etc) 4. Re-configure the PLL for the new CPU clock rate. It's done automatically, as the CPU clock rate change propagates to the PLL clock, because the CPU clock has CLK_SET_RATE_PARENT flag set in exynos_register_cpu_clock() 5. Once the PLL is locked, set it back as the CPU clock source 6. Set alternate parent clock rate back to max speed As in already existing clk-cpu.c code, the divider and mux clocks are configured in a low-level fashion (using direct register access instead of CCF API), to avoid affecting how DIV and MUX clock flags are declared in the actual clock driver (clk-exynos850.c). No functional change. This patch adds support for Exynos850 CPU clock, but doesn't enable it per se. Signed-off-by: Sam Protsenko --- Changes in v2: - Changed .ctrl_base field to .base, to reflect changes made in previous commits drivers/clk/samsung/clk-cpu.c | 183 ++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-cpu.h | 4 + 2 files changed, 187 insertions(+) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 89b24fd5d0a9..34c195a980b2 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -29,6 +29,7 @@ * down in order to keep the output clock rate within the previous OPP limits. */ +#include #include #include #include @@ -397,6 +398,178 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata, return 0; } +/* ---- Exynos850 ----------------------------------------------------------- */ + +#define E850_DIV_RATIO_MASK GENMASK(3, 0) +#define E850_BUSY_MASK BIT(16) + +/* Max time for divider or mux to stabilize, usec */ +#define E850_DIV_MUX_STAB_TIME 100 +/* OSCCLK clock rate, Hz */ +#define E850_OSCCLK (26 * MHZ) + +/** + * struct exynos850_cpuclk_regs - Register offsets for Exynos850 CPU clocks + * @mux: offset of MUX register for choosing CPU clock source + * @divs: offsets of DIV registers (ACLK, ATCLK, PCLKDBG and + * PERIPHCLK) + */ +struct exynos850_cpuclk_regs { + u32 mux; + u32 divs[4]; +}; + +static const struct exynos850_cpuclk_regs e850cl0_cpuclk_regs = { + .mux = 0x100c, + .divs = { 0x1800, 0x1808, 0x180c, 0x1810 }, +}; + +static const struct exynos850_cpuclk_regs e850cl1_cpuclk_regs = { + .mux = 0x1000, + .divs = { 0x1800, 0x1808, 0x180c, 0x1810 }, +}; + +/* + * Set alternate parent rate to "rate" value or less. + * + * rate: Desired alt_parent rate, or 0 for max alt_parent rate + * + * Exynos850 doesn't have CPU clock divider in CMU_CPUCLx block (CMUREF divider + * doesn't affect CPU speed). So CPUCLx_SWITCH divider from CMU_TOP is used + * instead to adjust alternate parent speed. + * + * It's possible to use clk_set_max_rate() instead of this function, but it + * would set overly pessimistic rate values to alternate parent. + */ +static int exynos850_alt_parent_set_max_rate(const struct clk_hw *alt_parent, + unsigned long rate) +{ + struct clk_hw *clk_div, *clk_divp; + unsigned long divp_rate, div_rate, div; + int ret; + + /* Divider from CMU_TOP */ + clk_div = clk_hw_get_parent(alt_parent); + if (!clk_div) + return -ENOENT; + /* Divider's parent from CMU_TOP */ + clk_divp = clk_hw_get_parent(clk_div); + if (!clk_divp) + return -ENOENT; + /* Divider input rate */ + divp_rate = clk_hw_get_rate(clk_divp); + if (!divp_rate) + return -EINVAL; + + /* Calculate new alt_parent rate for integer divider value */ + if (rate == 0) + div = 1; + else + div = DIV_ROUND_UP(divp_rate, rate); + div_rate = DIV_ROUND_UP(divp_rate, div); + WARN_ON(div >= MAX_DIV); + + /* alt_parent will propagate this change up to the divider */ + ret = clk_set_rate(alt_parent->clk, div_rate); + if (ret) + return ret; + udelay(E850_DIV_MUX_STAB_TIME); + + return 0; +} + +/* Handler for pre-rate change notification from parent clock */ +static int exynos850_cpuclk_pre_rate_change(struct clk_notifier_data *ndata, + struct exynos_cpuclk *cpuclk) +{ + const unsigned int shifts[4] = { 16, 12, 8, 4 }; /* E850_CPU_DIV0() */ + const struct exynos850_cpuclk_regs * const regs = cpuclk->chip->regs; + const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg; + const struct clk_hw *alt_parent = cpuclk->alt_parent; + void __iomem *base = cpuclk->base; + unsigned long alt_prate = clk_hw_get_rate(alt_parent); + unsigned long flags; + u32 mux_reg; + size_t i; + int ret; + + /* No actions are needed when switching to or from OSCCLK parent */ + if (ndata->new_rate == E850_OSCCLK || ndata->old_rate == E850_OSCCLK) + return 0; + + /* Find out the divider values to use for clock data */ + while ((cfg_data->prate * 1000) != ndata->new_rate) { + if (cfg_data->prate == 0) + return -EINVAL; + cfg_data++; + } + + /* + * If the old parent clock speed is less than the clock speed of + * the alternate parent, then it should be ensured that at no point + * the armclk speed is more than the old_prate until the dividers are + * set. Also workaround the issue of the dividers being set to lower + * values before the parent clock speed is set to new lower speed + * (this can result in too high speed of armclk output clocks). + */ + if (alt_prate > ndata->old_rate || ndata->old_rate > ndata->new_rate) { + unsigned long tmp_rate = min(ndata->old_rate, ndata->new_rate); + + ret = exynos850_alt_parent_set_max_rate(alt_parent, tmp_rate); + if (ret) + return ret; + } + + spin_lock_irqsave(cpuclk->lock, flags); + + /* Select the alternate parent */ + mux_reg = readl(base + regs->mux); + writel(mux_reg | 1, base + regs->mux); + wait_until_mux_stable(base + regs->mux, 16, 1, 0); + + /* Alternate parent is active now. Set the dividers */ + for (i = 0; i < ARRAY_SIZE(shifts); ++i) { + unsigned long div = (cfg_data->div0 >> shifts[i]) & 0xf; + u32 val; + + val = readl(base + regs->divs[i]); + val = (val & ~E850_DIV_RATIO_MASK) | div; + writel(val, base + regs->divs[i]); + wait_until_divider_stable(base + regs->divs[i], E850_BUSY_MASK); + } + + spin_unlock_irqrestore(cpuclk->lock, flags); + + return 0; +} + +/* Handler for post-rate change notification from parent clock */ +static int exynos850_cpuclk_post_rate_change(struct clk_notifier_data *ndata, + struct exynos_cpuclk *cpuclk) +{ + const struct exynos850_cpuclk_regs * const regs = cpuclk->chip->regs; + const struct clk_hw *alt_parent = cpuclk->alt_parent; + void __iomem *base = cpuclk->base; + unsigned long flags; + u32 mux_reg; + + /* No actions are needed when switching to or from OSCCLK parent */ + if (ndata->new_rate == E850_OSCCLK || ndata->old_rate == E850_OSCCLK) + return 0; + + spin_lock_irqsave(cpuclk->lock, flags); + + /* Select main parent (PLL) for mux */ + mux_reg = readl(base + regs->mux); + writel(mux_reg & ~1, base + regs->mux); + wait_until_mux_stable(base + regs->mux, 16, 1, 0); + + spin_unlock_irqrestore(cpuclk->lock, flags); + + /* Set alt_parent rate back to max */ + return exynos850_alt_parent_set_max_rate(alt_parent, 0); +} + /* -------------------------------------------------------------------------- */ /* Common round rate callback usable for all types of CPU clocks */ @@ -459,6 +632,16 @@ static const struct exynos_cpuclk_chip exynos_clkcpu_chips[] = { .pre_rate_cb = exynos5433_cpuclk_pre_rate_change, .post_rate_cb = exynos5433_cpuclk_post_rate_change, }, + [CPUCLK_LAYOUT_E850_CL0] = { + .regs = &e850cl0_cpuclk_regs, + .pre_rate_cb = exynos850_cpuclk_pre_rate_change, + .post_rate_cb = exynos850_cpuclk_post_rate_change, + }, + [CPUCLK_LAYOUT_E850_CL1] = { + .regs = &e850cl1_cpuclk_regs, + .pre_rate_cb = exynos850_cpuclk_pre_rate_change, + .post_rate_cb = exynos850_cpuclk_post_rate_change, + }, }; /* helper function to register a CPU clock */ diff --git a/drivers/clk/samsung/clk-cpu.h b/drivers/clk/samsung/clk-cpu.h index 4382ab005ad3..892843611b0a 100644 --- a/drivers/clk/samsung/clk-cpu.h +++ b/drivers/clk/samsung/clk-cpu.h @@ -17,10 +17,14 @@ * enum exynos_cpuclk_layout - CPU clock registers layout compatibility * @CPUCLK_LAYOUT_E4210: Exynos4210 compatible layout * @CPUCLK_LAYOUT_E5433: Exynos5433 compatible layout + * @CPUCLK_LAYOUT_E850_CL0: Exynos850 cluster 0 compatible layout + * @CPUCLK_LAYOUT_E850_CL1: Exynos850 cluster 1 compatible layout */ enum exynos_cpuclk_layout { CPUCLK_LAYOUT_E4210, CPUCLK_LAYOUT_E5433, + CPUCLK_LAYOUT_E850_CL0, + CPUCLK_LAYOUT_E850_CL1, }; /** From patchwork Thu Feb 22 03:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566725 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7309C48BF6 for ; Thu, 22 Feb 2024 03:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i9Ae4kyVmr8+qtYY2iFEZPsD9s7A/NPN7j2GYHeTUwo=; b=0kS2tU52uFeun1 qQIFt565nAu4MYz9+Zr41CDEM8pBRTA/HwyFYaUZKDWqDZqq6oErQnkzMRz0Tfyj3mbOCrNGFUHNH iiCoMdme+pxmJLTADPVIujWhbJfaFzO3m7tYB34gpRGc+tyYcaBoNjCokuhz0p7N8oTt5w4uVIJdd gz/niaQJuTnbAf4lLnVFiYRYKimL6NsJWFURi9I4jj6TmubLINzBi6LeHAmlQTayVe5X6ywzbpa5j AYbMGaVfANO9kqheZvKOv5BFMSuMUfO+lWYcHeHtocUTnZ+HcyoOuRKPm0ULrj1gj1MmHu5bDMl4F VArL0ZtfmXotGBW5CfiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczOO-00000003Jxe-24lg; Thu, 22 Feb 2024 03:05:00 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMG-00000003Ijy-2hiA for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:50 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3bbb4806f67so4936652b6e.3 for ; Wed, 21 Feb 2024 19:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570967; x=1709175767; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7FVV9XkzNkckGF5r8p15gninEMa0F9j2UMwTU7X9t5U=; b=Ad04ILRKtPc6Gt3Y6m1F1Sh5jWr5ZrvCFjOiRikPq0BKgB6AKqRrvEhc1vFHAhECef WPCwhg8KwihbWm6BooshAxKPf1JOVL5XoZwkWo0FCrt5QaKgscGa/MW9oygaF9wAZfWY xwjnTmCDtczMI0EgNzYYY6vLSSZxhiScsts4yhcfblH5WCf9Af11Y47kePLF4K5NhOrE Zm7TZ+CCs5gzK028HYyL4ll1Ao0GECIQGu3iix2EyLljqb6qn+AnM7HnlL9P2tBsHbg8 I1qjYLAQYLP48S6HYnYxRIh5EPnu5uqmc1lWU2c1esNwYqbHac4hbMW5PiTNRC2sF9er b0qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570967; x=1709175767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7FVV9XkzNkckGF5r8p15gninEMa0F9j2UMwTU7X9t5U=; b=DVpY5+jS3YRfzc72iA1nXQH83Xz9jbVfcsPxPSc/VKpduNW4NKnSuTC5YVmyNd+66F DiIdgPCl8Pv0bqTfQLn4XfSeq4lxW8DKwLt3wG4q/g/z2DnofgjBldDgAtS4Vwv/XB1+ A0HCdmj/oyCQDP+gZkNs+Qhiy2/5vpBA3joB0aa9zg/NnQ1/xjCsmCLWwIBgAb5FGlRN dkFi6UcBGHOWyvh6Sk2HXCq1MQbQrxHTknQLvJYsnmMxhrWxFNGqo+gXaMJpUp9mp2lQ 06NtD+3rsXYkFxsB+5h0Vu9I/X8jgdzlHnJEJQXGXoTuGMFJqRIEt0gnvXd1QWoECA5r eZhg== X-Forwarded-Encrypted: i=1; AJvYcCUEi3Ss3nbYS+s3rXsyfz68xMojxq/nfhyD5jVMAfCe9FTnZi0yYWmJ3X+liSFb60qCmNo3lhSBjg/RPY57RJJTbsOUDifRDy9toEUmMeES+EUAa3k= X-Gm-Message-State: AOJu0Yx6TgTb4+Edv5wevCClNK06Z5WX+6IpXuxHbGuS65Y9w/R9UHLF PH6VB9j0uUR+o2nCNUudv8TCrIN+xMByxGs9cFKI82snJ50uaG+Ored5XZWG8XU= X-Google-Smtp-Source: AGHT+IFDqLwUZKoz0hGjxt5wtidJ2c+JHpOH/RWc0W4xfJqMkTkS0kRod9I9+S/Y+Pj5xpFpNXgpIg== X-Received: by 2002:a05:6808:1249:b0:3c1:7c2b:8d51 with SMTP id o9-20020a056808124900b003c17c2b8d51mr229612oiv.54.1708570967058; Wed, 21 Feb 2024 19:02:47 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id l26-20020aca191a000000b003c16b1d3862sm640909oii.50.2024.02.21.19.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:46 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 13/15] clk: samsung: Implement manual PLL control for ARM64 SoCs Date: Wed, 21 Feb 2024 21:02:33 -0600 Message-Id: <20240222030235.27815-14-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190248_729787_4F93DC0C X-CRM114-Status: GOOD ( 25.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some ARM64 Exynos chips are capable to control PLL clocks automatically. For those chips, whether the PLL is controlled automatically or manually is chosen in PLL_CON1 register with next bits: [28] ENABLE_AUTOMATIC_CLKGATING [1] MANUAL_PLL_CTRL [0] AUTO_PLL_CTRL The bl2 bootloader sets 0x10000001 value for some PLL_CON1 registers, which means any attempt to control those PLLs manually (e.g. disabling/enabling those PLLs or changing MUX parent clocks) would lead to PLL lock timeout with error message like this: Could not lock PLL ... At the moment, all Samsung clock drivers implement manual clock control. So in order to make it possible to control PLLs, corresponding PLL_CON1 registers should be set to 0x2 first. Some older ARM64 chips don't implement the automatic clock control though. It also might be desirable to configure some PLLs for manual control, while keeping the default configuration for the rest. So it'd convenient to choose this PLL mode for each CMU separately. Introduce .manual_plls field to CMU structure to choose the PLL control mode. Because it'll be initialized with "false" in all existing CMU structures by default, it won't affect any existing clock drivers, allowing for this feature to be enabled gradually when it's needed with no change for the rest of users. In case .manual_plls is set, set PLL_CON1 registers to manual control, akin to what's already done for gate clocks in exynos_arm64_init_clocks(). Of course, PLL_CON1 registers should be added to corresponding struct samsung_cmu_info::clk_regs array to make sure they get initialized. No functional change. This patch adds a feature, but doesn't enable it for any users. Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-exynos-arm64.c | 44 +++++++++++++++++--------- drivers/clk/samsung/clk.h | 4 +++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-arm64.c b/drivers/clk/samsung/clk-exynos-arm64.c index 6fb7194df7ab..55490209b9a9 100644 --- a/drivers/clk/samsung/clk-exynos-arm64.c +++ b/drivers/clk/samsung/clk-exynos-arm64.c @@ -25,6 +25,19 @@ #define GATE_OFF_START 0x2000 #define GATE_OFF_END 0x2fff +/* PLL CON register offsets range */ +#define PLL_CON_START 0x100 +#define PLL_CON_END 0x600 + +/* PLL register bits */ +#define PLL_CON1_MANUAL BIT(1) + +/* Helper macros to check for particular clock regiter by its offset */ +#define IS_GATE_REG(o) ((o) >= GATE_OFF_START && (o) <= GATE_OFF_END) +#define IS_PLL_CONx_REG(o) ((o) >= PLL_CON_START && (o) <= PLL_CON_END) +#define IS_PLL_CON1_REG(o) \ + (IS_PLL_CONx_REG(o) && ((o) & 0xf) == 0x4 && !((o) & 0x10)) + struct exynos_arm64_cmu_data { struct samsung_clk_reg_dump *clk_save; unsigned int nr_clk_save; @@ -40,15 +53,16 @@ struct exynos_arm64_cmu_data { /** * exynos_arm64_init_clocks - Set clocks initial configuration - * @np: CMU device tree node with "reg" property (CMU addr) - * @reg_offs: Register offsets array for clocks to init - * @reg_offs_len: Number of register offsets in reg_offs array + * @np: CMU device tree node with "reg" property (CMU addr) + * @cmu: CMU data * - * Set manual control mode for all gate clocks. + * Set manual control mode for all gate and PLL clocks. */ static void __init exynos_arm64_init_clocks(struct device_node *np, - const unsigned long *reg_offs, size_t reg_offs_len) + const struct samsung_cmu_info *cmu) { + const unsigned long *reg_offs = cmu->clk_regs; + size_t reg_offs_len = cmu->nr_clk_regs; void __iomem *reg_base; size_t i; @@ -60,14 +74,14 @@ static void __init exynos_arm64_init_clocks(struct device_node *np, void __iomem *reg = reg_base + reg_offs[i]; u32 val; - /* Modify only gate clock registers */ - if (reg_offs[i] < GATE_OFF_START || reg_offs[i] > GATE_OFF_END) - continue; - - val = readl(reg); - val |= GATE_MANUAL; - val &= ~GATE_ENABLE_HWACG; - writel(val, reg); + if (cmu->manual_plls && IS_PLL_CON1_REG(reg_offs[i])) { + writel(PLL_CON1_MANUAL, reg); + } else if (IS_GATE_REG(reg_offs[i])) { + val = readl(reg); + val |= GATE_MANUAL; + val &= ~GATE_ENABLE_HWACG; + writel(val, reg); + } } iounmap(reg_base); @@ -177,7 +191,7 @@ void __init exynos_arm64_register_cmu(struct device *dev, pr_err("%s: could not enable bus clock %s; err = %d\n", __func__, cmu->clk_name, err); - exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs); + exynos_arm64_init_clocks(np, cmu); samsung_cmu_register_one(np, cmu); } @@ -224,7 +238,7 @@ int __init exynos_arm64_register_cmu_pm(struct platform_device *pdev, __func__, cmu->clk_name, ret); if (set_manual) - exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs); + exynos_arm64_init_clocks(np, cmu); reg_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(reg_base)) diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index a763309e6f12..a70bd7cce39f 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -330,6 +330,7 @@ struct samsung_clock_reg_cache { * @suspend_regs: list of clock registers to set before suspend * @nr_suspend_regs: count of clock registers in @suspend_regs * @clk_name: name of the parent clock needed for CMU register access + * @manual_plls: Enable manual control for PLL clocks */ struct samsung_cmu_info { const struct samsung_pll_clock *pll_clks; @@ -354,6 +355,9 @@ struct samsung_cmu_info { const struct samsung_clk_reg_dump *suspend_regs; unsigned int nr_suspend_regs; const char *clk_name; + + /* ARM64 Exynos CMUs */ + bool manual_plls; }; struct samsung_clk_provider *samsung_clk_init(struct device *dev, From patchwork Thu Feb 22 03:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566724 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EFADC48BF6 for ; Thu, 22 Feb 2024 03:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sMii6tcUiVdPsURwrPkXRgByM1AS0RD1Isvu1TnR6i8=; b=kzsdPkgiLVcdFO d77/eCiCCHi8K1Vccpxs/Lo80t1N2KaApTPsVr5Nmutphydz68g7oY4bzKM5CtpwEoKvEs6mmoiHA M2y421K6MqlL3/3E8lOQOGs1x+0S+WwzFkWYo5hWJhOm+KT4M0oD4RcAJYmpiZ6vWJZaDKJh77drO ScGiATx5wbNk6YKc2atHAhNyRlgo0a8+c5x17/TxTv0MfhfdGVXENE0vN4SiAtFlBy1g0iSid8sx7 Znp9G5AsDZyvqGy+sTwOP6ryG4YOjQI+Z5CI1uqXHtPacHsTwLr8kHoeTVXA/hnaiwEhgIPo5TBwn 6wGvQTbDz6FoR+zG+4og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczOP-00000003JyD-19Kz; Thu, 22 Feb 2024 03:05:01 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMG-00000003IkS-2Qdg for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:51 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6e2da00185dso3916968a34.1 for ; Wed, 21 Feb 2024 19:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570968; x=1709175768; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WlsQ1B+0CtzBD6FSbcHeF9Qp/tSSzBk1uXJJn0tpGjA=; b=K45mtMPmUZFBAVzB15zPQksMoY2RkmzSC73pl3MyQs7TaKc4QcWA40PxCYjX+PCeHG gUfSCJTtCqqKf1+g9D7E7qzpuHk05HOLh9rwVSeGh4NNb9sQReqNhlYc9kI1LQE1tsHq HUHjXpZythLQjFIQFoH7VmA4MT0c1qcbD0PFKPV3X1lth+ILwX8E9hzC/WWEyKwudy8P JV/yU5g+uMNM0NZGIpTZBkzzXhCUm/tOJwiUimsFRPA+F66P/IWAvTr5Lxa7MNSSjlgX l1eBxlGVi4sL11qXIQwDMzE76wCqU19KpEtzwFohiLSootNfmgkuFnJb0+aMDanQrcYB sJ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570968; x=1709175768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlsQ1B+0CtzBD6FSbcHeF9Qp/tSSzBk1uXJJn0tpGjA=; b=gLjSJ0koJX6l813rFDxrQ0Pdpm2sfb161gEsALZG44n70LMgFBlZCwo+UoFkkT/sQ9 6Rs748Pb+u8A/nPMwuD36LFfGBJxIiJIDNtHtnWyRMCzzx75R3Ml7meRK+ySqQXZgNXD 9MSFtNdP6fB3/RnpNh6UHQnGIVQBEPGR+OJZgnLzXm/WE3d5lh79cvd4JeZEYkQhlxui NGN9r/+T97aSYb2Brslat/mMyMVPAB7mZTIjNNErliZ4SXVaIQf3+FygMdKvHigdpe+O u9tzI+RdgZy/2iP06i27tWEpkKJTLzlQMuNr2RkDx8O0oA49ZXKiClbZM09PFGMwTwRA 7a6w== X-Forwarded-Encrypted: i=1; AJvYcCXsPFOpsn+fa6dbsYXQ4Lebifx+kU3UrvO/sf4+2N9bM1rVZeSoNKgJD0er6BYr1IgpVfYlrXPE7YZiruvFVgQdxKoUsAMOM3KRDq95ov87ki0B36U= X-Gm-Message-State: AOJu0YzcNHwFPTM1xfFd002sYwfckRbmmuwGbofi9alsdRuwshba2Hy/ x0HUkRQQBrM24+2D8VDlO4dGXuO87D2Ux2Aa7zqlK+BfXYYYvkM9ZRZ8h1S20Ew= X-Google-Smtp-Source: AGHT+IF4lrYzngv+RhXHjJjThHPTxPI6mvJEHT28CdAVHmOxI6wucHsyoKTfOa4ATFp2TQPjinCyDA== X-Received: by 2002:a9d:7a53:0:b0:6de:6ad0:d34c with SMTP id z19-20020a9d7a53000000b006de6ad0d34cmr19565704otm.9.1708570967869; Wed, 21 Feb 2024 19:02:47 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id g1-20020a9d6481000000b006e2ed0b4f2csm1898904otl.40.2024.02.21.19.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:47 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 14/15] clk: samsung: exynos850: Add CMU_CPUCL0 and CMU_CPUCL1 Date: Wed, 21 Feb 2024 21:02:34 -0600 Message-Id: <20240222030235.27815-15-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190248_741336_FE73C9C8 X-CRM114-Status: GOOD ( 18.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement support for CPU clock management units: - CMU_CPUCL0: clocks for cluster 0: 4 x Cortex-A55 (cpu0..cpu3) - CMU_CPUCL1: clocks for cluster 1: 4 x Cortex-A55 (cpu4..cpu7) CPU PLLs are generating main CPU clocks for each cluster, and there are alternate ("switch") clocks that can be used temporarily while re-configuring the PLL for a new rate. ACLK, ATCLK, PCLKDBG and PERIPHCLK clocks are driving corresponding buses. CLK_CLUSTERx_SCLK are actual leaf CPU clocks and should be used to change CPU rates. Also some CoreSight clocks can be derived from DBG_USER (debug clock). PLL table was extracted from ECT table. ECT stands for "Exynos Characteristic Table", it's a Samsung specific binary data populated by BL2 bootloader in RAM at 0x90000000 address, containing PLL tables for various CMUs and other hardware specific information. The particular PLL type used in CMU_CPUCL0 and CMU_CPUCL1 (pll0822x) is an integer PLL with middle FVCO. The equation to calculate its output rate is: fout = fin * M / (P*2^S) where: fin = 26 MHz (OSCCLK frequency) M = 64..1023 P = 1..63 S = 0..6 The PLL table tries to keep "P" value low to reduce the locking time, which for pll0822x is "t = P * 150" (in OSCCLK cycles). Signed-off-by: Sam Protsenko --- Changes in v2: - none drivers/clk/samsung/clk-exynos850.c | 440 +++++++++++++++++++++++++++- 1 file changed, 439 insertions(+), 1 deletion(-) diff --git a/drivers/clk/samsung/clk-exynos850.c b/drivers/clk/samsung/clk-exynos850.c index 82cfa22c0788..6215471c4ac6 100644 --- a/drivers/clk/samsung/clk-exynos850.c +++ b/drivers/clk/samsung/clk-exynos850.c @@ -14,13 +14,16 @@ #include #include "clk.h" +#include "clk-cpu.h" #include "clk-exynos-arm64.h" /* NOTE: Must be equal to the last clock ID increased by one */ -#define CLKS_NR_TOP (CLK_DOUT_G3D_SWITCH + 1) +#define CLKS_NR_TOP (CLK_DOUT_CPUCL1_SWITCH + 1) #define CLKS_NR_APM (CLK_GOUT_SYSREG_APM_PCLK + 1) #define CLKS_NR_AUD (CLK_GOUT_AUD_CMU_AUD_PCLK + 1) #define CLKS_NR_CMGP (CLK_GOUT_SYSREG_CMGP_PCLK + 1) +#define CLKS_NR_CPUCL0 (CLK_CLUSTER0_SCLK + 1) +#define CLKS_NR_CPUCL1 (CLK_CLUSTER1_SCLK + 1) #define CLKS_NR_G3D (CLK_GOUT_G3D_SYSREG_PCLK + 1) #define CLKS_NR_HSI (CLK_GOUT_HSI_CMU_HSI_PCLK + 1) #define CLKS_NR_IS (CLK_GOUT_IS_SYSREG_PCLK + 1) @@ -47,6 +50,10 @@ #define CLK_CON_MUX_MUX_CLKCMU_CORE_CCI 0x1018 #define CLK_CON_MUX_MUX_CLKCMU_CORE_MMC_EMBD 0x101c #define CLK_CON_MUX_MUX_CLKCMU_CORE_SSS 0x1020 +#define CLK_CON_MUX_MUX_CLKCMU_CPUCL0_DBG 0x1024 +#define CLK_CON_MUX_MUX_CLKCMU_CPUCL0_SWITCH 0x1028 +#define CLK_CON_MUX_MUX_CLKCMU_CPUCL1_DBG 0x102c +#define CLK_CON_MUX_MUX_CLKCMU_CPUCL1_SWITCH 0x1030 #define CLK_CON_MUX_MUX_CLKCMU_DPU 0x1034 #define CLK_CON_MUX_MUX_CLKCMU_G3D_SWITCH 0x1038 #define CLK_CON_MUX_MUX_CLKCMU_HSI_BUS 0x103c @@ -69,6 +76,10 @@ #define CLK_CON_DIV_CLKCMU_CORE_CCI 0x1824 #define CLK_CON_DIV_CLKCMU_CORE_MMC_EMBD 0x1828 #define CLK_CON_DIV_CLKCMU_CORE_SSS 0x182c +#define CLK_CON_DIV_CLKCMU_CPUCL0_DBG 0x1830 +#define CLK_CON_DIV_CLKCMU_CPUCL0_SWITCH 0x1834 +#define CLK_CON_DIV_CLKCMU_CPUCL1_DBG 0x1838 +#define CLK_CON_DIV_CLKCMU_CPUCL1_SWITCH 0x183c #define CLK_CON_DIV_CLKCMU_DPU 0x1840 #define CLK_CON_DIV_CLKCMU_G3D_SWITCH 0x1844 #define CLK_CON_DIV_CLKCMU_HSI_BUS 0x1848 @@ -97,6 +108,10 @@ #define CLK_CON_GAT_GATE_CLKCMU_CORE_CCI 0x2020 #define CLK_CON_GAT_GATE_CLKCMU_CORE_MMC_EMBD 0x2024 #define CLK_CON_GAT_GATE_CLKCMU_CORE_SSS 0x2028 +#define CLK_CON_GAT_GATE_CLKCMU_CPUCL0_DBG 0x202c +#define CLK_CON_GAT_GATE_CLKCMU_CPUCL0_SWITCH 0x2030 +#define CLK_CON_GAT_GATE_CLKCMU_CPUCL1_DBG 0x2034 +#define CLK_CON_GAT_GATE_CLKCMU_CPUCL1_SWITCH 0x2038 #define CLK_CON_GAT_GATE_CLKCMU_DPU 0x203c #define CLK_CON_GAT_GATE_CLKCMU_G3D_SWITCH 0x2040 #define CLK_CON_GAT_GATE_CLKCMU_HSI_BUS 0x2044 @@ -130,6 +145,10 @@ static const unsigned long top_clk_regs[] __initconst = { CLK_CON_MUX_MUX_CLKCMU_CORE_CCI, CLK_CON_MUX_MUX_CLKCMU_CORE_MMC_EMBD, CLK_CON_MUX_MUX_CLKCMU_CORE_SSS, + CLK_CON_MUX_MUX_CLKCMU_CPUCL0_DBG, + CLK_CON_MUX_MUX_CLKCMU_CPUCL0_SWITCH, + CLK_CON_MUX_MUX_CLKCMU_CPUCL1_DBG, + CLK_CON_MUX_MUX_CLKCMU_CPUCL1_SWITCH, CLK_CON_MUX_MUX_CLKCMU_DPU, CLK_CON_MUX_MUX_CLKCMU_G3D_SWITCH, CLK_CON_MUX_MUX_CLKCMU_HSI_BUS, @@ -152,6 +171,10 @@ static const unsigned long top_clk_regs[] __initconst = { CLK_CON_DIV_CLKCMU_CORE_CCI, CLK_CON_DIV_CLKCMU_CORE_MMC_EMBD, CLK_CON_DIV_CLKCMU_CORE_SSS, + CLK_CON_DIV_CLKCMU_CPUCL0_DBG, + CLK_CON_DIV_CLKCMU_CPUCL0_SWITCH, + CLK_CON_DIV_CLKCMU_CPUCL1_DBG, + CLK_CON_DIV_CLKCMU_CPUCL1_SWITCH, CLK_CON_DIV_CLKCMU_DPU, CLK_CON_DIV_CLKCMU_G3D_SWITCH, CLK_CON_DIV_CLKCMU_HSI_BUS, @@ -180,6 +203,10 @@ static const unsigned long top_clk_regs[] __initconst = { CLK_CON_GAT_GATE_CLKCMU_CORE_CCI, CLK_CON_GAT_GATE_CLKCMU_CORE_MMC_EMBD, CLK_CON_GAT_GATE_CLKCMU_CORE_SSS, + CLK_CON_GAT_GATE_CLKCMU_CPUCL0_DBG, + CLK_CON_GAT_GATE_CLKCMU_CPUCL0_SWITCH, + CLK_CON_GAT_GATE_CLKCMU_CPUCL1_DBG, + CLK_CON_GAT_GATE_CLKCMU_CPUCL1_SWITCH, CLK_CON_GAT_GATE_CLKCMU_DPU, CLK_CON_GAT_GATE_CLKCMU_G3D_SWITCH, CLK_CON_GAT_GATE_CLKCMU_HSI_BUS, @@ -234,6 +261,14 @@ PNAME(mout_core_mmc_embd_p) = { "oscclk", "dout_shared0_div2", "oscclk", "oscclk" }; PNAME(mout_core_sss_p) = { "dout_shared0_div3", "dout_shared1_div3", "dout_shared0_div4", "dout_shared1_div4" }; +/* List of parent clocks for Muxes in CMU_TOP: for CMU_CPUCL0 */ +PNAME(mout_cpucl0_switch_p) = { "fout_shared0_pll", "fout_shared1_pll", + "dout_shared0_div2", "dout_shared1_div2" }; +PNAME(mout_cpucl0_dbg_p) = { "dout_shared0_div4", "dout_shared1_div4" }; +/* List of parent clocks for Muxes in CMU_TOP: for CMU_CPUCL1 */ +PNAME(mout_cpucl1_switch_p) = { "fout_shared0_pll", "fout_shared1_pll", + "dout_shared0_div2", "dout_shared1_div2" }; +PNAME(mout_cpucl1_dbg_p) = { "dout_shared0_div4", "dout_shared1_div4" }; /* List of parent clocks for Muxes in CMU_TOP: for CMU_G3D */ PNAME(mout_g3d_switch_p) = { "dout_shared0_div2", "dout_shared1_div2", "dout_shared0_div3", "dout_shared1_div3" }; @@ -300,6 +335,18 @@ static const struct samsung_mux_clock top_mux_clks[] __initconst = { MUX(CLK_MOUT_CORE_SSS, "mout_core_sss", mout_core_sss_p, CLK_CON_MUX_MUX_CLKCMU_CORE_SSS, 0, 2), + /* CPUCL0 */ + MUX(CLK_MOUT_CPUCL0_DBG, "mout_cpucl0_dbg", mout_cpucl0_dbg_p, + CLK_CON_MUX_MUX_CLKCMU_CPUCL0_DBG, 0, 1), + MUX(CLK_MOUT_CPUCL0_SWITCH, "mout_cpucl0_switch", mout_cpucl0_switch_p, + CLK_CON_MUX_MUX_CLKCMU_CPUCL0_SWITCH, 0, 2), + + /* CPUCL1 */ + MUX(CLK_MOUT_CPUCL1_DBG, "mout_cpucl1_dbg", mout_cpucl1_dbg_p, + CLK_CON_MUX_MUX_CLKCMU_CPUCL1_DBG, 0, 1), + MUX(CLK_MOUT_CPUCL1_SWITCH, "mout_cpucl1_switch", mout_cpucl1_switch_p, + CLK_CON_MUX_MUX_CLKCMU_CPUCL1_SWITCH, 0, 2), + /* DPU */ MUX(CLK_MOUT_DPU, "mout_dpu", mout_dpu_p, CLK_CON_MUX_MUX_CLKCMU_DPU, 0, 2), @@ -378,6 +425,18 @@ static const struct samsung_div_clock top_div_clks[] __initconst = { DIV(CLK_DOUT_CORE_SSS, "dout_core_sss", "gout_core_sss", CLK_CON_DIV_CLKCMU_CORE_SSS, 0, 4), + /* CPUCL0 */ + DIV(CLK_DOUT_CPUCL0_DBG, "dout_cpucl0_dbg", "gout_cpucl0_dbg", + CLK_CON_DIV_CLKCMU_CPUCL0_DBG, 0, 3), + DIV(CLK_DOUT_CPUCL0_SWITCH, "dout_cpucl0_switch", "gout_cpucl0_switch", + CLK_CON_DIV_CLKCMU_CPUCL0_SWITCH, 0, 3), + + /* CPUCL1 */ + DIV(CLK_DOUT_CPUCL1_DBG, "dout_cpucl1_dbg", "gout_cpucl1_dbg", + CLK_CON_DIV_CLKCMU_CPUCL1_DBG, 0, 3), + DIV(CLK_DOUT_CPUCL1_SWITCH, "dout_cpucl1_switch", "gout_cpucl1_switch", + CLK_CON_DIV_CLKCMU_CPUCL1_SWITCH, 0, 3), + /* DPU */ DIV(CLK_DOUT_DPU, "dout_dpu", "gout_dpu", CLK_CON_DIV_CLKCMU_DPU, 0, 4), @@ -442,6 +501,18 @@ static const struct samsung_gate_clock top_gate_clks[] __initconst = { GATE(CLK_GOUT_AUD, "gout_aud", "mout_aud", CLK_CON_GAT_GATE_CLKCMU_AUD, 21, 0, 0), + /* CPUCL0 */ + GATE(CLK_GOUT_CPUCL0_DBG, "gout_cpucl0_dbg", "mout_cpucl0_dbg", + CLK_CON_GAT_GATE_CLKCMU_CPUCL0_DBG, 21, 0, 0), + GATE(CLK_GOUT_CPUCL0_SWITCH, "gout_cpucl0_switch", "mout_cpucl0_switch", + CLK_CON_GAT_GATE_CLKCMU_CPUCL0_SWITCH, 21, 0, 0), + + /* CPUCL1 */ + GATE(CLK_GOUT_CPUCL1_DBG, "gout_cpucl1_dbg", "mout_cpucl1_dbg", + CLK_CON_GAT_GATE_CLKCMU_CPUCL1_DBG, 21, 0, 0), + GATE(CLK_GOUT_CPUCL1_SWITCH, "gout_cpucl1_switch", "mout_cpucl1_switch", + CLK_CON_GAT_GATE_CLKCMU_CPUCL1_SWITCH, 21, 0, 0), + /* DPU */ GATE(CLK_GOUT_DPU, "gout_dpu", "mout_dpu", CLK_CON_GAT_GATE_CLKCMU_DPU, 21, 0, 0), @@ -1030,6 +1101,373 @@ static const struct samsung_cmu_info cmgp_cmu_info __initconst = { .clk_name = "gout_clkcmu_cmgp_bus", }; +/* ---- CMU_CPUCL0 ---------------------------------------------------------- */ + +/* Register Offset definitions for CMU_CPUCL0 (0x10900000) */ +#define PLL_LOCKTIME_PLL_CPUCL0 0x0000 +#define PLL_CON0_PLL_CPUCL0 0x0100 +#define PLL_CON1_PLL_CPUCL0 0x0104 +#define PLL_CON3_PLL_CPUCL0 0x010c +#define PLL_CON0_MUX_CLKCMU_CPUCL0_DBG_USER 0x0600 +#define PLL_CON0_MUX_CLKCMU_CPUCL0_SWITCH_USER 0x0610 +#define CLK_CON_MUX_MUX_CLK_CPUCL0_PLL 0x100c +#define CLK_CON_DIV_DIV_CLK_CLUSTER0_ACLK 0x1800 +#define CLK_CON_DIV_DIV_CLK_CLUSTER0_ATCLK 0x1808 +#define CLK_CON_DIV_DIV_CLK_CLUSTER0_PCLKDBG 0x180c +#define CLK_CON_DIV_DIV_CLK_CLUSTER0_PERIPHCLK 0x1810 +#define CLK_CON_DIV_DIV_CLK_CPUCL0_CMUREF 0x1814 +#define CLK_CON_DIV_DIV_CLK_CPUCL0_CPU 0x1818 +#define CLK_CON_DIV_DIV_CLK_CPUCL0_PCLK 0x181c +#define CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_ATCLK 0x2000 +#define CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PCLK 0x2004 +#define CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PERIPHCLK 0x2008 +#define CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_SCLK 0x200c +#define CLK_CON_GAT_CLK_CPUCL0_CMU_CPUCL0_PCLK 0x2010 +#define CLK_CON_GAT_GATE_CLK_CPUCL0_CPU 0x2020 + +static const unsigned long cpucl0_clk_regs[] __initconst = { + PLL_LOCKTIME_PLL_CPUCL0, + PLL_CON0_PLL_CPUCL0, + PLL_CON1_PLL_CPUCL0, + PLL_CON3_PLL_CPUCL0, + PLL_CON0_MUX_CLKCMU_CPUCL0_DBG_USER, + PLL_CON0_MUX_CLKCMU_CPUCL0_SWITCH_USER, + CLK_CON_MUX_MUX_CLK_CPUCL0_PLL, + CLK_CON_DIV_DIV_CLK_CLUSTER0_ACLK, + CLK_CON_DIV_DIV_CLK_CLUSTER0_ATCLK, + CLK_CON_DIV_DIV_CLK_CLUSTER0_PCLKDBG, + CLK_CON_DIV_DIV_CLK_CLUSTER0_PERIPHCLK, + CLK_CON_DIV_DIV_CLK_CPUCL0_CMUREF, + CLK_CON_DIV_DIV_CLK_CPUCL0_CPU, + CLK_CON_DIV_DIV_CLK_CPUCL0_PCLK, + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_ATCLK, + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PCLK, + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PERIPHCLK, + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_SCLK, + CLK_CON_GAT_CLK_CPUCL0_CMU_CPUCL0_PCLK, + CLK_CON_GAT_GATE_CLK_CPUCL0_CPU, +}; + +/* List of parent clocks for Muxes in CMU_CPUCL0 */ +PNAME(mout_pll_cpucl0_p) = { "oscclk", "fout_cpucl0_pll" }; +PNAME(mout_cpucl0_switch_user_p) = { "oscclk", "dout_cpucl0_switch" }; +PNAME(mout_cpucl0_dbg_user_p) = { "oscclk", "dout_cpucl0_dbg" }; +PNAME(mout_cpucl0_pll_p) = { "mout_pll_cpucl0", + "mout_cpucl0_switch_user" }; + +static const struct samsung_pll_rate_table cpu_pll_rates[] __initconst = { + PLL_35XX_RATE(26 * MHZ, 2210000000U, 255, 3, 0), + PLL_35XX_RATE(26 * MHZ, 2106000000U, 243, 3, 0), + PLL_35XX_RATE(26 * MHZ, 2002000000U, 231, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1846000000U, 213, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1742000000U, 201, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1586000000U, 183, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1456000000U, 168, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1300000000U, 150, 3, 0), + PLL_35XX_RATE(26 * MHZ, 1157000000U, 267, 3, 1), + PLL_35XX_RATE(26 * MHZ, 1053000000U, 243, 3, 1), + PLL_35XX_RATE(26 * MHZ, 949000000U, 219, 3, 1), + PLL_35XX_RATE(26 * MHZ, 806000000U, 186, 3, 1), + PLL_35XX_RATE(26 * MHZ, 650000000U, 150, 3, 1), + PLL_35XX_RATE(26 * MHZ, 546000000U, 252, 3, 2), + PLL_35XX_RATE(26 * MHZ, 442000000U, 204, 3, 2), + PLL_35XX_RATE(26 * MHZ, 351000000U, 162, 3, 2), + PLL_35XX_RATE(26 * MHZ, 247000000U, 114, 3, 2), + PLL_35XX_RATE(26 * MHZ, 182000000U, 168, 3, 3), + PLL_35XX_RATE(26 * MHZ, 130000000U, 120, 3, 3), +}; + +static const struct samsung_pll_clock cpucl0_pll_clks[] __initconst = { + PLL(pll_0822x, CLK_FOUT_CPUCL0_PLL, "fout_cpucl0_pll", "oscclk", + PLL_LOCKTIME_PLL_CPUCL0, PLL_CON3_PLL_CPUCL0, cpu_pll_rates), +}; + +static const struct samsung_mux_clock cpucl0_mux_clks[] __initconst = { + MUX_F(CLK_MOUT_PLL_CPUCL0, "mout_pll_cpucl0", mout_pll_cpucl0_p, + PLL_CON0_PLL_CPUCL0, 4, 1, + CLK_SET_RATE_PARENT | CLK_RECALC_NEW_RATES, 0), + MUX_F(CLK_MOUT_CPUCL0_SWITCH_USER, "mout_cpucl0_switch_user", + mout_cpucl0_switch_user_p, + PLL_CON0_MUX_CLKCMU_CPUCL0_SWITCH_USER, 4, 1, + CLK_SET_RATE_PARENT, 0), + MUX(CLK_MOUT_CPUCL0_DBG_USER, "mout_cpucl0_dbg_user", + mout_cpucl0_dbg_user_p, + PLL_CON0_MUX_CLKCMU_CPUCL0_DBG_USER, 4, 1), + MUX_F(CLK_MOUT_CPUCL0_PLL, "mout_cpucl0_pll", mout_cpucl0_pll_p, + CLK_CON_MUX_MUX_CLK_CPUCL0_PLL, 0, 1, CLK_SET_RATE_PARENT, 0), +}; + +static const struct samsung_div_clock cpucl0_div_clks[] __initconst = { + DIV_F(CLK_DOUT_CPUCL0_CPU, "dout_cpucl0_cpu", "mout_cpucl0_pll", + CLK_CON_DIV_DIV_CLK_CPUCL0_CPU, 0, 1, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CPUCL0_CMUREF, "dout_cpucl0_cmuref", "dout_cpucl0_cpu", + CLK_CON_DIV_DIV_CLK_CPUCL0_CMUREF, 0, 3, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CPUCL0_PCLK, "dout_cpucl0_pclk", "dout_cpucl0_cpu", + CLK_CON_DIV_DIV_CLK_CPUCL0_PCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + + /* EMBEDDED_CMU_CPUCL0 */ + DIV_F(CLK_DOUT_CLUSTER0_ACLK, "dout_cluster0_aclk", "gout_cluster0_cpu", + CLK_CON_DIV_DIV_CLK_CLUSTER0_ACLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER0_ATCLK, "dout_cluster0_atclk", + "gout_cluster0_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER0_ATCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER0_PCLKDBG, "dout_cluster0_pclkdbg", + "gout_cluster0_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER0_PCLKDBG, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER0_PERIPHCLK, "dout_cluster0_periphclk", + "gout_cluster0_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER0_PERIPHCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), +}; + +static const struct samsung_gate_clock cpucl0_gate_clks[] __initconst = { + GATE(CLK_GOUT_CPUCL0_CMU_CPUCL0_PCLK, "gout_cpucl0_cmu_cpucl0_pclk", + "dout_cpucl0_pclk", + CLK_CON_GAT_CLK_CPUCL0_CMU_CPUCL0_PCLK, 21, CLK_IGNORE_UNUSED, 0), + + /* EMBEDDED_CMU_CPUCL0 */ + GATE(CLK_GOUT_CLUSTER0_CPU, "gout_cluster0_cpu", "dout_cpucl0_cpu", + CLK_CON_GAT_GATE_CLK_CPUCL0_CPU, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER0_SCLK, "gout_cluster0_sclk", "gout_cluster0_cpu", + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_SCLK, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER0_ATCLK, "gout_cluster0_atclk", + "dout_cluster0_atclk", + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_ATCLK, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER0_PERIPHCLK, "gout_cluster0_periphclk", + "dout_cluster0_periphclk", + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PERIPHCLK, 21, + CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER0_PCLK, "gout_cluster0_pclk", + "dout_cluster0_pclkdbg", + CLK_CON_GAT_CLK_CPUCL0_CLUSTER0_PCLK, 21, CLK_IGNORE_UNUSED, 0), +}; + +/* + * Each parameter is going to be written into the corresponding DIV register. So + * the actual divider value for each parameter will be 1/(param+1). All these + * parameters must be in the range of 0..15, as the divider range for all of + * these DIV clocks is 1..16. The default values for these dividers is + * (1, 3, 3, 1). + */ +#define E850_CPU_DIV0(aclk, atclk, pclkdbg, periphclk) \ + (((aclk) << 16) | ((atclk) << 12) | ((pclkdbg) << 8) | \ + ((periphclk) << 4)) + +static const struct exynos_cpuclk_cfg_data exynos850_cluster_clk_d[] __initconst += { + { 2210000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 2106000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 2002000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1846000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1742000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1586000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1456000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1300000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1157000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 1053000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 949000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 806000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 650000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 546000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 442000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 351000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 247000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 182000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 130000, E850_CPU_DIV0(1, 3, 3, 1) }, + { 0 } +}; + +static const struct samsung_cpu_clock cpucl0_cpu_clks[] __initconst = { + CPU_CLK(CLK_CLUSTER0_SCLK, "cluster0_clk", CLK_MOUT_PLL_CPUCL0, + CLK_MOUT_CPUCL0_SWITCH_USER, 0, 0x0, CPUCLK_LAYOUT_E850_CL0, + exynos850_cluster_clk_d), +}; + +static const struct samsung_cmu_info cpucl0_cmu_info __initconst = { + .pll_clks = cpucl0_pll_clks, + .nr_pll_clks = ARRAY_SIZE(cpucl0_pll_clks), + .mux_clks = cpucl0_mux_clks, + .nr_mux_clks = ARRAY_SIZE(cpucl0_mux_clks), + .div_clks = cpucl0_div_clks, + .nr_div_clks = ARRAY_SIZE(cpucl0_div_clks), + .gate_clks = cpucl0_gate_clks, + .nr_gate_clks = ARRAY_SIZE(cpucl0_gate_clks), + .cpu_clks = cpucl0_cpu_clks, + .nr_cpu_clks = ARRAY_SIZE(cpucl0_cpu_clks), + .nr_clk_ids = CLKS_NR_CPUCL0, + .clk_regs = cpucl0_clk_regs, + .nr_clk_regs = ARRAY_SIZE(cpucl0_clk_regs), + .clk_name = "dout_cpucl0_switch", + .manual_plls = true, +}; + +static void __init exynos850_cmu_cpucl0_init(struct device_node *np) +{ + exynos_arm64_register_cmu(NULL, np, &cpucl0_cmu_info); +} + +/* Register CMU_CPUCL0 early, as CPU clocks should be available ASAP */ +CLK_OF_DECLARE(exynos850_cmu_cpucl0, "samsung,exynos850-cmu-cpucl0", + exynos850_cmu_cpucl0_init); + +/* ---- CMU_CPUCL1 ---------------------------------------------------------- */ + +/* Register Offset definitions for CMU_CPUCL1 (0x10800000) */ +#define PLL_LOCKTIME_PLL_CPUCL1 0x0000 +#define PLL_CON0_PLL_CPUCL1 0x0100 +#define PLL_CON1_PLL_CPUCL1 0x0104 +#define PLL_CON3_PLL_CPUCL1 0x010c +#define PLL_CON0_MUX_CLKCMU_CPUCL1_DBG_USER 0x0600 +#define PLL_CON0_MUX_CLKCMU_CPUCL1_SWITCH_USER 0x0610 +#define CLK_CON_MUX_MUX_CLK_CPUCL1_PLL 0x1000 +#define CLK_CON_DIV_DIV_CLK_CLUSTER1_ACLK 0x1800 +#define CLK_CON_DIV_DIV_CLK_CLUSTER1_ATCLK 0x1808 +#define CLK_CON_DIV_DIV_CLK_CLUSTER1_PCLKDBG 0x180c +#define CLK_CON_DIV_DIV_CLK_CLUSTER1_PERIPHCLK 0x1810 +#define CLK_CON_DIV_DIV_CLK_CPUCL1_CMUREF 0x1814 +#define CLK_CON_DIV_DIV_CLK_CPUCL1_CPU 0x1818 +#define CLK_CON_DIV_DIV_CLK_CPUCL1_PCLK 0x181c +#define CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_ATCLK 0x2000 +#define CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PCLK 0x2004 +#define CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PERIPHCLK 0x2008 +#define CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_SCLK 0x200c +#define CLK_CON_GAT_CLK_CPUCL1_CMU_CPUCL1_PCLK 0x2010 +#define CLK_CON_GAT_GATE_CLK_CPUCL1_CPU 0x2020 + +static const unsigned long cpucl1_clk_regs[] __initconst = { + PLL_LOCKTIME_PLL_CPUCL1, + PLL_CON0_PLL_CPUCL1, + PLL_CON1_PLL_CPUCL1, + PLL_CON3_PLL_CPUCL1, + PLL_CON0_MUX_CLKCMU_CPUCL1_DBG_USER, + PLL_CON0_MUX_CLKCMU_CPUCL1_SWITCH_USER, + CLK_CON_MUX_MUX_CLK_CPUCL1_PLL, + CLK_CON_DIV_DIV_CLK_CLUSTER1_ACLK, + CLK_CON_DIV_DIV_CLK_CLUSTER1_ATCLK, + CLK_CON_DIV_DIV_CLK_CLUSTER1_PCLKDBG, + CLK_CON_DIV_DIV_CLK_CLUSTER1_PERIPHCLK, + CLK_CON_DIV_DIV_CLK_CPUCL1_CMUREF, + CLK_CON_DIV_DIV_CLK_CPUCL1_CPU, + CLK_CON_DIV_DIV_CLK_CPUCL1_PCLK, + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_ATCLK, + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PCLK, + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PERIPHCLK, + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_SCLK, + CLK_CON_GAT_CLK_CPUCL1_CMU_CPUCL1_PCLK, + CLK_CON_GAT_GATE_CLK_CPUCL1_CPU, +}; + +/* List of parent clocks for Muxes in CMU_CPUCL0 */ +PNAME(mout_pll_cpucl1_p) = { "oscclk", "fout_cpucl1_pll" }; +PNAME(mout_cpucl1_switch_user_p) = { "oscclk", "dout_cpucl1_switch" }; +PNAME(mout_cpucl1_dbg_user_p) = { "oscclk", "dout_cpucl1_dbg" }; +PNAME(mout_cpucl1_pll_p) = { "mout_pll_cpucl1", + "mout_cpucl1_switch_user" }; + +static const struct samsung_pll_clock cpucl1_pll_clks[] __initconst = { + PLL(pll_0822x, CLK_FOUT_CPUCL1_PLL, "fout_cpucl1_pll", "oscclk", + PLL_LOCKTIME_PLL_CPUCL1, PLL_CON3_PLL_CPUCL1, cpu_pll_rates), +}; + +static const struct samsung_mux_clock cpucl1_mux_clks[] __initconst = { + MUX_F(CLK_MOUT_PLL_CPUCL1, "mout_pll_cpucl1", mout_pll_cpucl1_p, + PLL_CON0_PLL_CPUCL1, 4, 1, + CLK_SET_RATE_PARENT | CLK_RECALC_NEW_RATES, 0), + MUX_F(CLK_MOUT_CPUCL1_SWITCH_USER, "mout_cpucl1_switch_user", + mout_cpucl1_switch_user_p, + PLL_CON0_MUX_CLKCMU_CPUCL1_SWITCH_USER, 4, 1, + CLK_SET_RATE_PARENT, 0), + MUX(CLK_MOUT_CPUCL1_DBG_USER, "mout_cpucl1_dbg_user", + mout_cpucl1_dbg_user_p, + PLL_CON0_MUX_CLKCMU_CPUCL1_DBG_USER, 4, 1), + MUX_F(CLK_MOUT_CPUCL1_PLL, "mout_cpucl1_pll", mout_cpucl1_pll_p, + CLK_CON_MUX_MUX_CLK_CPUCL1_PLL, 0, 1, CLK_SET_RATE_PARENT, 0), +}; + +static const struct samsung_div_clock cpucl1_div_clks[] __initconst = { + DIV_F(CLK_DOUT_CPUCL1_CPU, "dout_cpucl1_cpu", "mout_cpucl1_pll", + CLK_CON_DIV_DIV_CLK_CPUCL1_CPU, 0, 1, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CPUCL1_CMUREF, "dout_cpucl1_cmuref", "dout_cpucl1_cpu", + CLK_CON_DIV_DIV_CLK_CPUCL1_CMUREF, 0, 3, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CPUCL1_PCLK, "dout_cpucl1_pclk", "dout_cpucl1_cpu", + CLK_CON_DIV_DIV_CLK_CPUCL1_PCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + + /* EMBEDDED_CMU_CPUCL1 */ + DIV_F(CLK_DOUT_CLUSTER1_ACLK, "dout_cluster1_aclk", "gout_cluster1_cpu", + CLK_CON_DIV_DIV_CLK_CLUSTER1_ACLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER1_ATCLK, "dout_cluster1_atclk", + "gout_cluster1_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER1_ATCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER1_PCLKDBG, "dout_cluster1_pclkdbg", + "gout_cluster1_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER1_PCLKDBG, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_CLUSTER1_PERIPHCLK, "dout_cluster1_periphclk", + "gout_cluster1_cpu", CLK_CON_DIV_DIV_CLK_CLUSTER1_PERIPHCLK, 0, 4, + CLK_GET_RATE_NOCACHE, CLK_DIVIDER_READ_ONLY), +}; + +static const struct samsung_gate_clock cpucl1_gate_clks[] __initconst = { + GATE(CLK_GOUT_CPUCL1_CMU_CPUCL1_PCLK, "gout_cpucl1_cmu_cpucl1_pclk", + "dout_cpucl1_pclk", + CLK_CON_GAT_CLK_CPUCL1_CMU_CPUCL1_PCLK, 21, CLK_IGNORE_UNUSED, 0), + + /* EMBEDDED_CMU_CPUCL1 */ + GATE(CLK_GOUT_CLUSTER1_CPU, "gout_cluster1_cpu", "dout_cpucl1_cpu", + CLK_CON_GAT_GATE_CLK_CPUCL1_CPU, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER1_SCLK, "gout_cluster1_sclk", "gout_cluster1_cpu", + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_SCLK, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER1_ATCLK, "gout_cluster1_atclk", + "dout_cluster1_atclk", + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_ATCLK, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER1_PERIPHCLK, "gout_cluster1_periphclk", + "dout_cluster1_periphclk", + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PERIPHCLK, 21, + CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_CLUSTER1_PCLK, "gout_cluster1_pclk", + "dout_cluster1_pclkdbg", + CLK_CON_GAT_CLK_CPUCL1_CLUSTER1_PCLK, 21, CLK_IGNORE_UNUSED, 0), +}; + +static const struct samsung_cpu_clock cpucl1_cpu_clks[] __initconst = { + CPU_CLK(CLK_CLUSTER1_SCLK, "cluster1_clk", CLK_MOUT_PLL_CPUCL1, + CLK_MOUT_CPUCL1_SWITCH_USER, 0, 0x0, CPUCLK_LAYOUT_E850_CL1, + exynos850_cluster_clk_d), +}; + +static const struct samsung_cmu_info cpucl1_cmu_info __initconst = { + .pll_clks = cpucl1_pll_clks, + .nr_pll_clks = ARRAY_SIZE(cpucl1_pll_clks), + .mux_clks = cpucl1_mux_clks, + .nr_mux_clks = ARRAY_SIZE(cpucl1_mux_clks), + .div_clks = cpucl1_div_clks, + .nr_div_clks = ARRAY_SIZE(cpucl1_div_clks), + .gate_clks = cpucl1_gate_clks, + .nr_gate_clks = ARRAY_SIZE(cpucl1_gate_clks), + .cpu_clks = cpucl1_cpu_clks, + .nr_cpu_clks = ARRAY_SIZE(cpucl1_cpu_clks), + .nr_clk_ids = CLKS_NR_CPUCL1, + .clk_regs = cpucl1_clk_regs, + .nr_clk_regs = ARRAY_SIZE(cpucl1_clk_regs), + .clk_name = "dout_cpucl1_switch", + .manual_plls = true, +}; + +static void __init exynos850_cmu_cpucl1_init(struct device_node *np) +{ + exynos_arm64_register_cmu(NULL, np, &cpucl1_cmu_info); +} + +/* Register CMU_CPUCL1 early, as CPU clocks should be available ASAP */ +CLK_OF_DECLARE(exynos850_cmu_cpucl1, "samsung,exynos850-cmu-cpucl1", + exynos850_cmu_cpucl1_init); + /* ---- CMU_G3D ------------------------------------------------------------- */ /* Register Offset definitions for CMU_G3D (0x11400000) */ From patchwork Thu Feb 22 03:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13566723 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1411DC48BEB for ; Thu, 22 Feb 2024 03:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JNFxzj2ASbO6fSzPuwS9WClyuwaoFGV8owkHog+U02g=; b=lqI2w6XOjn9Uti YQ2nqrVhR8FzlI1lQFYIFR6ChgtySkneZh0DVHPb2YH2GMRrOrX8AzgSHYhZKwzzL/8cx78pLyfmp RzmcPDbTeel/J/T5mwLfoKeOwa9tGAy1OQ3XYsRxumwhKwWdIu4uRH972j6ggLr+xZuGYCwG6UPnK uStNnDyNRBi5MS2YXKDoGcupQzvWhUHsyuyhI8vAq3hUaUReu7IiFDSgveaDvl2Q0a2Eg64sqt6xB 92GZsln9IiEDOKsCDpFauTxzOMRBhhWLWCuNJK47T2JsAYStUKb36wLHzpqhN2J1OMnOEhnRtxSGb 4FF+EAdEOgjjb0pjK6bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczOQ-00000003Jz7-2IgB; Thu, 22 Feb 2024 03:05:02 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rczMI-00000003Ikz-0hY4 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 03:02:51 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3bbbc6b4ed1so5415913b6e.2 for ; Wed, 21 Feb 2024 19:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708570968; x=1709175768; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=grJN+AzJeONYxPFqwVKM9Uij+OT9i/pLW+mGEwKkNHk=; b=vsJbVQI+/XDmKzhuUJyA1gEDOUbO8WyRHytAvm2ofkidlIaIUfOwCo1NdFbVJjgfPs +WqnGqbPvWf8h1ZAssj4z+XBJxPXTvEK49zPa1/nq+j8srOuIQCgYCQNjwVM+dbbvMsK z4j5ZPQ/GG33RW3yUBrkQlaFHvRy37Jou1eJ666w/7+gXlNithsn7AryeM5syHWcoZd0 2Lj8RNMVNDc9B+a+GB0MczZv1QbFtJDSpzmeraw9VGe5C6W0o96Dsn4jcJ7uVChLdR0b 3WzKjnsOyQbKUJabFS4vQKqktEFZ7ZMkTRUwT8ieqc06c9YN4bN/rE7bMopEAATqeL28 znvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708570968; x=1709175768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=grJN+AzJeONYxPFqwVKM9Uij+OT9i/pLW+mGEwKkNHk=; b=CeXU/QNy8C8ThsolzcAOKkd9ViBDcjNn06qkdUHUcmYKvLUGebG1EW/D1Bagonb9AD BqsvS5zPBvJAkJ4g7Fd16bzIS1CH/d6gyVASwQwTrsy7CkLoRb19M6BitTij5nRISVS/ W40SaFB7Ybwh0tF77y/zkejs9YnUsTGsZP4znEFuCG5tmLvzvz5+42TvWwjK2OVFm5n9 RmYwgRA5fIKaDW930Lml+DAk/DMba37Z8+aJhFD7oM6EgGv0zMnIJA12mMxOuTh4yIr3 j0ecEvEjskZd7JCyq8Z38vpa9hlPcLpArEyn3Ium/NZ36lb142/NWHtNi8VitvRH8tGu UEag== X-Forwarded-Encrypted: i=1; AJvYcCVDVATAY6b46qRQ6YOK0xE+MgrYLewD5gEO8H0sB02p0GK6NRvWsHsCueH+KaRUsOzv+yirVl0Ix2qPaBUZkAoZTNr7NAOwIHe0o8pKL6OXzWqJ+rU= X-Gm-Message-State: AOJu0YwlHDOI36baf08GqOECCEvHnqEHsFdKRk+OauUv1DAWk9CSOVQT XJra5NihlrorpiQCHYTE7hxLRgaM/ZIO1fV5wgCKtvwOfP28CZikgjYPGOY44IE= X-Google-Smtp-Source: AGHT+IHrF5e0wG7OyXIrS2TJJWIdex+esm8ZSi5i1AGtQTA2hm3QzTV/2zJRMkDX0FoZBhRVH6mnVw== X-Received: by 2002:a05:6808:30a6:b0:3c1:6008:1c64 with SMTP id bl38-20020a05680830a600b003c160081c64mr10012978oib.54.1708570968752; Wed, 21 Feb 2024 19:02:48 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id u19-20020a056808001300b003c14520c78csm1794653oic.54.2024.02.21.19.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:02:48 -0800 (PST) From: Sam Protsenko To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley , Tomasz Figa , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 15/15] arm64: dts: exynos: Add CPU clocks for Exynos850 Date: Wed, 21 Feb 2024 21:02:35 -0600 Message-Id: <20240222030235.27815-16-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222030235.27815-1-semen.protsenko@linaro.org> References: <20240222030235.27815-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_190250_269549_5B17B320 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Define CPU cluster 0 and CPU cluster 1 CMUs, which generate CPU clocks, and add corresponding CPU clocks to CPU nodes. Signed-off-by: Sam Protsenko --- Changes in v2: - Add "for Exynos850" part to the commit title arch/arm64/boot/dts/exynos/exynos850.dtsi | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm64/boot/dts/exynos/exynos850.dtsi b/arch/arm64/boot/dts/exynos/exynos850.dtsi index 2ba67c3d0681..0706c8534ceb 100644 --- a/arch/arm64/boot/dts/exynos/exynos850.dtsi +++ b/arch/arm64/boot/dts/exynos/exynos850.dtsi @@ -93,6 +93,8 @@ cpu0: cpu@0 { compatible = "arm,cortex-a55"; reg = <0x0>; enable-method = "psci"; + clocks = <&cmu_cpucl0 CLK_CLUSTER0_SCLK>; + clock-names = "cluster0_clk"; }; cpu1: cpu@1 { device_type = "cpu"; @@ -117,6 +119,8 @@ cpu4: cpu@100 { compatible = "arm,cortex-a55"; reg = <0x100>; enable-method = "psci"; + clocks = <&cmu_cpucl1 CLK_CLUSTER1_SCLK>; + clock-names = "cluster1_clk"; }; cpu5: cpu@101 { device_type = "cpu"; @@ -254,6 +258,28 @@ cmu_peri: clock-controller@10030000 { "dout_peri_uart", "dout_peri_ip"; }; + cmu_cpucl1: clock-controller@10800000 { + compatible = "samsung,exynos850-cmu-cpucl1"; + reg = <0x10800000 0x8000>; + #clock-cells = <1>; + + clocks = <&oscclk>, <&cmu_top CLK_DOUT_CPUCL1_SWITCH>, + <&cmu_top CLK_DOUT_CPUCL1_DBG>; + clock-names = "oscclk", "dout_cpucl1_switch", + "dout_cpucl1_dbg"; + }; + + cmu_cpucl0: clock-controller@10900000 { + compatible = "samsung,exynos850-cmu-cpucl0"; + reg = <0x10900000 0x8000>; + #clock-cells = <1>; + + clocks = <&oscclk>, <&cmu_top CLK_DOUT_CPUCL0_SWITCH>, + <&cmu_top CLK_DOUT_CPUCL0_DBG>; + clock-names = "oscclk", "dout_cpucl0_switch", + "dout_cpucl0_dbg"; + }; + cmu_g3d: clock-controller@11400000 { compatible = "samsung,exynos850-cmu-g3d"; reg = <0x11400000 0x8000>;