Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp653495imm; Wed, 17 Oct 2018 06:20:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV62FEtGEvu+ae1gAABcG3XL+4FvjbJSPUaKNk5j2DEhbTkQ6urwk4I6IDXTE6IIrNgdSldP0 X-Received: by 2002:a17:902:7e0b:: with SMTP id b11-v6mr25604641plm.246.1539782403388; Wed, 17 Oct 2018 06:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539782403; cv=none; d=google.com; s=arc-20160816; b=OcQkviO60m34se889dS9LklSONxPXOEXG50PgdGigOt0e1vgx3ZJ4VPLpVSY19buh5 JIeBic/P4eatrmxz+IrrlF4Hmu5ZGLMUqTcTEzMsszAvCRujmoaF+xGh5mn/SWXN+okb KBwZiVD2aRaibr26QIE8/FkPVwB3//NuPCMWzcOra2Os13KSjL4o2XWOyGMT8juv/+Ae FrKlf0RWln42X20ksXu6LTFehqBCmCQy/kfqh8cKVoUGvPqVHhSh36F1RJW9KXzKco5O kXXaxwnjti7lbynkfVw9U0Psbn4pA7C8TrYExJ5AlXspEXdIHWjdDo/5kKSmOag3OgzJ gGuw== 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=rpP7LLzkZD9x6lxg+oUW+SVTcnBtszqzjnQ6qQBmmLg=; b=eh/ORfpDfYSJtsPP7lTo0yre5/jLXubpQoHhFvK4EH7VtaanqrmeYDyWXCmVi0Xc2e K4bAMcw03gxric6V32TFxiIP1Mvvm6Yfwq9ZZkpj3uZpC0toTUDcfbGZRVRxQsDagPvX 0WvE5WL0+hjuYaWnqMytQmn/95IzBDGVwWVpWse7HRD35Rvq+JpDf6KRo9OlLsH5XXT3 OlZnUHPbo3pxuZW3OLEnV+pMCo1g+F7UkZrYiYmA2NegFjAQjmsnMDMvsHLe/JxZ0yr7 HmsfH/iQSIvv/2LpJR33F7FdxZ3ONNsVdHuhH1mICrsKS/4FkbyjCDVg5lDcYZuZeBRr 0qbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=hUivYby6; dkim=pass header.i=@codeaurora.org header.s=default header.b=g2mccGeq; 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 v38-v6si17900900pgl.539.2018.10.17.06.19.47; Wed, 17 Oct 2018 06:20:03 -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=hUivYby6; dkim=pass header.i=@codeaurora.org header.s=default header.b=g2mccGeq; 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 S1727462AbeJQVOf (ORCPT + 99 others); Wed, 17 Oct 2018 17:14:35 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37616 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727053AbeJQVOe (ORCPT ); Wed, 17 Oct 2018 17:14:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EC69D601B4; Wed, 17 Oct 2018 13:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539782334; bh=3Pq4zqDqbzzf9vWbDCQURnU0CrbXKmtkHIeV0trTFlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUivYby64xXMtN2nIeV7XYbf83BNonoxrTXj9nOmhC89UplgX4CDYvu7gytsqY2Cu ZKOr6To8ZjWdDMZzmz3Uj0O7GT2w8tuDcLdn1Bcq+aKMaGHtY3wySyNhKmpsEIgWmv L6xQGnVxg5uosZrWpMFyleuTGADQNk7on2xlffas= 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 98F9761312; Wed, 17 Oct 2018 13:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539782331; bh=3Pq4zqDqbzzf9vWbDCQURnU0CrbXKmtkHIeV0trTFlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2mccGeqRU33Wwyfz/1oN73mEXl69JASIljJA76lMwjzGjOOrg6+9ONyRJvqVUvbV s5v9gDdwPm6LsdOEcu7W6coafvVkA35YDD7Imdzg9UsjRDUyyeY2YRJMI/v58KFi+S LjopUVVVV+P4hWc6Xc/Wa55WVKvrpElou2zmK2BI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 98F9761312 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 v12 3/5] venus: firmware: register separate platform_device for firmware loader Date: Wed, 17 Oct 2018 18:48:21 +0530 Message-Id: <1539782303-4091-4-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539782303-4091-1-git-send-email-vgarodia@codeaurora.org> References: <1539782303-4091-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 | 55 ++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 2 + 4 files changed, 70 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 8b85dc8..c629666 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -131,6 +131,9 @@ struct venus_core { struct device *dev_dec; struct device *dev_enc; unsigned int use_tz; + struct video_firmware { + struct device *dev; + } fw; struct mutex lock; struct list_head instances; atomic_t insts_count; 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); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project