developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From 55dd46f8caed3d8baa6819d884a1e82c496083f5 Mon Sep 17 00:00:00 2001 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Thu, 14 Mar 2024 17:55:12 +0800 |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 4 | Subject: [PATCH 14/21] wifi: mt76: mt7915: update power on sequence |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 5 | |
| 6 | Update power on sequence to prevent unexpected behavior. |
| 7 | |
| 8 | Signed-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 | |
| 15 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 16 | index 89156f35..74cd8caf 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 17 | --- 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 { |
| 27 | diff --git a/mt7915/regs.h b/mt7915/regs.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 28 | index 7515b23f..3452a7e9 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 29 | --- 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 |
| 47 | diff --git a/mt7915/soc.c b/mt7915/soc.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 48 | index 92d8d710..bb3468a9 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 49 | --- a/mt7915/soc.c |
| 50 | +++ b/mt7915/soc.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 51 | @@ -260,6 +260,7 @@ static int mt7986_wmac_consys_lockup(struct mt7915_dev *dev, bool enable) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 52 | 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 | |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 59 | @@ -844,6 +845,10 @@ static void mt7986_wmac_subsys_setting(struct mt7915_dev *dev) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 60 | 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); |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 70 | @@ -914,7 +919,7 @@ static void mt7986_wmac_clock_enable(struct mt7915_dev *dev, u32 adie_type) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 71 | |
| 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 | |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 79 | @@ -1154,12 +1159,14 @@ int mt7986_wmac_enable(struct mt7915_dev *dev) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 80 | 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 | |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 95 | @@ -1178,6 +1185,20 @@ void mt7986_wmac_disable(struct mt7915_dev *dev) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 96 | 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); |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 116 | @@ -1189,6 +1210,28 @@ void mt7986_wmac_disable(struct mt7915_dev *dev) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 117 | 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 | -- |
| 146 | 2.18.0 |
| 147 | |