From patchwork Mon Nov 2 11:14:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 7535681 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 337D7BEEA4 for ; Mon, 2 Nov 2015 11:22:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D5222057F for ; Mon, 2 Nov 2015 11:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 401DC20573 for ; Mon, 2 Nov 2015 11:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752333AbbKBLWZ (ORCPT ); Mon, 2 Nov 2015 06:22:25 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38858 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbbKBLWZ (ORCPT ); Mon, 2 Nov 2015 06:22:25 -0500 Received: by wmeg8 with SMTP id g8so57618954wme.1 for ; Mon, 02 Nov 2015 03:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre_com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:organization:message-id:date:user-agent :mime-version:content-type:content-transfer-encoding; bh=MsJv+OSp+UB2+MEQKf2TI9Putst8anSPKsbs0p+VpAA=; b=yK4+FZsfVbG3vaDFcazORfE7adB/rd04n47XfMIzNap9VDrXCXbbbuY09UpG60t26e 7Xcmi82roTCn9EtdOAMSy9qHk4ii2jfrHX6npKhuqxESUdwyPZaOAir5LzShlYCweDI5 Kr8mLIV+CM1Nmyfh+ER9YMGuYDiAsJ88Ca+0zRfOjpRCkXSi/Wcp5J6XLDe9NeopYobW h5ldE5R0UwJyPEO04Gr64Ptq5k4es7Aenq2qiT6KtfI4BgvGGlVXgNYqiDuK4fnnCBwz tg0lCaC9wp50wnOktA1s39pduuygXzAOAMRfhIT8p2OH69hf56HKyaNKnyBGpKOxI9LR QVQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:organization:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding; bh=MsJv+OSp+UB2+MEQKf2TI9Putst8anSPKsbs0p+VpAA=; b=haGYHJsOuKjCZDKpcmDkfvKBm6D5pBB5DmMuLe63OcHToKe+V24tEW6JXnTeJ8llql QCvKK99yzH3LbEJeZPgXNqCU8LpEEPxgi7b1t7aduNc1XbMs3FzPdH1Xl+DVY0/di7ZB xajvEgY3S09zpDHZevSiDOezi62dECCJYbvEDZ/iu50E9sFDX0SexHF9SseMpxnOrbc2 PEkBhyTnTMo0gZreQVp3wduuXuAdJDSrF/dLp5iIFP7f9D9klscoALIsJi+hc7gPHsvK iiiOkw2ZareKk0GzUSWZmHlYfWtSLsCPMkyG/wGYM4VgwOxFq6iz8tALvwyRCEiFRHr1 qkrw== X-Gm-Message-State: ALoCoQlEuB4YBV2h8hUADFuTI3oVuSOCCyTS0QITggz5zynyytkJ5fvC6Pu9KA+qfNWzeoyZxVfz X-Received: by 10.28.87.67 with SMTP id l64mr11961407wmb.72.1446462864627; Mon, 02 Nov 2015 03:14:24 -0800 (PST) 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 r13sm17554986wmg.12.2015.11.02.03.14.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2015 03:14:23 -0800 (PST) From: Neil Armstrong Subject: [PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT 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 Organization: Baylibre Message-ID: <56374586.1040700@baylibre.com> Date: Mon, 2 Nov 2015 12:14:14 +0100 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 | 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)