From patchwork Fri Jan 27 15:32:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 92679 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp293770qgi; Fri, 27 Jan 2017 07:43:48 -0800 (PST) X-Received: by 10.84.197.3 with SMTP id m3mr10957651pld.89.1485531828324; Fri, 27 Jan 2017 07:43:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si4796131pfc.16.2017.01.27.07.43.48; Fri, 27 Jan 2017 07:43:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933157AbdA0PmF (ORCPT + 9 others); Fri, 27 Jan 2017 10:42:05 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:33612 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932163AbdA0PkF (ORCPT ); Fri, 27 Jan 2017 10:40:05 -0500 Received: by mail-wm0-f42.google.com with SMTP id d140so14787408wmd.0 for ; Fri, 27 Jan 2017 07:39:59 -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=0b0GADFTek8iJNxxRiKkdzk35wMC8uT22er/SB0Jf7Q=; b=QxZ/HrvRIbwiZeLn1xdDadP6L554WuU8jNsPqjZHUqLVdFTbKcp65lHoas4j6QNL4m BcxLLk2Fd7RYwQrisdLnKFUrau9UJW+MPZHd96J8fqh87z+jMoQ/zvNTmsb0+YP0nnuF /dnwEgL8MUijWt7E6Y4ysEZ6qkBtQQEt7zPak= 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=0b0GADFTek8iJNxxRiKkdzk35wMC8uT22er/SB0Jf7Q=; b=epO6q2gxCMoDZ/+7KeNU1mOFNYDL0INHx9Vfbm9rvRES4FhaLvCXFSrdOFiSz3VNAe WuOarOHzBIIwH7JjFi46/dY5ek1d8/RzrRdtPk8vwoKChMOa1JT+btsxFJg4Er63zdQ+ akWwWGn3n8QYhNUbH8A8JNnrcfhKnQr4E3lt6RgykV/X8DpAUz0UQD1tjGm8bMOdSD2m 7/rrjFlVxOuyEZKV4v5DWLYs37Usn5E3eOQ6/C1ZGL9LyrwbS94RFJQjYSPGubY5rmKc 17Qws+1oNou2Emsslk6JYMcIh7Mmb1kJsabEKiInflFOiZ1LVOhkreyZvdGaE3J4/++5 JIbw== X-Gm-Message-State: AIkVDXKhYD0e4vwAwuwzD95T//YUBuZfIzWOfOCpnyAGMvVBkMbShLvSn1Eo6OST5cIgtJa0 X-Received: by 10.28.189.134 with SMTP id n128mr3382183wmf.77.1485531193023; Fri, 27 Jan 2017 07:33:13 -0800 (PST) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id h75sm8447474wrh.37.2017.01.27.07.33.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 07:33:12 -0800 (PST) From: Stanimir Varbanov To: Ohad Ben-Cohen , Bjorn Andersson , Rob Herring Cc: Stephen Boyd , Andy Gross , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v3 1/2] dt-binding: remoteproc: venus rproc dt binding document Date: Fri, 27 Jan 2017 17:32:56 +0200 Message-Id: <1485531177-3543-2-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485531177-3543-1-git-send-email-stanimir.varbanov@linaro.org> References: <1485531177-3543-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add devicetree binding document for Venus remote processor. Acked-by: Rob Herring Signed-off-by: Stanimir Varbanov --- .../devicetree/bindings/remoteproc/qcom,venus.txt | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/qcom,venus.txt -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt b/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt new file mode 100644 index 000000000000..38ac585dbd7b --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt @@ -0,0 +1,33 @@ +Qualcomm Venus Peripheral Image Loader + +This document defines the binding for a component that loads and boots firmware +on the Qualcomm Venus remote processor core. + +- compatible: + Usage: required + Value type: + Definition: must contain "qcom,venus-pil" + +- memory-region: + Usage: required + Value type: + Definition: a phandle to a node describing reserved memory + +* An example + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + venus_mem: venus@89900000 { + compatible = "shared-dma-pool"; + reg = <0x0 0x89900000 0x0 0x800000>; + alignment = <0x1000>; + no-map; + }; + }; + + rproc-venus { + compatible = "qcom,venus-pil"; + memory-region = <&venus_mem>; + }; From patchwork Fri Jan 27 15:32:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 92684 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp294495qgi; Fri, 27 Jan 2017 07:45:33 -0800 (PST) X-Received: by 10.84.172.1 with SMTP id m1mr13256724plb.5.1485531933284; Fri, 27 Jan 2017 07:45:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t188si3398373pfb.193.2017.01.27.07.45.33; Fri, 27 Jan 2017 07:45: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; dkim=pass header.i=@linaro.org; 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 S933399AbdA0Pnu (ORCPT + 25 others); Fri, 27 Jan 2017 10:43:50 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38643 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933146AbdA0Pls (ORCPT ); Fri, 27 Jan 2017 10:41:48 -0500 Received: by mail-wm0-f51.google.com with SMTP id r144so144091662wme.1 for ; Fri, 27 Jan 2017 07:40:34 -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=9zTtu0TfdvIk6x/nK1Ph+6LNBvBcbq4uOvFfPbrzTFE=; b=XpyXRTO9IZNsMgQ0j6ajc2rTFaxi2Bxpuyf3nct/edmOsIxTAqwb1sQskqjNorHC/v FQ+/BO9XilCnmIrOyFLggkRYbx4Dq+7b8TTS/g2c51Z3EFcBIJgEX5p2sbpnUUUzusKP apt8sFrjt7iBW9Bw7HviXBPmhhcLvZW8k6HHo= 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=9zTtu0TfdvIk6x/nK1Ph+6LNBvBcbq4uOvFfPbrzTFE=; b=G+xS5Tdp6pFoJEMa/q6HRfRCyqqddQaQ2EYFkiNm0Yf9Kkv+h6a7ttzA0AuOW23GwL QDVuri5+DPvqZGxR+G1P78YojIPlidvI/vm3LoiwyWV39oEOfQiD9fbPFz351LN2ydAf tKf+J0Hp30VqSi0t/0i2jonFCvVdA+tJHWIIScpWL0cAdt/aMyLiHMc71ZUXOhI4zC+8 Ner/z11uJAwe91Sb5vpI9nFm/a6bX3g7+yDBaGDRJS0phbdaWipUupWXEN1otZsW4u2v kjsnI7wLy+UK5CLf2GbujvxC2XZcfrp2PIFMkNniTTS6PBGM1SVEIeC/QHnXGoCt68Xr WpvQ== X-Gm-Message-State: AIkVDXJI/+qRU5TDjw4prCJizJgWO554nC1EkQ8KA1TyXOKD4CZxHP+DDVQFk83sH1VHd16f X-Received: by 10.28.46.73 with SMTP id u70mr3494382wmu.54.1485531195555; Fri, 27 Jan 2017 07:33:15 -0800 (PST) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id h75sm8447474wrh.37.2017.01.27.07.33.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 07:33:15 -0800 (PST) From: Stanimir Varbanov To: Ohad Ben-Cohen , Bjorn Andersson , Rob Herring Cc: Stephen Boyd , Andy Gross , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v3 2/2] remoteproc: qcom: add Venus video core firmware loader driver Date: Fri, 27 Jan 2017 17:32:57 +0200 Message-Id: <1485531177-3543-3-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485531177-3543-1-git-send-email-stanimir.varbanov@linaro.org> References: <1485531177-3543-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver will load and authenticate the Venus firmware and bringing it core out of reset. Those two functionalities are via secure monitor calls to trusted environment. Signed-off-by: Stanimir Varbanov --- drivers/remoteproc/Kconfig | 12 +++ drivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_venus_pil.c | 208 ++++++++++++++++++++++++++++++++++++ 3 files changed, 221 insertions(+) create mode 100644 drivers/remoteproc/qcom_venus_pil.c -- 2.7.4 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index a5e888043f1f..08ee26db9d2b 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -110,6 +110,18 @@ config QCOM_WCNSS_PIL Say y here to support the Peripheral Image Loader for the Qualcomm Wireless Connectivity Subsystem. +config QCOM_VENUS_PIL + tristate "Qualcomm Venus Peripheral Image Loader" + depends on OF && ARCH_QCOM + depends on QCOM_SCM + select QCOM_MDT_LOADER + select REMOTEPROC + help + Say y here to support Qualcomm Peripherial Image Loader for the + Venus remote processor. The Venus remote processor is a + micro-controller plus dedicated hardware for video acceleration + of video decoding and encoding operations. + config ST_REMOTEPROC tristate "ST remoteproc support" depends on ARCH_STI diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 0938ea3c41ba..9bb292e4bac4 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -17,5 +17,6 @@ obj-$(CONFIG_QCOM_Q6V5_PIL) += qcom_q6v5_pil.o obj-$(CONFIG_QCOM_WCNSS_PIL) += qcom_wcnss_pil.o qcom_wcnss_pil-y += qcom_wcnss.o qcom_wcnss_pil-y += qcom_wcnss_iris.o +obj-$(CONFIG_QCOM_VENUS_PIL) += qcom_venus_pil.o obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o diff --git a/drivers/remoteproc/qcom_venus_pil.c b/drivers/remoteproc/qcom_venus_pil.c new file mode 100644 index 000000000000..3057bc67cf72 --- /dev/null +++ b/drivers/remoteproc/qcom_venus_pil.c @@ -0,0 +1,208 @@ +/* + * Qualcomm Venus Peripheral Image Loader + * + * Copyright (C) 2017 Linaro Ltd + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qcom_mdt_loader.h" +#include "remoteproc_internal.h" + +#define VENUS_FIRMWARE_NAME "venus.mdt" +#define VENUS_PAS_ID 9 +#define VENUS_FW_MEM_SIZE SZ_8M + +struct qcom_venus { + struct device *dev; + struct rproc *rproc; + phys_addr_t fw_addr; + phys_addr_t mem_phys; + void *mem_va; + size_t mem_size; +}; + +static int venus_load(struct rproc *rproc, const struct firmware *fw) +{ + struct qcom_venus *venus = rproc->priv; + phys_addr_t pa; + size_t fw_size; + bool relocate; + int ret; + + ret = qcom_scm_pas_init_image(VENUS_PAS_ID, fw->data, fw->size); + if (ret) { + dev_err(&rproc->dev, "invalid firmware metadata (%d)\n", ret); + return -EINVAL; + } + + ret = qcom_mdt_parse(fw, &venus->fw_addr, &fw_size, &relocate); + if (ret) { + dev_err(&rproc->dev, "failed to parse mdt header (%d)\n", ret); + return ret; + } + + if (fw_size > venus->mem_size) + return -ENOMEM; + + pa = relocate ? venus->mem_phys : venus->fw_addr; + + ret = qcom_scm_pas_mem_setup(VENUS_PAS_ID, pa, fw_size); + if (ret) { + dev_err(&rproc->dev, "unable to setup memory (%d)\n", ret); + return -EINVAL; + } + + return qcom_mdt_load(rproc, fw, VENUS_FIRMWARE_NAME); +} + +static const struct rproc_fw_ops venus_fw_ops = { + .find_rsc_table = qcom_mdt_find_rsc_table, + .load = venus_load, +}; + +static int venus_start(struct rproc *rproc) +{ + struct qcom_venus *venus = rproc->priv; + int ret; + + ret = qcom_scm_pas_auth_and_reset(VENUS_PAS_ID); + if (ret) + dev_err(venus->dev, + "authentication image and release reset failed (%d)\n", + ret); + + return ret; +} + +static int venus_stop(struct rproc *rproc) +{ + struct qcom_venus *venus = rproc->priv; + int ret; + + ret = qcom_scm_pas_shutdown(VENUS_PAS_ID); + if (ret) + dev_err(venus->dev, "failed to shutdown: %d\n", ret); + + return ret; +} + +static void *venus_da_to_va(struct rproc *rproc, u64 da, int len) +{ + struct qcom_venus *venus = rproc->priv; + s64 offset; + + offset = da - venus->fw_addr; + + if (offset < 0 || offset + len > venus->mem_size) + return NULL; + + return venus->mem_va + offset; +} + +static const struct rproc_ops venus_ops = { + .start = venus_start, + .stop = venus_stop, + .da_to_va = venus_da_to_va, +}; + +static int venus_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct qcom_venus *venus; + struct rproc *rproc; + int ret; + + if (!qcom_scm_is_available()) + return -EPROBE_DEFER; + + ret = of_reserved_mem_device_init(dev); + if (ret) + return ret; + + rproc = rproc_alloc(dev, pdev->name, &venus_ops, VENUS_FIRMWARE_NAME, + sizeof(*venus)); + if (!rproc) { + dev_err(dev, "unable to allocate remoteproc\n"); + ret = -ENOMEM; + goto release_mem; + } + + rproc->auto_boot = false; + rproc->fw_ops = &venus_fw_ops; + venus = rproc->priv; + venus->dev = dev; + venus->rproc = rproc; + venus->mem_size = VENUS_FW_MEM_SIZE; + + platform_set_drvdata(pdev, venus); + + venus->mem_va = dma_alloc_coherent(dev, venus->mem_size, + &venus->mem_phys, GFP_KERNEL); + if (!venus->mem_va) { + ret = -ENOMEM; + goto free_rproc; + } + + ret = rproc_add(rproc); + if (ret) + goto free_mem; + + return 0; + +free_mem: + dma_free_coherent(dev, venus->mem_size, venus->mem_va, venus->mem_phys); +free_rproc: + rproc_put(rproc); +release_mem: + of_reserved_mem_device_release(dev); + + return ret; +} + +static int venus_remove(struct platform_device *pdev) +{ + struct qcom_venus *venus = platform_get_drvdata(pdev); + struct device *dev = venus->dev; + + rproc_del(venus->rproc); + dma_free_coherent(dev, venus->mem_size, venus->mem_va, venus->mem_phys); + of_reserved_mem_device_release(dev); + + return 0; +} + +static const struct of_device_id venus_of_match[] = { + { .compatible = "qcom,venus-pil" }, + { }, +}; +MODULE_DEVICE_TABLE(of, venus_of_match); + +static struct platform_driver venus_driver = { + .probe = venus_probe, + .remove = venus_remove, + .driver = { + .name = "qcom-venus-pil", + .of_match_table = venus_of_match, + }, +}; + +module_platform_driver(venus_driver); +MODULE_DESCRIPTION("Peripheral Image Loader for Venus"); +MODULE_LICENSE("GPL v2");