From patchwork Fri Aug 31 15:01:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 145665 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp884799ljw; Fri, 31 Aug 2018 08:02:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbB5QR9LZQJh59wwdAV3rDTcX1zV4V4HTqUbfM5DVLjIAnztKtJIvv29lsvnJrCkmIxmNt7 X-Received: by 2002:a62:9992:: with SMTP id t18-v6mr16103664pfk.239.1535727720242; Fri, 31 Aug 2018 08:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535727720; cv=none; d=google.com; s=arc-20160816; b=TkGKkIRf3PAIhBhLggl9EZWrscJNVtaK+3dCG1jRTFR9NLuE7XCrP8oPvZijmSnOiP ccz/yIQJjsKbUGjPbhTeAwvdesonpYYG6nsUXJ7RDwLDcNIO5k8JyqNYf9U8OST73on9 6YqqYmdoJPrKFXJNejHD0jqN8av4H14wOHeN6a34oJEQ+EY86a5rZacTZ0E7r9kO7EQM 7t7m0I17La+kr8NfEOwZMH5Dtnz4L0X4TDse3is3I3OCypZPx3VZVLqKTO0LYCLWM2Kq S6o/pJ8+RePSqt6usOrN3v6zrAzCOQDakB/Ngn30DexxuM8Wy25WmFpFJTpbR4HXDqc+ RB5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=i+erQs3ae9ydZgQ4PQ08vvRdOI69NHKlklA+y99T3So=; b=BRq98m1YnzNL1zfL6vr2SnCRIkqsZSATpASnxEqr1Sh8BGnpEaD2i84QEUYgjVF1hJ yyuyNliOFSbk0lB7plywQvePGSh4CbwwMDIn2jThe2+YE0fO6UG8DH9gtCZN9JW5qkEi HR8dOzxilUa3sBowu/ASuNYAKXKYCUzRAp/dtZAjyeO9iI93q8MyKs1El+rwLiMyYAwu Ju3X+1s0BiUR6AeCRfKCHpa3qioNRqIcurxIVSeD8buwWiO6GBuIrU+RagkkIh+smI2R lSjpFIe+p4yHaX6fE2HUv8oC9Htj+qKnmpny05IDGJjh4xvZWOMUFs+6FIxP/wEqLMHQ oI1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GuZg6fkl; 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=pass (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 a24-v6si7851727pgi.515.2018.08.31.08.01.59; Fri, 31 Aug 2018 08:02:00 -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=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GuZg6fkl; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbeHaTJu (ORCPT + 5 others); Fri, 31 Aug 2018 15:09:50 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:44826 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbeHaTJu (ORCPT ); Fri, 31 Aug 2018 15:09:50 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VF1ZiW003164; Fri, 31 Aug 2018 10:01:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535727695; bh=i+erQs3ae9ydZgQ4PQ08vvRdOI69NHKlklA+y99T3So=; h=From:To:CC:Subject:Date; b=GuZg6fkl9qVN2j+ypqL4NmMng34I387okag1jzE3tnLrNVzO3XXh54Kl7vWwti44r n+HMtOXVGvPMc14XSYoudl7cYHa1kTWVFOWWF94Oi8L3BiCWHTsvP6Dze0d0+/d+JV qQ0n7k1zd5+lQfbbBa0CqwmOFSeaeN+itsVkoys8= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VF1ZG6025640; Fri, 31 Aug 2018 10:01:35 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 10:01:35 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 10:01:35 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VF1XO0030210; Fri, 31 Aug 2018 10:01:34 -0500 From: Tero Kristo To: CC: , Subject: [PATCH] ARM: omap2+: hwmod_core: improve the support for clkctrl clocks Date: Fri, 31 Aug 2018 18:01:23 +0300 Message-ID: <1535727683-23930-1-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 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 This patch adds support for split memory ranges for clkctrl providers. This is necessary to support the coming clockdomain based split of clkctrl provider ranges, instead of the current CM instance based one. Signed-off-by: Tero Kristo --- Note: This patch can be applied independently, the only hard dependency with the clkctrl data split is with the DT changes, those must follow everything else. arch/arm/mach-omap2/omap_hwmod.c | 72 ++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 29 deletions(-) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 2ceffd8..23819bb 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -188,16 +188,16 @@ /** * struct clkctrl_provider - clkctrl provider mapping data - * @addr: base address for the provider - * @size: size of the provider address space - * @offset: offset of the provider from PRCM instance base + * @num_addrs: number of base address ranges for the provider + * @addr: base address(es) for the provider + * @size: size(s) of the provider address space(s) * @node: device node associated with the provider * @link: list link */ struct clkctrl_provider { - u32 addr; - u32 size; - u16 offset; + int num_addrs; + u32 *addr; + u32 *size; struct device_node *node; struct list_head link; }; @@ -724,23 +724,34 @@ static int __init _setup_clkctrl_provider(struct device_node *np) const __be32 *addrp; struct clkctrl_provider *provider; u64 size; + int i; provider = memblock_virt_alloc(sizeof(*provider), 0); if (!provider) return -ENOMEM; - addrp = of_get_address(np, 0, &size, NULL); - provider->addr = (u32)of_translate_address(np, addrp); - 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; - pr_debug("%s: %s: %x...%x [+%x]\n", __func__, np->parent->name, - provider->addr, provider->addr + provider->size, - provider->offset); + provider->num_addrs = + of_property_count_elems_of_size(np, "reg", sizeof(u32)) / 2; + + provider->addr = + memblock_virt_alloc(sizeof(void *) * provider->num_addrs, 0); + if (!provider->addr) + return -ENOMEM; + + provider->size = + memblock_virt_alloc(sizeof(u32) * provider->num_addrs, 0); + if (!provider->size) + return -ENOMEM; + + for (i = 0; i < provider->num_addrs; i++) { + addrp = of_get_address(np, i, &size, NULL); + provider->addr[i] = (u32)of_translate_address(np, addrp); + provider->size[i] = size; + pr_debug("%s: %pOF: %x...%x\n", __func__, np, provider->addr[i], + provider->addr[i] + provider->size[i]); + } list_add(&provider->link, &clkctrl_providers); @@ -787,23 +798,26 @@ static struct clk *_lookup_clkctrl_clk(struct omap_hwmod *oh) pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); list_for_each_entry(provider, &clkctrl_providers, link) { - if (provider->addr <= addr && - provider->addr + provider->size >= addr) { - struct of_phandle_args clkspec; + int i; - clkspec.np = provider->node; - clkspec.args_count = 2; - clkspec.args[0] = addr - provider->addr - - provider->offset; - clkspec.args[1] = 0; + for (i = 0; i < provider->num_addrs; i++) { + if (provider->addr[i] <= addr && + provider->addr[i] + provider->size[i] > addr) { + struct of_phandle_args clkspec; - clk = of_clk_get_from_provider(&clkspec); + clkspec.np = provider->node; + clkspec.args_count = 2; + clkspec.args[0] = addr - provider->addr[0]; + clkspec.args[1] = 0; - pr_debug("%s: %s got %p (offset=%x, provider=%s)\n", - __func__, oh->name, clk, clkspec.args[0], - provider->node->parent->name); + clk = of_clk_get_from_provider(&clkspec); - return clk; + pr_debug("%s: %s got %p (offset=%x, provider=%pOF)\n", + __func__, oh->name, clk, + clkspec.args[0], provider->node); + + return clk; + } } }