From patchwork Fri Oct 3 13:57:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 38319 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8158E2057C for ; Fri, 3 Oct 2014 13:58:03 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b57sf844818eek.4 for ; Fri, 03 Oct 2014 06:58:02 -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=x6cnI8yKiQNDSoUI5HN7yK4bXTcSkirOzxC1mGz52r4=; b=Y2QNAHc0+atQjgJTtRnmCMT/MY8aYuOvkh0HA+3SxDnqKUDDCZuM3NHXqwfYjpEF+4 WE/TuyL4EEWLsxdIURxFwJy1stgPszqNDSKeD/R8bqd/3OBxAe3oPMg0m9V4ngRX3r3j HKBkDuiKQcaDPqDDWSHPakhQqjJd9KYQvP8ZXyaW8T0GqIyHIPVc/tQngPGnPCUs4xQD OyGrBD7wy0KOoHB3fkJDWoeG43juAyCSAeIMvt7w03pHDjq7Mbu8vd8RhYYyMgBC0bae th227WqzfRo35LeNlIQuzR0NzD9HjOvxQuORF9Ts3fwJtzUXEuppL9x3ksp/xIkl5q0p WDxA== X-Gm-Message-State: ALoCoQm76hO0+n55Gm873f4ZfoReV7JiO2K+id23hprSKf0BBraUu7PKOiDPLXlSs7pjpb7iGWXx X-Received: by 10.181.8.226 with SMTP id dn2mr1857969wid.4.1412344682648; Fri, 03 Oct 2014 06:58:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.201 with SMTP id je9ls277498lac.92.gmail; Fri, 03 Oct 2014 06:58:02 -0700 (PDT) X-Received: by 10.112.147.74 with SMTP id ti10mr5786882lbb.29.1412344682268; Fri, 03 Oct 2014 06:58:02 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id tl10si11207934lbb.131.2014.10.03.06.58.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 06:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so1019044lbv.26 for ; Fri, 03 Oct 2014 06:58:02 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr6266147lad.40.1412344682143; Fri, 03 Oct 2014 06:58:02 -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.112.130.169 with SMTP id of9csp231225lbb; Fri, 3 Oct 2014 06:58:01 -0700 (PDT) X-Received: by 10.70.91.204 with SMTP id cg12mr874411pdb.47.1412344680522; Fri, 03 Oct 2014 06:58:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gs8si7375428pac.40.2014.10.03.06.57.59 for ; Fri, 03 Oct 2014 06:58:00 -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 S1752702AbaJCN57 (ORCPT + 5 others); Fri, 3 Oct 2014 09:57:59 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:52954 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752469AbaJCN57 (ORCPT ); Fri, 3 Oct 2014 09:57:59 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s93DvSLb025406; Fri, 3 Oct 2014 08:57:28 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s93DvSfx019914; Fri, 3 Oct 2014 08:57:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 3 Oct 2014 08:57:27 -0500 Received: from sokoban.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s93DvJfd007112; Fri, 3 Oct 2014 08:57:26 -0500 From: Tero Kristo To: , , , CC: Subject: [PATCH 3/5] ARM: OMAP4: clock: add support for determine_rate for omap4 regm4xen DPLL Date: Fri, 3 Oct 2014 16:57:12 +0300 Message-ID: <1412344634-2798-4-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1412344634-2798-1-git-send-email-t-kristo@ti.com> References: <1412344634-2798-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.217.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: , Similarly to OMAP3 noncore DPLL, the implementation of this DPLL clock type is wrong. This patch adds basic functionality for determine_rate for this clock type which will be taken into use in the patches following later. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/dpll44xx.c | 41 ++++++++++++++++++++++++++++++++++++++++ include/linux/clk/ti.h | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/arch/arm/mach-omap2/dpll44xx.c b/arch/arm/mach-omap2/dpll44xx.c index 4613f1e..535822f 100644 --- a/arch/arm/mach-omap2/dpll44xx.c +++ b/arch/arm/mach-omap2/dpll44xx.c @@ -207,3 +207,44 @@ out: return dd->last_rounded_rate; } + +/** + * omap4_dpll_regm4xen_determine_rate - determine rate for a DPLL + * @hw: pointer to the clock to determine rate for + * @rate: target rate for the DPLL + * @best_parent_rate: pointer for returning best parent rate + * @best_parent_clk: pointer for returning best parent clock + * + * Determines which DPLL mode to use for reaching a desired rate. + * Checks whether the DPLL shall be in bypass or locked mode, and if + * locked, calculates the M,N values for the DPLL via round-rate. + * Returns a positive clock rate with success, negative error value + * in failure. + */ +long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *best_parent_rate, + struct clk **best_parent_clk) +{ + struct clk_hw_omap *clk = to_clk_hw_omap(hw); + struct dpll_data *dd; + + if (!hw || !rate) + return -EINVAL; + + dd = clk->dpll_data; + if (!dd) + return -EINVAL; + + if (__clk_get_rate(dd->clk_bypass) == rate && + (dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) { + *best_parent_clk = dd->clk_bypass; + } else { + rate = omap4_dpll_regm4xen_round_rate(hw, rate, + best_parent_rate); + *best_parent_clk = dd->clk_ref; + } + + *best_parent_rate = rate; + + return rate; +} diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h index 47d0c63..541dc33 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -270,6 +270,10 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw, unsigned long target_rate, unsigned long *parent_rate); +long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, + unsigned long rate, + unsigned long *best_parent_rate, + struct clk **best_parent_clk); u8 omap2_init_dpll_parent(struct clk_hw *hw); unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate); long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,