From patchwork Tue Aug 1 15:48:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 9874883 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 CD9E360361 for ; Tue, 1 Aug 2017 15:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE2B8252D5 for ; Tue, 1 Aug 2017 15:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B04E1280DE; Tue, 1 Aug 2017 15:50: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 06C8E252D5 for ; Tue, 1 Aug 2017 15:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PFG25UC6JSCY3xTD1jl44A8Dt3MroDbT0AB0INZDQ84=; b=pyb3txrvPKzKvn uJTd1Yp19DnUzNnG0lvfGdSYvrHfQDeiaRcSdLSf2vh+9Xxi99/Vepw9RdjgeEbWYyDa9+Jr839kk QOfD8PleNQkXDttuV2dPKLsNR3aBMRs/X7/x4oQFQVLKjrVGwgt8qBw9Rtisgyhysr98uD3Pbhg7A wM7Yf5E5DGmL1r4f5kqUihThx51Wczrk09yy9Qh3ZIY8LdfDU6Mma9mUC9y7VpYPhOu0LEFP1+sK/ FsYYCb7cRNFxQHK4JjIDsO/mztlJbpqsU4Mjyrda8+XhlQCJXPNgPJG44QW5KqsHi4SY6mUCUyQxq Qa0fjHVNqW0nL4QYbNJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcZRZ-0002jz-CE; Tue, 01 Aug 2017 15:50:49 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcZR2-0001u8-8A for linux-arm-kernel@bombadil.infradead.org; Tue, 01 Aug 2017 15:50:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mkqmhnGdmywWwol9uIX4lDS1P6z/1eCTb32Pw67+IWU=; b=wrmavUVrihQCuhxe8vicLBjkN 9xjFcCGOm3vBlO5QTPSOtuM6Mo1R6Fkm+oaGVsBkBQ2ZptYu64WRT8ZTD+iwX3IUsLR2NTzwIwC3e IPXva049qrANWC8ymLutanVdxbxOiyeJGwjkCeXjHr6xD4hCzvaEwPhdJXtWE15XkmVzGizP942yc +h21mEargXndfjZaGt13xyjgW8hF3p9PAeVppt5kfwaFyDQ77vqOMr2K6Ig/bTHrkGCiZ8Ee1lSi8 P66iWxy7ys/kpdanfgkcKjOkLG0oM/hLbXpqWYM6Dj99T5P2ELDZxBmYGnLyaqFDLWBiRTPRFQiBI Kww4sbO0Q==; Received: from fllnx209.ext.ti.com ([198.47.19.16]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcZQz-0007ox-7h for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2017 15:50:14 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v71FmrYq005505; Tue, 1 Aug 2017 10:48:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1501602533; bh=rCc3sXx7d6xcZMwHU9flGeh1aR9F+8u/TjVmLksdi80=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NM+zU87WWQLi4OKIrTzV2ANeOfxzw0DmuZfdonB4K67Ozj5LkWGGK2Kgy3JJ4lZTB 20c1832Ta13btdM5lnI7EsHMM6pYoqojNeE8YDjDhVXO+IHZ2jy21WCC1TsqxuPr49 /Zl20pb8OGhjDzHuIHSPgCadLfGAsixfoM/9f7jQ= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v71Fmmmr001096; Tue, 1 Aug 2017 10:48:48 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Tue, 1 Aug 2017 10:48:48 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v71FmmiK020935; Tue, 1 Aug 2017 10:48:48 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v71Fmm323822; Tue, 1 Aug 2017 10:48:48 -0500 (CDT) From: Suman Anna To: Bjorn Andersson , Ohad Ben-Cohen , Rob Herring Subject: [PATCH v2 2/4] remoteproc/davinci: Add support to parse internal memories Date: Tue, 1 Aug 2017 10:48:42 -0500 Message-ID: <20170801154844.24662-3-s-anna@ti.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170801154844.24662-1-s-anna@ti.com> References: <20170801154844.24662-1-s-anna@ti.com> MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Robert Tivy , Sekhar Nori , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, 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 The DSP subsystem on OMAP-L13x SoCs has various internal RAM memories that can accessed from the ARM side. These memories can be configured to be used as either RAM or Cache. The Davinci remoteproc driver has been enhanced to parse and store the kernel mappings for these internal RAM memories. These mappings can then be used to support direct loading of text/data into these memories from the remoteproc driver. Signed-off-by: Suman Anna --- v2: No code changes drivers/remoteproc/da8xx_remoteproc.c | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index 280b66d4f622..c1cff78de67b 100644 --- a/drivers/remoteproc/da8xx_remoteproc.c +++ b/drivers/remoteproc/da8xx_remoteproc.c @@ -38,9 +38,27 @@ MODULE_PARM_DESC(da8xx_fw_name, #define SYSCFG_CHIPSIG3 BIT(3) #define SYSCFG_CHIPSIG4 BIT(4) +#define DA8XX_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) + +/** + * struct da8xx_rproc_mem - internal memory structure + * @cpu_addr: MPU virtual address of the memory region + * @bus_addr: Bus address used to access the memory region + * @dev_addr: Device address of the memory region from DSP view + * @size: Size of the memory region + */ +struct da8xx_rproc_mem { + void __iomem *cpu_addr; + phys_addr_t bus_addr; + u32 dev_addr; + size_t size; +}; + /** * struct da8xx_rproc - da8xx remote processor instance state * @rproc: rproc handle + * @mem: internal memory regions data + * @num_mems: number of internal memory regions * @dsp_clk: placeholder for platform's DSP clk * @ack_fxn: chip-specific ack function for ack'ing irq * @irq_data: ack_fxn function parameter @@ -50,6 +68,8 @@ MODULE_PARM_DESC(da8xx_fw_name, */ struct da8xx_rproc { struct rproc *rproc; + struct da8xx_rproc_mem *mem; + int num_mems; struct clk *dsp_clk; void (*ack_fxn)(struct irq_data *data); struct irq_data *irq_data; @@ -158,6 +178,44 @@ static const struct rproc_ops da8xx_rproc_ops = { .kick = da8xx_rproc_kick, }; +static int da8xx_rproc_get_internal_memories(struct platform_device *pdev, + struct da8xx_rproc *drproc) +{ + static const char * const mem_names[] = {"l2sram", "l1pram", "l1dram"}; + int num_mems = ARRAY_SIZE(mem_names); + struct device *dev = &pdev->dev; + struct resource *res; + int i; + + drproc->mem = devm_kcalloc(dev, num_mems, sizeof(*drproc->mem), + GFP_KERNEL); + if (!drproc->mem) + return -ENOMEM; + + for (i = 0; i < num_mems; i++) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + mem_names[i]); + drproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res); + if (IS_ERR(drproc->mem[i].cpu_addr)) { + dev_err(dev, "failed to parse and map %s memory\n", + mem_names[i]); + return PTR_ERR(drproc->mem[i].cpu_addr); + } + drproc->mem[i].bus_addr = res->start; + drproc->mem[i].dev_addr = + res->start & DA8XX_RPROC_LOCAL_ADDRESS_MASK; + drproc->mem[i].size = resource_size(res); + + dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n", + mem_names[i], &drproc->mem[i].bus_addr, + drproc->mem[i].size, drproc->mem[i].cpu_addr, + drproc->mem[i].dev_addr); + } + drproc->num_mems = num_mems; + + return 0; +} + static int da8xx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -213,6 +271,10 @@ static int da8xx_rproc_probe(struct platform_device *pdev) drproc->dsp_clk = dsp_clk; rproc->has_iommu = false; + ret = da8xx_rproc_get_internal_memories(pdev, drproc); + if (ret) + goto free_rproc; + platform_set_drvdata(pdev, rproc); /* everything the ISR needs is now setup, so hook it up */