From patchwork Fri Dec 20 16:34:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 3390261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 98D46C0D4A for ; Fri, 20 Dec 2013 17:31:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65EE42017C for ; Fri, 20 Dec 2013 17:31:20 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09E1020170 for ; Fri, 20 Dec 2013 17:31:19 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vu34s-00026W-U7; Fri, 20 Dec 2013 16:37:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vu34B-0000rQ-VH; Fri, 20 Dec 2013 16:36:47 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vu32v-0000d1-CT for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2013 16:35:31 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBKGZ8ib023418; Fri, 20 Dec 2013 10:35:08 -0600 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 rBKGZ8MP008882; Fri, 20 Dec 2013 10:35:08 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Fri, 20 Dec 2013 10:35:07 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBKGYh6c031953; Fri, 20 Dec 2013 10:35:05 -0600 From: Tero Kristo To: , , , , , , Subject: [PATCHv12 08/49] clk: gate: add support for low level ops Date: Fri, 20 Dec 2013 18:34:26 +0200 Message-ID: <1387557274-22583-8-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387557274-22583-1-git-send-email-t-kristo@ti.com> References: <1387557274-22583-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131220_113529_621664_431971B3 X-CRM114-Status: GOOD ( 11.84 ) X-Spam-Score: -7.4 (-------) Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Gate clock can now be registered to use low level register access ops. Preferred initialization method is via clock description. Signed-off-by: Tero Kristo --- drivers/clk/clk-gate.c | 20 +++++++++++++++++--- include/linux/clk-provider.h | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index 3ec61d2..d4c94a7 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -62,7 +62,10 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) if (set) reg |= BIT(gate->bit_idx); } else { - reg = clk_readl(gate->reg); + if (gate->ll_ops) + reg = gate->ll_ops->clk_readl(gate->reg); + else + reg = clk_readl(gate->reg); if (set) reg |= BIT(gate->bit_idx); @@ -70,7 +73,10 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) reg &= ~BIT(gate->bit_idx); } - clk_writel(reg, gate->reg); + if (gate->ll_ops) + gate->ll_ops->clk_writel(reg, gate->reg); + else + clk_writel(reg, gate->reg); if (gate->lock) spin_unlock_irqrestore(gate->lock, flags); @@ -93,7 +99,10 @@ static int clk_gate_is_enabled(struct clk_hw *hw) u32 reg; struct clk_gate *gate = to_clk_gate(hw); - reg = clk_readl(gate->reg); + if (gate->ll_ops) + reg = gate->ll_ops->clk_readl(gate->reg); + else + reg = clk_readl(gate->reg); /* if a set bit disables this clk, flip it before masking */ if (gate->flags & CLK_GATE_SET_TO_DISABLE) @@ -157,6 +166,7 @@ struct clk *clk_register_gate(struct device *dev, const char *name, gate->flags = clk_gate_flags; gate->lock = lock; gate->hw.init = &init; + gate->ll_ops = &clk_ll_ops_default; clk = clk_register(dev, &gate->hw); @@ -184,6 +194,10 @@ struct clk_hw *clk_register_gate_desc(struct device *dev, struct clk_desc *desc) gate->bit_idx = hw_desc->bit_idx; gate->flags = hw_desc->flags; gate->lock = hw_desc->lock; + gate->ll_ops = hw_desc->ll_ops; + + if (!gate->ll_ops) + gate->ll_ops = &clk_ll_ops_default; if (!desc->ops) desc->ops = &clk_gate_ops; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index f082a89..3923d46 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -262,6 +262,7 @@ void of_fixed_clk_setup(struct device_node *np); * * @hw: handle between common and hardware-specific interfaces * @reg: register controlling gate + * @ll_ops: low-level ops for accessing the register * @bit_idx: single bit controlling gate * @flags: hardware-specific flags * @lock: register lock @@ -280,6 +281,7 @@ void of_fixed_clk_setup(struct device_node *np); struct clk_gate { struct clk_hw hw; void __iomem *reg; + struct clk_ll_ops *ll_ops; u8 bit_idx; u8 flags; spinlock_t *lock; @@ -289,6 +291,7 @@ struct clk_gate { * struct clk_gate_desc - init descriptor for gating clock * @desc: handle between common and hardware-specific interfaces * @reg: register controlling gate + * @ll_ops: low-level ops for accessing the register * @bit_idx: single bit controlling gate * @flags: hardware-specific flags * @lock: register lock @@ -296,6 +299,7 @@ struct clk_gate { struct clk_gate_desc { struct clk_desc desc; void __iomem *reg; + struct clk_ll_ops *ll_ops; u8 bit_idx; u8 flags; spinlock_t *lock;