Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp789760imm; Fri, 14 Sep 2018 06:26:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZDy/rqYxfPMI3oW2VDFMe09F3NA9igbByawZEt+qG6LnBi3La/n/NOgrTAt29nK6N0+ECR X-Received: by 2002:a17:902:468:: with SMTP id 95-v6mr11946478ple.122.1536931571462; Fri, 14 Sep 2018 06:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536931571; cv=none; d=google.com; s=arc-20160816; b=kczwW8aHJOE3z8dOcSYbEdyFpHXYSXn/Ec5cvOBZ1/rk14zjduI03sgg3Umawg8gDq vkR7Wt2UwakjmyJnGpwAXGD9oc2kAI63hzW+laUIpqGee66Uq8+jVzfykLrTiRi5ofVq ceVQNy9Ic25mNQtY9omLVJus7cy72eNRQyKibuP1V8nTmR1gNbyJqPToC4u+J5YyqIf/ CPXRilhz3LovnY/3O2ElMI9X7eJ4LW3A8AWNq0btXulIa04OQJ+lZHRY/7icgLtHQMYC 0DrcEJ4bvIlic+IHDDXyuHEUGyauG8NxdFJmua/Q7hNiMmbyUQMvz4vhPedhnt3NENz7 O4Xg== 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=qEAcFxqmVjTrc/jAui8DFCLGxZG6hkQfnlk4Qur7U9E=; b=xjB6K8BtzYYJUyFwRLsaBq71cUkV5Pb22PPhhKd7lK+3XsRCaDP7IVR6TP02TII6cV nOzObVuWGGdlBRY2IM8lE/dRiIkG/QEhsBs2VYfmMoOC5o5sh528O41tnxayUduePVCj IovOch/ikBRlaP1uRFFvFdeySebjf21Ex38ZQbudV5rONaHkicmnM2Wr0LvDt852MPVa gTY6L/vs4Pr/zJjJoRa0VhddrA0SoNqqUkTVuPyB4W8yvDDA+P7q2CAfLIFjjWPX1m8+ x1PASvS5ggynFFyzBwrp8bEgujmCR1hWsYrQgdIfQ5LzN1vnu8/V9pA5gvn1zd2HtaUC x2JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="W+ghn/z7"; dkim=pass header.i=@codeaurora.org header.s=default header.b=E8q+0EVa; 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 92-v6si7548813plw.81.2018.09.14.06.25.51; Fri, 14 Sep 2018 06:26:11 -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="W+ghn/z7"; dkim=pass header.i=@codeaurora.org header.s=default header.b=E8q+0EVa; 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 S1728236AbeINSkB (ORCPT + 99 others); Fri, 14 Sep 2018 14:40:01 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53430 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbeINSkB (ORCPT ); Fri, 14 Sep 2018 14:40:01 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6255F60AD9; Fri, 14 Sep 2018 13:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536931530; bh=yS0VqTGygTH3Ig3ghlx1uiDAQFnE3+TfFstB5a80wKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+ghn/z7HmJMzg4b2bl5ToAbxMk4n9IEQtDKuuR8n1awUr5hYLyIm6fRirE15QIM7 6Ih6ZOHkS1nmyNuYprxhx5OXgo2Wer4drNtxk7lYiwmLpVYtTIkWrK/WREhNz3XcuK ClaOGiGot4dpXP8hqh9mhTgSx+Ca8IfTpHp2+W4o= 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 D2FC260807; Fri, 14 Sep 2018 13:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536931526; bh=yS0VqTGygTH3Ig3ghlx1uiDAQFnE3+TfFstB5a80wKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8q+0EVa/0C+wjXCfbG6MYTG4xCDiPosPfK0mKeoDDPftuejCt3HCDyKHuhfTooQ1 lX8eptKT0bBCTKnqJ+HB5xq9N8yqFy2WoDibYzalzyU52VCfmwMs0h05HTyGndBocy QoKacimHDaEaD7zaxiz+8e8IlbcRNuI4uEa24FoA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D2FC260807 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 v7 3/5] venus: firmware: register separate platform_device for firmware loader Date: Fri, 14 Sep 2018 18:54:35 +0530 Message-Id: <1536931477-13018-4-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1536931477-13018-1-git-send-email-vgarodia@codeaurora.org> References: <1536931477-13018-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 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 | 54 ++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 2 ++ 4 files changed, 69 insertions(+), 4 deletions(-) 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 dfd5c10..3a53d5d 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 no_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 34224eb..69a99cd 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,55 @@ 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) + 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"); + goto err_unregister; + } + + core->fw.dev = &pdev->dev; + core->no_tz = true; + + 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); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project