From patchwork Mon Oct 8 13:32:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikash Garodia X-Patchwork-Id: 148371 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3657942lji; Mon, 8 Oct 2018 06:33:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV632k/jC/w1A3r41XlsX7D18xo3s9ayY52x1x+DfXz2DTX8gdITVZc8QxxNYFbOfAqTh31LQ X-Received: by 2002:a62:cc4:: with SMTP id 65-v6mr25298682pfm.127.1539005610853; Mon, 08 Oct 2018 06:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539005610; cv=none; d=google.com; s=arc-20160816; b=BMGPVLT4iTQQ1Svp6X9uDPLQnQdNQ5oE9qAXLe7sMeE5bNIA2CNyGgIB7SCHa1jr6n XGAyeOKd5E09EQD/eQDvp94SPrtK1ydzwu/qczoENPljHJIi0c9dRjn3GluiIgB4TRAq nB82tA2tvIyhePTwJKrZQ76pQO234vgPfWv8QsyvS3jPVLJ/olk/yIU3pH1+FwGK3ONg N5YgGWfQtT/DTX9WM2ftBWwMY5F6AS1FtpbivC9CmVVJ0nlmqiTWti2vee/QtoaeoyJo r+g+qeQqxcD1QXs9nCrUi69FsRPESb67E4oD/QNz/wsGdIhL3S4+PjWUYSW56sPSUCOA LLwQ== 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; bh=zAfzqO5L0OrJM4v5DGTYTp3dYYis60WFDEOMh+GnTa4=; b=wei5Rqm353ElJ/2hPoMn5D72/sjHIdK41FA3Re3SUc6nJWB1DZlr7F/rE8SSzB036J EyG2ZPu6aAEWPboUrYVDKfARbfPy8xCg02+Q8z1ZFDIXufuTp433ulSBxZmN8q2lAE1G iGqC65gV0H/GfjSbWKvee/vWYb4iACEeyHzFmPfK5kX+y0v4pVElMDrYAtCEa0Zd4kso 3CVHWP5femp70KyT8sFy9qhlvCUM/8YFxzvQAsjBDRRK/+J3Yfjw20e80MI56/ykd+1+ n65VKRby029KEZ3WmR4Rwzr3QXQebn5m2g6UBqnnbs00r+2aJcFwpzgM04aT6HGMaxyd ffxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=K3Fu49Du; dkim=pass header.i=@codeaurora.org header.s=default header.b=TTdfr3yz; 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 j7-v6si18281461pfk.203.2018.10.08.06.33.30; Mon, 08 Oct 2018 06:33:30 -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=K3Fu49Du; dkim=pass header.i=@codeaurora.org header.s=default header.b=TTdfr3yz; 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 S1726723AbeJHUpO (ORCPT + 4 others); Mon, 8 Oct 2018 16:45:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47776 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbeJHUpN (ORCPT ); Mon, 8 Oct 2018 16:45:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 73AB360C80; Mon, 8 Oct 2018 13:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539005606; bh=iv2EK+ZgRhvNeG6DvU2ZFUJoAIM4wftqxW+To1VUSEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K3Fu49DuTHmQz4bQHZKVvhUwhGWRhYGt4bd7g9vkdCFDn0VrPhw0ra3yFWksokFFU 5wqvLoRNrUos8S/a2CqBdo2zCRjJyuOTmb2n7amzCOGuAEIEwn9uyhWNlbAcaxo+sZ iVkmds7hSA1SCH+aDNiahkO1WSnFuliRzJ27HMOE= 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.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID, DKIM_SIGNED 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 B2C6460C80; Mon, 8 Oct 2018 13:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539005604; bh=iv2EK+ZgRhvNeG6DvU2ZFUJoAIM4wftqxW+To1VUSEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TTdfr3yzHhTlUVJKeDBR5Oo5I2evSkuyDTnWM0fmKWKGvR4alx07dYLKB58RGXYIY HVHhK/LCKP3RaPLor/N5IEUxn/wighKYzAYoh0f1juSAQ3Rb3qzHiHXqF1+kbLJMlI vKA8TLiSr5TyNz86BuZJmBfK+k4WamKBIzp54C/4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B2C6460C80 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 Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, acourbot@chromium.org, vgarodia@codeaurora.org Subject: [PATCH v11 3/5] venus: firmware: register separate platform_device for firmware loader Date: Mon, 8 Oct 2018 19:02:50 +0530 Message-Id: <1539005572-803-4-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539005572-803-1-git-send-email-vgarodia@codeaurora.org> References: <1539005572-803-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 --- drivers/media/platform/qcom/venus/core.c | 14 +++++-- drivers/media/platform/qcom/venus/core.h | 3 ++ drivers/media/platform/qcom/venus/firmware.c | 55 ++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 2 + 4 files changed, 70 insertions(+), 4 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 75b9785..440f25f 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(dev); 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/core.h b/drivers/media/platform/qcom/venus/core.h index 385e309..094c2ec 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -130,6 +130,9 @@ struct venus_core { struct device *dev; struct device *dev_dec; struct device *dev_enc; + struct video_firmware { + struct device *dev; + } fw; bool use_tz; struct mutex lock; struct list_head instances; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 1d4f066..98b3b16 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -144,3 +146,56 @@ int venus_shutdown(struct device *dev) { return qcom_scm_pas_shutdown(VENUS_PAS_ID); } + +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) { + core->use_tz = true; + 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, true); + if (ret) { + dev_err(core->dev, "dma configure fail\n"); + goto err_unregister; + } + + core->fw.dev = &pdev->dev; + + of_node_put(np); + + return 0; + +err_unregister: + platform_device_unregister(pdev); + of_node_put(np); + return ret; +} + +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 1343747..fd7edf0 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 device *dev); int venus_set_hw_state(struct venus_core *core, bool suspend);