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) {