From patchwork Wed Dec 13 03:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 753502 Delivered-To: patch@linaro.org Received: by 2002:adf:e406:0:b0:336:3749:476e with SMTP id g6csp240434wrm; Tue, 12 Dec 2023 19:18:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IExyMRYEiLri/+O1xwciXepp3L4crXsTVNjPTURZUEkxDwz4e/0yWG9PYIvb2yhMs0nas/H X-Received: by 2002:a2e:9dc8:0:b0:2ca:5d4:c174 with SMTP id x8-20020a2e9dc8000000b002ca05d4c174mr4897438ljj.4.1702437492262; Tue, 12 Dec 2023 19:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702437492; cv=none; d=google.com; s=arc-20160816; b=VC1B4jDBOgIZ8N6/1orpz5kTCBSodvW0JGDD+eKqO6eM79ycxOSmG3v6nwuuNqsPM8 P77GueW1L1I1WWASkPHAD/YX6DfqpzosZ1xOk8IEowE6o9jnQ9T4RrWwzufMxJJ2exCu UQdxoB5XYs09Fev8QniRVINqqAvrZmTd2wldsoeKuOQQYLiCHmq4JZRjE3SWh74sHdQF nCJcXOnYHz4zkIXDclgt+wdt14wUCc869/2S9o1snM5/ge7KmHG4LV6TPRoyRW2NcWZQ GPlN1YwmlA9nRpPAGTmSiut0AqxItfplRAlhI6L9fF8c1GnpYFbSVLZujhjXSok4nzTj +79g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OoASDofddKjMTsJrIPH1yXA9e/CL/xYJR32TzdjQmHo=; fh=i3GCrODwsJq1Muv9k3S5+Rfq06zGsCgdpsCPDR990YA=; b=AwSx7AtJGvGcILbgatI5UNuT7tlw+ndl6wrgWHgEaQGG99FM8kafWvojJjdD02tDR7 8AC3xyYjTUs9dSxRsNHlJy0fcbFbVM9SOa9DvZmMcEyXCjp8MJqS25z8yJLA3lTW1RFN anyIW+nQ8KQoJgqaX2m4UapvninSnEug95ZIliBxtqUY55lAa8e6vhNxM5+qGeFm36vU ENu2ikRhia1qW+qm5pNkHO+1lBc+CoPEg2LTtBJLx8ISYLP3k1oenwYIPEQ7F8jyiXqC MtbkD3NahgFk7+AT21k1A2aW9TuulKC0UVQarol8HLjotz/hw8nDtwdlAZj23t2KM9H0 Dt9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kzDaPESY; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id o12-20020a2e9b4c000000b002ca107ec17esi3359586ljj.543.2023.12.12.19.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 19:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kzDaPESY; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D2CD787815; Wed, 13 Dec 2023 04:17:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kzDaPESY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B75BB87813; Wed, 13 Dec 2023 04:17:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 35BB98749E for ; Wed, 13 Dec 2023 04:16:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3ba00fe4e94so2762423b6e.1 for ; Tue, 12 Dec 2023 19:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702437413; x=1703042213; darn=lists.denx.de; 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=OoASDofddKjMTsJrIPH1yXA9e/CL/xYJR32TzdjQmHo=; b=kzDaPESYR3uLadMuFzpW1Kl6A9C3jrwomjUpfE9afyeykdcQR1T40c0NRWORvtDWeo StDr8GgMF0I/07RrQWwuxqdsUTa+0y051RRHhmp5BnJSUOqm2Gpg/tuosbFt/q3blmc/ nLf0VDBMQxP9ynr75EekLuruEZ2CAykjkfCQU8682VSr86VUfXMIMKHlEfoSy2JT1DP7 v6X8yTOe1Uf6fqGtHKgfQzeNKb9zgGcYHtRJBtAb6/tg90A8EBnchg/lPiftU6OlEcg6 d9KixMaSf/C3GHOOnvsjUIQVvLOLg6Tr9HLsEs029wJyMw2LsmyH+jKaeMZpgdIwv/8Z aQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702437413; x=1703042213; 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=OoASDofddKjMTsJrIPH1yXA9e/CL/xYJR32TzdjQmHo=; b=jRZoB58kWTBl3vygDfKFavDVvW6X+1/jLEu+99Dtn/BoNWK4o2NSEGzFcZVHQzRaDt kwbJWedSHRayp6FqO5BIE9KuBSbP819dy31V/4pz+qbFDL2/mKPs+NOgM2YHVf5hynFP haxqd15CYHe7P8HnSr46QbLNS0w/KMhlouRr9rH4GFyW77WpmpO92uaWJfYK0mNREXW2 1bpdXwklkwTUmPtCFruCmD0OwmLVPMkR7eHLoHTJhoaK7vdzZpbZ+iEeALUtOlYa9osU LF8N68e6EbGcEfLr+B3iZu/zll2tTKdbrRMvTYCTyFw999djt5X1xm4DY0mgsXeeCMMb x2Kw== X-Gm-Message-State: AOJu0YxjoqiswH+XByanGG+CulwlM0eMxu+KJwJkAKvhUPoDpkp7peFH ZUTm3o4k0HiBeINgypjx64ZMfg== X-Received: by 2002:a05:6808:1290:b0:3b8:9b7f:40e8 with SMTP id a16-20020a056808129000b003b89b7f40e8mr9741875oiw.17.1702437412828; Tue, 12 Dec 2023 19:16:52 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id a23-20020a056808099700b003b9f6ecb222sm2242503oic.6.2023.12.12.19.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 19:16:52 -0800 (PST) From: Sam Protsenko To: Minkyu Kang , Tom Rini , Lukasz Majewski , Sean Anderson Cc: Simon Glass , Heinrich Schuchardt , u-boot@lists.denx.de Subject: [PATCH 06/13] clk: exynos: Move pll code into clk-exynos7420 Date: Tue, 12 Dec 2023 21:16:39 -0600 Message-Id: <20231213031646.28828-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231213031646.28828-1-semen.protsenko@linaro.org> References: <20231213031646.28828-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean PLL utilities code is only used by clk-exynos7420 driver at the moment. Move it into clk-exynos7420 to make clk-pll.c file available for CCF PLL clocks implementation, which is coming in the next patches. Signed-off-by: Sam Protsenko Reviewed-by: Chanho Park --- drivers/clk/exynos/Makefile | 1 - drivers/clk/exynos/clk-exynos7420.c | 25 +++++++++++++++++++++- drivers/clk/exynos/clk-pll.c | 32 ----------------------------- drivers/clk/exynos/clk-pll.h | 13 ------------ 4 files changed, 24 insertions(+), 47 deletions(-) delete mode 100644 drivers/clk/exynos/clk-pll.c delete mode 100644 drivers/clk/exynos/clk-pll.h diff --git a/drivers/clk/exynos/Makefile b/drivers/clk/exynos/Makefile index c9f29c873e9b..7faf238571ef 100644 --- a/drivers/clk/exynos/Makefile +++ b/drivers/clk/exynos/Makefile @@ -3,5 +3,4 @@ # Copyright (C) 2016 Samsung Electronics # Thomas Abraham -obj-y += clk-pll.o obj-$(CONFIG_CLK_EXYNOS7420) += clk-exynos7420.o diff --git a/drivers/clk/exynos/clk-exynos7420.c b/drivers/clk/exynos/clk-exynos7420.c index 7d869eb02b8e..9caa932e12fb 100644 --- a/drivers/clk/exynos/clk-exynos7420.c +++ b/drivers/clk/exynos/clk-exynos7420.c @@ -10,8 +10,15 @@ #include #include #include +#include #include -#include "clk-pll.h" + +#define PLL145X_MDIV_SHIFT 16 +#define PLL145X_MDIV_MASK 0x3ff +#define PLL145X_PDIV_SHIFT 8 +#define PLL145X_PDIV_MASK 0x3f +#define PLL145X_SDIV_SHIFT 0 +#define PLL145X_SDIV_MASK 0x7 #define DIVIDER(reg, shift, mask) \ (((readl(reg) >> shift) & mask) + 1) @@ -64,6 +71,22 @@ struct exynos7420_clk_top0_priv { unsigned long sclk_uart2; }; +static unsigned long pll145x_get_rate(unsigned int *con1, + unsigned long fin_freq) +{ + unsigned long pll_con1 = readl(con1); + unsigned long mdiv, sdiv, pdiv; + u64 fvco = fin_freq; + + mdiv = (pll_con1 >> PLL145X_MDIV_SHIFT) & PLL145X_MDIV_MASK; + pdiv = (pll_con1 >> PLL145X_PDIV_SHIFT) & PLL145X_PDIV_MASK; + sdiv = (pll_con1 >> PLL145X_SDIV_SHIFT) & PLL145X_SDIV_MASK; + + fvco *= mdiv; + do_div(fvco, (pdiv << sdiv)); + return (unsigned long)fvco; +} + static ulong exynos7420_topc_get_rate(struct clk *clk) { struct exynos7420_clk_topc_priv *priv = dev_get_priv(clk->dev); diff --git a/drivers/clk/exynos/clk-pll.c b/drivers/clk/exynos/clk-pll.c deleted file mode 100644 index 407fc71d415b..000000000000 --- a/drivers/clk/exynos/clk-pll.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Exynos PLL helper functions for clock drivers. - * Copyright (C) 2016 Samsung Electronics - * Thomas Abraham - */ - -#include -#include -#include - -#define PLL145X_MDIV_SHIFT 16 -#define PLL145X_MDIV_MASK 0x3ff -#define PLL145X_PDIV_SHIFT 8 -#define PLL145X_PDIV_MASK 0x3f -#define PLL145X_SDIV_SHIFT 0 -#define PLL145X_SDIV_MASK 0x7 - -unsigned long pll145x_get_rate(unsigned int *con1, unsigned long fin_freq) -{ - unsigned long pll_con1 = readl(con1); - unsigned long mdiv, sdiv, pdiv; - uint64_t fvco = fin_freq; - - mdiv = (pll_con1 >> PLL145X_MDIV_SHIFT) & PLL145X_MDIV_MASK; - pdiv = (pll_con1 >> PLL145X_PDIV_SHIFT) & PLL145X_PDIV_MASK; - sdiv = (pll_con1 >> PLL145X_SDIV_SHIFT) & PLL145X_SDIV_MASK; - - fvco *= mdiv; - do_div(fvco, (pdiv << sdiv)); - return (unsigned long)fvco; -} diff --git a/drivers/clk/exynos/clk-pll.h b/drivers/clk/exynos/clk-pll.h deleted file mode 100644 index 7b7af5e67612..000000000000 --- a/drivers/clk/exynos/clk-pll.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Exynos PLL helper functions for clock drivers. - * Copyright (C) 2016 Samsung Electronics - * Thomas Abraham - */ - -#ifndef __EXYNOS_CLK_PLL_H -#define __EXYNOS_CLK_PLL_H - -unsigned long pll145x_get_rate(unsigned int *con1, unsigned long fin_freq); - -#endif /* __EXYNOS_CLK_PLL_H */