From patchwork Tue Dec 3 13:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 13892487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FA46E64AA4 for ; Tue, 3 Dec 2024 13:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QQwsguT5z3ey9C0x9NzUSLQgCUpxu3tSTZ7ZzPkfZ5g=; b=D+XUxxKiR5EMKR n2OkXpwLhf8qTrA4v/E4UtdPeoi51ZTPzC5L0Yap6NyAr1W6sekuuJqXX0HaSWpYNJXLQogXn/icH KNuD9s7lLE/KJ87CKiH66nFpPsOyMF5IslhuC+41dEXy61xS80zPP1I7DqoBk044C8P+TVlg0bTRB OBNz4QfUS9omj/AdfBQfNux/vmd7WUvP/03WxfdFuIKnDEO6f2+9DqjVLj9YJNWYiRxuo76zuYXJM xEbNsR8ynj35VidG+w/b/56N9LnAO2XPdexXJJSl+M/trVRPAwWq9EzMRuxuT0MKy+WrMbmiVqcsC oU3DVaqz1uMb0GjMuY9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tITA6-00000009e2Z-0o4A; Tue, 03 Dec 2024 13:41:58 +0000 Received: from [210.118.77.11] (helo=mailout1.w1.samsung.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tITA2-00000009e0C-3Rcs for linux-riscv@lists.infradead.org; Tue, 03 Dec 2024 13:41:56 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20241203134153euoutp011bdd6607ac973476b6caa4597034a6f1~NroQCYFDM2559325593euoutp01Q for ; Tue, 3 Dec 2024 13:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20241203134153euoutp011bdd6607ac973476b6caa4597034a6f1~NroQCYFDM2559325593euoutp01Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1733233313; bh=a88yTuKc0U8ya5XZYE8bq3AQdSOHV1kDfujITRvdz+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5d1BHZKJNrxvWKS37T6NyxZKQgiKL7c/D4nIHzWwwfTeEixx4fJhYbYQe+Yr6i7l Mgys5OHwUwhA2Y2L4zDf+T243G4AV7QZhQNTjNnrX0222n6PGjB4FQSr/N7mCs8QDk DtnaxxDqXklpHnERC6wtUdNxKQuWvhoDxklNvUeY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20241203134153eucas1p2eb472062c8d3c2e55fd6c337a04d3931~NroPq-ZAP2017220172eucas1p24; Tue, 3 Dec 2024 13:41:53 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B1.CA.20821.1AA0F476; Tue, 3 Dec 2024 13:41:53 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20241203134152eucas1p1ed480afaf4d7de3a4a706477e709b6fd~NroPMLKEF1743017430eucas1p1Z; Tue, 3 Dec 2024 13:41:52 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241203134152eusmtrp1e7991a53db793011b255982f7216e896~NroPLY6vw0888908889eusmtrp1-; Tue, 3 Dec 2024 13:41:52 +0000 (GMT) X-AuditID: cbfec7f2-b11c470000005155-63-674f0aa166ca Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A7.F6.19654.0AA0F476; Tue, 3 Dec 2024 13:41:52 +0000 (GMT) Received: from AMDC4942.home (unknown [106.210.136.40]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241203134151eusmtip27b7ed05ed073adc14202b77624744963~NroN5kQhD2454624546eusmtip2J; Tue, 3 Dec 2024 13:41:51 +0000 (GMT) From: Michal Wilczynski To: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, drew@pdp7.com, guoren@kernel.org, wefu@redhat.com, jassisinghbrar@gmail.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, frank.binns@imgtec.com, matt.coster@imgtec.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, ulf.hansson@linaro.org, jszhang@kernel.org, m.szyprowski@samsung.com Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-pm@vger.kernel.org, Michal Wilczynski Subject: [RFC PATCH v1 03/14] clk: thead: Enable clock gates with regmaps Date: Tue, 3 Dec 2024 14:41:26 +0100 Message-Id: <20241203134137.2114847-4-m.wilczynski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203134137.2114847-1-m.wilczynski@samsung.com> MIME-Version: 1.0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A9MbXkl8YZmBqaGJmaWBqaWZsZK4rxsV86nCQmkJ5akZqemFqQWwfQxcXBKNTDVhLqy PnWujjyx5UH0qmP3/z9clHzo2d37klkPy82alIWPK+85Mp9JfY1+zZScSyxm8r5MR2VY5gmX zuyvX/5T5I+Zs9qrDY/cM7W8DvB5WJ3+mfRV6dSiV6Iul48V8D34JmZ48nzczBexGx74Ti/4 vmn1ZEbm30cvb1/DUTrx1Repexml13izD06cPikuK8/+Xlql8UbJlQxrjBnTAk5snrXozjXf qKeRFtcbOfSuKjlpz1f+wGkX18sWL77043P+TNMU+UlNDxZPCHKI3CPBKrDLqPL27CML+FIU jITW/KpJN+tZXccssOG5akkFs1hJUtmfRvctay3zvH/EbpgtqpsRkcRT/tvmY1xLbIkSS3FG oqEWc1FxIgBpGSjwtQMAAA== X-CMS-MailID: 20241203134152eucas1p1ed480afaf4d7de3a4a706477e709b6fd X-Msg-Generator: CA X-RootMTR: 20241203134152eucas1p1ed480afaf4d7de3a4a706477e709b6fd X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20241203134152eucas1p1ed480afaf4d7de3a4a706477e709b6fd References: <20241203134137.2114847-1-m.wilczynski@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241203_054155_126352_3F141C7C X-CRM114-Status: GOOD ( 16.63 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The current implementation of the CCU_GATE macro assumes direct access to memory-mapped registers, which isn't suitable when using regmaps for register access. In the TH1520 SoC, the address space for the VO (Video Output) subsystem clocks is shared with other control registers, such as those used for resetting the GPU. To prevent conflicts and ensure synchronized access, it's important to access these registers via a regmap. This patch updates the CCU_GATE macro to support regmap-based access by reusing the clk_ops from the divider clocks (ccu_div_ops). This change allows the clock gates to be controlled through regmap, enabling proper synchronization when multiple components interact with the shared address space. Signed-off-by: Michal Wilczynski --- drivers/clk/thead/clk-th1520.c | 10 ++++++++-- drivers/clk/thead/clk-th1520.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/clk/thead/clk-th1520.c b/drivers/clk/thead/clk-th1520.c index e2bfe56de9af..3ada8b98bd8e 100644 --- a/drivers/clk/thead/clk-th1520.c +++ b/drivers/clk/thead/clk-th1520.c @@ -120,8 +120,14 @@ const struct clk_ops ccu_div_ops = { .determine_rate = clk_hw_determine_rate_no_reparent, }; -static unsigned long th1520_pll_vco_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) +const struct clk_ops ccu_gate_ops = { + .disable = ccu_div_disable, + .enable = ccu_div_enable, + .is_enabled = ccu_div_is_enabled, +}; + +unsigned long th1520_pll_vco_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) { struct ccu_pll *pll = hw_to_ccu_pll(hw); unsigned long div, mul, frac; diff --git a/drivers/clk/thead/clk-th1520.h b/drivers/clk/thead/clk-th1520.h index 5d30f55e88a1..532afbbfea01 100644 --- a/drivers/clk/thead/clk-th1520.h +++ b/drivers/clk/thead/clk-th1520.h @@ -94,6 +94,20 @@ struct ccu_pll { } \ } +#define CCU_GATE_REGMAP(_clkid, _struct, _name, _parent, _reg, _gate, _flags) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .clkid = _clkid, \ + .cfg0 = _reg, \ + .hw.init = CLK_HW_INIT_PARENTS_DATA( \ + _name, \ + _parent, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) { return container_of(hw, struct ccu_common, hw); @@ -130,5 +144,6 @@ static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw) extern const struct clk_ops ccu_div_ops; extern const struct clk_ops clk_pll_ops; extern const struct regmap_config th1520_clk_regmap_config; +extern const struct clk_ops ccu_gate_ops; #endif /* CLK_TH1520_H */