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: 13560764 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 43429C48260 for ; Fri, 16 Feb 2024 22:34:06 +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=OuRfKqRhIj2NmABgCp3lqma1OJtrttEgoJzUnTZExbw=; b=C8c2oPKZI2iKO0 mwm8IfZIj3LsgcvyskJQaBKvxBU1hhCqseKCkcnO2YyePVey03SlmXMflc283/PLBhaSXgKGqT7LV fDENzaCSqAsu64eycevq36YttUhLBc4ufHE5CnpJ38LFIoWdDNcwkLMBmt/7uyoRPnayca+l+awPQ gpzeDbjXX+pGFDq5BX00IOXlwL8yrtOXJmM3n/3i3Ina16KgCrPKlQEMNiZdR1BRV8UdNGGKyOjk3 7HAssgWT8B4SIJ6bbb2wVuBhbeMUzuXFesq1YjzzOatfxb9gJ+0nbEkpmsG6AlLnTVMvEOLyNsPvV CPU87aAegf/QYIoOM0UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb6mK-00000003wIy-3qYL; Fri, 16 Feb 2024 22:33:56 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb6lM-00000003vdh-0xBX for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 22:32:58 +0000 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6e2e6bcc115so1275600a34.3 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=1708122774; x=1708727574; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BSXQtp/xYos/De5K15KnT8HtuCXV3FX1KoFk0gl8ZIY=; b=og/3xSGNu3lxytce+LhZJXXUqMA3dzjar6vkhrtHBI0XYQzRj5MUgro2qHyMMEzTFc 44zDCZyuEc9/LSFBKQ95qjvETe74Sg1VFYNm6XYTUTETtlaB7Pae+6YboW8reE/M+vHD kEsEUHAoucjfnJ0mV/qIOTrZYirE403Kz33wRQDhkaoujw3jK+PSxDd+V0ppsaLXqIWx NvPP6DaLAYsNCXbKMg70JXmo5p5tRRCk0dt85ymjiGaundvfEiR2QR9vlXXDH2ECu8/I lDEUGEA+StS5gXJ0swaXg8MwX8VUzC2BzeWQklvLR6tzk5ipap2PmxAM68d5IpNzB8j+ D++g== 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=wfZftOPhjY2eRK85CpDvmTTeZ9vgxCGG2r20PzjZNm0mYz69F3sXml9ouUFWSh9OpH yM38XMiqrrmjy35T1S4FhNmGqFVd70W1LqSyPq03mgHekT8jQ5bGgtU00pimhC30I3R8 8HJhH7UVWBcB0qWCceT58nIraHKiriIWyZEcJTGwm/7Y1ljMb1Opl+4ilS+nfTbkDYNQ T9k0kv2//I06MIyzz9fScbQvfKOWpp32/IanLy1plOB4DE2mi8+bb85mhCRTkIg3llLA JxxU89fwBjZbSUVR0AohFIwPvey49nV+yYk0C3Ph2TOcgB6jI2Fb8S+BU60vIVCvpJMm ON2Q== X-Forwarded-Encrypted: i=1; AJvYcCXfz0IoRyja7ywHxF/vp98a9WV7cVhmxEjm7fqwEvoh/UuVU8HIISdFi2t+XJdMPazxUFxwNUvt2k14WWbhU24KlcyUfJAJ7Vy8B0PZk+UXPsl1uF4= X-Gm-Message-State: AOJu0YzKir27y18s6NcwT6aoM1TW86boVjgHIo9QRUpxfRpIdmqAXTxd EMsiXhVUqlOdBIZKaZGrqVzUVnLqmAe3uKk20VgZ6iUEhm6SQU4C3Ma6YBfejTI= X-Google-Smtp-Source: AGHT+IF80c+KUyEOcpIptb5o8+krEJ6RGLdrgifsX5usLDGRORjlnGWJbpx/niTC9m5iauYccvVvKQ== 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240216_143256_310581_24968F35 X-CRM114-Status: GOOD ( 17.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Keep chip specific data in the data structure, don't mix it with code. It makes it easier to add more chip specific data further. 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) {