From patchwork Tue Nov 8 17:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dwivedi, Avaneesh Kumar (avani)" X-Patchwork-Id: 9417865 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B995B60512 for ; Tue, 8 Nov 2016 17:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD67928A4C for ; Tue, 8 Nov 2016 17:58:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A06F028A53; Tue, 8 Nov 2016 17:58:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D43C289EC for ; Tue, 8 Nov 2016 17:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbcKHR6Q (ORCPT ); Tue, 8 Nov 2016 12:58:16 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:55396 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbcKHR6P (ORCPT ); Tue, 8 Nov 2016 12:58:15 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C3C94624C7; Tue, 8 Nov 2016 17:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1478627894; bh=lm6hf4r+ezIM+OSoC3GylN2tISqsFRw3MzcUevjxDrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejHm8ycRcDUvBX2EsaFSbusXY7WXZ4kti2pnD2wOcyujeXnN8vOdvPoBo9JRxXZ6q jfr/zrl3/LoA+8g+WGH5BcSg8MipuQXbYm+NalC6CspFIAaLl5HJ4CISoUvETI1GBN 3hrNnMAidVH0L+OL9LrSPFvq+Qn8OFJjSj1hgXq4= Received: from akdwived-linux.qualcomm.com (unknown [202.46.23.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akdwived@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 15EEE62379; Tue, 8 Nov 2016 17:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1478627894; bh=lm6hf4r+ezIM+OSoC3GylN2tISqsFRw3MzcUevjxDrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejHm8ycRcDUvBX2EsaFSbusXY7WXZ4kti2pnD2wOcyujeXnN8vOdvPoBo9JRxXZ6q jfr/zrl3/LoA+8g+WGH5BcSg8MipuQXbYm+NalC6CspFIAaLl5HJ4CISoUvETI1GBN 3hrNnMAidVH0L+OL9LrSPFvq+Qn8OFJjSj1hgXq4= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 15EEE62379 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=akdwived@codeaurora.org From: Avaneesh Kumar Dwivedi To: bjorn.andersson@linaro.org Cc: linux-arm-msm@vger.kernel.org, Avaneesh Kumar Dwivedi Subject: [PATCH 2/2] remoteproc: qcom: Add clock init and enable support if needed. Date: Tue, 8 Nov 2016 23:28:01 +0530 Message-Id: <1478627881-20073-3-git-send-email-akdwived@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478627881-20073-1-git-send-email-akdwived@codeaurora.org> References: <1478627881-20073-1-git-send-email-akdwived@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To bring venus firmware module standalone on msm8996, it need certain multimedia clocks to be enabled. Adding support for initialization and enable disable of such clocks. Signed-off-by: Avaneesh Kumar Dwivedi --- drivers/remoteproc/qcom_venus_pil.c | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/remoteproc/qcom_venus_pil.c b/drivers/remoteproc/qcom_venus_pil.c index 5b4ea10..1a41a23 100644 --- a/drivers/remoteproc/qcom_venus_pil.c +++ b/drivers/remoteproc/qcom_venus_pil.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -86,11 +87,47 @@ static int venus_load(struct rproc *rproc, const struct firmware *fw) .load = venus_load, }; +static int qcom_venus_clk_enable(struct qcom_venus *venus) +{ + int i, ret; + + if (!venus->venus_clks) + return 0; + + for (i = 0; i < venus->venus_rproc_res->venus_clk_cnt; i++) { + ret = clk_prepare_enable(venus->venus_clks[i]); + if (ret) { + for (; i > 0; i--) { + clk_disable_unprepare(venus->venus_clks[i]); + return ret; + } + } + } + return 0; +} + +static void qcom_venus_clk_disable(struct qcom_venus *venus) +{ + int i; + + if (!venus->venus_clks) + return; + + for (i = venus->venus_rproc_res->venus_clk_cnt-1; i >= 0; i--) + clk_disable_unprepare(venus->venus_clks[i]); +} + static int venus_start(struct rproc *rproc) { struct qcom_venus *venus = rproc->priv; int ret; + ret = qcom_venus_clk_enable(venus); + if (ret) { + dev_err(venus->dev, "failed to enable venus_clk\n"); + return ret; + } + ret = qcom_scm_pas_auth_and_reset(VENUS_PAS_ID); if (ret) dev_err(venus->dev, @@ -109,6 +146,8 @@ static int venus_stop(struct rproc *rproc) if (ret) dev_err(venus->dev, "failed to shutdown: %d\n", ret); + qcom_venus_clk_disable(venus); + return ret; } @@ -131,6 +170,34 @@ static void *venus_da_to_va(struct rproc *rproc, u64 da, int len) .da_to_va = venus_da_to_va, }; +static int qcom_venus_init_clocks(struct qcom_venus *venus) +{ + struct clk **clk_arr; + int i; + + if (venus->venus_rproc_res->venus_clk_cnt) { + clk_arr = devm_kzalloc(venus->dev, + sizeof(clk_arr) * venus->venus_rproc_res->venus_clk_cnt, + GFP_KERNEL); + + for (i = 0; i < venus->venus_rproc_res->venus_clk_cnt; i++) { + clk_arr[i] = devm_clk_get(venus->dev, + venus->venus_rproc_res->venus_clks[i]); + + if (IS_ERR(clk_arr[i])) { + dev_err(venus->dev, "failed to get %s clock\n", + venus->venus_rproc_res->venus_clks[i]); + return PTR_ERR(clk_arr[i]); + } + clk_set_rate(clk_arr[i], clk_round_rate(clk_arr[i], + venus->venus_rproc_res->venus_clk_rate[i])); + } + venus->venus_clks = clk_arr; + } + venus->venus_clks = NULL; + return 0; +} + static int venus_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -172,6 +239,11 @@ static int venus_probe(struct platform_device *pdev) platform_set_drvdata(pdev, venus); venus->venus_rproc_res = desc; + + ret = qcom_venus_init_clocks(venus); + if (ret) + goto free_rproc; + venus->mem_va = dma_alloc_coherent(dev, venus->mem_size, &venus->mem_phys, GFP_KERNEL); if (!venus->mem_va) {