From patchwork Tue Mar 7 00:24:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13162550 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 06907C61DA4 for ; Tue, 7 Mar 2023 00:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UBJapeYzwWGBjy51U0eUvrPoEr+hqLRFhwCTNQk1Gos=; b=hpyChXS/pXbpMm Z0JBwogChtejt6ptvAnuIa8NZjuiS46FakvPqy/Cuam2ytTxD6ci1LlTxW2jjkLi5mmpAq8Q0uF8b l9cNWWBOHJqBvdwTGHBC0xpM8UyCYIHCULRPoiNnjRQ2nTb0Udq2sqWTd3UHbKzcrVBPNSJCRoIg3 SJTxi+o7GeBwqm/T2nZ7CMXW6nmpdiJtyyxi5vKW/MopapaV8tzYbEH/xVWg7odCPU8HP9ZdxfdCK Mgs8Kf2KLjNg4ecyQ2lpjFnD/GOFVz84xzZEy+r/Kj0ZL09Y0cVNsYvNbLajQieZmFmj2M8swzYX7 3Fb0EOwjLVkZsaYz81dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZL8B-00FayN-Gx; Tue, 07 Mar 2023 00:24:39 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZL7z-00Fatk-O3 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 00:24:29 +0000 Received: by mail-oi1-x234.google.com with SMTP id bh20so8450951oib.9 for ; Mon, 06 Mar 2023 16:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678148665; 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=X33PgEK5uIcJ5gMDM0bY9YafAMoBom21UwJHhtQLkAM=; b=xNAHfRPYa7eHF6pVyz/fiz1bw0fEJMXoPYD+zzqJXp7uTha9Q5JjcvCFNYG5iNX/jq 63kEoaK36OWCvXYHTdeFCnO3QT5aCSajjD6lRc4NAXZCZw8dWHIv87jmdpUhxrFjKEgN 4Nv/xe8ZPcSyHJ5zp5fDSH2et9s4Bp86YBNy/tVcfOUV8VjfbDlkw9hOk77gkXhV2ecq wNK5DWZ9wqZT39JFZjeKsMjOoaFyUxeX0WC0ejtBiOoIxLmdKZyi3WsSXoexI9X6RQ9K f5LnWxdWhmKTH6aCaCfElU4aJJzF7p1QaHZ4hvTdavv4R/8P8B5+ammHixy3zyRvXfAX cABw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678148665; 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=X33PgEK5uIcJ5gMDM0bY9YafAMoBom21UwJHhtQLkAM=; b=eqR20p5MGdl6TojYzrlATUVVIKCTSfXH/D0XtK1s4GysRWW5v/PDWq9UaNhCvBA/mI 7r9ohRImlyeBbZ/tKRaB+Y6ZnA1Y58KntLVjCk4pZatptgauUSSDKsNMr1zGsEXV0QNo I22aMeyo1u3wby1r33TH/rIm84IAVD5T1wQZ2UxKdNA2mbUSj1ZiaFnYjMuyF3OWcpp7 sbwDUaPse/Nu30m5d5qxSMg9fJCI2hIqlTZ+YYnU7hbNFHdA9vkXum2JPOxd5GUMf23F +hXX9PpYTo/SimfnfRiAbTm2Pp4kb78TPaS0nJ9NirexSOy/7boPmZWGELjYxjQqBx4I EIOQ== X-Gm-Message-State: AO0yUKW+pfBQnK1GlVDbda75EoO3fv+VaWduEVG7ExsUKg3FhpvrmE36 wujtNptqzlSOmrE4ahqW7wUeaA== X-Google-Smtp-Source: AK7set+9REwPUF0kOZOW/EW1tavBrAoM+cYn9XS3xZdyCYP0hL1GzpNV5ZXscCD6ojdCrRJOZZyf7Q== X-Received: by 2002:a05:6808:106:b0:384:219:5691 with SMTP id b6-20020a056808010600b0038402195691mr5403953oie.15.1678148665590; Mon, 06 Mar 2023 16:24:25 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id s7-20020acac207000000b00383b2b6f453sm4606169oif.35.2023.03.06.16.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 16:24:25 -0800 (PST) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi Cc: Tomasz Figa , Alim Akhtar , Chanho Park , David Virag , Sumit Semwal , Michael Turquette , Stephen Boyd , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] clk: samsung: Extract clocks registration to common function Date: Mon, 6 Mar 2023 18:24:21 -0600 Message-Id: <20230307002423.24454-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307002423.24454-1-semen.protsenko@linaro.org> References: <20230307002423.24454-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_162427_822366_8EF3AA87 X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It might be useful to have a separate clocks registration function, so it can be called from different users. Extract that common code from samsung_cmu_register_one() to samsung_cmu_register_clocks(). Also make that new function global as it's going to be used in other modules further. Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko --- Changes in v4: - Rebased on top of krzk/linux.git/for-next tree Changes in v3: - Rebased on top of latest soc/for-next tree - Added Marek's Acked-by tag Changes in v2: - Rebased on top of latest soc/for-next tree drivers/clk/samsung/clk.c | 46 ++++++++++++++++++++++++--------------- drivers/clk/samsung/clk.h | 2 ++ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index 912dfbe5ac20..b6701905f254 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -335,6 +335,33 @@ void samsung_clk_extended_sleep_init(void __iomem *reg_base, } #endif +/** + * samsung_cmu_register_clocks() - Register all clocks provided in CMU object + * @ctx: Clock provider object + * @cmu: CMU object with clocks to register + */ +void __init samsung_cmu_register_clocks(struct samsung_clk_provider *ctx, + const struct samsung_cmu_info *cmu) +{ + if (cmu->pll_clks) + samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks); + if (cmu->mux_clks) + samsung_clk_register_mux(ctx, cmu->mux_clks, cmu->nr_mux_clks); + if (cmu->div_clks) + samsung_clk_register_div(ctx, cmu->div_clks, cmu->nr_div_clks); + if (cmu->gate_clks) + samsung_clk_register_gate(ctx, cmu->gate_clks, + cmu->nr_gate_clks); + if (cmu->fixed_clks) + samsung_clk_register_fixed_rate(ctx, cmu->fixed_clks, + cmu->nr_fixed_clks); + if (cmu->fixed_factor_clks) + samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks, + cmu->nr_fixed_factor_clks); + if (cmu->cpu_clks) + samsung_clk_register_cpu(ctx, cmu->cpu_clks, cmu->nr_cpu_clks); +} + /* * Common function which registers plls, muxes, dividers and gates * for each CMU. It also add CMU register list to register cache. @@ -353,29 +380,12 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( } ctx = samsung_clk_init(NULL, reg_base, cmu->nr_clk_ids); + samsung_cmu_register_clocks(ctx, cmu); - if (cmu->pll_clks) - samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks); - if (cmu->mux_clks) - samsung_clk_register_mux(ctx, cmu->mux_clks, - cmu->nr_mux_clks); - if (cmu->div_clks) - samsung_clk_register_div(ctx, cmu->div_clks, cmu->nr_div_clks); - if (cmu->gate_clks) - samsung_clk_register_gate(ctx, cmu->gate_clks, - cmu->nr_gate_clks); - if (cmu->fixed_clks) - samsung_clk_register_fixed_rate(ctx, cmu->fixed_clks, - cmu->nr_fixed_clks); - if (cmu->fixed_factor_clks) - samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks, - cmu->nr_fixed_factor_clks); if (cmu->clk_regs) samsung_clk_extended_sleep_init(reg_base, cmu->clk_regs, cmu->nr_clk_regs, cmu->suspend_regs, cmu->nr_suspend_regs); - if (cmu->cpu_clks) - samsung_clk_register_cpu(ctx, cmu->cpu_clks, cmu->nr_cpu_clks); samsung_clk_of_add_provider(np, ctx); diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 3fd6c0868921..ab9c3d7a25b3 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -377,6 +377,8 @@ void samsung_clk_register_pll(struct samsung_clk_provider *ctx, void samsung_clk_register_cpu(struct samsung_clk_provider *ctx, const struct samsung_cpu_clock *list, unsigned int nr_clk); +void samsung_cmu_register_clocks(struct samsung_clk_provider *ctx, + const struct samsung_cmu_info *cmu); struct samsung_clk_provider *samsung_cmu_register_one( struct device_node *, const struct samsung_cmu_info *);