From patchwork Mon Oct 28 12:42:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 177914 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3339164ill; Mon, 28 Oct 2019 05:43:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxY2HUkRRV61sT5T27C3DIpAZhBDj+hO+AvtCc/+2jY/zZq/fVL6G42mCax8JUtT/Zm8H6E X-Received: by 2002:a50:f306:: with SMTP id p6mr7268732edm.284.1572266589343; Mon, 28 Oct 2019 05:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572266589; cv=none; d=google.com; s=arc-20160816; b=JRQd/xojcQZnH+Q7QdyC/4vSPAZIxvZ83F1vBNiQ/gC0lNXFQFCFnE1/xT3YXKrN2P dD3ONxrXeaOu58vpJw2VU0dya+H57bQ6+3xSby09CDUqQjW/nNyTA1o6qec0bb0L5bJR Wlt7dWCTBDLTCKW35zIuVhUOJ7LCuJq8sLsVHDNGtDic/Ej+//JVrqD6uFWuvxdI+5NZ u37AVDZ6zRGS//g9Eq9rofuioRNP1e3aMYFBGE+ceftwJMZo6S7AhH2yiL5sysB6JXP9 YATFAxN5hIYiSCmp7zQeasH1u/lzW4U+spUyxtW64Fpxuq9yn7HeXuBFPjQs7JZ+xg5r 3NcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kORRencE9DM8NfTqtaMIohHglGjh+p4ato3bv8Q2oMs=; b=h1S4v7ZiCDVwxm5gwSBmMTQRKvFV1FQq6w7II8ntpPK/0kq6HhugHf9u9zUlspRnL0 Uta7Y4ERvPUxGq46B3DD1YY+OSM2WF+4UqEyK7tJ5kf+1RjXd0MHDj9ogx7BEChKcNBC dyM+DfP+iY7FgUQap6fsLH+vhr6nDF5H51O58X/9xERBrQGOzCm4RlThpKzHrvasiCo8 eu3GBqELFAisJD88djrTkGHTrO9T2e4pKfBhN3ZLU6etpOngfon6duHD9uEj79oNuPya ngUBxxqPWhcqvuD6I0H1ylFwwd2GgyX9kvn7Gu7QFSgGvYn5nu8RyavCbkzZEEyOISer 8y7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VO5zVgxL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si6238715ejj.288.2019.10.28.05.43.09; Mon, 28 Oct 2019 05:43:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VO5zVgxL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389304AbfJ1MnI (ORCPT + 26 others); Mon, 28 Oct 2019 08:43:08 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:48222 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389230AbfJ1MnF (ORCPT ); Mon, 28 Oct 2019 08:43:05 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9SCh4hR016610; Mon, 28 Oct 2019 07:43:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572266584; bh=kORRencE9DM8NfTqtaMIohHglGjh+p4ato3bv8Q2oMs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=VO5zVgxLXHGx0Ya0ikqnXBdW+tGudvi4TvHFdzX2tKzVNXD5WBYcDWrKEbz4z4fz6 rbT37xBFAk0iQuMiPYP6xiA0ZXYD7QFf9QoWoqdK7u8kWfOVFh4eZRkBiQCc3Cg4y3 2DUny/oywJ4PNWpLlT2H7xjFBtVBO4wVmB9Cf1PE= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9SCh4lR074933 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Oct 2019 07:43:04 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 28 Oct 2019 07:42:52 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Oct 2019 07:42:51 -0500 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9SCgogv063574; Mon, 28 Oct 2019 07:43:02 -0500 From: Tero Kristo To: , , CC: , , , Tero Kristo Subject: [PATCH 05/17] remoteproc/omap: Add support to parse internal memories from DT Date: Mon, 28 Oct 2019 14:42:26 +0200 Message-ID: <20191028124238.19224-6-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028124238.19224-1-t-kristo@ti.com> References: <20191028124238.19224-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suman Anna The OMAP remoteproc driver has been enhanced to parse and store the kernel mappings for different internal RAM memories that may be present within each remote processor IP subsystem. Different devices have varying memories present on current SoCs. The current support handles the L2RAM for all IPU devices on OMAP4+ SoCs. The DSPs on OMAP4/OMAP5 only have Unicaches and do not have any L1 or L2 RAM memories. IPUs are expected to have the L2RAM at a fixed device address of 0x20000000, based on the current limitations on Attribute MMU configurations. NOTE: The current logic doesn't handle the parsing of memories for DRA7 remoteproc devices, and will be added alongside the DRA7 support. Signed-off-by: Suman Anna Signed-off-by: Tero Kristo --- drivers/remoteproc/omap_remoteproc.c | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index a10377547533..bbd6ff360e10 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -29,6 +29,8 @@ #include "omap_remoteproc.h" #include "remoteproc_internal.h" +#define OMAP_RPROC_IPU_L2RAM_DEV_ADDR (0x20000000) + /** * struct omap_rproc_boot_data - boot data structure for the DSP omap rprocs * @syscon: regmap handle for the system control configuration module @@ -39,11 +41,27 @@ struct omap_rproc_boot_data { unsigned int boot_reg; }; +/* + * struct omap_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 omap_rproc_mem { + void __iomem *cpu_addr; + phys_addr_t bus_addr; + u32 dev_addr; + size_t size; +}; + /** * struct omap_rproc - omap remote processor state * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel * @boot_data: boot data structure for setting processor boot address + * @mem: internal memory regions data + * @num_mems: number of internal memory regions * @rproc: rproc handle * @reset: reset handle */ @@ -51,6 +69,8 @@ struct omap_rproc { struct mbox_chan *mbox; struct mbox_client client; struct omap_rproc_boot_data *boot_data; + struct omap_rproc_mem *mem; + int num_mems; struct rproc *rproc; struct reset_control *reset; }; @@ -307,6 +327,51 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev, return 0; } +static int omap_rproc_of_get_internal_memories(struct platform_device *pdev, + struct rproc *rproc) +{ + static const char * const mem_names[] = {"l2ram"}; + struct device_node *np = pdev->dev.of_node; + struct omap_rproc *oproc = rproc->priv; + struct device *dev = &pdev->dev; + struct resource *res; + int num_mems; + int i; + + /* OMAP4 and OMAP5 DSPs do not have support for flat SRAM */ + if (of_device_is_compatible(np, "ti,omap4-dsp") || + of_device_is_compatible(np, "ti,omap5-dsp")) + return 0; + + num_mems = ARRAY_SIZE(mem_names); + oproc->mem = devm_kcalloc(dev, num_mems, sizeof(*oproc->mem), + GFP_KERNEL); + if (!oproc->mem) + return -ENOMEM; + + for (i = 0; i < num_mems; i++) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + mem_names[i]); + oproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res); + if (IS_ERR(oproc->mem[i].cpu_addr)) { + dev_err(dev, "failed to parse and map %s memory\n", + mem_names[i]); + return PTR_ERR(oproc->mem[i].cpu_addr); + } + oproc->mem[i].bus_addr = res->start; + oproc->mem[i].dev_addr = OMAP_RPROC_IPU_L2RAM_DEV_ADDR; + oproc->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], &oproc->mem[i].bus_addr, + oproc->mem[i].size, oproc->mem[i].cpu_addr, + oproc->mem[i].dev_addr); + } + oproc->num_mems = num_mems; + + return 0; +} + static int omap_rproc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -346,6 +411,10 @@ static int omap_rproc_probe(struct platform_device *pdev) /* All existing OMAP IPU and DSP processors have an MMU */ rproc->has_iommu = true; + ret = omap_rproc_of_get_internal_memories(pdev, rproc); + if (ret) + goto free_rproc; + ret = omap_rproc_get_boot_data(pdev, rproc); if (ret) goto free_rproc;