From patchwork Mon May 9 12:32:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 9046391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 064B2BF29F for ; Mon, 9 May 2016 12:50:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2484200C1 for ; Mon, 9 May 2016 12:50:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEBF1200DB for ; Mon, 9 May 2016 12:50:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1azkcT-0003z2-2d; Mon, 09 May 2016 12:49:05 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1azkcK-0003Y5-HJ for linux-arm-kernel@bombadil.infradead.org; Mon, 09 May 2016 12:48:56 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1azkNb-0002aJ-58 for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2016 12:33:44 +0000 Received: by mail-pa0-x234.google.com with SMTP id bt5so71881451pac.3 for ; Mon, 09 May 2016 05:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N+zMpIVceuCoMwuorig/SYbrzwvYBjLl46SoVmdMcE4=; b=kmQeRxkZA/AK8vfQvdODNoGmLLkIzk+4s8cbyVC8NoM3fRJeGm0mG8f+V7i36rko2o /nZcdKeG3Fw6Vl64VGzN05+J2igbbAm2SKzG8PVzB74nPkCpSd0u4d8tTKUKSvdBryMl c0RJGI3v6sIvgvkfEtWef2l1xIdIA/FhpBSLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N+zMpIVceuCoMwuorig/SYbrzwvYBjLl46SoVmdMcE4=; b=ILqCCMTTIRyrHGTz4gyNT8Z0RLygFl37clqE+AbFpIsfcVhW1075d80xuY8/Ts7QJi XY7DCrWedVgoYl9qIER4sMsUzpW8O5Y/zV+gpg9ZZbWxKGvo2pKP0PzaDq690oiRwGGV 97TIYK8Fu+7b0RjMaOZHeA9QedgS/Ug2+ZW0t/Qa37IJJhvro87cYHYgiOE6if8sux7e E+sQhINOYRNhIvxNQCQp7xDeJjqUsGJDEdSm/0PyFzgdREJQT1Iy8/EIzRCmqMsB9vEP 4gYoEMmAB8n1/8rFq6EgHSso+dI6wWAzwqDc9Tl/z3kmJtyopQnSa00yla05GFgGXEEi OhOw== X-Gm-Message-State: AOPr4FW4JtFdgufyimbZKCjWrkapuTVQx/qRolvesYtrqli3vVCfMnz95WjXI4fJtG3oCQ== X-Received: by 10.66.167.40 with SMTP id zl8mr50405285pab.8.1462797199970; Mon, 09 May 2016 05:33:19 -0700 (PDT) Received: from icarus.au.ibm.com ([2403:480:11:10:3400:b218:cbe9:48cb]) by smtp.gmail.com with ESMTPSA id e2sm34452101pfd.20.2016.05.09.05.33.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 May 2016 05:33:19 -0700 (PDT) From: Joel Stanley To: daniel.lezcano@linaro.org, tglx@linutronix.de, jonas.jensen@gmail.com Subject: [PATCH 4/4] drivers/clocksource/moxart: Add Aspeed support Date: Mon, 9 May 2016 22:02:49 +0930 Message-Id: <1462797169-14512-5-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1462797169-14512-1-git-send-email-joel@jms.id.au> References: <1462797169-14512-1-git-send-email-joel@jms.id.au> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160509_133343_363423_C3075E3F X-CRM114-Status: GOOD ( 19.09 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, arnd@arndb.de, jk@ozlabs.org, linux-arm-kernel@lists.infradead.org, benh@kernel.crashing.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Aspeed SoC has timer IP with a very similar register layout to the moxart timer. This patch adds support for the fourth and fifth gen aspeed SoCs, and has been tested on the ast2400 and ast2500. Signed-off-by: Joel Stanley Acked-by: Rob Herring --- .../bindings/timer/moxa,moxart-timer.txt | 4 ++- drivers/clocksource/moxart_timer.c | 32 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt b/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt index da2d510cae47..e207c11630af 100644 --- a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt +++ b/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt @@ -2,7 +2,9 @@ MOXA ART timer Required properties: -- compatible : Must be "moxa,moxart-timer" +- 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 diff --git a/drivers/clocksource/moxart_timer.c b/drivers/clocksource/moxart_timer.c index d17e3eface87..83ffa2727699 100644 --- a/drivers/clocksource/moxart_timer.c +++ b/drivers/clocksource/moxart_timer.c @@ -56,6 +56,23 @@ #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; @@ -159,6 +176,9 @@ static void __init moxart_timer_init(struct device_node *node) 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 panic("%s: unknown platform\n", node->full_name); @@ -189,6 +209,17 @@ static void __init moxart_timer_init(struct device_node *node) if (ret) panic("%s: setup_irq failed\n", node->full_name); + /* 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); @@ -201,3 +232,4 @@ static void __init moxart_timer_init(struct device_node *node) clockevents_config_and_register(&timer->clkevt, pclk, 0x4, 0xfffffffe); } CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); +CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init);