From patchwork Thu Oct 27 18:56:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 9400227 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 734EF60231 for ; Thu, 27 Oct 2016 18:59:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59E5F2A382 for ; Thu, 27 Oct 2016 18:59:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EC032A385; Thu, 27 Oct 2016 18:59:54 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D4DCB2A382 for ; Thu, 27 Oct 2016 18:59:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzpss-0004sN-0u; Thu, 27 Oct 2016 18:58:38 +0000 Received: from arroyo.ext.ti.com ([198.47.19.12]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzprx-0004U5-Gs for linux-arm-kernel@lists.infradead.org; Thu, 27 Oct 2016 18:57:43 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9RIuxjH013805; Thu, 27 Oct 2016 13:56:59 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9RIuxC9023235; Thu, 27 Oct 2016 13:56:59 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Thu, 27 Oct 2016 13:56:59 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9RIuxi6021118; Thu, 27 Oct 2016 13:56:59 -0500 Received: from localhost (uda0274052.am.dhcp.ti.com [128.247.83.19]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u9RIuw327519; Thu, 27 Oct 2016 13:56:58 -0500 (CDT) From: Dave Gerlach To: Arnd Bergmann , Russell King , Dan Williams Subject: [PATCH 3/3] misc: SRAM: Add option to map SRAM to allow code execution Date: Thu, 27 Oct 2016 13:56:12 -0500 Message-ID: <20161027185612.22362-4-d-gerlach@ti.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161027185612.22362-1-d-gerlach@ti.com> References: <20161027185612.22362-1-d-gerlach@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161027_115741_746364_D18E7928 X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishanth Menon , Dave Gerlach , Tony Lindgren , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Alexandre Belloni , linux-omap@vger.kernel.org, Shawn Guo , 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 Allow option for mapping SRAM as executable. DT node can specify "memory-exec" and "memory-exec-nocache" to also map it as non-cached. This is useful for platforms using the sram driver that need to run PM code from sram like several ARM platforms. Signed-off-by: Dave Gerlach --- Documentation/devicetree/bindings/sram/sram.txt | 2 ++ drivers/misc/sram.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/sram/sram.txt b/Documentation/devicetree/bindings/sram/sram.txt index add48f09015e..8eac557204e5 100644 --- a/Documentation/devicetree/bindings/sram/sram.txt +++ b/Documentation/devicetree/bindings/sram/sram.txt @@ -29,6 +29,8 @@ Optional properties in the sram node: - no-memory-wc : the flag indicating, that SRAM memory region has not to be remapped as write combining. WC is used by default. +- memory-exec : map range to allow code execution +- memory-exec-nocache : map range to allow code execution and also non-cached Required properties in the area nodes: diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index f84b53d6ce50..a9ba1be115bb 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -362,6 +362,13 @@ static int sram_probe(struct platform_device *pdev) if (of_property_read_bool(pdev->dev.of_node, "no-memory-wc")) sram->virt_base = devm_ioremap(sram->dev, res->start, size); + else if (of_property_read_bool(pdev->dev.of_node, "memory-exec")) + sram->virt_base = devm_memremap(sram->dev, res->start, size, + MEMREMAP_EXEC); + else if (of_property_read_bool(pdev->dev.of_node, + "memory-exec-nocache")) + sram->virt_base = devm_memremap(sram->dev, res->start, size, + MEMREMAP_EXEC_NOCACHE); else sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size); if (!sram->virt_base)