From patchwork Thu Aug 23 14:28:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikash Garodia X-Patchwork-Id: 144933 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp222786ljw; Thu, 23 Aug 2018 07:29:36 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZH6uE2nRvtRSkZ5mxqYqtjwPUc1YOVRy3ad89vWgc/nrzRMEdhV761CpxLE+JNBNPn+7f0 X-Received: by 2002:a63:485a:: with SMTP id x26-v6mr9404667pgk.375.1535034575993; Thu, 23 Aug 2018 07:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535034575; cv=none; d=google.com; s=arc-20160816; b=L5KQ7v7vcQm7pi/N6TcpSZbF0vV7P74L4eA2MHW1Q7kc0+mDhoYnbNkJGAssZKhZ1m ieMvCZzkb2LrSANfSpiO6PC9pCuZjVk+iYYgMM8Zeo7C/iQsDU2DvuCKk4wCqWz6JCf2 FF1nz+PCSk04vCvJ3CIKlY2G4jJjb7l6BSmGQKb83slMUm6zJHhwB5tsAPttYekZ/AZL RKWbzysC4ISkDBecHp9yfSi7mVutO9uf6YulrPRCT2cz0RzO8DGVTlFkCA1v8EI1g19q okEw/MIrczwnpaM8vTYSzJrOZ/1kEx9Y7EkBieWIDXs1mHxiYom+ej1scdCKMNPO8Joa tYLA== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=PmVO4ZlQGGXGSZ+qxVzqegmXG5WCvSxQrCS67rMjFEM=; b=MYQ0T5cGMBA6SBh4Sl0DFgEgRjmO2Ga03IeGtglCmP6yDDWguRZrKBPHtVMpxZjszq 7UQ7gsbLVrLdqhyHDDavPf03Hh2b8ZhkBIUaOGZnAvPakGfdPD0emHLq765/eU1lGVfU HOV5r6UcSGFE+O7KCh/6LVdXewd0HKiCehyXvqmmxMas2IL/W9zwsCHK4w3ceOcd70dk mPRi3ixjQu62VLuFPKSq0E7Drt5EhPOiuCU5o7Eg8nggsknEBd/5donHAaHBs3Jot1HV tECQITged9SlDsDYW3hKq30hwKiGBoFqs/xW8j6RibBTM7liFZZTTD/1CUep2QuR7OSr nfzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=X4Po5S1p; dkim=pass header.i=@codeaurora.org header.s=default header.b=jsqkg7ZQ; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 r22-v6si2605152pgb.509.2018.08.23.07.29.35; Thu, 23 Aug 2018 07:29:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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=@codeaurora.org header.s=default header.b=X4Po5S1p; dkim=pass header.i=@codeaurora.org header.s=default header.b=jsqkg7ZQ; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732821AbeHWR73 (ORCPT + 4 others); Thu, 23 Aug 2018 13:59:29 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47042 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727597AbeHWR73 (ORCPT ); Thu, 23 Aug 2018 13:59:29 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1F3DB60540; Thu, 23 Aug 2018 14:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535034572; bh=a3+c3B+enKxPpQzuEEXZHUPxuevz3371ZLvVLgU6OSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4Po5S1pDYj+SckVfBj19/qD+y811meOLHExgLZoeQU+w2qml88bspY8X4CfovcId AJJd1V3xWzYrBn0PQ0CCx2bT7mQQb1ZbXEogcI6FfUddCapl2ltAx2uLYOSRnkYCK2 JranS0Am6CObHkAkUYYxkgfj3Lu0Fpc8KF0cSHNI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from vgarodia-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vgarodia@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2309760585; Thu, 23 Aug 2018 14:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535034570; bh=a3+c3B+enKxPpQzuEEXZHUPxuevz3371ZLvVLgU6OSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jsqkg7ZQE4u5VaFGNYg+a1a1v+WwAfghFmrP5mNJDe9u/ZCOdim73bjDA4TiMXYlI 52MCn9iLskYDDEwqYPwA4Ed6aCtsJ8dS8JxqcBondHp6SFcDDPga8UCZOCfJsGUjuA uTdGkr/hiZsTiGndnDWSGwzmfXBlf5YQzOPCt+ts= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2309760585 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vgarodia@codeaurora.org From: Vikash Garodia To: stanimir.varbanov@linaro.org, hverkuil@xs4all.nl, mchehab@kernel.org, robh@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, arnd@arndb.de, bjorn.andersson@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, acourbot@chromium.org, vgarodia@codeaurora.org Subject: [PATCH v6 4/4] venus: firmware: register separate platform_device for firmware loader Date: Thu, 23 Aug 2018 19:58:48 +0530 Message-Id: <1535034528-11590-5-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535034528-11590-1-git-send-email-vgarodia@codeaurora.org> References: <1535034528-11590-1-git-send-email-vgarodia@codeaurora.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Stanimir Varbanov This registers a firmware platform_device and associate it with video-firmware DT subnode. Then calls dma configure to initialize dma and iommu. Signed-off-by: Stanimir Varbanov --- .../devicetree/bindings/media/qcom,venus.txt | 13 +++++- drivers/media/platform/qcom/venus/core.c | 14 +++++-- drivers/media/platform/qcom/venus/firmware.c | 49 ++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 2 + 4 files changed, 73 insertions(+), 5 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/Documentation/devicetree/bindings/media/qcom,venus.txt b/Documentation/devicetree/bindings/media/qcom,venus.txt index 00d0d1b..7e04586 100644 --- a/Documentation/devicetree/bindings/media/qcom,venus.txt +++ b/Documentation/devicetree/bindings/media/qcom,venus.txt @@ -53,7 +53,7 @@ * Subnodes The Venus video-codec node must contain two subnodes representing -video-decoder and video-encoder. +video-decoder and video-encoder, and one optional firmware subnode. Every of video-encoder or video-decoder subnode should have: @@ -79,6 +79,13 @@ Every of video-encoder or video-decoder subnode should have: power domain which is responsible for collapsing and restoring power to the subcore. +The firmware subnode must have: + +- iommus: + Usage: required + Value type: + Definition: A list of phandle and IOMMU specifier pairs. + * An Example video-codec@1d00000 { compatible = "qcom,msm8916-venus"; @@ -105,4 +112,8 @@ Every of video-encoder or video-decoder subnode should have: clock-names = "core"; power-domains = <&mmcc VENUS_CORE1_GDSC>; }; + + video-firmware { + iommus = <&apps_iommu 0x10b2 0x0>; + }; }; diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 393994e..3bd3b8a 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -284,6 +284,14 @@ static int venus_probe(struct platform_device *pdev) if (ret < 0) goto err_runtime_disable; + ret = of_platform_populate(dev->of_node, NULL, NULL, dev); + if (ret) + goto err_runtime_disable; + + ret = venus_firmware_init(core); + if (ret) + goto err_runtime_disable; + ret = venus_boot(core); if (ret) goto err_runtime_disable; @@ -308,10 +316,6 @@ static int venus_probe(struct platform_device *pdev) if (ret) goto err_core_deinit; - ret = of_platform_populate(dev->of_node, NULL, NULL, dev); - if (ret) - goto err_dev_unregister; - ret = pm_runtime_put_sync(dev); if (ret) goto err_dev_unregister; @@ -347,6 +351,8 @@ static int venus_remove(struct platform_device *pdev) venus_shutdown(core); of_platform_depopulate(dev); + venus_firmware_deinit(core); + pm_runtime_put_sync(dev); pm_runtime_disable(dev); diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 79b3858..86a26fb 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -228,3 +229,51 @@ int venus_shutdown(struct venus_core *core) return ret; } + +int venus_firmware_init(struct venus_core *core) +{ + struct platform_device_info info; + struct platform_device *pdev; + struct device_node *np; + int ret; + + np = of_get_child_by_name(core->dev->of_node, "video-firmware"); + if (!np) + return 0; + + memset(&info, 0, sizeof(info)); + info.fwnode = &np->fwnode; + info.parent = core->dev; + info.name = np->name; + info.dma_mask = DMA_BIT_MASK(32); + + pdev = platform_device_register_full(&info); + if (IS_ERR(pdev)) { + of_node_put(np); + return PTR_ERR(pdev); + } + + pdev->dev.of_node = np; + + ret = of_dma_configure(&pdev->dev, np); + if (ret) + dev_err(core->dev, "dma configure fail\n"); + + of_node_put(np); + + if (ret) + return ret; + + core->no_tz = true; + core->fw.dev = &pdev->dev; + + return 0; +} + +void venus_firmware_deinit(struct venus_core *core) +{ + if (!core->fw.dev) + return; + + platform_device_unregister(to_platform_device(core->fw.dev)); +} diff --git a/drivers/media/platform/qcom/venus/firmware.h b/drivers/media/platform/qcom/venus/firmware.h index f41b615..119a9a4 100644 --- a/drivers/media/platform/qcom/venus/firmware.h +++ b/drivers/media/platform/qcom/venus/firmware.h @@ -16,6 +16,8 @@ struct device; +int venus_firmware_init(struct venus_core *core); +void venus_firmware_deinit(struct venus_core *core); int venus_boot(struct venus_core *core); int venus_shutdown(struct venus_core *core); int venus_set_hw_state(struct venus_core *core, bool suspend);