Received: by 10.223.185.116 with SMTP id b49csp2393041wrg; Mon, 5 Mar 2018 01:59:47 -0800 (PST) X-Google-Smtp-Source: AG47ELssx4q99519Npy0yfA2k6xglfwtpSIpJ7qJjYbza4ZUO+dczi4lB7+3OHA2AYkQKxd+QVwT X-Received: by 10.99.120.197 with SMTP id t188mr11814407pgc.358.1520243986976; Mon, 05 Mar 2018 01:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520243986; cv=none; d=google.com; s=arc-20160816; b=ZyiKS4F/0XUFm5nONUuO2bUDqpIM0HyUq4H6tx5kge1ICViwb3W0v8by+IllZSJ1Hj Jh7S4TM3RbhDO1tU9XWeKc+U0iwlUbbupxH31AHv5vovqeISotNe/u6m+mm4AksKCewn Qa2+2JAEPzjQtG6xJ0ue8Fc0Oscsp2/IyvyPwD0bzYgirIhDgBiQgOW3TLdOKyCdH1+B ECrObYrj87lCUK4ApplVUv2w49sg1An/kbI0qBeJ0cGMBVzhFOLZ+CkXhvEmmmgKMq+b lkbPpzn2H5UPB+odLMjiw2BTAn1e76zynDPQthl1P8XBZNhM6ee7Y6mUAIGqKjV4FhR+ 3XRw== 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 :arc-authentication-results; bh=8kWYeI1Yc9Ug8wADV0m0jKA7A/Y7SV83MieyFBSmo/s=; b=xgodsWNVfHSl1Lq/e0nIXu+1AvJA/F0VwItCW+gyo2eaBNDJwsMnIvfJIKRYj1M6K8 qqaIAVhCXdyctl0Dl01LQs1vKwdQcFavZv0Ao8X9PKcHZBnDcOSF8BBvFBi6JAj103UG jNDw0pOgnYwxrwl1BMoR7n723euyEOWf2vcNwEHQlgQPpFdBE88Y7V0U282TJFs97q0L lsj8V+OycxAqpPlVsszGvO8Onk7JN08g6MwJUcULAAYgd6PAD7JK+l2Fa46EIQn50tB4 aFr2EHLAkhFE0XieUlGzlNADe56ReExO8BarKqoPmV7LWsoyok0y8vghUfUZPjZXW1j3 PaLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GXxxl6I3; dkim=pass header.i=@codeaurora.org header.s=default header.b=l200Ocsv; 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 t25si8162075pge.26.2018.03.05.01.59.32; Mon, 05 Mar 2018 01:59:46 -0800 (PST) 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=GXxxl6I3; dkim=pass header.i=@codeaurora.org header.s=default header.b=l200Ocsv; 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 S933943AbeCEJyi (ORCPT + 99 others); Mon, 5 Mar 2018 04:54:38 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:48192 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933903AbeCEJya (ORCPT ); Mon, 5 Mar 2018 04:54:30 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 79FF06076C; Mon, 5 Mar 2018 09:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520243669; bh=cccnCpZGoI8MycBLTZRt2X+t6/eFcMiml1BcNyYMx9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXxxl6I3OrYExv/gS4+2qVretBMEy502/dtQB6s2OrSL7/jU1YmT3rYo0YDi7FLdT a2IttPSjchVg25msJG5DEpoC7863UWzRb6M0O1jIshMz0whYgMXG2UV+tM5yEL4sLK 6eJgK/2TFXl1BwGwoZtJde+AeRFtCMHVNusTctbA= 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 blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id ACB3D607F5; Mon, 5 Mar 2018 09:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520243668; bh=cccnCpZGoI8MycBLTZRt2X+t6/eFcMiml1BcNyYMx9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l200Ocsvnodj8f4/BtrH492xgxfoVw2K1paQvwQHAeCCMrwuVs77EgDnM1cypTxlv K1aBEcLihq7c5zR7ZSbA/EkyAK8sVUk4333SEOytruGnCspuLGwwdq/bYyXzDJmelR QMeWJOA6jk10X07xzY41ekujg90UHif6LcvTVoek= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org ACB3D607F5 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=sibis@codeaurora.org From: sibis To: bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, sibis@codeaurora.org, georgi.djakov@linaro.org, jassisinghbrar@gmail.com, p.zabel@pengutronix.de, ohad@wizery.com, mark.rutland@arm.com, robh+dt@kernel.org, kyan@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 6/6] remoteproc: qcom: Always assert and deassert reset signals in SDM845 Date: Mon, 5 Mar 2018 15:23:33 +0530 Message-Id: <1520243613-30393-7-git-send-email-sibis@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520243613-30393-1-git-send-email-sibis@codeaurora.org> References: <1520243613-30393-1-git-send-email-sibis@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SDM845 brings a new reset signal ALT_RESET which is a part of the MSS subsystem hence requires some of the active clks to be enabled before assert/deassert Reset the modem if the BOOT FSM does timeout Reset assert/deassert sequence vary across SoCs adding reset, adding start/stop helper functions to handle SoC specific reset sequences Signed-off-by: sibis --- drivers/remoteproc/qcom_q6v5_pil.c | 100 ++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 92bf125..bd8c397 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -130,11 +130,14 @@ struct rproc_hexagon_res { struct qcom_mss_reg_res *proxy_supply; struct qcom_mss_reg_res *active_supply; char **proxy_clk_names; + char **reset_clk_names; char **active_clk_names; int version; bool need_mem_protection; }; +struct q6v5_reset_ops; + struct q6v5 { struct device *dev; struct rproc *rproc; @@ -153,8 +156,10 @@ struct q6v5 { unsigned stop_bit; struct clk *active_clks[8]; + struct clk *reset_clks[4]; struct clk *proxy_clks[4]; int active_clk_count; + int reset_clk_count; int proxy_clk_count; struct reg_info active_regs[1]; @@ -175,6 +180,7 @@ struct q6v5 { void *mpss_region; size_t mpss_size; + const struct q6v5_reset_ops *ops; struct qcom_rproc_glink glink_subdev; struct qcom_rproc_subdev smd_subdev; struct qcom_rproc_ssr ssr_subdev; @@ -184,6 +190,11 @@ struct q6v5 { int version; }; +struct q6v5_reset_ops { + int (*reset_start)(struct q6v5 *qproc); + int (*reset_stop)(struct q6v5 *qproc); +}; + enum { MSS_MSM8916, MSS_MSM8974, @@ -343,6 +354,52 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw) return 0; } +static void alt_reset_restart(struct q6v5 *qproc, u32 restart) +{ + writel(restart, qproc->rmb_base + RMB_MBA_ALT_RESET); +} + +static int q6v5_msm_reset_stop(struct q6v5 *qproc) +{ + return reset_control_assert(qproc->mss_restart); +} + +static int q6v5_msm_reset_start(struct q6v5 *qproc) +{ + return reset_control_deassert(qproc->mss_restart); +} + +static int q6v5_sdm_reset_stop(struct q6v5 *qproc) +{ + return reset_control_reset(qproc->mss_restart); +} + +static int q6v5_sdm_reset_start(struct q6v5 *qproc) +{ + int ret; + + alt_reset_restart(qproc, 1); + /* Ensure alt reset is written before restart reg */ + udelay(100); + + ret = reset_control_reset(qproc->mss_restart); + + udelay(100); + alt_reset_restart(qproc, 0); + + return ret; +} + +static const struct q6v5_reset_ops q6v5_msm_ops = { + .reset_stop = q6v5_msm_reset_stop, + .reset_start = q6v5_msm_reset_start, +}; + +static const struct q6v5_reset_ops q6v5_sdm_ops = { + .reset_stop = q6v5_sdm_reset_stop, + .reset_start = q6v5_sdm_reset_start, +}; + static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms) { unsigned long timeout; @@ -418,6 +475,8 @@ static int q6v5proc_reset(struct q6v5 *qproc) val, (val & BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT); if (ret) { dev_err(qproc->dev, "Boot FSM failed to complete.\n"); + /* Reset the modem so that boot FSM is in reset state */ + qproc->ops->reset_start(qproc); return ret; } @@ -785,10 +844,18 @@ static int q6v5_start(struct rproc *rproc) dev_err(qproc->dev, "failed to enable supplies\n"); goto disable_proxy_clk; } - ret = reset_control_deassert(qproc->mss_restart); + + ret = q6v5_clk_enable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); + if (ret) { + dev_err(qproc->dev, "failed to enable reset clocks\n"); + goto disable_vdd; + } + + ret = qproc->ops->reset_start(qproc); if (ret) { dev_err(qproc->dev, "failed to deassert mss restart\n"); - goto disable_vdd; + goto disable_reset_clks; } ret = q6v5_clk_enable(qproc->dev, qproc->active_clks, @@ -880,7 +947,10 @@ static int q6v5_start(struct rproc *rproc) qproc->active_clk_count); assert_reset: - reset_control_assert(qproc->mss_restart); + qproc->ops->reset_stop(qproc); +disable_reset_clks: + q6v5_clk_disable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); disable_vdd: q6v5_regulator_disable(qproc, qproc->active_regs, qproc->active_reg_count); @@ -930,9 +1000,11 @@ static int q6v5_stop(struct rproc *rproc) qproc->mpss_phys, qproc->mpss_size); WARN_ON(ret); - reset_control_assert(qproc->mss_restart); + qproc->ops->reset_stop(qproc); q6v5_clk_disable(qproc->dev, qproc->active_clks, qproc->active_clk_count); + q6v5_clk_disable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); q6v5_regulator_disable(qproc, qproc->active_regs, qproc->active_reg_count); @@ -1179,6 +1251,12 @@ static int q6v5_probe(struct platform_device *pdev) qproc->dev = &pdev->dev; qproc->rproc = rproc; platform_set_drvdata(pdev, qproc); + qproc->version = desc->version; + + if (qproc->version == MSS_SDM845) + qproc->ops = &q6v5_sdm_ops; + else + qproc->ops = &q6v5_msm_ops; init_completion(&qproc->start_done); init_completion(&qproc->stop_done); @@ -1199,6 +1277,14 @@ static int q6v5_probe(struct platform_device *pdev) } qproc->proxy_clk_count = ret; + ret = q6v5_init_clocks(&pdev->dev, qproc->reset_clks, + desc->reset_clk_names); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to get reset clocks.\n"); + goto free_rproc; + } + qproc->reset_clk_count = ret; + ret = q6v5_init_clocks(&pdev->dev, qproc->active_clks, desc->active_clk_names); if (ret < 0) { @@ -1227,7 +1313,6 @@ static int q6v5_probe(struct platform_device *pdev) if (ret) goto free_rproc; - qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; ret = q6v5_request_irq(qproc, pdev, "wdog", q6v5_wdog_interrupt); if (ret < 0) @@ -1290,8 +1375,11 @@ static int q6v5_remove(struct platform_device *pdev) "prng", NULL }, - .active_clk_names = (char*[]){ + .reset_clk_names = (char*[]){ "iface", + NULL + }, + .active_clk_names = (char*[]){ "bus", "mem", "gpll0_mss", -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project