From patchwork Wed May 23 05:20:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10420191 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 52DA56016C for ; Wed, 23 May 2018 05:21:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40D62290A2 for ; Wed, 23 May 2018 05:21:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34B77290A5; Wed, 23 May 2018 05:21:41 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 91FAD290A2 for ; Wed, 23 May 2018 05:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754060AbeEWFVk (ORCPT ); Wed, 23 May 2018 01:21:40 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:47031 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754084AbeEWFVD (ORCPT ); Wed, 23 May 2018 01:21:03 -0400 Received: by mail-pg0-f65.google.com with SMTP id a3-v6so3933742pgt.13 for ; Tue, 22 May 2018 22:21: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=4hmV56D5pM+iajC2qqe4z96PIgpcRdLUZl2I093zQwY=; b=OrLAlC48m98fy05hztdT72VscJ46VeLqWsK6H90YSc8stK0rROqgg0UpRtM2EMn9bd pjuklKY4mmHoT+j1QAgnNnK4g19153uNI0Hk/3cr0zOcH2Ml8upps5fqQVR8OSqxsNOz j0o7+LSTARUAkJSvNG+E4ahlVQJr8Du/jcPOA= 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=4hmV56D5pM+iajC2qqe4z96PIgpcRdLUZl2I093zQwY=; b=G3q3KAmmILUp5ek7iMZJEiy9DT6ZoeRP0Vei+KzbKbAZQoaR+s3k/RUDzVdizAYAOr S6gCKL4kGbgc6rNMedsvR7vWzLWmSKOEjrf+/yFUSV4RiwpVP8vgI69Vrd8VOPvu80/V 1lBt45772Nx7zMN9N4MznfWZMPI7ufORQ74vYRbYOt1is30X0AmSo3D0qoyDn4qS9E0T m6i8De/Jxijs11l/+GoknpnnD8GV2FI4ayBCyIIkBe1B+QNiBTH3btK3S/YgXnYcc3iR LH9VFTVRnsFG/kQWqtVwI2W80g3tLDqHpAkr1Gl1s2P3ZpkhaOzLqMFpxTYFfUbnAYVf X+aQ== X-Gm-Message-State: ALKqPwcyPk4SLY4GgymyOtyvFf0uEe7NhnmMC+Yd87W8AYaO57W+IfnW AD7TRgD+RSBu6Geu8kPK5otTlA== X-Google-Smtp-Source: AB8JxZreyr8zZz3Y7U6ysdeSkVyj8loYK7BBWrLaM/KRJVSy6PHJiKt7RQBYlMpwkjG2dmcsVTGbpA== X-Received: by 2002:a62:f20d:: with SMTP id m13-v6mr1425166pfh.170.1527052862044; Tue, 22 May 2018 22:21:02 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r76-v6sm34401146pfl.1.2018.05.22.22.21.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 22:21:01 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH 3/5] remoteproc: qcom: adsp: Use common q6v5 helpers Date: Tue, 22 May 2018 22:20:52 -0700 Message-Id: <20180523052054.19025-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523052054.19025-1-bjorn.andersson@linaro.org> References: <20180523052054.19025-1-bjorn.andersson@linaro.org> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Migrate the Hexagon V5 PAS (ADSP) driver to using the newly extracted helper functions. The use of the handover callback does introduce latent disabling of proxy resources. But apart from this there should be no change in functionality. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/Kconfig | 1 + drivers/remoteproc/qcom_adsp_pil.c | 156 +++++------------------------ 2 files changed, 28 insertions(+), 129 deletions(-) diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 63b79ea91a21..d51d155cf8bd 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -93,6 +93,7 @@ config QCOM_ADSP_PIL depends on QCOM_SYSMON || QCOM_SYSMON=n select MFD_SYSCON select QCOM_MDT_LOADER + select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM help diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 89a86ce07f99..d4339a6da616 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -31,6 +31,7 @@ #include #include "qcom_common.h" +#include "qcom_q6v5.h" #include "remoteproc_internal.h" struct adsp_data { @@ -48,14 +49,7 @@ struct qcom_adsp { struct device *dev; struct rproc *rproc; - int wdog_irq; - int fatal_irq; - int ready_irq; - int handover_irq; - int stop_ack_irq; - - struct qcom_smem_state *state; - unsigned stop_bit; + struct qcom_q6v5 q6v5; struct clk *xo; struct clk *aggre2_clk; @@ -96,6 +90,8 @@ static int adsp_start(struct rproc *rproc) struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; int ret; + qcom_q6v5_prepare(&adsp->q6v5); + ret = clk_prepare_enable(adsp->xo); if (ret) return ret; @@ -119,16 +115,14 @@ static int adsp_start(struct rproc *rproc) goto disable_px_supply; } - ret = wait_for_completion_timeout(&adsp->start_done, - msecs_to_jiffies(5000)); - if (!ret) { + ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000)); + if (ret == -ETIMEDOUT) { dev_err(adsp->dev, "start timed out\n"); qcom_scm_pas_shutdown(adsp->pas_id); - ret = -ETIMEDOUT; goto disable_px_supply; } - ret = 0; + return 0; disable_px_supply: regulator_disable(adsp->px_supply); @@ -142,28 +136,34 @@ static int adsp_start(struct rproc *rproc) return ret; } +static void qcom_pas_handover(struct qcom_q6v5 *q6v5) +{ + struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); + + regulator_disable(adsp->px_supply); + regulator_disable(adsp->cx_supply); + clk_disable_unprepare(adsp->aggre2_clk); + clk_disable_unprepare(adsp->xo); +} + static int adsp_stop(struct rproc *rproc) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; + int handover; int ret; - qcom_smem_state_update_bits(adsp->state, - BIT(adsp->stop_bit), - BIT(adsp->stop_bit)); - - ret = wait_for_completion_timeout(&adsp->stop_done, - msecs_to_jiffies(5000)); - if (ret == 0) + ret = qcom_q6v5_request_stop(&adsp->q6v5); + if (ret == -ETIMEDOUT) dev_err(adsp->dev, "timed out on wait\n"); - qcom_smem_state_update_bits(adsp->state, - BIT(adsp->stop_bit), - 0); - ret = qcom_scm_pas_shutdown(adsp->pas_id); if (ret) dev_err(adsp->dev, "failed to shutdown: %d\n", ret); + handover = qcom_q6v5_unprepare(&adsp->q6v5); + if (handover) + qcom_pas_handover(&adsp->q6v5); + return ret; } @@ -187,53 +187,6 @@ static const struct rproc_ops adsp_ops = { .load = adsp_load, }; -static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - rproc_report_crash(adsp->rproc, RPROC_WATCHDOG); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_fatal_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - size_t len; - char *msg; - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, adsp->crash_reason_smem, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(adsp->dev, "fatal error received: %s\n", msg); - - rproc_report_crash(adsp->rproc, RPROC_FATAL_ERROR); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_ready_interrupt(int irq, void *dev) -{ - return IRQ_HANDLED; -} - -static irqreturn_t adsp_handover_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - complete(&adsp->start_done); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - complete(&adsp->stop_done); - - return IRQ_HANDLED; -} - static int adsp_init_clock(struct qcom_adsp *adsp) { int ret; @@ -272,29 +225,6 @@ static int adsp_init_regulator(struct qcom_adsp *adsp) return PTR_ERR_OR_ZERO(adsp->px_supply); } -static int adsp_request_irq(struct qcom_adsp *adsp, - struct platform_device *pdev, - const char *name, - irq_handler_t thread_fn) -{ - int ret; - - ret = platform_get_irq_byname(pdev, name); - if (ret < 0) { - dev_err(&pdev->dev, "no %s IRQ defined\n", name); - return ret; - } - - ret = devm_request_threaded_irq(&pdev->dev, ret, - NULL, thread_fn, - IRQF_ONESHOT, - "adsp", adsp); - if (ret) - dev_err(&pdev->dev, "request %s IRQ failed\n", name); - - return ret; -} - static int adsp_alloc_memory_region(struct qcom_adsp *adsp) { struct device_node *node; @@ -348,13 +278,9 @@ static int adsp_probe(struct platform_device *pdev) adsp->dev = &pdev->dev; adsp->rproc = rproc; adsp->pas_id = desc->pas_id; - adsp->crash_reason_smem = desc->crash_reason_smem; adsp->has_aggre2_clk = desc->has_aggre2_clk; platform_set_drvdata(pdev, adsp); - init_completion(&adsp->start_done); - init_completion(&adsp->stop_done); - ret = adsp_alloc_memory_region(adsp); if (ret) goto free_rproc; @@ -367,37 +293,10 @@ static int adsp_probe(struct platform_device *pdev) if (ret) goto free_rproc; - ret = adsp_request_irq(adsp, pdev, "wdog", adsp_wdog_interrupt); - if (ret < 0) - goto free_rproc; - adsp->wdog_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "fatal", adsp_fatal_interrupt); - if (ret < 0) - goto free_rproc; - adsp->fatal_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "ready", adsp_ready_interrupt); - if (ret < 0) - goto free_rproc; - adsp->ready_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "handover", adsp_handover_interrupt); - if (ret < 0) - goto free_rproc; - adsp->handover_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "stop-ack", adsp_stop_ack_interrupt); - if (ret < 0) - goto free_rproc; - adsp->stop_ack_irq = ret; - - adsp->state = qcom_smem_state_get(&pdev->dev, "stop", - &adsp->stop_bit); - if (IS_ERR(adsp->state)) { - ret = PTR_ERR(adsp->state); + ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, + qcom_pas_handover); + if (ret) goto free_rproc; - } qcom_add_glink_subdev(rproc, &adsp->glink_subdev); qcom_add_smd_subdev(rproc, &adsp->smd_subdev); @@ -422,7 +321,6 @@ static int adsp_remove(struct platform_device *pdev) { struct qcom_adsp *adsp = platform_get_drvdata(pdev); - qcom_smem_state_put(adsp->state); rproc_del(adsp->rproc); qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev);