11c42e0f2SLorenzo Bianconi /* SPDX-License-Identifier: ISC */
21c42e0f2SLorenzo Bianconi /* Copyright (C) 2023 MediaTek Inc. */
31c42e0f2SLorenzo Bianconi
41c42e0f2SLorenzo Bianconi #ifndef __MT792X_H
51c42e0f2SLorenzo Bianconi #define __MT792X_H
61c42e0f2SLorenzo Bianconi
71c42e0f2SLorenzo Bianconi #include <linux/interrupt.h>
81c42e0f2SLorenzo Bianconi #include <linux/ktime.h>
91c42e0f2SLorenzo Bianconi
101c42e0f2SLorenzo Bianconi #include "mt76_connac_mcu.h"
11c693f2f0SLorenzo Bianconi #include "mt792x_regs.h"
1229f5a494SLorenzo Bianconi #include "mt792x_acpi_sar.h"
131c42e0f2SLorenzo Bianconi
147d403f3aSLorenzo Bianconi #define MT792x_PM_TIMEOUT (HZ / 12)
157d403f3aSLorenzo Bianconi #define MT792x_HW_SCAN_TIMEOUT (HZ / 10)
167d403f3aSLorenzo Bianconi
17c74df1c0SLorenzo Bianconi #define MT792x_MAX_INTERFACES 4
18c74df1c0SLorenzo Bianconi #define MT792x_WTBL_SIZE 20
19c74df1c0SLorenzo Bianconi #define MT792x_WTBL_RESERVED (MT792x_WTBL_SIZE - 1)
20c74df1c0SLorenzo Bianconi #define MT792x_WTBL_STA (MT792x_WTBL_RESERVED - MT792x_MAX_INTERFACES)
21c74df1c0SLorenzo Bianconi
22c74df1c0SLorenzo Bianconi #define MT792x_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
23c74df1c0SLorenzo Bianconi #define MT792x_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
24c74df1c0SLorenzo Bianconi
25e8a264ccSLorenzo Bianconi #define MT792x_FW_TAG_FEATURE 4
26e8a264ccSLorenzo Bianconi #define MT792x_FW_CAP_CNM BIT(7)
27e8a264ccSLorenzo Bianconi
28c74df1c0SLorenzo Bianconi /* NOTE: used to map mt76_rates. idx may change if firmware expands table */
29c74df1c0SLorenzo Bianconi #define MT792x_BASIC_RATES_TBL 11
30c74df1c0SLorenzo Bianconi
31c74df1c0SLorenzo Bianconi #define MT792x_WATCHDOG_TIME (HZ / 4)
32c74df1c0SLorenzo Bianconi
331c025496SLorenzo Bianconi #define MT792x_DRV_OWN_RETRY_COUNT 10
341c025496SLorenzo Bianconi #define MT792x_MCU_INIT_RETRY_COUNT 10
351c025496SLorenzo Bianconi #define MT792x_WFSYS_INIT_RETRY_COUNT 2
361c025496SLorenzo Bianconi
37583204aeSLorenzo Bianconi #define MT7921_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7961_1.bin"
38583204aeSLorenzo Bianconi #define MT7922_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7922_1.bin"
39583204aeSLorenzo Bianconi
40583204aeSLorenzo Bianconi #define MT7921_ROM_PATCH "mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
41583204aeSLorenzo Bianconi #define MT7922_ROM_PATCH "mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
42583204aeSLorenzo Bianconi
431c42e0f2SLorenzo Bianconi struct mt792x_vif;
441c42e0f2SLorenzo Bianconi struct mt792x_sta;
451c42e0f2SLorenzo Bianconi
46e8a264ccSLorenzo Bianconi struct mt792x_realease_info {
47e8a264ccSLorenzo Bianconi __le16 len;
48e8a264ccSLorenzo Bianconi u8 pad_len;
49e8a264ccSLorenzo Bianconi u8 tag;
50e8a264ccSLorenzo Bianconi } __packed;
51e8a264ccSLorenzo Bianconi
52e8a264ccSLorenzo Bianconi struct mt792x_fw_features {
53e8a264ccSLorenzo Bianconi u8 segment;
54e8a264ccSLorenzo Bianconi u8 data;
55e8a264ccSLorenzo Bianconi u8 rsv[14];
56e8a264ccSLorenzo Bianconi } __packed;
57e8a264ccSLorenzo Bianconi
581c42e0f2SLorenzo Bianconi enum {
591c42e0f2SLorenzo Bianconi MT792x_CLC_POWER,
601c42e0f2SLorenzo Bianconi MT792x_CLC_CHAN,
611c42e0f2SLorenzo Bianconi MT792x_CLC_MAX_NUM,
621c42e0f2SLorenzo Bianconi };
631c42e0f2SLorenzo Bianconi
641c42e0f2SLorenzo Bianconi DECLARE_EWMA(avg_signal, 10, 8)
651c42e0f2SLorenzo Bianconi
661c42e0f2SLorenzo Bianconi struct mt792x_sta {
671c42e0f2SLorenzo Bianconi struct mt76_wcid wcid; /* must be first */
681c42e0f2SLorenzo Bianconi
691c42e0f2SLorenzo Bianconi struct mt792x_vif *vif;
701c42e0f2SLorenzo Bianconi
711c42e0f2SLorenzo Bianconi u32 airtime_ac[8];
721c42e0f2SLorenzo Bianconi
731c42e0f2SLorenzo Bianconi int ack_signal;
741c42e0f2SLorenzo Bianconi struct ewma_avg_signal avg_ack_signal;
751c42e0f2SLorenzo Bianconi
761c42e0f2SLorenzo Bianconi unsigned long last_txs;
771c42e0f2SLorenzo Bianconi
781c42e0f2SLorenzo Bianconi struct mt76_connac_sta_key_conf bip;
791c42e0f2SLorenzo Bianconi };
801c42e0f2SLorenzo Bianconi
811c42e0f2SLorenzo Bianconi DECLARE_EWMA(rssi, 10, 8);
821c42e0f2SLorenzo Bianconi
831c42e0f2SLorenzo Bianconi struct mt792x_vif {
841c42e0f2SLorenzo Bianconi struct mt76_vif mt76; /* must be first */
851c42e0f2SLorenzo Bianconi
861c42e0f2SLorenzo Bianconi struct mt792x_sta sta;
871c42e0f2SLorenzo Bianconi struct mt792x_sta *wep_sta;
881c42e0f2SLorenzo Bianconi
891c42e0f2SLorenzo Bianconi struct mt792x_phy *phy;
901c42e0f2SLorenzo Bianconi
911c42e0f2SLorenzo Bianconi struct ewma_rssi rssi;
921c42e0f2SLorenzo Bianconi
931c42e0f2SLorenzo Bianconi struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
941c42e0f2SLorenzo Bianconi };
951c42e0f2SLorenzo Bianconi
961c42e0f2SLorenzo Bianconi struct mt792x_phy {
971c42e0f2SLorenzo Bianconi struct mt76_phy *mt76;
981c42e0f2SLorenzo Bianconi struct mt792x_dev *dev;
991c42e0f2SLorenzo Bianconi
1001c42e0f2SLorenzo Bianconi struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
1011c42e0f2SLorenzo Bianconi
1021c42e0f2SLorenzo Bianconi u64 omac_mask;
1031c42e0f2SLorenzo Bianconi
1041c42e0f2SLorenzo Bianconi u16 noise;
1051c42e0f2SLorenzo Bianconi
1061c42e0f2SLorenzo Bianconi s16 coverage_class;
1071c42e0f2SLorenzo Bianconi u8 slottime;
1081c42e0f2SLorenzo Bianconi
1091c42e0f2SLorenzo Bianconi u32 rx_ampdu_ts;
1101c42e0f2SLorenzo Bianconi u32 ampdu_ref;
1111c42e0f2SLorenzo Bianconi
1121c42e0f2SLorenzo Bianconi struct mt76_mib_stats mib;
1131c42e0f2SLorenzo Bianconi
1141c42e0f2SLorenzo Bianconi u8 sta_work_count;
1151c42e0f2SLorenzo Bianconi
1161c42e0f2SLorenzo Bianconi struct sk_buff_head scan_event_list;
1171c42e0f2SLorenzo Bianconi struct delayed_work scan_work;
1181c42e0f2SLorenzo Bianconi #ifdef CONFIG_ACPI
1191c42e0f2SLorenzo Bianconi void *acpisar;
1201c42e0f2SLorenzo Bianconi #endif
1211c42e0f2SLorenzo Bianconi void *clc[MT792x_CLC_MAX_NUM];
1221c42e0f2SLorenzo Bianconi
1231c42e0f2SLorenzo Bianconi struct work_struct roc_work;
1241c42e0f2SLorenzo Bianconi struct timer_list roc_timer;
1251c42e0f2SLorenzo Bianconi wait_queue_head_t roc_wait;
1261c42e0f2SLorenzo Bianconi u8 roc_token_id;
1271c42e0f2SLorenzo Bianconi bool roc_grant;
1281c42e0f2SLorenzo Bianconi };
1291c42e0f2SLorenzo Bianconi
130c9072f11SLorenzo Bianconi struct mt792x_irq_map {
131c9072f11SLorenzo Bianconi u32 host_irq_enable;
132c9072f11SLorenzo Bianconi struct {
133c9072f11SLorenzo Bianconi u32 all_complete_mask;
134c9072f11SLorenzo Bianconi u32 mcu_complete_mask;
135c9072f11SLorenzo Bianconi } tx;
136c9072f11SLorenzo Bianconi struct {
137c9072f11SLorenzo Bianconi u32 data_complete_mask;
138c9072f11SLorenzo Bianconi u32 wm_complete_mask;
139c9072f11SLorenzo Bianconi u32 wm2_complete_mask;
140c9072f11SLorenzo Bianconi } rx;
141c9072f11SLorenzo Bianconi };
142c9072f11SLorenzo Bianconi
1435c041325SLorenzo Bianconi #define mt792x_init_reset(dev) ((dev)->hif_ops->init_reset(dev))
1445c041325SLorenzo Bianconi #define mt792x_dev_reset(dev) ((dev)->hif_ops->reset(dev))
1455c041325SLorenzo Bianconi #define mt792x_mcu_init(dev) ((dev)->hif_ops->mcu_init(dev))
1465c041325SLorenzo Bianconi #define __mt792x_mcu_drv_pmctrl(dev) ((dev)->hif_ops->drv_own(dev))
1475c041325SLorenzo Bianconi #define __mt792x_mcu_fw_pmctrl(dev) ((dev)->hif_ops->fw_own(dev))
1485c041325SLorenzo Bianconi
1491c42e0f2SLorenzo Bianconi struct mt792x_hif_ops {
1501c42e0f2SLorenzo Bianconi int (*init_reset)(struct mt792x_dev *dev);
1511c42e0f2SLorenzo Bianconi int (*reset)(struct mt792x_dev *dev);
1521c42e0f2SLorenzo Bianconi int (*mcu_init)(struct mt792x_dev *dev);
1531c42e0f2SLorenzo Bianconi int (*drv_own)(struct mt792x_dev *dev);
1541c42e0f2SLorenzo Bianconi int (*fw_own)(struct mt792x_dev *dev);
1551c42e0f2SLorenzo Bianconi };
1561c42e0f2SLorenzo Bianconi
1571c42e0f2SLorenzo Bianconi struct mt792x_dev {
1581c42e0f2SLorenzo Bianconi union { /* must be first */
1591c42e0f2SLorenzo Bianconi struct mt76_dev mt76;
1601c42e0f2SLorenzo Bianconi struct mt76_phy mphy;
1611c42e0f2SLorenzo Bianconi };
1621c42e0f2SLorenzo Bianconi
1631c42e0f2SLorenzo Bianconi const struct mt76_bus_ops *bus_ops;
1641c42e0f2SLorenzo Bianconi struct mt792x_phy phy;
1651c42e0f2SLorenzo Bianconi
1661c42e0f2SLorenzo Bianconi struct work_struct reset_work;
1671c42e0f2SLorenzo Bianconi bool hw_full_reset:1;
1681c42e0f2SLorenzo Bianconi bool hw_init_done:1;
1691c42e0f2SLorenzo Bianconi bool fw_assert:1;
1701c42e0f2SLorenzo Bianconi bool has_eht:1;
1711c42e0f2SLorenzo Bianconi
1721c42e0f2SLorenzo Bianconi struct work_struct init_work;
1731c42e0f2SLorenzo Bianconi
1741c42e0f2SLorenzo Bianconi u8 fw_debug;
1751c42e0f2SLorenzo Bianconi u8 fw_features;
1761c42e0f2SLorenzo Bianconi
1771c42e0f2SLorenzo Bianconi struct mt76_connac_pm pm;
1781c42e0f2SLorenzo Bianconi struct mt76_connac_coredump coredump;
1791c42e0f2SLorenzo Bianconi const struct mt792x_hif_ops *hif_ops;
180c9072f11SLorenzo Bianconi const struct mt792x_irq_map *irq_map;
1811c42e0f2SLorenzo Bianconi
1821c42e0f2SLorenzo Bianconi struct work_struct ipv6_ns_work;
1831c42e0f2SLorenzo Bianconi /* IPv6 addresses for WoWLAN */
1841c42e0f2SLorenzo Bianconi struct sk_buff_head ipv6_ns_list;
1851c42e0f2SLorenzo Bianconi
1861c42e0f2SLorenzo Bianconi enum environment_cap country_ie_env;
1871c42e0f2SLorenzo Bianconi u32 backup_l1;
1881c42e0f2SLorenzo Bianconi u32 backup_l2;
1891c42e0f2SLorenzo Bianconi };
1901c42e0f2SLorenzo Bianconi
19120249e1aSLorenzo Bianconi static inline struct mt792x_dev *
mt792x_hw_dev(struct ieee80211_hw * hw)19220249e1aSLorenzo Bianconi mt792x_hw_dev(struct ieee80211_hw *hw)
19320249e1aSLorenzo Bianconi {
19420249e1aSLorenzo Bianconi struct mt76_phy *phy = hw->priv;
19520249e1aSLorenzo Bianconi
19620249e1aSLorenzo Bianconi return container_of(phy->dev, struct mt792x_dev, mt76);
19720249e1aSLorenzo Bianconi }
19820249e1aSLorenzo Bianconi
199c74df1c0SLorenzo Bianconi static inline struct mt792x_phy *
mt792x_hw_phy(struct ieee80211_hw * hw)200c74df1c0SLorenzo Bianconi mt792x_hw_phy(struct ieee80211_hw *hw)
201c74df1c0SLorenzo Bianconi {
202c74df1c0SLorenzo Bianconi struct mt76_phy *phy = hw->priv;
203c74df1c0SLorenzo Bianconi
204c74df1c0SLorenzo Bianconi return phy->priv;
205c74df1c0SLorenzo Bianconi }
206c74df1c0SLorenzo Bianconi
207311f121cSLorenzo Bianconi static inline void
mt792x_get_status_freq_info(struct mt76_rx_status * status,u8 chfreq)208311f121cSLorenzo Bianconi mt792x_get_status_freq_info(struct mt76_rx_status *status, u8 chfreq)
209311f121cSLorenzo Bianconi {
210311f121cSLorenzo Bianconi if (chfreq > 180) {
211311f121cSLorenzo Bianconi status->band = NL80211_BAND_6GHZ;
212311f121cSLorenzo Bianconi chfreq = (chfreq - 181) * 4 + 1;
213311f121cSLorenzo Bianconi } else if (chfreq > 14) {
214311f121cSLorenzo Bianconi status->band = NL80211_BAND_5GHZ;
215311f121cSLorenzo Bianconi } else {
216311f121cSLorenzo Bianconi status->band = NL80211_BAND_2GHZ;
217311f121cSLorenzo Bianconi }
218311f121cSLorenzo Bianconi status->freq = ieee80211_channel_to_frequency(chfreq, status->band);
219311f121cSLorenzo Bianconi }
220311f121cSLorenzo Bianconi
mt792x_dma_need_reinit(struct mt792x_dev * dev)221c693f2f0SLorenzo Bianconi static inline bool mt792x_dma_need_reinit(struct mt792x_dev *dev)
222c693f2f0SLorenzo Bianconi {
223c693f2f0SLorenzo Bianconi return !mt76_get_field(dev, MT_WFDMA_DUMMY_CR, MT_WFDMA_NEED_REINIT);
224c693f2f0SLorenzo Bianconi }
225c693f2f0SLorenzo Bianconi
226c605d0ceSLorenzo Bianconi #define mt792x_mutex_acquire(dev) \
227c605d0ceSLorenzo Bianconi mt76_connac_mutex_acquire(&(dev)->mt76, &(dev)->pm)
228c605d0ceSLorenzo Bianconi #define mt792x_mutex_release(dev) \
229c605d0ceSLorenzo Bianconi mt76_connac_mutex_release(&(dev)->mt76, &(dev)->pm)
230c605d0ceSLorenzo Bianconi
231c21a7f9fSLorenzo Bianconi void mt792x_pm_wake_work(struct work_struct *work);
232c21a7f9fSLorenzo Bianconi void mt792x_pm_power_save_work(struct work_struct *work);
233311f121cSLorenzo Bianconi void mt792x_reset(struct mt76_dev *mdev);
234311f121cSLorenzo Bianconi void mt792x_update_channel(struct mt76_phy *mphy);
235311f121cSLorenzo Bianconi void mt792x_mac_reset_counters(struct mt792x_phy *phy);
236e8a264ccSLorenzo Bianconi void mt792x_mac_init_band(struct mt792x_dev *dev, u8 band);
237311f121cSLorenzo Bianconi void mt792x_mac_assoc_rssi(struct mt792x_dev *dev, struct sk_buff *skb);
238311f121cSLorenzo Bianconi struct mt76_wcid *mt792x_rx_get_wcid(struct mt792x_dev *dev, u16 idx,
239311f121cSLorenzo Bianconi bool unicast);
240c74df1c0SLorenzo Bianconi void mt792x_mac_update_mib_stats(struct mt792x_phy *phy);
241c74df1c0SLorenzo Bianconi void mt792x_mac_set_timeing(struct mt792x_phy *phy);
242c74df1c0SLorenzo Bianconi void mt792x_mac_work(struct work_struct *work);
243c74df1c0SLorenzo Bianconi void mt792x_remove_interface(struct ieee80211_hw *hw,
244c74df1c0SLorenzo Bianconi struct ieee80211_vif *vif);
245c74df1c0SLorenzo Bianconi void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
246c74df1c0SLorenzo Bianconi struct sk_buff *skb);
247c74df1c0SLorenzo Bianconi int mt792x_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
248c74df1c0SLorenzo Bianconi unsigned int link_id, u16 queue,
249c74df1c0SLorenzo Bianconi const struct ieee80211_tx_queue_params *params);
250c74df1c0SLorenzo Bianconi int mt792x_get_stats(struct ieee80211_hw *hw,
251c74df1c0SLorenzo Bianconi struct ieee80211_low_level_stats *stats);
252c74df1c0SLorenzo Bianconi u64 mt792x_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
253c74df1c0SLorenzo Bianconi void mt792x_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
254c74df1c0SLorenzo Bianconi u64 timestamp);
255c74df1c0SLorenzo Bianconi void mt792x_tx_worker(struct mt76_worker *w);
256c74df1c0SLorenzo Bianconi void mt792x_roc_timer(struct timer_list *timer);
257c74df1c0SLorenzo Bianconi void mt792x_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
258c74df1c0SLorenzo Bianconi u32 queues, bool drop);
259c74df1c0SLorenzo Bianconi int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,
260c74df1c0SLorenzo Bianconi struct ieee80211_vif *vif,
261c74df1c0SLorenzo Bianconi struct ieee80211_bss_conf *link_conf,
262c74df1c0SLorenzo Bianconi struct ieee80211_chanctx_conf *ctx);
263c74df1c0SLorenzo Bianconi void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,
264c74df1c0SLorenzo Bianconi struct ieee80211_vif *vif,
265c74df1c0SLorenzo Bianconi struct ieee80211_bss_conf *link_conf,
266c74df1c0SLorenzo Bianconi struct ieee80211_chanctx_conf *ctx);
267c74df1c0SLorenzo Bianconi void mt792x_set_wakeup(struct ieee80211_hw *hw, bool enabled);
268c74df1c0SLorenzo Bianconi void mt792x_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
269c74df1c0SLorenzo Bianconi u32 sset, u8 *data);
270c74df1c0SLorenzo Bianconi int mt792x_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
271c74df1c0SLorenzo Bianconi int sset);
272c74df1c0SLorenzo Bianconi void mt792x_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
273c74df1c0SLorenzo Bianconi struct ethtool_stats *stats, u64 *data);
274c74df1c0SLorenzo Bianconi void mt792x_sta_statistics(struct ieee80211_hw *hw,
275c74df1c0SLorenzo Bianconi struct ieee80211_vif *vif,
276c74df1c0SLorenzo Bianconi struct ieee80211_sta *sta,
277c74df1c0SLorenzo Bianconi struct station_info *sinfo);
278c74df1c0SLorenzo Bianconi void mt792x_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class);
279c693f2f0SLorenzo Bianconi void mt792x_dma_cleanup(struct mt792x_dev *dev);
280ff655174SLorenzo Bianconi int mt792x_dma_enable(struct mt792x_dev *dev);
281ff655174SLorenzo Bianconi int mt792x_wpdma_reset(struct mt792x_dev *dev, bool force);
282ff655174SLorenzo Bianconi int mt792x_wpdma_reinit_cond(struct mt792x_dev *dev);
283c693f2f0SLorenzo Bianconi int mt792x_dma_disable(struct mt792x_dev *dev, bool force);
284ff655174SLorenzo Bianconi irqreturn_t mt792x_irq_handler(int irq, void *dev_instance);
285ff655174SLorenzo Bianconi void mt792x_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q);
286ff655174SLorenzo Bianconi int mt792x_poll_tx(struct napi_struct *napi, int budget);
287c693f2f0SLorenzo Bianconi int mt792x_poll_rx(struct napi_struct *napi, int budget);
288ff655174SLorenzo Bianconi void mt792x_irq_tasklet(unsigned long data);
289ff655174SLorenzo Bianconi int mt792x_wfsys_reset(struct mt792x_dev *dev);
290974e759cSLorenzo Bianconi int mt792x_tx_stats_show(struct seq_file *file, void *data);
291974e759cSLorenzo Bianconi int mt792x_queues_acq(struct seq_file *s, void *data);
292974e759cSLorenzo Bianconi int mt792x_queues_read(struct seq_file *s, void *data);
293974e759cSLorenzo Bianconi int mt792x_pm_stats(struct seq_file *s, void *data);
294974e759cSLorenzo Bianconi int mt792x_pm_idle_timeout_set(void *data, u64 val);
295974e759cSLorenzo Bianconi int mt792x_pm_idle_timeout_get(void *data, u64 *val);
296e8a264ccSLorenzo Bianconi int mt792x_init_wiphy(struct ieee80211_hw *hw);
297e8a264ccSLorenzo Bianconi struct ieee80211_ops *
298e8a264ccSLorenzo Bianconi mt792x_get_mac80211_ops(struct device *dev,
299e8a264ccSLorenzo Bianconi const struct ieee80211_ops *mac80211_ops,
300e8a264ccSLorenzo Bianconi void *drv_data, u8 *fw_features);
301e8a264ccSLorenzo Bianconi int mt792x_init_wcid(struct mt792x_dev *dev);
302c21a7f9fSLorenzo Bianconi int mt792x_mcu_drv_pmctrl(struct mt792x_dev *dev);
303c21a7f9fSLorenzo Bianconi int mt792x_mcu_fw_pmctrl(struct mt792x_dev *dev);
304c74df1c0SLorenzo Bianconi
mt792x_ram_name(struct mt792x_dev * dev)305583204aeSLorenzo Bianconi static inline char *mt792x_ram_name(struct mt792x_dev *dev)
306583204aeSLorenzo Bianconi {
307583204aeSLorenzo Bianconi switch (mt76_chip(&dev->mt76)) {
308583204aeSLorenzo Bianconi case 0x7922:
309583204aeSLorenzo Bianconi return MT7922_FIRMWARE_WM;
310583204aeSLorenzo Bianconi default:
311583204aeSLorenzo Bianconi return MT7921_FIRMWARE_WM;
312583204aeSLorenzo Bianconi }
313583204aeSLorenzo Bianconi }
314583204aeSLorenzo Bianconi
mt792x_patch_name(struct mt792x_dev * dev)315583204aeSLorenzo Bianconi static inline char *mt792x_patch_name(struct mt792x_dev *dev)
316583204aeSLorenzo Bianconi {
317583204aeSLorenzo Bianconi switch (mt76_chip(&dev->mt76)) {
318583204aeSLorenzo Bianconi case 0x7922:
319583204aeSLorenzo Bianconi return MT7922_ROM_PATCH;
320583204aeSLorenzo Bianconi default:
321583204aeSLorenzo Bianconi return MT7921_ROM_PATCH;
322583204aeSLorenzo Bianconi }
323583204aeSLorenzo Bianconi }
324583204aeSLorenzo Bianconi
325583204aeSLorenzo Bianconi int mt792x_load_firmware(struct mt792x_dev *dev);
326583204aeSLorenzo Bianconi
327d28e1a48SLorenzo Bianconi /* usb */
328d28e1a48SLorenzo Bianconi #define MT_USB_TYPE_VENDOR (USB_TYPE_VENDOR | 0x1f)
329d28e1a48SLorenzo Bianconi #define MT_USB_TYPE_UHW_VENDOR (USB_TYPE_VENDOR | 0x1e)
330d28e1a48SLorenzo Bianconi int mt792xu_dma_init(struct mt792x_dev *dev, bool resume);
331d28e1a48SLorenzo Bianconi int mt792xu_mcu_power_on(struct mt792x_dev *dev);
332d28e1a48SLorenzo Bianconi int mt792xu_wfsys_reset(struct mt792x_dev *dev);
333d28e1a48SLorenzo Bianconi int mt792xu_init_reset(struct mt792x_dev *dev);
334d28e1a48SLorenzo Bianconi u32 mt792xu_rr(struct mt76_dev *dev, u32 addr);
335d28e1a48SLorenzo Bianconi void mt792xu_wr(struct mt76_dev *dev, u32 addr, u32 val);
336d28e1a48SLorenzo Bianconi u32 mt792xu_rmw(struct mt76_dev *dev, u32 addr, u32 mask, u32 val);
337d28e1a48SLorenzo Bianconi void mt792xu_copy(struct mt76_dev *dev, u32 offset, const void *data, int len);
338*fc80731bSLorenzo Bianconi void mt792xu_disconnect(struct usb_interface *usb_intf);
339d28e1a48SLorenzo Bianconi
3401c025496SLorenzo Bianconi int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev);
3411c025496SLorenzo Bianconi int mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev);
3421c025496SLorenzo Bianconi int mt792xe_mcu_fw_pmctrl(struct mt792x_dev *dev);
3431c025496SLorenzo Bianconi
34429f5a494SLorenzo Bianconi #ifdef CONFIG_ACPI
34529f5a494SLorenzo Bianconi int mt792x_init_acpi_sar(struct mt792x_dev *dev);
34629f5a494SLorenzo Bianconi int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default);
34729f5a494SLorenzo Bianconi u8 mt792x_acpi_get_flags(struct mt792x_phy *phy);
34829f5a494SLorenzo Bianconi #else
mt792x_init_acpi_sar(struct mt792x_dev * dev)34929f5a494SLorenzo Bianconi static inline int mt792x_init_acpi_sar(struct mt792x_dev *dev)
35029f5a494SLorenzo Bianconi {
35129f5a494SLorenzo Bianconi return 0;
35229f5a494SLorenzo Bianconi }
35329f5a494SLorenzo Bianconi
mt792x_init_acpi_sar_power(struct mt792x_phy * phy,bool set_default)35429f5a494SLorenzo Bianconi static inline int mt792x_init_acpi_sar_power(struct mt792x_phy *phy,
35529f5a494SLorenzo Bianconi bool set_default)
35629f5a494SLorenzo Bianconi {
35729f5a494SLorenzo Bianconi return 0;
35829f5a494SLorenzo Bianconi }
35929f5a494SLorenzo Bianconi
mt792x_acpi_get_flags(struct mt792x_phy * phy)36029f5a494SLorenzo Bianconi static inline u8 mt792x_acpi_get_flags(struct mt792x_phy *phy)
36129f5a494SLorenzo Bianconi {
36229f5a494SLorenzo Bianconi return 0;
36329f5a494SLorenzo Bianconi }
36429f5a494SLorenzo Bianconi #endif
36529f5a494SLorenzo Bianconi
3661c42e0f2SLorenzo Bianconi #endif /* __MT7925_H */
367