From patchwork Thu May 18 17:16:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 9734897 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 1BF5E601C8 for ; Thu, 18 May 2017 17:17:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2152288C3 for ; Thu, 18 May 2017 17:17:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6C89288D0; Thu, 18 May 2017 17:17:00 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 632BC288C3 for ; Thu, 18 May 2017 17:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lCTgVMKdh2BV6Cx57bt+US7RjMsxnS7iavM4NahUXA4=; b=DO9t9s2JLehW7P 0wuo1GVFYRV/AiKeoApWMIf9O1FMsGudgQQ4qBJwEFNNFDqq59VEXfvILN4kgaY/1kDFPlNHEBL5W inXlJEFU1+7tZvTRi7nV0+sK2TQqO+AA9GRoVcchDRcgbUfLf0UC3gMLnAd95P0k/3izo3GQfRsRH u3/ZzD/3nDH691+/o2VwoUSlb9k/yC08JxycpS2A1m8ahYp9hf2q/ixWOp6S3nVMVCBEO5BtcA3VN yiQ5x1A4mEzf7YieHtyArY28FQ510YePYHwZGTGCs1IDVZvaUwOzQVT51GDfxlTYq69qlvnouHDhz IVV9SHfzkdZucjoKgaXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dBP2o-0001PR-2X; Thu, 18 May 2017 17:16:58 +0000 Received: from fllnx210.ext.ti.com ([198.47.19.17]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBP2k-0001Nu-Cx for linux-arm-kernel@lists.infradead.org; Thu, 18 May 2017 17:16:56 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v4IHGTON006447; Thu, 18 May 2017 12:16:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1495127789; bh=9/RJhAE1HaENG9XMcDNDNPGcLvvQb5PR9bT3s/SZ+HI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BHaVN23luK5rphupjf/qosmiLcvsCvNFMXKmO1lqW56aIe72ObWHbjcLOtGJzFixw uBo5FIc+KWppYQPi/zHTZC+0nOJmvhAy0qNBlNME0gZUxFDqVXdHAcrMv4bNt99NmF DLJbFwpsNQPHbuORd5YCX+kNlSCXSQT/JthW9rro= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4IHGTgr027545; Thu, 18 May 2017 12:16:29 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Thu, 18 May 2017 12:16:29 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4IHGNea019601; Thu, 18 May 2017 12:16:25 -0500 From: Tero Kristo To: , Subject: [PATCHv3 1/3] ARM: OMAP2+: hwmod: assign main clock from DT if available Date: Thu, 18 May 2017 20:16:10 +0300 Message-ID: <1495127772-7486-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495127772-7486-1-git-send-email-t-kristo@ti.com> References: <1495127772-7486-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-20170518_101654_559486_AE7A858E X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Fix the main clock assignment to assign clkctrl clk from DT as the main clock if available. If main clock is assigned via DT, the direct PRCM access for module handling is not used on OMAP4+ architectures either, as it is assumed the main clock will be doing this instead. This patch also drops the obsolete "_mod_ck" search as the implementation required for this was not accepted upstream. Signed-off-by: Tero Kristo Acked-by: Tony Lindgren --- arch/arm/mach-omap2/omap_hwmod.c | 57 ++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 8bcea0d..6b8a2cf 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -693,31 +693,48 @@ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) /** * _init_main_clk - get a struct clk * for the the hwmod's main functional clk * @oh: struct omap_hwmod * + * @np: device node mapped to this hwmod * * Called from _init_clocks(). Populates the @oh _clk (main * functional clock pointer) if a clock matching the hwmod name is found, * or a main_clk is present. Returns 0 on success or -EINVAL on error. */ -static int _init_main_clk(struct omap_hwmod *oh) +static int _init_main_clk(struct omap_hwmod *oh, struct device_node *np) { int ret = 0; - char name[MOD_CLK_MAX_NAME_LEN]; - struct clk *clk; - static const char modck[] = "_mod_ck"; - - if (strlen(oh->name) >= MOD_CLK_MAX_NAME_LEN - strlen(modck)) - pr_warn("%s: warning: cropping name for %s\n", __func__, - oh->name); + struct clk *clk = NULL; + int i; + int count; + const char *name; + char clk_name[strlen("clkctrl-x") + 1]; - strlcpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - strlen(modck)); - strlcat(name, modck, MOD_CLK_MAX_NAME_LEN); + if (np) { + clk = of_clk_get_by_name(np, "clkctrl"); + if (IS_ERR(clk)) { + /* Try matching by hwmod name */ + count = of_property_count_strings(np, "ti,hwmods"); + for (i = 0; i < count; i++) { + ret = of_property_read_string_index(np, + "ti,hwmods", + i, &name); + if (ret) + continue; + if (!strcmp(name, oh->name)) { + sprintf(clk_name, "clkctrl-%d", i); + clk = of_clk_get_by_name(np, clk_name); + } + } + } + if (!IS_ERR(clk)) { + pr_debug("%s: mapped main_clk %s for %s\n", __func__, + __clk_get_name(clk), oh->name); + oh->main_clk = __clk_get_name(clk); + oh->_clk = clk; + soc_ops.disable_direct_prcm(oh); + } + } - clk = clk_get(NULL, name); - if (!IS_ERR(clk)) { - oh->_clk = clk; - soc_ops.disable_direct_prcm(oh); - oh->main_clk = kstrdup(name, GFP_KERNEL); - } else { + if (IS_ERR_OR_NULL(clk)) { if (!oh->main_clk) return 0; @@ -1482,13 +1499,13 @@ static int _init_clkdm(struct omap_hwmod *oh) * _init_clocks - clk_get() all clocks associated with this hwmod. Retrieve as * well the clockdomain. * @oh: struct omap_hwmod * - * @data: not used; pass NULL + * @np: device_node mapped to this hwmod * * Called by omap_hwmod_setup_*() (after omap2_clk_init()). * Resolves all clock names embedded in the hwmod. Returns 0 on * success, or a negative error code on failure. */ -static int _init_clocks(struct omap_hwmod *oh, void *data) +static int _init_clocks(struct omap_hwmod *oh, struct device_node *np) { int ret = 0; @@ -1500,7 +1517,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data) if (soc_ops.init_clkdm) ret |= soc_ops.init_clkdm(oh); - ret |= _init_main_clk(oh); + ret |= _init_main_clk(oh, np); ret |= _init_interface_clks(oh); ret |= _init_opt_clks(oh); @@ -2360,7 +2377,7 @@ static int __init _init(struct omap_hwmod *oh, void *data) return 0; } - r = _init_clocks(oh, NULL); + r = _init_clocks(oh, np); if (r < 0) { WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); return -EINVAL;