From patchwork Fri Jan 6 17:16:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic PALLARDY X-Patchwork-Id: 9501531 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 3BD1A6021C for ; Fri, 6 Jan 2017 17:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 275A6284C2 for ; Fri, 6 Jan 2017 17:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C12E28505; Fri, 6 Jan 2017 17:16:42 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5E0A284C2 for ; Fri, 6 Jan 2017 17:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754822AbdAFRQl (ORCPT ); Fri, 6 Jan 2017 12:16:41 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:15395 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754775AbdAFRQl (ORCPT ); Fri, 6 Jan 2017 12:16:41 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v06HGdvr029554; Fri, 6 Jan 2017 18:16:39 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 27p2pa0kvs-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 06 Jan 2017 18:16:39 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 58B5D31; Fri, 6 Jan 2017 17:16:38 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2FB324ECE; Fri, 6 Jan 2017 17:16:38 +0000 (GMT) Received: from localhost (10.201.23.23) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.444.0; Fri, 6 Jan 2017 18:16:37 +0100 From: Loic Pallardy To: , , CC: , , , Subject: [PATCH v2 2/3] remoteproc: st: add da to va support Date: Fri, 6 Jan 2017 18:16:12 +0100 Message-ID: <1483722973-21531-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483722973-21531-1-git-send-email-loic.pallardy@st.com> References: <1483722973-21531-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-06_14:, , signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ST remoteproc driver needs to provide information about carveout memory region to allow remoteproc core to load firmware and access trace buffer. Signed-off-by: Loic Pallardy --- drivers/remoteproc/st_remoteproc.c | 42 ++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index 2d99111..b6eb716 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,10 @@ struct st_rproc { struct mbox_chan *mbox_chan[ST_RPROC_MAX_VRING][MBOX_MAX]; struct mbox_client mbox_client_vq0; struct mbox_client mbox_client_vq1; + phys_addr_t mem_phys; + phys_addr_t mem_reloc; + void *mem_region; + size_t mem_size; }; static void st_rproc_mbox_callback(struct device *dev, u32 msg) @@ -155,10 +160,23 @@ static int st_rproc_stop(struct rproc *rproc) return sw_err ?: pwr_err; } +static void *st_proc_da_to_va(struct rproc *rproc, u64 da, int len) +{ + struct st_rproc *ddata = rproc->priv; + int offset; + + offset = da - ddata->mem_reloc; + if (offset < 0 || offset + len > ddata->mem_size) + return NULL; + + return ddata->mem_region + offset; +} + static struct rproc_ops st_rproc_ops = { .kick = st_rproc_kick, .start = st_rproc_start, .stop = st_rproc_stop, + .da_to_va = st_proc_da_to_va, }; /* @@ -206,7 +224,8 @@ static int st_rproc_parse_dt(struct platform_device *pdev) struct device *dev = &pdev->dev; struct rproc *rproc = platform_get_drvdata(pdev); struct st_rproc *ddata = rproc->priv; - struct device_node *np = dev->of_node; + struct device_node *np = dev->of_node, *node; + struct resource res; int err; if (ddata->config->sw_reset) { @@ -250,10 +269,23 @@ static int st_rproc_parse_dt(struct platform_device *pdev) return -EINVAL; } - err = of_reserved_mem_device_init(dev); - if (err) { - dev_err(dev, "Failed to obtain shared memory\n"); + node = of_parse_phandle(np, "memory-region", 0); + if (!node) { + dev_err(dev, "No memory-region specified\n"); + return -EINVAL; + } + + err = of_address_to_resource(node, 0, &res); + if (err) return err; + + ddata->mem_phys = ddata->mem_reloc = res.start; + ddata->mem_size = resource_size(&res); + ddata->mem_region = devm_ioremap_wc(dev, ddata->mem_phys, ddata->mem_size); + if (!ddata->mem_region) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &res.start, ddata->mem_size); + return -EBUSY; } err = clk_prepare(ddata->clk); @@ -390,8 +422,6 @@ static int st_rproc_remove(struct platform_device *pdev) clk_disable_unprepare(ddata->clk); - of_reserved_mem_device_release(&pdev->dev); - mbox_free_channel(ddata->mbox_chan[0][MBOX_RX]); mbox_free_channel(ddata->mbox_chan[1][MBOX_RX]); mbox_free_channel(ddata->mbox_chan[0][MBOX_TX]);