Received: by 10.192.165.148 with SMTP id m20csp190060imm; Tue, 1 May 2018 21:05:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwJd4l4QsR2+h0JDSYvtV78UpFKmyXCVxaLaDLHLEAGk2Tv5VQjOiK227IvbnWCAC5/IO5 X-Received: by 10.98.130.140 with SMTP id w134mr10156690pfd.138.1525233910865; Tue, 01 May 2018 21:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525233910; cv=none; d=google.com; s=arc-20160816; b=Pie0ehi53kDNyrlqswJ5BagZm5kqoIuTMnqKXVJ4aedKdfr7jmQ71ienYMB6sE7Jg1 G9tqgwfS2PWPfzAdWyLorNbZ4V2q4GzyyUhW1UeTah7B8zQcM9ya8OtXSqRTzYTkXGqk q8frIw4NmtmDZYIIY4kffbOF2tVzH/4FStKfg3wD/Urf6P4BGbsVxbRO2oEDEueb93Be 28QcegQepXhujd5ThN7kLlBZYlF9Bc/34Op9flHl4m/K8HMS06e7yUxiY6vsUB6CXWJq dE8d6xF2g0qwyoIbvtltf50IACg7sv+h5utNZV0yqtY5mhu2+83QdxcY+f10eQ7Km87t CcrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=9hKQ9w19nUh9NPLZmrWaQMn6UJKc54KvFwoDAiPbdDU=; b=CWXLQdgIr0TIELWsh76XleLtd+bQNoyKta9mlqIUQFzFjM2y//xMcO0rJ5YHXqYXhA yQhNW7V48BMQCl0r/ZVG2tdn7Fc7IwIumvEdS3QsBng8LQSDWt/gpwsXckQo83dVn1Hw wOqOAHGrWKsoYHn99ShW6az220WE9rtIbM9jVPIbmVARSD9HHoq6cFQL7VSItTjALAxc LMxx4tWm/JZqJHlqIDk8dllaDKlGZEfgXBLFi27YDHgGwXLkLcX5+EmMaKBHQgWfwW+e ykCWxUmFUKFNFOybYqWbX8NOo0mRXAFYsQ399Xu1xQepKnTsn4uvj5E2XtGNW8xl1Ah6 eynA== ARC-Authentication-Results: i=1; mx.google.com; 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 b7-v6si11275580pla.345.2018.05.01.21.04.56; Tue, 01 May 2018 21:05:10 -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; 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 S1750918AbeEBEDk (ORCPT + 99 others); Wed, 2 May 2018 00:03:40 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:31821 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750836AbeEBEDj (ORCPT ); Wed, 2 May 2018 00:03:39 -0400 X-UUID: 1a5377590c8b4d779a8a206bbb826be4-20180502 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 491282687; Wed, 02 May 2018 12:03:32 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 2 May 2018 12:03:30 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 2 May 2018 12:03:30 +0800 From: To: , , CC: , , , , , Sean Wang , Weiyi Lu Subject: [PATCH v3] soc: mediatek: add a fixed wait for SRAM stable Date: Wed, 2 May 2018 12:03:29 +0800 Message-ID: <90f83c1bd359bb39cdae334e489037d6fb8ac69b.1525233544.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang MT7622_POWER_DOMAIN_WB doesn't send an ACK when its managed SRAM becomes stable, which is not like the behavior the other power domains should have. Therefore, it's necessary for such a power domain to have a fixed and well-predefined duration to wait until its managed SRAM can be allowed to access by all functions running on the top. v1 -> v2: - use MTK_SCPD_FWAIT_SRAM flag as an indication requiring force waiting. v2 -> v3: - change the order for condition judgment with we check an existence of the MTK_SCPD_FWAIT_SRAM first to get rid of any oversight on negative condition. Signed-off-by: Sean Wang Cc: Matthias Brugger Cc: Ulf Hansson Cc: Weiyi Lu --- drivers/soc/mediatek/mtk-scpsys.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index b1b45e4..2080c8f 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -32,6 +32,7 @@ #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ)) #define MTK_SCPD_ACTIVE_WAKEUP BIT(0) +#define MTK_SCPD_FWAIT_SRAM BIT(1) #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x)) #define SPM_VDE_PWR_CON 0x0210 @@ -237,11 +238,21 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) val &= ~scpd->data->sram_pdn_bits; writel(val, ctl_addr); - /* wait until SRAM_PDN_ACK all 0 */ - ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0, - MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); - if (ret < 0) - goto err_pwr_ack; + /* Either wait until SRAM_PDN_ACK all 0 or have a force wait */ + if (MTK_SCPD_CAPS(scpd, MTK_SCPD_FWAIT_SRAM)) { + /* + * Currently, MTK_SCPD_FWAIT_SRAM is necessary only for + * MT7622_POWER_DOMAIN_WB and thus just a trivial setup is + * applied here. + */ + usleep_range(12000, 12100); + + } else { + ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0, + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); + if (ret < 0) + goto err_pwr_ack; + }; if (scpd->data->bus_prot_mask) { ret = mtk_infracfg_clear_bus_protection(scp->infracfg, @@ -785,7 +796,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = { .sram_pdn_ack_bits = 0, .clk_id = {CLK_NONE}, .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_WB, - .caps = MTK_SCPD_ACTIVE_WAKEUP, + .caps = MTK_SCPD_ACTIVE_WAKEUP | MTK_SCPD_FWAIT_SRAM, }, }; -- 2.7.4