Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3042258pxp; Mon, 14 Mar 2022 09:39:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKwU7QgjIs8UepN261tTWRm2eszra29tXF/wglwauzZL6UmScmACddQ9VhkrcitauKHlfn X-Received: by 2002:a17:902:f68b:b0:151:d869:3b16 with SMTP id l11-20020a170902f68b00b00151d8693b16mr24450838plg.85.1647275971778; Mon, 14 Mar 2022 09:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647275971; cv=none; d=google.com; s=arc-20160816; b=Q5MbYKKewZ+frgzQOswNnB2AcmeIaOu+8y2z6dIdXtCPGg++TQYnNd7Pfzw4V5WfQG 5IIk0HE83jKJVNEiWFk66ZXQIElFvBpu2JoBlKV0Z6ecduQ6RvJfYJVINh2oNCq8+UX7 sL3JrV0yDduI0/waGrTjQ6MuQtDTJ2DzjZieXdm54dCfi94vk8Au6Dzv4dVCr/cMJRBW eR7M7FT3WCtJ8B9FiPnrdQq/wwrSEPTYtzbgs6McPggsrN1OJc/0yues9ghIKP3rpFyw GI1/+Qp8nPddfZnVfik8Fli8igYA+l3zW1j+miKRBcYe1PMFGO6GpKxjtL8W7iwQw04L /bGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wXdQt4G6GEahsSN2DwyuUEUDuhugrlsBpypEB8vqgXI=; b=obHpIOJmbYzCazpPGATrQNDBR+E2vhKR7tkD1pvwm6TQnM/pXX4wpEsLiiakUF/nWk PR9SKAP6rVBDbXo+6gx/tFWj8cFs1KB9H1YQvZYNuEX+0TfCIVWbnHS484C7AsyyHNIs 0IgzT5n6eSqQk8vxgKtC6ue5zrUXGqP/SiEjdXmIqyu3AlghmtCaP9I7nI4BoipqUAwu I3jHtanxSr4f7ztl0g/mN7FtBYZC7aGS8EMBfrP2yGjitxDc01AA45nOb9IVQgalRHzV UqdqWeTXgtD+RTFO/ul1qjga+MLoAtp/TlplDPmWX86sYPwRCI7rmSm8M6DKq5gvcWhq 6rag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dnc4R9gh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g123-20020a636b81000000b003811d3261a8si7499626pgc.620.2022.03.14.09.39.17; Mon, 14 Mar 2022 09:39:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dnc4R9gh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231578AbiCNMYv (ORCPT + 99 others); Mon, 14 Mar 2022 08:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241795AbiCNMSY (ORCPT ); Mon, 14 Mar 2022 08:18:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63753140F9; Mon, 14 Mar 2022 05:13:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C2BA1B80D24; Mon, 14 Mar 2022 12:13:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6D77C340E9; Mon, 14 Mar 2022 12:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259981; bh=sIs2vLv0LU4RwOYr14ccSSzcXKm3+p+9K3S56bkx5WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dnc4R9ghb1rCTrSHaM/b9eSi+MCK1wrLPCdFiwwYrKxh1cix0zKJ82fxN0OexUe5s V+sHGWfvecwEyiuEMZgJaSS4dQIcBtFo0zOuif1C2s9k9GF/Skr6+yxmbM46qZpPeM eZjgEJYOFRJPrzbJu9VB461JB8Ptlm8elqEsEi5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taniya Das , Bjorn Andersson , Stephen Boyd , Sasha Levin Subject: [PATCH 5.16 006/121] clk: qcom: gdsc: Add support to update GDSC transition delay Date: Mon, 14 Mar 2022 12:53:09 +0100 Message-Id: <20220314112744.302790306@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Taniya Das [ Upstream commit 4e7c4d3652f96f41179aab3ff53025c7a550d689 ] GDSCs have multiple transition delays which are used for the GDSC FSM states. Older targets/designs required these values to be updated from gdsc code to certain default values for the FSM state to work as expected. But on the newer targets/designs the values updated from the GDSC driver can hamper the FSM state to not work as expected. On SC7180 we observe black screens because the gdsc is being enabled/disabled very rapidly and the GDSC FSM state does not work as expected. This is due to the fact that the GDSC reset value is being updated from SW. Thus add support to update the transition delay from the clock controller gdscs as required. Fixes: 45dd0e55317cc ("clk: qcom: Add support for GDSCs) Signed-off-by: Taniya Das Link: https://lore.kernel.org/r/20220223185606.3941-1-tdas@codeaurora.org Reviewed-by: Bjorn Andersson Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/qcom/gdsc.c | 26 +++++++++++++++++++++----- drivers/clk/qcom/gdsc.h | 8 +++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 7e1dd8ccfa38..44520efc6c72 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved. */ #include @@ -35,9 +35,14 @@ #define CFG_GDSCR_OFFSET 0x4 /* Wait 2^n CXO cycles between all states. Here, n=2 (4 cycles). */ -#define EN_REST_WAIT_VAL (0x2 << 20) -#define EN_FEW_WAIT_VAL (0x8 << 16) -#define CLK_DIS_WAIT_VAL (0x2 << 12) +#define EN_REST_WAIT_VAL 0x2 +#define EN_FEW_WAIT_VAL 0x8 +#define CLK_DIS_WAIT_VAL 0x2 + +/* Transition delay shifts */ +#define EN_REST_WAIT_SHIFT 20 +#define EN_FEW_WAIT_SHIFT 16 +#define CLK_DIS_WAIT_SHIFT 12 #define RETAIN_MEM BIT(14) #define RETAIN_PERIPH BIT(13) @@ -380,7 +385,18 @@ static int gdsc_init(struct gdsc *sc) */ mask = HW_CONTROL_MASK | SW_OVERRIDE_MASK | EN_REST_WAIT_MASK | EN_FEW_WAIT_MASK | CLK_DIS_WAIT_MASK; - val = EN_REST_WAIT_VAL | EN_FEW_WAIT_VAL | CLK_DIS_WAIT_VAL; + + if (!sc->en_rest_wait_val) + sc->en_rest_wait_val = EN_REST_WAIT_VAL; + if (!sc->en_few_wait_val) + sc->en_few_wait_val = EN_FEW_WAIT_VAL; + if (!sc->clk_dis_wait_val) + sc->clk_dis_wait_val = CLK_DIS_WAIT_VAL; + + val = sc->en_rest_wait_val << EN_REST_WAIT_SHIFT | + sc->en_few_wait_val << EN_FEW_WAIT_SHIFT | + sc->clk_dis_wait_val << CLK_DIS_WAIT_SHIFT; + ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val); if (ret) return ret; diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index d7cc4c21a9d4..ad313d7210bd 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved. */ #ifndef __QCOM_GDSC_H__ @@ -22,6 +22,9 @@ struct reset_controller_dev; * @cxcs: offsets of branch registers to toggle mem/periph bits in * @cxc_count: number of @cxcs * @pwrsts: Possible powerdomain power states + * @en_rest_wait_val: transition delay value for receiving enr ack signal + * @en_few_wait_val: transition delay value for receiving enf ack signal + * @clk_dis_wait_val: transition delay value for halting clock * @resets: ids of resets associated with this gdsc * @reset_count: number of @resets * @rcdev: reset controller @@ -36,6 +39,9 @@ struct gdsc { unsigned int clamp_io_ctrl; unsigned int *cxcs; unsigned int cxc_count; + unsigned int en_rest_wait_val; + unsigned int en_few_wait_val; + unsigned int clk_dis_wait_val; const u8 pwrsts; /* Powerdomain allowable state bitfields */ #define PWRSTS_OFF BIT(0) -- 2.34.1