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: 7414541 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CE1CA9F443 for ; Fri, 16 Oct 2015 12:28:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EECE920A6B for ; Fri, 16 Oct 2015 12:28:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09C3B20A64 for ; Fri, 16 Oct 2015 12:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753865AbbJPM1h (ORCPT ); Fri, 16 Oct 2015 08:27:37 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:34078 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753835AbbJPM1f (ORCPT ); Fri, 16 Oct 2015 08:27:35 -0400 Received: by wicgb1 with SMTP id gb1so7475787wic.1 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=TTrQ2rvynRKqU4dJp2x2hOKfOIfmsIr7Rvv/6JfFsY9mWv8t30CEAGvJ9S6h78g7Ps lvCzQrVOt5+DHlaI3sUBZvS7jH5OYbKtPnTwmbyBRyZRAf5MfYC9TBsFoWao1X7kB9uq vUtVpcvKenQpTMp0WdNmchvgZqSTsOjLKwlDERpRGBJ6xMgwru2+n9eEoCTT1Uqivrg4 48qytSilOpB+PDuXEH4yjiAsKTX38+gh4+xfqzWEMkVww0DsKD1MAPwZ2ncam29K1Bpa bki4m3bYYytBVvib+yuO2WOr0OX90PTYPQo2/eendJVA12Fiy54AnOkfLIg9sTglnZbj HPnQ== X-Gm-Message-State: ALoCoQkfxkHfnMafeV4b/OP4YsmQ8Lnn2q7MC8gv7SgA7XODM9PCadFQHTMUsKq6gaak8Ss8PJmU 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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)