From patchwork Thu Mar 1 16:23:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130331 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3006796edc; Thu, 1 Mar 2018 08:26:46 -0800 (PST) X-Google-Smtp-Source: AG47ELuNi901g+H2kC1vb4wHc8sFDgGeBYRY6VAWSaPgHfL1L5GIqjCgHh9gYu1aJfn6g7oNYv4z X-Received: by 10.98.211.198 with SMTP id z67mr2575128pfk.0.1519921606541; Thu, 01 Mar 2018 08:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921606; cv=none; d=google.com; s=arc-20160816; b=cxNWaLx2eDnawXRysoav2lconDKWqhRG/dtdhtrrteVqZ/Hvk5phXYEvNueUqYtQda Ak6PJhgSLkdIrWeSybAHgtnHrclpUGBEfDyqnN0OHy3hRRGB3j/B6nIgHNa8MwixyHQW neSLJkKtxykHVk9wLA9H5ac0Xt0b5GES/KEV3725Xy1R40XbEvvuw65vDX7KhkPfAuUO 8eZ6X5UVgA88EiKauvEJfTfWbJVjpuLtu8LsTtwnd02pc1vDziHFA5J8pVFM3S6h5VRc nNdLFAOlKm0AwyUdrXVhw3k61Nm/LwJGvKO0WmKbShTR0DFOxODr6kgvsOcTJcorqxP4 OuMg== 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:arc-authentication-results; bh=zYyxEcM25Kt1a1I8BIDz7pM7rPWqYzAb2Q89cZccnQU=; b=bn65agoD+FguT8II4cOTFeuc+y8N+MkdBDs5OMf93HwQMfKdxY85jiDIOGXnBQTOk8 U687fmui6oUE26R0UZ+LilohIO6U7XBZV/zZx68nhtfDqSTwMesrWp1Ifz3J/NXme+uw loWWx2ci+LbRCcfHntWvumaz8+rMTT/VHCyBpKg2LLPxs3hSotdNCu8EgmWpl8SFaTD3 HorE8HXBz+6myypBCB/Dyuzq6Rdjq5BylvBuqb007y0IXmGjTc0EjkVjz6Rw2eE9oRgn uh8URKsMuDDTY5F7s6FVUntBmP1IddFlllfb2elBNoTUscTtwKbhx28Zbmz4MPgC/eMA wfKQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127si2647952pga.171.2018.03.01.08.26.46; Thu, 01 Mar 2018 08:26:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033124AbeCAQ0n (ORCPT + 28 others); Thu, 1 Mar 2018 11:26:43 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43970 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032977AbeCAQYT (ORCPT ); Thu, 1 Mar 2018 11:24:19 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJKq5002395; Thu, 1 Mar 2018 17:24:16 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gaytjb7jw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:16 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6100D34; Thu, 1 Mar 2018 16:24:16 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4158E51FF; Thu, 1 Mar 2018 16:24:16 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:15 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops Date: Thu, 1 Mar 2018 17:23:55 +0100 Message-ID: <1519921440-21356-9-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some SoC architecture, it is needed to enable HW like clock, bus, regulator, memory region... before loading co-processor firmware. This patch introduces prepare and unprepare ops to execute platform specific function before firmware loading and after stop execution. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 20 +++++++++++++++++++- include/linux/remoteproc.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7a500cb..0ebbc4f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1058,12 +1058,22 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } + /* Prepare rproc for firmware loading if needed */ + if (rproc->ops->prepare) { + ret = rproc->ops->prepare(rproc); + if (ret) { + dev_err(dev, "can't prepare rproc %s: %d\n", + rproc->name, ret); + goto disable_iommu; + } + } + rproc->bootaddr = rproc_get_boot_addr(rproc, fw); /* load resource table */ ret = rproc_load_rsc_table(rproc, fw); if (ret) - goto disable_iommu; + goto unprepare_rproc; /* reset max_notifyid */ rproc->max_notifyid = -1; @@ -1086,6 +1096,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) kfree(rproc->cached_table); rproc->cached_table = NULL; rproc->table_ptr = NULL; +unprepare_rproc: + /* release HW resources if needed */ + if (rproc->ops->unprepare) + rproc->ops->unprepare(rproc); disable_iommu: rproc_disable_iommu(rproc); return ret; @@ -1331,6 +1345,10 @@ void rproc_shutdown(struct rproc *rproc) /* clean up all acquired resources */ rproc_resource_cleanup(rproc); + /* release HW resources if needed */ + if (rproc->ops->unprepare) + rproc->ops->unprepare(rproc); + rproc_disable_iommu(rproc); /* Free the copy of the resource table */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 4aa30bd..dcfa601 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -333,6 +333,8 @@ struct rproc_mem_entry { /** * struct rproc_ops - platform-specific device handlers + * @prepare: prepare device for code loading + * @unprepare: unprepare device after stop * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) @@ -345,6 +347,8 @@ struct rproc_mem_entry { * @get_boot_addr: get boot address to entry point specified in firmware */ struct rproc_ops { + int (*prepare)(struct rproc *rproc); + int (*unprepare)(struct rproc *rproc); int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid);