Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp68224imm; Tue, 18 Sep 2018 16:46:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYiPWwwRFd16NJYjdEfbI4i1BzHoENIqd/h0TdKXXBMdweZzjp/cbo2GaCHOPXHzBZdoAgD X-Received: by 2002:a63:d401:: with SMTP id a1-v6mr29662852pgh.414.1537314392646; Tue, 18 Sep 2018 16:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537314392; cv=none; d=google.com; s=arc-20160816; b=tkXYJUl91vgkG/twjO4TdaWky3qvjiTgAT0uKcVXMNu2gg9tbpl+G2741MqK1X41mP SPWKf33veqA2f7AQgE4lyHaPKr1z4bF51jWaky3emsxFHGXk91czIcTP0zZ7DSqiFQYB s/kK+Eh5LHcDCubZdmVLNMNePh+bJEM/8WVP/nuqEHNF6j/UBRpnDyjv1JNHQ5Qqmtka eG7CQZUcF0mSFwzzGJh8xdfd4OMILAZhBz4oJHySWDvBTcS+axtmOP6PZ5SQhDzoaKIj 23tzwhvioRq7/vTcZ66hdMoEjcbbaXPZa2kOXmN6dWeHVBPm6HuggUCfc9LWXeb1L24t JOjw== 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=y9kWNgBl8xSauVZTimiYGESAyzg5ZHgXlFWY/nVBE5M=; b=T9K15eULJfPMWhNEQdNpNk2Uwl9zmfAs/pe+QwN3wajEH8DWl1UOELEnIyby5HckUj KR6a4jjqsO9Jnh2oZcCN7xSNHuQVzpTczzfU72T+1v5FXRFozJrBszpto50rUorMwjX6 Q31FGQVVd3GSDi7a0GTiS6L7b42mkAZwEZuWP7Mwu//ZQGLIZ7vJWG0tZ8Lx0B/Lzn+4 936MHVM8fbI5eK1gbicOZSQ9SnM2wryiE2Ww6Q8BoUY4365GHCNsuN3nuLC+CbJyQizO W7Ikt5AS8Zt+RzfHVRAbFrlR+nAKE+P+g+t2cU3RmssrGtKpFl8DIEQQdz3T3lyg2RvN V8zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=kmLB5DMW; dkim=pass header.i=@codeaurora.org header.s=default header.b=FsHAYYOD; 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 x20-v6si20876064pff.333.2018.09.18.16.46.17; Tue, 18 Sep 2018 16:46:32 -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=kmLB5DMW; dkim=pass header.i=@codeaurora.org header.s=default header.b=FsHAYYOD; 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 S1730732AbeISFTK (ORCPT + 99 others); Wed, 19 Sep 2018 01:19:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42470 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbeISFTJ (ORCPT ); Wed, 19 Sep 2018 01:19:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AEA08607F7; Tue, 18 Sep 2018 23:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537314250; bh=pSZpMzMr5I7pi0On9KSG+KPUGroICyUez7YN8E3HBuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kmLB5DMWit8dneyUIoWp46vt9GNWvxq7JnxBrFiBmcmtnmJL93pZK67gStstSTHEU JqbMHM4UqvsLDvZ7PIadViXcSC2hhMuOc8ZMGYKMD4OOqWnNlUS/TXNiEWejvXKUvy lb3jFe8EBj6l+DWTyglKMiJzOs7A9LQLF8MO34zs= 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 BA5BF60C4E; Tue, 18 Sep 2018 23:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537314227; bh=pSZpMzMr5I7pi0On9KSG+KPUGroICyUez7YN8E3HBuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsHAYYOD47kqpVM9cpu+SSAl4m/6vJUTjkp65hXhruYH4ZwGticEOgJUT0zQlnwNA LtmRq3km/coUxKrHLNcq9IkejNyZg/SSdvi6auYsKVImXFArCdfkaO5RGiUTh67kA7 5++dq/uzIwWVjd1DXsFVV8WV5tguZ8hNtXeAQo7Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BA5BF60C4E 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 v9 3/5] venus: firmware: register separate platform_device for firmware loader Date: Wed, 19 Sep 2018 05:13:10 +0530 Message-Id: <1537314192-26892-4-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537314192-26892-1-git-send-email-vgarodia@codeaurora.org> References: <1537314192-26892-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..6f2c82d 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 16faba6..f4d2b4b 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, true); + 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