From patchwork Thu Dec 19 11:23:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 3376831 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AAA959F384 for ; Thu, 19 Dec 2013 11:25:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1579720627 for ; Thu, 19 Dec 2013 11:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4591D20642 for ; Thu, 19 Dec 2013 11:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753216Ab3LSLZP (ORCPT ); Thu, 19 Dec 2013 06:25:15 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:38894 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752852Ab3LSLZN (ORCPT ); Thu, 19 Dec 2013 06:25:13 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBJBOolQ009927; Thu, 19 Dec 2013 05:24:50 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBJBOoof029419; Thu, 19 Dec 2013 05:24:50 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Thu, 19 Dec 2013 05:24:49 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBJBOUgx009888; Thu, 19 Dec 2013 05:24:47 -0600 From: Tero Kristo To: , , , , , , CC: , Subject: [PATCHv11 05/49] clk: gate: add support for registering gate clock from descriptor Date: Thu, 19 Dec 2013 13:23:36 +0200 Message-ID: <1387452260-23276-6-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387452260-23276-1-git-send-email-t-kristo@ti.com> References: <1387452260-23276-1-git-send-email-t-kristo@ti.com> 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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 New clk_register_desc() call can be used to register this clock type now. Signed-off-by: Tero Kristo --- drivers/clk/clk-gate.c | 31 +++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 19 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index 4a58c55..3ec61d2 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -26,8 +26,12 @@ * parent - fixed parent. No clk_set_parent support */ +/* resolve struct clk_gate from inner struct clk_hw member */ #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) +/* resolve struct clk_gate_desc from inner struct clk_desc member */ +#define to_hw_desc(_desc) container_of(_desc, struct clk_gate_desc, desc) + /* * It works on following logic: * @@ -162,3 +166,30 @@ struct clk *clk_register_gate(struct device *dev, const char *name, return clk; } EXPORT_SYMBOL_GPL(clk_register_gate); + +struct clk_hw *clk_register_gate_desc(struct device *dev, struct clk_desc *desc) +{ + struct clk_gate *gate; + struct clk_gate_desc *hw_desc; + + hw_desc = to_hw_desc(desc); + + /* allocate mux clock */ + gate = kzalloc(sizeof(*gate), GFP_KERNEL); + if (!gate) + return ERR_PTR(-ENOMEM); + + /* populate struct clk_gate assignments */ + gate->reg = hw_desc->reg; + gate->bit_idx = hw_desc->bit_idx; + gate->flags = hw_desc->flags; + gate->lock = hw_desc->lock; + + if (!desc->ops) + desc->ops = &clk_gate_ops; + + desc->flags |= CLK_IS_BASIC; + + return &gate->hw; +} +EXPORT_SYMBOL_GPL(clk_register_gate_desc); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 7dd6842..27a9765 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -269,10 +269,29 @@ struct clk_gate { spinlock_t *lock; }; +/** + * struct clk_gate_desc - init descriptor for gating clock + * + * @desc: handle between common and hardware-specific interfaces + * @reg: register controlling gate + * @bit_idx: single bit controlling gate + * @flags: hardware-specific flags + * @lock: register lock + */ +struct clk_gate_desc { + struct clk_desc desc; + void __iomem *reg; + u8 bit_idx; + u8 flags; + spinlock_t *lock; +}; + #define CLK_GATE_SET_TO_DISABLE BIT(0) #define CLK_GATE_HIWORD_MASK BIT(1) extern const struct clk_ops clk_gate_ops; +struct clk_hw *clk_register_gate_desc(struct device *dev, + struct clk_desc *desc); struct clk *clk_register_gate(struct device *dev, const char *name, const char *parent_name, unsigned long flags, void __iomem *reg, u8 bit_idx,