From patchwork Wed Mar 22 15:48:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 95784 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp304962qgd; Wed, 22 Mar 2017 08:50:31 -0700 (PDT) X-Received: by 10.98.144.16 with SMTP id a16mr46858903pfe.247.1490197831838; Wed, 22 Mar 2017 08:50:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g65si2255892pgc.194.2017.03.22.08.50.31; Wed, 22 Mar 2017 08:50:31 -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=@gmail.com; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935529AbdCVPu0 (ORCPT + 10 others); Wed, 22 Mar 2017 11:50:26 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36626 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760243AbdCVPtu (ORCPT ); Wed, 22 Mar 2017 11:49:50 -0400 Received: by mail-wm0-f67.google.com with SMTP id x124so10795761wmf.3; Wed, 22 Mar 2017 08:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ehxKuxnUElC95WH0Oq86ZCtYVbos9KPNKLwxYDvVa4o=; b=D6hhWtV8MU7BO4ne0YSU52TwKw8InszpXx4LtZBUJqzIGzUW2uCwgG1q+cv5akirEq r86ZwilctpC8+AOQTdQfx6Od3FaRo2df3DJuRbuKzRlkvGWRgTlt6zm+4RAYe3/LlzKt /EmvJQ20CevRmPDKOt0uBUurq3ggTKPCUdJKoINOwV6PkkthRVVc8HECU1u+ixnfmPHn fByJUbR7zSu2s16vrRSF1ZeaXhGOg3PCJWPNu/lUkWOEd+as+1LRgBoabXePWrNrp5M8 oVo4X50nBj2gIXGgvKcT6iGMsLJoISvV0HcGdIeGa6oQ0Srz2rUDQs+8KbFN0P3DEXVD roQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ehxKuxnUElC95WH0Oq86ZCtYVbos9KPNKLwxYDvVa4o=; b=cBagcC3VI5dnidVbsv4ASaOWbWe+4t3Zkv47mt3HNzCvOI098d9VXebVcHD33fMDAP LIfJQglT+VjLowWC/0Lx96sYISqkEZrVxCwkOiRW4+fBZdUnFoTKqy+CMjekVDCabz48 6+T44fco444wPMXArFprtd7m/VThlI3GM2tvfaUOMRRwowr9MuRm8qwEzqyxaQn5LVkW ZudaZHxa2XjR+NBdE7Y2Yzs1DPkuqImGEAww1WqoV8qH8bVTBzcZdgpRJjO14n99OUJv vN7t0JG04Iz5RuGRHwvtnL7IR+EEcOpcn5xa7D7vqSOzG1pHSa2djSVfQlvIEt167CJm ayhg== X-Gm-Message-State: AFeK/H140LH15qQ3tFPxdQyN84lUXMQ2sCr6LUHoK5vk0n6aeHzwKTpTpKWB0Q1dKqBiiw== X-Received: by 10.25.79.15 with SMTP id d15mr10660313lfb.14.1490197719821; Wed, 22 Mar 2017 08:48:39 -0700 (PDT) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id p27sm591898lfg.5.2017.03.22.08.48.38 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 08:48:39 -0700 (PDT) From: Alexander Kochetkov To: Daniel Lezcano , Heiko Stuebner , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Thomas Gleixner , Mark Rutland , Rob Herring , Russell King , Caesar Wang , Huang Tao , Alexander Kochetkov Subject: [PATCH v7 1/7] clocksource/drivers/clksrc-evt-probe: Describe with the DT both the clocksource and the clockevent Date: Wed, 22 Mar 2017 18:48:28 +0300 Message-Id: <1490197714-25415-2-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1490197714-25415-1-git-send-email-al.kochet@gmail.com> References: <1490197714-25415-1-git-send-email-al.kochet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Lezcano The CLOCKSOURCE_OF_DECLARE() was introduced before the CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the clockevent and the clocksource are both initialized in the same init routine. With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can now split the clocksource and the clockevent init code. However, the device tree may specify a single node, so the same node will be passed to the clockevent/clocksource's init function, with the same base address. with this patch it is possible to specify an attribute to the timer's node to specify if it is a clocksource or a clockevent and define two timers node. For example: timer: timer@98400000 { compatible = "moxa,moxart-timer"; reg = <0x98400000 0x42>; interrupts = <19 1>; clocks = <&coreclk>; clockevent; }; timer: timer@98400010 { compatible = "moxa,moxart-timer"; reg = <0x98400010 0x42>; clocks = <&coreclk>; clocksource; }; With this approach, we allow a mechanism to clearly define a clocksource or a clockevent without aerobatics we can find around in some drivers: timer-sp804.c, arc-timer.c, dw_apb_timer_of.c, mps2-timer.c, renesas-ostm.c, time-efm32.c, time-lpc32xx.c. Signed-off-by: Daniel Lezcano Signed-off-by: Alexander Kochetkov --- Documentation/devicetree/bindings/timer/timer.txt | 38 +++++++++++++++++++++ drivers/clocksource/clkevt-probe.c | 7 ++++ drivers/clocksource/clksrc-probe.c | 7 ++++ 3 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/timer.txt -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/timer/timer.txt b/Documentation/devicetree/bindings/timer/timer.txt new file mode 100644 index 0000000..f1ee0cf --- /dev/null +++ b/Documentation/devicetree/bindings/timer/timer.txt @@ -0,0 +1,38 @@ + +Specifying timer information for devices +======================================== + +The timer can be declared via the macro: + +CLOCKSOURCE_OF_DECLARE(name, init) if it is a clocksource +CLOCKEVENT_OF_DECLARE(name, init) if it is a clockevent + +The CLOCKSOURCE_OF_DECLARE() was introduced before the +CLOCKEVENT_OF_DECLARE() and that resulted in some abuse where the +clockevent and the clocksource are both initialized in the same init +routine. + +With the introduction of the CLOCKEVENT_OF_DECLARE(), the driver can +now split the clocksource and the clockevent init code. However, the +device tree may specify a single node, so the same node will be passed +to the clockevent/clocksource's init function, with the same base +address. It is possible to specify an attribute to the timer's node to +specify if it is a clocksource or a clockevent and define two timers +node. + +Example: + + timer: timer@98400000 { + compatible = "moxa,moxart-timer"; + reg = <0x98400000 0x42>; + interrupts = <19 1>; + clocks = <&coreclk>; + clockevent; + }; + + timer: timer@98400010 { + compatible = "moxa,moxart-timer"; + reg = <0x98400010 0x42>; + clocks = <&coreclk>; + clocksource; + }; diff --git a/drivers/clocksource/clkevt-probe.c b/drivers/clocksource/clkevt-probe.c index eb89b50..fa02ac1 100644 --- a/drivers/clocksource/clkevt-probe.c +++ b/drivers/clocksource/clkevt-probe.c @@ -37,6 +37,13 @@ int __init clockevent_probe(void) init_func = match->data; + /* + * The device node describes a clocksource, ignore it + * as we are in the clockevent init routine. + */ + if (of_property_read_bool(np, "clocksource")) + continue; + ret = init_func(np); if (ret) { pr_warn("Failed to initialize '%s' (%d)\n", diff --git a/drivers/clocksource/clksrc-probe.c b/drivers/clocksource/clksrc-probe.c index bc62be9..ce50f33 100644 --- a/drivers/clocksource/clksrc-probe.c +++ b/drivers/clocksource/clksrc-probe.c @@ -38,6 +38,13 @@ void __init clocksource_probe(void) init_func_ret = match->data; + /* + * The device node describes a clockevent, ignore it + * as we are in the clocksource init routine. + */ + if (of_property_read_bool(np, "clockevent")) + continue; + ret = init_func_ret(np); if (ret) { pr_err("Failed to initialize '%s': %d",