From patchwork Fri Jan 5 23:58:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123576 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428380qgn; Fri, 5 Jan 2018 15:58:39 -0800 (PST) X-Google-Smtp-Source: ACJfBoteC8gTS7D0PXIOxEn6ilnqJmnLmksWOSj1E9d5NaLZWTtYkpV03sleXq+YCChSSboOYM/d X-Received: by 10.98.233.1 with SMTP id j1mr4455460pfh.123.1515196719591; Fri, 05 Jan 2018 15:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196719; cv=none; d=google.com; s=arc-20160816; b=KKoP1qK/4aCG3S7Bek/t7NsUht0GvLni6lSutTM9Dv63y4WV7TuPL0rQekqcfcEWGO 17gZFmiKJWmFT5OtmdvfAl7BCwRk7XGFin3ljZRkg77tmsWRlPEgFZtLluRcSUsqBFEK jsD9Ete2CJcQ7bSrYFjIlAkEFP8nYgVyJEhrOUs5XNwkYZuVia0ufZfyH8vxnwIJ771f 3xj0QXfPXkIMNwHp0RlU4Omdl7bBhpx3Go7W3PsZzF2OCiG66K62QP1vkyr2yf2Oicva 5pVIfYB/KXNjphn9W2s+yfxOYXNy/7FhifM6m1txQ0AHrDW+/G0kZtS/cNAXdPy5CvP0 MWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=Z0vmLdTjU5uI4ue/0c7/+lq9FOxNcRT3cv3nr8fOOqnEi5oT7bHOYhZ0k5sg2IU1aU pwEsj/h7I0a+ZcjLxc8RJLb9cPRtmrb8VlMMMKaxnRNYjF+83HtBaQONwC+D2+U9QDFR UBzueB3Njk5ASVCHMrrqZszOD6Q0nO7A7dhGIzHz6SyAZiwCGcPKvgcdgUNXkirzxBRA XbAI28HNeokrxMDnIiFdJMsUI8w2HoZW7u5rm+foNGX132R/+PWN5engxZ4RXKbqHpwc YEabXJYt8ws8rprxdYOvb50n41IkdGaG47uqMVA1I5iry5NNP5ekc/lroKvKf3Dna0a2 z4xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q1MzhLDj; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si4143833pgs.787.2018.01.05.15.58.39; Fri, 05 Jan 2018 15:58:39 -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=@linaro.org header.s=google header.b=Q1MzhLDj; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753432AbeAEX6X (ORCPT + 28 others); Fri, 5 Jan 2018 18:58:23 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37713 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbeAEX6P (ORCPT ); Fri, 5 Jan 2018 18:58:15 -0500 Received: by mail-pf0-f195.google.com with SMTP id n6so2815868pfa.4 for ; Fri, 05 Jan 2018 15:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=Q1MzhLDjuMLpzzQ8SKziQe1pICgDFAA/MnPVKVAa6GinJZgJI7nMaWmETLB67EB3Z7 LqlG/ouekVxn1Smui0bFEpXw9WmApHNpzmDM2BuP0/EWq5pA+rKacOlRCbfiVC2bJ0Ff S0FLC3WZtZwWpRBvjg+0Xl2iITXBqC/QbJJF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=mer43NI9J37uXhGDQ/0rqlxv2PyOJksJRF4aMx0Bohnc5EKdPnSdhw07b3mrpDd+TU LtKC69K9bQmMIWvmXE0vXnSCOoauWa4O+2QeK42amkWxASvCOcRF0wPLNPd87Hlh7q4w uKGTErfbsl4DU9iao6eZLg0Ps1ZbPjkqRoEFX5ahE6/Grn+vpDbN0oZanJTgiDBxINia hAbYd91KQD9f1FD7QgT9CbvyvVZfjp5mjhw+2mWOhD7oHlrhQf1yQ9E0SflYhPbomD0S MiY7jB7nQWEbNG4bp3G31qWEQhqeIiI6J/dOsBte5Tyt6X55P+t+1xXKXU739JNVJoUk kLoA== X-Gm-Message-State: AKGB3mIwd5r7qOl7VIQ05j+TSLUX72ANeVKXwihFABefBFBukv0DMOK6 CGcjFq0bcsiltziuVid4dMoSfw== X-Received: by 10.99.0.214 with SMTP id 205mr3992185pga.236.1515196694542; Fri, 05 Jan 2018 15:58:14 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id x4sm14473188pfk.51.2018.01.05.15.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:13 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 4/8] remoteproc: Merge rproc_ops and rproc_fw_ops Date: Fri, 5 Jan 2018 15:58:01 -0800 Message-Id: <20180105235805.9948-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are currently a few different schemes used for overriding fw_ops or parts of fw_ops. Merge fw_ops into rproc_ops and expose the default ELF-loader symbols so that they can be assigned by the drivers. To keep backwards compatibility with the "default" case, a driver not specifying the "load" operation is assumed to want the full ELF-loader suit of functions. Signed-off-by: Bjorn Andersson --- Changes since v1: - Fill load, sanity_check and get_boot_addr for st_slim drivers/remoteproc/qcom_adsp_pil.c | 9 ++---- drivers/remoteproc/qcom_q6v5_pil.c | 9 ++---- drivers/remoteproc/qcom_wcnss.c | 9 ++---- drivers/remoteproc/remoteproc_core.c | 10 ++++-- drivers/remoteproc/remoteproc_elf_loader.c | 30 +++++++----------- drivers/remoteproc/remoteproc_internal.h | 51 +++++++++++------------------- drivers/remoteproc/st_slim_rproc.c | 22 ++++--------- include/linux/remoteproc.h | 17 ++++++++-- 8 files changed, 67 insertions(+), 90 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 3f6af54dbc96..56156c12bd73 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -85,11 +85,6 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) adsp->mem_region, adsp->mem_phys, adsp->mem_size); } -static const struct rproc_fw_ops adsp_fw_ops = { - .find_rsc_table = qcom_mdt_find_rsc_table, - .load = adsp_load, -}; - static int adsp_start(struct rproc *rproc) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; @@ -182,6 +177,8 @@ static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, + .find_rsc_table = qcom_mdt_find_rsc_table, + .load = adsp_load, }; static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) @@ -344,8 +341,6 @@ static int adsp_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &adsp_fw_ops; - adsp = (struct qcom_adsp *)rproc->priv; adsp->dev = &pdev->dev; adsp->rproc = rproc; diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 8a3fa2bcc9f6..3ea668d9fd4c 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -342,11 +342,6 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw) return 0; } -static const struct rproc_fw_ops q6v5_fw_ops = { - .find_rsc_table = q6v5_find_rsc_table, - .load = q6v5_load, -}; - static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms) { unsigned long timeout; @@ -931,6 +926,8 @@ static const struct rproc_ops q6v5_ops = { .start = q6v5_start, .stop = q6v5_stop, .da_to_va = q6v5_da_to_va, + .find_rsc_table = q6v5_find_rsc_table, + .load = q6v5_load, }; static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) @@ -1150,8 +1147,6 @@ static int q6v5_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &q6v5_fw_ops; - qproc = (struct q6v5 *)rproc->priv; qproc->dev = &pdev->dev; qproc->rproc = rproc; diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index c7686393d505..e53fc6f268fc 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -156,11 +156,6 @@ static int wcnss_load(struct rproc *rproc, const struct firmware *fw) wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size); } -static const struct rproc_fw_ops wcnss_fw_ops = { - .find_rsc_table = qcom_mdt_find_rsc_table, - .load = wcnss_load, -}; - static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) { u32 val; @@ -313,6 +308,8 @@ static const struct rproc_ops wcnss_ops = { .start = wcnss_start, .stop = wcnss_stop, .da_to_va = wcnss_da_to_va, + .find_rsc_table = qcom_mdt_find_rsc_table, + .load = wcnss_load, }; static irqreturn_t wcnss_wdog_interrupt(int irq, void *dev) @@ -492,8 +489,6 @@ static int wcnss_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &wcnss_fw_ops; - wcnss = (struct qcom_wcnss *)rproc->priv; wcnss->dev = &pdev->dev; wcnss->rproc = rproc; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index dbf685dbafcf..2c669a73e77d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1437,8 +1437,14 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, atomic_set(&rproc->power, 0); - /* Set ELF as the default fw_ops handler */ - rproc->fw_ops = &rproc_elf_fw_ops; + /* Default to ELF loader if no load function is specified */ + if (!rproc->ops->load) { + rproc->ops->load = rproc_elf_load_segments; + rproc->ops->find_rsc_table = rproc_elf_find_rsc_table; + rproc->ops->find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table; + rproc->ops->sanity_check = rproc_elf_sanity_check; + rproc->ops->get_boot_addr = rproc_elf_get_boot_addr; + } mutex_init(&rproc->lock); diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index c523983a4aec..822fa1bf893f 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -39,8 +39,7 @@ * * Make sure this fw image is sane. */ -static int -rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) +int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) { const char *name = rproc->firmware; struct device *dev = &rproc->dev; @@ -98,6 +97,7 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) return 0; } +EXPORT_SYMBOL(rproc_elf_sanity_check); /** * rproc_elf_get_boot_addr() - Get rproc's boot address. @@ -110,13 +110,13 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) * Note that the boot address is not a configurable property of all remote * processors. Some will always boot at a specific hard-coded address. */ -static u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; return ehdr->e_entry; } +EXPORT_SYMBOL(rproc_elf_get_boot_addr); /** * rproc_elf_load_segments() - load firmware segments to memory @@ -142,8 +142,7 @@ u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) * directly allocate memory for every segment/resource. This is not yet * supported, though. */ -static int -rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) +int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) { struct device *dev = &rproc->dev; struct elf32_hdr *ehdr; @@ -207,6 +206,7 @@ rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) return ret; } +EXPORT_SYMBOL(rproc_elf_load_segments); static struct elf32_shdr * find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) @@ -282,9 +282,9 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) * size into @tablesz. If a valid table isn't found, NULL is returned * (and @tablesz isn't set). */ -static struct resource_table * -rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, - int *tablesz) +struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, + const struct firmware *fw, + int *tablesz) { struct elf32_hdr *ehdr; struct elf32_shdr *shdr; @@ -303,6 +303,7 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, return table; } +EXPORT_SYMBOL(rproc_elf_find_rsc_table); /** * rproc_elf_find_loaded_rsc_table() - find the loaded resource table @@ -315,8 +316,8 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, * Returns the pointer to the resource table if it is found or NULL otherwise. * If the table wasn't loaded yet the result is unspecified. */ -static struct resource_table * -rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) +struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw) { struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; struct elf32_shdr *shdr; @@ -327,11 +328,4 @@ rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); } - -const struct rproc_fw_ops rproc_elf_fw_ops = { - .load = rproc_elf_load_segments, - .find_rsc_table = rproc_elf_find_rsc_table, - .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, - .sanity_check = rproc_elf_sanity_check, - .get_boot_addr = rproc_elf_get_boot_addr -}; +EXPORT_SYMBOL(rproc_elf_find_loaded_rsc_table); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c1077bec5d0b..a42690c514e2 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -25,26 +25,6 @@ struct rproc; -/** - * struct rproc_fw_ops - firmware format specific operations. - * @find_rsc_table: find the resource table inside the firmware image - * @find_loaded_rsc_table: find the loaded resouce table - * @load: load firmeware to memory, where the remote processor - * expects to find it - * @sanity_check: sanity check the fw image - * @get_boot_addr: get boot address to entry point specified in firmware - */ -struct rproc_fw_ops { - struct resource_table *(*find_rsc_table)(struct rproc *rproc, - const struct firmware *fw, - int *tablesz); - struct resource_table *(*find_loaded_rsc_table)( - struct rproc *rproc, const struct firmware *fw); - int (*load)(struct rproc *rproc, const struct firmware *fw); - int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); - u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); -}; - /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); @@ -74,11 +54,20 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); int rproc_trigger_recovery(struct rproc *rproc); +int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); +u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw); +int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); +struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, + const struct firmware *fw, + int *tablesz); +struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw); + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->sanity_check) - return rproc->fw_ops->sanity_check(rproc, fw); + if (rproc->ops->sanity_check) + return rproc->ops->sanity_check(rproc, fw); return 0; } @@ -86,8 +75,8 @@ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) static inline u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->get_boot_addr) - return rproc->fw_ops->get_boot_addr(rproc, fw); + if (rproc->ops->get_boot_addr) + return rproc->ops->get_boot_addr(rproc, fw); return 0; } @@ -95,8 +84,8 @@ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) static inline int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->load) - return rproc->fw_ops->load(rproc, fw); + if (rproc->ops->load) + return rproc->ops->load(rproc, fw); return -EINVAL; } @@ -106,8 +95,8 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw, int *tablesz) { - if (rproc->fw_ops->find_rsc_table) - return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz); + if (rproc->ops->find_rsc_table) + return rproc->ops->find_rsc_table(rproc, fw, tablesz); return NULL; } @@ -116,12 +105,10 @@ static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->find_loaded_rsc_table) - return rproc->fw_ops->find_loaded_rsc_table(rproc, fw); + if (rproc->ops->find_loaded_rsc_table) + return rproc->ops->find_loaded_rsc_table(rproc, fw); return NULL; } -extern const struct rproc_fw_ops rproc_elf_fw_ops; - #endif /* REMOTEPROC_INTERNAL_H */ diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index 6cfd862f945b..1bce63a06424 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c @@ -200,12 +200,6 @@ static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) return va; } -static const struct rproc_ops slim_rproc_ops = { - .start = slim_rproc_start, - .stop = slim_rproc_stop, - .da_to_va = slim_rproc_da_to_va, -}; - /* * Firmware handler operations: sanity, boot address, load ... */ @@ -223,8 +217,14 @@ static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc, return &empty_rsc_tbl; } -static struct rproc_fw_ops slim_rproc_fw_ops = { +static const struct rproc_ops slim_rproc_ops = { + .start = slim_rproc_start, + .stop = slim_rproc_stop, + .da_to_va = slim_rproc_da_to_va, .find_rsc_table = slim_rproc_find_rsc_table, + .get_boot_addr = rproc_elf_get_boot_addr, + .load = rproc_elf_load_segments, + .sanity_check = rproc_elf_sanity_check, }; /** @@ -249,7 +249,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, struct rproc *rproc; struct resource *res; int err, i; - const struct rproc_fw_ops *elf_ops; if (!fw_name) return ERR_PTR(-EINVAL); @@ -267,13 +266,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, slim_rproc = rproc->priv; slim_rproc->rproc = rproc; - elf_ops = rproc->fw_ops; - /* Use some generic elf ops */ - slim_rproc_fw_ops.load = elf_ops->load; - slim_rproc_fw_ops.sanity_check = elf_ops->sanity_check; - - rproc->fw_ops = &slim_rproc_fw_ops; - /* get imem and dmem */ for (i = 0; i < ARRAY_SIZE(mem_names); i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index cc4d30a790b3..ca2021cf7b39 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -324,6 +324,7 @@ struct rproc_mem_entry { }; struct rproc; +struct firmware; /** * struct rproc_ops - platform-specific device handlers @@ -331,12 +332,26 @@ struct rproc; * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations + * @find_rsc_table: find the resource table inside the firmware image + * @find_loaded_rsc_table: find the loaded resouce table + * @load: load firmeware to memory, where the remote processor + * expects to find it + * @sanity_check: sanity check the fw image + * @get_boot_addr: get boot address to entry point specified in firmware */ 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); + struct resource_table *(*find_rsc_table)(struct rproc *rproc, + const struct firmware *fw, + int *tablesz); + struct resource_table *(*find_loaded_rsc_table)( + struct rproc *rproc, const struct firmware *fw); + int (*load)(struct rproc *rproc, const struct firmware *fw); + int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); + u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); }; /** @@ -390,7 +405,6 @@ enum rproc_crash_type { * @priv: private data which belongs to the platform-specific rproc module * @ops: platform-specific start/stop rproc handlers * @dev: virtual device for refcounting and common remoteproc behavior - * @fw_ops: firmware-specific handlers * @power: refcount of users who need this rproc powered up * @state: state of the device * @lock: lock which protects concurrent manipulations of the rproc @@ -421,7 +435,6 @@ struct rproc { void *priv; struct rproc_ops *ops; struct device dev; - const struct rproc_fw_ops *fw_ops; atomic_t power; unsigned int state; struct mutex lock;