From patchwork Fri Nov 3 14:26:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 117910 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3532988qgn; Fri, 3 Nov 2017 07:28:12 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q/31voc5Ug2+pcC4LOrZC0pd3AjRHmtZqT90gUhBoCA75VFtuRCXvJc7ZYCN6OrmON7Hcv X-Received: by 10.84.240.2 with SMTP id y2mr6922713plk.372.1509719292038; Fri, 03 Nov 2017 07:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509719292; cv=none; d=google.com; s=arc-20160816; b=MEYw4R2fFyttQETcwub+Syktiv9cnkmwv5dALyfgHVhDhXL3YOdCfGx9yXmfzUsPcI s+yH9ppDabOZKSce0Ns6ZnlJqiNPBI3fmOoRKg2PHN7cVNWg/RzA3VC9HkCBCHEE+46W jBk4E5Llpzrrm3QZiep8QAi/3aeurpaZ2KLWIn/Uzg1D/g1zVBIeVW0NwH9PaZQ266o9 lTb4na53bBL8m0i7qgh7m3aHXeUEUJUcDnPRltY1cq+qssqhzpJY/mfJIKXSpGRF99vb AvuhthRxia8cCigwxIS4sqzXyAe9et+AA90Kl7Ld7gC3Z1j3d9Iu6MH1igllcQKKe7qs KOlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GnRpIjx5s6OKW0QT9tp6vi9EFNEsvBzT/+/32r/BVZU=; b=smc9ZDrTg7n/pYEm621IvrzctDQs4/aTA9DMckvFkDIqYptKVO7BKjYQz16TCpN7Cn bQlKWgZMyDk+ls5skOlFrpOtByigRzcDfE3hLrStVWrq/Iq7Y49IxAH0T5uS+8u32S4D 3yxx4C5fhUc97Gsm+S/ACvQxA8OJ+wxampahmOgrDgIuKgLtGNC0ezGLiqNZTYnw1W+2 Bw66SOC/S0Qi7XkmIm3mmTuHsaSgriwzek3YWN1cK7WodrgsmD/WlnoEFTF/XlJNbf5R InVtgInC3EIQorH+gShjvXvuuThEYa2QHo9MEHR8cvHQ9rqG09ooSAmFyKwKnWzULT9V Y+Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=EnY7/uzQ; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si4866060plb.265.2017.11.03.07.28.11; Fri, 03 Nov 2017 07:28:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=EnY7/uzQ; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754609AbdKCO2J (ORCPT + 4 others); Fri, 3 Nov 2017 10:28:09 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:34543 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752302AbdKCO2G (ORCPT ); Fri, 3 Nov 2017 10:28:06 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id vA3ER4f4024088; Fri, 3 Nov 2017 09:27:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1509719224; bh=IB6apNnQVMZZnhtF1C7+bna422CGjB1cswLB8oI75nw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EnY7/uzQGwpvL49CuJGyOzmuLr2rtvwYiZNO+eVCVo9bvxq3kke7DcrBsIUDz2Jiv hnPdwv/0kgTt77/8hIfnYIFnFIS/NDs72K6MqiIpQsb5S2K4H949kvPkxSZF6+SRG9 c4dHc9bDFspDNt7y/mHRordv8SX4lJkFTa1Fht08= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vA3EQxHc017536; Fri, 3 Nov 2017 09:26:59 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 3 Nov 2017 09:26:59 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 3 Nov 2017 09:26:59 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vA3EQovv014982; Fri, 3 Nov 2017 09:26:56 -0500 From: Tero Kristo To: , CC: Subject: [PATCH 3/7] ARM: OMAP2+: hwmod: fix clkctrl address translation logic Date: Fri, 3 Nov 2017 16:26:37 +0200 Message-ID: <1509719201-32700-4-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509719201-32700-1-git-send-email-t-kristo@ti.com> References: <1509719201-32700-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org There are cases where clkctrl clock offsets do not match the corresponding clockdomain, and this case the existing mapping functionality will fail. Fix this by adding the whole address range for a clkctrl provider and matching the actual clkctrl registers against these ranges. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/omap_hwmod.c | 72 +++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 37 deletions(-) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 2dbd632..bb7c745 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -185,15 +185,15 @@ /** * struct clkctrl_provider - clkctrl provider mapping data * @addr: base address for the provider - * @offset: base offset for the provider - * @clkdm: base clockdomain for provider + * @size: size of the provider address space + * @offset: offset of the provider from PRCM instance base * @node: device node associated with the provider * @link: list link */ struct clkctrl_provider { u32 addr; + u32 size; u16 offset; - struct clockdomain *clkdm; struct device_node *node; struct list_head link; }; @@ -223,8 +223,7 @@ struct omap_hwmod_soc_ops { void (*update_context_lost)(struct omap_hwmod *oh); int (*get_context_lost)(struct omap_hwmod *oh); int (*disable_direct_prcm)(struct omap_hwmod *oh); - u32 (*xlate_clkctrl)(struct omap_hwmod *oh, - struct clkctrl_provider *provider); + u32 (*xlate_clkctrl)(struct omap_hwmod *oh); }; /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */ @@ -716,45 +715,28 @@ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) { } }; -static int _match_clkdm(struct clockdomain *clkdm, void *user) -{ - struct clkctrl_provider *provider = user; - - if (clkdm_xlate_address(clkdm) == provider->addr) { - pr_debug("%s: Matched clkdm %s for addr %x (%s)\n", __func__, - clkdm->name, provider->addr, - provider->node->parent->name); - provider->clkdm = clkdm; - - return -1; - } - - return 0; -} - static int _setup_clkctrl_provider(struct device_node *np) { const __be32 *addrp; struct clkctrl_provider *provider; + u64 size; provider = memblock_virt_alloc(sizeof(*provider), 0); if (!provider) return -ENOMEM; - addrp = of_get_address(np, 0, NULL, NULL); + addrp = of_get_address(np, 0, &size, NULL); provider->addr = (u32)of_translate_address(np, addrp); - provider->offset = provider->addr & 0xff; + addrp = of_get_address(np->parent, 0, NULL, NULL); + provider->offset = provider->addr - + (u32)of_translate_address(np->parent, addrp); provider->addr &= ~0xff; + provider->size = size | 0xff; provider->node = np; - clkdm_for_each(_match_clkdm, provider); - - if (!provider->clkdm) { - pr_err("%s: nothing matched for node %s (%x)\n", - __func__, np->parent->name, provider->addr); - memblock_free_early(__pa(provider), sizeof(*provider)); - return -EINVAL; - } + pr_debug("%s: %s: %x...%x [+%x]\n", __func__, np->parent->name, + provider->addr, provider->addr + provider->size, + provider->offset); list_add(&provider->link, &clkctrl_providers); @@ -775,32 +757,48 @@ static int _init_clkctrl_providers(void) return ret; } -static u32 _omap4_xlate_clkctrl(struct omap_hwmod *oh, - struct clkctrl_provider *provider) +static u32 _omap4_xlate_clkctrl(struct omap_hwmod *oh) { - return oh->prcm.omap4.clkctrl_offs - - provider->offset - provider->clkdm->clkdm_offs; + if (!oh->prcm.omap4.modulemode) + return 0; + + return omap_cm_xlate_clkctrl(oh->clkdm->prcm_partition, + oh->clkdm->cm_inst, + oh->prcm.omap4.clkctrl_offs); } static struct clk *_lookup_clkctrl_clk(struct omap_hwmod *oh) { struct clkctrl_provider *provider; struct clk *clk; + u32 addr; if (!soc_ops.xlate_clkctrl) return NULL; + addr = soc_ops.xlate_clkctrl(oh); + if (!addr) + return NULL; + + pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); + list_for_each_entry(provider, &clkctrl_providers, link) { - if (provider->clkdm == oh->clkdm) { + if (provider->addr <= addr && + provider->addr + provider->size >= addr) { struct of_phandle_args clkspec; clkspec.np = provider->node; clkspec.args_count = 2; - clkspec.args[0] = soc_ops.xlate_clkctrl(oh, provider); + clkspec.args[0] = addr - provider->addr - + provider->offset; clkspec.args[1] = 0; clk = of_clk_get_from_provider(&clkspec); + pr_debug("%s: %s got %p (offset=%x, provider=%s)\n", + __func__, oh->name, clk, clkspec.args[0], + provider->node->parent->name); + return clk; } }