From patchwork Fri Jul 29 13:58:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 9252525 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D202601C0 for ; Fri, 29 Jul 2016 13:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02162280DE for ; Fri, 29 Jul 2016 13:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA9E528111; Fri, 29 Jul 2016 13:58:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0633280DE for ; Fri, 29 Jul 2016 13:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbcG2N6f (ORCPT ); Fri, 29 Jul 2016 09:58:35 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35722 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbcG2N6e (ORCPT ); Fri, 29 Jul 2016 09:58:34 -0400 Received: by mail-pf0-f174.google.com with SMTP id x72so33176628pfd.2 for ; Fri, 29 Jul 2016 06:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=8wn0qEq3i2Xalz8YLkYC1A7vfh+BmezbvDCQGmD9a3I=; b=DL3YRfob6yYVgODhWUEHK/oNcoaoyxgXQNPS2KAt+KczEWICjkEB2bcE8Fmg8THYbI ZUazRq0LEpF7C9npuzuv7SVUhFK8WHIb/b8dwvKSK9HkVErqvX3Eobv7PoVmX2XJkiES CYlefLfT7no8N5pLrcbi+vjrZtQ/q21d43kDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8wn0qEq3i2Xalz8YLkYC1A7vfh+BmezbvDCQGmD9a3I=; b=AcomE3GYKs1F5pgLmwXcl7ntfG6jFmwz8hE6DcL2wpNP9Dwv21Wyzgeumz8s8ktqTE tSy9t0uKjj9HFIGSS92UAN2vOrmTfWls5aXIr/bGEeoHYFP8qqd1oLrXJM1mgAlDREKX fGa/L5sbStpVPOPyUNAhh4MdHN5GFJ+lGdW6h/C1x4onRtIhzvcloCNLRvADNiaNa+uF R+UnDkNyuFLVsxENhRxjokjlwt/12p+SGxnUbZvbFhQs/Xu9JiJbzv9UwmCdeDm8I1vo lY8yIMAgkkbj1UjppNEtesDJ7lwWZZ/SwbIHtTGDgnja/ZPJgIpnP6j1S4PZTdZAHgPP MaiA== X-Gm-Message-State: AEkoous30dne9GnRARpIOCrUYO5Cu+gUsES2jA3GZRsx9WzL3gXYwFqf5Z0sBwn+GyIgJYhl X-Received: by 10.98.64.193 with SMTP id f62mr69235975pfd.141.1469800714174; Fri, 29 Jul 2016 06:58:34 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.92]) by smtp.gmail.com with ESMTPSA id d3sm25410445pfk.37.2016.07.29.06.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 06:58:33 -0700 (PDT) From: Jun Nie To: mturquette@baylibre.com, sboyd@codeaurora.org, linux-clk@vger.kernel.org Cc: shawn.guo@linaro.org, jason.liu@linaro.org, Jun Nie Subject: [PATCH v2 1/2] clk: zx: reform pll config info to ease code extension Date: Fri, 29 Jul 2016 21:58:17 +0800 Message-Id: <1469800698-9374-1-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add power down bit and pll lock bit in pll config structure to ease new SoC support. Signed-off-by: Jun Nie --- drivers/clk/zte/clk.c | 21 ++++++++++++--------- drivers/clk/zte/clk.h | 4 ++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/clk/zte/clk.c b/drivers/clk/zte/clk.c index 7c73c53..c4c1251 100644 --- a/drivers/clk/zte/clk.c +++ b/drivers/clk/zte/clk.c @@ -21,8 +21,8 @@ #define to_clk_zx_audio(_hw) container_of(_hw, struct clk_zx_audio, hw) #define CFG0_CFG1_OFFSET 4 -#define LOCK_FLAG BIT(30) -#define POWER_DOWN BIT(31) +#define LOCK_FLAG 30 +#define POWER_DOWN 31 static int rate_to_idx(struct clk_zx_pll *zx_pll, unsigned long rate) { @@ -50,8 +50,8 @@ static int hw_to_idx(struct clk_zx_pll *zx_pll) hw_cfg1 = readl_relaxed(zx_pll->reg_base + CFG0_CFG1_OFFSET); /* For matching the value in lookup table */ - hw_cfg0 &= ~LOCK_FLAG; - hw_cfg0 |= POWER_DOWN; + hw_cfg0 &= ~BIT(zx_pll->lock_bit); + hw_cfg0 |= BIT(zx_pll->pd_bit); for (i = 0; i < zx_pll->count; i++) { if (hw_cfg0 == config[i].cfg0 && hw_cfg1 == config[i].cfg1) @@ -108,10 +108,10 @@ static int zx_pll_enable(struct clk_hw *hw) u32 reg; reg = readl_relaxed(zx_pll->reg_base); - writel_relaxed(reg & ~POWER_DOWN, zx_pll->reg_base); + writel_relaxed(reg & ~BIT(zx_pll->pd_bit), zx_pll->reg_base); return readl_relaxed_poll_timeout(zx_pll->reg_base, reg, - reg & LOCK_FLAG, 0, 100); + reg & BIT(zx_pll->lock_bit), 0, 100); } static void zx_pll_disable(struct clk_hw *hw) @@ -120,7 +120,7 @@ static void zx_pll_disable(struct clk_hw *hw) u32 reg; reg = readl_relaxed(zx_pll->reg_base); - writel_relaxed(reg | POWER_DOWN, zx_pll->reg_base); + writel_relaxed(reg | BIT(zx_pll->pd_bit), zx_pll->reg_base); } static int zx_pll_is_enabled(struct clk_hw *hw) @@ -130,10 +130,10 @@ static int zx_pll_is_enabled(struct clk_hw *hw) reg = readl_relaxed(zx_pll->reg_base); - return !(reg & POWER_DOWN); + return !(reg & BIT(zx_pll->pd_bit)); } -static const struct clk_ops zx_pll_ops = { +const struct clk_ops zx_pll_ops = { .recalc_rate = zx_pll_recalc_rate, .round_rate = zx_pll_round_rate, .set_rate = zx_pll_set_rate, @@ -141,6 +141,7 @@ static const struct clk_ops zx_pll_ops = { .disable = zx_pll_disable, .is_enabled = zx_pll_is_enabled, }; +EXPORT_SYMBOL(zx_pll_ops); struct clk *clk_register_zx_pll(const char *name, const char *parent_name, unsigned long flags, void __iomem *reg_base, @@ -164,6 +165,8 @@ struct clk *clk_register_zx_pll(const char *name, const char *parent_name, zx_pll->reg_base = reg_base; zx_pll->lookup_table = lookup_table; zx_pll->count = count; + zx_pll->lock_bit = LOCK_FLAG; + zx_pll->pd_bit = POWER_DOWN; zx_pll->lock = lock; zx_pll->hw.init = &init; diff --git a/drivers/clk/zte/clk.h b/drivers/clk/zte/clk.h index 65ae08b..8f6b5f0 100644 --- a/drivers/clk/zte/clk.h +++ b/drivers/clk/zte/clk.h @@ -24,6 +24,8 @@ struct clk_zx_pll { const struct zx_pll_config *lookup_table; /* order by rate asc */ int count; spinlock_t *lock; + u8 pd_bit; /* power down bit */ + u8 lock_bit; /* pll lock flag bit */ }; struct clk *clk_register_zx_pll(const char *name, const char *parent_name, @@ -38,4 +40,6 @@ struct clk_zx_audio { struct clk *clk_register_zx_audio(const char *name, const char * const parent_name, unsigned long flags, void __iomem *reg_base); + +extern const struct clk_ops zx_pll_ops; #endif