From patchwork Tue Jul 23 07:20:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2831867 Return-Path: X-Original-To: patchwork-linux-arm@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 384179F7D6 for ; Tue, 23 Jul 2013 08:39:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8E7B2011D for ; Tue, 23 Jul 2013 08:39:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 603C020117 for ; Tue, 23 Jul 2013 08:39:48 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1X3X-00081S-PN; Tue, 23 Jul 2013 07:30:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1Wye-00010w-Ld; Tue, 23 Jul 2013 07:25:44 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1Wvm-0000jM-Cu for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2013 07:23:07 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6N7MPqC031898; Tue, 23 Jul 2013 02:22:25 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6N7MPCR026712; Tue, 23 Jul 2013 02:22:25 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Tue, 23 Jul 2013 02:22:25 -0500 Received: from sokoban.tieu.ti.com (h79-8.vpn.ti.com [172.24.79.8]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6N7LQtr027090; Tue, 23 Jul 2013 02:22:23 -0500 From: Tero Kristo To: , , , , , , Subject: [PATCHv4 23/33] CLK: OMAP: add interface clock support for OMAP3 Date: Tue, 23 Jul 2013 10:20:18 +0300 Message-ID: <1374564028-11352-24-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374564028-11352-1-git-send-email-t-kristo@ti.com> References: <1374564028-11352-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-20130723_032246_584595_9BD26488 X-CRM114-Status: GOOD ( 15.76 ) X-Spam-Score: -8.4 (--------) Cc: devicetree-discuss@lists.ozlabs.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.2 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 OMAP3 has interface clocks in addition to functional clocks, which require special handling for the autoidle and idle status register offsets mainly. Signed-off-by: Tero Kristo --- drivers/clk/omap/Makefile | 2 +- drivers/clk/omap/clk.c | 3 ++ drivers/clk/omap/interface.c | 110 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/omap/interface.c diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile index c4e8825..faaeb62 100644 --- a/drivers/clk/omap/Makefile +++ b/drivers/clk/omap/Makefile @@ -1,3 +1,3 @@ obj-y += clk.o dpll.o autoidle.o gate.o \ clk-44xx.o clk-54xx.o clk-7xx.o \ - clk-33xx.o + clk-33xx.o interface.o diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c index 8c89714..5cbefde 100644 --- a/drivers/clk/omap/clk.c +++ b/drivers/clk/omap/clk.c @@ -30,6 +30,9 @@ static const struct of_device_id clk_match[] = { {.compatible = "gate-clock", .data = of_gate_clk_setup, }, {.compatible = "ti,omap4-dpll-clock", .data = of_omap4_dpll_setup, }, {.compatible = "ti,gate-clock", .data = of_omap_gate_clk_setup, }, + {.compatible = "ti,interface-clock", + .data = of_omap_interface_clk_setup, }, + {.compatible = "ti,omap3-dpll-clock", .data = of_omap3_dpll_setup, }, {}, }; diff --git a/drivers/clk/omap/interface.c b/drivers/clk/omap/interface.c new file mode 100644 index 0000000..f1f1a1a --- /dev/null +++ b/drivers/clk/omap/interface.c @@ -0,0 +1,110 @@ +/* + * OMAP interface clock support + * + * Copyright (C) 2013 Texas Instruments, Inc. + * + * Tero Kristo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_OF + +static const struct clk_ops omap_interface_clk_ops = { + .init = &omap2_init_clk_clkdm, + .enable = &omap2_dflt_clk_enable, + .disable = &omap2_dflt_clk_disable, + .is_enabled = &omap2_dflt_clk_is_enabled, +}; + +void __init of_omap_interface_clk_setup(struct device_node *node) +{ + struct clk *clk; + struct clk_init_data init; + struct clk_hw_omap *clk_hw; + const char *clk_name = node->name; + int num_parents; + const char **parent_names; + int i; + u32 val; + + clk_hw = kzalloc(sizeof(struct clk_hw_omap), GFP_KERNEL); + if (!clk_hw) { + pr_err("%s: could not allocate clk_hw_omap\n", __func__); + return; + } + + clk_hw->hw.init = &init; + clk_hw->ops = &clkhwops_iclk_wait; + clk_hw->enable_reg = of_iomap(node, 0); + + if (!of_property_read_u32(node, "ti,enable-bit", &val)) + clk_hw->enable_bit = val; + + if (of_property_read_bool(node, "ti,iclk-no-wait")) + clk_hw->ops = &clkhwops_iclk; + + if (of_property_read_bool(node, "ti,iclk-hsotgusb")) + clk_hw->ops = &clkhwops_omap3430es2_iclk_hsotgusb_wait; + + if (of_property_read_bool(node, "ti,iclk-dss")) + clk_hw->ops = &clkhwops_omap3430es2_iclk_dss_usbhost_wait; + + if (of_property_read_bool(node, "ti,iclk-ssi")) + clk_hw->ops = &clkhwops_omap3430es2_iclk_ssi_wait; + + of_property_read_string(node, "clock-output-names", &clk_name); + of_property_read_string(node, "ti,clkdm-name", &clk_hw->clkdm_name); + + init.name = clk_name; + init.ops = &omap_interface_clk_ops; + init.flags = 0; + + num_parents = of_clk_get_parent_count(node); + if (num_parents < 1) { + pr_err("%s: omap interface_clk %s must have parent(s)\n", + __func__, node->name); + goto cleanup; + } + + parent_names = kzalloc(sizeof(char *) * num_parents, GFP_KERNEL); + + for (i = 0; i < num_parents; i++) + parent_names[i] = of_clk_get_parent_name(node, i); + + init.num_parents = num_parents; + init.parent_names = parent_names; + + clk = clk_register(NULL, &clk_hw->hw); + + if (!IS_ERR(clk)) { + of_clk_add_provider(node, of_clk_src_simple_get, clk); + omap2_init_clk_hw_omap_clocks(clk); + return; + } + +cleanup: + kfree(clk_hw); +} +EXPORT_SYMBOL(of_omap_interface_clk_setup); +CLK_OF_DECLARE(omap_interface_clk, "ti,omap-interface-clock", + of_omap_interface_clk_setup); +#endif