From patchwork Mon Oct 19 15:01:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 7437771 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 B396ABEEA4 for ; Mon, 19 Oct 2015 15:04:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA8482075F for ; Mon, 19 Oct 2015 15:04:27 +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 EC3A8206FF for ; Mon, 19 Oct 2015 15:04: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 1ZoBxJ-0005AR-2x; Mon, 19 Oct 2015 15:02:33 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoBxG-00056R-DR for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2015 15:02:31 +0000 Received: by wikq8 with SMTP id q8so10018992wik.1 for ; Mon, 19 Oct 2015 08:02:08 -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=MsJv+OSp+UB2+MEQKf2TI9Putst8anSPKsbs0p+VpAA=; b=RgrDCIKVTvz36PzKtrIqrd0RY2xLYgprwtYtRKPrvf+i5JoxrzTfmKIPYig0pOEhQ6 4qQr1WZnbWIOI3Az6udKchhNwpdlLAFhrU++thXkzUcBDZxDih9plDyWX//kzak6V0ck kxlxwGSUXzQZonc+qLNPzBf2wXgXH+GpoghrZBvgKqUX2frkzjLqOk5gHUUQChyir6pU I1Ex241W5ltBc9oUZ838ml6BvUmoDpQYsGpo1IsYIGHYT1z3Cz6V0nHUa+9ahwXB9+S2 zxx9kS80tbMZYqrnazBVmcXt+m0sG+IjsKlh3iOZejefST4m6Ww7uK7EMt9O9oHbb0Q8 9HrQ== X-Gm-Message-State: ALoCoQl8px1Y+FeAYBUDdBcXxCct6JIb+cy4WhGY2AnVI23ThlDvSyKvvWAqQmxs+favMt4eFXyN X-Received: by 10.180.12.206 with SMTP id a14mr22412617wic.25.1445266927544; Mon, 19 Oct 2015 08:02:07 -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 p7sm40698772wjf.26.2015.10.19.08.02.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 08:02:06 -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 v2 1/3] arm: plat-omap: dmtimer: Add clock source from DT Organization: Baylibre Message-ID: <562505E5.1040706@baylibre.com> Date: Mon, 19 Oct 2015 17:01:57 +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-20151019_080230_654395_247467B7 X-CRM114-Status: GOOD ( 16.63 ) 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, 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 | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 8ca94d3..7c7f260 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -137,6 +137,31 @@ 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; + + /* + * FIXME: OMAP1 devices do not use the clock framework for dmtimers so + * do not call clk_get() for these devices. + */ + if (!timer->fclk) + return -ENODEV; + + 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; @@ -166,7 +191,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); + rc = omap_dm_timer_of_set_source(timer); + if (rc == -ENODEV) + return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ); + + return rc; } static inline u32 omap_dm_timer_reserved_systimer(int id)