From patchwork Fri Jan 4 05:51:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Gaikwad X-Patchwork-Id: 1931031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 4788DDFABD for ; Fri, 4 Jan 2013 05:55:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tr0Cl-0001sY-6L; Fri, 04 Jan 2013 05:52:31 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tr0Cd-0001rq-TK for linux-arm-kernel@lists.infradead.org; Fri, 04 Jan 2013 05:52:25 +0000 Received: from hqnvupgp06.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Thu, 03 Jan 2013 21:52:04 -0800 Received: from hqemhub03.nvidia.com ([172.17.108.22]) by hqnvupgp06.nvidia.com (PGP Universal service); Thu, 03 Jan 2013 21:49:45 -0800 X-PGP-Universal: processed; by hqnvupgp06.nvidia.com on Thu, 03 Jan 2013 21:49:45 -0800 Received: from localhost.localdomain (172.20.144.16) by hqemhub03.nvidia.com (172.20.150.15) with Microsoft SMTP Server (TLS) id 8.3.279.1; Thu, 3 Jan 2013 21:52:20 -0800 From: Prashant Gaikwad To: , Subject: [PATCH 2/2] clk: tegra30: Convert clk out to composite clk Date: Fri, 4 Jan 2013 11:21:46 +0530 Message-ID: <1357278706-28149-2-git-send-email-pgaikwad@nvidia.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1357278706-28149-1-git-send-email-pgaikwad@nvidia.com> References: <1357278706-28149-1-git-send-email-pgaikwad@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130104_005224_329620_A1978D70 X-CRM114-Status: GOOD ( 16.06 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [216.228.121.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Prashant Gaikwad , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Convert clk out to composite clock type which removes the mux clock. Signed-off-by: Prashant Gaikwad --- This patch is rebased on ccf-rework for Tegra patch series. It is just to show how clk-composite can be used, not to be merged. If patch 1 is accepted then I would like to merge this patch to ccf-rework series. --- drivers/clk/tegra/clk-tegra30.c | 51 +++++++++++++------------------------- drivers/clk/tegra/clk.h | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 33 deletions(-) diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c index 30fb743..4c16c11 100644 --- a/drivers/clk/tegra/clk-tegra30.c +++ b/drivers/clk/tegra/clk-tegra30.c @@ -1191,43 +1191,28 @@ static void __init tegra30_audio_clk_init(void) clks[spdif_2x] = clk; } +static struct tegra_clk_out_init_data tegra_clk_out_list[] = { + TEGRA_CLK_OUT_INIT_DATA("clk_out_1", "extern1", "clk_out_1", clk_out1_parents, PMC_CLK_OUT_CNTRL, 6, 3, 0, 2, 0, &clk_out_lock, clk_out_1), + TEGRA_CLK_OUT_INIT_DATA("clk_out_2", "extern2", "clk_out_2", clk_out2_parents, PMC_CLK_OUT_CNTRL, 14, 3, 0, 10, 0, &clk_out_lock, clk_out_2), + TEGRA_CLK_OUT_INIT_DATA("clk_out_3", "extern3", "clk_out_3", clk_out3_parents, PMC_CLK_OUT_CNTRL, 22, 3, 0, 18, 0, &clk_out_lock, clk_out_3), +}; + static void __init tegra30_pmc_clk_init(void) { struct clk *clk; + int i; - /* clk_out_1 */ - clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents, - ARRAY_SIZE(clk_out1_parents), 0, - pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0, - &clk_out_lock); - clks[clk_out_1_mux] = clk; - clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0, - pmc_base + PMC_CLK_OUT_CNTRL, 2, 0, - &clk_out_lock); - clk_register_clkdev(clk, "extern1", "clk_out_1"); - clks[clk_out_1] = clk; - - /* clk_out_2 */ - clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents, - ARRAY_SIZE(clk_out1_parents), 0, - pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0, - &clk_out_lock); - clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0, - pmc_base + PMC_CLK_OUT_CNTRL, 10, 0, - &clk_out_lock); - clk_register_clkdev(clk, "extern2", "clk_out_2"); - clks[clk_out_2] = clk; - - /* clk_out_3 */ - clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents, - ARRAY_SIZE(clk_out1_parents), 0, - pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0, - &clk_out_lock); - clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0, - pmc_base + PMC_CLK_OUT_CNTRL, 18, 0, - &clk_out_lock); - clk_register_clkdev(clk, "extern3", "clk_out_3"); - clks[clk_out_3] = clk; + for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++) { + struct tegra_clk_out_init_data *out = &tegra_clk_out_list[i]; + + out->out.mux.reg = pmc_base + out->offset; + out->out.gate.reg = pmc_base + out->offset; + + clk = clk_register_composite(NULL, out->name, out->parent_names, + out->num_parents, &out->out.mux.hw, &clk_mux_ops, + NULL, NULL, &out->out.gate.hw, &clk_gate_ops, 0); + clks[out->clk_id] = clk; + } /* blink */ clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0, diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h index f1ed1d0..47c536d 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -437,6 +437,55 @@ struct clk *tegra_clk_super_mux(const char *name, const char **parent_names, u8 width, u8 pllx_index, u8 div2_index, spinlock_t *lock); +struct tegra_clk_out { + struct clk_hw hw; + struct clk_mux mux; + struct clk_gate gate; +}; + +#define TEGRA_CLK_OUT(_mux_shift, _mux_width, _mux_flags, \ + _gate_bit_idx, _gate_flags, _lock) \ + { \ + .mux = { \ + .shift = _mux_shift, \ + .width = _mux_width, \ + .flags = _mux_flags, \ + .lock = _lock, \ + }, \ + .gate = { \ + .bit_idx = _gate_bit_idx, \ + .flags = _gate_flags, \ + .lock = _lock, \ + }, \ + } + +struct tegra_clk_out_init_data { + const char *name; + int clk_id; + const char **parent_names; + int num_parents; + struct tegra_clk_out out; + u32 offset; + const char *con_id; + const char *dev_id; +}; + +#define TEGRA_CLK_OUT_INIT_DATA(_name, _con_id, _dev_id, _parent_names, \ + _offset, _mux_shift, _mux_width, _mux_flags, \ + _gate_bit_idx, _gate_flags, _lock, _clk_id) \ + { \ + .name = _name, \ + .clk_id = _clk_id, \ + .parent_names = _parent_names, \ + .num_parents = ARRAY_SIZE(_parent_names), \ + .out = TEGRA_CLK_OUT(_mux_shift, _mux_width, \ + _mux_flags, _gate_bit_idx, \ + _gate_flags, _lock), \ + .offset = _offset, \ + .con_id = _con_id, \ + .dev_id = _dev_id, \ + } + /** * struct clk_init_tabel - clock initialization table * @clk_id: clock id as mentioned in device tree bindings