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: 7437751 Return-Path: X-Original-To: patchwork-linux-omap@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 E1B89BEEA4 for ; Mon, 19 Oct 2015 15:02:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AD802077C for ; Mon, 19 Oct 2015 15:02:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E75412075F for ; Mon, 19 Oct 2015 15:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753833AbbJSPCL (ORCPT ); Mon, 19 Oct 2015 11:02:11 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:33307 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753801AbbJSPCJ (ORCPT ); Mon, 19 Oct 2015 11:02:09 -0400 Received: by wijp11 with SMTP id p11so10522263wij.0 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=Wtt/kY1bwi3k9PDY5N8r5/UV1K+b6RQmE05X7k20Yuj8lcH13qn7d9SvhbKQe01WZO J5zhjRLO8YCqDqOTaVI5UG+zp8HE1zBOxgZ5Jz742vuPCeJzoX1iL+mvkp0V06jF+FFH Kpm4h6M8fkFuhWgEp4VrFC9vVlQWvSb5NaCO/7psw5oeMV0u9Uw05EMi0SNCMdv7EtZx kIb2C1lDqOI6VfJQiN55XWxWaW1C/fneR4b+8+2QHG22rRNx4cKt0Bi2YVfZB4ewUaso Cegy2ndmUvUzEidohGEYZA6vL4peP9MCocHpXPFb5LEcByQtgKa1BGxsujSOONK+gSyA r4oA== X-Gm-Message-State: ALoCoQn9c+gwZMZlcU5c7BiTOxh7bp6xeS7w7/4a/8YfcGZom8wLxjdCeR389bbdkV2gko0m0dgg 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 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, 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)