Received: by 10.223.185.116 with SMTP id b49csp717334wrg; Fri, 23 Feb 2018 05:48:23 -0800 (PST) X-Google-Smtp-Source: AH8x224An3r17vxmWsitcjmpHT9soDHOkQbpZLEbQUgFx/HDLsmN2kZAFyUNRpM4hWu4VTTfL/F4 X-Received: by 10.101.102.2 with SMTP id w2mr1519619pgv.326.1519393703788; Fri, 23 Feb 2018 05:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519393703; cv=none; d=google.com; s=arc-20160816; b=GLy8rTSjVBOoLRI3E832Jq8MdQ5nOtNuiYuuB4FLCg9Z7QHuW5M6WE0zni0+Ev7tgf ukqoBkoykELBcG15mpCeuWFxAH/XhJMfAuIyIFKK5xCCWDH6gUipZGPyxzsPDPHfTX28 y5lMgxVv9/qr8c+KBetVfUAtO4wrNPvzA1P2uIrtjjr3bobU7vdN3jUxGkCelusfVV+G mXzyxYbrjemrfwo05nf6EOiVJNBUsNHbua3fCf9x8R0oRUDelwZL0NWd+IxwasYZ7zX7 eHcbXYBXkLrKxbAMAR0NfpXU7APIC93NYsQf9yeOyZ9FgqU82HVJJZ1g4x9mZhNmOpYG gY8Q== 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 :arc-authentication-results; bh=ExdPqFLWftH4tvL2HJ0G+X1h9WEKxmkdHUOaW+w86ZI=; b=Jyk6kwXAYxwOdjFISHy6t+Fz6IINRk6ji6fapfRRP0uz34VcLhh0QIuzEe1N+Ebyqb 2Tif3g+fOH0PFszcLpW4o7hxbuxUZPlDUO0gj4PV3yLtiGrd23oaoO9z44aqsA4Kn1Ps Ud7R/j6VbupyhSQYThctwf/uUzU7IIVsvn8Ea8a9lW2vIimrw7jBa/mAIKo/kF+dilpr WQB9eefmexg3X8BZY6KAH91HBEFJFk4r7SzI6uVnm69BYisphRtk18Dm3z0dqjyjV1ip 5FQwKKyQv6G3tzak6erMNitVx0IYOKTCRVlZBpc64ZkfEW3hxyLhXlHGJpQ6tzG5GGXL W3wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si1857135pfi.53.2018.02.23.05.48.09; Fri, 23 Feb 2018 05:48:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbeBWNqT (ORCPT + 99 others); Fri, 23 Feb 2018 08:46:19 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:48885 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751420AbeBWNid (ORCPT ); Fri, 23 Feb 2018 08:38:33 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 00C8920849; Fri, 23 Feb 2018 14:38:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from dell-desktop.lan (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 869912043E; Fri, 23 Feb 2018 14:38:30 +0100 (CET) From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= To: maxime.ripard@bootlin.com, linux@armlinux.org.uk, wens@csie.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clabbe.montjoie@gmail.com, thomas.petazzoni@bootlin.com, mylene.josserand@bootlin.com, quentin.schulz@bootlin.com Subject: [PATCH v4 01/10] ARM: sun9i: smp: Add sun9i dt parsing function Date: Fri, 23 Feb 2018 14:37:33 +0100 Message-Id: <20180223133742.26044-2-mylene.josserand@bootlin.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223133742.26044-1-mylene.josserand@bootlin.com> References: <20180223133742.26044-1-mylene.josserand@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To prepare the support for sun8i-a83t, create a new function that handles all the resources needed on sun9i-a80 (because it will be different from sun8i-a83t). All the parsing of device tree is moved into this new function: sun9i_dt_parsing. Create also a function to release the resources retrieved during the dt parsing in case there is an error in init function. Signed-off-by: Mylène Josserand --- arch/arm/mach-sunxi/mc_smp.c | 99 ++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c index 11e46c6efb90..650a2ad4398f 100644 --- a/arch/arm/mach-sunxi/mc_smp.c +++ b/arch/arm/mach-sunxi/mc_smp.c @@ -684,35 +684,22 @@ static int __init sunxi_mc_smp_lookback(void) return ret; } -static int __init sunxi_mc_smp_init(void) +static int sun9i_dt_parsing(struct resource res) { - struct device_node *cpucfg_node, *sram_node, *node; - struct resource res; + struct device_node *prcm_node, *cpucfg_node, *sram_node; int ret; - if (!of_machine_is_compatible("allwinner,sun9i-a80")) - return -ENODEV; - - if (!sunxi_mc_smp_cpu_table_init()) - return -EINVAL; - - if (!cci_probed()) { - pr_err("%s: CCI-400 not available\n", __func__); - return -ENODEV; - } - - node = of_find_compatible_node(NULL, NULL, "allwinner,sun9i-a80-prcm"); - if (!node) { - pr_err("%s: PRCM not available\n", __func__); + prcm_node = of_find_compatible_node(NULL, NULL, + "allwinner,sun9i-a80-prcm"); + if (!prcm_node) return -ENODEV; - } /* * Unfortunately we can not request the I/O region for the PRCM. * It is shared with the PRCM clock. */ - prcm_base = of_iomap(node, 0); - of_node_put(node); + prcm_base = of_iomap(prcm_node, 0); + of_node_put(prcm_node); if (!prcm_base) { pr_err("%s: failed to map PRCM registers\n", __func__); return -ENOMEM; @@ -748,33 +735,12 @@ static int __init sunxi_mc_smp_init(void) goto err_put_sram_node; } - /* Configure CCI-400 for boot cluster */ - ret = sunxi_mc_smp_lookback(); - if (ret) { - pr_err("%s: failed to configure boot cluster: %d\n", - __func__, ret); - goto err_unmap_release_secure_sram; - } - /* We don't need the CPUCFG and SRAM device nodes anymore */ of_node_put(cpucfg_node); of_node_put(sram_node); - /* Set the hardware entry point address */ - writel(__pa_symbol(sunxi_mc_smp_secondary_startup), - prcm_base + PRCM_CPU_SOFT_ENTRY_REG); - - /* Actually enable multi cluster SMP */ - smp_set_ops(&sunxi_mc_smp_smp_ops); - - pr_info("sunxi multi cluster SMP support installed\n"); - return 0; -err_unmap_release_secure_sram: - iounmap(sram_b_smp_base); - of_address_to_resource(sram_node, 0, &res); - release_mem_region(res.start, resource_size(&res)); err_put_sram_node: of_node_put(sram_node); err_unmap_release_cpucfg: @@ -785,6 +751,57 @@ static int __init sunxi_mc_smp_init(void) of_node_put(cpucfg_node); err_unmap_prcm: iounmap(prcm_base); + + return ret; +} + +static void sun9i_iounmap(void) +{ + iounmap(sram_b_smp_base); + iounmap(cpucfg_base); + iounmap(prcm_base); +} + +static int __init sunxi_mc_smp_init(void) +{ + struct resource res; + int ret; + + if (!of_machine_is_compatible("allwinner,sun9i-a80")) + return -ENODEV; + + if (!sunxi_mc_smp_cpu_table_init()) + return -EINVAL; + + if (!cci_probed()) { + pr_err("%s: CCI-400 not available\n", __func__); + return -ENODEV; + } + + ret = sun9i_dt_parsing(res); + if (ret) { + pr_err("%s: failed to parse DT: %d\n", __func__, ret); + return ret; + } + + /* Configure CCI-400 for boot cluster */ + ret = sunxi_mc_smp_lookback(); + if (ret) { + pr_err("%s: failed to configure boot cluster: %d\n", + __func__, ret); + sun9i_iounmap(); + return ret; + } + + /* Set the hardware entry point address */ + writel(__pa_symbol(sunxi_mc_smp_secondary_startup), + prcm_base + PRCM_CPU_SOFT_ENTRY_REG); + + /* Actually enable multi cluster SMP */ + smp_set_ops(&sunxi_mc_smp_smp_ops); + + pr_info("sunxi multi cluster SMP support installed\n"); + return ret; } -- 2.11.0