From patchwork Fri Sep 6 11:55:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 11135073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C118715E6 for ; Fri, 6 Sep 2019 11:55:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EE10206CD for ; Fri, 6 Sep 2019 11:55:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pMfztF7k"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eGW1pVA6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EE10206CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=646FkIDDqYNkRsMaelh2cKg3A3f1mgurPGOP4WL3N1s=; b=pMfztF7kTgmp0Q ygYSiV1QB4NDlOywmWA2I+IhFrPfnHqKVd4G8w09OqJyA2Jq5IVRBTyS315RCtcniR2XNg/lywF3J dWZjRLt/NXu/Mwq3QFEzg9E78kNtF9Rx1YrdfU1y1lKppGviD/T86GIAQPDUZ+tsRb0FtA3uuY2sV 50p80LUbucklLnYL8Sfmb+srjG+GeSDCFDeZbq1kQQVO9D5zLng6+W8jCMm8yCcweFeD0b/aEjcTc HHJ31Wvw2hSloPXHETJUy7JZxyt3dUc0VEUay1a7OJY60up40t9yphdfDd6I1K3IsglMC8O0zJ0Qp L59Olml+Z25fwBSNGc7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i6CqJ-00045n-8v; Fri, 06 Sep 2019 11:55:55 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i6CqE-0003y5-OX for linux-mediatek@lists.infradead.org; Fri, 06 Sep 2019 11:55:53 +0000 Received: by mail-pl1-x641.google.com with SMTP id y1so3010847plp.9 for ; Fri, 06 Sep 2019 04:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kv55BZnn02toQdz6kJnclO1x7RUZAYx9ZqQlXw9MFbw=; b=eGW1pVA6FgmcZ6zJNDohUT0Z1B3VbFHelf5Zix26sr+4tvawKYD346Nf2mmNVVYDHi niCnBRlj6FhRv8FxDKWqU0prp1mgcm2mft6s20X5+xdMY0lFuAJCiFRWc+L6mf+S1aYT njlmsvX8bjcaQrG95D2KZN+hadP5ibbXz3isA= 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:mime-version:content-transfer-encoding; bh=Kv55BZnn02toQdz6kJnclO1x7RUZAYx9ZqQlXw9MFbw=; b=QERwXZ/5KJHQuuU3w5GhoO+jKReO/b3Y+lfniGABVatNsoCxSyySJOsyOyvoNRaShX aOFAThtyGXLGHytboRUaV3G4g5Auw7Z6THdU2mTEv+FWeMOeCydhFdCUa0YGesDY2Lao SHw1dq9BfIchO1FnFcbdNzvKT1W0np/9kkcngjAIAk8KfgWuo8E57catX39i0jr6mga7 C0ZoYEfYSLWydMsF1bvI2UDRx+5aMICJuH0oEW8u8XmtK3dOTGPMNq8/x1z7i7SkV80/ 883vynIUViCuE7C/JHnJnxVztb5WmigQpMDK6yTFeoemezVqpbmlk0r4Qi6JExWjXTzD S5EA== X-Gm-Message-State: APjAAAViJTGepDC9OErSqBaPff9qPNwjYRpzKwHTFaQ9Ywc+omdhb+Dk QKuUTimq27G4MXoApjn9RabsLdrjc2U= X-Google-Smtp-Source: APXvYqyC5FMNkRM36lVldrFj5nOcN4Wyw8rYmXXE/IM8t7emC1crUrfOtvatZ4cgQsZy5ZAz5EJASg== X-Received: by 2002:a17:902:744a:: with SMTP id e10mr8865982plt.239.1567770949864; Fri, 06 Sep 2019 04:55:49 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:4:9712:8cf1:d0f:7d33]) by smtp.gmail.com with ESMTPSA id o22sm3667394pjq.21.2019.09.06.04.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 04:55:49 -0700 (PDT) From: Alexandre Courbot To: Yunfei Dong , Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Mauro Carvalho Chehab Subject: [RFC PATCH v2 07/13] media: mtk-vcodec: add SCP firmware ops Date: Fri, 6 Sep 2019 20:55:07 +0900 Message-Id: <20190906115513.159705-8-acourbot@chromium.org> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog In-Reply-To: <20190906115513.159705-1-acourbot@chromium.org> References: <20190906115513.159705-1-acourbot@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190906_045550_800163_52710C22 X-CRM114-Status: GOOD ( 11.60 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Yunfei Dong Add support for communicating with the SCP firmware, which will be used by MT8183. Signed-off-by: Yunfei Dong [acourbot: refactor, cleanup and split] Co-developed-by: Alexandre Courbot Signed-off-by: Alexandre Courbot --- .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 3 ++ .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 3 ++ .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 51 +++++++++++++++++++ .../media/platform/mtk-vcodec/mtk_vcodec_fw.h | 2 + 4 files changed, 59 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index f6494f584354..53a9e016d989 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -226,6 +226,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", &rproc_phandle)) { fw_type = VPU; + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", + &rproc_phandle)) { + fw_type = SCP; } else { mtk_v4l2_err("Could not get vdec IPI device"); return -ENODEV; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c index 6a2ae909d36b..1f40dd780f30 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c @@ -234,6 +234,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", &rproc_phandle)) { fw_type = VPU; + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", + &rproc_phandle)) { + fw_type = SCP; } else { mtk_v4l2_err("Could not get vdec IPI device"); return -ENODEV; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c index a4361f57aedc..de22e16ad3a3 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c @@ -63,6 +63,48 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = { .ipi_send = mtk_vcodec_vpu_ipi_send, }; +static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw) +{ + return rproc_boot(fw->rproc); +} + +static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw) +{ + return scp_get_vdec_hw_capa(fw->pdev); +} + +static unsigned int mtk_vcodec_scp_get_venc_capa(struct mtk_vcodec_fw *fw) +{ + return scp_get_venc_hw_capa(fw->pdev); +} + +static void *mtk_vcodec_vpu_scp_dm_addr(struct mtk_vcodec_fw *fw, + u32 dtcm_dmem_addr) +{ + return scp_mapping_dm_addr(fw->pdev, dtcm_dmem_addr); +} + +static int mtk_vcodec_scp_set_ipi_register(struct mtk_vcodec_fw *fw, int id, + mtk_vcodec_ipi_handler handler, const char *name, void *priv) +{ + return scp_ipi_register(fw->pdev, id, handler, priv); +} + +static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf, + unsigned int len, unsigned int wait) +{ + return scp_ipi_send(fw->pdev, id, buf, len, wait); +} + +static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = { + .load_firmware = mtk_vcodec_scp_load_firmware, + .get_vdec_capa = mtk_vcodec_scp_get_vdec_capa, + .get_venc_capa = mtk_vcodec_scp_get_venc_capa, + .map_dm_addr = mtk_vcodec_vpu_scp_dm_addr, + .ipi_register = mtk_vcodec_scp_set_ipi_register, + .ipi_send = mtk_vcodec_scp_ipi_send, +}; + static void mtk_vcodec_reset_handler(void *priv) { struct mtk_vcodec_dev *dev = priv; @@ -96,6 +138,15 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler, dev, rst_id); break; + case SCP: + ops = &mtk_vcodec_rproc_msg; + fw_pdev = scp_get_pdev(dev->plat_dev); + rproc = rproc_get_by_phandle(rproc_phandle); + if (!rproc) { + mtk_v4l2_err("could not get vdec rproc handle"); + return ERR_PTR(-EPROBE_DEFER); + } + break; default: mtk_v4l2_err("invalid vcodec fw type"); return ERR_PTR(-EINVAL); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h index a6edb3858e6e..c000bda70362 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h @@ -4,6 +4,7 @@ #define _MTK_VCODEC_FW_H_ #include +#include #include "../mtk-vpu/mtk_vpu.h" @@ -11,6 +12,7 @@ struct mtk_vcodec_dev; enum mtk_vcodec_fw_type { VPU, + SCP, }; struct mtk_vcodec_fw;