blob: 5f53feb893f9c144f6f6faadc06412a4e72d940a [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 55dd46f8caed3d8baa6819d884a1e82c496083f5 Mon Sep 17 00:00:00 2001
developera46f6132024-03-26 14:09:54 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Thu, 14 Mar 2024 17:55:12 +0800
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH 14/21] wifi: mt76: mt7915: update power on sequence
developera46f6132024-03-26 14:09:54 +08005
6Update power on sequence to prevent unexpected behavior.
7
8Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
9---
10 mt7915/mt7915.h | 1 +
11 mt7915/regs.h | 2 ++
12 mt7915/soc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
13 3 files changed, 48 insertions(+), 2 deletions(-)
14
15diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer05f3b2b2024-08-19 19:17:34 +080016index 89156f35..74cd8caf 100644
developera46f6132024-03-26 14:09:54 +080017--- a/mt7915/mt7915.h
18+++ b/mt7915/mt7915.h
19@@ -329,6 +329,7 @@ struct mt7915_dev {
20
21 bool wmm_pbc_enable;
22 struct work_struct wmm_pbc_work;
23+ u32 adie_type;
24 };
25
26 enum {
27diff --git a/mt7915/regs.h b/mt7915/regs.h
developer05f3b2b2024-08-19 19:17:34 +080028index 7515b23f..3452a7e9 100644
developera46f6132024-03-26 14:09:54 +080029--- a/mt7915/regs.h
30+++ b/mt7915/regs.h
31@@ -775,6 +775,7 @@ enum offs_rev {
32 #define MT_TOP_RGU_SYSRAM_PDN (MT_TOP_RGU_BASE + 0x050)
33 #define MT_TOP_RGU_SYSRAM_SLP (MT_TOP_RGU_BASE + 0x054)
34 #define MT_TOP_WFSYS_PWR (MT_TOP_RGU_BASE + 0x010)
35+#define MT_TOP_BGFYS_PWR (MT_TOP_RGU_BASE + 0x020)
36 #define MT_TOP_PWR_EN_MASK BIT(7)
37 #define MT_TOP_PWR_ACK_MASK BIT(6)
38 #define MT_TOP_PWR_KEY_MASK GENMASK(31, 16)
39@@ -886,6 +887,7 @@ enum offs_rev {
40 #define MT_ADIE_SLP_CTRL(_band, ofs) (MT_ADIE_SLP_CTRL_BASE(_band) + (ofs))
41
42 #define MT_ADIE_SLP_CTRL_CK0(_band) MT_ADIE_SLP_CTRL(_band, 0x120)
43+#define MT_ADIE_SLP_CTRL_CK1(_band) MT_ADIE_SLP_CTRL(_band, 0x124)
44
45 /* ADIE */
46 #define MT_ADIE_CHIP_ID 0x02c
47diff --git a/mt7915/soc.c b/mt7915/soc.c
developer05f3b2b2024-08-19 19:17:34 +080048index 92d8d710..bb3468a9 100644
developera46f6132024-03-26 14:09:54 +080049--- a/mt7915/soc.c
50+++ b/mt7915/soc.c
developerdc9eeae2024-04-08 14:36:46 +080051@@ -260,6 +260,7 @@ static int mt7986_wmac_consys_lockup(struct mt7915_dev *dev, bool enable)
developera46f6132024-03-26 14:09:54 +080052 MT_INFRACFG_TX_EN_MASK,
53 FIELD_PREP(MT_INFRACFG_TX_EN_MASK, enable));
54
55+ usleep_range(1000, 2000);
56 return 0;
57 }
58
developerdc9eeae2024-04-08 14:36:46 +080059@@ -844,6 +845,10 @@ static void mt7986_wmac_subsys_setting(struct mt7915_dev *dev)
developera46f6132024-03-26 14:09:54 +080060 MT_CONN_INFRA_OSC_STB_TIME_MASK, 0x80706);
61
62 /* prevent subsys from power on/of in a short time interval */
63+ mt76_rmw(dev, MT_TOP_BGFYS_PWR,
64+ MT_TOP_PWR_ACK_MASK | MT_TOP_PWR_KEY_MASK,
65+ (0x42540000));
66+
67 mt76_rmw(dev, MT_TOP_WFSYS_PWR,
68 MT_TOP_PWR_ACK_MASK | MT_TOP_PWR_KEY_MASK,
69 MT_TOP_PWR_KEY);
developerdc9eeae2024-04-08 14:36:46 +080070@@ -914,7 +919,7 @@ static void mt7986_wmac_clock_enable(struct mt7915_dev *dev, u32 adie_type)
developera46f6132024-03-26 14:09:54 +080071
72 read_poll_timeout(mt76_rr, cur, !(cur & MT_SLP_CTRL_BSY_MASK),
73 USEC_PER_MSEC, 50 * USEC_PER_MSEC, false,
74- dev, MT_ADIE_SLP_CTRL_CK0(0));
75+ dev, MT_ADIE_SLP_CTRL_CK0(1));
76 }
77 mt76_wmac_spi_unlock(dev);
78
developerdc9eeae2024-04-08 14:36:46 +080079@@ -1154,12 +1159,14 @@ int mt7986_wmac_enable(struct mt7915_dev *dev)
developera46f6132024-03-26 14:09:54 +080080 if (ret)
81 return ret;
82
83+ dev->adie_type = adie_type;
84+
85 return mt7986_wmac_sku_update(dev, adie_type);
86 }
87
88 void mt7986_wmac_disable(struct mt7915_dev *dev)
89 {
90- u32 cur;
91+ u32 cur, i;
92
93 mt7986_wmac_top_wfsys_wakeup(dev, true);
94
developerdc9eeae2024-04-08 14:36:46 +080095@@ -1178,6 +1185,20 @@ void mt7986_wmac_disable(struct mt7915_dev *dev)
developera46f6132024-03-26 14:09:54 +080096 mt76_rmw_field(dev, MT_AFE_DIG_EN_02(0), MT_AFE_MCU_BPLL_CFG_MASK, 0x2);
97 mt76_rmw_field(dev, MT_AFE_DIG_EN_02(0), MT_AFE_WPLL_CFG_MASK, 0x2);
98
99+ /* Disable adie top clock */
100+ mt76_wmac_spi_lock(dev);
101+ for (i = 0; i < 2; i++) {
102+ if (is_7975(dev, i, dev->adie_type) || is_7976(dev, i, dev->adie_type)) {
103+ mt76_rmw_field(dev, MT_ADIE_SLP_CTRL_CK1(i),
104+ MT_SLP_CTRL_EN_MASK, 0x0);
105+
106+ read_poll_timeout(mt76_rr, cur, !(cur & MT_SLP_CTRL_BSY_MASK),
107+ USEC_PER_MSEC, 50 * USEC_PER_MSEC,
108+ false, dev, MT_ADIE_SLP_CTRL_CK1(i));
109+ }
110+ }
111+ mt76_wmac_spi_unlock(dev);
112+
113 /* Reset EMI */
114 mt76_rmw_field(dev, MT_CONN_INFRA_EMI_REQ,
115 MT_CONN_INFRA_EMI_REQ_MASK, 0x1);
developerdc9eeae2024-04-08 14:36:46 +0800116@@ -1189,6 +1210,28 @@ void mt7986_wmac_disable(struct mt7915_dev *dev)
developera46f6132024-03-26 14:09:54 +0800117 MT_CONN_INFRA_INFRA_REQ_MASK, 0x0);
118
119 mt7986_wmac_top_wfsys_wakeup(dev, false);
120+
121+ mt76_rmw(dev, MT_TOP_CONN_INFRA_WAKEUP,
122+ MT_TOP_CONN_INFRA_WAKEUP_MASK, 0x1);
123+
124+ usleep_range(1000, 1100);
125+
126+ mt76_wmac_spi_lock(dev);
127+ for (i = 0; i < 2; i++) {
128+ if (is_7975(dev, i, dev->adie_type) || is_7976(dev, i, dev->adie_type)) {
129+ mt76_rmw_field(dev, MT_ADIE_SLP_CTRL_CK0(i),
130+ MT_SLP_CTRL_EN_MASK, 0x0);
131+
132+ read_poll_timeout(mt76_rr, cur, !(cur & MT_SLP_CTRL_BSY_MASK),
133+ USEC_PER_MSEC, 50 * USEC_PER_MSEC,
134+ false, dev, MT_ADIE_SLP_CTRL_CK0(i));
135+ }
136+ }
137+ mt76_wmac_spi_unlock(dev);
138+
139+ mt76_rmw(dev, MT_TOP_CONN_INFRA_WAKEUP,
140+ MT_TOP_CONN_INFRA_WAKEUP_MASK, 0x0);
141+
142 mt7986_wmac_consys_lockup(dev, true);
143 mt7986_wmac_consys_reset(dev, false);
144 }
145--
1462.18.0
147