From patchwork Thu May 18 20:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100122 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6153qge; Thu, 18 May 2017 13:17:51 -0700 (PDT) X-Received: by 10.99.113.74 with SMTP id b10mr6369200pgn.139.1495138671661; Thu, 18 May 2017 13:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138671; cv=none; d=google.com; s=arc-20160816; b=zKsxwDEuMb3DqMmOVMTVFo6KNE8Fs/u6buL0gjDvIxh3FlnM0WF3UmC5yuCChIA+/d ouh9IV5PdLH0POOM+lwiRZltg+snD9jn0J511XsOOMZ24wLA4+FbYEgTqIcpSWa8NAq9 SlG1mjnpkiB5SMdg+qke/lvPef1X9YGmhOeX/Bc96rvlVlgiomczu4P+rbuERSGHGeqg w06JFbzrtawgN+asnvH6TV1btonp3BAQNLolXUTZE0gnei0CXE2E5twhRw3bJIKRSeMa PQNxquhwRwdacUAry69//pn+NXzBsfsl68Fva9yn6iGziZAt7qqiKOSlWXyVWLEvuVNJ 61sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ehq7rWO0XTA3iuh05UU4aHNgyKmpUa4g2qWj34R1iMk=; b=RahQOn1PfmLbYdT2P2ERLWDOZpBwuo+zqHjyzJB4sQF1cV50vdR8I7qQATMNAyrXPh YHCLmmYEDk5KOftScOneQ06/RWcRMMBZRta/MQuA/vdQD0gY/O7+eUDwu25A24p7jSH6 ENS7u1g17UcleNg740adFoGYbAXjKAY7qvBznZp0nn80oPuL1Mw3XGOuL0bfMhlUc91R jDeoQ0CuMlAhkAnqGVDTrAoKDMqFr5LBMx4cLTrjcHWtj1TSgXd5MpIJUpIjDsJLU2ml Q6rmf24kfGK7fo8ekYfA1QCxUKXvfNPQZmrynHjkRlNka+INhY9iEEsCpCNxPZ7FlLV+ u+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 q7si6059160pfd.332.2017.05.18.13.17.51; Thu, 18 May 2017 13:17:51 -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; 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 S1755749AbdERUR2 (ORCPT + 25 others); Thu, 18 May 2017 16:17:28 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:35134 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753069AbdERURZ (ORCPT ); Thu, 18 May 2017 16:17:25 -0400 Received: by mail-wr0-f170.google.com with SMTP id z52so3069186wrc.2 for ; Thu, 18 May 2017 13:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ehq7rWO0XTA3iuh05UU4aHNgyKmpUa4g2qWj34R1iMk=; b=FLlQGsIP/+vZ+R0KHzuWd4JwaBpyyP1v4E9t2xH/gKVrbFTm6jQUgOf7ZDjw2vQRTg aHPhzY2NNUKWFo+MqhC/4O9usI0WH0gGH1l8Ol4P5aVabU0TUla/au8+8TZn6p9VQYZW CcnrAPXT66jvfsJlJA9zuV/tG+j9K0qChhsqc= 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; bh=ehq7rWO0XTA3iuh05UU4aHNgyKmpUa4g2qWj34R1iMk=; b=gmtSCrjQpsF/vsW50JdIeyJBppLaTDjq7uoSH45HMMyNAiV9n7VeSQeP92L6TnOKDz giXR1YNKMSHVa+OJwUJhrz4Bmk0wN+O7XD2xjXdpIxuxnQm8SN3uTCiv5cIi2+qBZUO+ eSUnEQe9Ku7rvuPWjxViZ+H4OBvBIB+aP/OmJHO9zXdnvN2goi1FZmvfA5C0FsWWrhwE t+T/l+I4rmGtVx8hv7VxkoIqb8a19daKu/nsMkX+qjIhVKEq1UZgnEXmlzRa1uG0dL8D 5R1buAQSskFkJzNGOR5kaL1qBo+dZNgLdGerJi/PtQCpEc79SBmbQ3k/nTqgfCovviCg Xf/g== X-Gm-Message-State: AODbwcDueeZbNhYKWQRFQzj6/ECGzmLBM692aH3B34gfsq3qfYf5Ef4j IH7SfESFfRuBfST9 X-Received: by 10.46.32.169 with SMTP id g41mr707335lji.65.1495138638815; Thu, 18 May 2017 13:17:18 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:17 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 1/8 v2] clocksource/drivers/fttmr010: Fix the clock handling Date: Thu, 18 May 2017 22:16:58 +0200 Message-Id: <20170518201705.28790-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to also prepare and enable the clock we are using to get the right reference count and avoid it being shut off. Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index b4a6f1e4bc54..58ce017e4a65 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -238,12 +238,18 @@ static int __init fttmr010_timer_of_init(struct device_node *np) * and using EXTCLK is not supported in the driver. */ struct clk *clk; + int ret; clk = of_clk_get_by_name(np, "PCLK"); if (IS_ERR(clk)) { - pr_err("could not get PCLK"); + pr_err("could not get PCLK\n"); return PTR_ERR(clk); } + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("failed to enable PCLK\n"); + return ret; + } tick_rate = clk_get_rate(clk); return fttmr010_timer_common_init(np); From patchwork Thu May 18 20:16:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100129 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6536qge; Thu, 18 May 2017 13:18:59 -0700 (PDT) X-Received: by 10.98.15.23 with SMTP id x23mr6405305pfi.86.1495138739879; Thu, 18 May 2017 13:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138739; cv=none; d=google.com; s=arc-20160816; b=c1cCgwFxsOjjZTaFqfyDIZemslNQwZvF1/4SBxE74BPeQGdNN9OdB9w27tt2wop0q4 +y8bhP/7DUhsEGpbNk6Ydn1ccoxLkxT6cSHYGdAN7WGBDv+oU5hY7WLfZjxa2fScQvZg I2L7KHwhFsW/KQym7Ju+sSsFii+8GoRaBegyZK+jMQOEDaqGAif5Bb4nQ1YPXbzUMgXT HY2ygga2dcW2MukvWWM9axb9OOorfW1H17emlASY/AypnG6DTrDSgCsxMQsr/Y/QnBLQ 4gio+UUgzH5iR/slw1lIjic9DqvNhdF5tWr6Ao9VA+h1NGLF3VV5vnpp4wYjJ8CnDGAP bbWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tG9DOdKRY1pJTUGw5gRVv8L8Y05mXzxF0/G8uunOEOs=; b=LnrP/tv446qfzd6btsuqMoLO338At7KBPlLr3Dd0eyhuEm8LPAwGm8lr7dzSzcS5zy jwo4yeFI3cyGumNIXtj2VcWSlson87rz2aB/Adn9hE6awcqyGMUDR+W5MnebHuqH4xJk IsU4GqaN/Sb9xWQo7RjAkdmWY+dkKnDBThJDhIgI68tnMvo2hVB2687HyIMPIddnzMdZ E08S62GfIDzBBi5ommQh9VcKriSUcbtEDP8x30TTzPfBDs+h/hA5KqatWIG9VWqRhzyo YCejKYIfizWCsxdNLoV7NZe8BBrFmsFpwjokVwytRZQyGD4im0LeqZkv0RNml7+VeDkR 7q5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 b8si4984374ple.2.2017.05.18.13.18.58; Thu, 18 May 2017 13:18:59 -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; 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 S1755709AbdERUR0 (ORCPT + 25 others); Thu, 18 May 2017 16:17:26 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:38174 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbdERURX (ORCPT ); Thu, 18 May 2017 16:17:23 -0400 Received: by mail-wm0-f49.google.com with SMTP id v15so65045787wmv.1 for ; Thu, 18 May 2017 13:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tG9DOdKRY1pJTUGw5gRVv8L8Y05mXzxF0/G8uunOEOs=; b=ch2A0sXzWYTL+asK8keGFgo6ZxExlvFvKce7IwV+8kstjAqARfUhmxaifr8IMOwSbN LIIXm35GmmMjnijUTk5Hl3OYUKOxxbKaSEaS09uQIHXqeLXQNUY9H7PDzzjiPvsunXcb SDjX+4rzA6h7UFnRpY/vyvBAJA7AnLZ8dnraU= 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=tG9DOdKRY1pJTUGw5gRVv8L8Y05mXzxF0/G8uunOEOs=; b=idYLGZdDApdNaBnBu+joZsy9CYdmdXOKkDQTXXUk+OFPHjtYVy3leanm4DM/PbC7fP Jy4Sr+ablYzZzy4RoxVdr00x4qHeSkRM2BspEeEYA0Kyn8Mu7yauonCFR6jpt6flFk0e gp1gZON44PS3O98Jt2bNRxg/AcX/kR3R5imP3AiKYhyv8wv5wuQTtjzww2xGoIzsCQY/ kGMfWY8kIHL6HDDJ+WqtrgnCxqoAKt6ZQlExnX9CXpRTcpErBPyKUQCRoyue5rCuwmjH FQVuNGiXLtXeNqFJ2wt5lqGnbpPbgbnm3Vp5OIdekiJcNU4zTV2fU6E959q8DO28PUid MVIA== X-Gm-Message-State: AODbwcC+GJ44K+RXEHBS8cu7YEnDbkGNMNlDsjjU/9Fojk1lMYpWL7kP Ahc9BtROOZIF+eQn X-Received: by 10.25.77.149 with SMTP id a143mr1280613lfb.121.1495138642310; Thu, 18 May 2017 13:17:22 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:20 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 2/8 v2] clocksource/drivers/fttmr010: Merge FTTMR010 DT bindings Date: Thu, 18 May 2017 22:16:59 +0200 Message-Id: <20170518201705.28790-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This merges the Moxa and FTTMR010 device tree bindings into the Faraday binding document to avoid confusion. The FTTMR010 is the IP block used by these SoCs, in vanilla or modified variant. The Aspeed variant is modified such that it is no longer fully register-compatible with FTTMR010 so for this reason it is not listed with two compatible strings, instead just one. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- .../devicetree/bindings/timer/faraday,fttmr010.txt | 4 +++- .../devicetree/bindings/timer/moxa,moxart-timer.txt | 19 ------------------- 2 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt -- 2.9.3 Acked-by: Joel Stanley diff --git a/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt b/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt index b73ca6cd07f8..6e18bd662ccb 100644 --- a/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt +++ b/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt @@ -7,7 +7,9 @@ Required properties: - compatible : Must be one of "faraday,fttmr010" - "cortina,gemini-timer" + "cortina,gemini-timer", "faraday,fttmr010" + "moxa,moxart-timer", "faraday,fttmr010" + "aspeed,ast2400-timer" - reg : Should contain registers location and length - interrupts : Should contain the three timer interrupts usually with flags for falling edge diff --git a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt b/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt deleted file mode 100644 index e207c11630af..000000000000 --- a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt +++ /dev/null @@ -1,19 +0,0 @@ -MOXA ART timer - -Required properties: - -- compatible : Must be one of: - - "moxa,moxart-timer" - - "aspeed,ast2400-timer" -- reg : Should contain registers location and length -- interrupts : Should contain the timer interrupt number -- clocks : Should contain phandle for the clock that drives the counter - -Example: - - timer: timer@98400000 { - compatible = "moxa,moxart-timer"; - reg = <0x98400000 0x42>; - interrupts = <19 1>; - clocks = <&coreclk>; - }; From patchwork Thu May 18 20:17:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100123 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6155qge; Thu, 18 May 2017 13:17:52 -0700 (PDT) X-Received: by 10.98.102.208 with SMTP id s77mr6396246pfj.22.1495138672033; Thu, 18 May 2017 13:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138672; cv=none; d=google.com; s=arc-20160816; b=toQZr+i/K/gHySBXDgbAB+I5XdE+a00X+So9/F2zhhCpsl2otempoVYwQmwrBN30zp axsqux9clYUfJMcT+avIEroxZ9+SHOXNbz+hROZdLYc1YPLHGf2Qk2sN6PJxY8QhXBAT IFikqnugG6Tv5yn4lgsCnDmQc/9DbDqqSUEIBrMGlAMTYOEPsN5wDT5olsE+IPCImRP6 +KnbQlw0uJ4ikZ8rx6Ngu41B739ef8aY7MKMLsWner0kazJ2qCO333yYN5IpQzW9/cuD TQr2Y3By7NlRXBMag5bbnnn9NfXiWZBWctOFPyyEbTLvssWsLlbrdfBCp+tsprTz+z5B 2SRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=ZMRgtAWruZwlMF+BZiJh7f88V8VhdLOB5sAnnUwNUkH0pVAtow7HaZz0T/m3jWALNA wmS75DIsbqDxlI4nwHcdOZN+ag+Ne7Snh7d1aRISzr1sABdrtHABjorISaUrJUXjpqrj ZgKcmWpMPx8uUCK04leZtYJ4ZorboME7bR1L47TPm6pJF3yWmoFFslUwml5GeKBfTyHn qVZ9CzyRcSx0Rxqe9A+6WMEUBHMFGnxxPIbAOnjbIrC6H4XZRENiZ7nkKf+PWq42LfAG LoWEFjyLVY80ofQE4RqIAN7HP09g0gFAQZlIBYPhXuXqPpEPiNqhCVVvaUdd6kS2+QV5 JC/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 q7si6059160pfd.332.2017.05.18.13.17.51; Thu, 18 May 2017 13:17:52 -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; 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 S1755797AbdERURa (ORCPT + 25 others); Thu, 18 May 2017 16:17:30 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38253 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755695AbdERUR0 (ORCPT ); Thu, 18 May 2017 16:17:26 -0400 Received: by mail-wm0-f50.google.com with SMTP id v15so65047073wmv.1 for ; Thu, 18 May 2017 13:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=J3IgQq2LZgVFrHOoEpn01kdu6e0WG9cgrmVlLetSO88frWIaCgRVPOOimU0yFi7VVd EjbEf46JzFY7n8as+z/2T1wDV4CifycnOOvvytifPoxt/j5veh3tkTK7kwHlBCGG0UjU A1HQughaSaTux9dbd3Ntpv1Upv0RnwVVlPmgE= 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=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=MNw65tmbeQNjVTPqs7OWUigPuNVfzIdRpL6flBwIv8d/Wnqpym7B0adtlLqG99LsKs m63d76pIMeG32Ek4gQ4+gSW7N444ycfGLj+Eup9u9qOdlQ437lzNPNQAwrSEj/1burn9 rJzn+4uykEYvUdWTvjoCa9OSaCRkVLeaJ7Gq66SyT0ArPDZjGynbrhal9AF6HesCDzEI yIdq6/H2tY/hjyn5D+KENCqmtw7szACWlf+aXi3fM+umYn8jIjj36yWTNRKJXM7TH89/ G/s4ufFC76y8ZZKySHRPAh1wEWIpWcJICmg8a6Uxng4RZtXqyzrFYrMsU/xIkCO86MER iQaA== X-Gm-Message-State: AODbwcD8EVdliTLIZLh6CJH7u5ILgIU7iPNzq2sRWjomM1Pb5cLt4cyC 5M1FcAIdJJHtW+8r X-Received: by 10.25.221.198 with SMTP id w67mr1490783lfi.114.1495138644994; Thu, 18 May 2017 13:17:24 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:23 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 3/8 v2] clocksource/drivers/fttmr010: Drop Gemini specifics Date: Thu, 18 May 2017 22:17:00 +0200 Message-Id: <20170518201705.28790-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Gemini now has a proper clock driver and a proper PCLK assigned in its device tree. Drop the Gemini-specific hacks to look up the system speed and rely on the clock framework like everyone else. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 103 ++++++++--------------------------- 1 file changed, 22 insertions(+), 81 deletions(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index 58ce017e4a65..db097db346e3 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -179,9 +177,28 @@ static struct irqaction fttmr010_timer_irq = { .handler = fttmr010_timer_interrupt, }; -static int __init fttmr010_timer_common_init(struct device_node *np) +static int __init fttmr010_timer_init(struct device_node *np) { int irq; + struct clk *clk; + int ret; + + /* + * These implementations require a clock reference. + * FIXME: we currently only support clocking using PCLK + * and using EXTCLK is not supported in the driver. + */ + clk = of_clk_get_by_name(np, "PCLK"); + if (IS_ERR(clk)) { + pr_err("could not get PCLK\n"); + return PTR_ERR(clk); + } + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("failed to enable PCLK\n"); + return ret; + } + tick_rate = clk_get_rate(clk); base = of_iomap(np, 0); if (!base) { @@ -229,81 +246,5 @@ static int __init fttmr010_timer_common_init(struct device_node *np) return 0; } - -static int __init fttmr010_timer_of_init(struct device_node *np) -{ - /* - * These implementations require a clock reference. - * FIXME: we currently only support clocking using PCLK - * and using EXTCLK is not supported in the driver. - */ - struct clk *clk; - int ret; - - clk = of_clk_get_by_name(np, "PCLK"); - if (IS_ERR(clk)) { - pr_err("could not get PCLK\n"); - return PTR_ERR(clk); - } - ret = clk_prepare_enable(clk); - if (ret) { - pr_err("failed to enable PCLK\n"); - return ret; - } - tick_rate = clk_get_rate(clk); - - return fttmr010_timer_common_init(np); -} -CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_of_init); - -/* - * Gemini-specific: relevant registers in the global syscon - */ -#define GLOBAL_STATUS 0x04 -#define CPU_AHB_RATIO_MASK (0x3 << 18) -#define CPU_AHB_1_1 (0x0 << 18) -#define CPU_AHB_3_2 (0x1 << 18) -#define CPU_AHB_24_13 (0x2 << 18) -#define CPU_AHB_2_1 (0x3 << 18) -#define REG_TO_AHB_SPEED(reg) ((((reg) >> 15) & 0x7) * 10 + 130) - -static int __init gemini_timer_of_init(struct device_node *np) -{ - static struct regmap *map; - int ret; - u32 val; - - map = syscon_regmap_lookup_by_phandle(np, "syscon"); - if (IS_ERR(map)) { - pr_err("Can't get regmap for syscon handle\n"); - return -ENODEV; - } - ret = regmap_read(map, GLOBAL_STATUS, &val); - if (ret) { - pr_err("Can't read syscon status register\n"); - return -ENXIO; - } - - tick_rate = REG_TO_AHB_SPEED(val) * 1000000; - pr_info("Bus: %dMHz ", tick_rate / 1000000); - - tick_rate /= 6; /* APB bus run AHB*(1/6) */ - - switch (val & CPU_AHB_RATIO_MASK) { - case CPU_AHB_1_1: - pr_cont("(1/1)\n"); - break; - case CPU_AHB_3_2: - pr_cont("(3/2)\n"); - break; - case CPU_AHB_24_13: - pr_cont("(24/13)\n"); - break; - case CPU_AHB_2_1: - pr_cont("(2/1)\n"); - break; - } - - return fttmr010_timer_common_init(np); -} -CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", gemini_timer_of_init); +CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init); +CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init); From patchwork Thu May 18 20:17:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100128 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6409qge; Thu, 18 May 2017 13:18:38 -0700 (PDT) X-Received: by 10.98.106.199 with SMTP id f190mr6546350pfc.142.1495138718694; Thu, 18 May 2017 13:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138718; cv=none; d=google.com; s=arc-20160816; b=A/2TRxvI6/lgSbeaYHyfowHL17imIgHf71PgPxHTrXXEVuYSUdj832ONcOISY4igPY ht2CxgEuxWExJhwu8uHvq5KyM4HHlmrKFcfWUo1HSiv4Gj7lW/BFqjedlwTqhoGXtlJh +NYlGf+KKEk6fZcX8XBV3oH4iViVfEDSu24FhESfi32Qjg8awn7aWGPAE9JYm/rHMAiI fZZ4P6knQ4zMfke+kn9hvwEy7UxkFy/UdMCKy1IinpuLUdVRewpue3aMONon/IXdStvE wAz+Ki1jq/0fd2+rDvwEgDBorGA+JTuuIYQcydFr53R+ax4ND7XtU+VeIc7REpemL2sk 7d8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OwV6d2WdQnRAKTFtFtGlcw+khQmMQ7uzw+zFLiNqNR4=; b=g/Hz8m7m3fPQptFy2jGF01Fv+PtiJbYG2LQn6QE//7rzO5WgpBdUnXjab6HPDjr2it ptwuWPcmDhAwsPe9f6DbeXTLukJmZ5Wi5QVVdXswCkAdpB9K9guXUtSIaLyVbfMSf6y3 9JjHz4tzkCrOuSL7cCb76SL+Qlfo3p1SH3CM/Uf6KFtTJYP+fXMBzLMMoV8y2eTVqnPq 3Ng6sVMhvPEMngBVqH6BYk6pkoZ+fa0+pS32NVPLWEXBAQUAAu//1WK2Wtjoh8K5iBae 7AmeCubV+uFh2y34dO2YOGfJr1pANHAVAum3oWvJh3dEwZFHaX0vRE4aV1fVaOtkkbQy AlDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 b8si4984374ple.2.2017.05.18.13.18.38; Thu, 18 May 2017 13:18:38 -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; 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 S1755955AbdERUSf (ORCPT + 25 others); Thu, 18 May 2017 16:18:35 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:37009 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755689AbdERUR3 (ORCPT ); Thu, 18 May 2017 16:17:29 -0400 Received: by mail-wm0-f44.google.com with SMTP id d127so64797327wmf.0 for ; Thu, 18 May 2017 13:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OwV6d2WdQnRAKTFtFtGlcw+khQmMQ7uzw+zFLiNqNR4=; b=KkZuR04vjOEy5g8HMCadpcf8ratphHPRmXSTQB7eFcXHaxht86kpZ2dLyKi7wR/XVu N+uxXkvsOQrNmagRFTYSxPyIHXrujWjnqxlox4190sTpstW0V8NcX/wfLHt8uJd7UftG nqlkW+3s6pc2lIHwUpbB+SLtEXzkt7041vcmE= 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=OwV6d2WdQnRAKTFtFtGlcw+khQmMQ7uzw+zFLiNqNR4=; b=BwQuV+4ExLzTd41iyNd3UDvE3nZMPs5aVe073ZQF9DPZtmRV2tAOYnfmUVbyydOrPh iQDVFwBfXcTAbcv6alAHUygJmWj7TCf2ehAzmqMVUPmtyoHxf8UoelE9DQNB6PpEUfnk 6Ue9cU6kdZjQtAWusU3r1OtYPJWnFjapqBO/9a9FAi2wRBvLmmzA1DWmsCdoZLLGQnZ9 n06dRPEx18so73PnNOVYGI5ws1majKNH4fSzHh8PUnweLq6v0lqzbSIwOr2NbjxsSnkN jTtN34devgAfhOAYZFVixhxtXDbJBSXbvJ+qXrEtPhI090KCW2eChWDShwIOa5Y02ES0 3p9A== X-Gm-Message-State: AODbwcBEozT28Pp3SmhM3gNFCfxDoes4vn9TUrglQBnVPtfcVMCSwVMP 4Sm/OcbCFMwqknfJ X-Received: by 10.25.74.196 with SMTP id x187mr1348093lfa.164.1495138647875; Thu, 18 May 2017 13:17:27 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:26 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 4/8 v2] clocksource/drivers/fttmr010: Use state container Date: Thu, 18 May 2017 22:17:01 +0200 Message-Id: <20170518201705.28790-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This converts the Faraday FTTMR010 to use the state container design pattern. Take some care to handle the state container and free:ing of resources as has been done in the Moxa driver. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 190 +++++++++++++++++++++-------------- 1 file changed, 116 insertions(+), 74 deletions(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index db097db346e3..9ad31489bbef 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -15,6 +15,7 @@ #include #include #include +#include /* * Register definitions for the timers @@ -62,23 +63,35 @@ #define TIMER_3_INT_OVERFLOW (1 << 8) #define TIMER_INT_ALL_MASK 0x1ff -static unsigned int tick_rate; -static void __iomem *base; +struct fttmr010 { + void __iomem *base; + unsigned int tick_rate; + struct clock_event_device clkevt; +}; + +/* A local singleton used by sched_clock, which is stateless */ +static struct fttmr010 *local_fttmr; + +static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt) +{ + return container_of(evt, struct fttmr010, clkevt); +} static u64 notrace fttmr010_read_sched_clock(void) { - return readl(base + TIMER3_COUNT); + return readl(local_fttmr->base + TIMER3_COUNT); } static int fttmr010_timer_set_next_event(unsigned long cycles, struct clock_event_device *evt) { + struct fttmr010 *fttmr010 = to_fttmr010(evt); u32 cr; /* Setup the match register */ - cr = readl(base + TIMER1_COUNT); - writel(cr + cycles, base + TIMER1_MATCH1); - if (readl(base + TIMER1_COUNT) - cr > cycles) + cr = readl(fttmr010->base + TIMER1_COUNT); + writel(cr + cycles, fttmr010->base + TIMER1_MATCH1); + if (readl(fttmr010->base + TIMER1_COUNT) - cr > cycles) return -ETIME; return 0; @@ -86,99 +99,90 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, static int fttmr010_timer_shutdown(struct clock_event_device *evt) { + struct fttmr010 *fttmr010 = to_fttmr010(evt); + u32 cr; + + /* Stop timer and interrupt. */ + cr = readl(fttmr010->base + TIMER_CR); + cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); + writel(cr, fttmr010->base + TIMER_CR); + + return 0; +} + +static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) +{ + struct fttmr010 *fttmr010 = to_fttmr010(evt); u32 cr; - /* - * Disable also for oneshot: the set_next() call will arm the timer - * instead. - */ /* Stop timer and interrupt. */ - cr = readl(base + TIMER_CR); + cr = readl(fttmr010->base + TIMER_CR); cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); - writel(cr, base + TIMER_CR); + writel(cr, fttmr010->base + TIMER_CR); /* Setup counter start from 0 */ - writel(0, base + TIMER1_COUNT); - writel(0, base + TIMER1_LOAD); + writel(0, fttmr010->base + TIMER1_COUNT); + writel(0, fttmr010->base + TIMER1_LOAD); - /* enable interrupt */ - cr = readl(base + TIMER_INTR_MASK); + /* Enable interrupt */ + cr = readl(fttmr010->base + TIMER_INTR_MASK); cr &= ~(TIMER_1_INT_OVERFLOW | TIMER_1_INT_MATCH2); cr |= TIMER_1_INT_MATCH1; - writel(cr, base + TIMER_INTR_MASK); + writel(cr, fttmr010->base + TIMER_INTR_MASK); - /* start the timer */ - cr = readl(base + TIMER_CR); + /* Start the timer */ + cr = readl(fttmr010->base + TIMER_CR); cr |= TIMER_1_CR_ENABLE; - writel(cr, base + TIMER_CR); + writel(cr, fttmr010->base + TIMER_CR); return 0; } static int fttmr010_timer_set_periodic(struct clock_event_device *evt) { - u32 period = DIV_ROUND_CLOSEST(tick_rate, HZ); + struct fttmr010 *fttmr010 = to_fttmr010(evt); + u32 period = DIV_ROUND_CLOSEST(fttmr010->tick_rate, HZ); u32 cr; /* Stop timer and interrupt */ - cr = readl(base + TIMER_CR); + cr = readl(fttmr010->base + TIMER_CR); cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); - writel(cr, base + TIMER_CR); + writel(cr, fttmr010->base + TIMER_CR); /* Setup timer to fire at 1/HT intervals. */ cr = 0xffffffff - (period - 1); - writel(cr, base + TIMER1_COUNT); - writel(cr, base + TIMER1_LOAD); + writel(cr, fttmr010->base + TIMER1_COUNT); + writel(cr, fttmr010->base + TIMER1_LOAD); /* enable interrupt on overflow */ - cr = readl(base + TIMER_INTR_MASK); + cr = readl(fttmr010->base + TIMER_INTR_MASK); cr &= ~(TIMER_1_INT_MATCH1 | TIMER_1_INT_MATCH2); cr |= TIMER_1_INT_OVERFLOW; - writel(cr, base + TIMER_INTR_MASK); + writel(cr, fttmr010->base + TIMER_INTR_MASK); /* Start the timer */ - cr = readl(base + TIMER_CR); + cr = readl(fttmr010->base + TIMER_CR); cr |= TIMER_1_CR_ENABLE; cr |= TIMER_1_CR_INT; - writel(cr, base + TIMER_CR); + writel(cr, fttmr010->base + TIMER_CR); return 0; } -/* Use TIMER1 as clock event */ -static struct clock_event_device fttmr010_clockevent = { - .name = "TIMER1", - /* Reasonably fast and accurate clock event */ - .rating = 300, - .shift = 32, - .features = CLOCK_EVT_FEAT_PERIODIC | - CLOCK_EVT_FEAT_ONESHOT, - .set_next_event = fttmr010_timer_set_next_event, - .set_state_shutdown = fttmr010_timer_shutdown, - .set_state_periodic = fttmr010_timer_set_periodic, - .set_state_oneshot = fttmr010_timer_shutdown, - .tick_resume = fttmr010_timer_shutdown, -}; - /* * IRQ handler for the timer */ static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id) { - struct clock_event_device *evt = &fttmr010_clockevent; + struct clock_event_device *evt = dev_id; evt->event_handler(evt); return IRQ_HANDLED; } -static struct irqaction fttmr010_timer_irq = { - .name = "Faraday FTTMR010 Timer Tick", - .flags = IRQF_TIMER, - .handler = fttmr010_timer_interrupt, -}; - static int __init fttmr010_timer_init(struct device_node *np) { + struct fttmr010 *fttmr010; int irq; struct clk *clk; int ret; @@ -198,53 +202,91 @@ static int __init fttmr010_timer_init(struct device_node *np) pr_err("failed to enable PCLK\n"); return ret; } - tick_rate = clk_get_rate(clk); - base = of_iomap(np, 0); - if (!base) { + fttmr010 = kzalloc(sizeof(*fttmr010), GFP_KERNEL); + if (!fttmr010) { + ret = -ENOMEM; + goto out_disable_clock; + } + fttmr010->tick_rate = clk_get_rate(clk); + + fttmr010->base = of_iomap(np, 0); + if (!fttmr010->base) { pr_err("Can't remap registers"); - return -ENXIO; + ret = -ENXIO; + goto out_free; } /* IRQ for timer 1 */ irq = irq_of_parse_and_map(np, 0); if (irq <= 0) { pr_err("Can't parse IRQ"); - return -EINVAL; + ret = -EINVAL; + goto out_unmap; } /* * Reset the interrupt mask and status */ - writel(TIMER_INT_ALL_MASK, base + TIMER_INTR_MASK); - writel(0, base + TIMER_INTR_STATE); - writel(TIMER_DEFAULT_FLAGS, base + TIMER_CR); + writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); + writel(0, fttmr010->base + TIMER_INTR_STATE); + writel(TIMER_DEFAULT_FLAGS, fttmr010->base + TIMER_CR); /* * Setup free-running clocksource timer (interrupts * disabled.) */ - writel(0, base + TIMER3_COUNT); - writel(0, base + TIMER3_LOAD); - writel(0, base + TIMER3_MATCH1); - writel(0, base + TIMER3_MATCH2); - clocksource_mmio_init(base + TIMER3_COUNT, - "fttmr010_clocksource", tick_rate, + local_fttmr = fttmr010; + writel(0, fttmr010->base + TIMER3_COUNT); + writel(0, fttmr010->base + TIMER3_LOAD); + writel(0, fttmr010->base + TIMER3_MATCH1); + writel(0, fttmr010->base + TIMER3_MATCH2); + clocksource_mmio_init(fttmr010->base + TIMER3_COUNT, + "FTTMR010-TIMER3", + fttmr010->tick_rate, 300, 32, clocksource_mmio_readl_up); - sched_clock_register(fttmr010_read_sched_clock, 32, tick_rate); + sched_clock_register(fttmr010_read_sched_clock, 32, + fttmr010->tick_rate); /* - * Setup clockevent timer (interrupt-driven.) + * Setup clockevent timer (interrupt-driven) on timer 1. */ - writel(0, base + TIMER1_COUNT); - writel(0, base + TIMER1_LOAD); - writel(0, base + TIMER1_MATCH1); - writel(0, base + TIMER1_MATCH2); - setup_irq(irq, &fttmr010_timer_irq); - fttmr010_clockevent.cpumask = cpumask_of(0); - clockevents_config_and_register(&fttmr010_clockevent, tick_rate, + writel(0, fttmr010->base + TIMER1_COUNT); + writel(0, fttmr010->base + TIMER1_LOAD); + writel(0, fttmr010->base + TIMER1_MATCH1); + writel(0, fttmr010->base + TIMER1_MATCH2); + ret = request_irq(irq, fttmr010_timer_interrupt, IRQF_TIMER, + "FTTMR010-TIMER1", &fttmr010->clkevt); + if (ret) { + pr_err("FTTMR010-TIMER1 no IRQ\n"); + goto out_unmap; + } + + fttmr010->clkevt.name = "FTTMR010-TIMER1"; + /* Reasonably fast and accurate clock event */ + fttmr010->clkevt.rating = 300; + fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | + CLOCK_EVT_FEAT_ONESHOT; + fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event; + fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown; + fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic; + fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot; + fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown; + fttmr010->clkevt.cpumask = cpumask_of(0); + fttmr010->clkevt.irq = irq; + clockevents_config_and_register(&fttmr010->clkevt, + fttmr010->tick_rate, 1, 0xffffffff); return 0; + +out_unmap: + iounmap(fttmr010->base); +out_free: + kfree(fttmr010); +out_disable_clock: + clk_disable_unprepare(clk); + + return ret; } CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init); CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init); From patchwork Thu May 18 20:17:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100124 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6158qge; Thu, 18 May 2017 13:17:52 -0700 (PDT) X-Received: by 10.84.150.131 with SMTP id h3mr6969382plh.103.1495138672418; Thu, 18 May 2017 13:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138672; cv=none; d=google.com; s=arc-20160816; b=DF3hubrWb1vV/UlbY2lltOODUsSKKGRdDyQBvaK98SpyV1/NqQfzHnXk6eKNRWM1C9 hrtseXVCeBkTkvxZUjOoglWmJ8NnEeThwJfMR0AgAi1eVbhKFII7+dBSBOeC90cwNvYL 6yXVtABXT5Cue3Odj8AKgXQXMOWoXhVJI5JtBhxLIN4THHTCUmvyjxj5OCOqP+M0qyu3 /rTKZ7IkzoGeLQPfH61fFmZ55X2ZTd00EeCy75M/iduwLWXe+owVZKvf6Qqo9BJo5JZU m7WMjZXO4umiIn9N8mx8NtkFlxxJEco/iVFVR8NqVDx/55K0MlwZlh1ldf6lze8sTTyH ZE0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=XbzO8hEp9aq9iuqVDfUVydAzCCyg4MzK2/tngoQiBY4=; b=fyz3qaY5JTHWEE2Zq493EA9AHtmgN7NFls4Wv9IwUv09rU2DAcgjcKklpA+RtY7I+P Vts5EKckzCCWquxuIPhP65OZpAE/+A1450k2DeypOqcv56qoPdL3e+0k1KcSH4L9kFFG XAjDOBOjTsWyRQPqoAzo74tpsb04r8Wz0OH7vCRJBDw0Y+8uMVR7Kl0uT4p/D8IxcKqQ XwXl4odGVZM6k2ycZQgKBdXVDEzh/HTe2Q3zrZODPmVmGV6g33vq+PO1p28NMF34Orur 5JfCJ5L7bN9QYmkfmarNlbMnDI2AqyLjMVw7Kv9Uk87VlNoOfTsVQL+sxHaMn/w3vQp7 YJeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 q7si6059160pfd.332.2017.05.18.13.17.52; Thu, 18 May 2017 13:17:52 -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; 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 S1755848AbdERURi (ORCPT + 25 others); Thu, 18 May 2017 16:17:38 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35227 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755695AbdERURc (ORCPT ); Thu, 18 May 2017 16:17:32 -0400 Received: by mail-wm0-f45.google.com with SMTP id b84so214498949wmh.0 for ; Thu, 18 May 2017 13:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XbzO8hEp9aq9iuqVDfUVydAzCCyg4MzK2/tngoQiBY4=; b=BYGnMcSG18lko8lgIhC7wGKMLNrVSN80HO0WBn7puFTRMyODtKNkPGRwM6m8bSc+xz vGlA0Nhuv2lZqShr1DPcUyEZDj2TWhgT6tYDwVRwJyaJEMlqu52VlxPgu/H9Sjc9UuTg aINsXH8btYujO6Uyyhpm0b0jJr+VAxLb3qaPE= 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=XbzO8hEp9aq9iuqVDfUVydAzCCyg4MzK2/tngoQiBY4=; b=OyrM1jwXuRb1hGPeNZWiRM+2QHLtsDNHvV4Z1QwQet1QB4aR0LBTwKod/elDxpb4Xk COKP0xI+FuCn64jHoXFo7bzS6gjbBcH/oQ11oC4dhWdd1SfAYMs/hRZrK7SHFWy8OXTC hreHzs+r6bt3/PqLHCyJozdWbMFJTHDLKqHolEWPYQ5Ub/A8FTDSgqKet4BIHzzpL1p8 dueSfgseoWnIekq1fBkc2BfHDf9hGEZn13tfJr/UhUXpwmpMiJKUVDc9SMu4R5B5cwFW vCmBkR8/1r1iEW5qPqwg87MrpswNj47ei+Seq4Xvxf6Bgzw8SR8rqvx7CSEXbSdsvvrM r1vA== X-Gm-Message-State: AODbwcBGYmpG4A4hyFqhSKI8/yMvYc2TOjgfP13OCIi+6GvXZjgp3Day 74nXqLxJeuqfPp7W X-Received: by 10.25.38.129 with SMTP id m123mr1489832lfm.150.1495138650778; Thu, 18 May 2017 13:17:30 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:29 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 5/8 v2] clocksource/drivers/fttmr010: Switch to use bitops Date: Thu, 18 May 2017 22:17:02 +0200 Message-Id: <20170518201705.28790-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This switches the drivers to use the bitops BIT() macro to define bits. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index 9ad31489bbef..9df14cf13808 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -16,6 +16,7 @@ #include #include #include +#include /* * Register definitions for the timers @@ -36,31 +37,31 @@ #define TIMER_INTR_STATE (0x34) #define TIMER_INTR_MASK (0x38) -#define TIMER_1_CR_ENABLE (1 << 0) -#define TIMER_1_CR_CLOCK (1 << 1) -#define TIMER_1_CR_INT (1 << 2) -#define TIMER_2_CR_ENABLE (1 << 3) -#define TIMER_2_CR_CLOCK (1 << 4) -#define TIMER_2_CR_INT (1 << 5) -#define TIMER_3_CR_ENABLE (1 << 6) -#define TIMER_3_CR_CLOCK (1 << 7) -#define TIMER_3_CR_INT (1 << 8) -#define TIMER_1_CR_UPDOWN (1 << 9) -#define TIMER_2_CR_UPDOWN (1 << 10) -#define TIMER_3_CR_UPDOWN (1 << 11) +#define TIMER_1_CR_ENABLE BIT(0) +#define TIMER_1_CR_CLOCK BIT(1) +#define TIMER_1_CR_INT BIT(2) +#define TIMER_2_CR_ENABLE BIT(3) +#define TIMER_2_CR_CLOCK BIT(4) +#define TIMER_2_CR_INT BIT(5) +#define TIMER_3_CR_ENABLE BIT(6) +#define TIMER_3_CR_CLOCK BIT(7) +#define TIMER_3_CR_INT BIT(8) +#define TIMER_1_CR_UPDOWN BIT(9) +#define TIMER_2_CR_UPDOWN BIT(10) +#define TIMER_3_CR_UPDOWN BIT(11) #define TIMER_DEFAULT_FLAGS (TIMER_1_CR_UPDOWN | \ TIMER_3_CR_ENABLE | \ TIMER_3_CR_UPDOWN) -#define TIMER_1_INT_MATCH1 (1 << 0) -#define TIMER_1_INT_MATCH2 (1 << 1) -#define TIMER_1_INT_OVERFLOW (1 << 2) -#define TIMER_2_INT_MATCH1 (1 << 3) -#define TIMER_2_INT_MATCH2 (1 << 4) -#define TIMER_2_INT_OVERFLOW (1 << 5) -#define TIMER_3_INT_MATCH1 (1 << 6) -#define TIMER_3_INT_MATCH2 (1 << 7) -#define TIMER_3_INT_OVERFLOW (1 << 8) +#define TIMER_1_INT_MATCH1 BIT(0) +#define TIMER_1_INT_MATCH2 BIT(1) +#define TIMER_1_INT_OVERFLOW BIT(2) +#define TIMER_2_INT_MATCH1 BIT(3) +#define TIMER_2_INT_MATCH2 BIT(4) +#define TIMER_2_INT_OVERFLOW BIT(5) +#define TIMER_3_INT_MATCH1 BIT(6) +#define TIMER_3_INT_MATCH2 BIT(7) +#define TIMER_3_INT_OVERFLOW BIT(8) #define TIMER_INT_ALL_MASK 0x1ff struct fttmr010 { From patchwork Thu May 18 20:17:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100127 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6264qge; Thu, 18 May 2017 13:18:12 -0700 (PDT) X-Received: by 10.84.173.195 with SMTP id p61mr7002404plb.83.1495138692730; Thu, 18 May 2017 13:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138692; cv=none; d=google.com; s=arc-20160816; b=FmOPQUzHP0UfJLoO6BCb5QPGXo2D//2b4Vw436YlemuVY3V4DoaGIB2fFGl0LeQCWl GxiAh8k4JuyBeU5UQIU+zwI4yRLeG9/d2vlV0Id40b4HDee9zwtC3fO+lDSMCl8gNX74 3Hi0ZsIwNO2j5N3P+ciCc6T8jg4gVngAzoBJ0/GohryjiDM9syYzj08x2+B1tDHb/BJS xxjyMV08rzAicmGcZRLw0CVCNBc7O1Y0Bpy2x6CT+Il8eqrXuttX2GgVeQed9QRku+6b 8pe3KhuFP9+c7PohOfJUolrsglqHOOCaUyq9JYz+fVami///Dr52z75orpDCRNCqXPdF MumQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=oSPVC/2T5g8tja7hpHKzpYEqqAu3BI3wl4mu4w3COrs=; b=JHRmOTEB2ailNdW5CQE0dh48igUCEzKz6vUlb3+9OO4ShY/XbAcWJMqpEU/abzoEaU PjtQ0w9lsz+sxZf8/Vm4AVOv+VKJ4t6J/c1kpQ0ck7aUa3ytFH++QOy4AnI4JtkI0qip TQgKuMGX45yjywCn64ES3xAV0vFaUZb8upbraNj051EFVEQ3pxbZOlCUxmsd7C1yw5o9 TTQDzofoJ4+1BM5oVzLy/PrANgpy+jd1VN7UqRYZwrsBE9y37Nf1j1K77nV6ih1qMUjN 1KW+5UWz5zU/Yxx3k+H1WqSAZ4Xm6YXG1/suPGo22bsecQK2JO035yZpOMmTwuJOW1eF 8Qeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 b8si4984374ple.2.2017.05.18.13.18.12; Thu, 18 May 2017 13:18:12 -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; 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 S1755946AbdERUSG (ORCPT + 25 others); Thu, 18 May 2017 16:18:06 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:36093 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755890AbdERURo (ORCPT ); Thu, 18 May 2017 16:17:44 -0400 Received: by mail-wr0-f169.google.com with SMTP id l50so3049996wrc.3 for ; Thu, 18 May 2017 13:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oSPVC/2T5g8tja7hpHKzpYEqqAu3BI3wl4mu4w3COrs=; b=ZvvAzINoQEjWYqpf+ZEK1zPNHl3g/Xd0ZppG1KFi0fNk5z0rKphALp/rtISu+LAptF ay1hC9dL9xTUO3gi7WuEusOvps45a3C02+5fIVMRFsqWi8VqDL53y/p/s2jLumgxO6Zn bk3rwfgJuqMcVHG5E7tgIUaRbmyDLMTUaUrf4= 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=oSPVC/2T5g8tja7hpHKzpYEqqAu3BI3wl4mu4w3COrs=; b=sOCyLOIM/3Whyhiw6DU8fTc75g3MRdBAbo6vnUDkOF1n09X3RGlQZ5u/yktogS936W 0qGfnKANFXKJ04xbacW5UOmLJwhDOffCQ45nOkfXn/8uAhOn2fmXC0nq7eZVs4fEZE1U 4EoMfuFjZ0dBIryc/1g6HEQAi7drf4G1f4DnbbNx41hntM5LWLZAeg5noifSh2sgMT/1 KWAPzlmbUvMF+gYx/ovMlrf0TXNrUAhfzbYCWAWzrBlVGymkUx3eDwuiVBF1wzw4rKC+ L/C+jRI9qPYP2CFf0u8hhgO0jKp20nng5cnpTguRtgJUEO9GKZ4fu32i5d1cZK8D9Tq3 SM/Q== X-Gm-Message-State: AODbwcAeZt7d6INfpYmZLDK00yXWXGPBmOmJLka54n/ZjRg4iKuZ1aKN M+ngsd+uPWr3Q3dE X-Received: by 10.46.75.17 with SMTP id y17mr1604542lja.77.1495138653464; Thu, 18 May 2017 13:17:33 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:32 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 6/8 v2] clocksource/drivers/fttmr010: Switch to use TIMER2 src Date: Thu, 18 May 2017 22:17:03 +0200 Message-Id: <20170518201705.28790-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This switches the clocksource to TIMER2 like the Moxart driver does. Mainly to make it more similar to the Moxart/Aspeed driver but also because it seems more neat to use the timers in order: use timer 1, then timer 2. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index 9df14cf13808..2d915d1455ab 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -49,9 +49,6 @@ #define TIMER_1_CR_UPDOWN BIT(9) #define TIMER_2_CR_UPDOWN BIT(10) #define TIMER_3_CR_UPDOWN BIT(11) -#define TIMER_DEFAULT_FLAGS (TIMER_1_CR_UPDOWN | \ - TIMER_3_CR_ENABLE | \ - TIMER_3_CR_UPDOWN) #define TIMER_1_INT_MATCH1 BIT(0) #define TIMER_1_INT_MATCH2 BIT(1) @@ -80,7 +77,7 @@ static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt) static u64 notrace fttmr010_read_sched_clock(void) { - return readl(local_fttmr->base + TIMER3_COUNT); + return readl(local_fttmr->base + TIMER2_COUNT); } static int fttmr010_timer_set_next_event(unsigned long cycles, @@ -230,19 +227,21 @@ static int __init fttmr010_timer_init(struct device_node *np) */ writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); writel(0, fttmr010->base + TIMER_INTR_STATE); - writel(TIMER_DEFAULT_FLAGS, fttmr010->base + TIMER_CR); + /* Enable timer 1 count up, timer 2 count up */ + writel((TIMER_1_CR_UPDOWN | TIMER_2_CR_ENABLE | TIMER_2_CR_UPDOWN), + fttmr010->base + TIMER_CR); /* * Setup free-running clocksource timer (interrupts * disabled.) */ local_fttmr = fttmr010; - writel(0, fttmr010->base + TIMER3_COUNT); - writel(0, fttmr010->base + TIMER3_LOAD); - writel(0, fttmr010->base + TIMER3_MATCH1); - writel(0, fttmr010->base + TIMER3_MATCH2); - clocksource_mmio_init(fttmr010->base + TIMER3_COUNT, - "FTTMR010-TIMER3", + writel(0, fttmr010->base + TIMER2_COUNT); + writel(0, fttmr010->base + TIMER2_LOAD); + writel(0, fttmr010->base + TIMER2_MATCH1); + writel(0, fttmr010->base + TIMER2_MATCH2); + clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, + "FTTMR010-TIMER2", fttmr010->tick_rate, 300, 32, clocksource_mmio_readl_up); sched_clock_register(fttmr010_read_sched_clock, 32, From patchwork Thu May 18 20:17:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100125 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6160qge; Thu, 18 May 2017 13:17:52 -0700 (PDT) X-Received: by 10.98.206.201 with SMTP id y192mr6328602pfg.60.1495138672822; Thu, 18 May 2017 13:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138672; cv=none; d=google.com; s=arc-20160816; b=wR6yGHopNWbtZJcm7XYtrnhDoN3srKx8qUOLRCSM6S/3HbSdMtTwiUt6vlPJJnKf7E htvLSi4L6HRmPO9WKFBl3vjXtEZwOVso0NGnN+youpBLswOcnlQlAIUHXFjjTUeF1yJ1 v+9GsUdHaiBt26XsjVkkWL9dqhJt5zxDSOXJRN3Sfhj9zcXrHHRu235zbe7pas7CZBiZ pdzJT/gqUtkjkd2lMXPU6NUIODHZ2E0Kxb6XIBgAIZ/Obm+cD1pPuqdlkuNEm8dqwsPN OfNJ76z9v2rURxnyXY1aNB5d1AS5+0puRck067meFWm67xDmOIKto5lJk5Hm3ZHGMRRa j47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aib2xmMFgaTAZ8whiaE/8eyAGwOD5wp/nkKySufxu4Q=; b=OqNCPpel+BTRaVyiuUB4O+VRp99wq8gB5vlI4EgqKoEfqIflWcrQFcPB+phFNh2dsM I1RFccEwcxyOiwPt6RuLFNQGAVD05vKI8rEZwzcLhsrYZFuGOBYHargGe0VD/vUAemQ4 jI2zU6k4a7oRG9G+14npzCA2aVH/OFqkh6Br+I+fCJarLFViR5bLXI3+lXNuW891DGYM jahqdYVK7mv6/Hl2KkraUXT1XATLcrvsVkpe9aN8aP3CKgNa+Uq3tVCbcv957/wu07ax 4ODs7Vk16BolsWRq46vglWYt07mlDEW9x558rDzbM8yS0ZIME61WUGqz52vgTGU68rRs zDKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 q7si6059160pfd.332.2017.05.18.13.17.52; Thu, 18 May 2017 13:17:52 -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; 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 S1755898AbdERURp (ORCPT + 25 others); Thu, 18 May 2017 16:17:45 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:33815 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755784AbdERURi (ORCPT ); Thu, 18 May 2017 16:17:38 -0400 Received: by mail-wr0-f181.google.com with SMTP id l9so3072232wre.1 for ; Thu, 18 May 2017 13:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aib2xmMFgaTAZ8whiaE/8eyAGwOD5wp/nkKySufxu4Q=; b=LXlFJADd3lYh+6PMd4JoLHuGOqQ1VRMe7SqFCOfL43UtoixJROC/ek3QEHFd+koPj5 AgfKHDT/fNn06ri9xJG0xgKf+WES0DVq9mOwiMkDZqN19EolzsxJaRKKxpddjs5GpSUu V+Mq/79FeQsAgvqooWAvh7Mk7a5mWO8iuP34I= 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=aib2xmMFgaTAZ8whiaE/8eyAGwOD5wp/nkKySufxu4Q=; b=Syi4DWMsFbRHAfV6CBfgBoYb0NISCHefYXwlYAPhUVg3iHVj0K4g4eZBBMdgOZAdrt N/VmdjmCtQjbFiFYuayrKaX+ZojOoj/nS3yFn5Qm62pqQ24FxLwmRJqsM6f4lOjjK7FK qqpdbx1sA8q/+PyE5uqPIKdDqXYWy2qYFb4T3uIPNRb1zr8gp2kwOd8iaVjpU2QPJDFF +0uDo3jjV1Cs/rVxeF9brb0/9hUAgYygmCdJOtWKGD8PYkJXdVtzQJ+yQ41JIfOLF65u OZJBKRGsT1Sja876AzvimMDFP9UdjeFHgnUcPhBWb0EDT4rIgPNTlu1YvrfD8W/ldmSw 2Xog== X-Gm-Message-State: AODbwcDSp5Gdeq+uHswGGTY7PwthObx+sBibtDuCjyqS5YD1lv8EbYMs pEZodzz2p+XRiY6S X-Received: by 10.46.84.94 with SMTP id y30mr1527791ljd.114.1495138656428; Thu, 18 May 2017 13:17:36 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:35 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010 Date: Thu, 18 May 2017 22:17:04 +0200 Message-Id: <20170518201705.28790-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This merges the Moxa Art timer driver into the Faraday FTTMR010 driver and replaces all Kconfig symbols to use the Faraday driver instead. We are now so similar that the drivers can be merged by just adding a few lines to the Faraday timer. Differences: - The Faraday driver explicitly sets the counter to count upwards for the clocksource, removing the need for the clocksource core to invert the value. - The Faraday driver also handles sched_clock() On the Aspeed, the counter can only count downwards, so support the timers in downward-counting mode as well, and flag the Aspeed to use this mode. This mode was tested on the Gemini so I have high hopes that it'll work fine on the Aspeed as well. After this we have one driver for all three SoCs and a generic Faraday FTTMR010 timer driver, which is nice. Cc: Joel Stanley Cc: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - As it appears that the Aspeed timers can only count downwards, augment the code to deal with downward counting clockevent, clock source and sched_clock(), and flag the Aspeed for this mode. ARM SoC folks: please ACK this so it can be merged with in the clocksource subsystem once it works. Joel: it would be super if you can test this. If you have some vendor tree or similar that actually indicates where the up/down counter bits are it's even better, but I'm hoping that this half-assed guesswork will JustWork(TM) (yeah, famous last words, sorry...) --- arch/arm/mach-aspeed/Kconfig | 2 +- arch/arm/mach-moxart/Kconfig | 2 +- drivers/clocksource/Kconfig | 7 - drivers/clocksource/Makefile | 1 - drivers/clocksource/moxart_timer.c | 256 ----------------------------------- drivers/clocksource/timer-fttmr010.c | 143 ++++++++++++++----- 6 files changed, 108 insertions(+), 303 deletions(-) delete mode 100644 drivers/clocksource/moxart_timer.c -- 2.9.3 Reviewed-by: Joel Stanley Tested-by: Joel Stanley Tested-by: Jonas Jensen diff --git a/arch/arm/mach-aspeed/Kconfig b/arch/arm/mach-aspeed/Kconfig index f3f8c5c658db..2d5570e6e186 100644 --- a/arch/arm/mach-aspeed/Kconfig +++ b/arch/arm/mach-aspeed/Kconfig @@ -4,7 +4,7 @@ menuconfig ARCH_ASPEED select SRAM select WATCHDOG select ASPEED_WATCHDOG - select MOXART_TIMER + select FTTMR010_TIMER select MFD_SYSCON select PINCTRL help diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig index 70db2abf6163..a4a91f9a3301 100644 --- a/arch/arm/mach-moxart/Kconfig +++ b/arch/arm/mach-moxart/Kconfig @@ -4,7 +4,7 @@ menuconfig ARCH_MOXART select CPU_FA526 select ARM_DMA_MEM_BUFFERABLE select FARADAY_FTINTC010 - select MOXART_TIMER + select FTTMR010_TIMER select GPIOLIB select PHYLIB if NETDEVICES help diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 545d541ae20e..1b22ade4c8f1 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -188,13 +188,6 @@ config ATLAS7_TIMER help Enables support for the Atlas7 timer. -config MOXART_TIMER - bool "Moxart timer driver" if COMPILE_TEST - depends on GENERIC_CLOCKEVENTS - select CLKSRC_MMIO - help - Enables support for the Moxart timer. - config MXS_TIMER bool "Mxs timer driver" if COMPILE_TEST depends on GENERIC_CLOCKEVENTS diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 2b5b56a6f00f..cf0c30b6ec1f 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -26,7 +26,6 @@ obj-$(CONFIG_ORION_TIMER) += time-orion.o obj-$(CONFIG_BCM2835_TIMER) += bcm2835_timer.o obj-$(CONFIG_CLPS711X_TIMER) += clps711x-timer.o obj-$(CONFIG_ATLAS7_TIMER) += timer-atlas7.o -obj-$(CONFIG_MOXART_TIMER) += moxart_timer.o obj-$(CONFIG_MXS_TIMER) += mxs_timer.o obj-$(CONFIG_CLKSRC_PXA) += pxa_timer.o obj-$(CONFIG_PRIMA2_TIMER) += timer-prima2.o diff --git a/drivers/clocksource/moxart_timer.c b/drivers/clocksource/moxart_timer.c deleted file mode 100644 index 7f3430654fbd..000000000000 --- a/drivers/clocksource/moxart_timer.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * MOXA ART SoCs timer handling. - * - * Copyright (C) 2013 Jonas Jensen - * - * Jonas Jensen - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TIMER1_BASE 0x00 -#define TIMER2_BASE 0x10 -#define TIMER3_BASE 0x20 - -#define REG_COUNT 0x0 /* writable */ -#define REG_LOAD 0x4 -#define REG_MATCH1 0x8 -#define REG_MATCH2 0xC - -#define TIMER_CR 0x30 -#define TIMER_INTR_STATE 0x34 -#define TIMER_INTR_MASK 0x38 - -/* - * Moxart TIMER_CR flags: - * - * MOXART_CR_*_CLOCK 0: PCLK, 1: EXT1CLK - * MOXART_CR_*_INT overflow interrupt enable bit - */ -#define MOXART_CR_1_ENABLE BIT(0) -#define MOXART_CR_1_CLOCK BIT(1) -#define MOXART_CR_1_INT BIT(2) -#define MOXART_CR_2_ENABLE BIT(3) -#define MOXART_CR_2_CLOCK BIT(4) -#define MOXART_CR_2_INT BIT(5) -#define MOXART_CR_3_ENABLE BIT(6) -#define MOXART_CR_3_CLOCK BIT(7) -#define MOXART_CR_3_INT BIT(8) -#define MOXART_CR_COUNT_UP BIT(9) - -#define MOXART_TIMER1_ENABLE (MOXART_CR_2_ENABLE | MOXART_CR_1_ENABLE) -#define MOXART_TIMER1_DISABLE (MOXART_CR_2_ENABLE) - -/* - * The ASpeed variant of the IP block has a different layout - * for the control register - */ -#define ASPEED_CR_1_ENABLE BIT(0) -#define ASPEED_CR_1_CLOCK BIT(1) -#define ASPEED_CR_1_INT BIT(2) -#define ASPEED_CR_2_ENABLE BIT(4) -#define ASPEED_CR_2_CLOCK BIT(5) -#define ASPEED_CR_2_INT BIT(6) -#define ASPEED_CR_3_ENABLE BIT(8) -#define ASPEED_CR_3_CLOCK BIT(9) -#define ASPEED_CR_3_INT BIT(10) - -#define ASPEED_TIMER1_ENABLE (ASPEED_CR_2_ENABLE | ASPEED_CR_1_ENABLE) -#define ASPEED_TIMER1_DISABLE (ASPEED_CR_2_ENABLE) - -struct moxart_timer { - void __iomem *base; - unsigned int t1_disable_val; - unsigned int t1_enable_val; - unsigned int count_per_tick; - struct clock_event_device clkevt; -}; - -static inline struct moxart_timer *to_moxart(struct clock_event_device *evt) -{ - return container_of(evt, struct moxart_timer, clkevt); -} - -static inline void moxart_disable(struct clock_event_device *evt) -{ - struct moxart_timer *timer = to_moxart(evt); - - writel(timer->t1_disable_val, timer->base + TIMER_CR); -} - -static inline void moxart_enable(struct clock_event_device *evt) -{ - struct moxart_timer *timer = to_moxart(evt); - - writel(timer->t1_enable_val, timer->base + TIMER_CR); -} - -static int moxart_shutdown(struct clock_event_device *evt) -{ - moxart_disable(evt); - return 0; -} - -static int moxart_set_oneshot(struct clock_event_device *evt) -{ - moxart_disable(evt); - writel(~0, to_moxart(evt)->base + TIMER1_BASE + REG_LOAD); - return 0; -} - -static int moxart_set_periodic(struct clock_event_device *evt) -{ - struct moxart_timer *timer = to_moxart(evt); - - moxart_disable(evt); - writel(timer->count_per_tick, timer->base + TIMER1_BASE + REG_LOAD); - writel(0, timer->base + TIMER1_BASE + REG_MATCH1); - moxart_enable(evt); - return 0; -} - -static int moxart_clkevt_next_event(unsigned long cycles, - struct clock_event_device *evt) -{ - struct moxart_timer *timer = to_moxart(evt); - u32 u; - - moxart_disable(evt); - - u = readl(timer->base + TIMER1_BASE + REG_COUNT) - cycles; - writel(u, timer->base + TIMER1_BASE + REG_MATCH1); - - moxart_enable(evt); - - return 0; -} - -static irqreturn_t moxart_timer_interrupt(int irq, void *dev_id) -{ - struct clock_event_device *evt = dev_id; - evt->event_handler(evt); - return IRQ_HANDLED; -} - -static int __init moxart_timer_init(struct device_node *node) -{ - int ret, irq; - unsigned long pclk; - struct clk *clk; - struct moxart_timer *timer; - - timer = kzalloc(sizeof(*timer), GFP_KERNEL); - if (!timer) - return -ENOMEM; - - timer->base = of_iomap(node, 0); - if (!timer->base) { - pr_err("%s: of_iomap failed\n", node->full_name); - ret = -ENXIO; - goto out_free; - } - - irq = irq_of_parse_and_map(node, 0); - if (irq <= 0) { - pr_err("%s: irq_of_parse_and_map failed\n", node->full_name); - ret = -EINVAL; - goto out_unmap; - } - - clk = of_clk_get(node, 0); - if (IS_ERR(clk)) { - pr_err("%s: of_clk_get failed\n", node->full_name); - ret = PTR_ERR(clk); - goto out_unmap; - } - - pclk = clk_get_rate(clk); - - if (of_device_is_compatible(node, "moxa,moxart-timer")) { - timer->t1_enable_val = MOXART_TIMER1_ENABLE; - timer->t1_disable_val = MOXART_TIMER1_DISABLE; - } else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) { - timer->t1_enable_val = ASPEED_TIMER1_ENABLE; - timer->t1_disable_val = ASPEED_TIMER1_DISABLE; - } else { - pr_err("%s: unknown platform\n", node->full_name); - ret = -EINVAL; - goto out_unmap; - } - - timer->count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ); - - timer->clkevt.name = node->name; - timer->clkevt.rating = 200; - timer->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | - CLOCK_EVT_FEAT_ONESHOT; - timer->clkevt.set_state_shutdown = moxart_shutdown; - timer->clkevt.set_state_periodic = moxart_set_periodic; - timer->clkevt.set_state_oneshot = moxart_set_oneshot; - timer->clkevt.tick_resume = moxart_set_oneshot; - timer->clkevt.set_next_event = moxart_clkevt_next_event; - timer->clkevt.cpumask = cpumask_of(0); - timer->clkevt.irq = irq; - - ret = clocksource_mmio_init(timer->base + TIMER2_BASE + REG_COUNT, - "moxart_timer", pclk, 200, 32, - clocksource_mmio_readl_down); - if (ret) { - pr_err("%s: clocksource_mmio_init failed\n", node->full_name); - goto out_unmap; - } - - ret = request_irq(irq, moxart_timer_interrupt, IRQF_TIMER, - node->name, &timer->clkevt); - if (ret) { - pr_err("%s: setup_irq failed\n", node->full_name); - goto out_unmap; - } - - /* Clear match registers */ - writel(0, timer->base + TIMER1_BASE + REG_MATCH1); - writel(0, timer->base + TIMER1_BASE + REG_MATCH2); - writel(0, timer->base + TIMER2_BASE + REG_MATCH1); - writel(0, timer->base + TIMER2_BASE + REG_MATCH2); - - /* - * Start timer 2 rolling as our main wall clock source, keep timer 1 - * disabled - */ - writel(0, timer->base + TIMER_CR); - writel(~0, timer->base + TIMER2_BASE + REG_LOAD); - writel(timer->t1_disable_val, timer->base + TIMER_CR); - - /* - * documentation is not publicly available: - * min_delta / max_delta obtained by trial-and-error, - * max_delta 0xfffffffe should be ok because count - * register size is u32 - */ - clockevents_config_and_register(&timer->clkevt, pclk, 0x4, 0xfffffffe); - - return 0; - -out_unmap: - iounmap(timer->base); -out_free: - kfree(timer); - return ret; -} -CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); -CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init); diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index 2d915d1455ab..f8801507a687 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -50,6 +50,20 @@ #define TIMER_2_CR_UPDOWN BIT(10) #define TIMER_3_CR_UPDOWN BIT(11) +/* + * The Aspeed AST2400 moves bits around in the control register + * and lacks bits for setting the timer to count upwards. + */ +#define TIMER_1_CR_ASPEED_ENABLE BIT(0) +#define TIMER_1_CR_ASPEED_CLOCK BIT(1) +#define TIMER_1_CR_ASPEED_INT BIT(2) +#define TIMER_2_CR_ASPEED_ENABLE BIT(4) +#define TIMER_2_CR_ASPEED_CLOCK BIT(5) +#define TIMER_2_CR_ASPEED_INT BIT(6) +#define TIMER_3_CR_ASPEED_ENABLE BIT(8) +#define TIMER_3_CR_ASPEED_CLOCK BIT(9) +#define TIMER_3_CR_ASPEED_INT BIT(10) + #define TIMER_1_INT_MATCH1 BIT(0) #define TIMER_1_INT_MATCH2 BIT(1) #define TIMER_1_INT_OVERFLOW BIT(2) @@ -64,6 +78,8 @@ struct fttmr010 { void __iomem *base; unsigned int tick_rate; + bool count_down; + u32 t1_enable_val; struct clock_event_device clkevt; }; @@ -77,6 +93,8 @@ static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt) static u64 notrace fttmr010_read_sched_clock(void) { + if (local_fttmr->count_down) + return ~readl(local_fttmr->base + TIMER2_COUNT); return readl(local_fttmr->base + TIMER2_COUNT); } @@ -86,11 +104,23 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, struct fttmr010 *fttmr010 = to_fttmr010(evt); u32 cr; - /* Setup the match register */ + /* Stop */ + cr = readl(fttmr010->base + TIMER_CR); + cr &= ~fttmr010->t1_enable_val; + writel(cr, fttmr010->base + TIMER_CR); + + /* Setup the match register forward/backward in time */ cr = readl(fttmr010->base + TIMER1_COUNT); - writel(cr + cycles, fttmr010->base + TIMER1_MATCH1); - if (readl(fttmr010->base + TIMER1_COUNT) - cr > cycles) - return -ETIME; + if (fttmr010->count_down) + cr -= cycles; + else + cr += cycles; + writel(cr, fttmr010->base + TIMER1_MATCH1); + + /* Start */ + cr = readl(fttmr010->base + TIMER_CR); + cr |= fttmr010->t1_enable_val; + writel(cr, fttmr010->base + TIMER_CR); return 0; } @@ -100,9 +130,9 @@ static int fttmr010_timer_shutdown(struct clock_event_device *evt) struct fttmr010 *fttmr010 = to_fttmr010(evt); u32 cr; - /* Stop timer and interrupt. */ + /* Stop */ cr = readl(fttmr010->base + TIMER_CR); - cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); + cr &= ~fttmr010->t1_enable_val; writel(cr, fttmr010->base + TIMER_CR); return 0; @@ -113,14 +143,17 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) struct fttmr010 *fttmr010 = to_fttmr010(evt); u32 cr; - /* Stop timer and interrupt. */ + /* Stop */ cr = readl(fttmr010->base + TIMER_CR); - cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); + cr &= ~fttmr010->t1_enable_val; writel(cr, fttmr010->base + TIMER_CR); - /* Setup counter start from 0 */ + /* Setup counter start from 0 or ~0 */ writel(0, fttmr010->base + TIMER1_COUNT); - writel(0, fttmr010->base + TIMER1_LOAD); + if (fttmr010->count_down) + writel(~0, fttmr010->base + TIMER1_LOAD); + else + writel(0, fttmr010->base + TIMER1_LOAD); /* Enable interrupt */ cr = readl(fttmr010->base + TIMER_INTR_MASK); @@ -128,11 +161,6 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) cr |= TIMER_1_INT_MATCH1; writel(cr, fttmr010->base + TIMER_INTR_MASK); - /* Start the timer */ - cr = readl(fttmr010->base + TIMER_CR); - cr |= TIMER_1_CR_ENABLE; - writel(cr, fttmr010->base + TIMER_CR); - return 0; } @@ -142,26 +170,30 @@ static int fttmr010_timer_set_periodic(struct clock_event_device *evt) u32 period = DIV_ROUND_CLOSEST(fttmr010->tick_rate, HZ); u32 cr; - /* Stop timer and interrupt */ + /* Stop */ cr = readl(fttmr010->base + TIMER_CR); - cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); + cr &= ~fttmr010->t1_enable_val; writel(cr, fttmr010->base + TIMER_CR); - /* Setup timer to fire at 1/HT intervals. */ - cr = 0xffffffff - (period - 1); - writel(cr, fttmr010->base + TIMER1_COUNT); - writel(cr, fttmr010->base + TIMER1_LOAD); - - /* enable interrupt on overflow */ - cr = readl(fttmr010->base + TIMER_INTR_MASK); - cr &= ~(TIMER_1_INT_MATCH1 | TIMER_1_INT_MATCH2); - cr |= TIMER_1_INT_OVERFLOW; - writel(cr, fttmr010->base + TIMER_INTR_MASK); + /* Setup timer to fire at 1/HZ intervals. */ + if (fttmr010->count_down) { + writel(period, fttmr010->base + TIMER1_LOAD); + writel(0, fttmr010->base + TIMER1_MATCH1); + } else { + cr = 0xffffffff - (period - 1); + writel(cr, fttmr010->base + TIMER1_COUNT); + writel(cr, fttmr010->base + TIMER1_LOAD); + + /* Enable interrupt on overflow */ + cr = readl(fttmr010->base + TIMER_INTR_MASK); + cr &= ~(TIMER_1_INT_MATCH1 | TIMER_1_INT_MATCH2); + cr |= TIMER_1_INT_OVERFLOW; + writel(cr, fttmr010->base + TIMER_INTR_MASK); + } /* Start the timer */ cr = readl(fttmr010->base + TIMER_CR); - cr |= TIMER_1_CR_ENABLE; - cr |= TIMER_1_CR_INT; + cr |= fttmr010->t1_enable_val; writel(cr, fttmr010->base + TIMER_CR); return 0; @@ -181,9 +213,11 @@ static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id) static int __init fttmr010_timer_init(struct device_node *np) { struct fttmr010 *fttmr010; + bool is_ast2400; int irq; struct clk *clk; int ret; + u32 val; /* * These implementations require a clock reference. @@ -223,13 +257,37 @@ static int __init fttmr010_timer_init(struct device_node *np) } /* + * The Aspeed AST2400 moves bits around in the control register, + * otherwise it works the same. + */ + is_ast2400 = of_device_is_compatible(np, "aspeed,ast2400-timer"); + if (is_ast2400) { + fttmr010->t1_enable_val = TIMER_1_CR_ASPEED_ENABLE | + TIMER_1_CR_ASPEED_INT; + /* Downward not available */ + fttmr010->count_down = true; + } else { + fttmr010->t1_enable_val = TIMER_1_CR_ENABLE | TIMER_1_CR_INT; + } + + /* * Reset the interrupt mask and status */ writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); writel(0, fttmr010->base + TIMER_INTR_STATE); - /* Enable timer 1 count up, timer 2 count up */ - writel((TIMER_1_CR_UPDOWN | TIMER_2_CR_ENABLE | TIMER_2_CR_UPDOWN), - fttmr010->base + TIMER_CR); + + /* + * Enable timer 1 count up, timer 2 count up, except on Aspeed, + * where everything just counts down. + */ + if (is_ast2400) + val = TIMER_2_CR_ASPEED_ENABLE; + else { + val = TIMER_2_CR_ENABLE; + if (!fttmr010->count_down) + val |= TIMER_1_CR_UPDOWN | TIMER_2_CR_UPDOWN; + } + writel(val, fttmr010->base + TIMER_CR); /* * Setup free-running clocksource timer (interrupts @@ -237,13 +295,22 @@ static int __init fttmr010_timer_init(struct device_node *np) */ local_fttmr = fttmr010; writel(0, fttmr010->base + TIMER2_COUNT); - writel(0, fttmr010->base + TIMER2_LOAD); writel(0, fttmr010->base + TIMER2_MATCH1); writel(0, fttmr010->base + TIMER2_MATCH2); - clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, - "FTTMR010-TIMER2", - fttmr010->tick_rate, - 300, 32, clocksource_mmio_readl_up); + + if (fttmr010->count_down) { + writel(~0, fttmr010->base + TIMER2_LOAD); + clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, + "FTTMR010-TIMER2", + fttmr010->tick_rate, + 300, 32, clocksource_mmio_readl_down); + } else { + writel(0, fttmr010->base + TIMER2_LOAD); + clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, + "FTTMR010-TIMER2", + fttmr010->tick_rate, + 300, 32, clocksource_mmio_readl_up); + } sched_clock_register(fttmr010_read_sched_clock, 32, fttmr010->tick_rate); @@ -290,3 +357,5 @@ static int __init fttmr010_timer_init(struct device_node *np) } CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init); CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init); +CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", fttmr010_timer_init); +CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", fttmr010_timer_init); From patchwork Thu May 18 20:17:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100126 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6258qge; Thu, 18 May 2017 13:18:12 -0700 (PDT) X-Received: by 10.84.233.136 with SMTP id l8mr7135242plk.169.1495138692279; Thu, 18 May 2017 13:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138692; cv=none; d=google.com; s=arc-20160816; b=aa/Qc0dp3L/9hm714ZltBhCjuBGu3HYGREGw/XQStDmSbOCK7bqdUmVs48Y1M/VB+l Fl4ULjIUIVjE9bH4yUQlYFtSjK7Zj9zVIDILuZ+HOCLWVFDo8aeBFgmJUjkepRTEPXwp y7cUsotx3aIohNSjDAeZGRPHBT1pm19g3D+kgJtdnsUGBpEke5WBNFm6Cpc2v74TAZmK t8MMAx+d2QufRS1qAd1iYqdAwoSXcXTUt+fG1pNYnzfAgI3qJ6RVFalLyzSRyBLQClqM AYZG99naApj/l5J9plsPCnHr7Fm6IiobJNwwDq/+86Mv9uJ3EizmMUT2hnj0cVElsKfe eP/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Kaua6rsUJY/iLiGOrQwCcbKInAvi9J1tZHeMkR2P2uc=; b=RrMxehUzxHKtxJI2WLnOGCI4xkM8f2nqHbh6DM9YepMqJ12o7Rom1kzE3OefJqauyU hsN2mQpzK1BJgyA+MjBzlSyF5c/4NL3JLngXOe5Z/Q0ntXfPrntyS4O/T3xjDs0YqOdx RmCiBX0lPZZwqBAVu6PrG8ULw5WphDvqyuNkqyb1/MrgChIRHwDb1G1Upd+eCj0isHIS qWR17dXY3cih8tjxlS9Jr/GViyX6nEbLTh3TtI+d11OwWmAg990lIWSXHbzGM17QmvBB ++pwJOa7/HLqIgjuazuEF6/Q8959YeHjqoFGj8kXm5SuNuQvb2gfxXYcvx8l6QmK0+X0 gblQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 b8si4984374ple.2.2017.05.18.13.18.11; Thu, 18 May 2017 13:18:12 -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; 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 S1755925AbdERURv (ORCPT + 25 others); Thu, 18 May 2017 16:17:51 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:38649 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755695AbdERURk (ORCPT ); Thu, 18 May 2017 16:17:40 -0400 Received: by mail-wm0-f42.google.com with SMTP id v15so65053414wmv.1 for ; Thu, 18 May 2017 13:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kaua6rsUJY/iLiGOrQwCcbKInAvi9J1tZHeMkR2P2uc=; b=ANwuRREDCb8IQ/IhybNI8y4d4GrDcQziRx1xMYUuum4UdjJDnpZdmHX3MKr4pryl96 2Ir6xPPAMSc1to+a2QNESOoiMn+ccnbtfXGuuyym7e3OhZiMuzP4m38ulJvgyja91D2y bwEbjYqQxi5LomYUJ+Hs+ezYky67tfxfGIcsQ= 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=Kaua6rsUJY/iLiGOrQwCcbKInAvi9J1tZHeMkR2P2uc=; b=Wy9wIE5IOXvInk5Ekrp36AWsKj9JrAa171j9onBk+P9emXW5rL/6pM1LM37Oqi6uWn sCQHoB7QbntN+eZXrJWTRcvS3DNaGQ6B6NQ8MzVjDAiBZUe9sbQEhPB1e0L1v4pu/v+n nTUUVPg6gC5RaVQP/vK2uksRc+0ZQcs4gZEiH5mp7h48Qe+7/8m0DQq2mEpamEBOJdXv 3B0MP+57oylXyRyes7NsDvKmAuH6eGXrQks3+7DHPWBSSLP1ri5JAqpTv5lPnr+V3zzy WKaqSG60uooSaFe2m98dkPzRDZOKMEw4dfodVJ9QnNHgot6M8t1ew0lfEYiMShNlpeLN 6i5w== X-Gm-Message-State: AODbwcDOHa2RRebWPDOljUTrRn6xMSlzyvLOFYcr/x3auyxP6LcDj6+m 0aN8Ch6lKY1dFal3 X-Received: by 10.25.158.17 with SMTP id h17mr1307468lfe.2.1495138659224; Thu, 18 May 2017 13:17:39 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:37 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 8/8 v2] ARM: dts: augment Moxa and Aspeed DTS for FTTMR010 Date: Thu, 18 May 2017 22:17:05 +0200 Message-Id: <20170518201705.28790-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This augments the Moxa Art and Aspeed device trees to: - Explicitly name the clock "PCLK" as the Faraday FTTMR010 names it. - List the Moxa timer as compatible with the Faradat FTTMR010 vanilla version. - Add a comment that the Aspeed driver is a Faraday FTTMR010 derivative. - Pass all IRQs to the timer from Aspeed: they are all there so they should be in the device tree, we only use the first one anyways. Cc: Joel Stanley Cc: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix a syntax error in the g5 DTSI file. Clocksource maintainers: I will ask the ARM SoC people to merge this patch orthogonally, it is only included in this series for reference and for testing. --- arch/arm/boot/dts/aspeed-g4.dtsi | 7 +++---- arch/arm/boot/dts/aspeed-g5.dtsi | 7 +++---- arch/arm/boot/dts/moxart.dtsi | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) -- 2.9.3 diff --git a/arch/arm/boot/dts/aspeed-g4.dtsi b/arch/arm/boot/dts/aspeed-g4.dtsi index 8c6bc29eb7f6..8a04c7e2d818 100644 --- a/arch/arm/boot/dts/aspeed-g4.dtsi +++ b/arch/arm/boot/dts/aspeed-g4.dtsi @@ -886,13 +886,12 @@ }; timer: timer@1e782000 { + /* This timer is a Faraday FTTMR010 derivative */ compatible = "aspeed,ast2400-timer"; reg = <0x1e782000 0x90>; - // The moxart_timer driver registers only one - // interrupt and assumes it's for timer 1 - //interrupts = <16 17 18 35 36 37 38 39>; - interrupts = <16>; + interrupts = <16 17 18 35 36 37 38 39>; clocks = <&clk_apb>; + clock-names = "PCLK"; }; wdt1: wdt@1e785000 { diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index a0bea4a6ec77..9cffe347b828 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -993,13 +993,12 @@ }; timer: timer@1e782000 { + /* This timer is a Faraday FTTMR010 derivative */ compatible = "aspeed,ast2400-timer"; reg = <0x1e782000 0x90>; - // The moxart_timer driver registers only one - // interrupt and assumes it's for timer 1 - //interrupts = <16 17 18 35 36 37 38 39>; - interrupts = <16>; + interrupts = <16 17 18 35 36 37 38 39>; clocks = <&clk_apb>; + clock-names = "PCLK"; }; diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi index e86f8c905ac5..1f4c795d3f72 100644 --- a/arch/arm/boot/dts/moxart.dtsi +++ b/arch/arm/boot/dts/moxart.dtsi @@ -58,10 +58,11 @@ }; timer: timer@98400000 { - compatible = "moxa,moxart-timer"; + compatible = "moxa,moxart-timer", "faraday,fttmr010"; reg = <0x98400000 0x42>; interrupts = <19 IRQ_TYPE_EDGE_FALLING>; clocks = <&clk_apb>; + clock-names = "PCLK"; }; gpio: gpio@98700000 {