From patchwork Mon Nov 26 07:52:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151972 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328561ljp; Sun, 25 Nov 2018 23:53:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXd3CL7rfqLC5LlagkEv+1I5SZ260Sr94uCHTfiOqIrrhZHU5a4t6ZcVQNjxMk+Xg58HZr X-Received: by 2002:a17:902:15c5:: with SMTP id a5-v6mr26207100plh.136.1543218787235; Sun, 25 Nov 2018 23:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218787; cv=none; d=google.com; s=arc-20160816; b=iyLqRDaamSAMuTUt8GcumBESQ76IMwacgGnfFkv3tYDaYSaPm+YaRk4HGZfjaKrDhB hcD9ldpLrEh2cchCZuXZWRdDu4p+mW2lAgts9Y7U2FfnFwpmryDcNIVDIJyBXqUWPQMC DDKsf3QJlQSTJ27rPRckNIe0BlU9CpMohSSynxveA1ipZyRzMiriEdN05UO/+MhJ/594 lK9R1SFqYbdYM9kIheyxptVCZnU0o0ZxmG+BdrxsHiEaL+PtBMh54BgYz1vFmxKmMKTV dnpwZ+cU+cuFvBsnKfC8+AXuH4XHEQoeYyNvivHFlJf2vpeYx57QH5mLICBqe+k49IC7 oX/g== 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=7kOxLaAQ9Jp0JZcpYjcc6R3FqKlSJT75I2AzPGbOI1M=; b=THTy1VCY0YtWO1WPr7GnLrL66A8E1ryy1KirVCvWYkdeKH+r+cnZV8oaNFKdDRxh3j MlW0ECciuvHDG/tMOepal5J2vhJRgkexuSaO8pXQmANR+mfMCq1Q7Hsdj+UkXDYYY1df vOD59uPLm8uIP3yVqwV0S0Rq+01DIgqC+acGqmbTyQzImxthZ5MRZI3SH646gE/ztFzF 2RfYny5MspbVTR1xGlHW+tCAYAIUXHU3GqG//ly20xLhyLtg3626tl4t6XvfPdBS1BJA Hbtl/Xgfa052GJ/bZEqgXxt+CUxccPx8XI8xBgTdBKwnJg1/bpRvOouyhoiXy4QGAOmS lm/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=acJH0YJZ; 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 s123si3831004pfb.274.2018.11.25.23.53.06; Sun, 25 Nov 2018 23:53:07 -0800 (PST) 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=acJH0YJZ; 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 S1726413AbeKZSqU (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:20 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:40880 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbeKZSqT (ORCPT ); Mon, 26 Nov 2018 13:46:19 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7qw36043386; Mon, 26 Nov 2018 01:52:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218778; bh=7kOxLaAQ9Jp0JZcpYjcc6R3FqKlSJT75I2AzPGbOI1M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=acJH0YJZoUE0yXAugA2OAgBUx/uY9Uw7049BX3WIXdFkfZ6mbUovLttcWRXa1taQZ HB4b+I062PA4/mb7A4SLpCD5gLpO2pmfW4GuD0om/pVRgCpQkp29SAAEuMQxLItrpP ER9mxQAvjy8xSPAEVVyQxDiiijZi0gp30AXiuhGw= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7qwnZ059022 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:52:58 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:52:58 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:52:58 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qwt2008479; Mon, 26 Nov 2018 01:52:58 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1F024490; Mon, 26 Nov 2018 01:52:54 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 01/16] remoteproc: Extend rproc_da_to_va() API with a flags parameter Date: Mon, 26 Nov 2018 09:52:34 +0200 Message-ID: <1543218769-5507-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 rproc_da_to_va() API is currently used to perform any device to kernel address translations to meet the different needs of the remoteproc core/platform drivers (eg: loading). The function also invokes the da_to_va ops, if present, to allow the remoteproc platform drivers to provide address translation. However, not all platform implementations have linear address spaces, and may need an additional parameter to be able to perform proper translations. The rproc_da_to_va() API and the rproc .da_to_va ops have therefore been expanded to take in an additional flags field enabling some remoteproc implementations (like the TI PRUSS remoteproc driver) to use these flags. Also, define some semantics for this flags argument as this can vary from one implementation to another. A new flags type is encoded into the upper 16 bits along side the actual value in the lower 16-bits for the flags argument, to allow different individual implementations to have better flexibility in interpreting the flags as per their needs. Also, update the various remoteproc implementations that use the .da_to_va() ops for the new signature. Signed-off-by: Suman Anna --- drivers/remoteproc/imx_rproc.c | 2 +- drivers/remoteproc/keystone_remoteproc.c | 3 ++- drivers/remoteproc/qcom_q6v5_mss.c | 5 +++-- drivers/remoteproc/qcom_q6v5_pas.c | 2 +- drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- drivers/remoteproc/qcom_wcnss.c | 2 +- drivers/remoteproc/remoteproc_core.c | 15 ++++++++++----- drivers/remoteproc/remoteproc_elf_loader.c | 6 ++++-- drivers/remoteproc/remoteproc_internal.h | 2 +- drivers/remoteproc/st_slim_rproc.c | 3 ++- drivers/remoteproc/wkup_m3_rproc.c | 3 ++- include/linux/remoteproc.h | 16 +++++++++++++++- 12 files changed, 43 insertions(+), 18 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 54c07fd..14d7f15 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -211,7 +211,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, return -ENOENT; } -static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct imx_rproc *priv = rproc->priv; void *va = NULL; diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c index aaac311..41c4d5c 100644 --- a/drivers/remoteproc/keystone_remoteproc.c +++ b/drivers/remoteproc/keystone_remoteproc.c @@ -254,7 +254,8 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid) * can be used either by the remoteproc core for loading (when using kernel * remoteproc loader), or by any rpmsg bus drivers. */ -static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len, + u32 flags) { struct keystone_rproc *ksproc = rproc->priv; void __iomem *va = NULL; diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 01be731..3b77e12 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -971,7 +971,8 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, int ret = 0; struct q6v5 *qproc = rproc->priv; unsigned long mask = BIT((unsigned long)segment->priv); - void *ptr = rproc_da_to_va(rproc, segment->da, segment->size); + void *ptr = rproc_da_to_va(rproc, segment->da, segment->size, + RPROC_FLAGS_NONE); /* Unlock mba before copying segments */ if (!qproc->dump_mba_loaded) @@ -1052,7 +1053,7 @@ static int q6v5_stop(struct rproc *rproc) return 0; } -static void *q6v5_da_to_va(struct rproc *rproc, u64 da, int len) +static void *q6v5_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct q6v5 *qproc = rproc->priv; int offset; diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index b1e63fc..46e1c6b 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -167,7 +167,7 @@ static int adsp_stop(struct rproc *rproc) return ret; } -static void *adsp_da_to_va(struct rproc *rproc, u64 da, int len) +static void *adsp_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; int offset; diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c index f93e1e4..5b4d4c6 100644 --- a/drivers/remoteproc/qcom_q6v5_wcss.c +++ b/drivers/remoteproc/qcom_q6v5_wcss.c @@ -406,7 +406,7 @@ static int q6v5_wcss_stop(struct rproc *rproc) return 0; } -static void *q6v5_wcss_da_to_va(struct rproc *rproc, u64 da, int len) +static void *q6v5_wcss_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct q6v5_wcss *wcss = rproc->priv; int offset; diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index b0e07e9..eb7d4b9 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -295,7 +295,7 @@ static int wcnss_stop(struct rproc *rproc) return ret; } -static void *wcnss_da_to_va(struct rproc *rproc, u64 da, int len) +static void *wcnss_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; int offset; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 54ec38f..39458a7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -166,6 +166,7 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) * @rproc: handle of a remote processor * @da: remoteproc device address to translate * @len: length of the memory region @da is pointing to + * @flags: flags to pass onto platform implementations for aiding translations * * Some remote processors will ask us to allocate them physically contiguous * memory regions (which we call "carveouts"), and map them to specific @@ -181,7 +182,10 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) * carveouts and translate specific device addresses to kernel virtual addresses * so we can access the referenced memory. This function also allows to perform * translations on the internal remoteproc memory regions through a platform - * implementation specific da_to_va ops, if present. + * implementation specific da_to_va ops, if present. The @flags field is passed + * onto these ops to aid the translation within the ops implementation. The + * @flags field is to be passed as a combination of the RPROC_FLAGS_xxx type + * and the pertinent flags value for that type. * * The function returns a valid kernel address on success or NULL on failure. * @@ -190,13 +194,13 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) * here the output of the DMA API for the carveouts, which should be more * correct. */ -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) +void *rproc_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) { struct rproc_mem_entry *carveout; void *ptr = NULL; if (rproc->ops->da_to_va) { - ptr = rproc->ops->da_to_va(rproc, da, len); + ptr = rproc->ops->da_to_va(rproc, da, len, flags); if (ptr) goto out; } @@ -575,7 +579,7 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, } /* what's the kernel address of this resource ? */ - ptr = rproc_da_to_va(rproc, rsc->da, rsc->len); + ptr = rproc_da_to_va(rproc, rsc->da, rsc->len, RPROC_FLAGS_NONE); if (!ptr) { dev_err(dev, "erroneous trace resource entry\n"); return -EINVAL; @@ -1549,7 +1553,8 @@ static void rproc_coredump(struct rproc *rproc) if (segment->dump) { segment->dump(rproc, segment, data + offset); } else { - ptr = rproc_da_to_va(rproc, segment->da, segment->size); + ptr = rproc_da_to_va(rproc, segment->da, segment->size, + RPROC_FLAGS_NONE); if (!ptr) { dev_err(&rproc->dev, "invalid coredump segment (%pad, %zu)\n", diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index b17d72e..fff2e0b 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -182,7 +182,8 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) } /* grab the kernel address for this device address */ - ptr = rproc_da_to_va(rproc, da, memsz); + ptr = rproc_da_to_va(rproc, da, memsz, + RPROC_FLAGS_ELF_PHDR | phdr->p_flags); if (!ptr) { dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz); ret = -EINVAL; @@ -333,6 +334,7 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, if (!shdr) return NULL; - return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); + return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size, + RPROC_FLAGS_ELF_SHDR | shdr->sh_flags); } EXPORT_SYMBOL(rproc_elf_find_loaded_rsc_table); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index f6cad24..c62b3e7 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -51,7 +51,7 @@ void rproc_exit_sysfs(void); void rproc_free_vring(struct rproc_vring *rvring); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); +void *rproc_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags); int rproc_trigger_recovery(struct rproc *rproc); int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index d711d94..c41e58c 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c @@ -178,7 +178,8 @@ static int slim_rproc_stop(struct rproc *rproc) return 0; } -static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len, + u32 flags) { struct st_slim_rproc *slim_rproc = rproc->priv; void *va = NULL; diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c index 1ada0e5..eff7497 100644 --- a/drivers/remoteproc/wkup_m3_rproc.c +++ b/drivers/remoteproc/wkup_m3_rproc.c @@ -88,7 +88,8 @@ static int wkup_m3_rproc_stop(struct rproc *rproc) return 0; } -static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, int len, + u32 flags) { struct wkup_m3_rproc *wkupm3 = rproc->priv; void *va = NULL; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 68e72f3..9e01a44 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -41,6 +41,7 @@ #include #include #include +#include /** * struct resource_table - firmware resource table header @@ -339,6 +340,19 @@ struct rproc_mem_entry { struct firmware; +/* + * Macros to use with flags field in rproc_da_to_va API. Use + * the upper 16 bits to dictate the flags type and the lower + * 16 bits to pass on the value of the flags pertinent to that + * type. + * + * Add any new flags type at a new bit-field position + */ +#define RPROC_FLAGS_SHIFT 16 +#define RPROC_FLAGS_NONE 0 +#define RPROC_FLAGS_ELF_PHDR BIT(0 + RPROC_FLAGS_SHIFT) +#define RPROC_FLAGS_ELF_SHDR BIT(1 + RPROC_FLAGS_SHIFT) + /** * struct rproc_ops - platform-specific device handlers * @start: power on the device and boot it @@ -356,7 +370,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); - void * (*da_to_va)(struct rproc *rproc, u64 da, int len); + void * (*da_to_va)(struct rproc *rproc, u64 da, int len, u32 flags); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); From patchwork Mon Nov 26 07:52:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151973 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328626ljp; Sun, 25 Nov 2018 23:53:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wb+quyHqJ3uMODMjt2UyWZf2rIHRMvx9gDemSqzExehg02UrJ5WxEuTlaIFKgPg568Cmc7 X-Received: by 2002:a17:902:14b:: with SMTP id 69mr26869727plb.52.1543218791521; Sun, 25 Nov 2018 23:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218791; cv=none; d=google.com; s=arc-20160816; b=hOcF5OWE6wNtSpKArMghhhAKLzA/BXKnvwNSagOqTSRcrzlBLa5UTIpcNbtlf3js/q pjIGlGfe0WB0D7oMyi021RCNrs3y7wSkRuYr2k/cS9rIMS2i4uiCcfRnOu3rkXT22VOn cSCa1vSMOcfRp1XpJpbQe2JtZIlI217T9xAriro5B1jXcwFtMNc5yOsygnV6eQTL8ivg n+7JP35zsQk+X0ExJxD/q4uRw1Smt9cX2G1UDegMOzQ2lr8omF40O8sU1j7H0lB4oAyu HM0zf/v90fJ+BaX/qU0Qo7U/SD4nQmwaE9EHD3zThi5pLGLKgccQffhXv7FFc868XbJ7 s0Gw== 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=3g8PnxtfE4Aj4rp7f1734/PSgrBTxF/lNlXn7HscNMI=; b=GslEko38+FJSfkkUvNcrGNuexeiMg1dlPPo/ILjvt1HBUmZW2q3d9dLuKXht1eneeP 0tYvh9Wy3A13t/TAndnGyIPXJcJyikF3c+Mf0lA+BEHJXVQGICZ1KyFqggVnvEVlhtcB +4TytkT5cv07Jv8KnOInGVZyrZizlRK0GNOxBGR5PSZG0NFLYUiiNJZM/wBonV5es42i ajWqTIg/ELI2BnxoJEHffgMUEcA3RgDQAN7wnXtpgxX7aiS/AFKYKCBk8JFFROKt3w9Z Th4d51DeIQCsagsMjIpNDmR98d8jpMcrxQN8Vn+/KGjgDaRGvq/YoNAezXI5uQ1ankBu vs2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="a7FL/XzJ"; 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 86si35325874pfl.46.2018.11.25.23.53.11; Sun, 25 Nov 2018 23:53:11 -0800 (PST) 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="a7FL/XzJ"; 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 S1726445AbeKZSqZ (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:25 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:39958 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbeKZSqY (ORCPT ); Mon, 26 Nov 2018 13:46:24 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7r4VH060646; Mon, 26 Nov 2018 01:53:04 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218784; bh=3g8PnxtfE4Aj4rp7f1734/PSgrBTxF/lNlXn7HscNMI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=a7FL/XzJgwrBHPEEhC6Us4fv+hlJBVbDqOR66dt+/my3ao4z1Bav4oyQYuNoKJuOM m7SDVfyJInOkU46xbGN1XU/RWZZJpGShLq3sJ/j9ZW3wKgMlm5+tVF4yMQnQLgKnKl un6M2ozJIFdjRBbBQ9I0FyMPor2TxPUkhZsPCzjE= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7r4GI037908 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:04 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:02 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:02 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7r2pP019403; Mon, 26 Nov 2018 01:53:02 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1G024490; Mon, 26 Nov 2018 01:52:58 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 02/16] remoteproc: Add a rproc_set_firmware() API Date: Mon, 26 Nov 2018 09:52:35 +0200 Message-ID: <1543218769-5507-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 A new API, rproc_set_firmware() is added to allow the remoteproc platform drivers and remoteproc client drivers to be able to configure a custom firmware name that is different from the default name used during remoteproc registration. This function is being introduced to provide a kernel-level equivalent of the current sysfs interface to remoteproc client drivers. This allows some remoteproc drivers to choose different firmwares at runtime when the remote processor is not running based on the functional feature it is providing using that remote processor. The TI PRU Ethernet driver will be an example of such usage as it requires to use different firmwares for different supported protocols. Also, update the firmware_store() function used by the sysfs interface to reuse this function to avoid code duplication. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_core.c | 61 +++++++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_sysfs.c | 33 ++----------------- include/linux/remoteproc.h | 1 + 3 files changed, 64 insertions(+), 31 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 39458a7..581e6e8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2151,6 +2151,67 @@ void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type) } EXPORT_SYMBOL(rproc_report_crash); +/** + * rproc_set_firmware() - assign a new firmware + * @rproc: rproc handle to which the new firmware is being assigned + * @fw_name: new firmware name to be assigned + * + * This function allows remoteproc drivers or clients to configure a custom + * firmware name that is different from the default name used during remoteproc + * registration. The function does not trigger a remote processor boot, + * only sets the firmware name used for a subsequent boot. This function + * should also be called only when the remote processor is offline. + * + * This allows either the userspace to configure a different name through + * sysfs or a kernel-level remoteproc or a remoteproc client driver to set + * a specific firmware when it is controlling the boot and shutdown of the + * remote processor. + * + * Returns 0 on success or a negative value upon failure + */ +int rproc_set_firmware(struct rproc *rproc, const char *fw_name) +{ + struct device *dev = rproc->dev.parent; + int ret, len; + char *p; + + if (!rproc || !fw_name) + return -EINVAL; + + ret = mutex_lock_interruptible(&rproc->lock); + if (ret) { + dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); + return -EINVAL; + } + + if (rproc->state != RPROC_OFFLINE) { + dev_err(dev, "can't change firmware while running\n"); + ret = -EBUSY; + goto out; + } + + len = strcspn(fw_name, "\n"); + if (!len) { + dev_err(dev, "can't provide a NULL firmware\n"); + ret = -EINVAL; + goto out; + } + + p = kstrndup(fw_name, len, GFP_KERNEL); + if (!p) { + ret = -ENOMEM; + goto out; + } + + kfree(rproc->firmware); + rproc->firmware = p; + +out: + mutex_unlock(&rproc->lock); + return ret; +} +EXPORT_SYMBOL(rproc_set_firmware); + static int __init remoteproc_init(void) { rproc_init_sysfs(); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 3a4c3d7..6cf04a7 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -32,38 +32,9 @@ static ssize_t firmware_store(struct device *dev, const char *buf, size_t count) { struct rproc *rproc = to_rproc(dev); - char *p; - int err, len = count; + int err; - err = mutex_lock_interruptible(&rproc->lock); - if (err) { - dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, err); - return -EINVAL; - } - - if (rproc->state != RPROC_OFFLINE) { - dev_err(dev, "can't change firmware while running\n"); - err = -EBUSY; - goto out; - } - - len = strcspn(buf, "\n"); - if (!len) { - dev_err(dev, "can't provide a NULL firmware\n"); - err = -EINVAL; - goto out; - } - - p = kstrndup(buf, len, GFP_KERNEL); - if (!p) { - err = -ENOMEM; - goto out; - } - - kfree(rproc->firmware); - rproc->firmware = p; -out: - mutex_unlock(&rproc->lock); + err = rproc_set_firmware(rproc, buf); return err ? err : count; } diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 9e01a44..063468b 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -604,6 +604,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); +int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); int rproc_coredump_add_custom_segment(struct rproc *rproc, From patchwork Mon Nov 26 07:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151975 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328730ljp; Sun, 25 Nov 2018 23:53:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKa6i2nMl9GXlo9tpEvbvekkkHvnYy9M+fUQq/SD5KYuF1jP1b0Tn0XEYdknRofVBmwM2o X-Received: by 2002:a63:9a52:: with SMTP id e18mr23649517pgo.14.1543218799948; Sun, 25 Nov 2018 23:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218799; cv=none; d=google.com; s=arc-20160816; b=B9jA7GvhiseAuMycyFvOm1a2GMLAtfJfJaZ/Bf9jELraVIwauwyKNbErVPcB6plFIs P+pp8MuYBSY2MKONdRZXCwgRVHhvKomQJZRtyiw0+yMELsgrrWClynvJIKIC+WnKvhha SPbg2fosrUKBTBts8mlF4LEM7jf9ECeQvnyT/HXsV/pH9rrBtFkinz/y1CyQeqGACJKd c7ypVU8LAOBzdqK2gb+96+dYxouVnCk3PbY14+RYotjlOFd1lKwdXL9miBy2TbDHwYgC qQUe8JBryPgQ+W5DmKtQX/jtk9W8VvtY8jiu3HmycES82ZB3s+nNZJIhaOI3LJMka5lY SpRw== 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; bh=27CpzbefFwcbVPVpPv5AKucrka5hspSfU2DxMO1oU+4=; b=x7O1xpaVfDz8sRQnHlk1TOfhX++y6J4txTfFGH27okb3o5NhpYIMItyJoht24JUYdO 4k2PrWckhrKZOxhFtMm8yhV3BG6YKorvZx5jMYDNRyJNqL8rFqvSiHmNmzPe6Jd7NCBN bSLimlS06H8c5p5eCNE6x0sh+jtCT3EbaHdJMl4HgPsUYGW6m+Hb9HXBJRt1uDQiWb8D 4FQlnRqXSgPehnF4R2jWJG7Pi/vGNTRzEG7tXQKidATqprP/Dl+bz0xHU/JLLI2DDIWG Hs8DFsmyAyUnOYnxXN/B9qIx4B3eAGqdACQSTplG3fIw5i82ffCyTf8UAuH+C2vlhqNI OPvw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 w10si33195143pgj.214.2018.11.25.23.53.19; Sun, 25 Nov 2018 23:53:19 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726511AbeKZSqe (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:34 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36458 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbeKZSqb (ORCPT ); Mon, 26 Nov 2018 13:46:31 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rBPV102421; Mon, 26 Nov 2018 01:53:11 -0600 Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rBva083637 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:11 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:10 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:10 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rAMd008881; Mon, 26 Nov 2018 01:53:10 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1I024490; Mon, 26 Nov 2018 01:53:06 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 04/16] remoteproc/pru: Add PRU remoteproc driver Date: Mon, 26 Nov 2018 09:52:37 +0200 Message-ID: <1543218769-5507-5-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 Programmable Real-Time Unit Subsystem (PRUSS) consists of dual 32-bit RISC cores (Programmable Real-Time Units, or PRUs) for program execution. This patch adds a remoteproc platform driver for managing the individual PRU RISC cores life cycle. The PRU remoteproc driver uses the standard remoteproc core ELF loader. However, the PRUs do not have a unified address space, (has an Instruction RAM and a primary Data RAM at both 0x0) and leverage an added .da_to_va ops to use the standard ELF loader. This remoteproc driver does not have support for error recovery and system suspend/resume features. Different compatibles are used to allow providing scalability for instance-specific device data if needed. The driver uses a default firmware-name retrieved from device-tree, and the firmwares are expected to be present in the standard Linux firmware search paths. They can also be adjusted by userspace if required through the sysfs interface provided by the remoteproc core. The PRU remoteproc driver uses a client-driven boot methodology - it does _not_ support auto-boot so that the PRU load and boot is dictated by the corresponding client drivers for achieving various usecases. This allows flexibility for the client drivers or applications to set a firmware name (if needed) based on their desired functionality and boot the PRU. The sysfs bind and unbind attributes have also been suppressed so that the PRU devices cannot be unbound and thereby shutdown a PRU from underneath a PRU client driver. The driver currently supports the AM335x SoC, and support for other TI SoCs will be added in subsequent patches. [rogerq@ti.com] Use request/release_mem_region() [rogerq@ti.com] Strip INTC handling Signed-off-by: Suman Anna Signed-off-by: Andrew F. Davis Signed-off-by: Roger Quadros --- drivers/remoteproc/Kconfig | 14 ++ drivers/remoteproc/Makefile | 1 + drivers/remoteproc/pru_rproc.c | 392 +++++++++++++++++++++++++++++++++++++++++ drivers/remoteproc/pru_rproc.h | 65 +++++++ 4 files changed, 472 insertions(+) create mode 100644 drivers/remoteproc/pru_rproc.c create mode 100644 drivers/remoteproc/pru_rproc.h -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index f0abd26..333666e 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -197,6 +197,20 @@ config ST_REMOTEPROC config ST_SLIM_REMOTEPROC tristate +config PRUSS_REMOTEPROC + tristate "TI PRUSS remoteproc support" + depends on TI_PRUSS + default n + help + Support for TI PRU-ICSS remote processors via the remote processor + framework. + + Currently supported on AM33xx SoCs. + + Say Y or M here to support the Programmable Realtime Unit (PRU) + processors on various TI SoCs. It's safe to say N here if you're + not interested in the PRU or if you are unsure. + endif # REMOTEPROC endmenu diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index ce5d061..88a86cc 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -26,3 +26,4 @@ qcom_wcnss_pil-y += qcom_wcnss.o qcom_wcnss_pil-y += qcom_wcnss_iris.o obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o +obj-$(CONFIG_PRUSS_REMOTEPROC) += pru_rproc.o diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c new file mode 100644 index 0000000..c35f432 --- /dev/null +++ b/drivers/remoteproc/pru_rproc.c @@ -0,0 +1,392 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PRU-ICSS remoteproc driver for various TI SoCs + * + * Copyright (C) 2014-2018 Texas Instruments Incorporated - http://www.ti.com/ + * Suman Anna + * Andrew F. Davis + */ + +#include +#include +#include +#include +#include +#include + +#include "remoteproc_internal.h" +#include "pru_rproc.h" + +/* PRU_ICSS_PRU_CTRL registers */ +#define PRU_CTRL_CTRL 0x0000 +#define PRU_CTRL_STS 0x0004 +#define PRU_CTRL_WAKEUP_EN 0x0008 +#define PRU_CTRL_CYCLE 0x000C +#define PRU_CTRL_STALL 0x0010 +#define PRU_CTRL_CTBIR0 0x0020 +#define PRU_CTRL_CTBIR1 0x0024 +#define PRU_CTRL_CTPPR0 0x0028 +#define PRU_CTRL_CTPPR1 0x002C + +/* CTRL register bit-fields */ +#define CTRL_CTRL_SOFT_RST_N BIT(0) +#define CTRL_CTRL_EN BIT(1) +#define CTRL_CTRL_SLEEPING BIT(2) +#define CTRL_CTRL_CTR_EN BIT(3) +#define CTRL_CTRL_SINGLE_STEP BIT(8) +#define CTRL_CTRL_RUNSTATE BIT(15) + +/** + * enum pru_mem - PRU core memory range identifiers + */ +enum pru_mem { + PRU_MEM_IRAM = 0, + PRU_MEM_CTRL, + PRU_MEM_DEBUG, + PRU_MEM_MAX, +}; + +/** + * struct pru_rproc - PRU remoteproc structure + * @id: id of the PRU core within the PRUSS + * @pruss: back-reference to parent PRUSS structure + * @rproc: remoteproc pointer for this PRU core + * @mem_regions: data for each of the PRU memory regions + * @dram0: PRUSS DRAM0 region + * @dram1: PRUSS DRAM1 region + * @shrdram: PRUSS SHARED RAM region + * @iram_da: device address of Instruction RAM for this PRU + * @pdram_da: device address of primary Data RAM for this PRU + * @sdram_da: device address of secondary Data RAM for this PRU + * @shrdram_da: device address of shared Data RAM + * @fw_name: name of firmware image used during loading + */ +struct pru_rproc { + int id; + struct pruss *pruss; + struct rproc *rproc; + struct pruss_mem_region mem_regions[PRU_MEM_MAX]; + struct pruss_mem_region dram0; + struct pruss_mem_region dram1; + struct pruss_mem_region shrdram; + u32 iram_da; + u32 pdram_da; + u32 sdram_da; + u32 shrdram_da; + const char *fw_name; +}; + +static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, int len); + +static inline u32 pru_control_read_reg(struct pru_rproc *pru, unsigned int reg) +{ + return readl_relaxed(pru->mem_regions[PRU_MEM_CTRL].va + reg); +} + +static inline +void pru_control_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val) +{ + writel_relaxed(val, pru->mem_regions[PRU_MEM_CTRL].va + reg); +} + +static inline u32 pru_debug_read_reg(struct pru_rproc *pru, unsigned int reg) +{ + return readl_relaxed(pru->mem_regions[PRU_MEM_DEBUG].va + reg); +} + +static inline +void pru_debug_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val) +{ + writel_relaxed(val, pru->mem_regions[PRU_MEM_DEBUG].va + reg); +} + +/* start a PRU core */ +static int pru_rproc_start(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + struct pru_rproc *pru = rproc->priv; + u32 val; + + dev_dbg(dev, "starting PRU%d: entry-point = 0x%x\n", + pru->id, (rproc->bootaddr >> 2)); + + val = CTRL_CTRL_EN | ((rproc->bootaddr >> 2) << 16); + pru_control_write_reg(pru, PRU_CTRL_CTRL, val); + + /* TODO: INTC setup */ + + return 0; +} + +/* stop/disable a PRU core */ +static int pru_rproc_stop(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + struct pru_rproc *pru = rproc->priv; + u32 val; + + dev_dbg(dev, "stopping PRU%d\n", pru->id); + + val = pru_control_read_reg(pru, PRU_CTRL_CTRL); + val &= ~CTRL_CTRL_EN; + pru_control_write_reg(pru, PRU_CTRL_CTRL, val); + + /* TODO: INTC cleanup */ + + return 0; +} + +/* + * Convert PRU device address (data spaces only) to kernel virtual address + * + * Each PRU has access to all data memories within the PRUSS, accessible at + * different ranges. So, look through both its primary and secondary Data + * RAMs as well as any shared Data RAM to convert a PRU device address to + * kernel virtual address. Data RAM0 is primary Data RAM for PRU0 and Data + * RAM1 is primary Data RAM for PRU1. + */ +static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, int len) +{ + struct pruss_mem_region dram0, dram1, shrd_ram; + u32 offset; + void *va = NULL; + + if (len <= 0) + return NULL; + + dram0 = pru->dram0; + dram1 = pru->dram1; + /* PRU1 has its local RAM addresses reversed */ + if (pru->id == 1) + swap(dram0, dram1); + shrd_ram = pru->shrdram; + + if (da >= pru->pdram_da && da + len <= pru->pdram_da + dram0.size) { + offset = da - pru->pdram_da; + va = (__force void *)(dram0.va + offset); + } else if (da >= pru->sdram_da && + da + len <= pru->sdram_da + dram1.size) { + offset = da - pru->sdram_da; + va = (__force void *)(dram1.va + offset); + } else if (da >= pru->shrdram_da && + da + len <= pru->shrdram_da + shrd_ram.size) { + offset = da - pru->shrdram_da; + va = (__force void *)(shrd_ram.va + offset); + } + + return va; +} + +/* + * Convert PRU device address (instruction space) to kernel virtual address + * + * A PRU does not have an unified address space. Each PRU has its very own + * private Instruction RAM, and its device address is identical to that of + * its primary Data RAM device address. + */ +static void *pru_i_da_to_va(struct pru_rproc *pru, u32 da, int len) +{ + u32 offset; + void *va = NULL; + + if (len <= 0) + return NULL; + + if (da >= pru->iram_da && + da + len <= pru->iram_da + pru->mem_regions[PRU_MEM_IRAM].size) { + offset = da - pru->iram_da; + va = (__force void *)(pru->mem_regions[PRU_MEM_IRAM].va + + offset); + } + + return va; +} + +/* PRU-specific address translator */ +static void *pru_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) +{ + struct pru_rproc *pru = rproc->priv; + void *va; + u32 exec_flag; + + exec_flag = ((flags & RPROC_FLAGS_ELF_SHDR) ? flags & SHF_EXECINSTR : + ((flags & RPROC_FLAGS_ELF_PHDR) ? flags & PF_X : 0)); + + if (exec_flag) + va = pru_i_da_to_va(pru, da, len); + else + va = pru_d_da_to_va(pru, da, len); + + return va; +} + +static struct rproc_ops pru_rproc_ops = { + .start = pru_rproc_start, + .stop = pru_rproc_stop, + .da_to_va = pru_da_to_va, +}; + +static int pru_rproc_set_id(struct pru_rproc *pru) +{ + int ret = 0; + u32 mask1 = 0x34000; + u32 mask2 = 0x38000; + + if ((pru->mem_regions[0].pa & mask1) == mask1) + pru->id = 0; + else if ((pru->mem_regions[0].pa & mask2) == mask2) + pru->id = 1; + else + ret = -EINVAL; + + return ret; +} + +static int pru_rproc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct platform_device *ppdev = to_platform_device(dev->parent); + struct pru_rproc *pru; + const char *fw_name; + struct rproc *rproc = NULL; + struct resource *res; + int i, ret; + const char *mem_names[PRU_MEM_MAX] = { "iram", "control", "debug" }; + + if (!np) { + dev_err(dev, "Non-DT platform device not supported\n"); + return -ENODEV; + } + + ret = of_property_read_string(np, "firmware-name", &fw_name); + if (ret) { + dev_err(dev, "unable to retrieve firmware-name %d\n", ret); + return ret; + } + + rproc = rproc_alloc(dev, pdev->name, &pru_rproc_ops, fw_name, + sizeof(*pru)); + if (!rproc) { + dev_err(dev, "rproc_alloc failed\n"); + return -ENOMEM; + } + /* error recovery is not supported for PRUs */ + rproc->recovery_disabled = true; + + /* + * rproc_add will auto-boot the processor normally, but this is + * not desired with PRU client driven boot-flow methodology. A PRU + * application/client driver will boot the corresponding PRU + * remote-processor as part of its state machine either through + * the remoteproc sysfs interface or through the equivalent kernel API + */ + rproc->auto_boot = false; + + pru = rproc->priv; + pru->pruss = platform_get_drvdata(ppdev); + pru->rproc = rproc; + pru->fw_name = fw_name; + + ret = pruss_request_mem_region(pru->pruss, PRUSS_MEM_DRAM0, + &pru->dram0); + if (ret) { + dev_err(dev, "couldn't get PRUSS DRAM0: %d\n", ret); + return ret; + } + pruss_release_mem_region(pru->pruss, &pru->dram0); + + ret = pruss_request_mem_region(pru->pruss, PRUSS_MEM_DRAM1, + &pru->dram1); + if (ret) { + dev_err(dev, "couldn't get PRUSS DRAM1: %d\n", ret); + return ret; + } + pruss_release_mem_region(pru->pruss, &pru->dram1); + + ret = pruss_request_mem_region(pru->pruss, PRUSS_MEM_SHRD_RAM2, + &pru->shrdram); + if (ret) { + dev_err(dev, "couldn't get PRUSS Shared RAM: %d\n", ret); + return ret; + } + pruss_release_mem_region(pru->pruss, &pru->shrdram); + + /* XXX: get this from match data if different in the future */ + pru->iram_da = 0; + pru->pdram_da = 0; + pru->sdram_da = 0x2000; + pru->shrdram_da = 0x10000; + + for (i = 0; i < ARRAY_SIZE(mem_names); i++) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + mem_names[i]); + pru->mem_regions[i].va = devm_ioremap_resource(dev, res); + if (IS_ERR(pru->mem_regions[i].va)) { + dev_err(dev, "failed to parse and map memory resource %d %s\n", + i, mem_names[i]); + ret = PTR_ERR(pru->mem_regions[i].va); + goto free_rproc; + } + pru->mem_regions[i].pa = res->start; + pru->mem_regions[i].size = resource_size(res); + + dev_dbg(dev, "memory %8s: pa %pa size 0x%zx va %p\n", + mem_names[i], &pru->mem_regions[i].pa, + pru->mem_regions[i].size, pru->mem_regions[i].va); + } + + ret = pru_rproc_set_id(pru); + if (ret < 0) + goto free_rproc; + + platform_set_drvdata(pdev, rproc); + + ret = rproc_add(pru->rproc); + if (ret) { + dev_err(dev, "rproc_add failed: %d\n", ret); + goto free_rproc; + } + + dev_info(dev, "PRU rproc node %s probed successfully\n", np->full_name); + + return 0; + +free_rproc: + rproc_free(rproc); + return ret; +} + +static int pru_rproc_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rproc *rproc = platform_get_drvdata(pdev); + + dev_info(dev, "%s: removing rproc %s\n", __func__, rproc->name); + + rproc_del(rproc); + rproc_free(rproc); + + return 0; +} + +static const struct of_device_id pru_rproc_match[] = { + { .compatible = "ti,am3356-pru", }, + {}, +}; +MODULE_DEVICE_TABLE(of, pru_rproc_match); + +static struct platform_driver pru_rproc_driver = { + .driver = { + .name = "pru-rproc", + .of_match_table = pru_rproc_match, + .suppress_bind_attrs = true, + }, + .probe = pru_rproc_probe, + .remove = pru_rproc_remove, +}; +module_platform_driver(pru_rproc_driver); + +MODULE_AUTHOR("Suman Anna "); +MODULE_DESCRIPTION("PRU-ICSS Remote Processor Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/remoteproc/pru_rproc.h b/drivers/remoteproc/pru_rproc.h new file mode 100644 index 0000000..35240e9 --- /dev/null +++ b/drivers/remoteproc/pru_rproc.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* + * PRUSS Remote Processor specific types + * + * Copyright (C) 2014-2018 Texas Instruments Incorporated - http://www.ti.com/ + * All rights reserved. + */ + +#ifndef _PRU_REMOTEPROC_H_ +#define _PRU_REMOTEPROC_H_ + +/** + * enum pruss_rsc_types - PRU specific resource types + * + * @PRUSS_RSC_INTRS: Resource holding information on PRU PINTC configuration + * @PRUSS_RSC_MAX: Indicates end of known/defined PRU resource types. + * This should be the last definition. + * + * Introduce new custom resource types before PRUSS_RSC_MAX. + */ +enum pruss_rsc_types { + PRUSS_RSC_INTRS = 1, + PRUSS_RSC_MAX = 2, +}; + +/** + * struct pruss_event_chnl - PRU system events _to_ channel mapping + * @event: number of the system event + * @chnl: channel number assigned to a given @event + * + * PRU system events are mapped to channels, and these channels are mapped + * to host interrupts. Events can be mapped to channels in a one-to-one or + * many-to-one ratio (multiple events per channel), and channels can be + * mapped to host interrupts in a one-to-one or many-to-one ratio (multiple + * channels per interrupt). + * + */ +struct pruss_event_chnl { + s8 event; + s8 chnl; +}; + +/** + * struct fw_rsc_custom_intrmap - custom resource to define PRU interrupts + * @reserved: reserved field providing padding and alignment + * @chnl_host_intr_map: array of PRU channels to host interrupt mappings + * @event_chnl_map_size: number of event_channel mappings defined in + * @event_chnl_map_addr + * @event_chnl_map_addr: PRU device address of pointer to array of events to + * channel mappings (struct pruss_event_chnl elements) + * + * PRU system events are mapped to channels, and these channels are mapped + * to host interrupts. Events can be mapped to channels in a one-to-one or + * many-to-one ratio (multiple events per channel), and channels can be + * mapped to host interrupts in a one-to-one or many-to-one ratio (multiple + * channels per interrupt). + */ +struct fw_rsc_custom_intrmap { + u16 reserved; + s8 chnl_host_intr_map[10]; + u32 event_chnl_map_size; + u32 event_chnl_map_addr; +}; + +#endif /* _PRU_REMOTEPROC_H_ */ From patchwork Mon Nov 26 07:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151976 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328745ljp; Sun, 25 Nov 2018 23:53:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WnDCZu+fPc7FCjicsLaSoGXBqh9A32ngjh5mXThfACLXQk8FWFMQL+e2kULQbsvBIytT4c X-Received: by 2002:a17:902:7107:: with SMTP id a7mr26323278pll.290.1543218801899; Sun, 25 Nov 2018 23:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218801; cv=none; d=google.com; s=arc-20160816; b=wEMGLeYgQ2KVU9+gN7G4zitWe6+IFBxS/jKM1R/FfnfXoGSN2ZtbTT3rcRdsLFAKHs KFlvIk7eAvhNpjhuZMiCl4Zh6yldTqsZXUJGlTYIWHUSJBAi1/VQyJsGF/6zNG7/Yb/X 0IsfTJUzWCdW7fOnIT7Dd5uPmXNczw40882y4OQSDeQpNsgR3lKwRMnWFK0loDHf70wL ZgyT4+TEkkzNVQaYW4aIklKod7fbNK3afLYT0pXR5JKqSQD6awxVb+XruqUSrry39vfP npWOzPo1s6SjVi5AMzrFXttRg37JF1tSB6YuCoN9PMC40KWUg4RqERqa8uwLPGnyU/I6 0vyw== 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=trY+rKRaXzr+XXemQYYt3LpgzdzpAoqCZiJ8oFvAQXQ=; b=dqs2K5QYqROcPfNO9/a5Y6W3HDO5Cy3vr8RUghgFpHDIGhJdVHzd/T6Xk9sPNYqQBX WwRKU2RoFw/GMFpLq3XqprGz1z6z9HzdWtYnloXDZvYpwarVHgnPjhnj30K8+ywr8Dsk mN2Uj6bx5IceHrm2E2y9Ni+Gq30XpqcL4ZS5ep3zdeohY6s3vK020x5vC9wzvy6HAt0C 3n0rnNFyORLx3SPFwnHeXk7ht92cAavcIPLGTmscqb4FahrGywbou7Dwb66o2F56MDc1 TNG8A/gAYZwnR0boLzMecWvKJ1H+375WPvq5D5CURqafw60tGmxC01q+Ke95TGN51AWL FOLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=f3NDklOB; 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 q5si49966640pgb.245.2018.11.25.23.53.21; Sun, 25 Nov 2018 23:53:21 -0800 (PST) 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=f3NDklOB; 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 S1726543AbeKZSqe (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:34 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:40938 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbeKZSqe (ORCPT ); Mon, 26 Nov 2018 13:46:34 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rFIx043460; Mon, 26 Nov 2018 01:53:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218795; bh=trY+rKRaXzr+XXemQYYt3LpgzdzpAoqCZiJ8oFvAQXQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=f3NDklOBg2fMf88DLBiTgUNrD2EU7OCrcO/I3rTXVn3VnaNm7p0khGfRQG9ER/Lfb OyuOBL7NECMKL6nIRfvNiilvGLNIjVs1mjFYjDv+0uNUdKkgJcm2ZN/c53WfaiyIzd 3mJqHWmsnC4wXS+yblbKzThBZROyONWFh4rGHUCg= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rFwH059381 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:15 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:14 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:14 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rE0K008903; Mon, 26 Nov 2018 01:53:14 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1J024490; Mon, 26 Nov 2018 01:53:11 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 05/16] remoteproc/pru: Add pru-specific debugfs support Date: Mon, 26 Nov 2018 09:52:38 +0200 Message-ID: <1543218769-5507-6-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 remoteproc core creates certain standard debugfs entries, that does not give a whole lot of useful information for the PRUs. The PRU remoteproc driver is enhanced to add additional debugfs entries for PRU. These will be auto-cleaned up when the parent rproc debug directory is removed. The enhanced debugfs support adds two new entries: 'regs' and 'single_step'. The 'regs' dumps out the useful CTRL sub-module registers as well as each of the 32 GPREGs and CT_REGs registers. The GPREGs and CT_REGs though are printed only when the PRU is halted and accessible as per the IP design. The 'single_step' utilizes the single-step execution of the PRU cores. Writing a non-zero value performs a single step, and a zero value restores the PRU to execute in the same mode as the mode before the first single step. (note: if the PRU is halted because of a halt instruction, then no change occurs). Logic for setting the PC and jumping over a halt instruction shall be added in the future. Signed-off-by: Suman Anna --- drivers/remoteproc/pru_rproc.c | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index c35f432..73a7f13 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -36,6 +37,10 @@ #define CTRL_CTRL_SINGLE_STEP BIT(8) #define CTRL_CTRL_RUNSTATE BIT(15) +/* PRU_ICSS_PRU_DEBUG registers */ +#define PRU_DEBUG_GPREG(x) (0x0000 + (x) * 4) +#define PRU_DEBUG_CT_REG(x) (0x0080 + (x) * 4) + /** * enum pru_mem - PRU core memory range identifiers */ @@ -60,6 +65,8 @@ enum pru_mem { * @sdram_da: device address of secondary Data RAM for this PRU * @shrdram_da: device address of shared Data RAM * @fw_name: name of firmware image used during loading + * @dbg_single_step: debug state variable to set PRU into single step mode + * @dbg_continuous: debug state variable to restore PRU execution mode */ struct pru_rproc { int id; @@ -74,6 +81,8 @@ struct pru_rproc { u32 sdram_da; u32 shrdram_da; const char *fw_name; + u32 dbg_single_step; + u32 dbg_continuous; }; static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, int len); @@ -100,6 +109,130 @@ void pru_debug_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val) writel_relaxed(val, pru->mem_regions[PRU_MEM_DEBUG].va + reg); } +static int pru_rproc_debug_read_regs(struct seq_file *s, void *data) +{ + struct rproc *rproc = s->private; + struct pru_rproc *pru = rproc->priv; + int i, nregs = 32; + u32 pru_sts; + int pru_is_running; + + seq_puts(s, "============== Control Registers ==============\n"); + seq_printf(s, "CTRL := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CTRL)); + pru_sts = pru_control_read_reg(pru, PRU_CTRL_STS); + seq_printf(s, "STS (PC) := 0x%08x (0x%08x)\n", pru_sts, pru_sts << 2); + seq_printf(s, "WAKEUP_EN := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_WAKEUP_EN)); + seq_printf(s, "CYCLE := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CYCLE)); + seq_printf(s, "STALL := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_STALL)); + seq_printf(s, "CTBIR0 := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CTBIR0)); + seq_printf(s, "CTBIR1 := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CTBIR1)); + seq_printf(s, "CTPPR0 := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CTPPR0)); + seq_printf(s, "CTPPR1 := 0x%08x\n", + pru_control_read_reg(pru, PRU_CTRL_CTPPR1)); + + seq_puts(s, "=============== Debug Registers ===============\n"); + pru_is_running = pru_control_read_reg(pru, PRU_CTRL_CTRL) & + CTRL_CTRL_RUNSTATE; + if (pru_is_running) { + seq_puts(s, "PRU is executing, cannot print/access debug registers.\n"); + return 0; + } + + for (i = 0; i < nregs; i++) { + seq_printf(s, "GPREG%-2d := 0x%08x\tCT_REG%-2d := 0x%08x\n", + i, pru_debug_read_reg(pru, PRU_DEBUG_GPREG(i)), + i, pru_debug_read_reg(pru, PRU_DEBUG_CT_REG(i))); + } + + return 0; +} + +static int pru_rproc_debug_regs_open(struct inode *inode, struct file *file) +{ + return single_open(file, pru_rproc_debug_read_regs, inode->i_private); +} + +static const struct file_operations pru_rproc_debug_regs_ops = { + .open = pru_rproc_debug_regs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +/* + * Control PRU single-step mode + * + * This is a debug helper function used for controlling the single-step + * mode of the PRU. The PRU Debug registers are not accessible when the + * PRU is in RUNNING state. + * + * Writing a non-zero value sets the PRU into single-step mode irrespective + * of its previous state. The PRU mode is saved only on the first set into + * a single-step mode. Writing a zero value will restore the PRU into its + * original mode. + */ +static int pru_rproc_debug_ss_set(void *data, u64 val) +{ + struct rproc *rproc = data; + struct pru_rproc *pru = rproc->priv; + u32 reg_val; + + val = val ? 1 : 0; + if (!val && !pru->dbg_single_step) + return 0; + + reg_val = pru_control_read_reg(pru, PRU_CTRL_CTRL); + + if (val && !pru->dbg_single_step) + pru->dbg_continuous = reg_val; + + if (val) + reg_val |= CTRL_CTRL_SINGLE_STEP | CTRL_CTRL_EN; + else + reg_val = pru->dbg_continuous; + + pru->dbg_single_step = val; + pru_control_write_reg(pru, PRU_CTRL_CTRL, reg_val); + + return 0; +} + +static int pru_rproc_debug_ss_get(void *data, u64 *val) +{ + struct rproc *rproc = data; + struct pru_rproc *pru = rproc->priv; + + *val = pru->dbg_single_step; + + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(pru_rproc_debug_ss_fops, pru_rproc_debug_ss_get, + pru_rproc_debug_ss_set, "%llu\n"); + +/* + * Create PRU-specific debugfs entries + * + * The entries are created only if the parent remoteproc debugfs directory + * exists, and will be cleaned up by the remoteproc core. + */ +static void pru_rproc_create_debug_entries(struct rproc *rproc) +{ + if (!rproc->dbg_dir) + return; + + debugfs_create_file("regs", 0400, rproc->dbg_dir, + rproc, &pru_rproc_debug_regs_ops); + debugfs_create_file("single_step", 0600, rproc->dbg_dir, + rproc, &pru_rproc_debug_ss_fops); +} + /* start a PRU core */ static int pru_rproc_start(struct rproc *rproc) { @@ -348,6 +481,8 @@ static int pru_rproc_probe(struct platform_device *pdev) goto free_rproc; } + pru_rproc_create_debug_entries(rproc); + dev_info(dev, "PRU rproc node %s probed successfully\n", np->full_name); return 0; From patchwork Mon Nov 26 07:52:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151977 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328790ljp; Sun, 25 Nov 2018 23:53:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/WZgi8+NyPBsWkndqJrxzHbr4V7o0fOxSwL3rdZsaSQMukqmZZPuHNRTVB4gaEZB4DdVPZo X-Received: by 2002:a63:ba48:: with SMTP id l8mr23363608pgu.72.1543218805012; Sun, 25 Nov 2018 23:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218805; cv=none; d=google.com; s=arc-20160816; b=VrFHeupMGJPxUeTiQmlGpQ+lFc2PfaSbUBdXkOxqwsTZhHQC2j3iLYaiCSUVTldeiY Q7jw1xnZMU8DNmGLUAhVlpp+zb61rHiua72C8GOl2b8EX+nICQZYH2ggsQxzGelBfJnF lHxQPYFYsVjIbsY4SyIHuK+5oR5/thXyVsjUg7cnzHHXdAqvwf485XXFHbzGL6K2RqRM fEI2ua8EdsySqTg+kfpqENAYzfLaAE91OmlpeSsegqCgKhixrrNBzCGf7eykdwaMUzIe C+iCDwLDbVkg8DdogYqHCrFZm102knhFDsCJHjhKRbotROHn0qAOY98FkytpfdnkyUCB 8ufg== 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=Yh64jBOQ6CGd9QDt1o7kjVGWBqwatvzpTmxITAnhZlQ=; b=WMoS0R3ZiKL1t7hcZoq3plDHYnNIEzT+2eTtp2SZVQn0aYaDLQA5bpY8XeUTP+QhEB PXr6Yx8G/JFbPpn92f2d2BS8+T6HbK2Okq9gD0emCLrmpBIQNy8Tj57kzGEeOWYG3vK3 Vxf9z4bvs91ktYQgj5dTiu2ZGgqM9zM4D6v4MaOIzbrypb4cPiET2FE0yCEZWr5XTaEU GbWIA/FveAf/NPqp99WTfm48KmLuOS6ig8brmyVhppk3BP/x7DIWN5ASKLP7YRqLyQ6I SZU0L/IWdv0x07iBqZIiFsvKUanwZzZuvnP7n4MHsh8bD0QF7n0YI68e/2EWnCMw3fO5 ZV0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jzVryKFU; 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 w11si60211632pgf.452.2018.11.25.23.53.24; Sun, 25 Nov 2018 23:53:24 -0800 (PST) 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=jzVryKFU; 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 S1726565AbeKZSqi (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:38 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:40012 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbeKZSqh (ORCPT ); Mon, 26 Nov 2018 13:46:37 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rJfw060729; Mon, 26 Nov 2018 01:53:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218799; bh=Yh64jBOQ6CGd9QDt1o7kjVGWBqwatvzpTmxITAnhZlQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jzVryKFUgwp4qxo2ueYJA09GlM8aUGd9Inf5A4CjNpZX5ob/DBLpN2+H9F2KJQDnJ HT+0kZiKEy/QHkV89XiNM6XA9tLZSP0ZsgurBokBMQ1plFUcyS46lm8X1mtYeT1moM O8eF/e/PYghN+Y7N5nuYMz4dyt+xbVHfUrP5NDe0= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rJcM038229 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:19 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:18 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:18 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rIGv019818; Mon, 26 Nov 2018 01:53:18 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1K024490; Mon, 26 Nov 2018 01:53:15 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 06/16] dt-bindings: remoteproc: ti-pruss: Update bindings for supporting rpmsg Date: Mon, 26 Nov 2018 09:52:39 +0200 Message-ID: <1543218769-5507-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 Update the PRUSS DT bindings to add the properties required to support the optional virtio rpmsg stack using the virtio-ring based communication transport between MPU and a PRU core. Signed-off-by: Suman Anna --- .../devicetree/bindings/soc/ti/ti,pruss.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt b/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt index 24fedad..3e5f32f 100644 --- a/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt +++ b/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt @@ -175,6 +175,32 @@ Required Properties: - firmware-name : should contain the name of the default firmware image file located on the firmware search path +Optional Properties: +-------------------- +The virtio based communication between the MPU and a PRU core _requires_ +either the 'mboxes' property, or the set of 'interrupt-parent', 'interrupts' +and 'interrupt-names' properties to be defined. The latter option is the +preferred choice. The 'mboxes' property is not applicable for 66AK2G and +DA850/OMAP-L138 SoCs. + +- mboxes : OMAP Mailbox specifier denoting the sub-mailbox, if using + a mailbox for IPC signalling between host and a PRU core. + The specifier format is as per the bindings, + Documentation/devicetree/bindings/mailbox/omap-mailbox.txt + This property should match with the sub-mailbox node used + in the corresponding firmware image. +- interrupt-parent : phandle to the PRUSS INTC node. Should be defined if + interrupts property is to be used. +- interrupts : array of interrupt specifiers if using PRU system events + for IPC signalling between host and a PRU core. This + property should match with the PRU system event used in + the corresponding firmware image. +- interrupt-names : should use one of the following names for each interrupt, + the name should match the corresponding PRU system event + number, + "vring" - for PRU to HOST virtqueue signalling + "kick" - for HOST to PRU virtqueue signalling + MDIO Child Node ================ @@ -243,6 +269,9 @@ Example: <0x4a322400 0x100>; reg-names = "iram", "control", "debug"; firmware-name = "am335x-pru0-fw"; + interrupt-parent = <&pruss_intc>; + interrupts = <16>, <17>; + interrupt-names = "vring", "kick"; }; pru1: pru@4a338000 { @@ -252,6 +281,10 @@ Example: <0x4a324400 0x100>; reg-names = "iram", "control", "debug"; firmware-name = "am335x-pru1-fw"; + interrupt-parent = <&pruss_intc>; + interrupts = <18>, <19>; + interrupt-names = "vring", "kick"; + /* mboxes = <&mailbox &mbox_pru1>; */ }; pruss_mdio: mdio@4a332400 { @@ -329,6 +362,9 @@ Example: <0x54422400 0x100>; reg-names = "iram", "control", "debug"; firmware-name = "am437x-pru1_0-fw"; + interrupt-parent = <&pruss1_intc>; + interrupts = <16>, <17>; + interrupt-names = "vring", "kick"; }; pru1_1: pru@54438000 { @@ -338,6 +374,9 @@ Example: <0x54424400 0x100>; reg-names = "iram", "control", "debug"; firmware-name = "am437x-pru1_1-fw"; + interrupt-parent = <&pruss1_intc>; + interrupts = <18>, <19>; + interrupt-names = "vring", "kick"; }; pruss1_mdio: mdio@54432400 { From patchwork Mon Nov 26 07:52:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151978 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328865ljp; Sun, 25 Nov 2018 23:53:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WPkiy00r2e2PAMZkL1UuVUn/JSEOJoy3HlCn+q4siz9x7rhTBmd/4f2wKuU8dknqKw3RQB X-Received: by 2002:a65:610d:: with SMTP id z13mr24130370pgu.427.1543218809793; Sun, 25 Nov 2018 23:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218809; cv=none; d=google.com; s=arc-20160816; b=Ea6LEFRT+BoYG9BiFJhn2CHCVb4YwvZJ/5iJj6aI8b+kZaJrL69NzauyVCtJHUG1Jb 2RFua5pYH4t7ulMkjX1eO7tX6RHET4DcKOO0scprPKbzHgeqzVvqlZxmUKM1Q0WGf80G Si37omeGmsk3mHPQ+AGc5UImj9zkE6jNuiVLHzZhW27IONgNGKT64vTMLLOlFFRIoAGT wlTTHEoyBrV7LiedGlCZdsrb+9tLa/w1omLamOOXCaEQ0poyFXaOWIE2gndIGytByaf/ z25SjMFcYHtMzzB4aK9s+XbtQVAss7bGdUbb7ChKBt6lfs8JCQ64DrVZJJ/onvuCmdyP 7BhA== 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=K+9OIo+WoGSA6CXrJCWmEtG9/Mc7G+cne17UP/YTkdw=; b=1DV/RjdT4yCk44Y7zc1lvbcOC2d4jR+///aEnW5+SYNcJMvZDRiZPh4PLMNoWKRRuM fu8+js072kIrSqbfSI96IZ/nMhD4LSL3ZSsDg79GfGPKkBG7V5Wre8c87A7aXgbcJkmJ VXLyLUhSz168dufuwaTItWfyjQTGAijEzdfxTEdQ6z1Lm88Kdo5rC5p4cGIaHuIh3pIp M7RTll08sy5M4ox4cw9zIsantThPE5WhgvibOeqXPX+qFQ0JfBAMgyzty0Y2+f3on4FY PND4WmikfsEAb6gSv1m7Nvnfp4+KyKNN8D61Vr8iEsPTh/qahUIQZuBFZO0Psb7pKFx9 Hmhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=woKj9aDo; 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 p32si8820359pgm.413.2018.11.25.23.53.29; Sun, 25 Nov 2018 23:53:29 -0800 (PST) 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=woKj9aDo; 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 S1726590AbeKZSqn (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:43 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:40974 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbeKZSqn (ORCPT ); Mon, 26 Nov 2018 13:46:43 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rNf7043501; Mon, 26 Nov 2018 01:53:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218803; bh=K+9OIo+WoGSA6CXrJCWmEtG9/Mc7G+cne17UP/YTkdw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=woKj9aDodaw3zQMssEqwS1YEVKBAbpyDGu8K5xim5POS7AMg0wSfIpon8hMAV9QtP vVWOWVy3/butnIvxCh6yLX9HWtqDQJgsCWRNMLhJA5nCpJOBdzCFodiPuSC84hoyH5 waQNNZoadvccPjkrt6QWdQLzfHLb2tgzfxI6Isko= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rNFQ059580 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:23 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:22 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:22 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rMoP019905; Mon, 26 Nov 2018 01:53:22 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1L024490; Mon, 26 Nov 2018 01:53:19 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 07/16] remoteproc/pru: Add support for virtio rpmsg stack Date: Mon, 26 Nov 2018 09:52:40 +0200 Message-ID: <1543218769-5507-8-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 PRU remoteproc driver has been enhanced to support the optional rpmsg stack using the virtio-ring based communication transport between MPU and a PRU core. This provides support to any firmware images supporting the virtio devices. The virtio-ring signalling support is provided either through a OMAP mailbox or through two PRU system events on OMAP-architecture based SoCs - one event used in each direction for kicking from one processor and receiving notification on the other processor. The virtio rpmsg signalling is enabled only using using PRU system events for interrupts on the Keystone-architecture based 66AK2G SoCs (it is possible to implement using an alternate Keystone specific IPCGR registers as well). The driver supports both signalling options, though the PRU events based signalling is the recommended option as it avoids an external peripheral access from the PRU side. It also provides a uniform solution across both the OMAP, Keystone and Davinci architectures. The PRU events based signalling takes precedence if both options are mentioned. Either of the options would require the corresponding firmware support though. A build dependency against MAILBOX is also added. Note that the OMAP Mailbox IP is not present on 66AK2G and Davinci SoCs, so it is only selected for OMAP-based SoCs. Signed-off-by: Suman Anna --- drivers/remoteproc/Kconfig | 2 + drivers/remoteproc/pru_rproc.c | 169 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 168 insertions(+), 3 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 333666e..b89acb0 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -200,6 +200,8 @@ config ST_SLIM_REMOTEPROC config PRUSS_REMOTEPROC tristate "TI PRUSS remoteproc support" depends on TI_PRUSS + select MAILBOX + select OMAP2PLUS_MBOX if ARCH_OMAP2PLUS default n help Support for TI PRU-ICSS remote processors via the remote processor diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 73a7f13..e0554b3 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,10 @@ enum pru_mem { * @id: id of the PRU core within the PRUSS * @pruss: back-reference to parent PRUSS structure * @rproc: remoteproc pointer for this PRU core + * @mbox: mailbox channel handle used for vring signalling with MPU + * @client: mailbox client to request the mailbox channel + * @irq_ring: IRQ number to use for processing vring buffers + * @irq_kick: IRQ number to use to perform virtio kick * @mem_regions: data for each of the PRU memory regions * @dram0: PRUSS DRAM0 region * @dram1: PRUSS DRAM1 region @@ -72,6 +77,10 @@ struct pru_rproc { int id; struct pruss *pruss; struct rproc *rproc; + struct mbox_chan *mbox; + struct mbox_client client; + int irq_vring; + int irq_kick; struct pruss_mem_region mem_regions[PRU_MEM_MAX]; struct pruss_mem_region dram0; struct pruss_mem_region dram1; @@ -233,22 +242,124 @@ static void pru_rproc_create_debug_entries(struct rproc *rproc) rproc, &pru_rproc_debug_ss_fops); } +/** + * pru_rproc_mbox_callback() - inbound mailbox message handler + * @client: mailbox client pointer used for requesting the mailbox channel + * @data: mailbox payload + * + * This handler is invoked by omap's mailbox driver whenever a mailbox + * message is received. Usually, the mailbox payload simply contains + * the index of the virtqueue that is kicked by the PRU remote processor, + * and we let remoteproc core handle it. + * + * In addition to virtqueue indices, we might also have some out-of-band + * values that indicates different events. Those values are deliberately + * very big so they don't coincide with virtqueue indices. + */ +static void pru_rproc_mbox_callback(struct mbox_client *client, void *data) +{ + struct pru_rproc *pru = container_of(client, struct pru_rproc, client); + struct device *dev = &pru->rproc->dev; + u32 msg = (u32)data; + + dev_dbg(dev, "mbox msg: 0x%x\n", msg); + + /* msg contains the index of the triggered vring */ + if (rproc_vq_interrupt(pru->rproc, msg) == IRQ_NONE) + dev_dbg(dev, "no message was found in vqid %d\n", msg); +} + +/** + * pru_rproc_vring_interrupt() - interrupt handler for processing vrings + * @irq: irq number associated with the PRU event MPU is listening on + * @data: interrupt handler data, will be a PRU rproc structure + * + * This handler is used by the PRU remoteproc driver when using PRU system + * events for processing the virtqueues. Unlike the mailbox IP, there is + * no payload associated with an interrupt, so either a unique event is + * used for each virtqueue kick, or a both virtqueues are processed on + * a single event. The latter is chosen to conserve the usable PRU system + * events. + */ +static irqreturn_t pru_rproc_vring_interrupt(int irq, void *data) +{ + struct pru_rproc *pru = data; + + dev_dbg(&pru->rproc->dev, "got vring irq\n"); + + /* process incoming buffers on both the Rx and Tx vrings */ + rproc_vq_interrupt(pru->rproc, 0); + rproc_vq_interrupt(pru->rproc, 1); + + return IRQ_HANDLED; +} + +/* kick a virtqueue */ +static void pru_rproc_kick(struct rproc *rproc, int vq_id) +{ + struct device *dev = &rproc->dev; + struct pru_rproc *pru = rproc->priv; + int ret; + + dev_dbg(dev, "kicking vqid %d on PRU%d\n", vq_id, pru->id); + + if (pru->irq_kick > 0) { + ret = pruss_intc_trigger(pru->irq_kick); + if (ret < 0) + dev_err(dev, "pruss_intc_trigger failed: %d\n", ret); + } else if (pru->mbox) { + /* + * send the index of the triggered virtqueue in the mailbox + * payload + */ + ret = mbox_send_message(pru->mbox, (void *)vq_id); + if (ret < 0) + dev_err(dev, "mbox_send_message failed: %d\n", ret); + } +} + /* start a PRU core */ static int pru_rproc_start(struct rproc *rproc) { struct device *dev = &rproc->dev; struct pru_rproc *pru = rproc->priv; u32 val; + int ret; dev_dbg(dev, "starting PRU%d: entry-point = 0x%x\n", pru->id, (rproc->bootaddr >> 2)); + /* TODO: INTC setup */ + + if (!list_empty(&pru->rproc->rvdevs)) { + if (!pru->mbox && (pru->irq_vring <= 0 || pru->irq_kick <= 0)) { + dev_err(dev, "virtio vring interrupt mechanisms are not provided\n"); + ret = -EINVAL; + goto fail; + } + + if (!pru->mbox && pru->irq_vring > 0) { + ret = request_threaded_irq(pru->irq_vring, NULL, + pru_rproc_vring_interrupt, + IRQF_ONESHOT, dev_name(dev), + pru); + if (ret) { + dev_err(dev, "failed to enable vring interrupt, ret = %d\n", + ret); + goto fail; + } + } + } + val = CTRL_CTRL_EN | ((rproc->bootaddr >> 2) << 16); pru_control_write_reg(pru, PRU_CTRL_CTRL, val); - /* TODO: INTC setup */ - return 0; + +fail: + /* TODO: INTC cleanup */ + + return ret; } /* stop/disable a PRU core */ @@ -264,6 +375,10 @@ static int pru_rproc_stop(struct rproc *rproc) val &= ~CTRL_CTRL_EN; pru_control_write_reg(pru, PRU_CTRL_CTRL, val); + if (!list_empty(&pru->rproc->rvdevs) && + !pru->mbox && pru->irq_vring > 0) + free_irq(pru->irq_vring, pru); + /* TODO: INTC cleanup */ return 0; @@ -356,6 +471,7 @@ static void *pru_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags) static struct rproc_ops pru_rproc_ops = { .start = pru_rproc_start, .stop = pru_rproc_stop, + .kick = pru_rproc_kick, .da_to_va = pru_da_to_va, }; @@ -383,6 +499,7 @@ static int pru_rproc_probe(struct platform_device *pdev) struct pru_rproc *pru; const char *fw_name; struct rproc *rproc = NULL; + struct mbox_client *client; struct resource *res; int i, ret; const char *mem_names[PRU_MEM_MAX] = { "iram", "control", "debug" }; @@ -475,10 +592,51 @@ static int pru_rproc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rproc); + /* get optional vring and kick interrupts for supporting virtio rpmsg */ + pru->irq_vring = platform_get_irq_byname(pdev, "vring"); + if (pru->irq_vring <= 0) { + ret = pru->irq_vring; + if (ret == -EPROBE_DEFER) + goto free_rproc; + dev_dbg(dev, "unable to get vring interrupt, status = %d\n", + ret); + } + + pru->irq_kick = platform_get_irq_byname(pdev, "kick"); + if (pru->irq_kick <= 0) { + ret = pru->irq_kick; + if (ret == -EPROBE_DEFER) + goto free_rproc; + dev_dbg(dev, "unable to get kick interrupt, status = %d\n", + ret); + } + + /* + * get optional mailbox for virtio rpmsg signalling if vring and kick + * interrupts are not specified for OMAP architecture based SoCs + */ + if (pru->irq_vring <= 0 && pru->irq_kick <= 0 && + !of_device_is_compatible(np, "ti,k2g-pru") && + !of_device_is_compatible(np, "ti,da850-pru")) { + client = &pru->client; + client->dev = dev; + client->tx_done = NULL; + client->rx_callback = pru_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + pru->mbox = mbox_request_channel(client, 0); + if (IS_ERR(pru->mbox)) { + ret = PTR_ERR(pru->mbox); + pru->mbox = NULL; + dev_dbg(dev, "unable to get mailbox channel, status = %d\n", + ret); + } + } + ret = rproc_add(pru->rproc); if (ret) { dev_err(dev, "rproc_add failed: %d\n", ret); - goto free_rproc; + goto put_mbox; } pru_rproc_create_debug_entries(rproc); @@ -487,6 +645,8 @@ static int pru_rproc_probe(struct platform_device *pdev) return 0; +put_mbox: + mbox_free_channel(pru->mbox); free_rproc: rproc_free(rproc); return ret; @@ -496,9 +656,12 @@ static int pru_rproc_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rproc *rproc = platform_get_drvdata(pdev); + struct pru_rproc *pru = rproc->priv; dev_info(dev, "%s: removing rproc %s\n", __func__, rproc->name); + mbox_free_channel(pru->mbox); + rproc_del(rproc); rproc_free(rproc); From patchwork Mon Nov 26 07:52:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151979 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5328898ljp; Sun, 25 Nov 2018 23:53:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/V4YEdIemvsu27cYWvZY8Lnl+2HjvAShzCYOmvckqqAMwOsmCjkw5CufJ5qvlRGpy/WT39G X-Received: by 2002:a63:ca0a:: with SMTP id n10mr23956539pgi.258.1543218813387; Sun, 25 Nov 2018 23:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218813; cv=none; d=google.com; s=arc-20160816; b=Bo9VmIRYA94p9u6aQ3dIU4T62e8knnpnDtMdrcjEQ4YvOaiLkAOQufeENvCTHyBfI/ nkth24bg4RmopNFKnB+Kpb/NN9wNBDDqhlTIAxe3w3Jihn4kLTrWL1zPhmZtmm8LFPau ZdZdOlM/pQoDvQoYvBL2PY8ZQrhw0VFvfq0ngRrbIWsiUzK3N8UBMO9Y3jPkSJTVQpMX kymBnY4juMkJ0qYo5ShAIQYj1B+MuQcEO3JjUkkcHb47PK3oJKtg3jGrRU6fLr8s1xnD WQkBLiwp4Q5dBdyTgnqwkeskFPZtIlUBmg+sdst4PqLngo2YdbvrbTIWgSIFiaRKa7AM 58yQ== 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; bh=sZTc94vWvOFsAAIAnKsSJMsoqEkZSC7CkT0BLKwKYuw=; b=vLlRbbo5nX61w5uolN2/jCj/B6P0Ib9touziHsUGWbwhJCZs6EwJyaD5MhaTMQG388 17vZNrAB8eMfIiUNBEs3AweO0ZHtxCi8td6yTBwnuKG+Ik/JgbSW6ifa3/2sWXYQ8lTA HH7xAQ6zFLgyNAjdOyQbfYB6yMlpr+1Cx4tb5Yfb8I4NIrll9ufyud9uYxFgGS/kbetp ZoFAjopzu1SIjvMV8Q4kdSN4FfwTnWvIiKorYSbVlIAUMtkSh5GlCPRlRCIWymrhNTTi eXnRkr50zU9RG2RurBeWdlidEZ81y9W773pxNV1lt4ySvxb8fIcx6UiAq5521pWZpZtI 01vA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 e69si49949009pfg.137.2018.11.25.23.53.33; Sun, 25 Nov 2018 23:53:33 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726622AbeKZSqr (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:47 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36530 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbeKZSqq (ORCPT ); Mon, 26 Nov 2018 13:46:46 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rRWW102518; Mon, 26 Nov 2018 01:53:27 -0600 Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rRE2059653 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:27 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:27 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:26 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rQwJ002527; Mon, 26 Nov 2018 01:53:26 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1M024490; Mon, 26 Nov 2018 01:53:23 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 08/16] remoteproc/pru: Add pru_rproc_set_ctable() function Date: Mon, 26 Nov 2018 09:52:41 +0200 Message-ID: <1543218769-5507-9-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 Some firmwares expect the OS drivers to configure the CTABLE entries publishing dynamically allocated memory regions. For example, the PRU Ethernet firmwares use the C28 and C30 entries for retrieving the Shared RAM and System SRAM (OCMC) areas allocated by the PRU Ethernet client driver. Provide a way for users to do that through a new API, pru_rproc_set_ctable(). The API returns 0 on success and a negative value on error. NOTE: The programmable CTABLE entries are typically re-programmed by the PRU firmwares when dealing with a certain block of memory during block processing. This API provides an interface to the PRU client drivers to publish a dynamically allocated memory block with the PRU firmware using a CTABLE entry instead of a negotiated address in shared memory. Additional synchronization may be needed between the PRU client drivers and firmwares if different addresses needs to be published at run-time reusing the same CTABLE entry. Signed-off-by: Roger Quadros Signed-off-by: Andrew F. Davis [s-anna@ti.com: add the NOTE: on patch description, minor cleanups] Signed-off-by: Suman Anna --- drivers/remoteproc/pru_rproc.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pruss.h | 29 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index e0554b3..fa3559b 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -65,6 +65,7 @@ enum pru_mem { * @dram0: PRUSS DRAM0 region * @dram1: PRUSS DRAM1 region * @shrdram: PRUSS SHARED RAM region + * @rmw_lock: lock for read, modify, write operations on registers * @iram_da: device address of Instruction RAM for this PRU * @pdram_da: device address of primary Data RAM for this PRU * @sdram_da: device address of secondary Data RAM for this PRU @@ -85,6 +86,7 @@ struct pru_rproc { struct pruss_mem_region dram0; struct pruss_mem_region dram1; struct pruss_mem_region shrdram; + spinlock_t rmw_lock; /* register access lock */ u32 iram_da; u32 pdram_da; u32 sdram_da; @@ -107,6 +109,54 @@ void pru_control_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val) writel_relaxed(val, pru->mem_regions[PRU_MEM_CTRL].va + reg); } +static inline +void pru_control_set_reg(struct pru_rproc *pru, unsigned int reg, + u32 mask, u32 set) +{ + u32 val; + unsigned long flags; + + spin_lock_irqsave(&pru->rmw_lock, flags); + + val = pru_control_read_reg(pru, reg); + val &= ~mask; + val |= (set & mask); + pru_control_write_reg(pru, reg, val); + + spin_unlock_irqrestore(&pru->rmw_lock, flags); +} + +/** + * pru_rproc_set_ctable() - set the constant table index for the PRU + * @rproc: the rproc instance of the PRU + * @c: constant table index to set + * @addr: physical address to set it to + */ +int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr) +{ + struct pru_rproc *pru = rproc->priv; + unsigned int reg; + u32 mask, set; + u16 idx; + u16 idx_mask; + + /* pointer is 16 bit and index is 8-bit so mask out the rest */ + idx_mask = (c >= PRU_C28) ? 0xFFFF : 0xFF; + + /* ctable uses bit 8 and upwards only */ + idx = (addr >> 8) & idx_mask; + + /* configurable ctable (i.e. C24) starts at PRU_CTRL_CTBIR0 */ + reg = PRU_CTRL_CTBIR0 + 4 * (c >> 1); + mask = idx_mask << (16 * (c & 1)); + set = idx << (16 * (c & 1)); + + pru_control_set_reg(pru, reg, mask, set); + + return 0; +} +EXPORT_SYMBOL_GPL(pru_rproc_set_ctable); + static inline u32 pru_debug_read_reg(struct pru_rproc *pru, unsigned int reg) { return readl_relaxed(pru->mem_regions[PRU_MEM_DEBUG].va + reg); @@ -537,6 +587,7 @@ static int pru_rproc_probe(struct platform_device *pdev) pru->pruss = platform_get_drvdata(ppdev); pru->rproc = rproc; pru->fw_name = fw_name; + spin_lock_init(&pru->rmw_lock); ret = pruss_request_mem_region(pru->pruss, PRUSS_MEM_DRAM0, &pru->dram0); diff --git a/include/linux/pruss.h b/include/linux/pruss.h index c797fb1..af04a1c 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -134,7 +134,22 @@ struct pruss_intc_config { s8 ch_to_host[MAX_PRU_CHANNELS]; }; +/** + * enum pru_ctable_idx - Configurable Constant table index identifiers + */ +enum pru_ctable_idx { + PRU_C24 = 0, + PRU_C25, + PRU_C26, + PRU_C27, + PRU_C28, + PRU_C29, + PRU_C30, + PRU_C31, +}; + struct pruss; +struct rproc; #if IS_ENABLED(CONFIG_TI_PRUSS) @@ -232,4 +247,18 @@ int pruss_intc_unconfigure(struct pruss *pruss, #endif /* CONFIG_TI_PRUSS */ +#if IS_ENABLED(CONFIG_PRUSS_REMOTEPROC) + +int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr); + +#else + +static inline int pru_rproc_set_ctable(struct rproc *rproc, + enum pru_ctable_idx c, u32 addr) +{ + return -ENOTSUPP; +} + +#endif /* CONFIG_PRUSS_REMOTEPROC */ + #endif /* __LINUX_PRUSS_H */ From patchwork Mon Nov 26 07:52:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151981 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329003ljp; Sun, 25 Nov 2018 23:53:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/XeIzjfY1YidCzrmrGzFofbW9Qfa5ZBXLtL52hhILYKOsmsrRs5wEuAuCyaE9/+Eohm/g9v X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr26564939plb.169.1543218821804; Sun, 25 Nov 2018 23:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218821; cv=none; d=google.com; s=arc-20160816; b=qPtP8+6+hcBF1tesSrOPXjbLPhFGyGlgQcJfOTA/th+bq4sPgwwOq5qqs96cANtq2G ZAG+x/HDaqoCB2gKUdIejWug2aDwx9JRTBUeKTtGwZW0MnuMy0Gf+HIpu/mWhvjHEL3P 63rtwAsW5FJn6xEH49bwxpzuWTfWfTLhWkaT13N7Hxsqfv7BL7I0LbL3tfNypQTJDKO4 KvD47PbRcv9/exZ96sd1VVa0BP4AH5uOjH/sQGvMvZR6jRqymUa6eqEYYGyO5NBpF5A3 NQ8sgjbwDMOd1R0eDKmpy4ytq0X1ISDHj939SlUcYcUaGFFjgtxuZ5gJ6W1lMlnn9tZ0 f7Sw== 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=yMp3d2Rx8hr0SIVsWuzA4gvgTZR/TBf2/mu894sSCew=; b=vDBe/43cnd7SCa0IPk+AF7Q0e6shhDTAZIY4sq//c2Zhoz0aBwV1uwO/LkBDM1wkzc GAOXGlAyvz0KQxYxvGnwewYQSdg4wjQkFIlPJZLIZC3RAyX6+iJZ7VvMB3Q/pkTaLOQz KWQ5E9ww0SUURWA1UUuIYzo4Nwmof+j/Wks+P+wTEH38lCVlByegequRed3B2DL0tksu 3IlPlt5fNrQqzigvNzQLLUcEEUzNYL9Qg4Wum720OeZE3PFWX1lkGX0WOsX6wbNrowk1 68m0PVuqCvmRoKyiJcHJp2XAtw3HFP5xlISNUhELb3vCTZkGS/da7Xcs/sPLoIJ9YHIt c/5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LviRcGJw; 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 cb2si44444721plb.298.2018.11.25.23.53.41; Sun, 25 Nov 2018 23:53:41 -0800 (PST) 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=LviRcGJw; 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 S1726679AbeKZSqz (ORCPT + 32 others); Mon, 26 Nov 2018 13:46:55 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36546 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726644AbeKZSqz (ORCPT ); Mon, 26 Nov 2018 13:46:55 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rZFm102536; Mon, 26 Nov 2018 01:53:35 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218815; bh=yMp3d2Rx8hr0SIVsWuzA4gvgTZR/TBf2/mu894sSCew=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LviRcGJwxprVYWAxm7GATeIJpx9o7ddCWekgO+yKKB8KCXvlRJDKD34Z8RyzOgg/S 210+EeaHqJf9b0TxcwOqfhmHa7esIf+3G7JLuwhjxQc8u5YhevrG5x0jL6c7EIC/Xb eyfOlYsEKRdjUtjQW3AtO29gRQ/lUEQsuHJhtz8E= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rZEK103677 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:35 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:35 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:35 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rYJa002594; Mon, 26 Nov 2018 01:53:34 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1O024490; Mon, 26 Nov 2018 01:53:31 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 10/16] remoteproc/pru: add pru_rproc_get_id() API to retrieve the PRU id Date: Mon, 26 Nov 2018 09:52:43 +0200 Message-ID: <1543218769-5507-11-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 Export an API pru_rproc_get_id() to allow other PRUSS platform drivers to clients to retrieve the PRU id from a remoteproc handle associated with a PRU. The new function takes in a struct rproc pointer as argument. Signed-off-by: Suman Anna --- drivers/remoteproc/pru_rproc.c | 27 +++++++++++++++++++++++++-- include/linux/pruss.h | 15 +++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 2aa05b0..d8b823d 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -238,6 +238,29 @@ void pru_rproc_put(struct rproc *rproc) EXPORT_SYMBOL_GPL(pru_rproc_put); /** + * pru_rproc_get_id() - get PRU id from a previously acquired PRU remoteproc + * @rproc: the rproc instance of the PRU + * + * Returns the PRU id of the PRU remote processor that has been acquired through + * a pru_rproc_get(), or a negative value on error + */ +enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc) +{ + struct pru_rproc *pru; + + if (IS_ERR_OR_NULL(rproc) || !rproc->dev.parent) + return -EINVAL; + + /* TODO: replace the crude string based check to make sure it is PRU */ + if (!strstr(dev_name(rproc->dev.parent), "pru")) + return -EINVAL; + + pru = rproc->priv; + return pru->id; +} +EXPORT_SYMBOL_GPL(pru_rproc_get_id); + +/** * pru_rproc_set_ctable() - set the constant table index for the PRU * @rproc: the rproc instance of the PRU * @c: constant table index to set @@ -643,9 +666,9 @@ static int pru_rproc_set_id(struct pru_rproc *pru) u32 mask2 = 0x38000; if ((pru->mem_regions[0].pa & mask1) == mask1) - pru->id = 0; + pru->id = PRUSS_PRU0; else if ((pru->mem_regions[0].pa & mask2) == mask2) - pru->id = 1; + pru->id = PRUSS_PRU1; else ret = -EINVAL; diff --git a/include/linux/pruss.h b/include/linux/pruss.h index 405039a..c0a3b3e 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -10,6 +10,15 @@ #ifndef __LINUX_PRUSS_H #define __LINUX_PRUSS_H +/** + * enum pruss_pru_id - PRU core identifiers + */ +enum pruss_pru_id { + PRUSS_PRU0 = 0, + PRUSS_PRU1, + PRUSS_NUM_PRUS, +}; + /* * PRU_ICSS_CFG registers * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only @@ -251,6 +260,7 @@ int pruss_intc_unconfigure(struct pruss *pruss, struct rproc *pru_rproc_get(struct device_node *node, int index); void pru_rproc_put(struct rproc *rproc); +enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc); int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr); #else @@ -262,6 +272,11 @@ static inline struct rproc *pru_rproc_get(struct device_node *node, int index) static inline void pru_rproc_put(struct rproc *rproc) { } +static inline enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc) +{ + return -ENOTSUPP; +} + static inline int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr) { From patchwork Mon Nov 26 07:52:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151982 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329070ljp; Sun, 25 Nov 2018 23:53:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/Up/mu8n5YAs2YiqO+Wjlzk/aP9rLz7FE+z0JHw+eUWlGv43s5Eao+ZnyH6+LjkbGO6qr6b X-Received: by 2002:a17:902:7b91:: with SMTP id w17mr26610062pll.111.1543218825844; Sun, 25 Nov 2018 23:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218825; cv=none; d=google.com; s=arc-20160816; b=N9utiJbkEinpzFbPT43hUuZDEIr4fY47gdy1/+NENFfNSWewUDY387064/dlpR8n7B YjOe/y+hbcndkJzxFyEiYqBwNWBtnP9rxdjyBJh9ttxEECkTsVtYxo4OmxDQibNeb8su nC+CvVhkWHgpX6iO2itq6lWbijEOkdAPbcTclZ8oWBbApW+vrch5LnvnEDFMMgnM36Gd CfrCWTiIozyMuqKV791XmK5Sh6bSZxUznssYjKLGHg5wn3Cntn1mVVcepLj/+6fCIvj9 ibNYo89s6iGub+lNq4mZ8nq/sMe7Flz69PnBaUHkvZq3gejUzizSErEug5YxUO6fhwl5 lPWA== 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=l0MhL2S79mZ5X3JBIlhYX7eDB29eRWidkIFQRsLrfoc=; b=vaUjObx12n43ZtHHT7DBD8FSXSNPoq45LAhqKAc0w0UdMHjBZqsB2DQPAnODX0Lty6 d6tjnQtHkkeHQIU/3HA51ga4/SsGccq7evrzXyOwzXM78nbMkbwceeCEVwubIVc0Cjkr EsaocYzIQOVka8Z3IHddCFNnCvBTJqUXKFgVBK8XhgOYzSYQMQkUwOF2ikdt9LEf+6Y6 P6g+b4aeUPMYW6tw02x0IMFu+QFQT76G8+LHZ+k8vP968Zjr9TsRYVBUQhCNxZH5VIwB xm/JUnQnnOgQQTYyXcIC9UvReOU42nSNNaYlas4cCqo48F69h+oTAT0Zj8AQTT3xnGjD sqdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ohHL1fKE; 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 cb2si44444721plb.298.2018.11.25.23.53.45; Sun, 25 Nov 2018 23:53:45 -0800 (PST) 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=ohHL1fKE; 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 S1726708AbeKZSrA (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:00 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:49494 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbeKZSq7 (ORCPT ); Mon, 26 Nov 2018 13:46:59 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rdME115949; Mon, 26 Nov 2018 01:53:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218819; bh=l0MhL2S79mZ5X3JBIlhYX7eDB29eRWidkIFQRsLrfoc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ohHL1fKEgCpZ5AQVzPEBhrOIjmwBKCAk3VNscuxLFEMNRkTOWMLjwtrM8LMNN1L28 2Z2foSJziUCi1jWb44opbNHVPUiKUOgxtyN0ppIZl7del8KijeeAb15t83hiv8KcVy ahlwtkQUyV5IydV1YwnywxsmRynb8eo87Fz+h1jk= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rdvV103711 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:39 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:39 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:39 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rdKU002632; Mon, 26 Nov 2018 01:53:39 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1P024490; Mon, 26 Nov 2018 01:53:35 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 11/16] soc: ti: pruss: add helper functions to set GPI mode, MII_RT_event and XFR Date: Mon, 26 Nov 2018 09:52:44 +0200 Message-ID: <1543218769-5507-12-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 PRUSS CFG module is represented as a syscon node and is currently managed by the PRUSS platform driver. Add easy accessor functions to set GPI mode, MII_RT event enable/disable and XFR (XIN XOUT) enable/disable to enable the PRUSS Ethernet usecase. These functions reuse the generic pruss_regmap_update() API function. Signed-off-by: Suman Anna --- include/linux/pruss.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/pruss.h b/include/linux/pruss.h index c0a3b3e..7227aae 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -204,6 +204,69 @@ int pruss_intc_configure(struct pruss *pruss, int pruss_intc_unconfigure(struct pruss *pruss, struct pruss_intc_config *intc_config); +/** + * pruss_cfg_get_gpmux() - get the current GPMUX value for a PRU device + * @pruss: pruss instance + * @id: PRU identifier (0-1) + * @mux: pointer to store the current mux value into + */ +static inline int pruss_cfg_get_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 *mux) +{ + int ret = 0; + u32 val; + + ret = pruss_cfg_read(pruss, PRUSS_CFG_GPCFG(id), &val); + if (!ret) + *mux = (u8)((val & PRUSS_GPCFG_PRU_MUX_SEL_MASK) >> + PRUSS_GPCFG_PRU_MUX_SEL_SHIFT); + return ret; +} + +/** + * pruss_cfg_set_gpmux() - set the GPMUX value for a PRU device + * @pruss: pruss instance + * @pru_id: PRU identifier (0-1) + * @mux: new mux value for PRU + */ +static inline int pruss_cfg_set_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 mux) +{ + if (mux >= PRUSS_GP_MUX_SEL_MAX) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_MUX_SEL_MASK, + (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_SHIFT); +} + +/** + * pruss_cfg_miirt_enable() - Enable/disable MII RT Events + * @pruss: the pruss instance + * @enable: enable/disable + * + * Enable/disable the MII RT Events for the PRUSS. + */ +static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) +{ + u32 set = enable ? PRUSS_MII_RT_EVENT_EN : 0; + + return pruss_cfg_update(pruss, PRUSS_CFG_MII_RT, + PRUSS_MII_RT_EVENT_EN, set); +} + +/** + * pruss_cfg_xfr_enable() - Enable/disable XIN XOUT shift functionality + * @pruss: the pruss instance + * @enable: enable/disable + */ +static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable) +{ + u32 set = enable ? PRUSS_SPP_XFER_SHIFT_EN : 0; + + return pruss_cfg_update(pruss, PRUSS_CFG_SPP, + PRUSS_SPP_XFER_SHIFT_EN, set); +} #else static inline struct pruss *pruss_get(struct rproc *rproc) @@ -254,6 +317,28 @@ int pruss_intc_unconfigure(struct pruss *pruss, return -ENOTSUPP; } +static inline int pruss_cfg_get_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 *mux) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_set_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 mux) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_TI_PRUSS */ #if IS_ENABLED(CONFIG_PRUSS_REMOTEPROC) @@ -263,6 +348,30 @@ void pru_rproc_put(struct rproc *rproc); enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc); int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr); +/** + * pruss_cfg_gpimode() - set the GPI mode of the PRU + * @pruss: the pruss instance handle + * @pru: the rproc instance handle of the PRU + * @mode: GPI mode to set + * + * Sets the GPI mode for a given PRU by programming the + * corresponding PRUSS_CFG_GPCFGx register + * + * Returns 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru, + enum pruss_gpi_mode mode) +{ + enum pruss_pru_id id = pru_rproc_get_id(pru); + + if (id < 0) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_GPI_MODE_MASK, + mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT); +} + #else static inline struct rproc *pru_rproc_get(struct device_node *node, int index) @@ -283,6 +392,12 @@ static inline int pru_rproc_set_ctable(struct rproc *rproc, return -ENOTSUPP; } +static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru, + enum pruss_gpi_mode mode) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_PRUSS_REMOTEPROC */ #endif /* __LINUX_PRUSS_H */ From patchwork Mon Nov 26 07:52:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151983 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329122ljp; Sun, 25 Nov 2018 23:53:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/WK19ZLETIPPwMv2Nz59wPSlfId5onisnh5xOTN8wn7hYJQMf2GXeiSt4t9ad1sNNjdmcOd X-Received: by 2002:a63:1258:: with SMTP id 24mr23507491pgs.114.1543218830185; Sun, 25 Nov 2018 23:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218830; cv=none; d=google.com; s=arc-20160816; b=Yg45U8JUbEDlIit+rabVDeu0aYgOKgxyv2+7WtXedFxKzGUTPeDbwE45E5yhwV0Wtc mIoFlrEXrWce2Is3zkvEtaGYHHN9h/IGe3oqMs0LvW7GFmVweANcLFpaxB0OOuPBjdeb cjCxRXoxwUFBDVJjhHD22MVbbdTe8NzcrnB6C4h+C8dlZDv+xo6jTx5mu57VGSGAy0Dg annGXVkue5ufLAfkUW68NWI26y9DCdhplxq2MadBh6/CUAj3JhshuGVeNcamkI9apkym 33o1i4FhxKJUw/ZOvqVXzbeldIcBq92eOhxjkVVoAo+aUsnhirVBgg3qtltZR+65vNqB 0pUw== 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=Wq3rx3PYsI4iFiwTWmGf7b0qeZ/uiC62qdIe0NzgMmM=; b=hTBLBSBHrYTWh6htOA9dGT/xWif9Qh3sl8WlZ2Gg3roqauJKiGE0WvhJ8/TbYZsqMN KmtIvGCb4NT79mVsv4ZxyM08seRpxLW5hmLsp6vr4cO52ZIqqtMKBrTutK6QiQvS4hkn KA7eATTc/XN6bkNRxZ80c1/z4Ls/WCk/PgZL8jKcMvaCLweOGreugYgNJi6AOZk6mq4S v+zqXPDDTeLll7vYz+JgC+SSkMJUGzx578Nbn8cTPUlYE6uSpSg+jzFESpuUly8CM707 Wt9az3TtD41bt3EWfYXduKinRQP3LLhj3YV6V3nmfPfkkVS4yfT4nGTIGVhzaDEZIJcu MlLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="tHXQ6/ih"; 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 x2-v6si61958178plv.413.2018.11.25.23.53.49; Sun, 25 Nov 2018 23:53:50 -0800 (PST) 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="tHXQ6/ih"; 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 S1726734AbeKZSrD (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:03 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:41014 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbeKZSrD (ORCPT ); Mon, 26 Nov 2018 13:47:03 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rh9k043570; Mon, 26 Nov 2018 01:53:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218823; bh=Wq3rx3PYsI4iFiwTWmGf7b0qeZ/uiC62qdIe0NzgMmM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tHXQ6/ih2Qi5WQozISuk6viTXN2cIbNfweHBXVdBdDonfKUK2ARQUw6Hz+mF1NHkU 27VZ/uB20NNl10pckTSAAhynn8kkKWaLa2g3xCindPIWs8NGL7ZSu7cc/C8q6mfhc3 F9yp08qCTq88lou35+jNWkKunDo/wbJ99CMqlYFU= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rhOU059915 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:43 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) 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.1591.10; Mon, 26 Nov 2018 01:53:43 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:43 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rh2U007296; Mon, 26 Nov 2018 01:53:43 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1Q024490; Mon, 26 Nov 2018 01:53:39 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 12/16] dt-bindings: remoteproc: ti-pruss: Document application node bindings Date: Mon, 26 Nov 2018 09:52:45 +0200 Message-ID: <1543218769-5507-13-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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: Tero Kristo Add documentation for the Texas Instruments PRU application nodes. These are used to configure specific user applications for PRU instances. Signed-off-by: Tero Kristo [s-anna@ti.com: some binding updates] Signed-off-by: Suman Anna Signed-off-by: Roger Quadros --- .../devicetree/bindings/soc/ti/ti,pruss.txt | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt b/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt index 3e5f32f..94c91ee 100644 --- a/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt +++ b/Documentation/devicetree/bindings/soc/ti/ti,pruss.txt @@ -210,6 +210,38 @@ used in TI Davinci SoCs. Please refer to the corresponding binding document, Documentation/devicetree/bindings/net/davinci-mdio.txt for details. +Application/User Nodes +======================= +A PRU application/user node typically uses one or more PRU device nodes to +implement a PRU application/functionality. Each application/client node would +need a reference to at least a PRU node, and optionally pass some configuration +parameters. + +Required Properties: +-------------------- +- prus : phandles to the PRU nodes used + +Optional Properties: +-------------------- +- firmware-name : firmwares for the PRU cores, the default firmware + for the core from the PRU node will be used if not + provided. The firmware names should correspond to + the PRU cores listed in the 'prus' property +- ti,pruss-gp-mux-sel : array of values for the GP_MUX_SEL under PRUSS_GPCFG + register for a PRU. This selects the internal muxing + scheme for the PRU instance. If not provided, the + default out-of-reset value (0) for the PRU core is + used. Values should correspond to the PRU cores listed + in the 'prus' property +- ti,pru-interrupt-map : PRU interrupt mappings, containing an array of entries + with each entry consisting of 4 cell-values. First one + is an index towards the "prus" property to identify the + PRU core for the interrupt map, second is the PRU + System Event id, third is the PRU interrupt channel id + and fourth is the PRU host interrupt id. If provided, + this map will supercede any other configuration + provided through firmware + Example: ======== 1. /* AM33xx PRU-ICSS */ @@ -397,3 +429,14 @@ Example: ... }; }; + +3: /* PRU application node example */ + app_node: app_node { + prus = <&pru1_0>, <&pru1_1>; + firmware-name = "pruss-app-fw", "pruss-app-fw-2"; + ti,pruss-gp-mux-sel = <2>, <1>; + /* setup interrupts for prus: + prus[0] => pru1_0: ev=16, chnl=2, host-irq=7, + prus[1] => pru1_1: ev=19, chnl=1, host-irq=3 */ + ti,pru-interrupt-map = <0 16 2 7 >, <1 19 1 3>; + } From patchwork Mon Nov 26 07:52:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151984 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329177ljp; Sun, 25 Nov 2018 23:53:54 -0800 (PST) X-Google-Smtp-Source: AJdET5fW+zF2PuzUXPAuYeaAVWAia0fvPC15UtC1tUlqO2jxEmQks56a8xHOsheAXoaZffqCArjn X-Received: by 2002:a62:2781:: with SMTP id n123mr27201236pfn.138.1543218834857; Sun, 25 Nov 2018 23:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218834; cv=none; d=google.com; s=arc-20160816; b=lkNLAXvjaJlwfnZDQCGXiXqeVWeabpkasLZXqa6RNjdmeFYz8y2/W/3S5pBNX8IMpj Vg0mX8xVP3doTXaAdIv/7H/ed66yVD6cMaO1o8qNk7WRivCpBoE59SWqPPCl49XsYhK9 pT7Sy1CNMXyUQYNq/jX4dlVDMcsNcFp7OI4KBxDzLefjZZa42Kwu9BqemF7F+uEySD57 cdVxALmOJptN1Ilv0nld/34fI1ur/tgbl0fBrhj37krl0IFV+frf1+Las/dge9BuUm4/ G4YsuRyCQt9ik4ZXuQjDZH0km+40xqTBVwVJnSw3JA+aCq7AOEK8GSZouzFCT1oVMszE J6wQ== 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; bh=GqjqmJN1O3r0UufVue0451MwIx1hTm8JfiUXI+/XlVI=; b=P2PcRTxVDHEzyFRkajoyfE4ceY07Su7Ojl37absqTM1L+cLrWSwbhkVJKijWbV2Lpi rvwpEzRybpx15wU/DP0dBRX/veN4TcOLvs2YTK+NFkQchTU5P80zSgjiw2HvNPEMGxo/ xkSl3NEd19mSpGtFy7xSWvfoFAk+kagLj611cSKVMezPjIIKci158OQZCdI/ZTZymPFj 3pyeMJvZKV9w6/iAaFpk4cJrh2jaXEjGnBYMxDGGf04j33sZEhHlaHbucdzIL8GqeGVs pAADYD/H8jZIoS/mfDHNjcIFGhoyKmeXygjRLVjcDxVrASpP9p+Ddye/P0X5tdr8lF33 kWzQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 x2-v6si61958178plv.413.2018.11.25.23.53.54; Sun, 25 Nov 2018 23:53:54 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbeKZSrJ (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:09 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36558 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeKZSrI (ORCPT ); Mon, 26 Nov 2018 13:47:08 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rn9U102551; Mon, 26 Nov 2018 01:53:49 -0600 Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rnmf084094 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:49 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:46 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:46 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rldY009288; Mon, 26 Nov 2018 01:53:47 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1R024490; Mon, 26 Nov 2018 01:53:43 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 13/16] remoteproc/pru: add support for configuring GPMUX based on client setup Date: Mon, 26 Nov 2018 09:52:46 +0200 Message-ID: <1543218769-5507-14-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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: Tero Kristo Client device node property ti,pruss-gp-mux-sel can now be used to configure the GPMUX config value for PRU. Signed-off-by: Tero Kristo [s-anna@ti.com: simplify the pru id usage] Signed-off-by: Suman Anna --- drivers/remoteproc/pru_rproc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index d8b823d..9a08937 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -72,6 +72,7 @@ enum pru_mem { * @sdram_da: device address of secondary Data RAM for this PRU * @shrdram_da: device address of shared Data RAM * @fw_name: name of firmware image used during loading + * @gpmux_save: saved value for gpmux config * @lock: mutex to protect client usage * @dbg_single_step: debug state variable to set PRU into single step mode * @dbg_continuous: debug state variable to restore PRU execution mode @@ -95,6 +96,7 @@ struct pru_rproc { u32 sdram_da; u32 shrdram_da; const char *fw_name; + u8 gpmux_save; struct mutex lock; /* client access lock */ u32 dbg_single_step; u32 dbg_continuous; @@ -184,12 +186,16 @@ struct rproc *pru_rproc_get(struct device_node *np, int index) { struct rproc *rproc; struct pru_rproc *pru; + struct device *dev; + int ret; + u32 mux; rproc = __pru_rproc_get(np, index); if (IS_ERR(rproc)) return rproc; pru = rproc->priv; + dev = &rproc->dev; mutex_lock(&pru->lock); @@ -203,7 +209,27 @@ struct rproc *pru_rproc_get(struct device_node *np, int index) mutex_unlock(&pru->lock); + ret = pruss_cfg_get_gpmux(pru->pruss, pru->id, &pru->gpmux_save); + if (ret) { + dev_err(dev, "failed to get cfg gpmux: %d\n", ret); + goto err; + } + + ret = of_property_read_u32_index(np, "ti,pruss-gp-mux-sel", index, + &mux); + if (!ret) { + ret = pruss_cfg_set_gpmux(pru->pruss, pru->id, mux); + if (ret) { + dev_err(dev, "failed to set cfg gpmux: %d\n", ret); + goto err; + } + } + return rproc; + +err: + pru_rproc_put(rproc); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(pru_rproc_get); @@ -229,6 +255,8 @@ void pru_rproc_put(struct rproc *rproc) if (!pru->client_np) return; + pruss_cfg_set_gpmux(pru->pruss, pru->id, pru->gpmux_save); + mutex_lock(&pru->lock); pru->client_np = NULL; mutex_unlock(&pru->lock); From patchwork Mon Nov 26 07:52:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151985 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329221ljp; Sun, 25 Nov 2018 23:53:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/XSdP2hqpNPswMNcvLufFBpB0V+cvgmXS7IOKUPWkE8tIXF9TuZTvKYLQSTZl175pjjVNtP X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr7874632plp.247.1543218838462; Sun, 25 Nov 2018 23:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218838; cv=none; d=google.com; s=arc-20160816; b=H2pId37ePjyhUm4Ix2iS6nUcsOWrPi1b0OjEmwy2AkNglxK5vKA+ogfrJAighefiii a4RtZtmuiC4+MjhJfhs5w2eEMcwPdhpTUpZgJ2fE7NpLlHuqYQqhJDqLmed1CeKJYZcN RyvAualezIJYE+VkEyS88sUJE6MlEdBm9fmqQ6kFzpsIp2fn2vQp7qeSkJB/SG+BhuEL mM4puZEkxnWXC3ki8ceR28Dq7jCW/ekxZ9pB9MORPQKDDMPlNitlSVg45CUc1OIa+AEf VEsftXw59Cbu7232g/UGbo4CAC5e09dycRsTSVGDipoQx8+dEW9ebJt+JZpvmmrI8avc b3Nw== 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; bh=qOWcnKY6j9Ncdl7ThfjVQ7uHztiyrAIG1hrANVfZq78=; b=IvwtZiPG1Ah8bwHHq3SIlUiJDcHZdyjaBgjO+4i6Vlnpled2qZLb+IIhBZJzMzvZGq nXdEAB5oMr+kYpFPIYdlRWKG6JdLw1s6arwXlFii0FoeU0OvoDDsW2HtQJ1oAyjJxVJs drUYQ9TCEOAuMDTVuFEBiX+nnqcTJ+4pGI5h+4CpZYaP+EziHp32mFl2QabjLz/7zYUs tzmM0jbKAYAMUUFcWMUUYaHoa+S75KTn1IPOXjWNOXSwR8YzgovXFCUc06ERum4AvPYX x3n1nZ6zoRyeH53t69Ctw4KKHGT/VWDDcXCjQyq6K0bk2rY5yljTYlBMHjPnEUocYNhM kKQg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 e1-v6si65161954plk.4.2018.11.25.23.53.58; Sun, 25 Nov 2018 23:53:58 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbeKZSrM (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:12 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36592 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeKZSrL (ORCPT ); Mon, 26 Nov 2018 13:47:11 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rqTm102568; Mon, 26 Nov 2018 01:53:52 -0600 Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rq3M084122 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:52 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:51 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:51 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rpPK020138; Mon, 26 Nov 2018 01:53:51 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1S024490; Mon, 26 Nov 2018 01:53:47 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 14/16] remoteproc/pru: configure firmware based on client setup Date: Mon, 26 Nov 2018 09:52:47 +0200 Message-ID: <1543218769-5507-15-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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: Tero Kristo Client device node property firmware-name is now used to configure firmware for the PRU instances. The default firmware is also restored once releasing the PRU resource. Signed-off-by: Tero Kristo Reviewed-by: Roger Quadros Signed-off-by: Suman Anna --- drivers/remoteproc/pru_rproc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 9a08937..84f006b 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -132,6 +132,21 @@ void pru_control_set_reg(struct pru_rproc *pru, unsigned int reg, spin_unlock_irqrestore(&pru->rmw_lock, flags); } +/** + * pru_rproc_set_firmware() - set firmware for a pru core + * @rproc: the rproc instance of the PRU + * @fw_name: the new firmware name, or NULL if default is desired + */ +static int pru_rproc_set_firmware(struct rproc *rproc, const char *fw_name) +{ + struct pru_rproc *pru = rproc->priv; + + if (!fw_name) + fw_name = pru->fw_name; + + return rproc_set_firmware(rproc, fw_name); +} + static struct rproc *__pru_rproc_get(struct device_node *np, int index) { struct device_node *rproc_np = NULL; @@ -189,6 +204,7 @@ struct rproc *pru_rproc_get(struct device_node *np, int index) struct device *dev; int ret; u32 mux; + const char *fw_name; rproc = __pru_rproc_get(np, index); if (IS_ERR(rproc)) @@ -225,6 +241,16 @@ struct rproc *pru_rproc_get(struct device_node *np, int index) } } + ret = of_property_read_string_index(np, "firmware-name", index, + &fw_name); + if (!ret) { + ret = pru_rproc_set_firmware(rproc, fw_name); + if (ret) { + dev_err(dev, "failed to set firmware: %d\n", ret); + goto err; + } + } + return rproc; err: @@ -255,6 +281,7 @@ void pru_rproc_put(struct rproc *rproc) if (!pru->client_np) return; + pru_rproc_set_firmware(rproc, NULL); pruss_cfg_set_gpmux(pru->pruss, pru->id, pru->gpmux_save); mutex_lock(&pru->lock); From patchwork Mon Nov 26 07:52:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151986 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329252ljp; Sun, 25 Nov 2018 23:54:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/XRpX4URZZDx6kJNf0moEsdztMXBoEtcU32wXauLGMd5pHaqxTe9/lcjxe2a1+ig5UIEK+k X-Received: by 2002:a63:1157:: with SMTP id 23mr23950757pgr.245.1543218841365; Sun, 25 Nov 2018 23:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218841; cv=none; d=google.com; s=arc-20160816; b=Df49NJ1a8eFXmj10mFvkalYOwHEFPlbIvDLvQ/Q1Fq4fxYlNsvuNT29lQZASWDPNVv JcFX5/9ecrco4Gyw7Lkw5fRPYX7QgxGbREU8MZNoim/rd/gfj1xfs9D6UMAkz99ALgHV 9vU7rkOw3duq1qMU/chqlIbKqDCbWGNehtmwnEXwjkkdzZDXkp6CV/o3dtKuP7B+1x9D 4Pq4QN2XwzU+AYmXiyoG1UBTrWJ+BH8y3/1b0NKMldI2MpCM1xBsMqZdewKbfq9WLF42 jsJnJNbw96ThfT0oEADsERmNa7dslff2dNafZCcaIZ0ByShxXEwIdYtDi5Z0zhHbjmkv nDlw== 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; bh=BrMkc1KybtAC28p8Ajc9LZ6lW5Gyw/fQJLxaqaSXIGY=; b=R+v4Trops8b6GAOslLGiJHenW2VvVv9BpZ6A5RWF1qiTWYPDIvVFxuv0dr7MYUs5nV Ng8gA+dZaEf/ftoRJhAx998GoU23hoh96FWkNl+GAMAPB+lgf6mvdlMsBp4PIdMqM49a htBoamE7ThwehG80z6p3ZPTm/Bgad5mjQ+zzQm7mq3tUxZNmIcyh61gKf2UGeVCYijgh v9+tkYHkuOWDc+9f/1NQeJUXAec7dytT4IcJJ7BG3sEDh5xTBwa89MfapIFKLPxd3l+K LKUQl+K3/5FznrFuAX4K4MePhK7We1X9+iT4bCObNBpr8Lwljvk/JWazJRtmkeVCyi+T LWpg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 e1-v6si65161954plk.4.2018.11.25.23.54.01; Sun, 25 Nov 2018 23:54:01 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbeKZSrP (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:15 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36600 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeKZSrO (ORCPT ); Mon, 26 Nov 2018 13:47:14 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rtaN102596; Mon, 26 Nov 2018 01:53:55 -0600 Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rt8F038728 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:55 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:55 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:55 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rtmx009392; Mon, 26 Nov 2018 01:53:55 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1T024490; Mon, 26 Nov 2018 01:53:51 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 15/16] remoteproc/pru: add support for parsing pru interrupt mapping from DT Date: Mon, 26 Nov 2018 09:52:48 +0200 Message-ID: <1543218769-5507-16-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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: Tero Kristo PRU interrupt mapping can now be parsed from devicetree also, from ti,pru-interrupt-map property. This is an alternative configuration method in addition to the legacy resource table config. If both are provided, the config in DT takes precedence. Signed-off-by: Tero Kristo [s-anna@ti.com: various fixes and cleanups] Signed-off-by: Suman Anna Signed-off-by: Roger Quadros --- drivers/remoteproc/pru_rproc.c | 109 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 3 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 84f006b..540cce3 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -63,6 +63,7 @@ enum pru_mem { * @irq_ring: IRQ number to use for processing vring buffers * @irq_kick: IRQ number to use to perform virtio kick * @mem_regions: data for each of the PRU memory regions + * @intc_config: PRU INTC configuration data * @dram0: PRUSS DRAM0 region * @dram1: PRUSS DRAM1 region * @shrdram: PRUSS SHARED RAM region @@ -73,6 +74,7 @@ enum pru_mem { * @shrdram_da: device address of shared Data RAM * @fw_name: name of firmware image used during loading * @gpmux_save: saved value for gpmux config + * @dt_irqs: number of irqs configured from DT * @lock: mutex to protect client usage * @dbg_single_step: debug state variable to set PRU into single step mode * @dbg_continuous: debug state variable to restore PRU execution mode @@ -87,6 +89,7 @@ struct pru_rproc { int irq_vring; int irq_kick; struct pruss_mem_region mem_regions[PRU_MEM_MAX]; + struct pruss_intc_config intc_config; struct pruss_mem_region dram0; struct pruss_mem_region dram1; struct pruss_mem_region shrdram; @@ -97,6 +100,7 @@ struct pru_rproc { u32 shrdram_da; const char *fw_name; u8 gpmux_save; + int dt_irqs; struct mutex lock; /* client access lock */ u32 dbg_single_step; u32 dbg_continuous; @@ -180,6 +184,87 @@ static struct rproc *__pru_rproc_get(struct device_node *np, int index) return rproc; } +static int pru_get_intc_dt_config(struct device *dev, const char *propname, + int index, + struct pruss_intc_config *intc_config) +{ + struct device_node *np = dev->of_node; + struct property *prop; + int ret = 0, entries, i; + int dt_irqs = 0; + u32 *arr; + int max_system_events, max_pru_channels, max_pru_host_ints; + + max_system_events = MAX_PRU_SYS_EVENTS; + max_pru_channels = MAX_PRU_CHANNELS; + max_pru_host_ints = MAX_PRU_CHANNELS; + + prop = of_find_property(np, propname, NULL); + if (!prop) + return 0; + + entries = of_property_count_u32_elems(np, propname); + if (entries <= 0 || entries % 4) + return -EINVAL; + + arr = kmalloc_array(entries, sizeof(u32), GFP_KERNEL); + if (!arr) + return -ENOMEM; + + ret = of_property_read_u32_array(np, propname, arr, entries); + if (ret) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(intc_config->sysev_to_ch); i++) + intc_config->sysev_to_ch[i] = -1; + + for (i = 0; i < ARRAY_SIZE(intc_config->ch_to_host); i++) + intc_config->ch_to_host[i] = -1; + + for (i = 0; i < entries; i += 4) { + if (arr[i] != index) + continue; + + if (arr[i + 1] < 0 || + arr[i + 1] >= max_system_events) { + dev_dbg(dev, "bad sys event %d\n", arr[i + 1]); + ret = -EINVAL; + goto err; + } + + if (arr[i + 2] < 0 || + arr[i + 2] >= max_pru_channels) { + dev_dbg(dev, "bad channel %d\n", arr[i + 2]); + ret = -EINVAL; + goto err; + } + + if (arr[i + 3] < 0 || + arr[i + 3] >= max_pru_host_ints) { + dev_dbg(dev, "bad irq %d\n", arr[i + 3]); + ret = -EINVAL; + goto err; + } + + intc_config->sysev_to_ch[arr[i + 1]] = arr[i + 2]; + dev_dbg(dev, "sysevt-to-ch[%d] -> %d\n", arr[i + 1], + arr[i + 2]); + + intc_config->ch_to_host[arr[i + 2]] = arr[i + 3]; + dev_dbg(dev, "chnl-to-host[%d] -> %d\n", arr[i + 2], + arr[i + 3]); + + dt_irqs++; + } + + kfree(arr); + return dt_irqs; + +err: + kfree(arr); + return ret; +} + /** * pru_rproc_get() - get the PRU rproc instance from a device node * @np: the user/client device node @@ -251,6 +336,15 @@ struct rproc *pru_rproc_get(struct device_node *np, int index) } } + ret = pru_get_intc_dt_config(dev, "ti,pru-interrupt-map", + index, &pru->intc_config); + if (ret < 0) { + dev_err(dev, "error getting DT interrupt map: %d\n", ret); + goto err; + } + + pru->dt_irqs = ret; + return rproc; err: @@ -568,7 +662,13 @@ static int pru_rproc_start(struct rproc *rproc) dev_dbg(dev, "starting PRU%d: entry-point = 0x%x\n", pru->id, (rproc->bootaddr >> 2)); - /* TODO: INTC setup */ + if (pru->dt_irqs) { + ret = pruss_intc_configure(pru->pruss, &pru->intc_config); + if (ret) { + dev_err(dev, "failed to configure intc %d\n", ret); + return ret; + } + } if (!list_empty(&pru->rproc->rvdevs)) { if (!pru->mbox && (pru->irq_vring <= 0 || pru->irq_kick <= 0)) { @@ -596,7 +696,8 @@ static int pru_rproc_start(struct rproc *rproc) return 0; fail: - /* TODO: INTC cleanup */ + if (pru->dt_irqs) + pruss_intc_unconfigure(pru->pruss, &pru->intc_config); return ret; } @@ -618,7 +719,9 @@ static int pru_rproc_stop(struct rproc *rproc) !pru->mbox && pru->irq_vring > 0) free_irq(pru->irq_vring, pru); - /* TODO: INTC cleanup */ + /* undo INTC config */ + if (pru->dt_irqs) + pruss_intc_unconfigure(pru->pruss, &pru->intc_config); return 0; } From patchwork Mon Nov 26 07:52:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151987 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329353ljp; Sun, 25 Nov 2018 23:54:07 -0800 (PST) X-Google-Smtp-Source: AJdET5eGygzTifk5NSBFjb9GAdj3FfPmAtbbFjfOeeky8EMlUy7NDGRo4wNg9gTNq9exRVdmj+y4 X-Received: by 2002:a62:440e:: with SMTP id r14-v6mr26763551pfa.185.1543218847719; Sun, 25 Nov 2018 23:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218847; cv=none; d=google.com; s=arc-20160816; b=N3j4uTwIYm/seb/xSPqMcVEh4pKWB+Ai3F298zSizEWNnKoWUtIzlwqiVzjXoNf/Uq 9JAhw2EZQrJ/fow7hTrHSyw23VikaMRBBfIaSkIlOdCuSBpqjUOMAIaagGPJhm+RDDM0 K2GNh3sV9OnrCFxBZxnE07h70B4JMizljaycaHq12Cfbc0Dse6k4OFDILsqAzqiSjLZw 8i8wRWw/ZsV7C230XeVpFFk7Xx3BMCk4B724FgVwE/nDY70T8RJOEJSNfSOzLAywMkJx W7RZPZdqrBL3dnWSlS0jXIlr8oYvpQ35SAcrnlyLrAcAUDOVfQxjbVJs9WImL5k+o87x pwdQ== 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=e7Kt614Hb305Va7Jkr2pFVKsfcKezvJJ/+gFDtyC3Fo=; b=H6+3n2x+gRO0KHJaiWiSSUlne4tYSsN290awt1LZSIFmsC8yinDrGc8LyZLMFLgs2U aqjG0DjmgvbQbJs0nh9Zb7z2/R62E5DV08u6EQCSzvtGXH9PjtPDHkvbFF1m2bOBjJrd acLmwlyOITTK0NVef3TibgKkJM0n1CKyscdODu8EqXsFPNw7XttiuEMYVpG4xBY6KoJK 5nxpeXF+sApXSTyFpHX5tZG/Zme/qGH3SkLwlel7YveV4ChxTz3U/8RN02Z+6YrEwVo0 g5XErs1LKrlYM5AX5fjls3kG8yLkW7Wj/7YtERyaxGJErsOfGPzTqebMd+48QNOSG5ft 0WcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZRh+cplV; 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 w61si25187912plb.309.2018.11.25.23.54.07; Sun, 25 Nov 2018 23:54:07 -0800 (PST) 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=ZRh+cplV; 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 S1726860AbeKZSrV (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:21 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:49600 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeKZSrV (ORCPT ); Mon, 26 Nov 2018 13:47:21 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rx4C116063; Mon, 26 Nov 2018 01:53:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218839; bh=e7Kt614Hb305Va7Jkr2pFVKsfcKezvJJ/+gFDtyC3Fo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZRh+cplVXn0ZcFNUFhYT2bKdXHRr8fiz0VV96nQ/Vp3hY1O+wF4yfUHv8r/J+vnnL qaHQhX2by13msSFOi1Kf+/1prbJ4Z0DuNV/A6fMzrkMF/fQ/M/M77sppQ2b9gi7bfj Pgoldsa6CQUvD8aIeDYmWEOP4LkenWY2ur+3wVzo= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rxl6103927 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:59 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:59 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:59 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rxIG009440; Mon, 26 Nov 2018 01:53:59 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1U024490; Mon, 26 Nov 2018 01:53:55 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 16/16] remoteproc/pru: Add support for INTC Interrupt map resource Date: Mon, 26 Nov 2018 09:52:49 +0200 Message-ID: <1543218769-5507-17-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@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 Use the vendor specific resource mechanism to get the INTC mapping details from firmware. pru-software-support-package [1] has been historically using version 0 for this. However, the data structure is not scaleable and is not self sufficient. 1) it hard codes number of channel to host mappings so is not scaleable to newer SoCs than have more of these. 2) it does not contain the event to channel mappings within itself but relies on a pointer to point to another section in data memory. This causes a weird complication that the respective data section must be loaded before we can really use the INTC map. With this patch we drop support for version 0 and support version 1 which is a more robust and scalable data structure. It should be able to support a sufficiently large number (255) of sysevents, channels and host interrupts and is self contained so it can be used without dependency on order of loading sections. [1] git://git.ti.com/pru-software-support-package/pru-software-support-package.git Signed-off-by: Roger Quadros --- drivers/remoteproc/pru_rproc.c | 110 +++++++++++++++++++++++++++++++++++++++-- drivers/remoteproc/pru_rproc.h | 48 +++++++----------- 2 files changed, 126 insertions(+), 32 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 540cce3..9e22c70 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -75,6 +75,7 @@ enum pru_mem { * @fw_name: name of firmware image used during loading * @gpmux_save: saved value for gpmux config * @dt_irqs: number of irqs configured from DT + * @fw_irqs: number of irqs configured from FW * @lock: mutex to protect client usage * @dbg_single_step: debug state variable to set PRU into single step mode * @dbg_continuous: debug state variable to restore PRU execution mode @@ -101,6 +102,7 @@ struct pru_rproc { const char *fw_name; u8 gpmux_save; int dt_irqs; + int fw_irqs; struct mutex lock; /* client access lock */ u32 dbg_single_step; u32 dbg_continuous; @@ -651,6 +653,107 @@ static void pru_rproc_kick(struct rproc *rproc, int vq_id) } } +/* + * parse the custom interrupt map resource and save the intc_config + * for use when booting the processor. + */ +static int pru_handle_vendor_intrmap(struct rproc *rproc, + struct fw_rsc_pruss_intrmap *rsc) +{ + int fw_irqs = 0, i, ret = 0; + u8 *arr; + struct device *dev = &rproc->dev; + struct pru_rproc *pru = rproc->priv; + + dev_dbg(dev, "vendor rsc intc: version %d\n", rsc->version); + + /* + * 0 was prototyping version. Not supported. + * 1 is currently supported version. + */ + if (rsc->version == 0 || rsc->version > 1) { + dev_err(dev, "Unsupported version %d\n", rsc->version); + return -EINVAL; + } + + /* DT provided INTC config takes precedence */ + if (pru->dt_irqs) { + dev_info(dev, "INTC config in DT and FW. Using DT config.\n"); + return 0; + } + + arr = rsc->data; + + for (i = 0; i < ARRAY_SIZE(pru->intc_config.sysev_to_ch); i++) + pru->intc_config.sysev_to_ch[i] = -1; + + for (i = 0; i < ARRAY_SIZE(pru->intc_config.ch_to_host); i++) + pru->intc_config.ch_to_host[i] = -1; + + for (i = 0; i < rsc->num_maps * 3; i += 3) { + if (arr[i] < 0 || + arr[i] >= MAX_PRU_SYS_EVENTS) { + dev_err(dev, "bad sys event %d\n", arr[i]); + ret = -EINVAL; + goto err; + } + + if (arr[i + 1] < 0 || + arr[i + 1] >= MAX_PRU_CHANNELS) { + dev_err(dev, "bad channel %d\n", arr[i + 1]); + ret = -EINVAL; + goto err; + } + + if (arr[i + 2] < 0 || + arr[i + 2] >= MAX_PRU_CHANNELS) { + dev_err(dev, "bad host irq %d\n", arr[i + 2]); + ret = -EINVAL; + goto err; + } + + pru->intc_config.sysev_to_ch[arr[i]] = arr[i + 1]; + dev_dbg(dev, "sysevt-to-ch[%d] -> %d\n", arr[i], + arr[i + 1]); + + pru->intc_config.ch_to_host[arr[i + 1]] = arr[i + 2]; + dev_dbg(dev, "chnl-to-host[%d] -> %d\n", arr[i + 1], + arr[i + 2]); + + fw_irqs++; + } + + pru->fw_irqs = fw_irqs; + return 0; + +err: + pru->fw_irqs = 0; + return ret; +} + +/* PRU-specific vendor resource handler */ +static int pru_rproc_handle_vendor_rsc(struct rproc *rproc, + struct fw_rsc_vendor *ven_rsc) +{ + struct device *dev = rproc->dev.parent; + int ret = -EINVAL; + + struct fw_rsc_pruss_intrmap *rsc; + + rsc = (struct fw_rsc_pruss_intrmap *)ven_rsc->data; + + switch (rsc->type) { + case PRUSS_RSC_INTRS: + ret = pru_handle_vendor_intrmap(rproc, rsc); + break; + default: + dev_err(dev, "%s: cannot handle unknown type %d\n", __func__, + rsc->type); + } + + return ret; +} + /* start a PRU core */ static int pru_rproc_start(struct rproc *rproc) { @@ -662,7 +765,7 @@ static int pru_rproc_start(struct rproc *rproc) dev_dbg(dev, "starting PRU%d: entry-point = 0x%x\n", pru->id, (rproc->bootaddr >> 2)); - if (pru->dt_irqs) { + if (pru->dt_irqs || pru->fw_irqs) { ret = pruss_intc_configure(pru->pruss, &pru->intc_config); if (ret) { dev_err(dev, "failed to configure intc %d\n", ret); @@ -696,7 +799,7 @@ static int pru_rproc_start(struct rproc *rproc) return 0; fail: - if (pru->dt_irqs) + if (pru->dt_irqs || pru->fw_irqs) pruss_intc_unconfigure(pru->pruss, &pru->intc_config); return ret; @@ -720,7 +823,7 @@ static int pru_rproc_stop(struct rproc *rproc) free_irq(pru->irq_vring, pru); /* undo INTC config */ - if (pru->dt_irqs) + if (pru->dt_irqs || pru->fw_irqs) pruss_intc_unconfigure(pru->pruss, &pru->intc_config); return 0; @@ -815,6 +918,7 @@ static struct rproc_ops pru_rproc_ops = { .stop = pru_rproc_stop, .kick = pru_rproc_kick, .da_to_va = pru_da_to_va, + .handle_vendor_rsc = pru_rproc_handle_vendor_rsc, }; static int pru_rproc_set_id(struct pru_rproc *pru) diff --git a/drivers/remoteproc/pru_rproc.h b/drivers/remoteproc/pru_rproc.h index 35240e9..a9413f6 100644 --- a/drivers/remoteproc/pru_rproc.h +++ b/drivers/remoteproc/pru_rproc.h @@ -23,43 +23,33 @@ enum pruss_rsc_types { PRUSS_RSC_MAX = 2, }; -/** - * struct pruss_event_chnl - PRU system events _to_ channel mapping - * @event: number of the system event - * @chnl: channel number assigned to a given @event - * - * PRU system events are mapped to channels, and these channels are mapped - * to host interrupts. Events can be mapped to channels in a one-to-one or - * many-to-one ratio (multiple events per channel), and channels can be - * mapped to host interrupts in a one-to-one or many-to-one ratio (multiple - * channels per interrupt). - * - */ -struct pruss_event_chnl { - s8 event; - s8 chnl; -}; /** - * struct fw_rsc_custom_intrmap - custom resource to define PRU interrupts - * @reserved: reserved field providing padding and alignment - * @chnl_host_intr_map: array of PRU channels to host interrupt mappings - * @event_chnl_map_size: number of event_channel mappings defined in - * @event_chnl_map_addr - * @event_chnl_map_addr: PRU device address of pointer to array of events to - * channel mappings (struct pruss_event_chnl elements) + * struct fw_rsc_pruss_intrmap - vendor resource to define PRU interrupts + * @type: should be PRUSS_RSC_INTRS + * @version: should be 1 or greater. 0 was for prototyping and is not supported + * @num_maps: number of interrupt mappings that follow + * @data: Array of 'num_maps' mappings. + * Each mapping is a triplet {s, c, h} + * s - system event id + * c - channel id + * h - host interrupt id * * PRU system events are mapped to channels, and these channels are mapped * to host interrupts. Events can be mapped to channels in a one-to-one or * many-to-one ratio (multiple events per channel), and channels can be * mapped to host interrupts in a one-to-one or many-to-one ratio (multiple * channels per interrupt). + * + * This resource is variable length due to the nature of INTC map. + * The below data structure is scalable so it can support sufficiently + * large number of sysevents and hosts. */ -struct fw_rsc_custom_intrmap { - u16 reserved; - s8 chnl_host_intr_map[10]; - u32 event_chnl_map_size; - u32 event_chnl_map_addr; -}; +struct fw_rsc_pruss_intrmap { + u16 type; + u16 version; + u8 num_maps; + u8 data[]; +} __packed; #endif /* _PRU_REMOTEPROC_H_ */