Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1003988imm; Fri, 1 Jun 2018 13:28:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOzXCbXiLjohq8zUq44NWXsUHDR4+fJHSTvR3r5ESmxuwQQPuXhF9hXkYtc/wZkmpsdrOY X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr12483157pld.127.1527884905484; Fri, 01 Jun 2018 13:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527884905; cv=none; d=google.com; s=arc-20160816; b=w0mun7t48cnvYSpE2UAqSBKBG2MiypJEWPmxwi9TfZ1MZD/wbe64ZPHj4UwUbpcy5c AgK11OQXO7lWV/vujyklGpeTCUgSkCWUT1DCwYLyn1Yj80BGNsA9c0/gdEMYOh0rMtnA eaWbjk+Vydq4MUu5Zi+OJttqG26lpMNqAAAmIxJUX2X58aeZUUUhyGVCxc6REkGpPyai 7F9aN6jsJo0ZWYFgA90R0ZANzqiItDr/qtWdIemVZog1UgmHA0DT43cc22KC4ZmfVOU0 eiD3XDhaxYMw2IXsxcHzuowGQV2GFXY6pzIKxhUy9W87T92f7Ci9fs85y5a+kHH+zIHX sAHQ== 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=yWjLB8HfGufHaRbHvW3L9PbjgKkwEDUqmBCahoBOxvk=; b=zwu6tFt/2oRLOQ4oaxPhyfksZ7vRgpCCrV3tuz1NIAPQTuje4SiD6NhwHNjeuGE+IT S8YINP4/a5VpUGQuIkyGbQSh6RoZ2haER7yk0Zi4vYVepHAs+2wJitE4SQAqSTGk6EyG UCNoy42UBrpJlmYGqcw5Epa8+cAxZp2bqdVenTmAh0DNRbYLx2KiwfaiCUI8w2cJLAYm TGo1NZWW29yZr5koZpo6Wn4FG6GxdQWQKooldG0E+yBpdF19X9Pi2CnK54N84Bqegqjy XMtDu+1l7B2pn/OXvgI71lSHSKiOrmRtemZaNaocXLHXDl8O2IYACE3RaVCze54ZOICK f1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=P6j0pHcF; dkim=pass header.i=@codeaurora.org header.s=default header.b=D22nUGns; 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 k1-v6si31220848pgt.325.2018.06.01.13.28.11; Fri, 01 Jun 2018 13:28:25 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=P6j0pHcF; dkim=pass header.i=@codeaurora.org header.s=default header.b=D22nUGns; 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 S1753733AbeFAU12 (ORCPT + 99 others); Fri, 1 Jun 2018 16:27:28 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54886 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753658AbeFAU1K (ORCPT ); Fri, 1 Jun 2018 16:27:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1E9C260708; Fri, 1 Jun 2018 20:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527884830; bh=SiH6jCPIlPiRwSgeHB44AZ6a3GJvpWlOsJa2gvLv6pU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P6j0pHcFWEiIMVLcWhUZDferNGIUR9e/Pm+AhGPmaea42nA5v2sC9vNvC4MZyq1xO R1VxWNY/3sJhZik3xZPLYpM9vf5UGlP+V4hg+hPRwITyJR6TgcaYzB5I6W7geY9gTQ 0Wn87Yq+K5Q4yQsgEbQyILqenW2cieqldVKFk3ps= 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 4DB85607E7; Fri, 1 Jun 2018 20:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527884829; bh=SiH6jCPIlPiRwSgeHB44AZ6a3GJvpWlOsJa2gvLv6pU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D22nUGnsN3VZLW9zkIDyQKwKE/0SncIYrg4EsFG/dDGZGplDgKAz0+X+7NcPtFZcP MmgBl9TKFPOxLDI2m9lCgQhvj+ByHlqOOfwgao09Lr/vK5nak981BCjWaTk7s9slCX 4tIOMyYSZhkMGtvd220F1FglVRBI59QbsYOvhEVA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4DB85607E7 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: hverkuil@xs4all.nl, mchehab@kernel.org, robh@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, bjorn.andersson@linaro.org, stanimir.varbanov@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, vgarodia@codeaurora.org, acourbot@chromium.org Subject: [PATCH v2 5/5] venus: register separate driver for firmware device Date: Sat, 2 Jun 2018 01:56:08 +0530 Message-Id: <1527884768-22392-6-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> References: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A separate child device is added for video firmware. This is needed to [1] configure the firmware context bank with the desired SID. [2] ensure that the iova for firmware region is from 0x0. Signed-off-by: Vikash Garodia --- .../devicetree/bindings/media/qcom,venus.txt | 8 +++- drivers/media/platform/qcom/venus/core.c | 48 +++++++++++++++++++--- drivers/media/platform/qcom/venus/firmware.c | 20 ++++++++- drivers/media/platform/qcom/venus/firmware.h | 2 + 4 files changed, 71 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/media/qcom,venus.txt b/Documentation/devicetree/bindings/media/qcom,venus.txt index 00d0d1b..701cbe8 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, one optional firmware subnode. Every of video-encoder or video-decoder subnode should have: @@ -79,6 +79,8 @@ 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 sub node must contain the iommus specifiers for ARM9. + * An Example video-codec@1d00000 { compatible = "qcom,msm8916-venus"; @@ -105,4 +107,8 @@ Every of video-encoder or video-decoder subnode should have: clock-names = "core"; power-domains = <&mmcc VENUS_CORE1_GDSC>; }; + venus-firmware { + compatible = "qcom,venus-firmware-no-tz"; + iommus = <&apps_smmu 0x10b2 0x0>; + } }; diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 101612b..5cfb3c2 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -179,6 +179,19 @@ static u32 to_v4l2_codec_type(u32 codec) } } +static int store_firmware_dev(struct device *dev, void *data) +{ + struct venus_core *core = data; + + if (!core) + return -EINVAL; + + if (of_device_is_compatible(dev->of_node, "qcom,venus-firmware-no-tz")) + core->fw.dev = dev; + + return 0; +} + static int venus_enumerate_codecs(struct venus_core *core, u32 type) { const struct hfi_inst_ops dummy_ops = {}; @@ -279,6 +292,13 @@ 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; + + /* Attempt to store firmware device */ + device_for_each_child(dev, core, store_firmware_dev); + ret = venus_boot(core); if (ret) goto err_runtime_disable; @@ -303,10 +323,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; @@ -483,7 +499,29 @@ static __maybe_unused int venus_runtime_resume(struct device *dev) .pm = &venus_pm_ops, }, }; -module_platform_driver(qcom_venus_driver); + +static int __init venus_init(void) +{ + int ret; + + ret = platform_driver_register(&qcom_video_firmware_driver); + if (ret) + return ret; + + ret = platform_driver_register(&qcom_venus_driver); + if (ret) + platform_driver_unregister(&qcom_video_firmware_driver); + + return ret; +} +module_init(venus_init); + +static void __exit venus_exit(void) +{ + platform_driver_unregister(&qcom_venus_driver); + platform_driver_unregister(&qcom_video_firmware_driver); +} +module_exit(venus_exit); MODULE_ALIAS("platform:qcom-venus"); MODULE_DESCRIPTION("Qualcomm Venus video encoder and decoder driver"); diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 058d544..ed29d10 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -12,6 +12,7 @@ * */ +#include #include #include #include @@ -124,7 +125,7 @@ static int venus_load_fw(struct device *dev, const char *fwname, } if (qcom_scm_is_available()) ret = qcom_mdt_load(dev, mdt, fwname, VENUS_PAS_ID, mem_va, - *mem_phys, *mem_size); + *mem_phys, *mem_size, NULL); else ret = qcom_mdt_load_no_init(dev, mdt, fwname, VENUS_PAS_ID, mem_va, *mem_phys, *mem_size, NULL); @@ -243,3 +244,20 @@ int venus_shutdown(struct venus_core *core) return ret; } + +static const struct of_device_id firmware_dt_match[] = { + { .compatible = "qcom,venus-firmware-no-tz" }, + { } +}; +MODULE_DEVICE_TABLE(of, firmware_dt_match); + +struct platform_driver qcom_video_firmware_driver = { + .driver = { + .name = "qcom-video-firmware", + .of_match_table = firmware_dt_match, + }, +}; + +MODULE_ALIAS("platform:qcom-video-firmware"); +MODULE_DESCRIPTION("Qualcomm Venus firmware driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/qcom/venus/firmware.h b/drivers/media/platform/qcom/venus/firmware.h index 67fdd89..23c0409 100644 --- a/drivers/media/platform/qcom/venus/firmware.h +++ b/drivers/media/platform/qcom/venus/firmware.h @@ -21,6 +21,8 @@ struct device; +extern struct platform_driver qcom_video_firmware_driver; + int venus_boot(struct venus_core *core); int venus_shutdown(struct venus_core *core); int venus_set_hw_state(enum tzbsp_video_state, struct venus_core *core); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project