Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1038558rwb; Fri, 28 Jul 2023 03:57:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlFU63T6Wnkz7lpgUEnYV7dFAyKsVqZo9EAG+pjtGkDjHjCwtUWMO5OByCr36YoEyZmrx9f0 X-Received: by 2002:a17:906:5d05:b0:98d:abd4:4000 with SMTP id g5-20020a1709065d0500b0098dabd44000mr5199542ejt.35.1690541859478; Fri, 28 Jul 2023 03:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690541859; cv=none; d=google.com; s=arc-20160816; b=Td+P9qTuFDzyyyV4K4GgT0qMb9zLmzCut2ddPw9LvSL0HtIvwnqCQxAqhSzRCyDRNW qchgWHkSq9Ju2L7Kj+/vVzsOJPIfgpC/CipseqsgrAHiHtSteXOvTAM98PwUAucIJ9z8 H5+fcX9AmQiZBSp8oBvajs7Dh2mXqmVBsSNN5xZhFiqw4Cip7ylPpusGjSYBvA4m51wj awEEEnj0dMGbZ6kRDmNk8qidwb5Nu9Gdr1ZQX2sbeRZ8AKUCYz6qCrfAZ8nRjquI4Gea Zip8EX7bxLUgQW3zyJxf7jtuMeSp3I7t9nScAxPCKVapROLYcrqmWn6yfqR/M2xJucvm I55Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=kfkWHmDH2ccixlU5fQHp7hs28wJxcr4ROkouneX9pAw=; fh=v+1g9mN+9S/UqVRA4XgevCgJzKSrWtUvl0aPJHLGya4=; b=spDboIYWpMGmimepJDwSUNm7Kai3JOj1QEIaUGIJ7z8YGlwo44iyupCQTBAu28DcOA NrzX8drTbFUGNM66IJo0ks7YQSzCbkaWVrQIlG5WeYOV7elC76X1A1QU4OMBL4KfGN7q EXChFmiVc1Kon4q4gb4ijLZlTBKZQeBJ079cE1/klYwQsmha9xC9p80xrvSeSGPLmu4B wS1qnfOU9tClT4FaBkiRIn0p6icFH9yDJveWvYI2ncXdWaLvdPtxLIr7mufGFJxnv4qD 6ot1OqF7yd+xsBj+V2Td4EB3sA/ejGF/MuchJbH+3kx4VS+BJ8k/o1NyEsA2ztaUtp8G /AgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=cdU6ggMj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a17090634d300b009935d9765fasi2485599ejb.1013.2023.07.28.03.57.13; Fri, 28 Jul 2023 03:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=cdU6ggMj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235953AbjG1Kcy (ORCPT + 99 others); Fri, 28 Jul 2023 06:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235750AbjG1Kcb (ORCPT ); Fri, 28 Jul 2023 06:32:31 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472964C3B; Fri, 28 Jul 2023 03:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1690540241; x=1722076241; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=yupO65VLUPyZffIc75hdCj1FpXzK+t+KpMhOK2JtQgw=; b=cdU6ggMjXr/GQGy9QyTeGAyJTm8uRQuQoQANpXSh1w8rcAvpabATIWAz Oek3E1jAOgZUz8nuVrjDkdZQLn/4ns/7aGLe6Fr8F6jylpG7xcf9c1hMw ClCReYCQ/TLla80zjR2hpnYTT9Xz7E+jtYeKfBbf431mZQ9Df2a5qflwv rCiXyLjNUoICYVI5V8WrZTNT6dYOKCesBkx5MMqGXmfELF6cH76nB6o6p 9yJHr89H4t5ZgUX+mMbzvSeS0Fmxz7cCZFmH3oZow5P32blp4SXV5GoUL t/JWSnz7lZOFAL7MGK3JfL81xGnAzvom1Uxqq6UYtL6IqFb0QtyIoMqMK g==; X-IronPort-AV: E=Sophos;i="6.01,237,1684825200"; d="scan'208";a="238401737" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jul 2023 03:29:28 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 28 Jul 2023 03:29:27 -0700 Received: from che-lt-i67070.amer.actel.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 28 Jul 2023 03:29:23 -0700 From: Varshini Rajendran To: , , , , , , , , , Subject: [PATCH v3 37/50] clk: at91: clk-sam9x60-pll: re-factor to support individual core freq outputs Date: Fri, 28 Jul 2023 15:59:19 +0530 Message-ID: <20230728102919.267179-1-varshini.rajendran@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SAM9X7 SoC family supports different core output frequencies for different PLL IDs. To handle the same in the PLL driver, a separate parameter core_output is added. The sam9x60 and sama7g5 SoC PMC drivers are aligned to the PLL driver by adding the core output freq range in the PLL characteristics configurations. Signed-off-by: Varshini Rajendran --- drivers/clk/at91/clk-sam9x60-pll.c | 12 ++++++------ drivers/clk/at91/pmc.h | 1 + drivers/clk/at91/sam9x60.c | 7 +++++++ drivers/clk/at91/sama7g5.c | 7 +++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/clk/at91/clk-sam9x60-pll.c b/drivers/clk/at91/clk-sam9x60-pll.c index ff65f7b916f0..b0314dfd7393 100644 --- a/drivers/clk/at91/clk-sam9x60-pll.c +++ b/drivers/clk/at91/clk-sam9x60-pll.c @@ -23,9 +23,6 @@ #define UPLL_DIV 2 #define PLL_MUL_MAX (FIELD_GET(PMC_PLL_CTRL1_MUL_MSK, UINT_MAX) + 1) -#define FCORE_MIN (600000000) -#define FCORE_MAX (1200000000) - #define PLL_MAX_ID 7 struct sam9x60_pll_core { @@ -194,7 +191,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core, unsigned long nmul = 0; unsigned long nfrac = 0; - if (rate < FCORE_MIN || rate > FCORE_MAX) + if (rate < core->characteristics->core_output[0].min || + rate > core->characteristics->core_output[0].max) return -ERANGE; /* @@ -214,7 +212,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core, } /* Check if resulted rate is a valid. */ - if (tmprate < FCORE_MIN || tmprate > FCORE_MAX) + if (tmprate < core->characteristics->core_output[0].min || + tmprate > core->characteristics->core_output[0].max) return -ERANGE; if (update) { @@ -669,7 +668,8 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock, goto free; } - ret = sam9x60_frac_pll_compute_mul_frac(&frac->core, FCORE_MIN, + ret = sam9x60_frac_pll_compute_mul_frac(&frac->core, + characteristics->core_output[0].min, parent_rate, true); if (ret < 0) { hw = ERR_PTR(ret); diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 0f52e80bcd49..bb9da35198d9 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -75,6 +75,7 @@ struct clk_pll_characteristics { struct clk_range input; int num_output; const struct clk_range *output; + const struct clk_range *core_output; u16 *icpll; u8 *out; u8 upll : 1; diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c index e309cbf3cb9a..db6db9e2073e 100644 --- a/drivers/clk/at91/sam9x60.c +++ b/drivers/clk/at91/sam9x60.c @@ -26,10 +26,16 @@ static const struct clk_range plla_outputs[] = { { .min = 2343750, .max = 1200000000 }, }; +/* Fractional PLL core output range. */ +static const struct clk_range core_outputs[] = { + { .min = 600000000, .max = 1200000000 }, +}; + static const struct clk_pll_characteristics plla_characteristics = { .input = { .min = 12000000, .max = 48000000 }, .num_output = ARRAY_SIZE(plla_outputs), .output = plla_outputs, + .core_output = core_outputs, }; static const struct clk_range upll_outputs[] = { @@ -40,6 +46,7 @@ static const struct clk_pll_characteristics upll_characteristics = { .input = { .min = 12000000, .max = 48000000 }, .num_output = ARRAY_SIZE(upll_outputs), .output = upll_outputs, + .core_output = core_outputs, .upll = true, }; diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index 91b5c6f14819..e6eb5afba93d 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -116,11 +116,17 @@ static const struct clk_range pll_outputs[] = { { .min = 2343750, .max = 1200000000 }, }; +/* Fractional PLL core output range. */ +static const struct clk_range core_outputs[] = { + { .min = 600000000, .max = 1200000000 }, +}; + /* CPU PLL characteristics. */ static const struct clk_pll_characteristics cpu_pll_characteristics = { .input = { .min = 12000000, .max = 50000000 }, .num_output = ARRAY_SIZE(cpu_pll_outputs), .output = cpu_pll_outputs, + .core_output = core_outputs, }; /* PLL characteristics. */ @@ -128,6 +134,7 @@ static const struct clk_pll_characteristics pll_characteristics = { .input = { .min = 12000000, .max = 50000000 }, .num_output = ARRAY_SIZE(pll_outputs), .output = pll_outputs, + .core_output = core_outputs, }; /* -- 2.25.1