From patchwork Fri Oct 16 12:27:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 7414551 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 96873BEEA4 for ; Fri, 16 Oct 2015 12:29:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9819E20A6B for ; Fri, 16 Oct 2015 12:29:52 +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 9D73220A64 for ; Fri, 16 Oct 2015 12:29:51 +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 1Zn47B-00083o-8P; Fri, 16 Oct 2015 12:28:05 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zn472-0007vh-AX for linux-arm-kernel@lists.infradead.org; Fri, 16 Oct 2015 12:27:57 +0000 Received: by wijq8 with SMTP id q8so8324906wij.0 for ; Fri, 16 Oct 2015 05:27:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:organization:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding; bh=R+8QsW6Yyg/MuIntQajOHkt5NRappWn7aEQHkKzm34g=; b=Zp1+MHHMh6iRoBpTyTNyCjqkysrc8njjGzjPxqAK4ytqRQAXOC+AO/VmxjfeJivcte xr+t1NfAXuFiVQtByX+z/G621H2ur0ybyMBGfNBQZXAVLEIGG87Pn8nxsQYfizqaNMJE ZOQ/HwnBXzyLE/UB2D+woLUxnTzvRaGCuIqC680cOIuSK1qoiCZ0flYkzFRKjbccLB7H 26onimrKSXZk1iLV2q8fe3NaJ2bvAidK1h0exMQN6vw1n3m0ZkXydNZBaVRgsvgH3n1Q 1WO8laeoyAzzNoR4Ah6dVtk/MNdWoBpkEMIPlOfELv++oHgD7hNp5F9r6mfshzPK/piU WnXw== X-Gm-Message-State: ALoCoQm1XOtp89Hie1jFEiOG6GZYf2Yfoc0jlKRlKHOfPzc6grtLSDJKZeAjyFRcWB1XcnGF79ds X-Received: by 10.194.158.68 with SMTP id ws4mr18096649wjb.25.1444998454428; Fri, 16 Oct 2015 05:27:34 -0700 (PDT) Received: from [192.168.2.52] (cag06-6-78-235-100-105.fbx.proxad.net. [78.235.100.105]) by smtp.gmail.com with ESMTPSA id t7sm3081179wib.1.2015.10.16.05.27.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 05:27:33 -0700 (PDT) From: Neil Armstrong To: Thierry Reding , Tony Lindgren , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, Grant Erickson , NeilBrown , Joachim Eastwood Subject: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT Organization: Baylibre Message-ID: <5620ED30.2050507@baylibre.com> Date: Fri, 16 Oct 2015 14:27:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151016_052756_567619_F39D36E8 X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -2.0 (--) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 Add a function which sets the timer source from the clocks binding on dm_timer_prepare call. In case the clocks property is not valid, it falls back to the set_source() with 32_KHZ clock as default. Suggested-by: Tony Lindgren Signed-off-by: Neil Armstrong --- arch/arm/plat-omap/dmtimer.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 8ca94d3..5e8aece 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -137,9 +137,33 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer) return 0; } +static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer) +{ + int ret; + struct clk *parent; + + if (unlikely(!timer)) + return -EINVAL; + + if (IS_ERR(timer->fclk)) + return -EINVAL; + + parent = clk_get(&timer->pdev->dev, NULL); + if (IS_ERR(parent)) + return -ENODEV; + + ret = clk_set_parent(timer->fclk, parent); + if (ret < 0) + pr_err("%s: failed to set parent\n", __func__); + + clk_put(parent); + + return ret; +} + static int omap_dm_timer_prepare(struct omap_dm_timer *timer) { - int rc; + int rc, ret; /* * FIXME: OMAP1 devices do not use the clock framework for dmtimers so @@ -166,7 +190,11 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer) __omap_dm_timer_enable_posted(timer); omap_dm_timer_disable(timer); - return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ); + ret = omap_dm_timer_of_set_source(timer); + if (ret < 0 && ret == -ENODEV) + return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ); + + return ret; } static inline u32 omap_dm_timer_reserved_systimer(int id)