Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3050580ybi; Tue, 2 Jul 2019 01:09:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZd92Ucrj6wgntIh0gz4n0iDQQujiznsFXKdhwbSdqtliuhdNZC3YMCQpCRciuYOjDwTJt X-Received: by 2002:a17:90a:9f0b:: with SMTP id n11mr4038937pjp.98.1562054967219; Tue, 02 Jul 2019 01:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054967; cv=none; d=google.com; s=arc-20160816; b=u96zCZTnxor5DoFohlYJnjsFNb6nEebamAWtngF1LNvhH8mvHrh1erjeJfaw5WIlJ/ tKa/9TdZFxYUwvyh2rQBJfBzMN8y+uwY29BtbxrA87p033xZhL/Tut5cLjDvVL2jU/5Q nfIew/SpDS+oiSPB37W4af4wiUIaP4Ul1XsDTAm1gU7k+Lmy3VltR/pAZthFvQ0Wopzd 3iqwwbS+ORwZGqHX7Ye+36hVihMHcBqJ3pm9NPWb+wzuoUpYo/YrernQh/Fqji8P6iXZ MLtBWXarrlcXsMzdNuLnAL6ZB1j9F/3IPiiHHptpU0M3W7juWqefUARrBpfdUb1ZD6tA 1HiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=3Uf+doeO5VtjdYVajvd6K1kZS8kG10W1FFm+PhtOBRg=; b=RiN7KAJ6nya+9ae62hD4eC+wSKq/tJDDUEn0M7oy2/EpCxGLXIwx5GfN+mO3/a+wsX zk4Wj6N9FjEijNLxAvf2iLB3aftwqJmZwUPL8x2LvbcRbi2GK7nC1cTobzsuIyzIRJOk np66l4YO1Y8JiTlDqXrkA2ELiPPI0VHcxBBZjI9uq/ocybEKcKwwpmqSUKoIwufc0LbQ gfU5yQcnia+U9lPeIj6MIU67s4onbQhKmSTvlLavZzJaz1hAPky/PG9DQaBtxrAzjyC1 hW4WexsuYQ4bCLy0Qzd+WKN0IF6bwX02/FJmaQzZlC+Sn9h+PC7Rz/wGfTrjLwbtaYdU lxkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gnEFc1Yt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si11556088pgp.183.2019.07.02.01.09.12; Tue, 02 Jul 2019 01:09:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gnEFc1Yt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbfGBIGy (ORCPT + 99 others); Tue, 2 Jul 2019 04:06:54 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34847 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728154AbfGBIGt (ORCPT ); Tue, 2 Jul 2019 04:06:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id c27so8932297wrb.2 for ; Tue, 02 Jul 2019 01:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3Uf+doeO5VtjdYVajvd6K1kZS8kG10W1FFm+PhtOBRg=; b=gnEFc1YtN21E7WYDMG8pTDp6oCGt2jPIS3ZMtgDDYPm48OAHD2ZhMajQAsRwk7CZxn jeQkIjU08B/AJuKHubmRUTtoB+8uHgRe7y77cuVyKLvxf3/TqHxk+d3PBmV4NnFolUCL 2DQQ3Cs8sNv94OyZZvZ/Ey0mU4PzuiWEpZSfCBMlekkOWwUqKA+ul+wkVkq3x7GQUqiC pOaoLxusEfLn5Iuykn4MUmhC6VjYwcWXxWRaQy3p/hFF0yqOh6RVrwmkSZ6mWNFv84iu zpIaBynXnOMnLlomqNpm4zauTeorutV8cx5VwaoyyoOVB847Cv8l2irNdaOol4pMGqzr GrBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=3Uf+doeO5VtjdYVajvd6K1kZS8kG10W1FFm+PhtOBRg=; b=fDGH/tWoZ96DW1ChAZYwhTry8tPxHAdeh/yFuV2K0yg7Yk0K7Twi4Bxf/5Pb+o13Oh wc3kiGR90OGHhKL1Sn/UJHLmKCukTpFlqVfTPmiSvkBpAqVxzYw/liPxkvLgKY2kIxoR KfDquxeUMsSBVo8teL9PwH1PLveEci5bimORd6ckK+cf56smys74FytIcEbrnYKuoOWV zztu8i3Hq5ASjpW1hD8dKcnLjuX9qZkW9qeZvbKWVcGXFFl1MRrOPIX1vzOV+wga1AI+ ejD0jJvdPmUHQMs6aZSU0KJ+9989Z50fdHrL8cm8p7GMGkzcmr0UTYRCEKuZ7mtGq2oG v8kA== X-Gm-Message-State: APjAAAUHibIz+w8NCNj3RL7cpyhYnBfxqcWdUOouF1rjK0WIBNqle2I9 k1CMo2qhQfYOMUC5n6cFWIIhtw== X-Received: by 2002:a5d:498a:: with SMTP id r10mr22916612wrq.28.1562054808004; Tue, 02 Jul 2019 01:06:48 -0700 (PDT) Received: from [192.168.0.41] (132.97.130.77.rev.sfr.net. [77.130.97.132]) by smtp.googlemail.com with ESMTPSA id o14sm10152987wrp.77.2019.07.02.01.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 01:06:47 -0700 (PDT) Subject: Re: [PATCH RESEND V4 1/5] clocksource: timer-of: Support getting clock frequency from DT To: Anson.Huang@nxp.com, tglx@linutronix.de, robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, leonard.crestez@nxp.com, viresh.kumar@linaro.org, daniel.baluta@nxp.com, ping.bai@nxp.com, l.stach@pengutronix.de, abel.vesa@nxp.com, andrew.smirnov@gmail.com, ccaione@baylibre.com, angus@akkea.ca, agx@sigxcpu.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Linux-imx@nxp.com References: <20190702075513.17451-1-Anson.Huang@nxp.com> From: Daniel Lezcano Openpgp: preference=signencrypt Autocrypt: addr=daniel.lezcano@linaro.org; prefer-encrypt=mutual; keydata= mQINBFv/yykBEADDdW8RZu7iZILSf3zxq5y8YdaeyZjI/MaqgnvG/c3WjFaunoTMspeusiFE sXvtg3ehTOoyD0oFjKkHaia1Zpa1m/gnNdT/WvTveLfGA1gH+yGes2Sr53Ht8hWYZFYMZc8V 2pbSKh8wepq4g8r5YI1XUy9YbcTdj5mVrTklyGWA49NOeJz2QbfytMT3DJmk40LqwK6CCSU0 9Ed8n0a+vevmQoRZJEd3Y1qXn2XHys0F6OHCC+VLENqNNZXdZE9E+b3FFW0lk49oLTzLRNIq 0wHeR1H54RffhLQAor2+4kSSu8mW5qB0n5Eb/zXJZZ/bRiXmT8kNg85UdYhvf03ZAsp3qxcr xMfMsC7m3+ADOtW90rNNLZnRvjhsYNrGIKH8Ub0UKXFXibHbafSuq7RqyRQzt01Ud8CAtq+w P9E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KeRG55TXbu9M LqJYccPJ85B0PXcy63fL9U5DTysmxKQ5RgaxcxIZCM528ULFQs3dfEx5euWTWnnh7pN30RLg a+0AjSGd886Bh0kT1Dznrite0dzYlTHlacbITZG84yRk/gS7DkYQdjL8zgFr/pxH5CbYJDk0 tYUhisTESeesbvWSPO5uNqqy1dAFw+dqRcF5gXIh3NKX0gqiAA87NM7nL5ym/CNpJ7z7nRC8 qePOXubgouxumi5RQs1+crBmCDa/AyJHKdG2mqCt9fx5EPbDpw6Zzx7hgURh4ikHoS7/tLjK iqWjuat8/HWc01yEd8rtkGuUcMqbCi1XhcAmkaOnX8FYscMRoyyMrWClRZEQRokqZIj79+PR adkDXtr4MeL8BaB7Ij2oyRVjXUwhFQNKi5Z5Rve0a3zvGkkqw8Mz20BOksjSWjAF6g9byukl CUVjC03PdMSufNLK06x5hPc/c4tFR4J9cLrV+XxdCX7r0zGos9SzTPGNuIk1LK++S3EJhLFj 4eoWtNhMWc1uiTf9ENza0ntqH9XBWEQ6IA1gubCniGG+Xg== Message-ID: Date: Tue, 2 Jul 2019 10:06:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190702075513.17451-1-Anson.Huang@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anson, why did you resend the series? On 02/07/2019 09:55, Anson.Huang@nxp.com wrote: > From: Anson Huang > > More and more platforms use platform driver model for clock driver, > so the clock driver is NOT ready during timer initialization phase, > it will cause timer initialization failed. > > To support those platforms with upper scenario, introducing a new > flag TIMER_OF_CLOCK_FREQUENCY which is mutually exclusive with > TIMER_OF_CLOCK flag to support getting timer clock frequency from > DT's timer node, the property name should be "clock-frequency", > then of_clk operations can be skipped. > > User needs to select either TIMER_OF_CLOCK_FREQUENCY or TIMER_OF_CLOCK > flag if want to use timer-of driver to initialize the clock rate. > > Signed-off-by: Anson Huang > --- > Changes since V3: > - use hardcoded "clock-frequency" instead of adding new variable prop_name; > - add pre-condition check for TIMER_OF_CLOCK and TIMER_OF_CLOCK_FREQUENCY, they MUST be exclusive. > --- > drivers/clocksource/timer-of.c | 29 +++++++++++++++++++++++++++++ > drivers/clocksource/timer-of.h | 7 ++++--- > 2 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c > index 8054228..858f684 100644 > --- a/drivers/clocksource/timer-of.c > +++ b/drivers/clocksource/timer-of.c > @@ -161,11 +161,30 @@ static __init int timer_of_base_init(struct device_node *np, > return 0; > } > > +static __init int timer_of_clk_frequency_init(struct device_node *np, > + struct of_timer_clk *of_clk) > +{ > + int ret; > + u32 rate; > + > + ret = of_property_read_u32(np, "clock-frequency", &rate); > + if (!ret) { > + of_clk->rate = rate; > + of_clk->period = DIV_ROUND_UP(rate, HZ); > + } > + > + return ret; > +} > + > int __init timer_of_init(struct device_node *np, struct timer_of *to) > { > + unsigned long clock_flags = TIMER_OF_CLOCK | TIMER_OF_CLOCK_FREQUENCY; > int ret = -EINVAL; > int flags = 0; > > + if ((to->flags & clock_flags) == clock_flags) > + return ret; > + > if (to->flags & TIMER_OF_BASE) { > ret = timer_of_base_init(np, &to->of_base); > if (ret) > @@ -180,6 +199,13 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to) > flags |= TIMER_OF_CLOCK; > } > > + if (to->flags & TIMER_OF_CLOCK_FREQUENCY) { > + ret = timer_of_clk_frequency_init(np, &to->of_clk); > + if (ret) > + goto out_fail; > + flags |= TIMER_OF_CLOCK_FREQUENCY; > + } > + > if (to->flags & TIMER_OF_IRQ) { > ret = timer_of_irq_init(np, &to->of_irq); > if (ret) > @@ -201,6 +227,9 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to) > if (flags & TIMER_OF_CLOCK) > timer_of_clk_exit(&to->of_clk); > > + if (flags & TIMER_OF_CLOCK_FREQUENCY) > + to->of_clk.rate = 0; > + > if (flags & TIMER_OF_BASE) > timer_of_base_exit(&to->of_base); > return ret; > diff --git a/drivers/clocksource/timer-of.h b/drivers/clocksource/timer-of.h > index a5478f3..a08e108 100644 > --- a/drivers/clocksource/timer-of.h > +++ b/drivers/clocksource/timer-of.h > @@ -4,9 +4,10 @@ > > #include > > -#define TIMER_OF_BASE 0x1 > -#define TIMER_OF_CLOCK 0x2 > -#define TIMER_OF_IRQ 0x4 > +#define TIMER_OF_BASE 0x1 > +#define TIMER_OF_CLOCK 0x2 > +#define TIMER_OF_IRQ 0x4 > +#define TIMER_OF_CLOCK_FREQUENCY 0x8 > > struct of_timer_irq { > int irq; > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog