From patchwork Wed Aug 22 12:34:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 144831 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp10467ljw; Wed, 22 Aug 2018 05:35:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyeza7O8iy4GV9Wf/Jbju7EaVE3hlghkgYLwY1i2F9n795aOdLjWmaTFZI7vyS/imo3HAoO X-Received: by 2002:a63:481:: with SMTP id 123-v6mr21301232pge.129.1534941305647; Wed, 22 Aug 2018 05:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534941305; cv=none; d=google.com; s=arc-20160816; b=BAd3WxNagMGs5o2QmsYnHIP4atrpUMNJAbV1JDdb/nJrb5AatnEJzqJROd4z1KKr0s unlj/mC1Nb0MV+EDr/3CxI8cAn4nmf/4ISdfQVKdXSbwW4/39bwQvCBKxshnLqS+kVqC uNfK5LrRqgwP+4vzF2CchJztqYJm4YSmYNRb8AoGAun4bl7hIEtcimTF4mEy/hWQ1ycL 96L165SsTyr7CCqsqBhMa+zNQr1aQhJJKaQGa99X6feN2WZh5OUBsu0D5ey7Mixid+B0 UdLoIMv+Qe7O8VdUMQxsHm5SUw82OWdwc4jA4TAUvI9MOdCevQ1nIyUbhon3eAd1qr8/ 7YEw== 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:dkim-signature:arc-authentication-results; bh=LwawqOo0pwh4kZq+Tvk8NLFsqY+IrSBq+oJntichXLw=; b=LFsMLXokF50L5lKRXj7FCkP2uR6yl6wwd0l8PN3uqXIhaqD9GD64jUp1NjmskEPXfN A+5nIxM7tVtoIEN/6mvPAryHnMwaEhoLoCXNGWX95iFVyJJ9LIA5y92IS7F9/0vUPBIg Hn11dmqWRg1Sf7OE74AAtfoKXGZ+dVStOmJpHAgXR3bmF4jhjBJqndHXPmoTBwNDRdyx DiS3aRyMazFfJ2/fxvldJ88IkWKUjwLC1iEHyCLwQDB0+hxL41c3V9kWmBHFnTnB39wz Hj0p2auY38sx+PMY0IFQMHz1B+jigwHkqQbCMzB/U8cNSEYqSsTZozyBi23mstIOhnwu eWKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cXPqWd1t; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h86-v6si1787559pfj.120.2018.08.22.05.35.05; Wed, 22 Aug 2018 05:35:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=cXPqWd1t; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbeHVP7t (ORCPT + 13 others); Wed, 22 Aug 2018 11:59:49 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46858 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728226AbeHVP7t (ORCPT ); Wed, 22 Aug 2018 11:59:49 -0400 Received: by mail-wr1-f68.google.com with SMTP id a108-v6so1453828wrc.13 for ; Wed, 22 Aug 2018 05:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LwawqOo0pwh4kZq+Tvk8NLFsqY+IrSBq+oJntichXLw=; b=cXPqWd1tadZq4hwdGRdC/YhAeVwlB9Zo8mAkCfAy4ECeyib4HPgG2gxLr9pS//2ENh RWKKKv476G2cJzll4f0aiwKdzJ6c2ukm/XwosgqBxgJcJYQ0Fy/vethfekJqsZcqqIim KmZlHDlnlZDukX27VjLuRbvkdpLCRYfLXGN7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LwawqOo0pwh4kZq+Tvk8NLFsqY+IrSBq+oJntichXLw=; b=FOttVZG6sOWut0ZcQjWsbPx+8aUhWmQYAblhCi4S/JRhIMM3mIHQ/rtQvRSPzeT7JB ifumdKH70rAi5OCgz9L/WkpnpaOF1aA5CqR6czt0MW3X3m0hSwZQh/53cp/CZXJyBZ58 uw9MLC7WNMNekzX/gwTXo2HnmcX1vMvYNZSmJF/vs0RiY/+XPofz33K0oUj9m4/BFucs v60uPeGhsKt2DDR1OyGLAubeF5wL+QQ8AdSihI5+xgDV5bEDvdac1aUjbHGpshV3GuZ/ F3aFGL0g/JH1+g5XHXmnTyyT3hWTyI5gZIreV5cEFI+GPDiJHuwiZdcGUN/7t/EKpmaA 3VOw== X-Gm-Message-State: APzg51ArxgR4dFHUvkNV48tqL/AuplmnN8b4D94LSviCTQEADDUQfTDB B1+YqCHUiTId59kMMCCmts/eHg== X-Received: by 2002:adf:facf:: with SMTP id a15-v6mr5975269wrs.74.1534941302169; Wed, 22 Aug 2018 05:35:02 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id l12-v6sm322217wrv.29.2018.08.22.05.35.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 05:35:01 -0700 (PDT) From: Stanimir Varbanov To: Vikash Garodia Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH 4/4] venus: firmware: register separate platform_device for firmware loader Date: Wed, 22 Aug 2018 15:34:42 +0300 Message-Id: <20180822123442.10810-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <1534871974-32269-5-git-send-email-vgarodia@codeaurora.org> References: <1534871974-32269-5-git-send-email-vgarodia@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- .../devicetree/bindings/media/qcom,venus.txt | 13 +++++- drivers/media/platform/qcom/venus/core.c | 14 +++++-- drivers/media/platform/qcom/venus/firmware.c | 49 ++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 2 + 4 files changed, 73 insertions(+), 5 deletions(-) -- 2.14.1 diff --git a/Documentation/devicetree/bindings/media/qcom,venus.txt b/Documentation/devicetree/bindings/media/qcom,venus.txt index 00d0d1bf7647..7e045862c3fe 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, and one optional firmware subnode. Every of video-encoder or video-decoder subnode should have: @@ -79,6 +79,13 @@ 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 subnode must have: + +- iommus: + Usage: required + Value type: + Definition: A list of phandle and IOMMU specifier pairs. + * An Example video-codec@1d00000 { compatible = "qcom,msm8916-venus"; @@ -105,4 +112,8 @@ Every of video-encoder or video-decoder subnode should have: clock-names = "core"; power-domains = <&mmcc VENUS_CORE1_GDSC>; }; + + video-firmware { + iommus = <&apps_iommu 0x10b2 0x0>; + }; }; diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 393994ecab26..3bd3b8ab1f82 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(core); 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/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 80c3d1362c04..2a9fcbb71216 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -228,3 +229,51 @@ int venus_shutdown(struct venus_core *core) return ret; } + +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"); + + of_node_put(np); + + if (ret) + return ret; + + core->no_tz = true; + core->fw.dev = &pdev->dev; + + return 0; +} + +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 f41b615b96f1..119a9a4fc1a2 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 venus_core *core); int venus_set_hw_state(struct venus_core *core, bool suspend);