Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942326AbcJ0S6H (ORCPT ); Thu, 27 Oct 2016 14:58:07 -0400 Received: from arroyo.ext.ti.com ([198.47.19.12]:43271 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964886AbcJ0S5p (ORCPT ); Thu, 27 Oct 2016 14:57:45 -0400 From: Dave Gerlach To: Arnd Bergmann , Russell King , Dan Williams CC: , , , Greg Kroah-Hartman , Shawn Guo , Tony Lindgren , Alexandre Belloni , Nishanth Menon , Dave Gerlach 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 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1887 Lines: 44 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) -- 2.9.3