From patchwork Fri Feb 16 22:32: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: 202386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp27561dyc; Fri, 16 Feb 2024 14:33:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuaIkCTRvXQQ0CRyOPn9cgdbBtBrvt4ocsdsBfggxuXw6dvoNpMmkhUA1R1MtV4bAje/4WGcRIbWNnPT1kWOmwQXJ51g== X-Google-Smtp-Source: AGHT+IEOCCq/uFSxodb8RNEpnNul+Zi5l4PtLDqnvuWsAd47YTP8SYRjuOXtVXcLL242UFBYy5+m X-Received: by 2002:a17:902:ce01:b0:1db:aef3:ac01 with SMTP id k1-20020a170902ce0100b001dbaef3ac01mr3259338plg.46.1708122823731; Fri, 16 Feb 2024 14:33:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122823; cv=pass; d=google.com; s=arc-20160816; b=a6+frKypHwmKKjNcciiTp+T/ZgbvHi2oz1hk5t6JI54VoDMCOqRQTwkjRwETAshkxa 04JyXFsz6IB6ege0kGOS+VLN94h7lKRukUZjasdl2GMMjCg7vWrdlDEhUfJl9qEPyoBJ Qk6DfEGpgWTgJcQ4Xfer/YK/yxxRn591PL6YrXXNYjqv5LcbFhvVIVqxSoKKL0t4s+Cd Tg4uS5a7eFoVbr328JtEIZILxyWO4wdFft67d1GYyQyoyBXio9zsNZ+yZzNjPnfvKJOY +TGSn3YZBTjQdA9dahIAhtPdugNZ/sO/RbJ5Du+gp9huOu1jTXl5bOrJPGMl0/rkMDTv WoSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Bvsfav+nL4sYpB4KGZGKljNCHaZWKG3pZvV4LqQ31bA=; fh=0YYlQBowP+w4g7jThpeAkCcMbHLpdEyeeB9PIDuFuoI=; b=kZSubxwn/doq7yvtG2aQJp6f3r9jr/ZwQ1zZI733Vh+yP9clK9ibKHRbfaxcsAMskt Z5/8yRPT97d713j8RcCU4XXpQrfjlfijjX9cQX750Mesz9wV6UYFB4XtbeYGj2Y+LFEO yealJeLfGWKrJchmXtZutYiP7C+21AwkLBdQNUTzsEji1Ux3TeAqk8TnMxpks69fRbR7 6B77ME+//LDusjfOAcLhxYh/r1JLb22cTISVoR5TrCAGO84OaA0dT8neShDXkqglfsuG haliZgrAMEGCE3RUJW/PB6WMLu4mEblzWAtqYsqz4KXgRdClyZaHoMpH0e7eMBwj12Re mjlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Enk4v12D; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69407-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69407-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k14-20020a170902d58e00b001db7eb50ff1si517357plh.104.2024.02.16.14.33.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:33:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69407-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Enk4v12D; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69407-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69407-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 84BA228C6CE for ; Fri, 16 Feb 2024 22:33:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C99414A09A; Fri, 16 Feb 2024 22:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Enk4v12D" Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A1EB1369B4 for ; Fri, 16 Feb 2024 22:32:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122769; cv=none; b=G7wvRucOA65FmFm/PKR3HhEHXDdrnhRS9F3aHAemrRwX9lJt6iKL8PbVq7diHR02i5RQY43TCP4Buma2lknYJN80nPDD++LPnCuQyPuR7ssf+KoUeNPXxNUGxMwi0KiQcdIm48S2O7euBzk4ysIE3RvXsT8cLWWzvlkS+sLeRAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122769; c=relaxed/simple; bh=ku6VSMwio83DtGsAZETFAIVDDL/5/fD1fkCL9iTm1sM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SEqWiVy9CrF7zuvodmSVvDKrYUYhR9hjcYW0rfcjyJt/po7ijQ31q3H3b3J3mvnjcM1IG56STrbeokbEoIcAr9nLkmDQ2C46uKZhjvoqRPiqz2elf+lXPIA9Eawdm9OGqtzIEReWNoTeye2ivVUIX93kt3yoXuZZMLcSo4Bc7so= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Enk4v12D; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6e12d0af927so1349178a34.0 for ; Fri, 16 Feb 2024 14:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122766; x=1708727566; darn=vger.kernel.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=Bvsfav+nL4sYpB4KGZGKljNCHaZWKG3pZvV4LqQ31bA=; b=Enk4v12D5bhxug0A5MSAC+3zdnH21VGgpHJpxFDeOdekvRZIWGZfkRkKRGhW0w1z9v YLHlVRGodtZcLN/n6zov1l2C4JN9kauaRdkdYds8ntp42EVFT4dHwZGHAyVtZOko2m10 o5qgNh6jQf/J/QPOgKiaByK4hWZQI0J1TgsYkJ4BwcUy2dNoLPSWAORqEivSZ062+2LG S6DLIGZtTlx+6AAvFr479SVJnxD7H+F5N+KxAzpFRbwyUHYumidybZM2k4rrIXTT7J47 mNs2+BQuwWzrkIECdIJk8PHLlKNKEkONMxk9Xw3Lu+hkoRCHj+BNoI/D4T9TmoJzrgtZ yWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122766; x=1708727566; 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=Bvsfav+nL4sYpB4KGZGKljNCHaZWKG3pZvV4LqQ31bA=; b=I2LelzuhC9Qwsd+kyZ/rKjh0bbJe8Y0uedBUu1jr+3GcbZITUT3H2+urWE+KPrYOOK TY4vmeVMigKzbaA6NP18FkbHXbTLK2RihdUcsy1qdR3GsPeqG7aPoWi59j8bEqykTJch cYn2mmduBh6P32/XS6oMBtCIaPeNfOZ2lH5x25kqR9Ew7KftEKMrdNRXCjc1nn6dLflt d0eVFJJQhZJTDlfp+DAVR7BdbfIuJE3KWszICyIVbBORjy13xCP5iI6Xooq/Mt+qEj/d kTqTm69J8kD/zTufeqQRZmTIikbu7Nxh2hSE+yG6F5A0YyVzPluvk8FpSQyEXvl56+bK Rnvw== X-Forwarded-Encrypted: i=1; AJvYcCXZ4krebVTf8NucMM2sAF6aVVg5dsRqGirGhw11fzscKGbY1/o6G6FtkVfnmUu0ORrNbXpquAp/e8jZkNwkNVq+KF2JEikzUnBpZOSw X-Gm-Message-State: AOJu0YzQUqCjKu4VYiJ5/g1r607fZxf/FwXeIB8K+Fd8pBnArQm3foKC K/HHMcVFMLIW1c9P1DSyRUkrR+mrejErypN4mMein9gbEEXRBm5j/KVFV7qpGlU= X-Received: by 2002:a05:6830:3103:b0:6e4:3c38:fb80 with SMTP id b3-20020a056830310300b006e43c38fb80mr2630072ots.10.1708122766570; Fri, 16 Feb 2024 14:32:46 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id dq20-20020a0568300ed400b006e2e8cb4da6sm141962otb.16.2024.02.16.14.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32: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 01/16] dt-bindings: clock: exynos850: Add CMU_CPUCLK0 and CMU_CPUCL1 Date: Fri, 16 Feb 2024 16:32:30 -0600 Message-Id: <20240216223245.12273-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096598372809335 X-GMAIL-MSGID: 1791096598372809335 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 --- .../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 Fri Feb 16 22:32: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: 202414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp35370dyc; Fri, 16 Feb 2024 14:56:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXUvQQHxU8LDvEzj1n4HH38KlCWM7kqKFWYADQ/sIBeYlW3pQBlOqgCF0LEHVrkWDNcia4QihszuW9pFbv6grQqrigJpw== X-Google-Smtp-Source: AGHT+IGC++V5UDzzIoNXCrwmnTjyeV6CwO90vWcSWZ0kMrLY1Ci56pAN3/m/PSC3Or/p2Gefo55L X-Received: by 2002:a62:cd0e:0:b0:6e1:1946:6680 with SMTP id o14-20020a62cd0e000000b006e119466680mr5330144pfg.31.1708124180033; Fri, 16 Feb 2024 14:56:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708124180; cv=pass; d=google.com; s=arc-20160816; b=cHtw9y/+0dL093K0g10uQ1Ef4G38cxwCTBOgp/AUeFslYi+jh47oLLyw8t5uGIRgMW dpv5qc++HR5a0Ykvmw/95HUhVcYDSBroehOz8r8vKTeQ82QLpt/SdnA17M7UHM4sb2vl ZHYBMW+N/Gsa2ZYxGkv0Y42/xQj/+5OvjBfIBhipBQRRr86saPp6vxDDYnn5iI1aI/Ax tfXO+HGNwJv4M3UjAkZCeeehpoCZNhUwpqbRR2g/1eAVwxGY7LNiQUBiYFRzc7VX85JV xbzM0f6VISplowvjjxsQOEDNXEST5KypJsO095XR/MgU1et9lVS6nxM4A7IdnhxWYnDi 3YRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4h/AGQpeHRpCr+IvQpsM+5P7zd5DzznbvZF/IRa0p4Q=; fh=s67QS8sYK8UllzvpHAubINfRU7weovWRkeG/oJ6/Cj4=; b=0prpwPh+6jwUsKlNxBYNxvCMJ4H4+4wmRuMXP5tauqZVPeoW4D0RhW4dIqOyWSnlDm H0w+ewZ9P2VIYM3ivRM6OKOJg8ysVk2kqdZy9ZA2mGV9UKrRGLtoAR87TosJqwin+QL2 Om+OU2ffHzEqcGbBQOK5yyLPYZnO2raCqUvrSxpPvjP5OePNRUzdWZsj63uuAS5c1cSU 8tUn19XiA/put4OBQokHo/ehzJ2jjSqgHcU+Rhil+uF1Q5gcVjss9xpNimZBFRBs7/8r kjfacZnPaoPoQb2gcnoYKkgmkhYH8K5gwZeSrxIlhl4sDUt5dzzFCnzQduKAtHUnG2Rm SVpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lam8AI4O; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v185-20020a6389c2000000b005dc892da3cfsi522257pgd.642.2024.02.16.14.56.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:56:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lam8AI4O; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 15C76B2985F for ; Fri, 16 Feb 2024 22:34:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3FAF79DA5; Fri, 16 Feb 2024 22:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lam8AI4O" Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B4711419A2 for ; Fri, 16 Feb 2024 22:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122770; cv=none; b=U2k6e6qdTi9ZsmQHGne3/7kaSaZC6QIyOcI0dXENYfjfEvn2r8aGSqEzBWG0QZnRmBU216cuWVpMTdEcNw1VEwRpIwjHse8ntaSK04C0H1jgouGKe7iZQForO8JH96rMWJhzCS5WoUAMlFEcFjCGlcZ9pkTFNCaIhyUjKlrslgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122770; c=relaxed/simple; bh=Ug0aSHXvGjRRHpg8YcHJDBWSFTS5hBgzkfvVGyxjYYs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=esnAZrY4cNpDKYbZApQMUNrtfLDtBrrPrfbqmodrhCALi2jPUH/sN6ynWJ0m8DcSmZiAG/SJovcFM9LdEeddp7r6r5Q2PE3teLzO+LKq5+QQmtU08x0UJUsnIghtwUEkZwEDDPm37qXs57dgcl4889Rt0l43XQDx97jDivS1MbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=lam8AI4O; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e2e452c852so1200067a34.3 for ; Fri, 16 Feb 2024 14:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122767; x=1708727567; darn=vger.kernel.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=4h/AGQpeHRpCr+IvQpsM+5P7zd5DzznbvZF/IRa0p4Q=; b=lam8AI4OYBnAvqqsk5nywrCPReslho2S8iitYkCUjEhUOT08lZVzti1A+S4EXaS7tf yfBamEDvAas+2Lbaghtqn2G10GXGjM2eude3fRnNt3W2WSghoYhVvyZKddvMgcbKqmyy SWOY5og79n26TbNpbQ+EdN0H+Q/4tardnkuSq/1wfh/RnyA+kr5EzA+FT2L5JxM1HKzq eFTTqNeABcm1B3oNgW4il7CPzKIJ7PsuYG+n9mva1Y66UaqP0TSTbO5JpOeQUdT9fM3O IinPY9mZry1lMbxzvoWedhI2bpiiFle9Ozt5T0msjHYq/xCr+cugWQvzqfaGbFkk84Cs 8mBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122767; x=1708727567; 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=4h/AGQpeHRpCr+IvQpsM+5P7zd5DzznbvZF/IRa0p4Q=; b=wYx+vCHlqbYVFegP5lzmnUwrTklvB80J6Mlb4kHQF3I+NGf1by7gIiY0drfcNQNnLb y/fKluYQ8K8R8d65Z9GdmIhLuWZW97wAxQg9KEqtn2apN1TTOYsCl64XGOh77FA+J+lu 958n5DwcW8gc7nZt+3d93qNkCCq7J6vA+udoLJexbXH+4M3+TrTE5jVbi9imRxGVKdON oAL6T1uLhGqyGgdq0QRYgRF4cZw+cBJxVyv5w8niFJWNFK+/gGR+5ybQvtklWZvBBIxI 2eyp4YODTb5BCDbIZeCMhOrcSx6Du6pz5Pdb/CoVQetT9YL+6cXnFEK8Ur7GwltOaGhP 1tKw== X-Forwarded-Encrypted: i=1; AJvYcCUHzAqG1GNfoWPJBBO5AM918/thtS56KLod9ggyu6u/NFpmkfsqMTQOxFov7TaOkwoL1rLvVU4veXmdYd7eItx3fHbGTNDqVE19BaGz X-Gm-Message-State: AOJu0Yx5Fb+Sdi/DJQNpyurcqGE8ugXpnUXTJ+OdYlWY2Xpx55zQ9Wwe nlZH1UKOeGG1j80+OavhCOnhMVeIKwSxbkYFZtTQgg6aRNOnF2gEDyyNlZgAbkc= X-Received: by 2002:a05:6870:2105:b0:214:dfe8:2b6a with SMTP id f5-20020a056870210500b00214dfe82b6amr6594730oae.51.1708122767499; Fri, 16 Feb 2024 14:32:47 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id mj12-20020a0568700d8c00b00219f34db8f6sm198423oab.46.2024.02.16.14.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32: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 02/16] clk: samsung: Improve clk-cpu.c style Date: Fri, 16 Feb 2024 16:32:31 -0600 Message-Id: <20240216223245.12273-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791098020574696282 X-GMAIL-MSGID: 1791098020574696282 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 --- 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 Fri Feb 16 22:32: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: 202387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp27745dyc; Fri, 16 Feb 2024 14:34:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpApL6RyiJYcmW5pQH6t/TjJxaCa5+H8JsM9Hdg1FJdc73X5FY26AlXWlePy3WZa0jnIdGOO1+8ZB4uc4To9x09jGXGQ== X-Google-Smtp-Source: AGHT+IE7bOEkWj5GmYU0c1JQEYnk3V+rbKKIoTb/PTNGg9VlwFNTWmgsCe7zxOozHzuhYkLR2LU4 X-Received: by 2002:a17:906:f28c:b0:a3d:ac47:614a with SMTP id gu12-20020a170906f28c00b00a3dac47614amr3024584ejb.10.1708122860308; Fri, 16 Feb 2024 14:34:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122860; cv=pass; d=google.com; s=arc-20160816; b=J/Zvr2vnqkoBhZpjviiR+0LdRO747m4n6PXZfa6Ck7U0Y6oDqj8dvtpPXV5p9/YHVm XMpvGQ4rqxuW8LjRP9qEyetYY7hVkUQyvLtAjzBx1ZIViYxspHtHCm6yZxCXZGqpGkjt KiVaIuqqFzejQauKInUAAhyUPEgkQn7kQrKF8iwjcqy70bUQGLV8R2RLB9kmcDRNXYMM Y5RqXAusNZElhwKc3wmQvH+DIu4bIPcOtKkA5lba0D1eFAPXsymkUmmHP/UVCMzwfV38 uGogLm13zoqLKU3IVIQ2BXVXdeoSGBC3+fDFvM1ZMe9r81vGSKv6dFMNzKCDOp+4Jhrp RyCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qYcm4iJ3mR2A37/LSJBHbBeWlNo0peHIDmGfwHsrh+Y=; fh=ST0MsKpTApiGl3mnqhn5Byd7Zg/Hw73132gInDgxTbE=; b=aeGa3/at1tL1F7CAwcsJJ0DRMspx8fdX5QnU7287ru2vwUkP7WKmP5WpsU/MtwGFQ/ gYKLEX0dsWeEcQw19BcC7F/JVPmclQiqCveyWL5Gu3JMb6K2DzX09lrvuLF3j816bUkr H5REGzzXv+B3JpdbxHsEFN45yiaZjGrIAW3H87JBJLFWxQSweEe4S0jDZbSaOtH6beHG bxY8H/Ckm++8VCXDXnv7Ssi+ho2tWtIgnd69tjYkHjqfZGxheHKyIfLyMEnSuZnqUD9j XfvOIJFkMbpl8gkazmtf/izXuIfyq0YSQL1jbKueJuxDyW5dZuCmwaHgV6pxurpIHG/Q kT6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HriQnBiL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69409-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69409-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id nb33-20020a1709071ca100b00a3cf73f2a22si329066ejc.125.2024.02.16.14.34.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:34:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69409-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HriQnBiL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69409-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69409-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BDE421F2473A for ; Fri, 16 Feb 2024 22:34:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8EE914AD0F; Fri, 16 Feb 2024 22:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HriQnBiL" Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EAD5148304 for ; Fri, 16 Feb 2024 22:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122771; cv=none; b=hd1ibutCqqZkwLTonDB6PifroyYXescYEEe030PeEyqylXB9hwnidWWKGYdwMtM/SHXU3zmRFzRWtxPo8khUaONTNAKkBiFXAo7GK2EIc1ulni3ya1UcscIeOnwlOfttF1Ahi7j92sucPdavgbCRQfw5FLR570jj4uXjT7iLdaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122771; c=relaxed/simple; bh=+fQChFJcYp8jj7UhaXy8j1dFeHPJZY+1zRRcdznyYwM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N8GP0czlQyiXMyNReA2CR1Vx75p1o9urBCBjFdzwFaOij18ImOEhgVwecVnQBeH3IabaihmbFRwcqIiT2bKBmRIqJn2MeUxAR9AFHbnFQqv8czXw15hzoSTRZh61qhFpYfDeR2f296U/QyFNHtDBiDn58Z8JRUcVCO/Z8VUJMVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=HriQnBiL; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e2f990c8b5so1166550a34.1 for ; Fri, 16 Feb 2024 14:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122768; x=1708727568; darn=vger.kernel.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=qYcm4iJ3mR2A37/LSJBHbBeWlNo0peHIDmGfwHsrh+Y=; b=HriQnBiLZhHO3Evd9ttC6aqCG7TVXsLB+5ddCn8NaqL5Hln4h2QqCTdmQk5eUiBjiu reUHatxClTj11I4O6JoQw/tERhmwIHt39CDXUJXN/0CA0FU/6cUwEDf1R3ln6qyqoxQP mu4jSsWtnKFSjl0V0ZgzqTNQ0uqLYBKXE3jFgjnYRnB+5RsH8yyFfRYArg1E74sXPZTc 0zn8PL1AmYvGedzvYF2E2dxdZDL9dO9foYNAojT5JP7nCUTYgYVoGdgyhpZc6hYRG2PJ hjWoCP4T0yCaPyNssqf/mlFmaJ63kxHooo5DPjNZ0GWxusROdR8kMtfQzxH8My05flxz Emqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122768; x=1708727568; 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=qYcm4iJ3mR2A37/LSJBHbBeWlNo0peHIDmGfwHsrh+Y=; b=G68nrhLtRoAOTrJtrGZ4zxldpvSQstH2hreIBtFPzVV1MutsKKgBILccLN895/4sMS VtOEIr0BZ+rVneeMnnbNu+cHwwi6nguOQpZaVwsWzLYnK6KluNlpP9nUTCwkSyOEIPg3 JyIWHjo/blp3naKShi+V0j2me25+1NH5CXvY3eu8KbveYS2DbdJtQ87l6Qjqe9IpBVC/ sMRy0S6tL53TBhbFQgY7LFEJXo03yW6i4VyqdMfRo9g2sy8r6dt2SkRIrhmqXPE9JHDH 7gdOPYUauWG2cxeih7Fxj71q4EKNdM7Xfc1jJHKDGclLFWA3UxvdEnhExXlpLHRtSjG4 I/iA== X-Forwarded-Encrypted: i=1; AJvYcCUx1du5wq3oaE/oDl+urJAk70b/qevt+shsaBgjcmT2ZgRZecpAGnr8WEK3JLFGuJqXGNWLdMAn4mqcLynOzgWUk8ilAd/5kGiXFigC X-Gm-Message-State: AOJu0Yx70Cmtgd+WZU2n/4HlvLJYHTH7ExzvAXr2D3Nos2DtBjhI97Tz hJFeycyrbegCU+rs7ZgSVnQURm8h0m6sakWV549y5UmdC9MQPNvmO2L6RojKxUY= X-Received: by 2002:a05:6830:1158:b0:6e4:31e7:c158 with SMTP id x24-20020a056830115800b006e431e7c158mr4959777otq.19.1708122768363; Fri, 16 Feb 2024 14:32:48 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id e24-20020a9d63d8000000b006e2e95e852csm140473otl.3.2024.02.16.14.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32: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 03/16] clk: samsung: Pull struct exynos_cpuclk into clk-cpu.c Date: Fri, 16 Feb 2024 16:32:32 -0600 Message-Id: <20240216223245.12273-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096636286941069 X-GMAIL-MSGID: 1791096636286941069 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 --- 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 Fri Feb 16 22:32: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: 202388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp27917dyc; Fri, 16 Feb 2024 14:34:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXCX2Tlep5M3CYLglNjjv85a1ro/5by73VBqg2o9TGl/163UaZBKsjQDOh4cbldiX4c/0jskNyv0hbgZYGZGd0OLjFZCQ== X-Google-Smtp-Source: AGHT+IFk3eK1vUhMgxaZkAnvnZXhw7fObyD+vz7Ud10AoI2f36m3iOCUrpCoZcDCCuOcgaoYcciW X-Received: by 2002:a05:6402:165a:b0:561:f7da:ee30 with SMTP id s26-20020a056402165a00b00561f7daee30mr3773206edx.42.1708122884752; Fri, 16 Feb 2024 14:34:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122884; cv=pass; d=google.com; s=arc-20160816; b=y4I/0cUayoddvfzoM71R2sN9YMS8gGEpf6jE9MwV0ldE0YeclMMDWC1QtXNP7X8GX2 ifcvNkYde86ZZHRodi2iPVAci6PkfuY/vstGtoFjnaf2k7dIQIA+kRxhtW3/SOKueK5d 9wfrZHbKfRT3DeuQqaZCOdSnA7gK/epcQqhP6Huwj+tsa5DXLlIcWBddIcZ9p52qCPlz EO5RkIPPqqEeJtIrBe5UFEbvTTyo7z4xzzyZRKqhJ2O38r4bWKtHUhJhf+LeRRT3fzEa i2S1V0eIk4usGKVu5xGQqBuTBZI8k2D2Pwrx3v5AAFeujGhbgLIvQa8uOAkjVVxg4CSK Ji8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tzL3yrVQ7EYMi4vxTiKilEqboOfr+d/YL4WUplo587Y=; fh=Zf8/0O/y0aK2PVJpBTsEiyfT6iXA30sUK8kTLeg+Wpo=; b=o2KpEQw4Y5fHT6KH3o2I9fHl5omUm18BcgOWZxkZe+MpDqwSwDl8noLWF6YbYV+HwP 2ZhZ1yB7X9kYTkyLhHaJA4awShyWRrXKi860QR8lAVwr15Suz1WdfPC2WHmSzEIY8qPz Djjq/Hv95M3EZEB4vOHSM2DK8EK1skQU9RfLwGckqwQYXPMM2FjKYyTI+9RfEly+eXSN E8IrdNnClyuHEr+mfPxYmLUOYGTWLIdGI3TnTjjUe0LMKyulIW+NrWVimas1ZoevncCQ u42OX/D7gZYTpGhDOwLn9VAhJeuwqDxI6Cs/pVC7ToHGYYqbUtyNpbb1Ragr9cVJLIqv ToEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDy9gzHg; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69410-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69410-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a19-20020a509b53000000b00561d07bc984si337402edj.603.2024.02.16.14.34.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:34:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69410-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDy9gzHg; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69410-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69410-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2F1601F25D80 for ; Fri, 16 Feb 2024 22:34:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84D7314C59D; Fri, 16 Feb 2024 22:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vDy9gzHg" Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21B9E1487C3 for ; Fri, 16 Feb 2024 22:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122772; cv=none; b=T8vi3f+NVszbOmWNA5/1ImwXVxpeNh8Ihc1eJiz5HCShxAjFmp4iVmA8nFU/GoHcIx/O31xoOtxgZZg5h0tsQoKEKdbm7Z01LdxrxjiK2B4xbHYhUA/j++2XNnf1pxWrKQtJKSie5hOF8lHdxY+C0+EDdqAyIrzcItWGydAym7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122772; c=relaxed/simple; bh=JAEN95vY95CVY9BjR9iBOZz5ov2YBs2UQvYjpLB+T+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=grduD5YVmjlgWBi7NyJSQ7RL5h9Fj/Is0n+zTmONe+SwpQ+Y6Yj2a0F8ksJgb+WH7Cjh8e6TFxg9FdGoEmsLn8t6Uaq5ZkGXUsIEKOV7bbSaPEuxYIDTb+tTVb7sLYn8vD8y/aafLp2aPw2Q8BjohAV60KE5meTpbaMULXqoQNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=vDy9gzHg; arc=none smtp.client-ip=209.85.161.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-59caf51d4bcso653811eaf.1 for ; Fri, 16 Feb 2024 14:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122769; x=1708727569; darn=vger.kernel.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=tzL3yrVQ7EYMi4vxTiKilEqboOfr+d/YL4WUplo587Y=; b=vDy9gzHgT+3KVJ+EVk8CWyLUkYttDUxjpKaqqUbLHw9lhIb8LXe/JL1XlOasErCR/H TcOPl6MYcDbmX6lyAIbxiQq0+ZhSCjoqvLZaYefhSzKD4v5WttYX0x31RmcXWc8JQ/d9 joxYnbRyGIFEHkkWL4X80ldLc8J1njU0PdoFvS9G3gEYVXPmP2Wa0OjdI8jYY96Y9hg1 nJcif81t7KWg0h5feGN5XKVml0MWHJJ9OYbYclloCfWpX/XhnvRfanBK6qrxCkR+q760 uo+EU36CXGh942zWfF93ghEObPXoe1J1P9yzC5K3XHdeqJD+CtEUFhpmhaciKduzX0x5 mYvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122769; x=1708727569; 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=tzL3yrVQ7EYMi4vxTiKilEqboOfr+d/YL4WUplo587Y=; b=uTDssIuep5UTIv4Au+yHHgMo64WzL5IKMzDQYUfHDevH211upel7XhzHbv8jNV+BxU JxsjsJ2xvW/vY82i5pP3MFrRFMdrgFbNHoA/jq9aSAo27gK/Xz/0pm+NQlGemfUHZF91 l8YuyaLIRDHcpEWk+uc/BAzGj4kVr6qcbk/m35kDqO3UDQcLnxrGzfgcJHrg3/9RRkNc YJS0KpMdMmdpBbCOye0+KcmEgwCqqS/oYXVAowBi7TsEI2/361CPCiTC/NFUtD1zvkXz 8Ngj2760cDZwuN6a6BfTGB1Zq75lw3QH7WRUOZm1O3y1zj6xgoZ5wYZ9FLcmG0IEtorg AEow== X-Forwarded-Encrypted: i=1; AJvYcCXPTPr57AIsfIvwdpj0Ydy4BapxQuTtYCtzaGu5RPfbi/gKes/I6v4+02fM2wiOfldobJatHEho2gUX2e3XBA8iCAWQHIoBAkKthYY0 X-Gm-Message-State: AOJu0Yw/GXD57CbEGZZJi+ojHvdlJEGwmn/6gGGuzj3Uxys5MXk39CYv D2OvVdkkDwyyHjgCarm7dAgVIT2C1nrMBIfn4f1WXNs547B+pl4GhSQCllGYdus= X-Received: by 2002:a05:6870:ac2c:b0:21e:63a1:b530 with SMTP id kw44-20020a056870ac2c00b0021e63a1b530mr1452890oab.15.1708122769193; Fri, 16 Feb 2024 14:32:49 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id mt13-20020a0568706b0d00b0021a60bb6f2dsm201925oab.2.2024.02.16.14.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32: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 04/16] clk: samsung: Reduce params count in exynos_register_cpu_clock() Date: Fri, 16 Feb 2024 16:32:33 -0600 Message-Id: <20240216223245.12273-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096662194096139 X-GMAIL-MSGID: 1791096662194096139 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 --- 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 Fri Feb 16 22:32: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: 202389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28100dyc; Fri, 16 Feb 2024 14:35:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbtgGgzNBhmzgwSeMoyOsLuFoWC0LMYSjb5fempTTp5eKJU1+qsTRodjPSsfvhroVp+kdVordRe1/lQoaGcWn9Q48MAA== X-Google-Smtp-Source: AGHT+IFYxN7G0ePowJgAghrfva0SgAhL/+N+yEvkCJUNYGauuiEJjkGdFCjrOfppHMCX5o5M6P2/ X-Received: by 2002:a17:906:af09:b0:a3d:3aef:2311 with SMTP id lx9-20020a170906af0900b00a3d3aef2311mr4938900ejb.35.1708122918134; Fri, 16 Feb 2024 14:35:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122918; cv=pass; d=google.com; s=arc-20160816; b=hnV4R1cx2Ho7Q9deR7Yjy7UE4TJezVNBZEl7zVRTR8B1poCh7HvTH0a93vwsw+tiVm 6dTyNzn6xTHzsw/FrXm4C4NDp7rCPz9Zjl7otViRyk7seg5I4+/+KXcxxftW/LzLr3AV rIrI9d+ZtZgTKzjlAJiqRmWyMWgk32hlgaZ5st9vDd9tc/r3v61ZeWUzpp6VzkBWc57T kTFQ7GrZPaWP/AVr+tSu/vTR/BdNeMrn3TPDfG5Tsc78U0eYm0g90N5Gd5Ut51U5Mza5 OKi7NYhOF3jqsog8MWfeSK+f+Lm8HhABA6iRsWiaDcAuGQdzsSUgYO7qm5Vaic/ABKou UQJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Cx1pe3dvuwBHZD5HJSTuBK3OcEfxD8vb8RyVZ6GAHCM=; fh=x2b+KMDPIooLKs89rm8VmTqr9zcrrkHg24dkWI5Zk1U=; b=T+U0ASYvipsHfXVvG0evEPEihQo3eMDLXLkfQivDufHRdwus2RXAGXKmGtHG8l2ilI 5621u0tCf61xK+PNi8Nnw3MXFYc++8o/V1S/65ZH4DNvQmFB/xuXvHR6cToaCo5Cfm+8 LbcBaZWbw2+FGNKR1qj+w0UeXZhQ1wVxUK4WkQFs/G7qDgg/Mxean2U1MIUwX/gw0rVS y/E1fsQkAsezNp8IjL2J6zwSYfL8VEyYQNbVnjqZ/d+b0x+qb6TuyKgYd+eV8QiX/sil 1Bi1r0AwXJ0JwBvHsr2bAqkGax491UbQCGDkBkiKv6NX0/O9njHJMVzpTot//fVNB8hd NTqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4mXHuMq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l20-20020a17090612d400b00a3d6382a307si320119ejb.830.2024.02.16.14.35.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4mXHuMq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 930471F25C27 for ; Fri, 16 Feb 2024 22:35:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7655414C58E; Fri, 16 Feb 2024 22:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="O4mXHuMq" Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB89C1487E0 for ; Fri, 16 Feb 2024 22:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122773; cv=none; b=dRrUbQ0DBRBB4lt8LN3SvM2Q4k4dsViaXfdK5m+jjGsx8UzIJTSmP2ecCTIrQ1zHqhqdUKa/0Ehd8n4JXjgqM4A3NZCcLFRrB7Y5lH/THYhvNIQfdEFp3ZYudOVdqcLPgy6UjwxR6kyvPM+44j/obLhUu5M6Fc6XSLa1E8AFiMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122773; c=relaxed/simple; bh=EENDe8i/hIP1jaiAMmy2hIQ5Oop2tfzV0CgfTOHuWhQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jNdNYed1j1R+9lU5JBBCI7d+lqRttu8fUreqRLiGiXpw+em5dyOLjdUmJVV9QIG3opHJmOb3UeJ4rmTdb19SIXdqm/ljxF6UjkG/xK5hDZx5lJXV3Jypt5rquFk6fm/mr3v199ZWq3ZWMvSqqbiPT1Wc4o1isrbXWVy8tpiW86A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=O4mXHuMq; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3c0d59a219dso1523137b6e.0 for ; Fri, 16 Feb 2024 14:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122770; x=1708727570; darn=vger.kernel.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=Cx1pe3dvuwBHZD5HJSTuBK3OcEfxD8vb8RyVZ6GAHCM=; b=O4mXHuMqabKAVCvrsY+CQ+q/5OJcYY3h5RHafCq3TYkYrZ84WuHK00bN+c0n75Pk8x +a7w5FH+YeeVaS3dsUpALcDSuI3SdCQWTSgfcjccIQpyaNvx3rSdzUC7nmYd/OE7B0Cd QwgTTuwlzlrIS3DZB7DTbBcng9/pZ/W158gfRSS69yXsRnbQzWsKE3FjBN7DroMT6f4w vOSOPBCWwTn3HdTkcyUcVd2th8Fln3Uho1j4CqI8iwMERGhyAspHXgSwymaQocBd38YW iBfAnBpeXFOAi8Wpkpsr3LmL8vZ+viU6xCof7YJ1uhdkMLkaJ+axHY9QYsF6DVDP1599 id9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122770; x=1708727570; 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=Cx1pe3dvuwBHZD5HJSTuBK3OcEfxD8vb8RyVZ6GAHCM=; b=vrjQFSFZcGmtPrThbz7u0vTa5tlKrkCA9jYQcZXDqcsWEulQFiYFXerHGtxL7GgZKT XffsY6EP+qH0tS8JIFQOIbPy5b7zerO/nenVBOIs4JaaXMQcLFaDjlgCZTjb9mx206x7 bzW3VTJ/ZZSKC5jcsCdirCGppWfLXLgPqS8k8oa7F95aQITbRIJCx+1WXX4Ac8bfRWsL dppglMIhqengNbHuSCE/RfLs6IfgRugbuQN2SmsiPiA7t5P1PkQ3aXUSkDkHUx5+KFTN x028BgRJaT/QI3BJkvQNyAhbN1Cy1pd2V9b9vMvmEUXxP6K0mwvMW/E5EBPtum7eYlz6 tmMg== X-Forwarded-Encrypted: i=1; AJvYcCW+3AsOCYn1JTKiS0h4cy++3kV/8hWQgmSMGhRdFODdlF1mn5iKqqjqDptE/Rs4PAzw4ldotYbMbGUCi9iOmmiE3+0t/gq/VneY9U64 X-Gm-Message-State: AOJu0YwdaH7C2tnqzK0scAvgR9stoaJASxCYLGbMrYVLZnGp40iHEVW1 t84WEdln/ho5pxAxw3jS7u6flfj/DGkg9lrM0BF9jthDvIiTar90p3IxfYosFnc= X-Received: by 2002:a05:6808:118b:b0:3c0:32d7:b93b with SMTP id j11-20020a056808118b00b003c032d7b93bmr6891732oil.50.1708122769980; Fri, 16 Feb 2024 14:32:49 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id y16-20020a056808131000b003c046fa43d7sm127176oiv.19.2024.02.16.14.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:49 -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 05/16] clk: samsung: Use single CPU clock notifier callback for all chips Date: Fri, 16 Feb 2024 16:32:34 -0600 Message-Id: <20240216223245.12273-6-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096697228000621 X-GMAIL-MSGID: 1791096697228000621 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 --- 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 Fri Feb 16 22:32: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: 202390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28142dyc; Fri, 16 Feb 2024 14:35:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV93tsqYBHNDHdu62Y7EPyCcUmXxgvfrsfV+JZB4726t30Wzqs4rjvX5iX7MWiDSCMd8NBh7HWS4SUU0JFrdu+D2j5rjg== X-Google-Smtp-Source: AGHT+IGuyCkPo4O+JmNY2XC4iqWRT0Rf/yGLB7iJcR3VUsP2BdTg8nr6dgNCruCxVFhvRqEO9nDq X-Received: by 2002:a05:6512:3991:b0:512:88c6:326f with SMTP id j17-20020a056512399100b0051288c6326fmr4783380lfu.59.1708122923706; Fri, 16 Feb 2024 14:35:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122923; cv=pass; d=google.com; s=arc-20160816; b=cD3t7irqyPxCeLWHS4OV9bGMoOtbaM3KnBObaM/FOhEyG4+6jL1WOPuMWg70ENQc8k n84FbNgIwEzdzc9bSn1VDt7b1w7O1ahD5XXHXviwzBenzHJlt0V5jxpx/nC0r+qjBb7e Zg0HXM3G5Op7wgidvUc1nIltlZC+UUeKLBjvBgc8Ov1zar5NJH3xUlhd2ceuXnGKi0ep Y7823vcycQOlPc9oTXHB2lQy3iD+RiV13VknDDw+YO8ai+Beppfi9fF03yNIcw81q6OQ hkJdCZT4xuJWSqJJJdvncbWxFKoFR6H5GLcVvz1K6kZkrFOGMELtClCPH+gDeenGo7kA XtGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nlC/G6qyLD1CwPpss1xClTu9E95TKvCvWeyrCtKG5kY=; fh=7PDeiLFf1BJZ5Ww4OqUO0Zz4KSr69HaZ1I2iS4LCDRQ=; b=vXh0Hrbn8eU/qweXmLtezLAK8F2u5BaDoVPmupsQPFNjt3XH5ksmEkTvov4a5j6I2+ 6YiXiUav6wqJpqXBPSpcEW8C1p6vOE3a5qctgSGkiCpRw6njp/S3mv42ipgRlRMTKEs9 S864rV8ELLXJv+JWJzzcbpiYSPq/ToUotCn8D8vQ6xzsiKB8YdW9AtFpp/yIqbfnM9Y9 Tqo7yux5ZDR5d7600YE+6HOzN/6zFek5BbeEnZzC2auk1PXdobF+XMXiDB4zXci373FP H3QHvspTHTAVn610vad56aADeffS0uUHhYf0sLF8cNbrfHU9zkWBKJXAjs+tXIXuYXne fELQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qGelz+X2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69412-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69412-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z10-20020a1709060aca00b00a384f2879dasi294095ejf.91.2024.02.16.14.35.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:35:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69412-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qGelz+X2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69412-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69412-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2910B1F22DE0 for ; Fri, 16 Feb 2024 22:35:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C670A14E2D4; Fri, 16 Feb 2024 22:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qGelz+X2" Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7F55148FE3 for ; Fri, 16 Feb 2024 22:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122774; cv=none; b=GrQNTG0lv3OFt2BH1e1GFdo+iNQ+256JNYOC4rI7DC+V8PYGXgGdB1i3IL+GhCzanJugLc7YZeFkV9WxqjqGcacz9E9PD/zUhjzQzegFjzsYWwTsu7LRAeOpVE8qjUaFXbJ1QNBuHa9UH0iLEFLVBHXvTaBNBGHQkcgYgxoMhYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122774; c=relaxed/simple; bh=fUhPeOsXzdNBsgyQxrK5IygDWIDaj8fhKRsiYpXQ/2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ewLU79Kr8drsHwlm11azVNJ6+M1FbngH/V09MA0d1CNSkBdVVszE9IXxKUrkRMp9fWR/AngaQDMUH9l24V9rUTNIsIMmv04JBRr7MicqQ36tzf58j+PLXz9hfLtnx69n9XIIOHvJ+IRj9BV4QhThX776+N6ewp+jB7xBxU/R03M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qGelz+X2; arc=none smtp.client-ip=209.85.160.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-2185a9966bcso1005790fac.0 for ; Fri, 16 Feb 2024 14:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122771; x=1708727571; darn=vger.kernel.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=nlC/G6qyLD1CwPpss1xClTu9E95TKvCvWeyrCtKG5kY=; b=qGelz+X2/WUYFpaVUPxY+y87ukCI3bLkN9E4o1PmfA7C/0+rh2oVbnFdS4VRXDsJvy BeLhlGBKI6smGXcQyPZrXZ7jr8m4x/wAqHnmQIPz+CSLkNZWRlEO4psI3ELXqlx7p2Sd wLCLlK5gzg7WfEPTYDT8AgjMFs+B29/v586OKe4JbMrIx3VC5qussasvaidDPReJfYVx j4I3gysef9kCc7dUUBJrknj6OLtYpeX6cNTF+9ffIe+d17/hcZACz2g2bMNrEj7I/WkK QXbfLnGr6OYXb0EexN99y3SyxQUPiOEIrAdHYiqFSzge6flefkVps8dQg98EggIGHhWD 5DEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122771; x=1708727571; 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=nlC/G6qyLD1CwPpss1xClTu9E95TKvCvWeyrCtKG5kY=; b=PKEV/ySQyliDYZlcaW3eYXYoEUED8guIkOM3LH+PKfiWGYhsqa/n/8P22iRw40sY76 4tltpdR6tN146tFz3uGWa4zCzhDBtQCkxyOVd9+UA3r6ETtofN70NLC3Yx2BRle/VZhL 6zCBuU9hdIMViON8IiLF19/XyrytwxUeylY8lwlKknhO5SwEUKQ4UafiwpV/KkZvBN8K 49LjrxqhAnKCc2b1shekHPuzKB5PEMPYTorja2X4bX8GOL/j3AfvtzEN0JfjgNhOTzeF NMYnK6M+OhkNM26S2Bt8GfgjUx/4IQay1YlWg23pBTzN5dzeqhjKJcNO7CFbDqyOnq/y orzw== X-Forwarded-Encrypted: i=1; AJvYcCUaRZv/MN1fV7F4tTVrNtPZ9eV78ZsLfQ9TAdftysTzDhMI7Sjk4mknSEY9gFYmoQTU+NffTPmPuaJ8+AaHRwwuc9OXdzw1FDqSfYK/ X-Gm-Message-State: AOJu0YzaJ3l2zgAPVv32C8/E/b6MgO/pIGwwkx6ndlRQJw6YhGTVEgRf wd360/jvHVASb+eCm6Lh1PHVMUqTqYixMgQhyerpG9CnKnLqh4T5yJePNDzwR3I= X-Received: by 2002:a05:6871:5828:b0:21a:5fa3:48a7 with SMTP id oj40-20020a056871582800b0021a5fa348a7mr4293326oac.26.1708122770919; Fri, 16 Feb 2024 14:32:50 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id n24-20020a9d7418000000b006e2e1400bd2sm142227otk.0.2024.02.16.14.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:50 -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 06/16] clk: samsung: Group CPU clock functions by chip Date: Fri, 16 Feb 2024 16:32:35 -0600 Message-Id: <20240216223245.12273-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096702846948748 X-GMAIL-MSGID: 1791096702846948748 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 --- 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 Fri Feb 16 22:32:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28427dyc; Fri, 16 Feb 2024 14:36:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPtBB04GGCkWvbZGyz6nROaf/wDxw1OyEixoKdU2VVwxSr0ArPz68Egkrh936+ZsG805JYVlueR1FNuf55nIhqu4Jk4g== X-Google-Smtp-Source: AGHT+IHTFnV3txmDnClk++A+jhkK9ZvO94bGsuU4seblr9zisYBEO0Q3h1JOrnvjBMKHr4jITsks X-Received: by 2002:a17:907:86a4:b0:a3b:ad02:98b1 with SMTP id qa36-20020a17090786a400b00a3bad0298b1mr9545027ejc.10.1708122976641; Fri, 16 Feb 2024 14:36:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122976; cv=pass; d=google.com; s=arc-20160816; b=r/96n71y4GJuMh8kkmBDpBsjirKRmhBnLLBIbuLvriTL2JwqBwUsX/c3wNRvRjP5aO gMSWXNEY94YlfMyibV1aobAqGBcIQ4BrV/gsSuATFlFfbe0HcY5WxmjWMKQmO+3sl3VU 9uP14qojXNmlOrFRbwvck6itXJJoU4n10rBgeSniH27kO9RxCJOqzStwS5xslblV+hBa UG2vLaLt/eIXenNrlRTArMrvbiIqjj3lxeOTSIbguwGbQRcLIFSS8L48WvsT7aoa2hjG 9fDUpTylIC3e+K3A+hmL55cWb6r7gz1ei718H6AiC+luits1mzvcACA8QXilW/1myLbV 21ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tfRvgXqx0o89/jIPwVq9FOvHNq0zNnYAgZUMMD+pgCc=; fh=MzMin77d/8Fke9tJxogeV4lHXA1dnBdle4MsIc647mw=; b=Bn/Pc75cR2v6GuptBDew0JCR8f86MroX3wKB/H2I924iIs3EIMq77VfS+OZmAgEWPM KnMKGLz0O2bpRwKQk3ku2xliAaqgbn6ALoJbSmkejbxP/M5gcOlnbUxjcSudceWB7Ho4 Kx5gBJ8FJOgtd2IGwRlwAntd8aq74nScn7UYg2V+cjyjGgg1gYCNmHZoGQCj6LL8uDjF e6NfgRZJ6CwRtoDAkzcQVPC1hPqifBo9ihrxdhiwSk3MHXQG7DL9iKbM3FDYFb+IBi5x SP/BZO2kXE0jN3tsXMApFf8fMT+77rNTS5JjLNgDUFvr7R2MXqdOQBUDaKhGYvwRJcdN LlRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qHY9ftYJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69413-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69413-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n25-20020a170906119900b00a3d9ee35c15si301401eja.165.2024.02.16.14.36.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:36:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69413-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qHY9ftYJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69413-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69413-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BF6871F22DE0 for ; Fri, 16 Feb 2024 22:36:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85DD81350DE; Fri, 16 Feb 2024 22:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qHY9ftYJ" Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E74E11487C7 for ; Fri, 16 Feb 2024 22:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122776; cv=none; b=FwJ1iuiKO6VDDvWPdWbWsLxZETPhK6yzRjAe96k7rOQFiOrJSG/BYbCRbE0vhQ0Ul4xgQjKlQ+uNKONh8gql/LLHzkEuS/sWxelxjUZnoTHQIhvwoj7xtgAsS4dk2nLOdyXaYhGVXcs9vlSvu70R3De3jc8gXatkpHyKZ4XJNUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122776; c=relaxed/simple; bh=1peV2N9hxDmggLKdh7aFERIj95Gt9U9ZGNpYQuU+WrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TKZW6GlXdMnsdYnztMiSGhOjeSbP8VOXNgJD7ZuWkcq+Ap0lcTxdeqGdunebDwkH/0WeBw81+vqUdzdts9oQkIRsT5QE9D/ShRd+rKaCXBp24xn6RvWzb0pZGpdr832Xlo3v3UI5LodOE3QieZE5oAY005Hm+A7/Fp7PEEsUtfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qHY9ftYJ; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e2db19761fso1166196a34.1 for ; Fri, 16 Feb 2024 14:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122771; x=1708727571; darn=vger.kernel.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=tfRvgXqx0o89/jIPwVq9FOvHNq0zNnYAgZUMMD+pgCc=; b=qHY9ftYJgEEml1e0A0ue2EqDJzRSgZJLOgxS4LjBiek6b9tjyttURAWUayZMDsb+RB 8//ZQGd2cct5/aQMuMknyXRnVxrCsOaT1LI/oHhcW7HSiROpC8PYgx/kr/CrsuPb6v1B vRfU5nQuYBb5UPaPjp4AfC45gs2gDNK9baw/yL07Be3o5a3HxXeKdXCSLb/x4R//Xmrf JI67WS06FgxIKN70HGwbRtIKvhbp2YOy0S9LJ0St8BShIiu1+ymqfYBLkyTBw1ljq3J9 kX3fEMLFd0JdFxv1XYMqIBQlFyiq5alqUTiVfBc8amRpGyJtWvhoUtl4yXKV45gg+8ZX NK1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122771; x=1708727571; 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=tfRvgXqx0o89/jIPwVq9FOvHNq0zNnYAgZUMMD+pgCc=; b=Ijllv937FUmcUJUKV2PfHhCVvBGepTnQ3R/GUK44n9Y0++dBrryGBFYSitJlEgslU5 oAk5p4mi2R+n8gHtUKEUrCAFdXZBzuNlMqqVo3qaxjKjQYEhBRCZqJw9eLLETDq2aRUW CPQocgPlfE/DSGeBuEBYg8dgasSNI0Zk2tyFLrtfobXWs8N5D31reClKvpwloZgQuOav w7J+/Tpoex6wyX+5NmFdpIJv4OtJbaqo2wn3coHUgCR08MkzMwd8/NI8GAkl+h2g9XK0 5NsJddYCQRAGSHoEYwwAAFFapMX2m/aCdahqAPMNM165kFAZHHMLmThB+4AEjTbYhuIn Z7cw== X-Forwarded-Encrypted: i=1; AJvYcCWT3jPFlH7IFYEfQUtvlgY5nl9hSTgqIE9fP71KbTyCHUkrRjBPZsTloCe/3ZUokBiCzPLuew+Vet4p9g5E0YmfWANsirHDT4HUMxQo X-Gm-Message-State: AOJu0Yy9XiSeizA0+zzAOSa/7OIga/Ubsde82OxJwp4pjQr91muI3bIu Jc/Wuen2v9kej06XyHgbN0pxtThoBWDiRsXlhpAe3cMtipt38wMhRfNuFAFywFY= X-Received: by 2002:a9d:7ccd:0:b0:6e2:e7d7:d6b8 with SMTP id r13-20020a9d7ccd000000b006e2e7d7d6b8mr6408623otn.9.1708122771683; Fri, 16 Feb 2024 14:32:51 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id r12-20020a05683001cc00b006e130365f5esm139136ota.34.2024.02.16.14.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:51 -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 07/16] clk: samsung: Pass actual clock controller base address to CPU_CLK() Date: Fri, 16 Feb 2024 16:32:36 -0600 Message-Id: <20240216223245.12273-8-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096758078436279 X-GMAIL-MSGID: 1791096758078436279 The documentation for struct exynos_cpuclk says .ctrl_base field should contain the controller base address. But in reality all Exynos clock drivers are passing CPU_SRC register address via CPU_CLK() macro, which in turn gets assigned to mentioned .ctrl_base field. Because CPU_SRC address 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 not consistent with register offsets provided in Exynis clock drivers, also breaking the contract for .ctrl_base field as described in struct exynos_cpuclk doc. Rework all register offsets in clk-cpu.c to be actual offsets from controller's base, and fix offsets provided to CPU_CLK() macro in all Exynos clock drivers. No functional change. Signed-off-by: Sam Protsenko --- drivers/clk/samsung/clk-cpu.c | 24 ++++++++++++------------ 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, 33 insertions(+), 32 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index d550a4bb632f..a59949990919 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -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) @@ -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 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 Fri Feb 16 22:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28499dyc; Fri, 16 Feb 2024 14:36:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhs2dnl8TkTMBmlaGaSW6uRrWDG5zkpCNdgIQSQKRQSEDzOTJ/CDflb79lrr03GTg5oyz3SJfQLCPduBfm+UegHFcJwQ== X-Google-Smtp-Source: AGHT+IGjBJTMWLYB+/y8G/Wd3daCTtciwWYm684ZFmStUZQNvyP+qDLMIA/BrogIFEFeElgSAL45 X-Received: by 2002:a05:6358:7618:b0:176:3e0d:9910 with SMTP id r24-20020a056358761800b001763e0d9910mr7321699rwg.0.1708122990198; Fri, 16 Feb 2024 14:36:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122990; cv=pass; d=google.com; s=arc-20160816; b=kGYqEIfzIMty9N+B+xJhv4Sc8hgjmUm4HG+TnydffI9CTKZogrD4UeEbBe1Q0Co/Ah eVJz1M4YPhTHLkmAs/gbkbYORFJy7dF65aVEKYOby3hLgUSBd8mVHW0vDOKFvPfNqV0Z WGJwuuVWiEl5KXx7bYheQ70kV4VaJIGUGWQAAUaIN1lrIVZggq1os/qZudzQ0C16ts72 HXfiMi01vYFOi9QuR9qu85LqmaqqZo7OHquH/Zg/0Yuli5ffLHlHNa6dVfj+jdIekPNZ oAqH2QFjUURzhfoBnfQ9mUpCRFX36Y1v9z1mXJcwzcms9FFwS5hwDNdtqBFmRzQF8tl2 SRpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TdZ9WPH7Nl2aH1xgLChF6BzPk0ENAzSqqSLTSdJZTwM=; fh=bJhkeEDM28aHVYDhmYsbSCICVVEzG5IshVS8V+IhFms=; b=a1laNu1kQnRXVYsv2uCD61VPYNtbP7KmQgMbQsEew+6XYE5xM6i/43XzJOzl9eF+A5 2yUOWi5PKPbzrRG0Vamn13gglsX6fj2ylVlVO/V/770fqSZ0lyWeIzUsukz4CcZ+v/ap jy2c1qz3vOY6iTbOu/5tWfFM8ZThyr0HUzFkwxdOaSeI68QcOya8+aryWQqOXMPTym1P eJMbNUuB+XWPlkdT9O7WlAY6tvw7Ml7Zzy35cLP+fFL8oIj1tXEqXPIrhGvKvD7Gn77I jAhhkFzFRSHqrC6AaVZN1XZGxqzkrGSwWPHaxUqO25i7U9/WEo2UWWjD7Xhcl98FWMhw Y4Uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DBMVlEig; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69414-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69414-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o20-20020a637314000000b005c279da45f1si508585pgc.566.2024.02.16.14.36.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69414-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DBMVlEig; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69414-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69414-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B495B2836DD for ; Fri, 16 Feb 2024 22:36:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB215150992; Fri, 16 Feb 2024 22:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DBMVlEig" Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF9F114A091 for ; Fri, 16 Feb 2024 22:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122776; cv=none; b=EdwQZFGVDxSmA70Zi+0085GR+UTKH/DjY4ERHnyFd9940p4e85fnoTn1ZalRcB3akM0Z89XD2TBDjvFXMQRdvLL5tUZxP+2nBqsC8127HyY+nb85g++94/1mNKsqiQc8MqfsHAYmWNEAZBJ62an7PZ+ALWlfEcQdX0vmwwBdVNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122776; c=relaxed/simple; bh=5ZoYtRQ2HjiqGEQZUVOcP2ADlsbfU9MvFiIZ1YzKk+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LhJHBQ4Rg1ngJv9OtwUXZZ5LZ7sgjZN+E+VV4A3iLSkXyoj3D0RvhEi0SK6AxhO2+hSSfRCg8obOjUXPWgtoYSejA8bS1YEtywJamOHu/ATD0NHev5jXsdp34bACL4s8nzJ10UV1fPaEMSHbFYt3b+GCdy034nDw/qj2BNd1dxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=DBMVlEig; arc=none smtp.client-ip=209.85.161.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-59d11e0b9e1so1260704eaf.1 for ; Fri, 16 Feb 2024 14:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122772; x=1708727572; darn=vger.kernel.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=TdZ9WPH7Nl2aH1xgLChF6BzPk0ENAzSqqSLTSdJZTwM=; b=DBMVlEigKGHihYH4vHTOqa2xGoY5LAu+v3b+3DT+OmFF4Tm7FOSURfukWf8t2pVFAq Te2su/ak4htE/Xt8W630Ymmg1WsXrpiXWx8YFkGsgWOCI3W+v7ka8RIWIG8l0zYZc/D3 6dasOe1n02caAX7Pkli3J3tVwmqq6sV29rBX64ItwYuvsu5rsa3naYF8lwOpQnk8TDTB CbOK20I2G9tHRnrt0a+5C36CYSm6J9aVB5NuGYbEFKartO9jv7zKMrw0paHUXxqFH8GS Y0D2AKiMbmBJvu/IwrbzMs3La5nYDH0A67czw+d1rYZui+JVTzudWQLBKmQ1UxQz/zoC S/yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122772; x=1708727572; 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=TdZ9WPH7Nl2aH1xgLChF6BzPk0ENAzSqqSLTSdJZTwM=; b=k2ET8tTRQyLZmDv94UHNudn7JkW2ciVfaVWoD3uDUn0GkKAePHGbcmhPIzl1Wul/pO I/iqYrhbfr3A3yuPs7TRJ3ZAQdf97bU5YFZ3gKEVx5vfZsYuTB1Ud/L0JeBwVK6t+lF8 19h3Epoy4uVAiK8KhWZ2H24mJotCKkVPSy0Ln+Pzz1cDKZdsAEaXHb3yhKGO3MaT84sF ZI/WvsDjjXsYJurBOLLshOqVFQd53EJfRigmt9frnMpeImTX0hX4IL7Z1hIS9Vc2x0lN SYlIed98mmS7hS1Kb6g8rW6LUsw8+WE3ktrKZrTuHgL2pdZz+8FjHFIrl6r96xwyJXzx qXfQ== X-Forwarded-Encrypted: i=1; AJvYcCUtLgjuu6xhScfIS0snCNtD65F72SZM8TtIi7P+ro2YzOOWE7917n4z6Fihvqa5RIbVwAOyvSbEjyxUXtusJ2P5Cgb/wvK98o/GbnmX X-Gm-Message-State: AOJu0Yx1V+fkcKewcesWn+5gOSpDgb5RGmQH7hRAsjtlX9YCZVO3GQSq EKSo6uIG+JEXTc8YImaBXkAfmRYOpn8N7iR9hvJaGgLDkpvjcTWJVPaP92GJdtY= X-Received: by 2002:a05:6820:2b11:b0:59f:aa2e:ef8b with SMTP id dt17-20020a0568202b1100b0059faa2eef8bmr1528834oob.0.1708122772629; Fri, 16 Feb 2024 14:32:52 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id x11-20020a4a9b8b000000b0059d24cfb5e3sm137045ooj.4.2024.02.16.14.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:52 -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 08/16] clk: samsung: Use clk.h as a single header for Samsung CCF Date: Fri, 16 Feb 2024 16:32:37 -0600 Message-Id: <20240216223245.12273-9-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096772851511404 X-GMAIL-MSGID: 1791096772851511404 Make both CPU and PLL clock headers to be included indirectly via clk.h. All Samsung clock drivers already include clk.h, which provides API for Samsung CCF clocks like muxes, gates, etc. Both CPU and PLL Samsung clock are not that different. It makes sense to only use both clk-cpu.h and clk-pll.h internally for Samsung CCF framework, and make clk.h the facade for Samsung CCF. This way all clock drivers only have to include clk.h. No functional change. Signed-off-by: Sam Protsenko --- drivers/clk/samsung/clk-cpu.c | 1 - drivers/clk/samsung/clk-exynos3250.c | 2 -- drivers/clk/samsung/clk-exynos4.c | 1 - drivers/clk/samsung/clk-exynos5250.c | 1 - drivers/clk/samsung/clk-exynos5260.c | 1 - drivers/clk/samsung/clk-exynos5420.c | 1 - drivers/clk/samsung/clk-exynos5433.c | 2 -- drivers/clk/samsung/clk-pll.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 1 - drivers/clk/samsung/clk-s5pv210.c | 1 - drivers/clk/samsung/clk.h | 1 + 11 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index a59949990919..4c46416281a3 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -36,7 +36,6 @@ #include #include "clk.h" -#include "clk-cpu.h" struct exynos_cpuclk; diff --git a/drivers/clk/samsung/clk-exynos3250.c b/drivers/clk/samsung/clk-exynos3250.c index bf149fae04c3..d1b72a75bc5a 100644 --- a/drivers/clk/samsung/clk-exynos3250.c +++ b/drivers/clk/samsung/clk-exynos3250.c @@ -14,8 +14,6 @@ #include #include "clk.h" -#include "clk-cpu.h" -#include "clk-pll.h" #define SRC_LEFTBUS 0x4200 #define DIV_LEFTBUS 0x4500 diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index d5b1e9f49d8b..3d57020a620f 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -16,7 +16,6 @@ #include #include "clk.h" -#include "clk-cpu.h" /* Exynos4 clock controller register offsets */ #define SRC_LEFTBUS 0x4200 diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 58df80de52ef..4953da754994 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -14,7 +14,6 @@ #include #include "clk.h" -#include "clk-cpu.h" #include "clk-exynos5-subcmu.h" #define APLL_LOCK 0x0 diff --git a/drivers/clk/samsung/clk-exynos5260.c b/drivers/clk/samsung/clk-exynos5260.c index 16da6ef5ca0c..280330ded100 100644 --- a/drivers/clk/samsung/clk-exynos5260.c +++ b/drivers/clk/samsung/clk-exynos5260.c @@ -11,7 +11,6 @@ #include "clk-exynos5260.h" #include "clk.h" -#include "clk-pll.h" #include diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index bd7b304d2c00..531ef1c3fa30 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -15,7 +15,6 @@ #include #include "clk.h" -#include "clk-cpu.h" #include "clk-exynos5-subcmu.h" #define APLL_LOCK 0x0 diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index d3779eefb438..379744f0a5b6 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -17,9 +17,7 @@ #include #include "clk.h" -#include "clk-cpu.h" #include "clk-exynos-arm64.h" -#include "clk-pll.h" /* NOTE: Must be equal to the last clock ID increased by one */ #define CLKS_NR_TOP (CLK_SCLK_HDMI_SPDIF_DISP + 1) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 4bbdf5e91650..37aa7beb547a 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -14,8 +14,8 @@ #include #include #include + #include "clk.h" -#include "clk-pll.h" #define PLL_TIMEOUT_US 20000U #define PLL_TIMEOUT_LOOPS 1000000U diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index d27a1f73f077..8ee3ffdf2b8d 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c @@ -14,7 +14,6 @@ #include #include "clk.h" -#include "clk-pll.h" /* S3C64xx clock controller register offsets. */ #define APLL_LOCK 0x000 diff --git a/drivers/clk/samsung/clk-s5pv210.c b/drivers/clk/samsung/clk-s5pv210.c index cd85342e4ddb..29f2531fd5d3 100644 --- a/drivers/clk/samsung/clk-s5pv210.c +++ b/drivers/clk/samsung/clk-s5pv210.c @@ -13,7 +13,6 @@ #include #include "clk.h" -#include "clk-pll.h" #include diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 516b716407e5..8157479f45eb 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -11,6 +11,7 @@ #define __SAMSUNG_CLK_H #include +#include "clk-cpu.h" #include "clk-pll.h" /** From patchwork Fri Feb 16 22:32:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp36923dyc; Fri, 16 Feb 2024 15:00:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1qNhb29+t5aJMc4wnwXXGZX55MdF9j/dUfCRiR+yPam1j8tGl6LebasfRYeoto0wR0Qbzvaq/ZoApkAjp4guJTXMYnA== X-Google-Smtp-Source: AGHT+IHobKvk37OPMFFFuMqZZowXmYbZT9hqG6O+PN6kq/8lOxhl0JJ3sdypvgxSK/KeSxCs5Trl X-Received: by 2002:a05:6a20:4c93:b0:19e:cd5d:88f6 with SMTP id fq19-20020a056a204c9300b0019ecd5d88f6mr5366052pzb.53.1708124431064; Fri, 16 Feb 2024 15:00:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708124431; cv=pass; d=google.com; s=arc-20160816; b=gbgiNLUU4tIoBiQ/j5VaTkvV1mRTw/KyTQf2hvQyHcm8/i5uIC5k1TqQoC9pzojzPK 7fT0uc4BGmAiDIkEo0Z2DkOPQl1AnA355vD9kiDH3lL/AIQ4FE2unJCapWu/hU4NLveU lk/QfTo7spr8UjO0jtndLDL6U8Rg6UOpSxmV1Ykaw0vV/V7kyIncAvCr86Jn/Z1WLLBD wibWlGizYmdxmnsqetAvs50n2WmgnwV4wh1/6HtdnYPz4FuuZ9qG8ErcfKDnDBhAeW1R 65mEIKOvSdeDJVFLCOq6giSpR63ZbtXy01ZgCgEpK01k0GybwC2pzmpPVAKDRE4RohXL zULQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JueSEWjzcD2UuRwkarRrGZ51dhlmNKxIoCGdG4EKeus=; fh=sdCyUImc2mLTe/dhqALusavQuBjhMD5Nwjs4n6qQ1LI=; b=uXk9p8XMcVyKeVbeULYXLM79cPm4datE0WAjO4BEf4py5l0e+brla5FOjWkiKwevi4 tYGoooBxMsrSFl0f4EKSQaVAc7CsChPt4Ylwp36oStBwSMc2EmFvkzTiKhqc0NXHERks V/vIEhchXO61FEI8NY2d3P6dOhPmgQQaCa4/QrS9lbocS0NIvpGHqld0N7n+QRVsGq92 hC7ifsOHh1VrWYM87L7L8l5gmXGB6Z81Qk+KJpW9uafkvAtf0Ooryk82qJgp5OPGT/Zz zjEyc80RmgGTEoypIzYqvAtzZwphMwT3IybXF05Gyzeytw1pFI6hPR6GXZPpg1FsqLVO kV4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BwTv8h6/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69415-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a2-20020a17090abe0200b002993be51a7dsi620830pjs.163.2024.02.16.15.00.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 15:00:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69415-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BwTv8h6/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69415-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A0CF8B2A231 for ; Fri, 16 Feb 2024 22:36:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CC4C1509B3; Fri, 16 Feb 2024 22:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BwTv8h6/" Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6119C14A0A4 for ; Fri, 16 Feb 2024 22:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122777; cv=none; b=S2h0pSX0SXqisBs8iY/NSItOo7X5mN86ChwXQ8LvmDgFc4ZrGCm0KobMp0zfBAHvHcXaQQ04IZVAmN4+PbqVePULDPabG90xWFy6iCe5XOoN+7dWz+DqSHp/LaU0FfA6z7qNJUaKyBolM/KWngtwtD33rWvGz/goU7jDENmWTiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122777; c=relaxed/simple; bh=ePFKOWRE3K7dYiOwtCkaYNJrSXoFcKNqXcZmDfVeAws=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FezcurGHIz43WAB/AYv/Sc8mYcusHKEMfKJQLOPuX+POZRRijKuRcZsUd6zN4zuAfIZZUomVA2cAvP/atxGYXs6DuQVQZXJUcVjkN6gUeXdOqEKiKLkR+AZb4mwXN63xB+Mr8GemPwNTruxg3pGEEd76u155Eh0gbkt3w0P1Db8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=BwTv8h6/; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-59f786b2b59so1192389eaf.0 for ; Fri, 16 Feb 2024 14:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122773; x=1708727573; darn=vger.kernel.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=JueSEWjzcD2UuRwkarRrGZ51dhlmNKxIoCGdG4EKeus=; b=BwTv8h6/A8lOtFHVhgCYvqI+YfzBk/fnjRpNVnmJVOm0VE5/756+kiIpHR7HYbA4ns YpOwEDfNkHSQCBOmpmR4lSXIGHYnnblc1dTlY/FC6fpG/FCFkFSwn8SGn6DKGNS3fjeF 8oYUCbDlKuaGde9IVtuvU8JIYpAm9tBSe5iQBSOLb/zOAZOB5KPlERgC/5cXIg4cX1Lq Vi+ca4hzDIqoaLML+5D8lK5VfaeYCrKBwBcmdA0zNv7JymIGsaR6gn3tSGaQ6Pzzv1He 0RL7zIjnxRL5t4/ziW/WQLeg4QdVFpdVPpTFUaSISn6vadqgiMbycg/DbWDEBCieWNiR hnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122773; x=1708727573; 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=JueSEWjzcD2UuRwkarRrGZ51dhlmNKxIoCGdG4EKeus=; b=NeJq7RAmdFvQM52HTI6LsNH/4Va8IbyTBYcMewRHooE3DUZIAXKB/I4VkBjtjD1hA+ uisEZiOqJAgsX3PvkWHbGDBvW4ST6+zFZW+jyjvVA0k+P56awBF1CvCytignNo7qf3Ai IQKvO0rJX3Pix74hAkQ4U70gKFQ6NhFGQxb1c5tJvUjxaVxw+SrIsJNDJTY4NuMsYSp5 naCzKXHYHfgnjrO6M7frurDNY7PVCA6x1J2YmqSI6qZMWRALmZ3ZahWyzWSM5WQbYyjK oaYUqljHrRs4Wm3DRLdtAn9vhrmKtDvuHvIeEDXFxu3Tl/D2ZWTCKZ7STTTenUmwH2Ko 1Q2g== X-Forwarded-Encrypted: i=1; AJvYcCWFb/rEJN2VyvQclj3yPzUaO2WsChMdNCNipG9bUzgQ0xYu84gn9cbe90SZhYj2sDI6OAJAfc5Uq4aYFDirjy3eRSakq+24pGtsSayI X-Gm-Message-State: AOJu0YzriN47qW9pjdo+FkVrGTPEi/MOyJ8sUbs018/8IR5kI6YxQY/6 Sxr3WWdz4ouoV7YpBap3PIhCpwGEgTxs320FWZ/HDgDw7hFnQ9n37xwZazjP59fhQd//IvA0dyI 7 X-Received: by 2002:a4a:345e:0:b0:59c:b57a:5746 with SMTP id n30-20020a4a345e000000b0059cb57a5746mr6347301oof.4.1708122773428; Fri, 16 Feb 2024 14:32:53 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id b6-20020a4ad886000000b0059fae73df22sm112897oov.3.2024.02.16.14.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:53 -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 09/16] clk: samsung: Pass register layout type explicitly to CLK_CPU() Date: Fri, 16 Feb 2024 16:32:38 -0600 Message-Id: <20240216223245.12273-10-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791098283231366964 X-GMAIL-MSGID: 1791098283231366964 Make it more obvious which register layout should be used for a CPU clock. It prepares clk-cpu.c for adding new chips support. No functional change. Signed-off-by: Sam Protsenko --- 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 | 4 +++- 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index 4c46416281a3..21998c89b96d 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -464,7 +464,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 d1b72a75bc5a..bd017a68163d 100644 --- a/drivers/clk/samsung/clk-exynos3250.c +++ b/drivers/clk/samsung/clk-exynos3250.c @@ -773,7 +773,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 3d57020a620f..e1b7a5e0dbb8 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1252,19 +1252,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 4953da754994..36d28d466da9 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -776,7 +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, 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 531ef1c3fa30..f8cd28465b58 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1555,16 +1555,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 379744f0a5b6..d35901af21d0 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -3698,8 +3698,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 = { @@ -3942,8 +3942,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 8157479f45eb..87bbb8b31b03 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -283,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, \ @@ -294,6 +295,7 @@ struct samsung_cpu_clock { .alt_parent_id = _apid, \ .flags = _flags, \ .offset = _offset, \ + .reg_layout = _layout, \ .cfg = _cfg, \ } From patchwork Fri Feb 16 22:32:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28556dyc; Fri, 16 Feb 2024 14:36:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjtJE3jDHtz0nzpc7uSNuUtAwqC/t0/769XPaExyGpeOrrNcFcElfQKRQSqjTlfikfFK/kQJxUHs00OXXJtD4is6AgKg== X-Google-Smtp-Source: AGHT+IF653hjpn3E9tj3VfJ5ZFe5zMrSSvrf3nmv0Q/FGZgWayjcR4paBwBiUlHaTJr6gMeuxFnE X-Received: by 2002:a17:902:9a07:b0:1da:17fb:3021 with SMTP id v7-20020a1709029a0700b001da17fb3021mr5137754plp.6.1708122997714; Fri, 16 Feb 2024 14:36:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708122997; cv=pass; d=google.com; s=arc-20160816; b=SILGbdle/tXqxGKEui46nwMQUEg0vghuK6grzAU22ALa1+X3QtGP0ZW0UvNsx0A3Gr rbNkSEdLV40mUapAlH9/x/s8ght9OwO9w3Rwor2/XF+s9h/SI9yCY1Rl6UWZXosG7ZKS sf/Lm/VOu0D3MFQquKOkeRHPDzcfJ3aGpdRiuG30HgiBnvPd4hLfZ3X7hhVrNKvZYRsk HI5A4cLcctkr7lChoWVQQ9qgqk5WUXeOLe/rnIjyntKELHPIzMoUk4xx0+ocoG1l80xm ZQtvhbTi6GHxb/LnjmbMRKyqiGTenhQwYZGtQkRxrVAT9pcAFQ8NyVhFRk1kBbBCJc1f oL0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BSXQtp/xYos/De5K15KnT8HtuCXV3FX1KoFk0gl8ZIY=; fh=iTbij6eV3hPaQcccpdU8Yq3fXBdxCjKxGxSO8MB3vXI=; b=OOPxTAESzSk3uH16v4o0CQFq+XFWFrqv8F2bQV6ummxI6ELGZTNlTTHA0eyl5iX2Te wGjeu2+UWYVTubQ74LZ2h5Z2QK9+fxPzwUEypcI+XGpKrTgyybW7HbvVTQp/xTquw+V+ t/qri6V0aj6TAjq0Fv8QU3s9Nn5f+0L2DqlUeEPKsXT667tlFsnJXjfrIoTBzjKx3eI+ ikAacWg15rBLXEMHoO5JL+/ikj6mE60h2O7NLU22yUh6G+rjgo1wZpQ7uoMalV1mw5h6 uUkS7jlZ8R3bchLQfQHWWQrqX/UOcxgwoWmKwKC+6WVs3SC+g+ok7wgc5hV/CtxU/0VN k8/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vtWjq/nI"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69416-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n16-20020a170903111000b001db3cdb3858si514277plh.84.2024.02.16.14.36.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:36:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69416-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vtWjq/nI"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69416-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8C86E28AAE2 for ; Fri, 16 Feb 2024 22:36:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 361111509A8; Fri, 16 Feb 2024 22:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vtWjq/nI" Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34EA01487FA for ; Fri, 16 Feb 2024 22:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122778; cv=none; b=RhwqbD0BsJrQ7hXklM/G3aCsC3csVRUZidDTzuz2udGNEoD9b01d/LTmUYX8XZ6owMtWnBg32lkwDjh/Ajnpq9IFN75fUARzaJ9gM0XSuhqUDq/RYZcMiCPvcCI38bZQ51D/SWSLHNOiD7eJP+SFDmdffJv1Qut0p6FKDwAedhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122778; c=relaxed/simple; bh=eqZGJoOdifIJ/nx09+Uj4OtPl8hVswxwsmltU49Eusg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QJ76IAsq4GojilXqubMLf9u0OIiy7t2YAWjrXLTpSmEPSwRgPjxEeiv5gpYEllgLTA+bl1iESQtlrdY7XV9XA9NInEyqLAGR3CVIrJbDww6P8i7LeP2N2AwpuqfhbqV1J+n75PH8kcV7Lk+aOHOMevWTXGkmuIMwgMYrMf6CUgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=vtWjq/nI; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e2e44aad03so1529946a34.2 for ; Fri, 16 Feb 2024 14:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122774; x=1708727574; darn=vger.kernel.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=BSXQtp/xYos/De5K15KnT8HtuCXV3FX1KoFk0gl8ZIY=; b=vtWjq/nIy+z7OvNKFwUITs5Vsx4DROu581jb8UvPcrZTQgRr7+L89yiOX98aBaCZwF Yx9KhuBZt8iK3UYF3LhoWxlDc3YnnlUBwnv/QdNoiYNl03KmtsvehQvZJ4Oaiup/Ujez JqCnt5RDPKOqBgUpVT5sOl0TIFnYZwxEp+Ir11aAXtHfL2V6Y5FDDr8fxcKDaFwcFvHu bRqidlYnTZ1EdqqXv27f8pk3nWPk1Ak+Tc1huMTKMioimzqSpSdgNVGreCz883AbHluq 95MG0nNPc87YI6KNywevXhlJBqTp73GBIS5njaYGXHs+ooOvp1C/wOcHqAUeKApc6md4 U/TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122774; x=1708727574; 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=BSXQtp/xYos/De5K15KnT8HtuCXV3FX1KoFk0gl8ZIY=; b=cpmD46Q1Thd49wqNHJ3GfnqHp6JSOXRlVM3G/7UGyG5mORMGtvaAlicmb87yka1J+i anekaSmseNsh9Wnb1amyXOIDjUODYDqB5/IAIQM1HvNxnO0rZCwZmXy7OiT8SEOaaXus VSPGw8SXmfCh1zqzRhgEG99ZdkkBLCV9+SDfecP/hO/CWgHNNCVf+W3aVPTBSjdHbcEj Hq0J+lJIYiUdYq3YkoFIjw7/dDCGihCq7HfZQWkT7WFvtC4aw7+uXdYHOCUGntNxGyqS 0FNAJn9Vf4/v1N5A7cbTC9+txi9OeXlD1yVGkhNTopRoX5VuKkZgsePtZiJAwj6Fovn3 CdvA== X-Forwarded-Encrypted: i=1; AJvYcCUltiRxOEP15fT+ZD1OBG0zYMDZIcsgoSLXDTZG5bLsEYbGVbc6RrjNo+gv8HGIjIOh0Zdz30g3Z6MpzbV3kSnZWdusa9RxF1We8RBT X-Gm-Message-State: AOJu0Yzkw2dHP1A6w+20Xrg9KQVsyF90xeyxqzzja5pO5zlgx/alRLcr 5kFoq0bR3vcQgSJvJrouHfOIJVxygx1y1d2BBADJPimSzHMBABm4RKjLGtbu8eg= X-Received: by 2002:a9d:6b83:0:b0:6e2:f9fa:9e5c with SMTP id b3-20020a9d6b83000000b006e2f9fa9e5cmr6533177otq.3.1708122774331; Fri, 16 Feb 2024 14:32:54 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id j2-20020a9d7682000000b006e2ea96949csm141544otl.29.2024.02.16.14.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:53 -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 10/16] clk: samsung: Keep CPU clock chip specific data in a dedicated struct Date: Fri, 16 Feb 2024 16:32:39 -0600 Message-Id: <20240216223245.12273-11-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096780273023425 X-GMAIL-MSGID: 1791096780273023425 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. No functional change. Signed-off-by: Sam Protsenko --- 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 21998c89b96d..04394d2166c9 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -42,6 +42,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 @@ -54,8 +64,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. @@ -69,9 +78,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 --------------------------------------------------------- */ @@ -419,13 +426,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) @@ -464,13 +482,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 Fri Feb 16 22:32:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28732dyc; Fri, 16 Feb 2024 14:37:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXyjpqG/JUrvRgiSkeLbvds11mYkqcL5kdUddweepl+kib1GHG8mc4xAc31b6hirDfF2YcSjC/7ntwN+0JRDlhStJtBg== X-Google-Smtp-Source: AGHT+IFCYNWNxcVF6qdu+9gRguBZgiq/XQpMHPftOB39vuVAwAf9UW93xq0Hhd5E25RJ1JryL6H5 X-Received: by 2002:a17:90b:a4a:b0:299:16a0:ba53 with SMTP id gw10-20020a17090b0a4a00b0029916a0ba53mr4937300pjb.3.1708123025981; Fri, 16 Feb 2024 14:37:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708123025; cv=pass; d=google.com; s=arc-20160816; b=R4s3VhnYoTqXrnbgdB0JdoWYbAfsu8HuGJljxLhh/I6EJtsR5PED4bqABAX92xQBsn t+sCcz2tL+/OCTUarRDKXb4ETKEReGgNWRenJIRlEGiqBV6JrnfJJNA2SVUphZvl8bVU AGQmTbdK9FbULyxKd8T6F+MHqbuRelZ0+YuIk+yne1TiADgrfdAgEWsRF1zP952aGD4R jzgmBHo602OumM+5teCDPn7I9WkUwxNvrdCEOSfOL9SUcXxt4d7MeIYQGMNOCecg046S a3z+ZoyX9yt4fXtHTtidYu3vHs+5n2eNIRxamPh+0sIXMbub5sYXc7tG4PTW1F+8S5mY ZHUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=c94BuyoqMGlHD4ivYp1JoiKocO9tlaf5ysz98lqNzSQ=; fh=PTdBF51OntBwWENjl+w9jt5bVTZsEJk+Mw0DFwv9zkI=; b=n0KKLr/jYuZA9l5KnOFngL9y/fyo3gYbIvYSFZx4q4nFR2OkdOB082Sdk1LRTJiLw5 g3ZnyUhNZLYQGWr+ae2Njmh0PmJK+1cI+hyCx6b02y77VaLSISJ5X6HFlRnt719GfX+3 /dYsSf1s4NbmlhQUN3+m7Z9IrPF2+5h+NCYYEvSJKIQIHbm+DZpm/aY68spL9v0Qx6hy zsDjZuV2PTMLiuvD5lIf7MN0tANSl5kRA4eLN3xDPf244jpHLbJxYb9hWme0u23iFZql iYhQyZTZHVCYSPKEttTa0feLAsEbXGE1S9IbMP7vz+E2WKhtKqsXjgZl/w69lh7YXUE0 rKvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Wpy7kjH/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69418-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id sl14-20020a17090b2e0e00b00298d20b379bsi607147pjb.68.2024.02.16.14.37.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:37:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Wpy7kjH/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69418-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69418-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A51CD281DFB for ; Fri, 16 Feb 2024 22:37:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28FE1151CEB; Fri, 16 Feb 2024 22:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Wpy7kjH/" Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A60714A4F2 for ; Fri, 16 Feb 2024 22:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122780; cv=none; b=IoMQhP+JtoGXulD7Dw07ORxwVSwznnJ7a5sWfwFXXNUPOmGgMV31LG1zT63rj12jbjDmGc+ZQlLm2Tf/ZG5aq9cMiIQPVl+AOXRluUFrMYV5GjFIEuNCUg9djTnJo9YG8o3ZU93pxt8wWHgPAo2imzBs1XsljhmIhzHfWtcFP1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122780; c=relaxed/simple; bh=HSDrJSYA9UicU4PhhgP/G+lgI6M7sywpuh3/28TzU6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a/A2K5vBxV60b0vjtfBcO1VCxc4wQUXjQR3Wvk7D/LzdKYR0c/AJtnlaZAGQvxndY4ySjvUSH1FCJyVVdGrwM8DCqsR1OKIIOAg2Ll89zjDgqUQgMuDBLj8a6X8hLLE51Lo+yNAsrJgpSoBnprQ6KHs9UrE3xKhnxCK6CpkmskY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Wpy7kjH/; arc=none smtp.client-ip=209.85.161.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-59d489e8d68so457177eaf.2 for ; Fri, 16 Feb 2024 14:32:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122775; x=1708727575; darn=vger.kernel.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=c94BuyoqMGlHD4ivYp1JoiKocO9tlaf5ysz98lqNzSQ=; b=Wpy7kjH/C95Wx3mIRAoFjMjl+g0d4AkwioWF7PmkheSmQpIDsZSmo6wwsBl+5CqWx4 qDHZ01wYm44cwY2uethVq7UzvZgTni0itvy19jePDL/OFV7OSSnARScyjdnEMpW+J/43 8pDoYb2C6sqqUNkjrXF92YU3wNhmG37ueug6M/ZfTRZopRJiBgNJtfT8cjd7UDeFQAWf XIW1mp+llnotJBDlX5Hry7Y3ZRjtftBPrxFgpG4vfGWgkhvfZoC1zUbfZZihl903LzTk aOAGSC/8bOsqo4QbpwiAJglBdaQEd7BP7pgO5vgxnLaNl7s+BDBpi84bsWx/5LfOsxlC lXmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122775; x=1708727575; 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=c94BuyoqMGlHD4ivYp1JoiKocO9tlaf5ysz98lqNzSQ=; b=kjCpQM8ZOfiBEt7uK/hHvzAxS3GP9Y/6r1SS1iLSB3kH5F55uiepmDowhfKWfunHXO RNG1buCdmm/btY1wM8Tytbk6b4i/r0p0iSIQpdVFzYP8J+VE2StuyWx3pmMxRRjArs91 hNCYP47VOXdkdv5+dKsbyTITL3f+3iOoqfb7BXz9y0etG73nM3Idss0j7vQyoAyd5rTX PppW0yZcRxC1aT92IwPt7v7cNb8SQ77fXFK1uivUIh656oWzOwQuGKhsmwIt6flFhOAZ 4mEUpWmBuLdHmzsX4Kk7/DnP+Ja8ibg0OzDeyznOpBOwZFKxHi70+bgkTw9Dd00UhSHr Xxew== X-Forwarded-Encrypted: i=1; AJvYcCWVNDh3GiAquKzJux5h4WBjZ9xq/vZw989bybxWyFMbEPju2ogb3AhKRGBLhpogJ2kosEZvxoQGW8q9gOUin4tP8nKZBb3CAtQCwAqM X-Gm-Message-State: AOJu0YyZCfESSL+suddaeaPAHd34IhHkqXxUBYR8yiu+bfwy1BOVUgDD qvIjzEiTIEGYIrSoY96UV5aslUcdbHRLjhMisNsOcEqnyoHiPZImubS+W3j/nYw= X-Received: by 2002:a4a:6245:0:b0:59c:8922:65d2 with SMTP id y5-20020a4a6245000000b0059c892265d2mr6846630oog.5.1708122775108; Fri, 16 Feb 2024 14:32:55 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id i2-20020a056830010200b006e2f33453f8sm140062otp.9.2024.02.16.14.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:54 -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 11/16] clk: samsung: Keep register offsets in chip specific structure Date: Fri, 16 Feb 2024 16:32:40 -0600 Message-Id: <20240216223245.12273-12-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096810522263492 X-GMAIL-MSGID: 1791096810522263492 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. No functional change. Signed-off-by: Sam Protsenko --- 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 04394d2166c9..744b609c222d 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -44,12 +44,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; }; /** @@ -90,6 +92,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. @@ -129,43 +149,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->ctrl_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->ctrl_base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; @@ -188,8 +213,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); } @@ -216,22 +241,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); } @@ -244,6 +269,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->ctrl_base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; @@ -261,50 +287,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->ctrl_base; unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent); unsigned long div0, div1 = 0, mux_reg; @@ -341,21 +354,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; @@ -365,6 +378,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->ctrl_base; unsigned long div = 0, div_mask = DIV_MASK; unsigned long mux_reg; @@ -373,11 +387,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; } @@ -435,10 +449,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 Fri Feb 16 22:32:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28641dyc; Fri, 16 Feb 2024 14:36:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXO3D6WwGXv19KgBVKZaZuRO7PoIW7S34pBY+StvtzEj4L6zh7l99W//EIJJ5ykV2OV2FYP9eB3A34UfzgNunE3+6Nqog== X-Google-Smtp-Source: AGHT+IGJWXj3AcpFpfJMI6cjz9tWi5+Kujrj8Z0yvKnXykbmvsBlbZI9gP79KPzHddhbqXENOmqZ X-Received: by 2002:a17:90b:1085:b0:299:3f45:bd57 with SMTP id gj5-20020a17090b108500b002993f45bd57mr1959346pjb.30.1708123010652; Fri, 16 Feb 2024 14:36:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708123010; cv=pass; d=google.com; s=arc-20160816; b=plGnV/ipLkVzbr8OTeuTDKnTbC2jNvC70VQkrNbpWlgbyFntrggEUVZsn0zIIACLX2 Fw0mfV48jClxf39YKxz4/KvICOpyg+oaD14JnG07d7fVjW+KkSZMmopf9UpJpLNJI39y kKRMmwHVd7pdBwbX9pEhWcOTpVrJ4nojdmHbNiBTyBhhs5ZTIEoDFSgktxx5a4cDNhle 3v2usOXR4o6QOSJk5jMQKPCIMhNe16+4at/PAJMUvLOlR/+piNmbYflxl/tnl/Xb4MwF K3c0AiCap8R3YBVYZ5cLgVE4+BZh5C94ZSuK366GA1fJsI99O0189Dn5vSsD7lWyF909 6xsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dv24mbqztn1Vrin55e28olHgU7+Z3ekpJo7z50Ef2KU=; fh=A8XC6BJs8dKj783bPmOcpyDzxNFI8NAwkU9sWoRLUb8=; b=eQXQWhtnP1IdwDFCgQkkQt4axQOhMA3A0C6g+xG9hvHdNa4fO6nSoIR6DTwKDml/hQ EOnmhdxigA3v6Lw5zPo22BzSgIbXsw1DAxFv8zDmHW2rqez63Bi5zy17hM/xcWsn6Pi1 GzSYdVeP+DW2VR38jQGc6+vYuGhDrKhCyUddJAAlyQitM+KM0vhjvXD7URR+uaiRgLfJ 0EXYVSQGkGVwpdImxwIN5x7PiR7WTqYruoPUIRaIZsO2yVzTDsqurgoZ/jXmu05QPhEf 2i9+HSusSsPmd0XlDfXqRHE6WdUBXtJ17wH0nlgoUYOeUKxG25XwCtC91Le9cKXLVOkP NaHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cjqb3dH7; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69417-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69417-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id qe12-20020a17090b4f8c00b0029898fc65ccsi594980pjb.15.2024.02.16.14.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:36:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69417-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cjqb3dH7; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69417-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69417-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A85B28270A for ; Fri, 16 Feb 2024 22:36:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01EA21487C7; Fri, 16 Feb 2024 22:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cjqb3dH7" Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4456014AD26 for ; Fri, 16 Feb 2024 22:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122779; cv=none; b=eIHUAiXQzmUDlVgbULrGwsyGeYFlYEhNpipIzi68lxWp1Ure27R6ZccUSmQgBIAWyLYHpYyY9STNi+Uxt0kcL93OtJcdJopDJa/9HEvjMIxhzKEcpn/8XEXVidS0oovkYev7ZmdlncYj8smDNW7J6p4PriGy9oD/GiDqtpWk8y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122779; c=relaxed/simple; bh=xY1LMobodbRh5wNGfmOsFYW91hGkyg6ukGBHJClJZUw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GrDFdLSUQEmALejUFgAWqIVXZjzCawxRMiQ3K0zuZrsiXqnhgIj8Yy2kwcLlGo9aEc1ITAWy7//rO8JLKFt0zafLCp0OUhFVGjeVvDfQVfuiUfr6fgv1LWwbkpi4HiB4fcb+pK+FbJfdQiDq++VA4uQh4heCGKKTPoaEch4KK/Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cjqb3dH7; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e432514155so919214a34.1 for ; Fri, 16 Feb 2024 14:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122776; x=1708727576; darn=vger.kernel.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=dv24mbqztn1Vrin55e28olHgU7+Z3ekpJo7z50Ef2KU=; b=cjqb3dH70MuznxMRQvKlLu3suaxnTb6MeZc8p4AyXY7cktSQ7rSQ7cZZtBQxKUImXt J/Ae9MlwqtFhZfHQJc7Gw7uElUf0Tow+rTuEUgFoeMurmADUNlkNGul+VnkGnUdng3tc mMso8PQuMgWsTqp9A3FQXEUnC8Xk67+dyft1Y/JlXi5Y0s8c8BiphvL5KUTPwktH+xKA tVFnbGjP8v0w/KjWdLX/L9zvctYzwikMAuH1yYVaDxyNuu3j2tMsicUKPlSF0KzSDLcg Eyv2BdEsiG/tRSPPmgWD8ggV6SJKVxiQCH0hex58Qu3HvuFJwa0tYpmvSYiM+6ZyHeF8 yeMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122776; x=1708727576; 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=dv24mbqztn1Vrin55e28olHgU7+Z3ekpJo7z50Ef2KU=; b=ZMK7QR6nQB2Phz5W84jXjAIEluGh/6+uXh+G2/DpuJi4FyouR29Q0qWNp8QL8JKcbJ 7TRlf2XpYuNBbD9NZzp5+x5e2uahPLZyAN4R6AtjyVSSGt9X8Vh9SXDQ/tgm0nTvfxFN Fs+5AKU3RHCh26PqqO0+LE74eX1qPCnFKrndJfMPctV3hU6KHjJ29q2f69REo7Fk8suc xcfjyBtCf8CjqKusSm1N6pB1E++JnKJHVuCy1+OzEEsEAZdgNkbYPFPSzlsHOpAGAxUv rWSxOmxr4zeH/FtPbVCiLklpj9IIaq7jDsY4sv0lFXmbUj9bX/WvND4JRQzGnaL1ClQm boPA== X-Forwarded-Encrypted: i=1; AJvYcCUvkAj6KV9EcwfoU8t0PJmZGLnEfTdZOp6ROWau78NEoZlFiO42DEEqOSpkEhOFiEUvsTk+zkUtkArmXdG6tz6/bX0/Imbw5N57/nGm X-Gm-Message-State: AOJu0YyfNO4cER6+lfe/cq6qYlk4qztN57+EKZ2t9erqwcpz139WYX4/ qzedURPvBcOXJHF+ZGiiGaPKE7MzQ1abmzipAvo3p5+WsQmtG17o/1ORBDGAUTw= X-Received: by 2002:a05:6870:8192:b0:21e:6672:a46f with SMTP id k18-20020a056870819200b0021e6672a46fmr3255262oae.29.1708122775911; Fri, 16 Feb 2024 14:32:55 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id ov11-20020a056870cb8b00b0021e70d17dc7sm199912oab.30.2024.02.16.14.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:55 -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 12/16] clk: samsung: Pass mask to wait_until_mux_stable() Date: Fri, 16 Feb 2024 16:32:41 -0600 Message-Id: <20240216223245.12273-13-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096794041691607 X-GMAIL-MSGID: 1791096794041691607 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 --- 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 744b609c222d..5ea618da0bc1 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -134,16 +134,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__); @@ -248,7 +248,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); @@ -289,7 +289,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); @@ -361,7 +361,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); @@ -389,7 +389,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 Fri Feb 16 22:32:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28753dyc; Fri, 16 Feb 2024 14:37:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHv/aZmjpij6BqWLbUjxjYIqPIm0pf6II9c6FSByRjZKv9okszad+/dzMKqPKIyWCavVRb0SYqbPvTSbilWKOzW3y8eQ== X-Google-Smtp-Source: AGHT+IGK17AOp1obTXJ4tNRd6Z5YNOnjv5t85noVBJWvGZPkndVsladhpbEBjEPv0ZDuLJqrYqbW X-Received: by 2002:a0c:f04b:0:b0:68f:2b1e:5116 with SMTP id b11-20020a0cf04b000000b0068f2b1e5116mr4071846qvl.65.1708123029511; Fri, 16 Feb 2024 14:37:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708123029; cv=pass; d=google.com; s=arc-20160816; b=pTpwoG7HnZSYLFF3Yq0eswYhQ/KGPD1e8NDXdq1mrl+SfcBQIqXOyeE4JzIFHudoeR HzZhc2txe2LuDz9hy/7Fu0ENjcpQhie00jvI8+xcHNDMQtz+RLHqwBb7EzGqKmusOW1t peeNcL991WAqSqr0dNCzjSID3EYIVuYjKdfgqsT5OeEQRuD/o1zfDAg4iVNHUB55uYSh 5Lp9AwywbvmgYZS81NIiIHVASL6DdCKRIBBS0oApYAW28SF5MJP4SrwrI+RihUNuQVfm pFCp4hfq3zsOIo15blDsL9chHH+f1oRrI5Kb9iaAvvNQN6y67ziCvwLANsAEmUNLY8qN G9QQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DCV4aOoJ46ZF0jxbpqrKcxUZe1JHXLoObrCyTWUqx7U=; fh=euv7MLM0kGiiz4JlrX3siem/6f+9ZtkIaLrQaeVE+pk=; b=WfpCYfrhRmb0oIl71tSGm6vuqE6G9dZGgfAn3qO1sF+r4br+1G3KrpOpWwLXG3fgSY DRDzd2gGsT8Mn/7jUoJjpMKeMbhgiqAFE/qwwYp2ehSFTnzKAeI+eTqIjkjDxFntYLv8 oqi84HLZGNdMe1RjBtgA5wMqnjBOKpguD9h3a/OfkvXaBPTTWgTLaforEU6plonSq9y6 PBg5A9AzyvnXGzlA1o2XGDxHh0KgKKqtgCWebx9C/2KcWbgCRIh9B49cdOhq/cndssAQ sW1Rk0IEivo/Ii8XSkUjWV1dT6lv0k+hu+Nn4hEppbl96NfNlbLxh1xhVzhekp1kqnHG nb9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oznrvelo; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69420-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jr1-20020a0562142a8100b0068efb3f883asi788586qvb.380.2024.02.16.14.37.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69420-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oznrvelo; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69420-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 437161C2142D for ; Fri, 16 Feb 2024 22:37:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6514151CF8; Fri, 16 Feb 2024 22:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oznrvelo" Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA66414C584 for ; Fri, 16 Feb 2024 22:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122782; cv=none; b=GD3lTJNS/w3cgXtA7KPYRMYQEMLjNnBwi7pjp6kx0IJvr2hlAHUrj349UmvR+F9d4wfhPg1UH5h+LsSJjQrb4IgQNUnEeb00z7+IBlBey4XIHbl0iUCmf1uYcFPGCfUu8ZvPAkEM8DwBxuvWQjnogeFzIEBvs/4IS8Hb3xfqxTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122782; c=relaxed/simple; bh=oNX62pMUU90L6hUa+fYBn5B6a/Cz7XpyL+vXMyzirPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HqSklyGo6QNbyAsgTIIwCETvc/E0/gLOqL9SPDssBTVa3RKI4XjVZs226P2z0utkAml6TkrYBCH82gnK6mB8uuDvvgmDkzw2itPA1XGuyVuD3BsT6MU1D1r7jFsomOWHYJaUPVoFQSqwuCZr9wJCphEZFzVv1n9XBRDjahM3dak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oznrvelo; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c031a077d5so811159b6e.0 for ; Fri, 16 Feb 2024 14:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122776; x=1708727576; darn=vger.kernel.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=DCV4aOoJ46ZF0jxbpqrKcxUZe1JHXLoObrCyTWUqx7U=; b=oznrvelocY4PrrufeiON287TMF4g79TVubYXwzsLcAnxe676OeWhaKLmVa8qKAqMwI zCgnMCLT6MzJtDl9lKyDXSmdZQjtXGPNXNfXauOdbSfJJ6LEYn+ENcujZoHcaNYoCZ+y BRNvyd7wdzSri8SdDKzIb8syxHajCXme2akseaXGkHPwjFzHIVZrZk8OEmWWt52dlHH+ wcXCx+bD/P022DlFR6gb+XIbqb3T+oRei0vFybhwZ68wXW8JYkOtguTf1P9ln2Rz4Nql kW7cKwAgAsjYHIo3roT4cKJrwq3d0OOEoFJ5eNTHliWoVxZbK1sN8lyO4A+qQao3fWRy 2lfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122776; x=1708727576; 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=DCV4aOoJ46ZF0jxbpqrKcxUZe1JHXLoObrCyTWUqx7U=; b=U5tW1IFmWijxc0oMkBWCOc3PqLvAJeyfKR4coWVDqUoUW1zZod9ZubNyIRNGFbfD+y T7OvZIsW5O9BIO4kUpNnDiBf0FXrwmyqydlXVnq5V4UtfjmCM9yZOnOVf+tRixx5WHBV zZ2PpA5TMXKturF4MQ/A1ZN2JFIQrzhF4GwC1JqiYZ/ykNL0zCZRgCIJQ4uGKmprIT1+ OuUQUcFqqC95eKUxNOYLL9r8THa/tCCk5XndjC6it9ZS4F07QwnlyepsEDebv7FYK/xX ysY0bGNHD18WmHdz9yKMD8QPY30/hUzKo19WRyzIYoxdgayY108KlrRPK3HgAZpsmUxz +X/A== X-Forwarded-Encrypted: i=1; AJvYcCUPrgcKZHAhgCZgjCq8kKIHUvivnmgqOpALvu/V8glRsEeX8HzA3f4he8NKKZIi3fIHHd/4jo665JfDeefM5zEFs3/mbxThvtgz/6wN X-Gm-Message-State: AOJu0Yw95gVs71ITW3iDi2I6kImFXNtTSE+Xl5VbOmauDud5O2C2LTVh AJfHEJUH1qYFCcH/qO/cJKj7Z82ZA7pVOioieJyvPS11R/i43BIpeshcjiEhNbQ= X-Received: by 2002:a05:6808:2288:b0:3bf:f1da:633 with SMTP id bo8-20020a056808228800b003bff1da0633mr7530049oib.54.1708122776687; Fri, 16 Feb 2024 14:32:56 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id bf19-20020a056808191300b003c0315ead99sm126430oib.45.2024.02.16.14.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:56 -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 13/16] clk: samsung: Add CPU clock support for Exynos850 Date: Fri, 16 Feb 2024 16:32:42 -0600 Message-Id: <20240216223245.12273-14-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096813446959453 X-GMAIL-MSGID: 1791096813446959453 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 --- 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 5ea618da0bc1..cdf592da42e9 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 @@ -396,6 +397,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->ctrl_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->ctrl_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 */ @@ -458,6 +631,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 Fri Feb 16 22:32:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28720dyc; Fri, 16 Feb 2024 14:37:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW+iF4F6zQRc2HWMguB6oDXrlrH2M7KMuTYaFQPYm36estIwD6ad418GxqygIcguNKLurFAcnL9DLvUQ4L0xuMnd81UEg== X-Google-Smtp-Source: AGHT+IF+1Eue5meruhaK3bigo1y4NPtQWJPqS8D5ur/Hg++NTce0NvYGZEcH8pQBio0Hl/oOBz1/ X-Received: by 2002:a05:6a21:3483:b0:1a0:5de4:2f53 with SMTP id yo3-20020a056a21348300b001a05de42f53mr12372315pzb.25.1708123023861; Fri, 16 Feb 2024 14:37:03 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c16-20020a637250000000b005d760c23e09si540103pgn.146.2024.02.16.14.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jGvQ5uE9; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-69419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69419-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 161EB2814FE for ; Fri, 16 Feb 2024 22:36:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3B0E151CE7; Fri, 16 Feb 2024 22:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jGvQ5uE9" Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBE5C14C5A6 for ; Fri, 16 Feb 2024 22:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122781; cv=none; b=usKYKg1JWSUSoWqqNbw15aMljcL7HmvQ3ZLeUyTMiIuiOdsr3vznByOtbQVwyPEDJWIijrAXAmCCEpYQuHiqqA9VdqnkciVgrZdZAuyHBdKefjU6ek1IOEgc08bcNLGWtHxSqN489Iq9vUik0FpBgsKOnzQitFPXEVpL3mKMUro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122781; c=relaxed/simple; bh=mDEwKzsyvf/QX+KvIev3e4OPvDvB9fGW+nh4W4T2pXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cjmvlsAY2H1biifgLVIiBOs7jov1dgSK8WyvS5w17OfkaSLLtWznEXUQv6V2gE9rtJ1OXsRaQ3ui+aI3QYDFdcRyTUFZ1DvonNXdO/ZJtlF1kQZFzAPJvW8/gni/RhMSGk2OeybDfLuoGRQhd8EAC7cTTE6V5iDhn7DTbAin8BI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jGvQ5uE9; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e2dafa7011so852695a34.1 for ; Fri, 16 Feb 2024 14:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122777; x=1708727577; darn=vger.kernel.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=BmCUsZXeotk8RcE8hvgBX4XFcFyr4or7RHYfeMxqrr8=; b=jGvQ5uE9Ui0NeCaAsMR1o0JK72WRARwgqEywr8PN1VlUsaW7zOcHjL2uPYVTlpj+TR zV12QcwOQDVIyDpfM1kdzggyzKXI/PvqvJ6mnnpDItbyRH7Pmdc6N974uN1Stodqdoz9 tFkD3wIKamksHJlS2FVaN54Du1jo8NYfUR34ItAvHBz/+0eYRn83vHZM6vbZfY9svMYE qMYfTYGjhtfcPfHwqOx3VqRzPUQeEqp+cWIstyFv9F0n/7yzTK98SbYhnMUUfXgJfTuH 3b7smSagqUP+HcDBu/NTtUMZmVt1pGKKdF2pBRWnfbpFFuMd1AoUItuW+tBF62Njls5s FPKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122777; x=1708727577; 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=BmCUsZXeotk8RcE8hvgBX4XFcFyr4or7RHYfeMxqrr8=; b=X2hJFxbt11crVO4iGO4DhCmj0M+ND3HsWKI02rek2YD6nNi+wVtc6Q00OMxMQBFYM6 Bb0+qvgTSj0M7tObSwJhb7hGsHUtFfDPQzcWRsLUAcIcPRJ9VoFLhRlyJcahVO9MV1sA EMXUNEbxUbWJdqw/bpZM1RshWQ9m5xsKRju8vjAdgQdAJVdOhGj15+sC5Fz0hCYoAVF9 9yt6KWMQLqhbIhSYYx8dBKFxQSYCzvG3nuKLNtQ5FY4l8g41rWfpUd571e64vZawk/hr uqWPcMsrV+k/PfTHpAJJJtB3kPjLOWnnILKBbOvCL/5vEvknFq2tLVOZf+rIT558Ej6e m/pQ== X-Forwarded-Encrypted: i=1; AJvYcCV8OMCAiyGIlSphZXTRDE9WOvH/6qwMApiR/BNcWZdP9qIq+Jsk8IGdI3PSKe+8qhwzKonZ8Q2jFXIFD14mdHACUbfo7ifHcP9XN2og X-Gm-Message-State: AOJu0YyNmKOsXwhpSj93L8MEeQPvu06qKkPv8rJdF4igkVwVALuW4M78 jDde6ajK1ROHT6YIIWusTLgifeMirIGXNh28vKGQYp5W0UZeNaX9rkcHAkvyvac= X-Received: by 2002:a05:6830:1389:b0:6e2:ec57:bfcf with SMTP id d9-20020a056830138900b006e2ec57bfcfmr2159466otq.19.1708122777528; Fri, 16 Feb 2024 14:32:57 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id u11-20020a056830118b00b006dbfafc2049sm140600otq.30.2024.02.16.14.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:57 -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 14/16] clk: samsung: Implement manual PLL control for ARM64 SoCs Date: Fri, 16 Feb 2024 16:32:43 -0600 Message-Id: <20240216223245.12273-15-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096807546218442 X-GMAIL-MSGID: 1791096807546218442 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 --- 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 87bbb8b31b03..632c21dbd873 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 Fri Feb 16 22:32:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28804dyc; Fri, 16 Feb 2024 14:37:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWR2Jjlrmhgdi/DDGT1ROCLl15mwI98NQX/P5a5zhz9IX6nZs8x3CiVc/DqMg0hwzVaZymOpGe4Nf+95pHxltJyOirCTA== X-Google-Smtp-Source: AGHT+IFXJWu0pqVA1ZgaaFit9dT3mmJQtV1jGBDPC6BkSR7+qAY1F1A7/ZlajjRdhkcznDooVCpZ X-Received: by 2002:a05:620a:c17:b0:783:1e5b:8e57 with SMTP id l23-20020a05620a0c1700b007831e5b8e57mr14475353qki.34.1708123042786; Fri, 16 Feb 2024 14:37:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708123042; cv=pass; d=google.com; s=arc-20160816; b=Q1dD9ollr4uJHa9Goc/SJ4Pkni+CyEevPTepzlZplqMWA2oYvUc5TZlqf2cJIj1p3B dodSW9J8brE4MCzSo0xN35hkbgMOGwJy6TUzvJeYXN/wHTfmfUG0RVhU/G/K9jp2mlsu swTDt+ajGAUrIwQRosA0emQeULiMuijixrmKk3sYU3VqZd36IotNTmxw4TwSXfY2dXpH 9XoJnNklaw/uLOpA+wmW1WxxYZtoMyK2nBW+QaaFzqCpHOwWcMY3xCC4Y5KbuQ6r6zQI 5gLA/O1wJAVgP44NN07eesKW8AkpG5bcQtyTMdjGSD+ZOitoqI+o9ygLGze3gUwY8I9+ AGpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=F0Q8XrtyaDtTLycbBxdBWNasLRrDLF8CQ529QvpMu38=; fh=5mXBNWcB0WzbfitHa/nRTv39Q/K7BtxPSmTuEPpbI1E=; b=mW7SVVm1klBOf0Va+qkij4zYbIODXvjYkzzjB/Sd+vZRLuHVO4JrUj9PmBiZ730s8y DSzRnmG14FAwtkTXtFqYcqzIDesi20Q19cM5FcCp7l4Yc8V45SVE725IfQIaKMcjutEE MRPs4yf/OsOgoeyjAB7waNAqmOitD+ttJ8nEfrRFyWZdFS4QYyXpC8K6PQlujVkYzwyd HeqRQALuMemUOKuGGwXXiIEUYuXcN/3VqgvoNyGuU3MQZwDlm8V4hrYf3Wyo5W2gKGTI +xoTIHPwNhJQDrDSG1WLFUFRYBM+I3wRQoR2a/a2mCa5aAqFp6oU/GP8FXf3rLp2INh/ DPug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o2BgKMZz; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69421-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z9-20020ae9c109000000b00785db0e12bbsi892692qki.652.2024.02.16.14.37.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:37:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o2BgKMZz; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69421-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69421-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 838381C215D6 for ; Fri, 16 Feb 2024 22:37:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FF8E152DF3; Fri, 16 Feb 2024 22:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o2BgKMZz" Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E14D914D42A for ; Fri, 16 Feb 2024 22:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122783; cv=none; b=TJKMqg7VapG04Uq71rXvajxkGRMloUTpcsiV+675hYg94rN+xj0CTTE0FPX2CJVhtFLoGkMmtdKUxAHTX4IAv+P6pNmVinkdDmb0p9oEQSR1SzRTigRs3DFPwltonWrb8fuNYdbyM2zJ065IGFpkTn3kwBbKO2YMwJkMwuJqiBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122783; c=relaxed/simple; bh=cy8fD8owLu7Gb9LJp8nPw2GScsIkZmy7V7thy5M7DVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rHI7eZUTN89g9twirala/h/tI2GY5+6j/daHwa/McniN9ZyGdVrK+BN5G5VpeS4mLRyqV916Aao/DAaEBGJRhsDxhobMG2o3G5E4lEwXueQZediBXjfecnuuePmQGdsIGKg735AfSrWPJt/SVFDW31Q3TXlXAMt53vE6Nnm5vM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=o2BgKMZz; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3bba0ac2e88so2096234b6e.0 for ; Fri, 16 Feb 2024 14:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122778; x=1708727578; darn=vger.kernel.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=F0Q8XrtyaDtTLycbBxdBWNasLRrDLF8CQ529QvpMu38=; b=o2BgKMZz61w8yBkKIudRJ1DKovZ7sG6prZikvx1SP4N6PdJLxp5vRLNTKG20SVxMFN rDQV4o60BM/ZoikqsijsJpw6qSjHp1WjuCxw78BV3a/VhpRRVp7LtsDBOJ/5P980wvh1 T2dm0WwcFVmI59viq5wXMaV6BpEqYGDAM0lvzy/oTL8JG8ii+RRhpXr+wcUO9vf6yb81 i3UviphYPNhsYrKW21mtuS+NMGW/BUUIjxridRHsB0ROmJL2Or4hPve6W22HM/U5tsXT cAGOW2a82R+vuNlFCYnPbPsNxqgiyO4OjH4b/HZ5eigaQdbQ7YNkjZg6gfOthJ2lR6U+ LdiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122778; x=1708727578; 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=F0Q8XrtyaDtTLycbBxdBWNasLRrDLF8CQ529QvpMu38=; b=RphM9q4BAl5bj6gp4b0IOAY0uFfaLD+Q59OnhTufX6BDyhPjz5TxiMmMAs6t2Mzi0s W7MvN4OiGdFA4i4ypLEaU1OtJM7p6kukD4oD+VfqWvFbzvNG8YA3x9YZw7jODfffHKV9 59Q2KSTaLupsSOaUW1reM4albexF/wqcK63nCdR91Hd4qLFvgg3PH2mjtH7OFlCX+/yS ANissLW3Mbg0Yn3RCNoSC2hn6nnmvJjQFwUw1ggdXNPceTht61d69UH4Ixj1viRWZ8tj 4cWDx0atO2D6fN2JTPsIlg14e+cQUYw/PRmIHcgwdhFf9NNv/57OOBRmb8dx9IhByOvX jc2w== X-Forwarded-Encrypted: i=1; AJvYcCUtWmAL1lIVuEUpzdREZ5WTspIymtaSRlgFGcY/IYwhhiiBgFuBGRojC0XB2q9Bhy+tCh/pbt+R+Fye+8ImhUO5H+6KZKwEtgR4loib X-Gm-Message-State: AOJu0YyLkZU++styk/O8bEKu6IZxgZnqCoP2t2g3oKi8XeN0IzmDw/uY +eFfQQPx7NqWtjURvoh2++6M2m8ED4I7YOSOpskL1pZOsC1nmpnRhkbxi3SQUmA= X-Received: by 2002:a05:6808:b05:b0:3c0:48f2:d5d2 with SMTP id s5-20020a0568080b0500b003c048f2d5d2mr4236124oij.17.1708122778454; Fri, 16 Feb 2024 14:32:58 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id w24-20020a056830111800b006e2c16b7df4sm142378otq.23.2024.02.16.14.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:58 -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 15/16] clk: samsung: exynos850: Add CMU_CPUCL0 and CMU_CPUCL1 Date: Fri, 16 Feb 2024 16:32:44 -0600 Message-Id: <20240216223245.12273-16-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096827606999967 X-GMAIL-MSGID: 1791096827606999967 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 --- 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 Fri Feb 16 22:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 202398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp28749dyc; Fri, 16 Feb 2024 14:37:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWARZallFEMkCXZ47g53dA9b0YYD/IZFhjFfpYPHKYsfyH5KmzpAipfoCwv4E3YEOriS0rV9URgprKh5NCIDtYJWfQHlg== X-Google-Smtp-Source: AGHT+IHWDlyyV/eQUudO/QBtOTpoHwLQ8MzAs/yYGd5Uz0LfajWoGH5XihgcwhoX2omF0px2SIks X-Received: by 2002:a05:6102:d8f:b0:46d:4090:6ac2 with SMTP id d15-20020a0561020d8f00b0046d40906ac2mr7287300vst.11.1708123028984; Fri, 16 Feb 2024 14:37:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708123028; cv=pass; d=google.com; s=arc-20160816; b=zIlmeyjodvagb24T1spWcY6tMBh5SeceVU5NJQ2ZjXXxsn+5NPxfBgeKxFo9jd4pEZ K+IUcGVA7+8kpLoazrixrfyrrrFLtD35lOdCL4TJDJE7TNYk3BJHk2IvT5XCQqjQbQrx g24WiqTuAqnc8tl1PFQNKekpGfF8llwLNmwStj2fSh2j/rZlxnd76SuNFfi7kMjKop+0 wcg9l9ltOy61YQlT9wyG4wZG0tB+NurrxQ83hByv6EJQ7yYeFPAFyKg+cGx0HGLeeuu2 Za71p86xnWlSRq+Yw1Mug2jvl4uP+fx7jnjSHtQ8/L5SijQUay2LH+RsNpqEx3BZdZS3 gulg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hqedr2Cf8uu/ojchTl0vqAT7pyl8JaYNxl2fhHgkUDU=; fh=rjjsNvnil7bIewoLvRMmJFbRzSCj4S+xwHxYoZvsSjQ=; b=vwLmAEqMkL068wPsdc0yVuiDgxqPt9WdGH0U3CqkGZYgfk4hEZRuvNj4kJZVzgbRRo +B6iDyNtekvgEvT1TL5zsSi9NV7+Bu69JxTIl423aucpKlu9ZWmz35zskZMsfTFzOkeX +LLICMcJsu/iLQZ9CUCBeopbV13mmJroDpgR41DH946VBhZWyYEsplYmd2VnTkZkbpLg bS63fYQYXSaZA8F/HRjWBNFew61hfZ+h+huIeuOZSP3ktDvHHR5W7Qop7Vx1B41w3a2W CAhiyzV4MH2Re/AzWZEt3rw0XRxSKBhT5pJTDCrLnJC+TRrNuxzcfRBUPAQcn9lZB1Hn sH6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nPIKj6BG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69422-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y15-20020ac85f4f000000b0042c74f61419si933335qta.634.2024.02.16.14.37.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:37:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nPIKj6BG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69422-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69422-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B3D2A1C21493 for ; Fri, 16 Feb 2024 22:37:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE0AC1509B2; Fri, 16 Feb 2024 22:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nPIKj6BG" Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5A7614D44D for ; Fri, 16 Feb 2024 22:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122784; cv=none; b=K/FsCM+j3yMZIptCeiIXNLSD/2S1Xkg6q1iKt5TTCiUJrdZp+CHMvfLhR+ZqPFM3O7F65/Kn32zPxnbYhryxNtAikH/2J4ENae9riG9b6LB+CUvTcul6evh1LhdXV/8yMlWRclu9qCTtcDHvQ/Y4AGm/mEx9SRKuQP2Gm9cTUpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708122784; c=relaxed/simple; bh=IpYTwVvtbGsA5DUmVNUVd0AssLWUdtfSYxsrxvQPaCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sGY0eEDQh7No5aUXsi9EqHj+bafehNyp3MCr7ggnrURFEOVlRQ+wdHoWv5O5UFK34WkJ/kJCvCoUipPzBUgbqJ6jKdbRv+IqGYq6lc4GsFvEoHrE5nCBIFNmIWAQBhhBJ+4YIiYjTM+a9ik8Gv5+m3WoM4M+p0F/viRd1kyT7MA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=nPIKj6BG; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3c0496f494cso2366077b6e.1 for ; Fri, 16 Feb 2024 14:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708122779; x=1708727579; darn=vger.kernel.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=hqedr2Cf8uu/ojchTl0vqAT7pyl8JaYNxl2fhHgkUDU=; b=nPIKj6BGNEUwUY5wJ8eHJsXcPeR/CmInExnkB3YDvRe/jjYn3X6y/XZx8IHOpEhMbS 7recHhiYEzRJNXlTZ8ze9xzsVqJV+XyJ0ZDLoaIENOpscbwdhoPawvClZ1NTe3xPC9Jm TFdk8v8wmRLf6Ruus73Zzo76pqQmSmfPySh95IMiBiLy2VFqcv1k+vze42o+LbyRO8nV IBjkd6coac2SVtMOyQZEgylqh/y5P19tNHZC0g1o2bSg+L/h0R9C0EJ/49LAPn27KHnQ Qxz7OrLQvmprIckMPKAtMF03rKlS8xwL4wp0O+yM0jVv7sqZBKHts1tYRDRFUKxikp81 nh5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708122779; x=1708727579; 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=hqedr2Cf8uu/ojchTl0vqAT7pyl8JaYNxl2fhHgkUDU=; b=IFicB4jhc4w1B0lxlN2U1ISdZPxSoFJrusdRQaRf5iHtcEwt7kNWGtzjmo33svrim8 KRIY6Ub8nrDpCWfpCbDZZ6NzUfjnIPyVfTHVV9SojWdh7io7+LkIpGjG5uq8jf2J6WyJ t1Fw/ld0juG3EYPyaEFD43t5V5bhUy7b/sk0a2WHdbzvCHWrmcYoYPbwo6G61DdZ3CTj UsRHesCoZv0BS9tf5sVsGTpU3IOwWsOncKpn8BRTF8KEfj3gamivT5svXGcvN1mn1nAW ZG04iKU0CyNdy5yfz/UHmxJ/VujELaE3hoZIlWWGONtaYpd9Cj69zrwjdNBKpOt8xMUE kMPA== X-Forwarded-Encrypted: i=1; AJvYcCXhM/Wnd2hQU1g6lVJG2GFPW29xQmqVmSbjc4TloWkq/pYpgI5pNg5bSAJHIJ2CpNSj4KXRi6IRf6js8ASevMd+F6tGXWgcpocOo9PZ X-Gm-Message-State: AOJu0YwH8/z4RzXk6SXb6AaAm+Cr7zGiHMdHCibCnc3yecMXWhwum2rK aomjD75/ZZdaHclZ62Ob748qVEV7jXhNBHIyYyLsmKp/EkEygIoziSp7Kdy6OTc= X-Received: by 2002:a05:6808:3193:b0:3bf:f4b2:2164 with SMTP id cd19-20020a056808319300b003bff4b22164mr7924507oib.28.1708122779339; Fri, 16 Feb 2024 14:32:59 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id cr3-20020a056808368300b003bff074dd43sm126449oib.58.2024.02.16.14.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 14:32:59 -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 16/16] arm64: dts: exynos: Add CPU clocks Date: Fri, 16 Feb 2024 16:32:45 -0600 Message-Id: <20240216223245.12273-17-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216223245.12273-1-semen.protsenko@linaro.org> References: <20240216223245.12273-1-semen.protsenko@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791096813177924337 X-GMAIL-MSGID: 1791096813177924337 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 --- 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>;