Skip to content

Commit 4e7c4d3

Browse files
Taniya Dasbebarino
authored andcommitted
clk: qcom: gdsc: Add support to update GDSC transition delay
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: 45dd0e5 ("clk: qcom: Add support for GDSCs) Signed-off-by: Taniya Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2f0754f commit 4e7c4d3

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

drivers/clk/qcom/gdsc.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
3+
* Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved.
44
*/
55

66
#include <linux/bitops.h>
@@ -35,9 +35,14 @@
3535
#define CFG_GDSCR_OFFSET 0x4
3636

3737
/* Wait 2^n CXO cycles between all states. Here, n=2 (4 cycles). */
38-
#define EN_REST_WAIT_VAL (0x2 << 20)
39-
#define EN_FEW_WAIT_VAL (0x8 << 16)
40-
#define CLK_DIS_WAIT_VAL (0x2 << 12)
38+
#define EN_REST_WAIT_VAL 0x2
39+
#define EN_FEW_WAIT_VAL 0x8
40+
#define CLK_DIS_WAIT_VAL 0x2
41+
42+
/* Transition delay shifts */
43+
#define EN_REST_WAIT_SHIFT 20
44+
#define EN_FEW_WAIT_SHIFT 16
45+
#define CLK_DIS_WAIT_SHIFT 12
4146

4247
#define RETAIN_MEM BIT(14)
4348
#define RETAIN_PERIPH BIT(13)
@@ -380,7 +385,18 @@ static int gdsc_init(struct gdsc *sc)
380385
*/
381386
mask = HW_CONTROL_MASK | SW_OVERRIDE_MASK |
382387
EN_REST_WAIT_MASK | EN_FEW_WAIT_MASK | CLK_DIS_WAIT_MASK;
383-
val = EN_REST_WAIT_VAL | EN_FEW_WAIT_VAL | CLK_DIS_WAIT_VAL;
388+
389+
if (!sc->en_rest_wait_val)
390+
sc->en_rest_wait_val = EN_REST_WAIT_VAL;
391+
if (!sc->en_few_wait_val)
392+
sc->en_few_wait_val = EN_FEW_WAIT_VAL;
393+
if (!sc->clk_dis_wait_val)
394+
sc->clk_dis_wait_val = CLK_DIS_WAIT_VAL;
395+
396+
val = sc->en_rest_wait_val << EN_REST_WAIT_SHIFT |
397+
sc->en_few_wait_val << EN_FEW_WAIT_SHIFT |
398+
sc->clk_dis_wait_val << CLK_DIS_WAIT_SHIFT;
399+
384400
ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val);
385401
if (ret)
386402
return ret;

drivers/clk/qcom/gdsc.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3-
* Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
3+
* Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved.
44
*/
55

66
#ifndef __QCOM_GDSC_H__
@@ -22,6 +22,9 @@ struct reset_controller_dev;
2222
* @cxcs: offsets of branch registers to toggle mem/periph bits in
2323
* @cxc_count: number of @cxcs
2424
* @pwrsts: Possible powerdomain power states
25+
* @en_rest_wait_val: transition delay value for receiving enr ack signal
26+
* @en_few_wait_val: transition delay value for receiving enf ack signal
27+
* @clk_dis_wait_val: transition delay value for halting clock
2528
* @resets: ids of resets associated with this gdsc
2629
* @reset_count: number of @resets
2730
* @rcdev: reset controller
@@ -36,6 +39,9 @@ struct gdsc {
3639
unsigned int clamp_io_ctrl;
3740
unsigned int *cxcs;
3841
unsigned int cxc_count;
42+
unsigned int en_rest_wait_val;
43+
unsigned int en_few_wait_val;
44+
unsigned int clk_dis_wait_val;
3945
const u8 pwrsts;
4046
/* Powerdomain allowable state bitfields */
4147
#define PWRSTS_OFF BIT(0)

0 commit comments

Comments
 (0)