From patchwork Wed Nov 26 21:22:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 5388121 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4B6729F319 for ; Wed, 26 Nov 2014 21:23:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 639B9201C8 for ; Wed, 26 Nov 2014 21:23:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81CC5201B9 for ; Wed, 26 Nov 2014 21:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751028AbaKZVXi (ORCPT ); Wed, 26 Nov 2014 16:23:38 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:33620 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbaKZVXg (ORCPT ); Wed, 26 Nov 2014 16:23:36 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id sAQLMOXO031475; Wed, 26 Nov 2014 15:22:24 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAQLMO3V021689; Wed, 26 Nov 2014 15:22:24 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 26 Nov 2014 15:22:24 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAQLMOBl010941; Wed, 26 Nov 2014 15:22:24 -0600 Received: from localhost (j-172-22-146-2.vpn.ti.com [172.22.146.2]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id sAQLMNt14176; Wed, 26 Nov 2014 15:22:23 -0600 (CST) From: Dave Gerlach To: , , , CC: Russ Dill , Greg Kroah-Hartman , Arnd Bergmann , Philipp Zabel , Shawn Guo , Tony Lindgren , , Russ Dill , Dave Gerlach Subject: [RFC PATCH] misc: SRAM: Add option to map SRAM to allow code execution Date: Wed, 26 Nov 2014 15:22:18 -0600 Message-ID: <5cca5199a7e675d2ac35b4e7f2901b10bbd5f4be.1417029919.git.d-gerlach@ti.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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: Russ Dill Allow option for mapping SRAM as executable. This is useful for platforms using the sram driver that need to run PM code from sram like several ARM platforms. Signed-off-by: Russ Dill Signed-off-by: Dave Gerlach --- This patch depends on the series here [1] and can be seen in context as a dependency for am335x suspend in this branch based on v3.18-rc6 here [2]. [1] http://lkml.iu.edu/hypermail/linux/kernel/1411.3/02782.html [2] https://github.com/dgerlach/linux-pm/tree/rfc-pm-am335x-v3.18-rc6 Documentation/devicetree/bindings/misc/sram.txt | 1 + drivers/misc/sram.c | 13 ++++++++++++- include/linux/platform_data/sram.h | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 include/linux/platform_data/sram.h diff --git a/Documentation/devicetree/bindings/misc/sram.txt b/Documentation/devicetree/bindings/misc/sram.txt index 36cbe5a..c5ecde4 100644 --- a/Documentation/devicetree/bindings/misc/sram.txt +++ b/Documentation/devicetree/bindings/misc/sram.txt @@ -33,6 +33,7 @@ Optional properties in the area nodes: - compatible : standard definition, should contain a vendor specific string in the form ,[-] +- map-exec : Map range to allow code execution Example: diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 21181fa..f5822de 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -31,6 +31,7 @@ #include #include #include +#include #define SRAM_GRANULARITY 32 @@ -56,6 +57,7 @@ static int sram_reserve_cmp(void *priv, struct list_head *a, static int sram_probe(struct platform_device *pdev) { + struct sram_platform_data *pdata = pdev->dev.platform_data; void __iomem *virt_base; struct sram_dev *sram; struct resource *res; @@ -64,12 +66,21 @@ static int sram_probe(struct platform_device *pdev) struct sram_reserve *rblocks, *block; struct list_head reserve_list; unsigned int nblocks; + bool map_exec = false; int ret; INIT_LIST_HEAD(&reserve_list); + if (of_get_property(pdev->dev.of_node, "map-exec", NULL)) + map_exec = true; + if (pdata && pdata->map_exec) + map_exec |= true; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - virt_base = devm_ioremap_resource(&pdev->dev, res); + if (map_exec) + virt_base = devm_ioremap_exec_resource(&pdev->dev, res); + else + virt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(virt_base)) return PTR_ERR(virt_base); diff --git a/include/linux/platform_data/sram.h b/include/linux/platform_data/sram.h new file mode 100644 index 0000000..8f5c4ba --- /dev/null +++ b/include/linux/platform_data/sram.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_SRAM_H +#define _LINUX_SRAM_H + +struct sram_platform_data { + bool map_exec; +}; + +#endif