From patchwork Mon May 4 11:46:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 6325521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2A138BEEE1 for ; Mon, 4 May 2015 11:50:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 432C3202EB for ; Mon, 4 May 2015 11:50:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D54E202E6 for ; Mon, 4 May 2015 11:50:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpEqK-0001G4-5X; Mon, 04 May 2015 11:47:24 +0000 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpEqC-0001Cf-EG for linux-arm-kernel@lists.infradead.org; Mon, 04 May 2015 11:47:17 +0000 Received: by pdbqa5 with SMTP id qa5so160863955pdb.1 for ; Mon, 04 May 2015 04:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=or+EooFv//F5/+JWoPmdI0NW8P2Ae4sNLeqid4pF95o=; b=tLF9Tw/vptofOkkVR5fYSK3UPptgpl29mkjmcLu/Sbx3Wuc/4HnxprusshBJUePvf/ uLdeAq45+Au/QSDd9NYwdZ+cbK28TraAzI1P/c44YLp/NDNQQs1Mk8d3qNz3p2xu1sIr Ous1CU4ZremYjLun7QdUyc+AWjvIx1ZLEk4i8ulUosz3FyAo8IDJluQzhmB7x0em5Oba +RV6JD2OQfonO5nZQXmPlXo0kfXZmdGqnhxvgj3HSZRnHcYx96O/+9islr7jARc6QXJD g4Y+PkJeYse/d/i+9wJrZ33xbrKnUd8f1qpMmtmpVMk8EOAssDiLQpNpXvzT+q4w5Hpl m7cw== X-Received: by 10.70.90.231 with SMTP id bz7mr41317287pdb.15.1430740015248; Mon, 04 May 2015 04:46:55 -0700 (PDT) Received: from localhost ([216.228.120.20]) by mx.google.com with ESMTPSA id ux4sm12585526pbc.61.2015.05.04.04.46.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 04:46:54 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Mark Rutland Subject: [PATCH 1/8] soc/tegra: pmc: Restrict legacy code to 32-bit ARM Date: Mon, 4 May 2015 13:46:39 +0200 Message-Id: <1430740006-29539-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430740006-29539-1-git-send-email-thierry.reding@gmail.com> References: <1430740006-29539-1-git-send-email-thierry.reding@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150504_044716_553145_62522869 X-CRM114-Status: GOOD ( 18.12 ) X-Spam-Score: -0.8 (/) Cc: Alexandre Courbot , Paul Walmsley , Stephen Warren , Peter De Schrijver , Paul Walmsley , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 From: Thierry Reding For backwards-compatibility with old device trees, if no PMC node exists this driver hard-codes the I/O memory region. All 64-bit ARM device tree files are recent enough that they can be required to have this node, and therefore the legacy code path is not required on 64-bit ARM. Based on work done by Paul Walmsley . Cc: Paul Walmsley Signed-off-by: Thierry Reding --- drivers/soc/tegra/pmc.c | 56 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index c956395cf46f..500339985dbe 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -17,6 +17,8 @@ * */ +#define pr_fmt(fmt) "tegra-pmc: " fmt + #include #include #include @@ -992,6 +994,7 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = { }; static const struct of_device_id tegra_pmc_match[] = { + { .compatible = "nvidia,tegra132-pmc", .data = &tegra124_pmc_soc }, { .compatible = "nvidia,tegra124-pmc", .data = &tegra124_pmc_soc }, { .compatible = "nvidia,tegra114-pmc", .data = &tegra114_pmc_soc }, { .compatible = "nvidia,tegra30-pmc", .data = &tegra30_pmc_soc }, @@ -1024,25 +1027,44 @@ static int __init tegra_pmc_early_init(void) bool invert; u32 value; - if (!soc_is_tegra()) - return 0; - np = of_find_matching_node_and_match(NULL, tegra_pmc_match, &match); if (!np) { - pr_warn("PMC device node not found, disabling powergating\n"); - - regs.start = 0x7000e400; - regs.end = 0x7000e7ff; - regs.flags = IORESOURCE_MEM; - - pr_warn("Using memory region %pR\n", ®s); + /* + * Fall back to legacy initialization for 32-bit ARM only. All + * 64-bit ARM device tree files for Tegra are required to have + * a PMC node. + * + * This is for backwards-compatibility with old device trees + * that didn't contain a PMC node. Note that in this case the + * SoC data can't be matched and therefore powergating is + * disabled. + */ + if (IS_ENABLED(CONFIG_ARM) && soc_is_tegra()) { + pr_warn("DT node not found, powergating disabled\n"); + + regs.start = 0x7000e400; + regs.end = 0x7000e7ff; + regs.flags = IORESOURCE_MEM; + + pr_warn("Using memory region %pR\n", ®s); + } else { + /* + * At this point we're not running on Tegra, so play + * nice with multi-platform kernels. + */ + return 0; + } } else { - pmc->soc = match->data; - } + /* + * Extract information from the device tree if we've found a + * matching node. + */ + if (of_address_to_resource(np, 0, ®s) < 0) { + pr_err("failed to get PMC registers\n"); + return -ENXIO; + } - if (of_address_to_resource(np, 0, ®s) < 0) { - pr_err("failed to get PMC registers\n"); - return -ENXIO; + pmc->soc = match->data; } pmc->base = ioremap_nocache(regs.start, resource_size(®s)); @@ -1053,6 +1075,10 @@ static int __init tegra_pmc_early_init(void) mutex_init(&pmc->powergates_lock); + /* + * Invert the interrupt polarity if a PMC device tree node exists and + * contains the nvidia,invert-interrupt property. + */ invert = of_property_read_bool(np, "nvidia,invert-interrupt"); value = tegra_pmc_readl(PMC_CNTRL);