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: 9639313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 589B06020B for ; Wed, 22 Mar 2017 16:02:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46FA41FF26 for ; Wed, 22 Mar 2017 16:02:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 389A328459; Wed, 22 Mar 2017 16:02:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B147B1FF26 for ; Wed, 22 Mar 2017 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Hlp302tmIP6SGou3epzf6bY6fg+ZXF4UBC5BrAMUmMI=; b=Yr8eIc2hjaico3zTOwpGZg5bee LbP7Kp8gN821ylpxbFEwdx1EdvpyBMTqkw3zO1eOqdFZXEGpOgpiaH7LLutiYkwOco3rDRoBjMYSP eivijUuP2TwlIJqHsupiRzJNq0/hMXLH2yA4inylJotDEucP99jaboqJXHSVF4z6lq2MZfisLRKri UZT/9VysA/bXnQpzFQMmiIw8rh+L/A7jr5kLIiGtzcNLkgjNm9VEUakXGeRXTYhiZdCqvbyscPTPw BPxX7aT74Sn4U2YKirpoapHqsOiwvUzgmKFXE/6nUhj86sRBppGivJ7BCjw6FYU4rMay00BNAhru8 QfGrNfEQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqii4-0001eM-EW; Wed, 22 Mar 2017 16:02:04 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqiVR-0000dj-Ou; Wed, 22 Mar 2017 15:49:03 +0000 Received: by mail-wm0-x242.google.com with SMTP id u132so10751425wmg.1; Wed, 22 Mar 2017 08:48:41 -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=F2u2WzU5xgiKswhKr3hJEu8+/qSU2J8gf25bYR+fLJ6Td0e+v2r8gzILvrH05Q/JqX x6EUTzjyAuob1wqIK0JNo3sesnOGDY1mn5XJ+uGBLuyXxWJQBaYsiXrvti0aqRG/O7B1 YXopgMOT26X+Z2rPdYXeyJykgmHPOngcuxXh2evSUCX0TKVwlZ36cXI4gRBUtRYxA7GE 2UhSmykTnx5dj3SLYjNTbGC6RLuc+C/TrQo4JQ5G3osK1jVmpaZRO3PsZsVtz0+N7h4B m2xIJBi9ycDvqsyd1A+182pcyqyYAeFPmEOkWs5tvb0Z8lj/jZUU+y8fGUDdkEu9vR4l yxvA== X-Gm-Message-State: AFeK/H2GWkXKUI84StIwqTUQ2iKTy6O+8JN+hyKvCG1z35dhkzY5gWnv5kd7+Q8pvPvkvA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_084901_989047_39FF9A0E X-CRM114-Status: GOOD ( 17.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Huang Tao , Alexander Kochetkov , Russell King , Rob Herring , Thomas Gleixner , Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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",