From patchwork Wed Feb 8 23:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 853F6C64EC5 for ; Wed, 8 Feb 2023 23:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbjBHXnD (ORCPT ); Wed, 8 Feb 2023 18:43:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbjBHXnC (ORCPT ); Wed, 8 Feb 2023 18:43:02 -0500 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFE11C337 for ; Wed, 8 Feb 2023 15:42:57 -0800 (PST) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-16a291b16bfso558831fac.7 for ; Wed, 08 Feb 2023 15:42:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=S6pc/fxZMqv/Ba/3boRFvyXeTwbRFVS36kkuAwIqnb0=; b=ms6fYZYwIzi415PDWqcer3XQBcB+0FiHQLuo9/eIrAzIyPlQToKSy3Bl2WEOggky1w XBDS+yBayYWaTOe+owm+t6AbQaiZAeIEv0TOfLU3ubbCMk+UAAkK6LkeR5Kn7ee/xNeP NGvIP/BSLths9V/mIHiThoIDtiAoAmRd1/hsUJKOTrUKwy1PSuUGv4wSWENfJPUeo4bl 4Epl1BOp4CnG9hKFWNvcDpucSKnk1CMNXXnmY4WfBtjs7F1fnKuDiSox5FauogLDuPUz mhpSj8n7yF/ocqUtuhPT+1U4vJyLQ2GmEW7/VEwI/dCYupiPDRWrTk2QETcpn5imorOs 4CuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=S6pc/fxZMqv/Ba/3boRFvyXeTwbRFVS36kkuAwIqnb0=; b=6ITGy7yKVsyNLLT5RcsWcJ5PKg1TR0N/7DGerF6IYWGb0ksyamFXaqechdyVKi6vOy tCxxrXLQTK98cb9zIg2B6WcJqyjbFTpLmYKI3u3hgStb4zqCgsPNJT1VM0d00EhxEy0O gosTlv/9Zr4jdpQlGDWeocstO/naLMl4X6jYJrvTRY/4ofe4AQbpiGd0GDi7V2H8KL3O w5yUx1KOWvj6kiLyNnlLA3k0xSHwNyyr3jOsBWXWKESWX/X/bdLbZe5+tR/82JBeqQqd IEdaecam0k0jzxpgHXALZdrOZ1m/E2ZSz81jP/xCJRPcKGn5LEj8t/Kktq8jOLw8InTq 68zQ== X-Gm-Message-State: AO0yUKVgTf6oKcdXKVqFtPRX2QK1pKv793V1e1Quy//vGlci6L5IjHmR vGdzgblYawCAH16y1PJw4LJqnw== X-Google-Smtp-Source: AK7set96GA4LKo/5gp5MfM+JfCqQgefR3/bB/21FB4FKPhxgFkCKrYJjeGox3xF34bejHSuty3OynA== X-Received: by 2002:a05:6870:6591:b0:169:decf:6ce3 with SMTP id fp17-20020a056870659100b00169decf6ce3mr5245087oab.14.1675899776178; Wed, 08 Feb 2023 15:42:56 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id c20-20020a4a4f14000000b0051a4b0ab2d0sm8018135oob.28.2023.02.08.15.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:42:55 -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 v2 1/6] clk: samsung: Don't pass reg_base to samsung_clk_register_pll() Date: Wed, 8 Feb 2023 17:43:08 -0600 Message-Id: <20230208234313.23863-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Base address can be derived from context structure. Remove `base' argument from samsung_clk_register_pll() and use `ctx->reg_base' instead, as it's done in other clock registering functions. No functional change. Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko --- Changes in v2: - Rebased on top of latest soc/for-next tree drivers/clk/samsung/clk-exynos4.c | 4 ++-- drivers/clk/samsung/clk-exynos5250.c | 3 +-- drivers/clk/samsung/clk-exynos5420.c | 3 +-- drivers/clk/samsung/clk-exynos5433.c | 4 ++-- drivers/clk/samsung/clk-pll.c | 11 +++++------ drivers/clk/samsung/clk-s3c64xx.c | 2 +- drivers/clk/samsung/clk-s5pv210.c | 4 ++-- drivers/clk/samsung/clk.c | 3 +-- drivers/clk/samsung/clk.h | 2 +- 9 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 22009cb53428..244f74f31746 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1276,7 +1276,7 @@ static void __init exynos4_clk_init(struct device_node *np, exynos4210_vpll_rates; samsung_clk_register_pll(ctx, exynos4210_plls, - ARRAY_SIZE(exynos4210_plls), reg_base); + ARRAY_SIZE(exynos4210_plls)); } else { if (clk_hw_get_rate(hws[CLK_FIN_PLL]) == 24000000) { exynos4x12_plls[apll].rate_table = @@ -1288,7 +1288,7 @@ static void __init exynos4_clk_init(struct device_node *np, } samsung_clk_register_pll(ctx, exynos4x12_plls, - ARRAY_SIZE(exynos4x12_plls), reg_base); + ARRAY_SIZE(exynos4x12_plls)); } samsung_clk_register_fixed_rate(ctx, exynos4_fixed_rate_clks, diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 113df773ee44..69862ab6dc52 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -815,8 +815,7 @@ static void __init exynos5250_clk_init(struct device_node *np) exynos5250_plls[vpll].rate_table = vpll_24mhz_tbl; samsung_clk_register_pll(ctx, exynos5250_plls, - ARRAY_SIZE(exynos5250_plls), - reg_base); + ARRAY_SIZE(exynos5250_plls)); samsung_clk_register_fixed_rate(ctx, exynos5250_fixed_rate_clks, ARRAY_SIZE(exynos5250_fixed_rate_clks)); samsung_clk_register_fixed_factor(ctx, exynos5250_fixed_factor_clks, diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index caad74dee297..df9e93d6adf2 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1606,8 +1606,7 @@ static void __init exynos5x_clk_init(struct device_node *np, else exynos5x_plls[bpll].rate_table = exynos5422_bpll_rate_table; - samsung_clk_register_pll(ctx, exynos5x_plls, ARRAY_SIZE(exynos5x_plls), - reg_base); + samsung_clk_register_pll(ctx, exynos5x_plls, ARRAY_SIZE(exynos5x_plls)); samsung_clk_register_fixed_rate(ctx, exynos5x_fixed_rate_clks, ARRAY_SIZE(exynos5x_fixed_rate_clks)); samsung_clk_register_fixed_factor(ctx, exynos5x_fixed_factor_clks, diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index f9daae20f393..eb72bf2aaee8 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -5610,8 +5610,8 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev) pm_runtime_enable(dev); if (info->pll_clks) - samsung_clk_register_pll(ctx, info->pll_clks, info->nr_pll_clks, - reg_base); + samsung_clk_register_pll(ctx, info->pll_clks, + info->nr_pll_clks); if (info->mux_clks) samsung_clk_register_mux(ctx, info->mux_clks, info->nr_mux_clks); diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index df7812371d70..5ceac4c25c1c 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -1259,8 +1259,7 @@ static const struct clk_ops samsung_pll2650xx_clk_min_ops = { }; static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, - const struct samsung_pll_clock *pll_clk, - void __iomem *base) + const struct samsung_pll_clock *pll_clk) { struct samsung_clk_pll *pll; struct clk_init_data init; @@ -1395,8 +1394,8 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, pll->hw.init = &init; pll->type = pll_clk->type; - pll->lock_reg = base + pll_clk->lock_offset; - pll->con_reg = base + pll_clk->con_offset; + pll->lock_reg = ctx->reg_base + pll_clk->lock_offset; + pll->con_reg = ctx->reg_base + pll_clk->con_offset; ret = clk_hw_register(ctx->dev, &pll->hw); if (ret) { @@ -1412,10 +1411,10 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx, const struct samsung_pll_clock *pll_list, - unsigned int nr_pll, void __iomem *base) + unsigned int nr_pll) { int cnt; for (cnt = 0; cnt < nr_pll; cnt++) - _samsung_clk_register_pll(ctx, &pll_list[cnt], base); + _samsung_clk_register_pll(ctx, &pll_list[cnt]); } diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index d6b432a26d63..d582bac68bb7 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c @@ -414,7 +414,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f, /* Register PLLs. */ samsung_clk_register_pll(ctx, s3c64xx_pll_clks, - ARRAY_SIZE(s3c64xx_pll_clks), reg_base); + ARRAY_SIZE(s3c64xx_pll_clks)); /* Register common internal clocks. */ samsung_clk_register_fixed_rate(ctx, s3c64xx_fixed_rate_clks, diff --git a/drivers/clk/samsung/clk-s5pv210.c b/drivers/clk/samsung/clk-s5pv210.c index 4425186bdcab..b91d20994bf5 100644 --- a/drivers/clk/samsung/clk-s5pv210.c +++ b/drivers/clk/samsung/clk-s5pv210.c @@ -753,7 +753,7 @@ static void __init __s5pv210_clk_init(struct device_node *np, samsung_clk_register_fixed_rate(ctx, s5p6442_frate_clks, ARRAY_SIZE(s5p6442_frate_clks)); samsung_clk_register_pll(ctx, s5p6442_pll_clks, - ARRAY_SIZE(s5p6442_pll_clks), reg_base); + ARRAY_SIZE(s5p6442_pll_clks)); samsung_clk_register_mux(ctx, s5p6442_mux_clks, ARRAY_SIZE(s5p6442_mux_clks)); samsung_clk_register_div(ctx, s5p6442_div_clks, @@ -764,7 +764,7 @@ static void __init __s5pv210_clk_init(struct device_node *np, samsung_clk_register_fixed_rate(ctx, s5pv210_frate_clks, ARRAY_SIZE(s5pv210_frate_clks)); samsung_clk_register_pll(ctx, s5pv210_pll_clks, - ARRAY_SIZE(s5pv210_pll_clks), reg_base); + ARRAY_SIZE(s5pv210_pll_clks)); samsung_clk_register_mux(ctx, s5pv210_mux_clks, ARRAY_SIZE(s5pv210_mux_clks)); samsung_clk_register_div(ctx, s5pv210_div_clks, diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index bca4731b14ea..e132d63933c3 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -344,8 +344,7 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids); if (cmu->pll_clks) - samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks, - reg_base); + 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); diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index b46e83a2581f..1b7315063edd 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -373,7 +373,7 @@ void samsung_clk_register_gate(struct samsung_clk_provider *ctx, unsigned int nr_clk); void samsung_clk_register_pll(struct samsung_clk_provider *ctx, const struct samsung_pll_clock *pll_list, - unsigned int nr_clk, void __iomem *base); + unsigned int nr_clk); void samsung_clk_register_cpu(struct samsung_clk_provider *ctx, const struct samsung_cpu_clock *list, unsigned int nr_clk); From patchwork Wed Feb 8 23:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B90AC636D3 for ; Wed, 8 Feb 2023 23:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjBHXnE (ORCPT ); Wed, 8 Feb 2023 18:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjBHXnC (ORCPT ); Wed, 8 Feb 2023 18:43:02 -0500 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E385E1C320 for ; Wed, 8 Feb 2023 15:42:58 -0800 (PST) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-16a291b16bfso558910fac.7 for ; Wed, 08 Feb 2023 15:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=f84JLknt9zf5KuZUy7eIlAu0yqleQaULaUEZ/2t+qgQ=; b=nFquQicdjsP2/hcUoahY97bT38Cuh30k6UJGdvvUS/74eV3tym2B77h2lXBsUtRF7e 3nbQbRRRch42ekqlx70g+Ll7faiUsHwjG875N7Q5ewXqpZ/QhjqNhv2nl9YSrqoLKjDf hL5I4gOnxQ5u5bWSein8BwDI91Frc3u8bYYZrI5iMmirtpiIzqZ+4myVbHoPybctsXqu M4Jw49PpkNPBv4vDkScrlbZWE7/KTZRCPRmUkiZEOVdnRYEy8tY8s5PjndKnmPA+DJCO xNsI346QtSHlzONN3713BC52KNJGbp3To7eukyLldT+6/WGRMKoGpZ5LMCdWlCSqFvEu yG3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=f84JLknt9zf5KuZUy7eIlAu0yqleQaULaUEZ/2t+qgQ=; b=H96wOnCmrO8zPhiqlsfpJKKjyoxyf8RmTbuDcZ6JS/C/wUGYNfc2MYFa2V3uAiV7se TDTu31bHVUP1QHLIjoTD3n8jDTRdChasx+TgXf+SkOjd0k84W8uGvDSFDncmJiGn6N5+ lLUbL9UYO6JZYBzSPVrDXBIflTlAl+T2eK15hExE3zV0cCDaNhiHNBa5/qJdhLEU9jU2 35LRMia89pm0ukX9JU9Eth8BNwtmyfYV7BsSK6Hib20Kw/fCzMhlX26elkh7OxylN92g 70G2NaeSW0kiB6OBcmDbq05i2fEtMU2VuPs6EuVPkeJI15YCsy2VrgNUFjq7RvKbuKP/ pE3g== X-Gm-Message-State: AO0yUKUWfCEZovFRav2wcnGqqGLltQ+zolIBfpSebkIXlN6GOmOgUW+8 pdSv6r7yQlwVYPbJxD3wLH44aQ== X-Google-Smtp-Source: AK7set8cwEKPwwAFCJQMGs0vbOXTdc83hpCY1w+EW9UmibhrgmEvRq53Os0+5Z+UP4JW+qtCaQFUag== X-Received: by 2002:a05:6870:c225:b0:15e:db7e:b4dc with SMTP id z37-20020a056870c22500b0015edb7eb4dcmr4943112oae.35.1675899778222; Wed, 08 Feb 2023 15:42:58 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id n38-20020a056870822600b00155ffbdbaffsm7446008oae.18.2023.02.08.15.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:42:57 -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 v2 2/6] clk: samsung: Remove np argument from samsung_clk_init() Date: Wed, 8 Feb 2023 17:43:09 -0600 Message-Id: <20230208234313.23863-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The code using `np' argument was removed from samsung_clk_init(). Remove that leftover parameter as well. No functional change. Fixes: d5e136a21b20 ("clk: samsung: Register clk provider only after registering its all clocks") Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko --- Changes in v2: - Rebased on top of latest soc/for-next tree drivers/clk/samsung/clk-exynos4.c | 2 +- drivers/clk/samsung/clk-exynos4412-isp.c | 2 +- drivers/clk/samsung/clk-exynos5250.c | 2 +- drivers/clk/samsung/clk-exynos5420.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 2 +- drivers/clk/samsung/clk-s5pv210.c | 2 +- drivers/clk/samsung/clk.c | 6 +++--- drivers/clk/samsung/clk.h | 3 +-- 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 244f74f31746..7a9994144d72 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1251,7 +1251,7 @@ static void __init exynos4_clk_init(struct device_node *np, if (!reg_base) panic("%s: failed to map registers\n", __func__); - ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos4_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-exynos4412-isp.c b/drivers/clk/samsung/clk-exynos4412-isp.c index 471a6fb82670..0b6390e04533 100644 --- a/drivers/clk/samsung/clk-exynos4412-isp.c +++ b/drivers/clk/samsung/clk-exynos4412-isp.c @@ -121,7 +121,7 @@ static int __init exynos4x12_isp_clk_probe(struct platform_device *pdev) if (!exynos4x12_save_isp) return -ENOMEM; - ctx = samsung_clk_init(np, reg_base, CLK_NR_ISP_CLKS); + ctx = samsung_clk_init(reg_base, CLK_NR_ISP_CLKS); ctx->dev = dev; platform_set_drvdata(pdev, ctx); diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 69862ab6dc52..f1cb69aea10e 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -797,7 +797,7 @@ static void __init exynos5250_clk_init(struct device_node *np) panic("%s: unable to determine soc\n", __func__); } - ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos5250_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index df9e93d6adf2..46cac4980be2 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1587,7 +1587,7 @@ static void __init exynos5x_clk_init(struct device_node *np, exynos5x_soc = soc; - ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos5x_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index d582bac68bb7..47e9d19486dc 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c @@ -405,7 +405,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f, panic("%s: failed to map registers\n", __func__); } - ctx = samsung_clk_init(np, reg_base, NR_CLKS); + ctx = samsung_clk_init(reg_base, NR_CLKS); hws = ctx->clk_data.hws; /* Register external clocks. */ diff --git a/drivers/clk/samsung/clk-s5pv210.c b/drivers/clk/samsung/clk-s5pv210.c index b91d20994bf5..b0ab6bc9d21d 100644 --- a/drivers/clk/samsung/clk-s5pv210.c +++ b/drivers/clk/samsung/clk-s5pv210.c @@ -743,7 +743,7 @@ static void __init __s5pv210_clk_init(struct device_node *np, struct samsung_clk_provider *ctx; struct clk_hw **hws; - ctx = samsung_clk_init(np, reg_base, NR_CLKS); + ctx = samsung_clk_init(reg_base, NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_register_mux(ctx, early_mux_clks, diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index e132d63933c3..2436223aac1a 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -54,8 +54,8 @@ struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump( } /* setup the essentials required to support clock lookup using ccf */ -struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np, - void __iomem *base, unsigned long nr_clks) +struct samsung_clk_provider * __init samsung_clk_init(void __iomem *base, + unsigned long nr_clks) { struct samsung_clk_provider *ctx; int i; @@ -341,7 +341,7 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( return NULL; } - ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids); + ctx = samsung_clk_init(reg_base, cmu->nr_clk_ids); if (cmu->pll_clks) samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks); diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 1b7315063edd..98753b0e5055 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -337,8 +337,7 @@ struct samsung_cmu_info { const char *clk_name; }; -struct samsung_clk_provider * samsung_clk_init( - struct device_node *np, void __iomem *base, +struct samsung_clk_provider *samsung_clk_init(void __iomem *base, unsigned long nr_clks); void samsung_clk_of_add_provider(struct device_node *np, struct samsung_clk_provider *ctx); From patchwork Wed Feb 8 23:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46DB6C64EC4 for ; Wed, 8 Feb 2023 23:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbjBHXnM (ORCPT ); Wed, 8 Feb 2023 18:43:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjBHXnF (ORCPT ); Wed, 8 Feb 2023 18:43:05 -0500 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F1681C5B7 for ; Wed, 8 Feb 2023 15:43:00 -0800 (PST) Received: by mail-oo1-xc2c.google.com with SMTP id w3-20020a4aa443000000b0051ac1e0f6b7so59998ool.11 for ; Wed, 08 Feb 2023 15:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=5jCJhdLbW2RQNs5IFAF6sXee3DGnrSicdVM+kwite9A=; b=aIsK4k6UuIa608h5e7Ti7pAohbKQX+x1VwiShBoWVHle5KJ6n4eSGjIRZripbbwxmm V0K1mrYsUP/41I+3sun+CO7r2hEXfpwdc+mXx01FIUDew83KEiKRJ2b7mgbC9FIFglB1 kbjQmms3mMJlU337i7yJLzWYwTBgsOAVVdPoAnQz/3v2vPaxRyE8U8VLTu3AGDLichsG x+k6HqU5z3j5GVy8mjkvXr7R+NQM+8HU8JTU1OpsltCie992yDPQm3WM49tISn6xUtXU 3WNDuzQHCRxQFhY+MpfDZcaCy1XOmVug347gDKiHjAO4ZqpXTeOVDR7sgXoY5EFInZEH zl8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5jCJhdLbW2RQNs5IFAF6sXee3DGnrSicdVM+kwite9A=; b=Xdb5jPKYbdUubZUS5VGvxco8USY0WqrIbkYUYTB5lbs5DCaZpf4YXwQ1o/xZsuVaFq Soqfa3VPwqV4odCTPhDF9f2d8oN0ynjHwjwDV26k83XJUuj2sSUt+/tMw+7ac19/nAOo Ek45qhb5qYbhwRpRsJ5I3ASzZjcI5l/mn8DJBTKskNsrgfplYPTn0+jrNe91gLIOUgOv lSb9bjFUKMWk5ZC6eyQu4+ijSGT6Tx5A8kMX/g/maWOUaVrmQA7Y00Q+pUFPJPCoCCe7 n7K1sQzLd2QPszGlNHWRzqmqqipIhYTcfC6D8Bm5nIVzjqX0DB6N7TRdzSF+ZP3FA/Eg 6Bgg== X-Gm-Message-State: AO0yUKUZAzaGK1iYObachBEVacwt0hQfUthEXQ+RqT36PYQTZyRj+a+J xi18Peak6JO2+v+m+7cPt37FIQ== X-Google-Smtp-Source: AK7set+ujAU2/+ND9zB9ndCu6E+rgIfdMz5QGzKWl97oBfjaFxSDS44oYnHUFq/3rddCOV3t3/gCzg== X-Received: by 2002:a4a:a748:0:b0:516:f374:443f with SMTP id h8-20020a4aa748000000b00516f374443fmr3963391oom.8.1675899779240; Wed, 08 Feb 2023 15:42:59 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id p17-20020a4a95d1000000b0050dc3c2f77asm8011011ooi.8.2023.02.08.15.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:42:58 -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 v2 3/6] clk: samsung: Set dev in samsung_clk_init() Date: Wed, 8 Feb 2023 17:43:10 -0600 Message-Id: <20230208234313.23863-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Some drivers set dev to context in order to implement PM. Make that part of samsung_clk_init() instead of assigning `ctx->dev = dev' separately. No functional change. Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko --- Changes in v2: - Rebased on top of latest soc/for-next tree drivers/clk/samsung/clk-exynos4.c | 2 +- drivers/clk/samsung/clk-exynos4412-isp.c | 3 +-- drivers/clk/samsung/clk-exynos5250.c | 2 +- drivers/clk/samsung/clk-exynos5420.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 2 +- drivers/clk/samsung/clk-s5pv210.c | 2 +- drivers/clk/samsung/clk.c | 19 +++++++++++++++---- drivers/clk/samsung/clk.h | 5 +++-- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 7a9994144d72..d7dbb3858347 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -1251,7 +1251,7 @@ static void __init exynos4_clk_init(struct device_node *np, if (!reg_base) panic("%s: failed to map registers\n", __func__); - ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos4_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-exynos4412-isp.c b/drivers/clk/samsung/clk-exynos4412-isp.c index 0b6390e04533..1470c15e95da 100644 --- a/drivers/clk/samsung/clk-exynos4412-isp.c +++ b/drivers/clk/samsung/clk-exynos4412-isp.c @@ -121,8 +121,7 @@ static int __init exynos4x12_isp_clk_probe(struct platform_device *pdev) if (!exynos4x12_save_isp) return -ENOMEM; - ctx = samsung_clk_init(reg_base, CLK_NR_ISP_CLKS); - ctx->dev = dev; + ctx = samsung_clk_init(dev, reg_base, CLK_NR_ISP_CLKS); platform_set_drvdata(pdev, ctx); diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index f1cb69aea10e..92fb09922f28 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -797,7 +797,7 @@ static void __init exynos5250_clk_init(struct device_node *np) panic("%s: unable to determine soc\n", __func__); } - ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos5250_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index 46cac4980be2..1e0cbf762408 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -1587,7 +1587,7 @@ static void __init exynos5x_clk_init(struct device_node *np, exynos5x_soc = soc; - ctx = samsung_clk_init(reg_base, CLK_NR_CLKS); + ctx = samsung_clk_init(NULL, reg_base, CLK_NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_of_register_fixed_ext(ctx, exynos5x_fixed_rate_ext_clks, diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index 47e9d19486dc..d27a1f73f077 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c @@ -405,7 +405,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f, panic("%s: failed to map registers\n", __func__); } - ctx = samsung_clk_init(reg_base, NR_CLKS); + ctx = samsung_clk_init(NULL, reg_base, NR_CLKS); hws = ctx->clk_data.hws; /* Register external clocks. */ diff --git a/drivers/clk/samsung/clk-s5pv210.c b/drivers/clk/samsung/clk-s5pv210.c index b0ab6bc9d21d..cd85342e4ddb 100644 --- a/drivers/clk/samsung/clk-s5pv210.c +++ b/drivers/clk/samsung/clk-s5pv210.c @@ -743,7 +743,7 @@ static void __init __s5pv210_clk_init(struct device_node *np, struct samsung_clk_provider *ctx; struct clk_hw **hws; - ctx = samsung_clk_init(reg_base, NR_CLKS); + ctx = samsung_clk_init(NULL, reg_base, NR_CLKS); hws = ctx->clk_data.hws; samsung_clk_register_mux(ctx, early_mux_clks, diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index 2436223aac1a..912dfbe5ac20 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -53,9 +53,19 @@ struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump( return rd; } -/* setup the essentials required to support clock lookup using ccf */ -struct samsung_clk_provider * __init samsung_clk_init(void __iomem *base, - unsigned long nr_clks) +/** + * samsung_clk_init() - Create and initialize a clock provider object + * @dev: CMU device to enable runtime PM, or NULL if RPM is not needed + * @base: Start address (mapped) of CMU registers + * @nr_clks: Total clock count to allocate in clock provider object + * + * Setup the essentials required to support clock lookup using Common Clock + * Framework. + * + * Return: Allocated and initialized clock provider object. + */ +struct samsung_clk_provider * __init samsung_clk_init(struct device *dev, + void __iomem *base, unsigned long nr_clks) { struct samsung_clk_provider *ctx; int i; @@ -67,6 +77,7 @@ struct samsung_clk_provider * __init samsung_clk_init(void __iomem *base, for (i = 0; i < nr_clks; ++i) ctx->clk_data.hws[i] = ERR_PTR(-ENOENT); + ctx->dev = dev; ctx->reg_base = base; ctx->clk_data.num = nr_clks; spin_lock_init(&ctx->lock); @@ -341,7 +352,7 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( return NULL; } - ctx = samsung_clk_init(reg_base, cmu->nr_clk_ids); + ctx = samsung_clk_init(NULL, reg_base, cmu->nr_clk_ids); if (cmu->pll_clks) samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks); diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 98753b0e5055..3fd6c0868921 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -16,6 +16,7 @@ /** * struct samsung_clk_provider: information about clock provider * @reg_base: virtual address for the register base. + * @dev: clock provider device needed for runtime PM. * @lock: maintains exclusion between callbacks for a given clock-provider. * @clk_data: holds clock related data like clk_hw* and number of clocks. */ @@ -337,8 +338,8 @@ struct samsung_cmu_info { const char *clk_name; }; -struct samsung_clk_provider *samsung_clk_init(void __iomem *base, - unsigned long nr_clks); +struct samsung_clk_provider *samsung_clk_init(struct device *dev, + void __iomem *base, unsigned long nr_clks); void samsung_clk_of_add_provider(struct device_node *np, struct samsung_clk_provider *ctx); void samsung_clk_of_register_fixed_ext( From patchwork Wed Feb 8 23:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 775BFC05027 for ; Wed, 8 Feb 2023 23:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjBHXnN (ORCPT ); Wed, 8 Feb 2023 18:43:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjBHXnG (ORCPT ); Wed, 8 Feb 2023 18:43:06 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8872F1C7C4 for ; Wed, 8 Feb 2023 15:43:03 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id bx13so232500oib.13 for ; Wed, 08 Feb 2023 15:43:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=KWb4xLniEmX+aWkTp2SPNOhVEYOvshRRUAHEhXXIsDk=; b=MtlXTC9QR7LQkVwUGxlZJvFnsxfQlHwErlGTzk4en0hUrTFa66zaJxERrMAOsV5mC6 Vsiv7PmuV0SMUCsRpu5NW1VL/Q9tAAB7K/EnIYQEbKLgBVhbBAufeRwjTfZKYIMr6ts1 8eCYCyhTfpf1TuZeOZM8YZH7o0MVFJYC5wlmv8qiu6A3t5VVATcBUxMvAcrOZIC8hJsh igUTl9owbOUaKnuH6reK53u9vxOdyHaPGACHyb4Do/AfXZK8hPm7OQD9QED/dGhe1rhj 2mBKxCHiw9fjE9SwVTskkcaxCDAooTN6uqAbfKyvCyBazHpzh6yfShszbRDRz146cH6s KCNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KWb4xLniEmX+aWkTp2SPNOhVEYOvshRRUAHEhXXIsDk=; b=mB9qKO56ZH1n1VLaqnyxjW48Cudf9Y6TOYORXayAzVAYp2bLYRbE32YobXFl8BIoEM 5joufw8NLZ6tFMe33oVKZp07434tbSwmIpYx0eXW4kW18ulXINll7tPX4ukUcb989kjd 9SwDFSw0Iiiur1CTrtnuvkwQLMkyPVMQ7fIZxHrE3PUq+wSu9lct1jNTvEyrQaWap2Q6 x/X+9dVWV5IKFGw23sg6gFyFYucIRXquM3LRrR3SmRbjDR2KBPxD4aPjJexKpWLl7Hh5 rgrUqo+SRShKD6zeHDAk2rYee5qRRXnpO0S0Fe4uuPOGWWsKjHyxmkTdWmXQ82UMRNlL x1Aw== X-Gm-Message-State: AO0yUKWRkmyjX295WhZQknKeTBi+Dx7aaAxM91UE9GsZGvMpmhv4x2Y9 vIBSNxbW8b73oREmWt5S3JIUeA== X-Google-Smtp-Source: AK7set8qZ/gZ5VjIpU6HFIYV2AnCDnlTwxC4sxKEMKVd8wyAUcpzOZ4d/yucYwLh1OiZEzMm7PgHog== X-Received: by 2002:a54:468f:0:b0:378:951d:a13e with SMTP id k15-20020a54468f000000b00378951da13emr3664712oic.27.1675899781283; Wed, 08 Feb 2023 15:43:01 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id o131-20020aca4189000000b003786e78f2b5sm47497oia.9.2023.02.08.15.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:43:00 -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 v2 4/6] clk: samsung: Extract clocks registration to common function Date: Wed, 8 Feb 2023 17:43:11 -0600 Message-Id: <20230208234313.23863-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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 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 *); From patchwork Wed Feb 8 23:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E1BC6379F for ; Wed, 8 Feb 2023 23:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjBHXnP (ORCPT ); Wed, 8 Feb 2023 18:43:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbjBHXnH (ORCPT ); Wed, 8 Feb 2023 18:43:07 -0500 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3F91CF73 for ; Wed, 8 Feb 2023 15:43:04 -0800 (PST) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1636eae256cso654715fac.0 for ; Wed, 08 Feb 2023 15:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=u3TQijj1zNEkMgIbB33746rNlmKDxV7N66SIgj0jQUQ=; b=r4nQNOWBzVynaqZrRXOi+W5IJ7rgPu8UYjOMJ7CcciSMSGYOewBVZTIL4nbqb9znCz 6Pplrqd+dG5YTCBaHulkQodV6zHxIhhhMDz2Fz/EhFW9o7sWHEXnyAwg/u8h28RvUY+3 sfM+WZw7mX4NpYEmF/bPadKseepuZgDD7GhmNZOmGW5yl2wNphCUIwFeP459GjJ64iYs 4gxIQo4hbJbz2Tfw31seJEcZ+ULccIWGT4v9Dpkbjb+kYFycCcaz+YpCXbOmrHexy2/m PrxddhxFE8PRZQ6c4R2aw1gsheQ8UhRjf57QNer5HeKy8Q9mPMP8hUpDxqpAx6LO4cFf Hhzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=u3TQijj1zNEkMgIbB33746rNlmKDxV7N66SIgj0jQUQ=; b=lWP1WKL/w1Wro+bdo+oyD97RvpGpxU2z1Ys6u4oLQLX/rjxdn99FJ6KA2MOTntaZ34 x/0omGxveh0jScikF56SD7b/YPwLImSRLFLE5ynLM93uEnl3Gcp6fcFL1Twa5w/Elcne 89PD7Tenf/3z3UuC6/sITosYTT+qQkQ6ZiVM+8G4ysbl1/eiIx704hWFHqdXK5xnDIB+ j3eQNAJkeSiti8S02dsY9Zt+p6WOCYD4Qrp+ALGig+KzA8ZBG24yCjd/ZbgTwtrx7Rnj LK26UdWqPqHts7pBgDGAhzxBJltKReu440zshP/Ce1X0joxiw8hgFVuls0qIB1JqHspY GKRw== X-Gm-Message-State: AO0yUKXqbK8dmTuze6CSLFhqJrFRTm9FjUJ+fRG9LqpXzqJrE0uP5IMf 6pW/+uj8N3fIl40zTUPAhIiPMA== X-Google-Smtp-Source: AK7set+KUQwbpmWSnr7ihtxwIRu7Tt3YgvSh2JEZxfJuyvrzzID8ro6gA9F3R3pjxvhzTKPA15Z8wQ== X-Received: by 2002:a05:6870:783:b0:15b:b523:3299 with SMTP id en3-20020a056870078300b0015bb5233299mr4714452oab.28.1675899783303; Wed, 08 Feb 2023 15:43:03 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id zf18-20020a0568716a9200b0016a629e1917sm3672069oab.52.2023.02.08.15.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:43:02 -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 v2 5/6] clk: samsung: Extract parent clock enabling to common function Date: Wed, 8 Feb 2023 17:43:12 -0600 Message-Id: <20230208234313.23863-6-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Extract parent clock enabling from exynos_arm64_register_cmu() to dedicated function. Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko --- Changes in v2: - Rebased on top of latest soc/for-next tree - Improved English in kernel doc comment - Added clk_prepare_enable() return value check - Added exynos_arm64_enable_bus_clk() check in exynos_arm64_register_cmu() - Changed the commit message to reflect code changes drivers/clk/samsung/clk-exynos-arm64.c | 51 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-arm64.c b/drivers/clk/samsung/clk-exynos-arm64.c index b921b9a1134a..2aa3f0a5644e 100644 --- a/drivers/clk/samsung/clk-exynos-arm64.c +++ b/drivers/clk/samsung/clk-exynos-arm64.c @@ -56,6 +56,37 @@ static void __init exynos_arm64_init_clocks(struct device_node *np, iounmap(reg_base); } +/** + * exynos_arm64_enable_bus_clk - Enable parent clock of specified CMU + * + * @dev: Device object; may be NULL if this function is not being + * called from platform driver probe function + * @np: CMU device tree node + * @cmu: CMU data + * + * Keep CMU parent clock running (needed for CMU registers access). + * + * Return: 0 on success or a negative error code on failure. + */ +static int __init exynos_arm64_enable_bus_clk(struct device *dev, + struct device_node *np, const struct samsung_cmu_info *cmu) +{ + struct clk *parent_clk; + + if (!cmu->clk_name) + return 0; + + if (dev) + parent_clk = clk_get(dev, cmu->clk_name); + else + parent_clk = of_clk_get_by_name(np, cmu->clk_name); + + if (IS_ERR(parent_clk)) + return PTR_ERR(parent_clk); + + return clk_prepare_enable(parent_clk); +} + /** * exynos_arm64_register_cmu - Register specified Exynos CMU domain * @dev: Device object; may be NULL if this function is not being @@ -72,23 +103,11 @@ static void __init exynos_arm64_init_clocks(struct device_node *np, void __init exynos_arm64_register_cmu(struct device *dev, struct device_node *np, const struct samsung_cmu_info *cmu) { - /* Keep CMU parent clock running (needed for CMU registers access) */ - if (cmu->clk_name) { - struct clk *parent_clk; - - if (dev) - parent_clk = clk_get(dev, cmu->clk_name); - else - parent_clk = of_clk_get_by_name(np, cmu->clk_name); - - if (IS_ERR(parent_clk)) { - pr_err("%s: could not find bus clock %s; err = %ld\n", - __func__, cmu->clk_name, PTR_ERR(parent_clk)); - } else { - clk_prepare_enable(parent_clk); - } - } + int err; + err = exynos_arm64_enable_bus_clk(dev, np, cmu); + if (err) + panic("%s: could not enable bus clock\n", __func__); exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs); samsung_cmu_register_one(np, cmu); } From patchwork Wed Feb 8 23:43:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13133799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2B5CC636D3 for ; Wed, 8 Feb 2023 23:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjBHXnT (ORCPT ); Wed, 8 Feb 2023 18:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbjBHXnL (ORCPT ); Wed, 8 Feb 2023 18:43:11 -0500 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33421C7D6 for ; Wed, 8 Feb 2023 15:43:05 -0800 (PST) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-15fe106c7c7so549171fac.8 for ; Wed, 08 Feb 2023 15:43:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=I8DjKi1QoUzJ0JkxCwg+VjZkGydASy4lR+II+PR8vM0=; b=pYlWTDfHa4ih1QgnQbvEo9J0oMgH3EPDAQfMIypOzPX3RhFQFNZhGSqz4EdNjHk8U+ 337DT3Pc+gJ6uye/ZQnGsklSYDlieBh86cRANcTl/L7OmboLTCsCekVx9f9UOEXV+Gw6 a2uYealJjjCPpkzzvGzDcTa6AkMjjFNn+6Enf3oq8lsfAQFLE2n7xdhr50djde1mOAX4 pS7guKByXSM6YcCUI0ewgX72SIPRO78GB62wTVXLqTiYrI4cKsEWU98vAv3eKZR/SXIb f/JsWo5waXlmfHctev7P3X9a9KzxrP7zFQpCRaLil2AJVY/z9sicggXEqOLW/idEDXPw dQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=I8DjKi1QoUzJ0JkxCwg+VjZkGydASy4lR+II+PR8vM0=; b=PaPASL1eoWHafeFu3SMeKUyMN36MgzVA1ETy/PgeQhvVsqVrvv6J3Tz76cksvZSZnP kCYukPEiej34JfLQDtj+RKZeY1YRTrF9fXmPnuyWj9FkiPUAiD7Soz4czV+ljacGAvtj bNOBF5KYIegAYm8i1QM94/rSYIXwUBb8F19jyoLHSrtud7HjPk3Bx2o9m60BuBz0rNCM Se8IcCL8z08dzROhicIUKv/AkKrHRQTtCOM/9pjbVsnELOFGKNwzHmD/oNsWe6q3OCNl ExwYStbnE4FlCRxJHtmBumxnTUVhlEXQo2jzik6mKUXkVJ4Sif81Azh0QYKob4NcUIA3 kMlA== X-Gm-Message-State: AO0yUKVvUDdxjSibtAy5YsrUwlNi1hokkOl02Ukc6Efxp2saqWLJ/VPA B0eN6s/vZt9UfXzdFvK/mZfcIQ== X-Google-Smtp-Source: AK7set+CT/DUS67wJ/K0V0xhkgpyLgRGZ8++F+664WvEwzq28yzHr11g0Pg9xH8IskHyGfJrTj+DYw== X-Received: by 2002:a05:6870:55a0:b0:163:3070:9059 with SMTP id n32-20020a05687055a000b0016330709059mr1412226oao.46.1675899785167; Wed, 08 Feb 2023 15:43:05 -0800 (PST) Received: from localhost ([136.49.140.41]) by smtp.gmail.com with ESMTPSA id h4-20020a056870d34400b00144e18d8525sm7491582oag.25.2023.02.08.15.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 15:43:04 -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 v2 6/6] clk: samsung: exynos5433: Extract PM support to common ARM64 layer Date: Wed, 8 Feb 2023 17:43:13 -0600 Message-Id: <20230208234313.23863-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208234313.23863-1-semen.protsenko@linaro.org> References: <20230208234313.23863-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Exynos5433 clock driver implements PM support internally, which might be also useful for other Exynos clock drivers. Extract all PM related code from clk-exynos5433 to common ARM64 functions. Tested-by: Marek Szyprowski Signed-off-by: Sam Protsenko Acked-by: Marek Szyprowski --- Changes in v2: - Rebased on top of latest soc/for-next tree - Included linux/slab.h for kfree (found by kernel test robot) drivers/clk/samsung/clk-exynos-arm64.c | 171 ++++++++++++++++++++++++- drivers/clk/samsung/clk-exynos-arm64.h | 3 + drivers/clk/samsung/clk-exynos5433.c | 157 +---------------------- 3 files changed, 175 insertions(+), 156 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-arm64.c b/drivers/clk/samsung/clk-exynos-arm64.c index 2aa3f0a5644e..7ad7fd353dda 100644 --- a/drivers/clk/samsung/clk-exynos-arm64.c +++ b/drivers/clk/samsung/clk-exynos-arm64.c @@ -10,6 +10,9 @@ */ #include #include +#include +#include +#include #include "clk-exynos-arm64.h" @@ -21,6 +24,19 @@ #define GATE_OFF_START 0x2000 #define GATE_OFF_END 0x2fff +struct exynos_arm64_cmu_data { + struct samsung_clk_reg_dump *clk_save; + unsigned int nr_clk_save; + const struct samsung_clk_reg_dump *clk_suspend; + unsigned int nr_clk_suspend; + + struct clk *clk; + struct clk **pclks; + int nr_pclks; + + struct samsung_clk_provider *ctx; +}; + /** * exynos_arm64_init_clocks - Set clocks initial configuration * @np: CMU device tree node with "reg" property (CMU addr) @@ -76,10 +92,16 @@ static int __init exynos_arm64_enable_bus_clk(struct device *dev, if (!cmu->clk_name) return 0; - if (dev) + if (dev) { + struct exynos_arm64_cmu_data *data; + parent_clk = clk_get(dev, cmu->clk_name); - else + data = dev_get_drvdata(dev); + if (data) + data->clk = parent_clk; + } else { parent_clk = of_clk_get_by_name(np, cmu->clk_name); + } if (IS_ERR(parent_clk)) return PTR_ERR(parent_clk); @@ -87,6 +109,46 @@ static int __init exynos_arm64_enable_bus_clk(struct device *dev, return clk_prepare_enable(parent_clk); } +static int __init exynos_arm64_cmu_prepare_pm(struct device *dev, + const struct samsung_cmu_info *cmu) +{ + struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev); + int i; + + data->clk_save = samsung_clk_alloc_reg_dump(cmu->clk_regs, + cmu->nr_clk_regs); + if (!data->clk_save) + return -ENOMEM; + + data->nr_clk_save = cmu->nr_clk_regs; + data->clk_suspend = cmu->suspend_regs; + data->nr_clk_suspend = cmu->nr_suspend_regs; + data->nr_pclks = of_clk_get_parent_count(dev->of_node); + if (!data->nr_pclks) + return 0; + + data->pclks = devm_kcalloc(dev, sizeof(struct clk *), data->nr_pclks, + GFP_KERNEL); + if (!data->pclks) { + kfree(data->clk_save); + return -ENOMEM; + } + + for (i = 0; i < data->nr_pclks; i++) { + struct clk *clk = of_clk_get(dev->of_node, i); + + if (IS_ERR(clk)) { + kfree(data->clk_save); + while (--i >= 0) + clk_put(data->pclks[i]); + return PTR_ERR(clk); + } + data->pclks[i] = clk; + } + + return 0; +} + /** * exynos_arm64_register_cmu - Register specified Exynos CMU domain * @dev: Device object; may be NULL if this function is not being @@ -111,3 +173,108 @@ void __init exynos_arm64_register_cmu(struct device *dev, exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs); samsung_cmu_register_one(np, cmu); } + +/** + * exynos_arm64_register_cmu_pm - Register Exynos CMU domain with PM support + * + * @pdev: Platform device object + * @set_manual: If true, set gate clocks to manual mode + * + * It's a version of exynos_arm64_register_cmu() with PM support. Should be + * called from probe function of platform driver. + * + * Return: 0 on success, or negative error code on error. + */ +int __init exynos_arm64_register_cmu_pm(struct platform_device *pdev, + bool set_manual) +{ + const struct samsung_cmu_info *cmu; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct exynos_arm64_cmu_data *data; + void __iomem *reg_base; + int ret; + + cmu = of_device_get_match_data(dev); + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + platform_set_drvdata(pdev, data); + + ret = exynos_arm64_cmu_prepare_pm(dev, cmu); + if (ret) + return ret; + + ret = exynos_arm64_enable_bus_clk(dev, NULL, cmu); + if (ret) + return ret; + + if (set_manual) + exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs); + + reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(reg_base)) + return PTR_ERR(reg_base); + + data->ctx = samsung_clk_init(dev, reg_base, cmu->nr_clk_ids); + + /* + * Enable runtime PM here to allow the clock core using runtime PM + * for the registered clocks. Additionally, we increase the runtime + * PM usage count before registering the clocks, to prevent the + * clock core from runtime suspending the device. + */ + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + samsung_cmu_register_clocks(data->ctx, cmu); + samsung_clk_of_add_provider(dev->of_node, data->ctx); + pm_runtime_put_sync(dev); + + return 0; +} + +int exynos_arm64_cmu_suspend(struct device *dev) +{ + struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev); + int i; + + samsung_clk_save(data->ctx->reg_base, data->clk_save, + data->nr_clk_save); + + for (i = 0; i < data->nr_pclks; i++) + clk_prepare_enable(data->pclks[i]); + + /* For suspend some registers have to be set to certain values */ + samsung_clk_restore(data->ctx->reg_base, data->clk_suspend, + data->nr_clk_suspend); + + for (i = 0; i < data->nr_pclks; i++) + clk_disable_unprepare(data->pclks[i]); + + clk_disable_unprepare(data->clk); + + return 0; +} + +int exynos_arm64_cmu_resume(struct device *dev) +{ + struct exynos_arm64_cmu_data *data = dev_get_drvdata(dev); + int i; + + clk_prepare_enable(data->clk); + + for (i = 0; i < data->nr_pclks; i++) + clk_prepare_enable(data->pclks[i]); + + samsung_clk_restore(data->ctx->reg_base, data->clk_save, + data->nr_clk_save); + + for (i = 0; i < data->nr_pclks; i++) + clk_disable_unprepare(data->pclks[i]); + + return 0; +} diff --git a/drivers/clk/samsung/clk-exynos-arm64.h b/drivers/clk/samsung/clk-exynos-arm64.h index 0dd174693935..969979e714bc 100644 --- a/drivers/clk/samsung/clk-exynos-arm64.h +++ b/drivers/clk/samsung/clk-exynos-arm64.h @@ -16,5 +16,8 @@ void exynos_arm64_register_cmu(struct device *dev, struct device_node *np, const struct samsung_cmu_info *cmu); +int exynos_arm64_register_cmu_pm(struct platform_device *pdev, bool set_manual); +int exynos_arm64_cmu_suspend(struct device *dev); +int exynos_arm64_cmu_resume(struct device *dev); #endif /* __CLK_EXYNOS_ARM64_H */ diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index eb72bf2aaee8..ed43233649ae 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include "clk.h" #include "clk-cpu.h" +#include "clk-exynos-arm64.h" #include "clk-pll.h" /* @@ -5478,160 +5478,9 @@ static const struct samsung_cmu_info imem_cmu_info __initconst = { .clk_name = "aclk_imem_200", }; -struct exynos5433_cmu_data { - struct samsung_clk_reg_dump *clk_save; - unsigned int nr_clk_save; - const struct samsung_clk_reg_dump *clk_suspend; - unsigned int nr_clk_suspend; - - struct clk *clk; - struct clk **pclks; - int nr_pclks; - - /* must be the last entry */ - struct samsung_clk_provider ctx; -}; - -static int __maybe_unused exynos5433_cmu_suspend(struct device *dev) -{ - struct exynos5433_cmu_data *data = dev_get_drvdata(dev); - int i; - - samsung_clk_save(data->ctx.reg_base, data->clk_save, - data->nr_clk_save); - - for (i = 0; i < data->nr_pclks; i++) - clk_prepare_enable(data->pclks[i]); - - /* for suspend some registers have to be set to certain values */ - samsung_clk_restore(data->ctx.reg_base, data->clk_suspend, - data->nr_clk_suspend); - - for (i = 0; i < data->nr_pclks; i++) - clk_disable_unprepare(data->pclks[i]); - - clk_disable_unprepare(data->clk); - - return 0; -} - -static int __maybe_unused exynos5433_cmu_resume(struct device *dev) -{ - struct exynos5433_cmu_data *data = dev_get_drvdata(dev); - int i; - - clk_prepare_enable(data->clk); - - for (i = 0; i < data->nr_pclks; i++) - clk_prepare_enable(data->pclks[i]); - - samsung_clk_restore(data->ctx.reg_base, data->clk_save, - data->nr_clk_save); - - for (i = 0; i < data->nr_pclks; i++) - clk_disable_unprepare(data->pclks[i]); - - return 0; -} - static int __init exynos5433_cmu_probe(struct platform_device *pdev) { - const struct samsung_cmu_info *info; - struct exynos5433_cmu_data *data; - struct samsung_clk_provider *ctx; - struct device *dev = &pdev->dev; - void __iomem *reg_base; - int i; - - info = of_device_get_match_data(dev); - - data = devm_kzalloc(dev, - struct_size(data, ctx.clk_data.hws, info->nr_clk_ids), - GFP_KERNEL); - if (!data) - return -ENOMEM; - ctx = &data->ctx; - - reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(reg_base)) - return PTR_ERR(reg_base); - - for (i = 0; i < info->nr_clk_ids; ++i) - ctx->clk_data.hws[i] = ERR_PTR(-ENOENT); - - ctx->clk_data.num = info->nr_clk_ids; - ctx->reg_base = reg_base; - ctx->dev = dev; - spin_lock_init(&ctx->lock); - - data->clk_save = samsung_clk_alloc_reg_dump(info->clk_regs, - info->nr_clk_regs); - if (!data->clk_save) - return -ENOMEM; - data->nr_clk_save = info->nr_clk_regs; - data->clk_suspend = info->suspend_regs; - data->nr_clk_suspend = info->nr_suspend_regs; - data->nr_pclks = of_clk_get_parent_count(dev->of_node); - - if (data->nr_pclks > 0) { - data->pclks = devm_kcalloc(dev, sizeof(struct clk *), - data->nr_pclks, GFP_KERNEL); - if (!data->pclks) { - kfree(data->clk_save); - return -ENOMEM; - } - for (i = 0; i < data->nr_pclks; i++) { - struct clk *clk = of_clk_get(dev->of_node, i); - - if (IS_ERR(clk)) { - kfree(data->clk_save); - while (--i >= 0) - clk_put(data->pclks[i]); - return PTR_ERR(clk); - } - data->pclks[i] = clk; - } - } - - if (info->clk_name) - data->clk = clk_get(dev, info->clk_name); - clk_prepare_enable(data->clk); - - platform_set_drvdata(pdev, data); - - /* - * Enable runtime PM here to allow the clock core using runtime PM - * for the registered clocks. Additionally, we increase the runtime - * PM usage count before registering the clocks, to prevent the - * clock core from runtime suspending the device. - */ - pm_runtime_get_noresume(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - - if (info->pll_clks) - samsung_clk_register_pll(ctx, info->pll_clks, - info->nr_pll_clks); - if (info->mux_clks) - samsung_clk_register_mux(ctx, info->mux_clks, - info->nr_mux_clks); - if (info->div_clks) - samsung_clk_register_div(ctx, info->div_clks, - info->nr_div_clks); - if (info->gate_clks) - samsung_clk_register_gate(ctx, info->gate_clks, - info->nr_gate_clks); - if (info->fixed_clks) - samsung_clk_register_fixed_rate(ctx, info->fixed_clks, - info->nr_fixed_clks); - if (info->fixed_factor_clks) - samsung_clk_register_fixed_factor(ctx, info->fixed_factor_clks, - info->nr_fixed_factor_clks); - - samsung_clk_of_add_provider(dev->of_node, ctx); - pm_runtime_put_sync(dev); - - return 0; + return exynos_arm64_register_cmu_pm(pdev, false); } static const struct of_device_id exynos5433_cmu_of_match[] = { @@ -5679,7 +5528,7 @@ static const struct of_device_id exynos5433_cmu_of_match[] = { }; static const struct dev_pm_ops exynos5433_cmu_pm_ops = { - SET_RUNTIME_PM_OPS(exynos5433_cmu_suspend, exynos5433_cmu_resume, + SET_RUNTIME_PM_OPS(exynos_arm64_cmu_suspend, exynos_arm64_cmu_resume, NULL) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)