From patchwork Wed Jul 2 08:47:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 32948 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f70.google.com (mail-qg0-f70.google.com [209.85.192.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B85720560 for ; Wed, 2 Jul 2014 08:48:08 +0000 (UTC) Received: by mail-qg0-f70.google.com with SMTP id z60sf10622805qgd.9 for ; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=umO+aP7zm61jGxJlpcpnBAulyK+TcwnKcKSMtn2N/Xg=; b=KZVXxNYv0vRO2ixxhPPyhqS+gHycNAeAhf6AbXj2to07DODvQrsP+dZ1EQ98C/zqcg zf5QbeW0HDELLPGtJpTHAxF+XypM++tbEEO02eIi4LVdT3q9ex2I/ia1GCVGQtrbJORe zHfhqEE0FH/f95bbGYSc8QhU62iC+MbLcACBWXiZj5OcN0XPbnnM+utjG7aiOCTL6gyx y7F+JTRfWGs6WiTGpBM9SN0xbV+jBdpuJskspGMnknVtzDcHzyrmctqszh5EmICDhf1h RL25fvMhvMr0CmDu2pXKdmXCWTwS+WycwonJO4ouIT9nrST0kbKTsZDGBxuRdyn54Qcg cgOg== X-Gm-Message-State: ALoCoQk20UeImHtG2OjQQF60Jx+Od9J0SpWyg8GHSPDPQP7AT+g/syu7M/9yvG5DJcnDY/Uqg6o7 X-Received: by 10.58.111.40 with SMTP id if8mr27478641veb.40.1404290887857; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.178 with SMTP id w47ls2310899qge.55.gmail; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) X-Received: by 10.220.53.72 with SMTP id l8mr48769077vcg.16.1404290887766; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id u8si12626427vey.74.2014.07.02.01.48.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 01:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so10128386vcb.12 for ; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) X-Received: by 10.58.188.199 with SMTP id gc7mr44536710vec.4.1404290887693; Wed, 02 Jul 2014 01:48:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp277218vcb; Wed, 2 Jul 2014 01:48:07 -0700 (PDT) X-Received: by 10.66.179.111 with SMTP id df15mr2517889pac.52.1404290886898; Wed, 02 Jul 2014 01:48:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl5si29620598pad.108.2014.07.02.01.48.06; Wed, 02 Jul 2014 01:48:06 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbaGBIsD (ORCPT + 6 others); Wed, 2 Jul 2014 04:48:03 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:55673 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbaGBIr7 (ORCPT ); Wed, 2 Jul 2014 04:47:59 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s628le4h031657; Wed, 2 Jul 2014 03:47:40 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s628leOF013335; Wed, 2 Jul 2014 03:47:40 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 2 Jul 2014 03:47:40 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s628lOXd007645; Wed, 2 Jul 2014 03:47:39 -0500 From: Tero Kristo To: , , , CC: Subject: [PATCH 07/13] ARM: OMAP2+: clock/dpll: add private API for checking if DPLL is in bypass Date: Wed, 2 Jul 2014 11:47:41 +0300 Message-ID: <1404290867-6768-8-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404290867-6768-1-git-send-email-t-kristo@ti.com> References: <1404290867-6768-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: t-kristo@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently, same functionality is copy pasted in two locations. Instead, add a private API for this and get rid of some duplicated code. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/clkt_dpll.c | 60 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c index 5207e84..f1b052a 100644 --- a/arch/arm/mach-omap2/clkt_dpll.c +++ b/arch/arm/mach-omap2/clkt_dpll.c @@ -175,6 +175,33 @@ static int _dpll_test_mult(int *m, int n, unsigned long *new_rate, return r; } +/** + * _omap2_dpll_is_in_bypass - check if DPLL is in bypass mode or not + * @v: bitfield value of the DPLL enable + * + * Checks given DPLL enable bitfield to see whether the DPLL is in bypass + * mode or not. Returns 1 if the DPLL is in bypass, 0 otherwise. + */ +static int _omap2_dpll_is_in_bypass(u32 v) +{ + if (cpu_is_omap24xx()) { + if (v == OMAP2XXX_EN_DPLL_LPBYPASS || + v == OMAP2XXX_EN_DPLL_FRBYPASS) + return 1; + } else if (cpu_is_omap34xx()) { + if (v == OMAP3XXX_EN_DPLL_LPBYPASS || + v == OMAP3XXX_EN_DPLL_FRBYPASS) + return 1; + } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx()) { + if (v == OMAP4XXX_EN_DPLL_LPBYPASS || + v == OMAP4XXX_EN_DPLL_FRBYPASS || + v == OMAP4XXX_EN_DPLL_MNBYPASS) + return 1; + } + + return 0; +} + /* Public functions */ u8 omap2_init_dpll_parent(struct clk_hw *hw) { @@ -191,20 +218,9 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw) v >>= __ffs(dd->enable_mask); /* Reparent the struct clk in case the dpll is in bypass */ - if (cpu_is_omap24xx()) { - if (v == OMAP2XXX_EN_DPLL_LPBYPASS || - v == OMAP2XXX_EN_DPLL_FRBYPASS) - return 1; - } else if (cpu_is_omap34xx()) { - if (v == OMAP3XXX_EN_DPLL_LPBYPASS || - v == OMAP3XXX_EN_DPLL_FRBYPASS) - return 1; - } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx()) { - if (v == OMAP4XXX_EN_DPLL_LPBYPASS || - v == OMAP4XXX_EN_DPLL_FRBYPASS || - v == OMAP4XXX_EN_DPLL_MNBYPASS) - return 1; - } + if (_omap2_dpll_is_in_bypass(v)) + return 1; + return 0; } @@ -237,20 +253,8 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk) v &= dd->enable_mask; v >>= __ffs(dd->enable_mask); - if (cpu_is_omap24xx()) { - if (v == OMAP2XXX_EN_DPLL_LPBYPASS || - v == OMAP2XXX_EN_DPLL_FRBYPASS) - return __clk_get_rate(dd->clk_bypass); - } else if (cpu_is_omap34xx()) { - if (v == OMAP3XXX_EN_DPLL_LPBYPASS || - v == OMAP3XXX_EN_DPLL_FRBYPASS) - return __clk_get_rate(dd->clk_bypass); - } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx()) { - if (v == OMAP4XXX_EN_DPLL_LPBYPASS || - v == OMAP4XXX_EN_DPLL_FRBYPASS || - v == OMAP4XXX_EN_DPLL_MNBYPASS) - return __clk_get_rate(dd->clk_bypass); - } + if (_omap2_dpll_is_in_bypass(v)) + return __clk_get_rate(dd->clk_bypass); v = omap2_clk_readl(clk, dd->mult_div1_reg); dpll_mult = v & dd->mult_mask;