Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp555141rbb; Sat, 24 Feb 2024 12:23:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXO8MgoGKaHW0dwiDk+QRVOukL9VOpiGu8c5zS618ZPgcWtC3BXDHLS30ht+CM7nwlALGBcXK81nJgWAROA85UYYBB1RABHbYDKFQ62qA== X-Google-Smtp-Source: AGHT+IHFsUNHFH6Evd9rpfaCM9QBzZ3MZ1dDaJnpcNXetuSUnYgX7s2WudtFn6xn8OZIuDIMDHmg X-Received: by 2002:a05:6a21:3514:b0:19e:cd14:1f8d with SMTP id zc20-20020a056a21351400b0019ecd141f8dmr2925080pzb.35.1708806182375; Sat, 24 Feb 2024 12:23:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708806182; cv=pass; d=google.com; s=arc-20160816; b=s8Z1KBcY3ZpeTodibXcetR/0unq0SaA4unKqwdg4X1qV2OjkkCrbkHzLjzLnk9FzX+ 8hsqBKIWJhMGiLQ/B+g33miRUL0kS3Yo0ZNa3wE/8oyRiIXDg0QRGLKB+x0EU9wJiDww /DgKxtxt6nU1blrulF1S/9YbOntDmYcDWLAGRPhk0/VGVYskWe/gWv1frw8OtMk5XB8R LBPViQBh2I3c5sNsd2itxgWoNTJmkP/gYuZoFGomiuJqF8lkQrVScTwTNe/dt2slZ81n +il/z1JleHlSnGSxVi5+BJquancbPnOtOnVbAIj5MGUMYYu23gHe5i5uhBy3OQuIFn3f fHEg== 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=KTnWrXz3JStivRTMwgchBq3jLcy8rn1qjS1DxI64urA=; fh=mR/jfRQbIE4UwGgcjXMgf/a1EPmG9oLJD+bpzsTo2MI=; b=xPww5J6UXlavK3lLqYpEJRhx8o7svaQpTCaBPE1VDIQyVlsitwdI+cf0K1ZBpXECHb lGCCLL0kStyNhFMBHLSTQwKYpGUnildUqbOwTZH4f/syo2A0EUGKX0kr6zVJ0JKjrDQ+ Wj/9r942zqFfOMdQO9oYG+V+q3xJ8+luzUz4arQpujvgVTCo1gZClE4/Yl+ZT0M20/ym WQLqtKmFraofeyyVUiqH1/HPEWwDu6F0fSrWXjNfmVz+eXTMEKdUZQy3B6DysW5KWobQ xkUAAUSW6vmV1wE3KPXmd/NqGAChM5bqio7jzktVwk4FjZ5QctEAT0B6Dl32kQTNBlNt u3bw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SYiBpzcw; 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-79839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i7-20020a636d07000000b005dc82dde3b2si1298433pgc.793.2024.02.24.12.23.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 12:23:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79839-linux.lists.archive=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=SYiBpzcw; 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-79839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79839-linux.lists.archive=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 E01492821C0 for ; Sat, 24 Feb 2024 20:23:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9002852F75; Sat, 24 Feb 2024 20:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SYiBpzcw" Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 9EC404DA00 for ; Sat, 24 Feb 2024 20:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708806061; cv=none; b=rxLspSlnXiskdi5N89z45jvHIzieg2uNb3PV+qN6AyyoQYRnXsmnxa0JDwVs732IJNL8KJW4Phv0OeVbC02HiUJ2mIgW31OJnuR8J5F3jfRjJklQxisVX9gfGSfA0+RkPZV46d5hcVGtwK3XDDcKe1Pf041HHK/ZltPnWAt4Pzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708806061; c=relaxed/simple; bh=o9Zqm0zN7ru0KQhZAunuI4IVxeZK+2pqeaTp3HSRgQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o8RUA/r2SUGiFJ66C4YHbWEo+C1bnnyylqMsVHXqIiXvx4yiO2jnxTSb5Tpgs4O1xrKHhyNX3L2Kmh2Tgihmqv7aIbclbfA0ylmT9cHmQBIIUXXNQC4CT8VebwuBMi6hDPylWPngxnmgCzkU91bQ/cu0ZayXSb1wY9mOQ2xVA0I= 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=SYiBpzcw; arc=none smtp.client-ip=209.85.210.49 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-f49.google.com with SMTP id 46e09a7af769-6e2d83d2568so1539645a34.3 for ; Sat, 24 Feb 2024 12:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708806059; x=1709410859; 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=KTnWrXz3JStivRTMwgchBq3jLcy8rn1qjS1DxI64urA=; b=SYiBpzcw2NSf26w7gKLXqv+pu3VMQk0LlLKshUWDepSOcvTv0VLG0G90NOwWunuzrB EIf8z/+33zV8Sh5mNiIQxaz90kVFGAsdUOpLXqfonsUHJRXWR1HOKFmFWO9iUCISHLI0 tn8h+gFb8QIQOrK9kHP/Ldpge2xRmAQAOqTicRI3V7MirEPPImOC7JJDZUtlOdwpwKPq gvXszVmFKkWTP8e5gifP2rphylbdcf8q30wQfth+spdq1VQHJpPoaZsSsIGHLcdp4TDM 6e/19sP6GYrFyaqzqFYmuqcjG+eyk+YDXckQ9/PIVcHhj0W6PAXzQgCoXZKSG91+VSga D3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708806059; x=1709410859; 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=KTnWrXz3JStivRTMwgchBq3jLcy8rn1qjS1DxI64urA=; b=ZdcCjIq/pHcSG5fcaVKtUh1+sZyEf4eX9MbrYGNcYRi/JFh8nWyQolXH8XB9mYed0I oWMqg8zu2DhPfGvOiX6yID9nWgliI+kYMaoyakfa4FUQCPuHxCe9SDloPYi4GSeAbXQZ M54pIN+bPWjLIx+PgqeYkKV8Mb32tvuVAkf7tQhIub3YzrCbhopjp9JmrnIqxqGl96DY TuI8oxA94xmCjOgFVGNPbt5PhuWd2VRJbLq+AGaLLKeMXgfcKGjOtYBN6gkLmQaUAMwZ RRSq1UU2KtfNeGKbEJyxCLdx7mmBoR7T86Fy4P7Hi6QKMzSPRV98sDeB0bJUH3PDN+mO Hg/w== X-Forwarded-Encrypted: i=1; AJvYcCXebA+A/m/IMud2SVPJeYHuU344GfBpQfX2m2O9LD0+QAvhPTqFK5/YT26Lkti2Y0Np5HOAZmW76g9soBm8A/Nc27ql3F0kkZZbXfVp X-Gm-Message-State: AOJu0YxftCak6bbGfIUOlf0i1eauLMt3EgN271/biG26/W/rprfuxjrf Qs30Z/8d2mhW307ZxeOb1FPRMaoi/1L86xUKvoUxl+92715Xmc53jvBPsdxZwPOovxYWvMlsAf6 Qc9MZUg== X-Received: by 2002:a05:6870:2112:b0:21d:e28a:fb14 with SMTP id f18-20020a056870211200b0021de28afb14mr3709363oae.47.1708806058911; Sat, 24 Feb 2024 12:20:58 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id h16-20020a056808015000b003c178f6a504sm393647oie.14.2024.02.24.12.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 12:20: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 v3 06/15] clk: samsung: Group CPU clock functions by chip Date: Sat, 24 Feb 2024 14:20:44 -0600 Message-Id: <20240224202053.25313-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240224202053.25313-1-semen.protsenko@linaro.org> References: <20240224202053.25313-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 Content-Transfer-Encoding: 8bit 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 --- Changes in v3: - none Changes in v2: - none 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. -- 2.39.2