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: 9639317 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 C7C0E6020B for ; Wed, 22 Mar 2017 16:02:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C471FF26 for ; Wed, 22 Mar 2017 16:02:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACA4F28459; Wed, 22 Mar 2017 16:02:21 +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 2AD891FF26 for ; Wed, 22 Mar 2017 16:02:21 +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=0Lj5Ssekkh1T5rF84DmJSkwFPqOUUPlqSSXaGXBCc98=; b=ij1p8RM7lwrLA7kgSZpJq4uDFb QUf6XxrVGeUmrRZYeZntZOeZQBgTx3TrlbO7iPqsR99fvSyi9oVnkiWEF1f7jQ5cEcd6w8XWUCONx pr9K74Aeery9bXTJF8apfs89grLPvYOvf1E8Bdse2PM0I6Kpp+o7DyfKRdrXcEd39+9ELXGV5eIXP Ws3p5UUKxRHsp3IQrROFguLVGUeT72X0zFEqgOpQvovA4IV1T9fkDnqV9DqYApYS1qCEkbmSuOtdx 1iEGDGEYdLiyaUPjzMNfZwXWCDUJ+L+XtZX+pZYJOXHNTNlSGU88BqRbHPZBM0OaVJaiQvoB+ZsQn sX87z5jg==; 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 1cqiiK-0001zw-55; Wed, 22 Mar 2017 16:02:20 +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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms 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-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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",