Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp292108pxb; Wed, 15 Sep 2021 02:05:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2c2b/HIk8L6FQYGk5PiKwR04ENfk3Vj1q9lYQM3SRMQWi6BQ9rGVjsoTIGDgK5+vz2qeV X-Received: by 2002:a05:651c:553:: with SMTP id q19mr19097951ljp.320.1631696710559; Wed, 15 Sep 2021 02:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631696710; cv=none; d=google.com; s=arc-20160816; b=wjkqSqhcCLlR2J48XVJJJmpMvRkL3X+c4LqFvpwDGzPt+mX9SlXfRnHZ632HgTN9Hj zvyZjc42UOhu850dcA2LGblZVcC9WbUDk93pYsKWFxkzwb7PNXv7o1k3BwKMXIojfwdK 6A2LAKTpG0iEsVjD+yFMsQhdSmM2zoTZUB5IaSDnTAbz6D/TGTEi3UDA1dio3EJDgLOG OW5E8evbDAYoT7p/bRnW0kuJugwceTGoOWEgZb33IceezWBTPCpa522fRvpjRf7bby4L SYE+sbjoj81YZS84qE5lCEnz5Ge4elhXiuGSgDePTEuIiuivVkAqM6CXCZ5c5BwHReLD ny9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=39NyD7eSdjWRLG7akJoaBQq2vkbMMaThM/SwbRfMg/Y=; b=mBZblVbLfPT2K7YVjqK1W78knAz4RbgmFONFqZta/NtzyLQ73ezXS0jvg6jA/aKybR 3DFq2p/7PVeSVpDpEyu1/k4TVRZzuVutsVfzlgTq7XJlel2kGELhhdUJezJVy58Ub911 FuHLGF+TwgFRHA2LnZJ4hxZ3bUZavIiFHT3S0OFA6csVek8b1lIQ+CEo02Y02FDXY2dd PPobei5ny3TW0W19qyd2l6ZcPRhjEaQLb8MVYVZWtvyT0ItQC6lBf7ZIjPwHfBLhwJL6 9j+LxZfXjWAp23OHwG6FgUF35xZ1aYsvR1dxww6ll7EbijXJlxmpi2Cjx5IVxmE9pT8s 0kIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=DMiwzSqY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si16337387lfn.155.2021.09.15.02.04.39; Wed, 15 Sep 2021 02:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=DMiwzSqY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237141AbhIOJBA (ORCPT + 99 others); Wed, 15 Sep 2021 05:01:00 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:54294 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237160AbhIOJAy (ORCPT ); Wed, 15 Sep 2021 05:00:54 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 584134017C for ; Wed, 15 Sep 2021 08:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631696368; bh=39NyD7eSdjWRLG7akJoaBQq2vkbMMaThM/SwbRfMg/Y=; h=To:Cc:References:From:Subject:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=DMiwzSqYW3AUg3oJEXVZANFWDVp5furaICTstN6E6aPxWTXiynPcTRYl+PlGbzCFl 1u3fluTHY/KZlAN+pBly5G9jQ1Jn18g7jdC+Lo4NHhqAcay7AF17xnsP7+7QRWyIXS 0Xi4aQ2MXD0qPp4SeQCkYWznJq1+oA3x/R0tGas8MxsUM+98sieIXijXYCZJ3/Q+my aK/RvX1ZgETnxy8VVo1PESmp9N8S7Zg4MDCiOyWannL8P7RlbzspNaE5OPOBJq20B+ sO3QRWI/lqTIRQ+l6KkF1mi9aaEcvuwppF4e3jCpPrukF2ir5dw1ce/6h6N+96mnMT L0ItJ4P5xw+3Q== Received: by mail-ej1-f72.google.com with SMTP id p24-20020a17090635d800b005f264e9cb99so1156432ejb.4 for ; Wed, 15 Sep 2021 01:59:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=39NyD7eSdjWRLG7akJoaBQq2vkbMMaThM/SwbRfMg/Y=; b=D7Q2VK+iwoYflyEQizf6KvyK8c05EcibCb/OrHXcB4Iq5Kd38SZPtCle0Em/KnvUtb crGXJ7QrFRzbWJLHcowws8IVq4hvLAZ6RQ3NTRi9jQsX63r6eitKMOOtazyjMTtMjTYd /ifzzb+2GF3NaT8yUvuA0oUwOOb3JVHsvXPYT1lZn1Smy3fFgD6VP7ehwnXkbuilZL03 hVwdZp3qVW+4Tx3iVcEq/9fHQpDvVAs7Q01fLqnz6Giu0/jryQSbLBglVTlvIi0ER+jV QXIlDVGaKhGJlZFwhAEKv3giVstM40pCymQy6twVlALMSCcHIbwCAUpFte+2i3tExIPJ 3YIQ== X-Gm-Message-State: AOAM530XTpy3bRGu4DRaWVDj/gxolssW0JgOlKW6brpx/HeIQrj83a/X nXIgk13iyF6+E3CUV7qbAvwpgN8HaaAeW3LGkDgREFaC+3vrNP62T4KCMuQ6LasEAVrXtlvCD4Q QTOZRR6GIxQEk4ChjJAGrjnFx6F7pYv1K3T4kSZ/HJg== X-Received: by 2002:a17:906:f15:: with SMTP id z21mr23428833eji.177.1631696368016; Wed, 15 Sep 2021 01:59:28 -0700 (PDT) X-Received: by 2002:a17:906:f15:: with SMTP id z21mr23428808eji.177.1631696367855; Wed, 15 Sep 2021 01:59:27 -0700 (PDT) Received: from [192.168.3.211] (lk.84.20.244.219.dc.cable.static.lj-kabel.net. [84.20.244.219]) by smtp.gmail.com with ESMTPSA id f24sm6703253edc.40.2021.09.15.01.59.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Sep 2021 01:59:27 -0700 (PDT) To: Sam Protsenko , Sylwester Nawrocki , =?UTF-8?Q?Pawe=c5=82_Chmiel?= , Chanwoo Choi , Tomasz Figa , Rob Herring , Stephen Boyd , Michael Turquette Cc: Ryu Euiyoul , Tom Gall , Sumit Semwal , John Stultz , Amit Pundir , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org References: <20210914155607.14122-1-semen.protsenko@linaro.org> <20210914155607.14122-7-semen.protsenko@linaro.org> From: Krzysztof Kozlowski Subject: Re: [PATCH 6/6] clk: samsung: Introduce Exynos850 clock driver Message-ID: <3da75dbe-2f98-39db-c455-46adead7097b@canonical.com> Date: Wed, 15 Sep 2021 10:59:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210914155607.14122-7-semen.protsenko@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/09/2021 17:56, Sam Protsenko wrote: > This is the initial implementation adding only basic clocks like UART, > MMC, I2C and corresponding parent clocks. Design is influenced by > Exynos7 and Exynos5433 clock drivers. > > Signed-off-by: Sam Protsenko > --- > drivers/clk/samsung/Makefile | 1 + > drivers/clk/samsung/clk-exynos850.c | 700 ++++++++++++++++++++++++++++ > 2 files changed, 701 insertions(+) > create mode 100644 drivers/clk/samsung/clk-exynos850.c > > diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile > index 028b2e27a37e..c46cf11e4d0b 100644 > --- a/drivers/clk/samsung/Makefile > +++ b/drivers/clk/samsung/Makefile > @@ -17,6 +17,7 @@ obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos5433.o > obj-$(CONFIG_EXYNOS_AUDSS_CLK_CON) += clk-exynos-audss.o > obj-$(CONFIG_EXYNOS_CLKOUT) += clk-exynos-clkout.o > obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos7.o > +obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos850.o > obj-$(CONFIG_S3C2410_COMMON_CLK)+= clk-s3c2410.o > obj-$(CONFIG_S3C2410_COMMON_DCLK)+= clk-s3c2410-dclk.o > obj-$(CONFIG_S3C2412_COMMON_CLK)+= clk-s3c2412.o > diff --git a/drivers/clk/samsung/clk-exynos850.c b/drivers/clk/samsung/clk-exynos850.c > new file mode 100644 > index 000000000000..1028caa2102e > --- /dev/null > +++ b/drivers/clk/samsung/clk-exynos850.c > @@ -0,0 +1,700 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2021 Linaro Ltd. > + * Author: Sam Protsenko > + * > + * Common Clock Framework support for Exynos850 SoC. > + */ > + > +#include > +#include > +#include > + > +#include > + > +#include "clk.h" > + > +/* Gate register bits */ > +#define GATE_MANUAL BIT(20) > +#define GATE_ENABLE_HWACG BIT(28) > + > +/* Gate register offsets range */ > +#define GATE_OFF_START 0x2000 > +#define GATE_OFF_END 0x2fff > + > +/** > + * exynos850_init_clocks - Set clocks initial configuration > + * @np: CMU device tree node with "reg" property (CMU addr) > + * @reg_offs: Register offsets array for clocks to init > + * @reg_offs_len: Number of register offsets in reg_offs array > + * > + * Set manual control mode for all gate clocks. > + */ > +static void __init exynos850_init_clocks(struct device_node *np, > + const unsigned long *reg_offs, size_t reg_offs_len) > +{ > + const __be32 *regaddr_p; > + u64 regaddr; > + u32 base; > + size_t i; > + > + /* Get the base address ("reg" property in dts) */ > + regaddr_p = of_get_address(np, 0, NULL, NULL); > + if (!regaddr_p) > + panic("%s: failed to get reg regaddr\n", __func__); > + > + regaddr = of_translate_address(np, regaddr_p); > + if (regaddr == OF_BAD_ADDR || !regaddr) > + panic("%s: bad reg regaddr\n", __func__); > + > + base = (u32)regaddr; > + > + for (i = 0; i < reg_offs_len; ++i) { > + void __iomem *reg; > + u32 val; > + > + /* Modify only gate clock registers */ > + if (reg_offs[i] < GATE_OFF_START || reg_offs[i] > GATE_OFF_END) > + continue; > + > + reg = ioremap(base + reg_offs[i], 4); You first translate the address to CPU physical address and then apply offset. This should be equivalent to one of_iomap() of entire range and iterate starting from the base pointer. IOW, I don't get why you have to map each register instead of mapping entire SFR/IO range? > + val = ioread32(reg); > + val |= GATE_MANUAL; > + val &= ~GATE_ENABLE_HWACG; > + iowrite32(val, reg); All other drivers use readl/writel, so how about keeping it consistent? Rest looks good but I did not verify the numbers :) Best regards, Krzysztof