From patchwork Sat Apr 20 14:09:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 2468041 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 5C4FCDF2A1 for ; Sat, 20 Apr 2013 14:10:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYU8-0000s9-Of; Sat, 20 Apr 2013 14:09:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYU0-0006iH-UO; Sat, 20 Apr 2013 14:09:40 +0000 Received: from mail-lb0-f171.google.com ([209.85.217.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYTr-0006hQ-Lu for linux-arm-kernel@lists.infradead.org; Sat, 20 Apr 2013 14:09:33 +0000 Received: by mail-lb0-f171.google.com with SMTP id v10so4463051lbd.2 for ; Sat, 20 Apr 2013 07:09:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=Gd3Ca1E5OaGKdxJcXz3wsDaE8BTpVMO8quyZQMb5hfk=; b=mvhvkDyCMqf5UwdYDZjZBtfwZDtKFvKpA5v0NiLpL1PFJP254pRE6KThTx6AByZAyj dY42jMGcQKGCBIV4e8QbFCuFpRuzbQy3wX5wZoY6K2CBGf5xd60PF8rmmLJhMQHLRkwS r4wHgoELkD8fTgsFd26CPB75zpTOlZC0X+Hrl/RgGEKdaE+4gjYFlmQaw5BL2cD8SFXe 7RW3j6yBGtze/oCjzEKzNbulfIRK8fbAg/1Aeqck4vhv6cviZNOw8SA8RZoimrNP19Ea pY5dbQSL6hA9RoxeqrAuvY7IJoCFDczKjHIdo+Hlw1fPwyXZp8OzPrKnPm1lmUzfECFH /lRQ== X-Received: by 10.112.140.1 with SMTP id rc1mr9995482lbb.43.1366466969514; Sat, 20 Apr 2013 07:09:29 -0700 (PDT) Received: from localhost.localdomain (c83-249-208-67.bredband.comhem.se. [83.249.208.67]) by mx.google.com with ESMTPS id q4sm7464512lbi.14.2013.04.20.07.09.27 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 20 Apr 2013 07:09:28 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] clocksource: nomadik-mtu: support of probe Date: Sat, 20 Apr 2013 16:09:26 +0200 Message-Id: <1366466966-16082-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Gm-Message-State: ALoCoQk/81O95Fx6emnqh3693se60amNSCaT38sVvM7kazVFY7QFLbgujOdmgcFM9fCQP0GsBrKV X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130420_100931_911833_CF8E2C7D X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.171 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Rabin Vincent X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rabin Vincent Support device tree probe of the nomadik-mtu clocksource. Signed-off-by: Rabin Vincent --- drivers/clocksource/nomadik-mtu.c | 70 ++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/drivers/clocksource/nomadik-mtu.c b/drivers/clocksource/nomadik-mtu.c index e405531..7982cb0 100644 --- a/drivers/clocksource/nomadik-mtu.c +++ b/drivers/clocksource/nomadik-mtu.c @@ -13,6 +13,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -188,22 +191,15 @@ static struct irqaction nmdk_timer_irq = { .dev_id = &nmdk_clkevt, }; -void __init nmdk_timer_init(void __iomem *base, int irq) +static void __init __nmdk_timer_init(void __iomem *base, int irq, + struct clk *pclk, struct clk *clk) { unsigned long rate; - struct clk *clk0, *pclk0; mtu_base = base; - pclk0 = clk_get_sys("mtu0", "apb_pclk"); - BUG_ON(IS_ERR(pclk0)); - BUG_ON(clk_prepare(pclk0) < 0); - BUG_ON(clk_enable(pclk0) < 0); - - clk0 = clk_get_sys("mtu0", NULL); - BUG_ON(IS_ERR(clk0)); - BUG_ON(clk_prepare(clk0) < 0); - BUG_ON(clk_enable(clk0) < 0); + BUG_ON(clk_prepare_enable(pclk)); + BUG_ON(clk_prepare_enable(clk)); /* * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz @@ -213,7 +209,7 @@ void __init nmdk_timer_init(void __iomem *base, int irq) * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer * with 16 gives too low timer resolution. */ - rate = clk_get_rate(clk0); + rate = clk_get_rate(clk); if (rate > 32000000) { rate /= 16; clk_prescale = MTU_CRn_PRESCALE_16; @@ -247,3 +243,53 @@ void __init nmdk_timer_init(void __iomem *base, int irq) mtu_delay_timer.freq = rate; register_current_timer_delay(&mtu_delay_timer); } + +void __init nmdk_timer_init(void __iomem *base, int irq) +{ + struct clk *clk0, *pclk0; + + pclk0 = clk_get_sys("mtu0", "apb_pclk"); + BUG_ON(IS_ERR(pclk0)); + clk0 = clk_get_sys("mtu0", NULL); + BUG_ON(IS_ERR(clk0)); + + __nmdk_timer_init(base, irq, pclk0, clk0); +} + +static struct of_device_id nmdk_timer_match[] __initconst = { + { .compatible = "st,nomadik-mtu" }, + {} +}; + +static void __init nmdk_timer_of_init(void) +{ + struct device_node *node; + struct clk *pclk; + struct clk *clk; + void __iomem *base; + int irq; + + node = of_find_matching_node(NULL, nmdk_timer_match); + if (!node) + panic("No timer node"); + + base = of_iomap(node, 0); + if (!base) + panic("Can't remap registers"); + + pclk = of_clk_get_by_name(node, "apb_pclk"); + if (IS_ERR(pclk)) + panic("could not get apb_pclk"); + + clk = of_clk_get_by_name(node, "timclk"); + if (IS_ERR(clk)) + panic("could not get timclk"); + + irq = irq_of_parse_and_map(node, 0); + if (irq <= 0) + panic("Can't parse IRQ"); + + __nmdk_timer_init(base, irq, pclk, clk); +} +CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu", + nmdk_timer_of_init);