add mt76x0e hw initialization support
Subsystems (2)
cover add mt76x0e hw initialization support
Add hw initialization support for mt76x0e driver. Remove usb dependency from generic init code (there is a usb dependency in tx generic code not fixed yet). Fix memory leak in mt76x0u_probe
Lorenzo Bianconi (26):
mt76x0: use mt76_poll in mt76x0_set_wlan_state
mt76: move wait_for_wpdma in mt76x02_dma.h
mt76: add mt76x02_dma_enable/mt76x02_dma_disable utility routines
mt76: move mt76x02_set_irq_mask in mt76x02_core.c
mt76: move queue initialization in mt76x02_dma.c
mt76: move mt76x02_beacon_offset in mt76x02_core.c
mt76: mmio: add implementation of wr_rp and rd_rp
mt76: move mt76x2_wait_for_bbp in mt76x02-lib module
mt76x0: update initvals to latest version of verndor driver
mt76x0: pci: move mcu code in pci_mcu.c
mt76x0: usb: move mcu code in usb_mcu.c
mt76x0: use mt76x02 utility routines in mt76x0 init code
mt76x0: init: remove duplicated initialization
mt76x0: init: remove MT_PBF_SYS_CTRL configuration in
mt76x0_reset_csr_bbp
mt76x0: init: reset beacon offset during bootstrap
mt76x0: init rx filter in mt76x0_init_hardware
mt76: add mt76x02_mac_start routine
mt76x0: usb: move initialization code in usb_init.c
mt76x0: pci: add hw initialization at bootstrap
mt76x0: phy: set antenna parameter according to wireless band
mt76: move set_{tx,rx}_path routines in mt76x02-lib module
mt76x0: add ieee80211_ops ops pointer to mt76x0_alloc_device signature
mt76x0: pci: add mt76x0e_start callback
mt76x0: pci: add mt76x0e_stop callback
mt76: move eeprom_load routines in mt76x02_eeprom.c
mt76x0: introduce mt76x0{e,u}_eeprom_init routines
drivers/net/wireless/mediatek/mt76/Makefile | 3 +- drivers/net/wireless/mediatek/mt76/mmio.c | 27 ++ drivers/net/wireless/mediatek/mt76/mt76.h | 7 +- .../wireless/mediatek/mt76/mt76x0/Makefile | 4 +- .../wireless/mediatek/mt76/mt76x0/eeprom.c | 21 +- .../wireless/mediatek/mt76/mt76x0/eeprom.h | 1 + .../net/wireless/mediatek/mt76/mt76x0/init.c | 205 ++------- .../wireless/mediatek/mt76/mt76x0/initvals.h | 405 ++++++++---------- .../net/wireless/mediatek/mt76/mt76x0/main.c | 84 ++-- .../net/wireless/mediatek/mt76/mt76x0/mcu.h | 2 + .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 30 +- .../net/wireless/mediatek/mt76/mt76x0/pci.c | 115 +---- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 126 ++++++ .../wireless/mediatek/mt76/mt76x0/pci_mcu.c | 146 +++++++ .../net/wireless/mediatek/mt76/mt76x0/phy.c | 62 +-- .../net/wireless/mediatek/mt76/mt76x0/tx.c | 1 + .../net/wireless/mediatek/mt76/mt76x0/usb.c | 190 +------- .../wireless/mediatek/mt76/mt76x0/usb_init.c | 197 +++++++++ .../wireless/mediatek/mt76/mt76x0/usb_mcu.c | 176 ++++++++ .../net/wireless/mediatek/mt76/mt76x02_core.c | 72 ++++ .../net/wireless/mediatek/mt76/mt76x02_dma.c | 136 ++++++ .../net/wireless/mediatek/mt76/mt76x02_dma.h | 17 + .../wireless/mediatek/mt76/mt76x02_eeprom.c | 154 +++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.h | 2 + .../net/wireless/mediatek/mt76/mt76x02_mac.c | 15 + .../net/wireless/mediatek/mt76/mt76x02_mac.h | 1 + .../net/wireless/mediatek/mt76/mt76x02_phy.c | 38 ++ .../net/wireless/mediatek/mt76/mt76x02_phy.h | 2 + .../net/wireless/mediatek/mt76/mt76x02_util.h | 22 + drivers/net/wireless/mediatek/mt76/mt76x2.h | 39 +- .../net/wireless/mediatek/mt76/mt76x2_core.c | 28 +- .../net/wireless/mediatek/mt76/mt76x2_dfs.c | 7 +- .../net/wireless/mediatek/mt76/mt76x2_dma.c | 91 +--- .../wireless/mediatek/mt76/mt76x2_eeprom.c | 157 +------ .../net/wireless/mediatek/mt76/mt76x2_init.c | 75 +--- .../mediatek/mt76/mt76x2_init_common.c | 17 +- .../net/wireless/mediatek/mt76/mt76x2_mac.c | 14 +- .../net/wireless/mediatek/mt76/mt76x2_main.c | 2 +- .../mediatek/mt76/mt76x2_mcu_common.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2u.h | 2 - .../net/wireless/mediatek/mt76/mt76x2u_init.c | 16 +- .../net/wireless/mediatek/mt76/mt76x2u_mac.c | 2 +- .../net/wireless/mediatek/mt76/mt76x2u_phy.c | 33 -- 43 files changed, 1483 insertions(+), 1263 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_mcu.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/usb_init.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_core.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_dma.c
Signature · 1 line
2.17.1
PATCH 1/26 mt76x0: use mt76_poll in mt76x0_set_wlan_state
Use mt76_poll utility routine in mt76x0_set_wlan_state to check if the PLL/XTAL is ready
--- .../net/wireless/mediatek/mt76/mt76x0/init.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +3 -15
@@ -43,7 +43,7 @@ static void mt76x0_vht_cap_mask(struct ieee80211_supported_band *sband)static void mt76x0_set_wlan_state (struct mt76x0_dev *dev,u32 val,bool enable) { -int i; +u32 mask =MT_CMB_CTRL_XTAL_RDY |MT_CMB_CTRL_PLL_LD ;/* Note: we don't turn off WLAN_CLK because that makes the device * not respond properly on the probe path.
@@ -60,24 +60,12 @@ mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable)mt76_wr (dev,MT_WLAN_FUN_CTRL , val);udelay (20 ); -if (!enable) -return ; - -for (i =200 ; i; i--) { - val =mt76_rr (dev,MT_CMB_CTRL ); - -if (val &MT_CMB_CTRL_XTAL_RDY && val &MT_CMB_CTRL_PLL_LD ) -break ; - -udelay (20 ); - } -/* Note: vendor driver tries to disable/enable wlan here and retry * but the code which does it is so buggy it must have never * triggered, so don't bother. */ -if (!i) -dev_err (dev->mt76.dev,"Error: PLL and XTAL check failed!\n" ); +if (enable && !mt76_poll (dev,MT_CMB_CTRL , mask, mask,2000 )) +dev_err (dev->mt76.dev,"PLL and XTAL check failed\n" ); }void mt76x0_chip_onoff (struct mt76x0_dev *dev,bool enable,bool reset)
Signature · 1 line
2.17.1
PATCH 2/26 mt76: move wait_for_wpdma in mt76x02_dma.h
In reply to Lorenzo BianconiMove wait_for_wpdma utility routine in mt76x02_dma.h in order to be reused by mt76x0 driver. Moreover add the possibility to specify the timeout value in wait_for_wpdma signature
--- drivers/net/wireless/mediatek/mt76/mt76x02_dma.h | 10 ++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2.h | 8 -------- drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_dma.h +10 -0
@@ -18,6 +18,7 @@#define __MT76x02_DMA_H#include "dma.h" +#include "mt76x02_regs.h" #define MT_TXD_INFO_LEN GENMASK(15, 0)#define MT_TXD_INFO_NEXT_VLD BIT(16)
@@ -57,4 +58,13 @@ enum dma_msg_port { DISCARD, }; +static inline bool +mt76x02_wait_for_wpdma (struct mt76_dev *dev,int timeout) +{ +return __mt76_poll (dev,MT_WPDMA_GLO_CFG , +MT_WPDMA_GLO_CFG_TX_DMA_BUSY | +MT_WPDMA_GLO_CFG_RX_DMA_BUSY , +0 , timeout); +} +#endif /* __MT76x02_DMA_H */
drivers/net/wireless/mediatek/mt76/mt76x2.h +0 -8
@@ -151,14 +151,6 @@ static inline bool mt76x2_wait_for_bbp(struct mt76x2_dev *dev) 0, 100); } -static inline bool wait_for_wpdma (struct mt76x2_dev *dev) -{ -return mt76_poll (dev,MT_WPDMA_GLO_CFG , -MT_WPDMA_GLO_CFG_TX_DMA_BUSY | -MT_WPDMA_GLO_CFG_RX_DMA_BUSY , -0 ,1000 ); -} -extern const struct ieee80211_ops mt76x2_ops;struct mt76x2_dev *mt76x2_alloc_device (struct device *pdev);
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +2 -1
@@ -19,6 +19,7 @@#include "mt76x2_eeprom.h" #include "mt76x2_mcu.h" #include "mt76x02_util.h" +#include "mt76x02_dma.h" static void mt76x2_mac_pbf_init (struct mt76x2_dev *dev)
@@ -206,7 +207,7 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)memset (dev->aggr_stats,0 ,sizeof (dev->aggr_stats));mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_ENABLE_TX ); -wait_for_wpdma (dev); +mt76x02_wait_for_wpdma (&dev->mt76,1000 );usleep_range (50 ,100 ); mt76_set(dev, MT_WPDMA_GLO_CFG,
drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c +1 -1
@@ -119,7 +119,7 @@ int mt76x2u_mac_start(struct mt76x2_dev *dev)mt76x2u_mac_reset_counters (dev);mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_ENABLE_TX ); -wait_for_wpdma (dev); +mt76x02_wait_for_wpdma (&dev->mt76,1000 );usleep_range (50 ,100 );mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter);
Signature · 1 line
2.17.1
PATCH 3/26 mt76: add mt76x02_dma_enable/mt76x02_dma_disable utility routines
In reply to Lorenzo BianconiIntroduce mt76x02_dma_enable and mt76x02_dma_disable utility routines in order to be reused in mt76x0 mac configuration and remove duplicated code
--- drivers/net/wireless/mediatek/mt76/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x02_dma.c | 51 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x02_dma.h | 3 ++ .../net/wireless/mediatek/mt76/mt76x2_init.c | 20 +------- 4 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_dma.c
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
@@ -16,7 +16,7 @@ CFLAGS_trace.o := -I$(src) CFLAGS_usb_trace.o := -I$(src) mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \ - mt76x02_eeprom.o mt76x02_phy.o + mt76x02_eeprom.o mt76x02_phy.o mt76x02_dma.o mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
drivers/net/wireless/mediatek/mt76/mt76x02_dma.c new file +51 -0
51 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x02_dma.h +3 -0
@@ -67,4 +67,7 @@ mt76x02_wait_for_wpdma(struct mt76_dev *dev, int timeout) 0, timeout); } +void mt76x02_dma_enable (struct mt76_dev *dev); +void mt76x02_dma_disable (struct mt76_dev *dev); +#endif /* __MT76x02_DMA_H */
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +2 -18
@@ -206,16 +206,7 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)memset (dev->aggr_stats,0 ,sizeof (dev->aggr_stats)); -mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_ENABLE_TX ); -mt76x02_wait_for_wpdma (&dev->mt76,1000 ); -usleep_range (50 ,100 ); - -mt76_set (dev,MT_WPDMA_GLO_CFG , -MT_WPDMA_GLO_CFG_TX_DMA_EN | -MT_WPDMA_GLO_CFG_RX_DMA_EN ); - -mt76_clear (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE ); - +mt76x02_dma_enable (&dev->mt76);mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter); mt76_wr(dev, MT_MAC_SYS_CTRL,
@@ -354,20 +345,13 @@ int mt76x2_init_hardware(struct mt76x2_dev *dev)0xc000 , 0xc000, }; -u32 val;int ret; dev->beacon_offsets = beacon_offsets;tasklet_init (&dev->pre_tbtt_tasklet, mt76x2_pre_tbtt_tasklet, (unsigned long ) dev); - val =mt76_rr (dev,MT_WPDMA_GLO_CFG ); - val &=MT_WPDMA_GLO_CFG_DMA_BURST_SIZE | -MT_WPDMA_GLO_CFG_BIG_ENDIAN | -MT_WPDMA_GLO_CFG_HDR_SEG_LEN ; - val |=MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE ; -mt76_wr (dev,MT_WPDMA_GLO_CFG , val); - +mt76x02_dma_disable (&dev->mt76);mt76x2_reset_wlan (dev, true);mt76x2_power_on (dev);
Signature · 1 line
2.17.1
PATCH 4/26 mt76: move mt76x02_set_irq_mask in mt76x02_core.c
In reply to Lorenzo BianconiMove mt76x02_set_irq_mask, mt76x02_irq_enable and mt76x02_irq_disable in mt76x02-lib module in order to be reused by mt76x0 driver. Moreover move irq_lock and irqmask in mt76_mmio data structure
--- drivers/net/wireless/mediatek/mt76/Makefile | 3 +- drivers/net/wireless/mediatek/mt76/mmio.c | 1 + drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ .../net/wireless/mediatek/mt76/mt76x02_core.c | 34 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x02_util.h | 13 +++++++ drivers/net/wireless/mediatek/mt76/mt76x2.h | 15 -------- .../net/wireless/mediatek/mt76/mt76x2_core.c | 28 +++++---------- .../net/wireless/mediatek/mt76/mt76x2_dfs.c | 7 ++-- .../net/wireless/mediatek/mt76/mt76x2_dma.c | 7 ++-- .../net/wireless/mediatek/mt76/mt76x2_init.c | 6 ++-- .../net/wireless/mediatek/mt76/mt76x2_mac.c | 8 ++--- 11 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_core.c
drivers/net/wireless/mediatek/mt76/Makefile +2 -1
@@ -16,7 +16,8 @@ CFLAGS_trace.o := -I$(src) CFLAGS_usb_trace.o := -I$(src) mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \ - mt76x02_eeprom.o mt76x02_phy.o mt76x02_dma.o + mt76x02_eeprom.o mt76x02_phy.o mt76x02_dma.o \ + mt76x02_core.o mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
drivers/net/wireless/mediatek/mt76/mmio.c +1 -0
@@ -60,6 +60,7 @@ void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs)skb_queue_head_init (&dev->mmio.mcu.res_q);init_waitqueue_head (&dev->mmio.mcu.wait); +spin_lock_init (&dev->mmio.irq_lock);mutex_init (&dev->mmio.mcu.mutex); }EXPORT_SYMBOL_GPL (mt76_mmio_init);
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
@@ -363,6 +363,8 @@ struct mt76_mmio {u32 msg_seq; } mcu;void __iomem *regs; +spinlock_t irq_lock; +u32 irqmask; };struct mt76_dev {
drivers/net/wireless/mediatek/mt76/mt76x02_core.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2016 Felix Fietkau <[email protected]> +* Copyright (C) 2018 Lorenzo Bianconi <[email protected]> +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include <linux/kernel.h> + +#include "mt76.h" +#include "mt76x02_dma.h" +#include "mt76x02_regs.h" + +void mt76x02_set_irq_mask (struct mt76_dev *dev,u32 clear,u32 set) +{ +unsigned long flags; + +spin_lock_irqsave (&dev->mmio.irq_lock, flags); + dev->mmio.irqmask &= ~clear; + dev->mmio.irqmask |= set; +__mt76_wr (dev,MT_INT_MASK_CSR , dev->mmio.irqmask); +spin_unlock_irqrestore (&dev->mmio.irq_lock, flags); +} +EXPORT_SYMBOL_GPL (mt76x02_set_irq_mask);
drivers/net/wireless/mediatek/mt76/mt76x02_util.h +13 -0
@@ -51,4 +51,17 @@ void mt76x02_tx_complete(struct mt76_dev *dev, struct sk_buff *skb);void mt76x02_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue *q,struct mt76_queue_entry *e,bool flush);bool mt76x02_tx_status_data (struct mt76_dev *dev,u8 *update); + +void mt76x02_set_irq_mask (struct mt76_dev *dev,u32 clear,u32 set); + +static inline void mt76x02_irq_enable (struct mt76_dev *dev,u32 mask) +{ +mt76x02_set_irq_mask (dev,0 , mask); +} + +static inline void mt76x02_irq_disable (struct mt76_dev *dev,u32 mask) +{ +mt76x02_set_irq_mask (dev, mask,0 ); +} +#endif
drivers/net/wireless/mediatek/mt76/mt76x2.h +0 -15
@@ -95,9 +95,6 @@ struct mt76x2_dev {u32 aggr_stats[32 ]; -spinlock_t irq_lock; -u32 irqmask; -struct sk_buff *beacons[8 ];u8 beacon_mask;u8 beacon_data_mask;
@@ -124,8 +121,6 @@ static inline bool is_mt7612(struct mt76x2_dev *dev)return mt76_chip (&dev->mt76) ==0x7612 ; } -void mt76x2_set_irq_mask (struct mt76x2_dev *dev,u32 clear,u32 set); -static inline bool mt76x2_channel_silent (struct mt76x2_dev *dev) {struct ieee80211_channel *chan = dev->mt76.chandef.chan;
@@ -134,16 +129,6 @@ static inline bool mt76x2_channel_silent(struct mt76x2_dev *dev) chan->dfs_state != NL80211_DFS_AVAILABLE); } -static inline void mt76x2_irq_enable (struct mt76x2_dev *dev,u32 mask) -{ -mt76x2_set_irq_mask (dev,0 , mask); -} - -static inline void mt76x2_irq_disable (struct mt76x2_dev *dev,u32 mask) -{ -mt76x2_set_irq_mask (dev, mask,0 ); -} -static inline bool mt76x2_wait_for_bbp (struct mt76x2_dev *dev) { return mt76_poll_msec(dev, MT_MAC_STATUS,
drivers/net/wireless/mediatek/mt76/mt76x2_core.c +8 -20
@@ -17,23 +17,11 @@#include <linux/delay.h> #include "mt76x2.h" #include "mt76x2_trace.h" - -void mt76x2_set_irq_mask (struct mt76x2_dev *dev,u32 clear,u32 set) -{ -unsigned long flags; - -spin_lock_irqsave (&dev->irq_lock, flags); - dev->irqmask &= ~clear; - dev->irqmask |= set; -mt76_wr (dev,MT_INT_MASK_CSR , dev->irqmask); -spin_unlock_irqrestore (&dev->irq_lock, flags); -} +#include "mt76x02_util.h" void mt76x2_rx_poll_complete (struct mt76_dev *mdev,enum mt76_rxq_id q) { - struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76); - -mt76x2_irq_enable (dev,MT_INT_RX_DONE (q)); +mt76x02_irq_enable (mdev,MT_INT_RX_DONE (q)); }irqreturn_t mt76x2_irq_handler (int irq,void *dev_instance)
@@ -47,22 +35,22 @@ irqreturn_t mt76x2_irq_handler(int irq, void *dev_instance)if (!test_bit (MT76_STATE_INITIALIZED , &dev->mt76.state))return IRQ_NONE ; -trace_dev_irq (dev, intr, dev->irqmask); +trace_dev_irq (dev, intr, dev->mt76.mmio.irqmask); - intr &= dev->irqmask; + intr &= dev->mt76.mmio.irqmask;if (intr &MT_INT_TX_DONE_ALL ) { -mt76x2_irq_disable (dev,MT_INT_TX_DONE_ALL ); +mt76x02_irq_disable (&dev->mt76,MT_INT_TX_DONE_ALL );tasklet_schedule (&dev->tx_tasklet); }if (intr &MT_INT_RX_DONE (0 )) { -mt76x2_irq_disable (dev,MT_INT_RX_DONE (0 )); +mt76x02_irq_disable (&dev->mt76,MT_INT_RX_DONE (0 ));napi_schedule (&dev->mt76.napi[0 ]); }if (intr &MT_INT_RX_DONE (1 )) { -mt76x2_irq_disable (dev,MT_INT_RX_DONE (1 )); +mt76x02_irq_disable (&dev->mt76,MT_INT_RX_DONE (1 ));napi_schedule (&dev->mt76.napi[1 ]); }
@@ -79,7 +67,7 @@ irqreturn_t mt76x2_irq_handler(int irq, void *dev_instance) }if (intr &MT_INT_GPTIMER ) { -mt76x2_irq_disable (dev,MT_INT_GPTIMER ); +mt76x02_irq_disable (&dev->mt76,MT_INT_GPTIMER );tasklet_schedule (&dev->dfs_pd.dfs_tasklet); }
drivers/net/wireless/mediatek/mt76/mt76x2_dfs.c +4 -3
@@ -15,6 +15,7 @@*/ #include "mt76x2.h" +#include "mt76x02_util.h" #define RADAR_SPEC(m, len, el, eh, wl, wh, \ w_tolerance, tl, th, t_tolerance, \
@@ -678,7 +679,7 @@ static void mt76x2_dfs_tasklet(unsigned long arg)mt76_wr (dev,MT_BBP (DFS ,1 ),0xf ); out: -mt76x2_irq_enable (dev,MT_INT_GPTIMER ); +mt76x02_irq_enable (&dev->mt76,MT_INT_GPTIMER ); }static void mt76x2_dfs_init_sw_detector (struct mt76x2_dev *dev)
@@ -834,7 +835,7 @@ void mt76x2_dfs_init_params(struct mt76x2_dev *dev)/* enable debug mode */ mt76x2_dfs_set_capture_mode_ctrl (dev, true); -mt76x2_irq_enable (dev,MT_INT_GPTIMER ); +mt76x02_irq_enable (&dev->mt76,MT_INT_GPTIMER );mt76_rmw_field (dev,MT_INT_TIMER_EN ,MT_INT_TIMER_EN_GP_TIMER_EN ,1 ); }else {
@@ -844,7 +845,7 @@ void mt76x2_dfs_init_params(struct mt76x2_dev *dev)mt76_wr (dev,MT_BBP (DFS ,1 ),0xf );mt76_wr (dev,0x212c ,0 ); -mt76x2_irq_disable (dev,MT_INT_GPTIMER ); +mt76x02_irq_disable (&dev->mt76,MT_INT_GPTIMER );mt76_rmw_field (dev,MT_INT_TIMER_EN ,MT_INT_TIMER_EN_GP_TIMER_EN ,0 ); }
drivers/net/wireless/mediatek/mt76/mt76x2_dma.c +4 -3
@@ -16,6 +16,7 @@#include "mt76x2.h" #include "mt76x02_dma.h" +#include "mt76x02_util.h" static int mt76x2_init_tx_queue(struct mt76x2_dev *dev, struct mt76_queue *q,
@@ -31,7 +32,7 @@ mt76x2_init_tx_queue(struct mt76x2_dev *dev, struct mt76_queue *q,if (ret)return ret; -mt76x2_irq_enable (dev,MT_INT_TX_DONE (idx)); +mt76x02_irq_enable (&dev->mt76,MT_INT_TX_DONE (idx));return 0 ; }
@@ -50,7 +51,7 @@ mt76x2_init_rx_queue(struct mt76x2_dev *dev, struct mt76_queue *q,if (ret)return ret; -mt76x2_irq_enable (dev,MT_INT_RX_DONE (idx)); +mt76x02_irq_enable (&dev->mt76,MT_INT_RX_DONE (idx));return 0 ; }
@@ -67,7 +68,7 @@ mt76x2_tx_tasklet(unsigned long data)mt76_queue_tx_cleanup (dev, i, false);mt76x2_mac_poll_tx_status (dev, false); -mt76x2_irq_enable (dev,MT_INT_TX_DONE_ALL ); +mt76x02_irq_enable (&dev->mt76,MT_INT_TX_DONE_ALL ); }int mt76x2_dma_init (struct mt76x2_dev *dev)
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +3 -3
@@ -213,8 +213,9 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX); -mt76x2_irq_enable (dev,MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | -MT_INT_TX_STAT ); +mt76x02_irq_enable (&dev->mt76, +MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | +MT_INT_TX_STAT );return 0 ; }
@@ -422,7 +423,6 @@ struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev) dev = container_of(mdev, struct mt76x2_dev, mt76); mdev->dev = pdev; mdev->drv = &drv_ops; -spin_lock_init (&dev->irq_lock);return dev; }
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +4 -4
@@ -42,9 +42,9 @@ void mt76x2_mac_poll_tx_status(struct mt76x2_dev *dev, bool irq)trace_mac_txstat_poll (dev);while (!irq || !kfifo_is_full (&dev->txstatus_fifo)) { -spin_lock_irqsave (&dev->irq_lock, flags); +spin_lock_irqsave (&dev->mt76.mmio.irq_lock, flags); ret =mt76x02_mac_load_tx_status (&dev->mt76, &stat); -spin_unlock_irqrestore (&dev->irq_lock, flags); +spin_unlock_irqrestore (&dev->mt76.mmio.irq_lock, flags);if (!ret)break ;
@@ -202,9 +202,9 @@ void mt76x2_mac_set_beacon_enable(struct mt76x2_dev *dev, u8 vif_idx, bool val)mt76_rmw (dev,MT_BEACON_TIME_CFG , reg, reg * en);if (en) -mt76x2_irq_enable (dev,MT_INT_PRE_TBTT |MT_INT_TBTT ); +mt76x02_irq_enable (&dev->mt76,MT_INT_PRE_TBTT |MT_INT_TBTT );else -mt76x2_irq_disable (dev,MT_INT_PRE_TBTT |MT_INT_TBTT ); +mt76x02_irq_disable (&dev->mt76,MT_INT_PRE_TBTT |MT_INT_TBTT ); }void mt76x2_update_channel (struct mt76_dev *mdev)
Signature · 1 line
2.17.1
PATCH 5/26 mt76: move queue initialization in mt76x02_dma.c
In reply to Lorenzo BianconiMove mt76x02_dma_init, mt76x02_init_rx_queue and mt76x02_init_tx_queue routines in mt76x02-lib module in order to be reused by mt76x0 driver
--- drivers/net/wireless/mediatek/mt76/mt76.h | 4 +- .../net/wireless/mediatek/mt76/mt76x02_dma.c | 87 +++++++++++++++++- .../net/wireless/mediatek/mt76/mt76x02_dma.h | 4 + drivers/net/wireless/mediatek/mt76/mt76x2.h | 5 +- .../net/wireless/mediatek/mt76/mt76x2_dma.c | 88 +------------------ .../net/wireless/mediatek/mt76/mt76x2_init.c | 3 +- 6 files changed, 96 insertions(+), 95 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +2 -2
@@ -518,8 +518,8 @@ static inline u16 mt76_rev(struct mt76_dev *dev)#define mt76xx_chip (dev) mt76_chip(&((dev)->mt76))#define mt76xx_rev (dev) mt76_rev(&((dev)->mt76)) -#define mt76_init_queues (dev) (dev)->mt76.queue_ops->init(&((dev)->mt76)) -#define mt76_queue_alloc (dev, ...) (dev)->mt76.queue_ops->alloc(&((dev)->mt76), __VA_ARGS__) +#define __mt76_init_queues (dev) (dev)->queue_ops->init((dev)) +#define __mt76_queue_alloc (dev, ...) (dev)->queue_ops->alloc((dev), __VA_ARGS__)#define mt76_queue_add_buf (dev, ...) (dev)->mt76.queue_ops->add_buf(&((dev)->mt76), __VA_ARGS__)#define mt76_queue_rx_reset (dev, ...) (dev)->mt76.queue_ops->rx_reset(&((dev)->mt76), __VA_ARGS__)#define mt76_queue_tx_cleanup (dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)
drivers/net/wireless/mediatek/mt76/mt76x02_dma.c +86 -1
93 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x02_dma.h +4 -0
@@ -48,6 +48,9 @@#define MT_MCU_MSG_TYPE GENMASK(31, 30)#define MT_MCU_MSG_TYPE_CMD BIT(30) +#define MT_RX_HEADROOM 32 +#define MT76X02_RX_RING_SIZE 256 +enum dma_msg_port {WLAN_PORT ,CPU_RX_PORT ,
@@ -67,6 +70,7 @@ mt76x02_wait_for_wpdma(struct mt76_dev *dev, int timeout) 0, timeout); } +int mt76x02_dma_init (struct mt76_dev *dev);void mt76x02_dma_enable (struct mt76_dev *dev);void mt76x02_dma_disable (struct mt76_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2.h +1 -4
@@ -35,9 +35,6 @@#define MT7662U_FIRMWARE "mediatek/mt7662u.bin"#define MT7662U_ROM_PATCH "mediatek/mt7662u_rom_patch.bin" -#define MT76x2_RX_RING_SIZE 256 -#define MT_RX_HEADROOM 32 -#define MT_MAX_CHAINS 2#define MT_CALIBRATE_INTERVAL HZ
@@ -165,7 +162,7 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,int mt76x2_mcu_load_cr (struct mt76x2_dev *dev,u8 type,u8 temp_level,u8 channel); -int mt76x2_dma_init (struct mt76x2_dev *dev); +void mt76x2_tx_tasklet (unsigned long data);void mt76x2_dma_cleanup (struct mt76x2_dev *dev);void mt76x2_cleanup (struct mt76x2_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2_dma.c +1 -87
100 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +2 -1
@@ -366,7 +366,7 @@ int mt76x2_init_hardware(struct mt76x2_dev *dev) dev->mt76.rxfilter =mt76_rr (dev,MT_RX_FILTR_CFG ); - ret =mt76x2_dma_init (dev); + ret =mt76x02_dma_init (&dev->mt76);if (ret)return ret;
@@ -525,6 +525,7 @@ int mt76x2_register_device(struct mt76x2_dev *dev)if (!status_fifo)return -ENOMEM ; +tasklet_init (&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long )dev);kfifo_init (&dev->txstatus_fifo, status_fifo, fifo_size);INIT_DELAYED_WORK (&dev->cal_work, mt76x2_phy_calibrate);INIT_DELAYED_WORK (&dev->mac_work, mt76x2_mac_work);
Signature · 1 line
2.17.1
PATCH 6/26 mt76: move mt76x02_beacon_offset in mt76x02_core.c
In reply to Lorenzo BianconiMove mt76x02_beacon_offset utility routine in mt76x02-lib module since it is shared between mt76x0 and mt76x2 driver and remove duplicated code. Moreover move beacon_offset data structure in mt76x02-lib module since it is shared between mt76x0 and mt76x2 drivers
--- .../net/wireless/mediatek/mt76/mt76x0/init.c | 28 +------------ .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 2 - .../net/wireless/mediatek/mt76/mt76x02_core.c | 38 +++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x02_util.h | 2 + drivers/net/wireless/mediatek/mt76/mt76x2.h | 2 - .../net/wireless/mediatek/mt76/mt76x2_init.c | 41 +------------------ .../net/wireless/mediatek/mt76/mt76x2_mac.c | 6 +-- .../net/wireless/mediatek/mt76/mt76x2u_init.c | 9 ---- 8 files changed, 45 insertions(+), 83 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1 -27
@@ -168,30 +168,13 @@ static int mt76x0_init_bbp(struct mt76x0_dev *dev)return 0 ; } -static void -mt76_init_beacon_offsets (struct mt76x0_dev *dev) -{ -u16 base =MT_BEACON_BASE ; -u32 regs[4 ] = {}; -int i; - -for (i =0 ; i <16 ; i++) { -u16 addr = dev->beacon_offsets[i]; - - regs[i /4 ] |= ((addr - base) /64 ) << (8 * (i %4 )); - } - -for (i =0 ; i <4 ; i++) -mt76_wr (dev,MT_BCN_OFFSET (i), regs[i]); -} -static void mt76x0_init_mac_registers (struct mt76x0_dev *dev) {u32 reg;RANDOM_WRITE (dev, common_mac_reg_table); -mt76_init_beacon_offsets (dev); +mt76x02_set_beacon_offsets (&dev->mt76);/* Enable PBF and MAC clock SYS_CTRL[11:10] = 0x3 */ RANDOM_WRITE (dev, mt76x0_mac_reg_table);
@@ -372,17 +355,8 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -static const u16 beacon_offsets[16 ] = { -/* 512 byte per beacon */ -0xc000 ,0xc200 ,0xc400 ,0xc600 , -0xc800 ,0xca00 ,0xcc00 ,0xce00 , -0xd000 ,0xd200 ,0xd400 ,0xd600 , -0xd800 ,0xda00 ,0xdc00 ,0xde00 - };int ret; - dev->beacon_offsets = beacon_offsets; -if (!mt76_poll_msec (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_DMA_BUSY |MT_WPDMA_GLO_CFG_RX_DMA_BUSY ,0 ,100 ))
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +0 -2
@@ -87,8 +87,6 @@ struct mt76x0_dev {spinlock_t mac_lock; -const u16 *beacon_offsets; -struct mt76x0_caldata caldata;struct mutex reg_atomic_mutex;
drivers/net/wireless/mediatek/mt76/mt76x02_core.c +38 -0
@@ -32,3 +32,41 @@ void mt76x02_set_irq_mask(struct mt76_dev *dev, u32 clear, u32 set)spin_unlock_irqrestore (&dev->mmio.irq_lock, flags); }EXPORT_SYMBOL_GPL (mt76x02_set_irq_mask); + +const u16 mt76x02_beacon_offsets[16 ] = { +/* 1024 byte per beacon */ +0xc000 , +0xc400 , +0xc800 , +0xcc00 , +0xd000 , +0xd400 , +0xd800 , +0xdc00 , +/* BSS idx 8-15 not used for beacons */ +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +}; +EXPORT_SYMBOL_GPL (mt76x02_beacon_offsets); + +void mt76x02_set_beacon_offsets (struct mt76_dev *dev) +{ +u16 val, base =MT_BEACON_BASE ; +u32 regs[4 ] = {}; +int i; + +for (i =0 ; i <16 ; i++) { + val = mt76x02_beacon_offsets[i] - base; + regs[i /4 ] |= (val /64 ) << (8 * (i %4 )); + } + +for (i =0 ; i <4 ; i++) +__mt76_wr (dev,MT_BCN_OFFSET (i), regs[i]); +} +EXPORT_SYMBOL_GPL (mt76x02_set_beacon_offsets);
drivers/net/wireless/mediatek/mt76/mt76x02_util.h +2 -0
@@ -52,6 +52,8 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q, struct mt76_queue_entry *e, bool flush);bool mt76x02_tx_status_data (struct mt76_dev *dev,u8 *update); +extern const u16 mt76x02_beacon_offsets[16 ]; +void mt76x02_set_beacon_offsets (struct mt76_dev *dev);void mt76x02_set_irq_mask (struct mt76_dev *dev,u32 clear,u32 set);static inline void mt76x02_irq_enable (struct mt76_dev *dev,u32 mask)
drivers/net/wireless/mediatek/mt76/mt76x2.h +0 -2
@@ -78,8 +78,6 @@ struct mt76x2_dev {struct mutex mutex; -const u16 *beacon_offsets; -u8 txdone_seq; DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +1 -40
61 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +3 -3
@@ -100,7 +100,7 @@ void mt76x2_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,static int mt76_write_beacon (struct mt76x2_dev *dev,int offset,struct sk_buff *skb) { -int beacon_len = dev->beacon_offsets[1 ] - dev->beacon_offsets[0 ]; +int beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ];struct mt76x02_txwi txwi;if (WARN_ON_ONCE (beacon_len < skb->len +sizeof (struct mt76x02_txwi )))
@@ -118,8 +118,8 @@ mt76_write_beacon(struct mt76x2_dev *dev, int offset, struct sk_buff *skb)static int __mt76x2_mac_set_beacon (struct mt76x2_dev *dev,u8 bcn_idx,struct sk_buff *skb) { -int beacon_len = dev->beacon_offsets[1 ] - dev->beacon_offsets[0 ]; -int beacon_addr = dev->beacon_offsets[bcn_idx]; +int beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +int beacon_addr = mt76x02_beacon_offsets[bcn_idx];int ret =0 ;int i;
drivers/net/wireless/mediatek/mt76/mt76x2u_init.c +0 -9
@@ -165,21 +165,12 @@ static void mt76x2u_init_beacon_offsets(struct mt76x2_dev *dev)int mt76x2u_init_hardware (struct mt76x2_dev *dev) { -static const u16 beacon_offsets[] = { -/* 512 byte per beacon */ -0xc000 ,0xc200 ,0xc400 ,0xc600 , -0xc800 ,0xca00 ,0xcc00 ,0xce00 , -0xd000 ,0xd200 ,0xd400 ,0xd600 , -0xd800 ,0xda00 ,0xdc00 ,0xde00 - };const struct mt76_wcid_addr addr = { .macaddr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .ba_mask =0 , };int i, err; - dev->beacon_offsets = beacon_offsets; -mt76x2_reset_wlan (dev, true);mt76x2u_power_on (dev);
Signature · 1 line
2.17.1
Re: [PATCH 06/26] mt76: move mt76x02_beacon_offset in mt76x02_core.c
Quoted 7 lines · Lorenzo Bianconi
Move
mt76x02_beacon_offsetutility routine in mt76x02-lib module since it is shared between mt76x0 and mt76x2 driver and remove duplicated code. Moreover movebeacon_offsetdata structure in mt76x02-lib module since it is shared between mt76x0 and mt76x2 driversSigned-off-by Lorenzo Bianconi <[email protected]>
<snip>
Quoted 11 lines
drivers/net/wireless/mediatek/mt76/mt76x02_core.c +11
-0+const u16 mt76x02_beacon_offsets[16 ] = { +/* 1024 byte per beacon */ +0xc000 , +0xc400 , +0xc800 , +0xcc00 , +0xd000 , +0xd400 , +0xd800 , +0xdc00 , +/* BSS idx 8-15 not used for beacons */
drivers/net/wireless/mediatek/mt76/mt76x02_core.c void mt76x02_set_irq_mask(struct mt76_dev *dev, u32 clear, u32 set) · line 56
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76x02_core.c +10
-0+0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 , +}; +EXPORT_SYMBOL_GPL (mt76x02_beacon_offsets);
I don't think this should be added to mt76x02_core.c with interrupt stuff. Interrupts are mmio specific, and beaconing are generic for both buses. Seems mt76x02_util is better place for beaconing.
Also maybe to avoid confusion mt76x02_core.c should be named mt76x02_mmio.c and contain only code for PCIe i.e. mt76x0e, mt76x2e.
Thanks
Stanislaw
Re: [PATCH 06/26] mt76: move mt76x02_beacon_offset in mt76x02_core.c
Quoted 26 lines · Lorenzo Bianconi
Quoted 7 lines
Move
mt76x02_beacon_offsetutility routine in mt76x02-lib module since it is shared between mt76x0 and mt76x2 driver and remove duplicated code. Moreover movebeacon_offsetdata structure in mt76x02-lib module since it is shared between mt76x0 and mt76x2 driversSigned-off-by Lorenzo Bianconi <[email protected]><snip>
Quoted 16 lines
drivers/net/wireless/mediatek/mt76/mt76x02_core.c +16
-0+const u16 mt76x02_beacon_offsets[16 ] = { +/* 1024 byte per beacon */ +0xc000 , +0xc400 , +0xc800 , +0xcc00 , +0xd000 , +0xd400 , +0xd800 , +0xdc00 , +/* BSS idx 8-15 not used for beacons */ +0xc000 , +0xc000 , +0xc000 , +0xc000 , +0xc000 ,
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt76x02_core.c void mt76x02_set_irq_mask(struct mt76_dev *dev, u32 clear, u32 set) · line 56
Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt76x02_core.c +5
-0+0xc000 , +0xc000 , +0xc000 , +}; +EXPORT_SYMBOL_GPL (mt76x02_beacon_offsets);I don't think this should be added to
mt76x02_core.cwith interrupt stuff. Interrupts are mmio specific, and beaconing are generic for both buses. Seemsmt76x02_utilis better place for beaconing.
ack
Quoted 3 lines
Also maybe to avoid confusion
mt76x02_core.cshould be namedmt76x02_mmio.cand contain only code for PCIe i.e. mt76x0e, mt76x2e.
ack, will do in v2
Regards,
Lorenzo
Quoted 3 lines
Thanks
Stanislaw
PATCH 7/26 mt76: mmio: add implementation of wr_rp and rd_rp
In reply to Lorenzo BianconiIntroduce mmio implementation of mt76_mmio_rd_rp and mt76_mmio_wr_rp and remove mt76x2 duplicated code. mt76_mmio_{wr,rd}_rp allows to reuse mt76x0 init code adding mt76x0e support
--- drivers/net/wireless/mediatek/mt76/mmio.c | 26 +++++++++++++++++++ .../mediatek/mt76/mt76x2_init_common.c | 15 ++--------- 2 files changed, 28 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mmio.c +26 -0
@@ -46,6 +46,30 @@ static void mt76_mmio_copy(struct mt76_dev *dev, u32 offset, const void *data,__iowrite32_copy (dev->mmio.regs + offset, data, len >>2 ); } +static int mt76_mmio_wr_rp (struct mt76_dev *dev,u32 base, +const struct mt76_reg_pair *data,int len) +{ +while (len >0 ) { +mt76_mmio_wr (dev, data->reg, data->value); + data++; + len--; + } + +return 0 ; +} + +static int mt76_mmio_rd_rp (struct mt76_dev *dev,u32 base, +struct mt76_reg_pair *data,int len) +{ +while (len >0 ) { + data->value =mt76_mmio_rr (dev, data->reg); + data++; + len--; + } + +return 0 ; +} +void mt76_mmio_init (struct mt76_dev *dev,void __iomem *regs) {static const struct mt76_bus_ops mt76_mmio_ops = {
@@ -53,6 +77,8 @@ void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs) .rmw = mt76_mmio_rmw, .wr = mt76_mmio_wr, .copy = mt76_mmio_copy, + .wr_rp = mt76_mmio_wr_rp, + .rd_rp = mt76_mmio_rd_rp, }; dev->bus = &mt76_mmio_ops;
drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c +2 -13
@@ -62,17 +62,6 @@ void mt76x2_reset_wlan(struct mt76x2_dev *dev, bool enable) }EXPORT_SYMBOL_GPL (mt76x2_reset_wlan); -static void -mt76x2_write_reg_pairs (struct mt76x2_dev *dev, -const struct mt76_reg_pair *data,int len) -{ -while (len >0 ) { -mt76_wr (dev, data->reg, data->value); - len--; - data++; - } -} -void mt76_write_mac_initvals (struct mt76x2_dev *dev) {#define DEFAULT_PROT_CFG_CCK \
@@ -164,8 +153,8 @@ void mt76_write_mac_initvals(struct mt76x2_dev *dev) { MT_GF40_PROT_CFG, DEFAULT_PROT_CFG_40 }, }; -mt76x2_write_reg_pairs (dev, vals,ARRAY_SIZE (vals)); -mt76x2_write_reg_pairs (dev, prot_vals,ARRAY_SIZE (prot_vals)); +mt76_wr_rp (dev,0 , vals,ARRAY_SIZE (vals)); +mt76_wr_rp (dev,0 , prot_vals,ARRAY_SIZE (prot_vals)); }EXPORT_SYMBOL_GPL (mt76_write_mac_initvals);
Signature · 1 line
2.17.1
PATCH 8/26 mt76: move mt76x2_wait_for_bbp in mt76x02-lib module
In reply to Lorenzo BianconiMove mt76x2_wait_for_bbp utility routine in mt76x02_util.h in order to be resued by mt76x0 driver
--- drivers/net/wireless/mediatek/mt76/mt76x02_util.h | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt76x2.h | 7 ------- drivers/net/wireless/mediatek/mt76/mt76x2u_init.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_util.h +7 -0
@@ -66,4 +66,11 @@ static inline void mt76x02_irq_disable(struct mt76_dev *dev, u32 mask) mt76x02_set_irq_mask(dev, mask, 0); } +static inline bool mt76x02_wait_for_bbp (struct mt76_dev *dev) +{ +return __mt76_poll_msec (dev,MT_MAC_STATUS , +MT_MAC_STATUS_TX |MT_MAC_STATUS_RX , +0 ,100 ); +} +#endif
drivers/net/wireless/mediatek/mt76/mt76x2.h +0 -7
@@ -124,13 +124,6 @@ static inline bool mt76x2_channel_silent(struct mt76x2_dev *dev) chan->dfs_state != NL80211_DFS_AVAILABLE); } -static inline bool mt76x2_wait_for_bbp (struct mt76x2_dev *dev) -{ -return mt76_poll_msec (dev,MT_MAC_STATUS , -MT_MAC_STATUS_TX |MT_MAC_STATUS_RX , -0 ,100 ); -} -extern const struct ieee80211_ops mt76x2_ops;struct mt76x2_dev *mt76x2_alloc_device (struct device *pdev);
drivers/net/wireless/mediatek/mt76/mt76x2u_init.c +1 -1
@@ -209,7 +209,7 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev)mt76x2u_init_beacon_offsets (dev); -if (!mt76x2_wait_for_bbp (dev)) +if (!mt76x02_wait_for_bbp (&dev->mt76))return -ETIMEDOUT ;/* reset wcid table */
Signature · 1 line
2.17.1
Re: [PATCH 08/26] mt76: move mt76x2_wait_for_bbp in mt76x02-lib module
drivers/net/wireless/mediatek/mt76/mt76x02_util.h static inline void mt76x02_irq_disable(struct mt76_dev *dev, u32 mask) · line 74
Quoted 11 lines · Lorenzo Bianconi
Move
mt76x2_wait_for_bbputility routine inmt76x02_util.hin order to be resued by mt76x0 driverSigned-off-by Lorenzo Bianconi <[email protected]>---
drivers/net/wireless/mediatek/mt76/mt76x02_util.h +6
-0+static inline bool mt76x02_wait_for_bbp (struct mt76_dev *dev) +{ +return __mt76_poll_msec (dev,MT_MAC_STATUS , +MT_MAC_STATUS_TX |MT_MAC_STATUS_RX , +0 ,100 ); +}
I think this should be renamed to
mt76x02_wait_for_txrx_busy()
or similar name, to avoid confusion and should be also used in mt76x0 to replace:
if (!mt76_poll_msec(dev, MT_MAC_STATUS,
MT_MAC_STATUS_TX | MT_MAC_STATUS_RX, 0, 1000))Regards
Stanislaw
Re: [PATCH 08/26] mt76: move mt76x2_wait_for_bbp in mt76x02-lib module
Quoted 15 lines · Stanislaw Gruszka
drivers/net/wireless/mediatek/mt76/mt76x02_util.h static inline void mt76x02_irq_disable(struct mt76_dev *dev, u32 mask) · line 74
Quoted 11 lines · Lorenzo Bianconi
Move
mt76x2_wait_for_bbputility routine inmt76x02_util.hin order to be resued by mt76x0 driverSigned-off-by Lorenzo Bianconi <[email protected]>---
drivers/net/wireless/mediatek/mt76/mt76x02_util.h +6
-0+static inline bool mt76x02_wait_for_bbp (struct mt76_dev *dev) +{ +return __mt76_poll_msec (dev,MT_MAC_STATUS , +MT_MAC_STATUS_TX |MT_MAC_STATUS_RX , +0 ,100 ); +}I think this should be renamed to
Quoted 7 lines
mt76x02_wait_for_txrx_busy()or similar name, to avoid confusion and should be also used in mt76x0 to replace:
if (!mt76_poll_msec(dev, MT_MAC_STATUS, MT_MAC_STATUS_TX | MT_MAC_STATUS_RX, 0, 1000))
ok, will do in v2
Regards,
Lorenzo
Quoted 5 lines
Regards
Stanislaw
PATCH 9/26 mt76x0: update initvals to latest version of vendor driver
In reply to Lorenzo BianconiUpdate mac/rf/dcoc initial values to latest version of vendor driver. Improve code readability
--- .../wireless/mediatek/mt76/mt76x0/initvals.h | 405 ++++++++---------- 1 file changed, 178 insertions(+), 227 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h +178 -227
@@ -2,6 +2,7 @@* (c) Copyright 2002-2010, Ralink Technology, Inc. * Copyright (C) 2015 Jakub Kicinski <[email protected]> * Copyright (C) 2018 Stanislaw Gruszka <[email protected]> +* Copyright (C) 2018 Lorenzo Bianconi <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2
@@ -19,264 +20,214 @@#include "phy.h" static const struct mt76_reg_pair common_mac_reg_table[] = { -#if 1 - {MT_BCN_OFFSET (0 ),0xf8f0e8e0 },/* 0x3800(e0), 0x3A00(e8), 0x3C00(f0), 0x3E00(f8), 512B for each beacon */ - {MT_BCN_OFFSET (1 ),0x6f77d0c8 },/* 0x3200(c8), 0x3400(d0), 0x1DC0(77), 0x1BC0(6f), 512B for each beacon */ -#endif - - {MT_LEGACY_BASIC_RATE ,0x0000013f },/* Basic rate set bitmap*/ - {MT_HT_BASIC_RATE ,0x00008003 },/* Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI.*/ - {MT_MAC_SYS_CTRL ,0x00 },/* 0x1004, , default Disable RX*/ - {MT_RX_FILTR_CFG ,0x17f97 },/*0x1400 , RX filter control, */ - {MT_BKOFF_SLOT_CFG ,0x209 },/* default set short slot time, CC_DELAY_TIME should be 2 */ -/*{TX_SW_CFG0, 0x40a06}, Gary,2006-08-23 */ - {MT_TX_SW_CFG0 ,0x0 },/* Gary,2008-05-21 for CWC test */ - {MT_TX_SW_CFG1 ,0x80606 },/* Gary,2006-08-23 */ - {MT_TX_LINK_CFG ,0x1020 },/* Gary,2006-08-23 */ -/*{TX_TIMEOUT_CFG, 0x00182090}, CCK has some problem. So increase timieout value. 2006-10-09 MArvek RT*/ - {MT_TX_TIMEOUT_CFG ,0x000a2090 },/* CCK has some problem. So increase timieout value. 2006-10-09 MArvek RT , Modify for 2860E ,2007-08-01*/ - {MT_MAX_LEN_CFG ,0xa0fff |0x00001000 },/* 0x3018, MAX frame length. Max PSDU = 16kbytes.*/ - {MT_LED_CFG ,0x7f031e46 },/* Gary, 2006-08-23*/ - - {MT_PBF_TX_MAX_PCNT ,0x1fbf1f1f /*0xbfbf3f1f*/ }, - {MT_PBF_RX_MAX_PCNT ,0x9f }, - -/*{TX_RTY_CFG, 0x6bb80408}, Jan, 2006/11/16*/ -/* WMM_ACM_SUPPORT */ -/* {TX_RTY_CFG, 0x6bb80101}, sample*/ - {MT_TX_RETRY_CFG ,0x47d01f0f },/* Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03*/ - - {MT_AUTO_RSP_CFG ,0x00000013 },/* Initial Auto_Responder, because QA will turn off Auto-Responder*/ - {MT_CCK_PROT_CFG ,0x05740003 /*0x01740003*/ },/* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */ - {MT_OFDM_PROT_CFG ,0x05740003 /*0x01740003*/ },/* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */ - {MT_PBF_CFG ,0xf40006 },/* Only enable Queue 2*/ - {MT_MM40_PROT_CFG ,0x3F44084 },/* Initial Auto_Responder, because QA will turn off Auto-Responder*/ - {MT_WPDMA_GLO_CFG ,0x00000030 }, - {MT_GF20_PROT_CFG ,0x01744004 },/* set 19:18 --> Short NAV for MIMO PS*/ - {MT_GF40_PROT_CFG ,0x03F44084 }, - {MT_MM20_PROT_CFG ,0x01744004 }, - {MT_TXOP_CTRL_CFG ,0x0000583f ,/*0x0000243f*/ /*0x000024bf*/ },/*Extension channel backoff.*/ - {MT_TX_RTS_CFG ,0x00092b20 }, - - {MT_EXP_ACK_TIME ,0x002400ca },/* default value */ - {MT_TXOP_HLDR_ET ,0x00000002 }, - -/* Jerry comments 2008/01/16: we use SIFS = 10us in CCK defaultly, but it seems that 10us -is too small for INTEL 2200bg card, so in MBSS mode, the delta time between beacon0 -and beacon1 is SIFS (10us), so if INTEL 2200bg card connects to BSS0, the ping -will always lost. So we change the SIFS of CCK from 10us to 16us. */ - {MT_XIFS_TIME_CFG ,0x33a41010 }, - {MT_PWR_PIN_CFG ,0x00000000 }, + {MT_BCN_OFFSET (0 ),0xf8f0e8e0 }, + {MT_BCN_OFFSET (1 ),0x6f77d0c8 }, + {MT_LEGACY_BASIC_RATE ,0x0000013f }, + {MT_HT_BASIC_RATE ,0x00008003 }, + {MT_MAC_SYS_CTRL ,0x00000000 }, + {MT_RX_FILTR_CFG ,0x00017f97 }, + {MT_BKOFF_SLOT_CFG ,0x00000209 }, + {MT_TX_SW_CFG0 ,0x00000000 }, + {MT_TX_SW_CFG1 ,0x00080606 }, + {MT_TX_LINK_CFG ,0x00001020 }, + {MT_TX_TIMEOUT_CFG ,0x000a2090 }, + {MT_MAX_LEN_CFG ,0xa0fff |0x00001000 }, + {MT_LED_CFG ,0x7f031e46 }, + {MT_PBF_TX_MAX_PCNT ,0x1fbf1f1f }, + {MT_PBF_RX_MAX_PCNT ,0x0000fe9f }, + {MT_TX_RETRY_CFG ,0x47d01f0f }, + {MT_AUTO_RSP_CFG ,0x00000013 }, + {MT_CCK_PROT_CFG ,0x05740003 }, + {MT_OFDM_PROT_CFG ,0x05740003 }, + {MT_PBF_CFG ,0x00f40006 }, + {MT_WPDMA_GLO_CFG ,0x00000030 }, + {MT_GF20_PROT_CFG ,0x01744004 }, + {MT_GF40_PROT_CFG ,0x03f44084 }, + {MT_MM20_PROT_CFG ,0x01744004 }, + {MT_MM40_PROT_CFG ,0x03f54084 }, + {MT_TXOP_CTRL_CFG ,0x0000583f }, + {MT_TX_RTS_CFG ,0x00092b20 }, + {MT_EXP_ACK_TIME ,0x002400ca }, + {MT_TXOP_HLDR_ET ,0x00000002 }, + {MT_XIFS_TIME_CFG ,0x33a41010 }, + {MT_PWR_PIN_CFG ,0x00000000 }, };static const struct mt76_reg_pair mt76x0_mac_reg_table[] = { -/* {MT_IOCFG_6, 0xA0040080 }, */ - {MT_PBF_SYS_CTRL ,0x00080c00 }, - {MT_PBF_CFG ,0x77723c1f }, - {MT_FCE_PSE_CTRL ,0x00000001 }, - - {MT_AMPDU_MAX_LEN_20M1S ,0xBAA99887 }, - -/* Delay bb_tx_pe for proper tx_mcs_pwr update */ - {MT_TX_SW_CFG0 ,0x00000601 }, - -/* Set rf_tx_pe deassert time to 1us by Chee's comment @MT7650_CR_setting_1018.xlsx */ - {MT_TX_SW_CFG1 ,0x00040000 }, - {MT_TX_SW_CFG2 ,0x00000000 }, - -/* disable Tx info report */ - {0xa44 ,0x0000000 }, - - {MT_HEADER_TRANS_CTRL_REG ,0x0 }, - {MT_TSO_CTRL ,0x0 }, - -/* BB_PA_MODE_CFG0(0x1214) Keep default value @20120903 */ - {MT_BB_PA_MODE_CFG1 ,0x00500055 }, - -/* RF_PA_MODE_CFG0(0x121C) Keep default value @20120903 */ - {MT_RF_PA_MODE_CFG1 ,0x00500055 }, - - {MT_TX_ALC_CFG_0 ,0x2F2F000C }, - {MT_TX0_BB_GAIN_ATTEN ,0x00000000 },/* set BBP atten gain = 0 */ - - {MT_TX_PWR_CFG_0 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_1 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_2 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_3 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_4 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_7 ,0x3A3A3A3A }, - {MT_TX_PWR_CFG_8 ,0x3A }, - {MT_TX_PWR_CFG_9 ,0x3A }, -/* Enable Tx length > 4095 byte */ - {0x150C ,0x00000002 }, - -/* Disable bt_abort_tx_en(0x1238[21] = 0) which is not used at MT7650 */ - {0x1238 ,0x001700C8 }, -/* PMU_OCLEVEL<5:1> from default <5'b10010> to <5'b11011> for normal driver */ -/* {MT_LDO_CTRL_0, 0x00A647B6}, */ - -/* Default LDO_DIG supply 1.26V, change to 1.2V */ - {MT_LDO_CTRL_1 ,0x6B006464 }, -/* -{MT_HT_BASIC_RATE, 0x00004003 }, -{MT_HT_CTRL_CFG, 0x000001FF }, -*/ + {MT_IOCFG_6 ,0xa0040080 }, + {MT_PBF_SYS_CTRL ,0x00080c00 }, + {MT_PBF_CFG ,0x77723c1f }, + {MT_FCE_PSE_CTRL ,0x00000001 }, + {MT_AMPDU_MAX_LEN_20M1S ,0xAAA99887 }, + {MT_TX_SW_CFG0 ,0x00000601 }, + {MT_TX_SW_CFG1 ,0x00040000 }, + {MT_TX_SW_CFG2 ,0x00000000 }, + {0xa44 ,0x00000000 }, + {MT_HEADER_TRANS_CTRL_REG ,0x00000000 }, + {MT_TSO_CTRL ,0x00000000 }, + {MT_BB_PA_MODE_CFG1 ,0x00500055 }, + {MT_RF_PA_MODE_CFG1 ,0x00500055 }, + {MT_TX_ALC_CFG_0 ,0x2F2F000C }, + {MT_TX0_BB_GAIN_ATTEN ,0x00000000 }, + {MT_TX_PWR_CFG_0 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_1 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_2 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_3 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_4 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_7 ,0x3A3A3A3A }, + {MT_TX_PWR_CFG_8 ,0x0000003A }, + {MT_TX_PWR_CFG_9 ,0x0000003A }, + {0x150C ,0x00000002 }, + {0x1238 ,0x001700C8 }, + {MT_LDO_CTRL_0 ,0x00A647B6 }, + {MT_LDO_CTRL_1 ,0x6B006464 }, + {MT_HT_BASIC_RATE ,0x00004003 }, + {MT_HT_CTRL_CFG ,0x000001FF }, + {MT_TXOP_HLDR_ET ,0x00000000 } }; -static const struct mt76_reg_pair mt76x0_bbp_init_tab[] = { - {MT_BBP (CORE ,1 ),0x00000002 }, - {MT_BBP (CORE ,4 ),0x00000000 }, - {MT_BBP (CORE ,24 ),0x00000000 }, - {MT_BBP (CORE ,32 ),0x4003000a }, - {MT_BBP (CORE ,42 ),0x00000000 }, - {MT_BBP (CORE ,44 ),0x00000000 }, - - {MT_BBP (IBI ,11 ),0x00000080 }, - -/* -0x2300[5] Default Antenna: -0 for WIFI main antenna -1 for WIFI aux antenna - -*/ - {MT_BBP (AGC ,0 ),0x00021400 }, - {MT_BBP (AGC ,1 ),0x00000003 }, - {MT_BBP (AGC ,2 ),0x003A6464 }, - {MT_BBP (AGC ,15 ),0x88A28CB8 }, - {MT_BBP (AGC ,22 ),0x00001E21 }, - {MT_BBP (AGC ,23 ),0x0000272C }, - {MT_BBP (AGC ,24 ),0x00002F3A }, - {MT_BBP (AGC ,25 ),0x8000005A }, - {MT_BBP (AGC ,26 ),0x007C2005 }, - {MT_BBP (AGC ,34 ),0x000A0C0C }, - {MT_BBP (AGC ,37 ),0x2121262C }, - {MT_BBP (AGC ,41 ),0x38383E45 }, - {MT_BBP (AGC ,57 ),0x00001010 }, - {MT_BBP (AGC ,59 ),0xBAA20E96 }, - {MT_BBP (AGC ,63 ),0x00000001 }, - - {MT_BBP (TXC ,0 ),0x00280403 }, - {MT_BBP (TXC ,1 ),0x00000000 }, - - {MT_BBP (RXC ,1 ),0x00000012 }, - {MT_BBP (RXC ,2 ),0x00000011 }, - {MT_BBP (RXC ,3 ),0x00000005 }, - {MT_BBP (RXC ,4 ),0x00000000 }, - {MT_BBP (RXC ,5 ),0xF977C4EC }, - {MT_BBP (RXC ,7 ),0x00000090 }, - - {MT_BBP (TXO ,8 ),0x00000000 }, - - {MT_BBP (TXBE ,0 ),0x00000000 }, - {MT_BBP (TXBE ,4 ),0x00000004 }, - {MT_BBP (TXBE ,6 ),0x00000000 }, - {MT_BBP (TXBE ,8 ),0x00000014 }, - {MT_BBP (TXBE ,9 ),0x20000000 }, - {MT_BBP (TXBE ,10 ),0x00000000 }, - {MT_BBP (TXBE ,12 ),0x00000000 }, - {MT_BBP (TXBE ,13 ),0x00000000 }, - {MT_BBP (TXBE ,14 ),0x00000000 }, - {MT_BBP (TXBE ,15 ),0x00000000 }, - {MT_BBP (TXBE ,16 ),0x00000000 }, - {MT_BBP (TXBE ,17 ),0x00000000 }, - - {MT_BBP (RXFE ,1 ),0x00008800 },/* Add for E3 */ - {MT_BBP (RXFE ,3 ),0x00000000 }, - {MT_BBP (RXFE ,4 ),0x00000000 }, - - {MT_BBP (RXO ,13 ),0x00000092 }, - {MT_BBP (RXO ,14 ),0x00060612 }, - {MT_BBP (RXO ,15 ),0xC8321B18 }, - {MT_BBP (RXO ,16 ),0x0000001E }, - {MT_BBP (RXO ,17 ),0x00000000 }, - {MT_BBP (RXO ,18 ),0xCC00A993 }, - {MT_BBP (RXO ,19 ),0xB9CB9CB9 }, - {MT_BBP (RXO ,20 ),0x26c00057 }, - {MT_BBP (RXO ,21 ),0x00000001 }, - {MT_BBP (RXO ,24 ),0x00000006 }, + {MT_BBP (CORE ,1 ),0x00000002 }, + {MT_BBP (CORE ,4 ),0x00000000 }, + {MT_BBP (CORE ,24 ),0x00000000 }, + {MT_BBP (CORE ,32 ),0x4003000a }, + {MT_BBP (CORE ,42 ),0x00000000 }, + {MT_BBP (CORE ,44 ),0x00000000 }, + {MT_BBP (IBI ,11 ),0x0FDE8081 }, + {MT_BBP (AGC ,0 ),0x00021400 }, + {MT_BBP (AGC ,1 ),0x00000003 }, + {MT_BBP (AGC ,2 ),0x003A6464 }, + {MT_BBP (AGC ,15 ),0x88A28CB8 }, + {MT_BBP (AGC ,22 ),0x00001E21 }, + {MT_BBP (AGC ,23 ),0x0000272C }, + {MT_BBP (AGC ,24 ),0x00002F3A }, + {MT_BBP (AGC ,25 ),0x8000005A }, + {MT_BBP (AGC ,26 ),0x007C2005 }, + {MT_BBP (AGC ,33 ),0x00003238 }, + {MT_BBP (AGC ,34 ),0x000A0C0C }, + {MT_BBP (AGC ,37 ),0x2121262C }, + {MT_BBP (AGC ,41 ),0x38383E45 }, + {MT_BBP (AGC ,57 ),0x00001010 }, + {MT_BBP (AGC ,59 ),0xBAA20E96 }, + {MT_BBP (AGC ,63 ),0x00000001 }, + {MT_BBP (TXC ,0 ),0x00280403 }, + {MT_BBP (TXC ,1 ),0x00000000 }, + {MT_BBP (RXC ,1 ),0x00000012 }, + {MT_BBP (RXC ,2 ),0x00000011 }, + {MT_BBP (RXC ,3 ),0x00000005 }, + {MT_BBP (RXC ,4 ),0x00000000 }, + {MT_BBP (RXC ,5 ),0xF977C4EC }, + {MT_BBP (RXC ,7 ),0x00000090 }, + {MT_BBP (TXO ,8 ),0x00000000 }, + {MT_BBP (TXBE ,0 ),0x00000000 }, + {MT_BBP (TXBE ,4 ),0x00000004 }, + {MT_BBP (TXBE ,6 ),0x00000000 }, + {MT_BBP (TXBE ,8 ),0x00000014 }, + {MT_BBP (TXBE ,9 ),0x20000000 }, + {MT_BBP (TXBE ,10 ),0x00000000 }, + {MT_BBP (TXBE ,12 ),0x00000000 }, + {MT_BBP (TXBE ,13 ),0x00000000 }, + {MT_BBP (TXBE ,14 ),0x00000000 }, + {MT_BBP (TXBE ,15 ),0x00000000 }, + {MT_BBP (TXBE ,16 ),0x00000000 }, + {MT_BBP (TXBE ,17 ),0x00000000 }, + {MT_BBP (RXFE ,1 ),0x00008800 }, + {MT_BBP (RXFE ,3 ),0x00000000 }, + {MT_BBP (RXFE ,4 ),0x00000000 }, + {MT_BBP (RXO ,13 ),0x00000192 }, + {MT_BBP (RXO ,14 ),0x00060612 }, + {MT_BBP (RXO ,15 ),0xC8321B18 }, + {MT_BBP (RXO ,16 ),0x0000001E }, + {MT_BBP (RXO ,17 ),0x00000000 }, + {MT_BBP (RXO ,18 ),0xCC00A993 }, + {MT_BBP (RXO ,19 ),0xB9CB9CB9 }, + {MT_BBP (RXO ,20 ),0x26c00057 }, + {MT_BBP (RXO ,21 ),0x00000001 }, + {MT_BBP (RXO ,24 ),0x00000006 }, + {MT_BBP (RXO ,28 ),0x0000003F }, };static const struct mt76x0_bbp_switch_item mt76x0_bbp_switch_tab[] = { - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,8 ),0x0E344EF0 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,8 ),0x122C54F2 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,4 ),0x1FEDA049 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,4 ),0x1FECA054 } }, + + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,6 ),0x00000045 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,6 ),0x0000000A } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,14 ),0x310F2E39 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,14 ),0x310F2A3F }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,8 ),0x16344EF0 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,8 ),0x122C54F2 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,32 ),0x00003230 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,32 ),0x0000181C }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,12 ),0x05052879 } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,12 ),0x050528F9 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,12 ),0x050528F9 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,33 ),0x00003240 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,33 ),0x00003218 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,13 ),0x35050004 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,13 ),0x2C3A0406 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,35 ),0x11112016 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,35 ),0x11112016 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,14 ),0x310F2E3C } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,14 ),0x310F2A3F } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (RXO ,28 ),0x0000008A }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (RXO ,28 ),0x0000008A }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,26 ),0x007C2005 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,26 ),0x007C2005 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,4 ),0x1FEDA049 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,4 ),0x1FECA054 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,27 ),0x000000E1 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,27 ),0x000000EC } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,6 ),0x00000045 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,6 ),0x0000000A }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,28 ),0x00060806 } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,28 ),0x00050806 } }, + {RF_A_BAND |RF_BW_40 , {MT_BBP (AGC ,28 ),0x00060801 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_80 , {MT_BBP (AGC ,28 ),0x00060806 } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,12 ),0x05052879 }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,12 ),0x050528F9 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,12 ),0x050528F9 }}, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (RXO ,28 ),0x0000008A } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,13 ),0x35050004 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,13 ),0x2C3A0406 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,31 ),0x00000E23 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,31 ),0x00000E13 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,27 ),0x000000E1 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,27 ),0x000000EC }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,32 ),0x00003218 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,32 ),0x0000181C } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,28 ),0x00060806 }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,28 ),0x00050806 }}, - {RF_A_BAND |RF_BW_40 , {MT_BBP (AGC ,28 ),0x00060801 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_80 , {MT_BBP (AGC ,28 ),0x00060806 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,33 ),0x00003240 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,33 ),0x00003218 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,31 ),0x00000F23 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,31 ),0x00000F13 }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,35 ),0x11111616 } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,35 ),0x11111516 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,35 ),0x11111111 } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,39 ),0x2A2A3036 }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,39 ),0x2A2A2C36 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,39 ),0x2A2A3036 }}, - {RF_A_BAND |RF_BW_80 , {MT_BBP (AGC ,39 ),0x2A2A2A36 }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,39 ),0x2A2A3036 } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,39 ),0x2A2A2C36 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,39 ),0x2A2A2A2A } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,43 ),0x27273438 }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,43 ),0x27272D38 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,43 ),0x27272B30 }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,43 ),0x27273438 } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,43 ),0x27272D38 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,43 ),0x27271A1A } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,51 ),0x17171C1C }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,51 ),0xFFFFFFFF }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,51 ),0x17171C1C } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,51 ),0xFFFFFFFF } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,53 ),0x26262A2F }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,53 ),0x2626322F }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,53 ),0xFFFFFFFF }}, + {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,53 ),0x26262A2F } }, + {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,53 ),0x2626322F } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,53 ),0xFFFFFFFF } }, - {RF_G_BAND |RF_BW_20 , {MT_BBP (AGC ,55 ),0x40404E58 }}, - {RF_G_BAND |RF_BW_40 , {MT_BBP (AGC ,55 ),0x40405858 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,55 ),0xFFFFFFFF }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,55 ),0x40404040 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,55 ),0xFFFFFFFF } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,58 ),0x00001010 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,58 ),0x00000000 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (AGC ,58 ),0x00001010 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (AGC ,58 ),0x00000000 } }, - {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (RXFE ,0 ),0x3D5000E0 }}, - {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (RXFE ,0 ),0x895000E0 }}, + {RF_G_BAND |RF_BW_20 |RF_BW_40 , {MT_BBP (RXFE ,0 ),0x3D5000E0 } }, + {RF_A_BAND |RF_BW_20 |RF_BW_40 |RF_BW_80 , {MT_BBP (RXFE ,0 ),0x895000E0 } }, };static const struct mt76_reg_pair mt76x0_dcoc_tab[] = { - {MT_BBP (CAL ,47 ),0x000010F0 }, - {MT_BBP (CAL ,48 ),0x00008080 }, - {MT_BBP (CAL ,49 ),0x00000F07 }, - {MT_BBP (CAL ,50 ),0x00000040 }, - {MT_BBP (CAL ,51 ),0x00000404 }, - {MT_BBP (CAL ,52 ),0x00080803 }, - {MT_BBP (CAL ,53 ),0x00000704 }, - {MT_BBP (CAL ,54 ),0x00002828 }, - {MT_BBP (CAL ,55 ),0x00005050 }, + {MT_BBP (CAL ,47 ),0x000010F0 }, + {MT_BBP (CAL ,48 ),0x00008080 }, + {MT_BBP (CAL ,49 ),0x00000F07 }, + {MT_BBP (CAL ,50 ),0x00000040 }, + {MT_BBP (CAL ,51 ),0x00000404 }, + {MT_BBP (CAL ,52 ),0x00080803 }, + {MT_BBP (CAL ,53 ),0x00000704 }, + {MT_BBP (CAL ,54 ),0x00002828 }, + {MT_BBP (CAL ,55 ),0x00005050 }, };#endif
Signature · 1 line
2.17.1
PATCH 10/26 mt76x0: pci: move mcu code in pci_mcu.c
In reply to Lorenzo BianconiMove pci mcu code in a dedicated source file in order to improve maintainability and facilitate new device support development
--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/mcu.h | 1 + .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 1 + .../net/wireless/mediatek/mt76/mt76x0/pci.c | 113 +------------- .../wireless/mediatek/mt76/mt76x0/pci_mcu.c | 146 ++++++++++++++++++ 5 files changed, 150 insertions(+), 113 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_mcu.c
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1 -1
@@ -6,7 +6,7 @@ mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o mt76x0u-y := usb.o -mt76x0e-y := pci.o +mt76x0e-y := pci.o pci_mcu.o # ccflags-y := -DDEBUG CFLAGS_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h +1 -0
@@ -41,6 +41,7 @@ enum mcu_calibrate { MCU_CAL_TX_GROUP_DELAY, }; +int mt76x0e_mcu_init (struct mt76x0_dev *dev);static inline int mt76x0_firmware_running (struct mt76x0_dev *dev) {return mt76_rr (dev,MT_MCU_COM_REG0 ) ==1 ;
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +1 -0
@@ -168,4 +168,5 @@ int mt76x0_tx_prepare_skb(struct mt76_dev *mdev, void *data, struct sk_buff *skb, struct mt76_queue *q, struct mt76_wcid *wcid, struct ieee80211_sta *sta, u32 *tx_info); +#endif
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +1 -112
131 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x0/pci_mcu.c new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 11/26 mt76x0: usb: move mcu code in usb_mcu.c
In reply to Lorenzo BianconiMove usb mcu code in a dedicated source file in order to remove usb dependency from generic source files and improve code maintainability
--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/mcu.h | 1 + .../net/wireless/mediatek/mt76/mt76x0/usb.c | 157 ---------------- .../wireless/mediatek/mt76/mt76x0/usb_mcu.c | 176 ++++++++++++++++++ 4 files changed, 178 insertions(+), 158 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_MT76x0_COMMON) += mt76x0-common.o mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o -mt76x0u-y := usb.o +mt76x0u-y := usb.o usb_mcu.o mt76x0e-y := pci.o pci_mcu.o # ccflags-y := -DDEBUG
drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h +1 -0
@@ -42,6 +42,7 @@ enum mcu_calibrate { };int mt76x0e_mcu_init (struct mt76x0_dev *dev); +int mt76x0u_mcu_init (struct mt76x0_dev *dev);static inline int mt76x0_firmware_running (struct mt76x0_dev *dev) {return mt76_rr (dev,MT_MCU_COM_REG0 ) ==1 ;
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +0 -157
181 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c new file +176 -0
176 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 12/26 mt76x0: use mt76x02 utility routines in mt76x0 init code
In reply to Lorenzo BianconiUse mt76x02_wait_for_wpdma and mt76x02_wait_for_mac utility routines in mt76x0_init_hardware and mt76x0_mac_start and remove duplicated code
--- .../net/wireless/mediatek/mt76/mt76x0/init.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +6 -13
@@ -19,6 +19,7 @@#include "trace.h" #include "mcu.h" #include "../mt76x02_util.h" +#include "../mt76x02_dma.h" #include "initvals.h"
@@ -273,8 +274,7 @@ int mt76x0_mac_start(struct mt76x0_dev *dev) {mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_ENABLE_TX ); -if (!mt76_poll (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_DMA_BUSY | -MT_WPDMA_GLO_CFG_RX_DMA_BUSY ,0 ,200000 )) +if (!mt76x02_wait_for_wpdma (&dev->mt76,200000 ))return -ETIMEDOUT ; dev->mt76.rxfilter = MT_RX_FILTR_CFG_CRC_ERR |
@@ -287,13 +287,9 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter);mt76_wr (dev,MT_MAC_SYS_CTRL , -MT_MAC_SYS_CTRL_ENABLE_TX |MT_MAC_SYS_CTRL_ENABLE_RX ); +MT_MAC_SYS_CTRL_ENABLE_TX |MT_MAC_SYS_CTRL_ENABLE_RX ); -if (!mt76_poll (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_DMA_BUSY | -MT_WPDMA_GLO_CFG_RX_DMA_BUSY ,0 ,50 )) -return -ETIMEDOUT ; - -return 0 ; +return !mt76x02_wait_for_wpdma (&dev->mt76,50 ) ? -ETIMEDOUT :0 ; }static void mt76x0_mac_stop_hw (struct mt76x0_dev *dev)
@@ -357,9 +353,7 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev) {int ret; -if (!mt76_poll_msec (dev,MT_WPDMA_GLO_CFG , -MT_WPDMA_GLO_CFG_TX_DMA_BUSY | -MT_WPDMA_GLO_CFG_RX_DMA_BUSY ,0 ,100 )) +if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;/* Wait for ASIC ready after FW load. */
@@ -378,8 +372,7 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)mt76x0_init_mac_registers (dev); -if (!mt76_poll_msec (dev,MT_MAC_STATUS , -MT_MAC_STATUS_TX |MT_MAC_STATUS_RX ,0 ,1000 )) +if (!mt76x02_wait_for_bbp (&dev->mt76))return -EIO ; ret =mt76x0_init_bbp (dev);
Signature · 1 line
2.17.1
PATCH 13/26 mt76x0: init: remove duplicated initialization
In reply to Lorenzo BianconiRemove MT_HEADER_TRANS_CTRL_REG/MT_TSO_CTRL configuration since they are already initialized in mt76x0_init_mac_registers routine
--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +0 -3
@@ -363,9 +363,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)mt76x0_reset_csr_bbp (dev);mt76x0_init_usb_dma (dev); -mt76_wr (dev,MT_HEADER_TRANS_CTRL_REG ,0x0 ); -mt76_wr (dev,MT_TSO_CTRL ,0x0 ); - ret =mt76x02_mcu_function_select (&dev->mt76,Q_SELECT ,1 , false);if (ret)return ret;
Signature · 1 line
2.17.1
PATCH 14/26 mt76x0: init: remove MT_PBF_SYS_CTRL configuration in mt76x0_reset_csr_bbp
In reply to Lorenzo BianconiRemove MT_PBF_SYS_CTRL configuration in mt76x0_reset_csr_bbp since it is already initialized in mt76x0_init_mac_registers routine
--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +3 -9
@@ -103,15 +103,9 @@ EXPORT_SYMBOL_GPL(mt76x0_chip_onoff);static void mt76x0_reset_csr_bbp (struct mt76x0_dev *dev) { -u32 val; - - val =mt76_rr (dev,MT_PBF_SYS_CTRL ); - val &= ~0x2000 ; -mt76_wr (dev,MT_PBF_SYS_CTRL , val); - -mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_RESET_CSR | -MT_MAC_SYS_CTRL_RESET_BBP ); - +mt76_wr (dev,MT_MAC_SYS_CTRL , +MT_MAC_SYS_CTRL_RESET_CSR | +MT_MAC_SYS_CTRL_RESET_BBP );msleep (200 ); }
Signature · 1 line
2.17.1
PATCH 15/26 mt76x0: init: reset beacon offset during bootstrap
In reply to Lorenzo BianconiAdd beacon offset reset in mt76x0e_init_hardware routine
--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +7 -1
@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -int ret; +int ret, i, j, beacon_len;if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;
@@ -385,6 +385,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_BEACON_TX)); + beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +for (i =0 ; i <8 ; i++) { +for (j =0 ; j < beacon_len; j +=4 ) +mt76_wr (dev, mt76x02_beacon_offsets[i] + j,0 ); + } +mt76x0_reset_counters (dev);mt76_rmw (dev,MT_US_CYC_CFG ,MT_US_CYC_CNT ,0x1e );
Signature · 1 line
2.17.1
Re: [PATCH 15/26] mt76x0: init: reset beacon offset during bootstrap
Quoted 21 lines · Lorenzo Bianconi
Add beacon offset reset in
mt76x0e_init_hardwareroutineSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1
-1@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -int ret; +int ret, i, j, beacon_len;if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;
drivers/net/wireless/mediatek/mt76/mt76x0/init.c int mt76x0_init_hardware(struct mt76x0_dev *dev) · line 393
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +6
-0@@ -385,6 +385,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_BEACON_TX)); + beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +for (i =0 ; i <8 ; i++) { +for (j =0 ; j < beacon_len; j +=4 ) +mt76_wr (dev, mt76x02_beacon_offsets[i] + j,0 ); + } +
This seems to ba fix for
"mt76: move mt76x02_beacon_offset in mt76x02_core.c"
please add "Fixes:" tag or merge this patch into previous one.
Thanks
Stanislaw
Re: [PATCH 15/26] mt76x0: init: reset beacon offset during bootstrap
Quoted 34 lines · Stanislaw Gruszka
Quoted 21 lines · Lorenzo Bianconi
Add beacon offset reset in
mt76x0e_init_hardwareroutineSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1
-1@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -int ret; +int ret, i, j, beacon_len;if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;drivers/net/wireless/mediatek/mt76/mt76x0/init.c int mt76x0_init_hardware(struct mt76x0_dev *dev) · line 393
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +6
-0@@ -385,6 +385,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_BEACON_TX)); + beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +for (i =0 ; i <8 ; i++) { +for (j =0 ; j < beacon_len; j +=4 ) +mt76_wr (dev, mt76x02_beacon_offsets[i] + j,0 ); + } +This seems to ba fix for
Quoted 1 line
"mt76: move
mt76x02_beacon_offsetinmt76x02_core.c"
I will double-check vendor driver but I guess this is in usb code as well, so I will add a 'Fixes' tag
Regards,
Lorenzo
Quoted 5 lines
please add "Fixes:" tag or merge this patch into previous one.
Thanks
Stanislaw
Felix Fietkau
maintainerRe: [PATCH 15/26] mt76x0: init: reset beacon offset during bootstrap
In reply to Lorenzo BianconiQuoted 21 lines · Lorenzo Bianconi
Add beacon offset reset in
mt76x0e_init_hardwareroutineSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1
-1@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -int ret; +int ret, i, j, beacon_len;if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;
drivers/net/wireless/mediatek/mt76/mt76x0/init.c int mt76x0_init_hardware(struct mt76x0_dev *dev) · line 392
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +5
-0@@ -385,6 +385,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_BEACON_TX)); + beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +for (i =0 ; i <8 ; i++) { +for (j =0 ; j < beacon_len; j +=4 ) +mt76_wr (dev, mt76x02_beacon_offsets[i] + j,0 ); +
That looks a bit convoluted. Do we really need to clear beacon memory? If we do need it, how about simply clearing the entire scratch space instead of looping over beacon offsets?
- Felix
Re: [PATCH 15/26] mt76x0: init: reset beacon offset during bootstrap
Quoted 25 lines · Felix Fietkau
Quoted 24 lines · Lorenzo Bianconi
Add beacon offset reset in
mt76x0e_init_hardwareroutineSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1
-1@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) { -int ret; +int ret, i, j, beacon_len;if (!mt76x02_wait_for_wpdma (&dev->mt76,1000 ))return -EIO ;@@ -385,6 +385,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)MT_BEACON_TIME_CFG_TBTT_EN | MT_BEACON_TIME_CFG_BEACON_TX));
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt76x0/init.c int mt76x0_init_hardware(struct mt76x0_dev *dev) · line 393
Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +5
-0+ beacon_len = mt76x02_beacon_offsets[1 ] - mt76x02_beacon_offsets[0 ]; +for (i =0 ; i <8 ; i++) { +for (j =0 ; j < beacon_len; j +=4 ) +mt76_wr (dev, mt76x02_beacon_offsets[i] + j,0 ); +That looks a bit convoluted. Do we really need to clear beacon memory? If we do need it, how about simply clearing the entire scratch space instead of looping over beacon offsets?
ack, will do in v2.
Regards,
Lorenzo
Quoted 3 lines
- Felix
PATCH 16/26 mt76x0: init rx filter in mt76x0_init_hardware
In reply to Lorenzo BianconiInitialize rxfilter mask at bootstrap an not at mac start. This is a preliminary patch to share mt76x2_mac_start routine between mt76x2e and mt76x0e drivers
--- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 10 ++-------- drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +2 -8
@@ -271,15 +271,7 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)if (!mt76x02_wait_for_wpdma (&dev->mt76,200000 ))return -ETIMEDOUT ; - dev->mt76.rxfilter =MT_RX_FILTR_CFG_CRC_ERR | -MT_RX_FILTR_CFG_PHY_ERR |MT_RX_FILTR_CFG_PROMISC | -MT_RX_FILTR_CFG_VER_ERR |MT_RX_FILTR_CFG_DUP | -MT_RX_FILTR_CFG_CFACK |MT_RX_FILTR_CFG_CFEND | -MT_RX_FILTR_CFG_ACK |MT_RX_FILTR_CFG_CTS | -MT_RX_FILTR_CFG_RTS |MT_RX_FILTR_CFG_PSPOLL | -MT_RX_FILTR_CFG_BA |MT_RX_FILTR_CFG_CTRL_RSV ;mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter); -mt76_wr (dev,MT_MAC_SYS_CTRL ,MT_MAC_SYS_CTRL_ENABLE_TX |MT_MAC_SYS_CTRL_ENABLE_RX );
@@ -370,6 +362,8 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)if (ret)return ret; + dev->mt76.rxfilter =mt76_rr (dev,MT_RX_FILTR_CFG ); + ret =mt76x0_init_wcid_mem (dev);if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt76x0/main.c +9 -0
@@ -73,6 +73,15 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)mt76x0_phy_set_txpower (dev); } +if (changed &IEEE80211_CONF_CHANGE_MONITOR ) { +if (!(hw->conf.flags &IEEE80211_CONF_MONITOR )) + dev->mt76.rxfilter |=MT_RX_FILTR_CFG_PROMISC ; +else + dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_PROMISC ; + +mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter); + } +mutex_unlock (&dev->mt76.mutex);return ret;
Signature · 1 line
2.17.1
PATCH 17/26 mt76: add mt76x02_mac_start routine
In reply to Lorenzo BianconiIntroduce mt76x02_mac_start since the mac start code is shared between mt76x0e and mt76x2 drivers.
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 15 +++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x02_mac.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 12 +----------- 3 files changed, 17 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +15 -0
@@ -18,6 +18,8 @@#include "mt76.h" #include "mt76x02_regs.h" #include "mt76x02_mac.h" +#include "mt76x02_dma.h" +#include "mt76x02_util.h" enum mt76x02_cipher_type mt76x02_mac_get_key_info (struct ieee80211_key_conf *key,u8 *key_data)
@@ -520,3 +522,16 @@ void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr) FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff)); }EXPORT_SYMBOL_GPL (mt76x02_mac_setaddr); + +void mt76x02_mac_start (struct mt76_dev *dev) +{ +mt76x02_dma_enable (dev); +__mt76_wr (dev,MT_RX_FILTR_CFG , dev->rxfilter); +__mt76_wr (dev,MT_MAC_SYS_CTRL , +MT_MAC_SYS_CTRL_ENABLE_TX | +MT_MAC_SYS_CTRL_ENABLE_RX ); +mt76x02_irq_enable (dev, +MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | +MT_INT_TX_STAT ); +} +EXPORT_SYMBOL_GPL (mt76x02_mac_start);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +1 -0
@@ -203,4 +203,5 @@ void mt76x02_send_tx_status(struct mt76_dev *dev,int mt76x02_mac_process_rate (struct mt76_rx_status *status,u16 rate);void mt76x02_mac_setaddr (struct mt76_dev *dev,u8 *addr); +void mt76x02_mac_start (struct mt76_dev *dev);#endif
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +1 -11
@@ -188,17 +188,7 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)mt76_rr (dev,MT_TX_STAT_FIFO );memset (dev->aggr_stats,0 ,sizeof (dev->aggr_stats)); - -mt76x02_dma_enable (&dev->mt76); -mt76_wr (dev,MT_RX_FILTR_CFG , dev->mt76.rxfilter); - -mt76_wr (dev,MT_MAC_SYS_CTRL , -MT_MAC_SYS_CTRL_ENABLE_TX | -MT_MAC_SYS_CTRL_ENABLE_RX ); - -mt76x02_irq_enable (&dev->mt76, -MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | -MT_INT_TX_STAT ); +mt76x02_mac_start (&dev->mt76);return 0 ; }
Signature · 1 line
2.17.1
Re: [PATCH 17/26] mt76: add mt76x02_mac_start routine
Quoted 29 lines · Lorenzo Bianconi
Introduce
mt76x02_mac_startsince the mac start code is shared between mt76x0e and mt76x2 drivers.Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 15 +++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x02_mac.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 12 +----------- 3 files changed, 17 insertions(+), 11 deletions(-)drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +4
-0@@ -18,6 +18,8 @@#include "mt76.h" #include "mt76x02_regs.h" #include "mt76x02_mac.h" +#include "mt76x02_dma.h" +#include "mt76x02_util.h" enum mt76x02_cipher_type mt76x02_mac_get_key_info (struct ieee80211_key_conf *key,u8 *key_data)@@ -520,3 +522,16 @@ void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr) FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff)); }EXPORT_SYMBOL_GPL (mt76x02_mac_setaddr); + +void mt76x02_mac_start (struct mt76_dev *dev)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr) · line 536
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +10
-0+{ +mt76x02_dma_enable (dev); +__mt76_wr (dev,MT_RX_FILTR_CFG , dev->rxfilter); +__mt76_wr (dev,MT_MAC_SYS_CTRL , +MT_MAC_SYS_CTRL_ENABLE_TX | +MT_MAC_SYS_CTRL_ENABLE_RX ); +mt76x02_irq_enable (dev, +MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | +MT_INT_TX_STAT ); +}
irq_enable is PCIe specific (also mt76x02_dma_enable() seems to be PCIe specifc). I think this should be not mixed within generic code and perhaps the function name prefix should be mt76x02e_ .
Thanks
Stanislaw
Re: [PATCH 17/26] mt76: add mt76x02_mac_start routine
Quoted 15 lines · Lorenzo Bianconi
Quoted 14 lines
enum
mt76x02_cipher_type
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +8
-0@@ -520,3 +522,16 @@ void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr) FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff)); }EXPORT_SYMBOL_GPL (mt76x02_mac_setaddr); + +void mt76x02_mac_start (struct mt76_dev *dev) +{ +mt76x02_dma_enable (dev); +__mt76_wr (dev,MT_RX_FILTR_CFG , dev->rxfilter); +__mt76_wr (dev,MT_MAC_SYS_CTRL , +MT_MAC_SYS_CTRL_ENABLE_TX | +MT_MAC_SYS_CTRL_ENABLE_RX );
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr) · line 536
Quoted 4 lines
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +4
-0+mt76x02_irq_enable (dev, +MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_ALL | +MT_INT_TX_STAT ); +}
irq_enableis PCIe specific (alsomt76x02_dma_enable()seems to be PCIe specifc). I think this should be not mixed within generic code and perhaps the function name prefix should bemt76x02e_.
ack, I will move them in mt76x02_mmio.c but I would prefer to maintain name convetion we are using so far.
Regards,
Lorenzo
Quoted 4 lines
Thanks
Stanislaw
PATCH 18/26 mt76x0: usb: move initialization code in usb_init.c
In reply to Lorenzo BianconiMove usb initialization code in a mt76x0 module in order to remove usb dependency from generic init code (not completed yet). Moreover fix a memory leak in usb probe if mt76x02_wait_for_mac fails
--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/init.c | 54 --------- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 4 +- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 28 +---- .../wireless/mediatek/mt76/mt76x0/usb_init.c | 107 ++++++++++++++++++ 5 files changed, 115 insertions(+), 80 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/usb_init.c
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_MT76x0_COMMON) += mt76x0-common.o mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o -mt76x0u-y := usb.o usb_mcu.o +mt76x0u-y := usb.o usb_mcu.o usb_init.o mt76x0e-y := pci.o pci_mcu.o # ccflags-y := -DDEBUG
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +0 -54
90 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +3 -1
@@ -130,12 +130,14 @@ struct mt76x0_dev * mt76x0_alloc_device(struct device *pdev, const struct mt76_driver_ops *drv_ops);int mt76x0_init_hardware (struct mt76x0_dev *dev);int mt76x0_register_device (struct mt76x0_dev *dev); -void mt76x0_cleanup (struct mt76x0_dev *dev);void mt76x0_chip_onoff (struct mt76x0_dev *dev,bool enable,bool reset);int mt76x0_mac_start (struct mt76x0_dev *dev);void mt76x0_mac_stop (struct mt76x0_dev *dev); +void mt76x0u_cleanup (struct mt76x0_dev *dev); +int mt76x0u_register_device (struct mt76x0_dev *dev); +/* PHY */ void mt76x0_phy_init (struct mt76x0_dev *dev);int mt76x0_wait_bbp_ready (struct mt76x0_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +4 -24
@@ -98,32 +98,12 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,if (!(mt76_rr (dev,MT_EFUSE_CTRL ) &MT_EFUSE_CTRL_SEL ))dev_warn (dev->mt76.dev,"Warning: eFUSE not present\n" ); - ret =mt76u_alloc_queues (&dev->mt76); + ret =mt76x0u_register_device (dev);if (ret <0 ) goto err; - ret =mt76u_mcu_init_rx (&dev->mt76); -if (ret <0 ) - goto err; - -mt76x0_chip_onoff (dev, true, true); - -if (!mt76x02_wait_for_mac (&dev->mt76)) -return -ETIMEDOUT ; - - ret =mt76x0u_mcu_init (dev); -if (ret) - goto err_hw; - - ret =mt76x0_register_device (dev); -if (ret) - goto err_hw; - -set_bit (MT76_STATE_INITIALIZED , &dev->mt76.state); -return 0 ; -err_hw: -mt76x0_cleanup (dev); + err:usb_set_intfdata (usb_intf,NULL );usb_put_dev (interface_to_usbdev (usb_intf));
@@ -141,7 +121,7 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf)return ;ieee80211_unregister_hw (dev->mt76.hw); -mt76x0_cleanup (dev); +mt76x0u_cleanup (dev);usb_set_intfdata (usb_intf,NULL );usb_put_dev (interface_to_usbdev (usb_intf));
@@ -190,7 +170,7 @@ static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf)return 0 ; err: -mt76x0_cleanup (dev); +mt76x0u_cleanup (dev);return ret; }
drivers/net/wireless/mediatek/mt76/mt76x0/usb_init.c new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 19/26 mt76x0: pci: add hw initialization at bootstrap
In reply to Lorenzo BianconiAdd mt76x0e_register_device routine in pci_init.c
to initialize the device during hw probe.
--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/init.c | 10 +-- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 2 + .../net/wireless/mediatek/mt76/mt76x0/pci.c | 2 +- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 65 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.h | 1 + 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1 -1
@@ -6,7 +6,7 @@ mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o mt76x0u-y := usb.o usb_mcu.o usb_init.o -mt76x0e-y := pci.o pci_mcu.o +mt76x0e-y := pci.o pci_mcu.o pci_init.o # ccflags-y := -DDEBUG CFLAGS_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +3 -7
@@ -107,6 +107,9 @@ static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev)MT_MAC_SYS_CTRL_RESET_CSR | MT_MAC_SYS_CTRL_RESET_BBP);msleep (200 ); +mt76_clear (dev,MT_MAC_SYS_CTRL , +MT_MAC_SYS_CTRL_RESET_CSR | +MT_MAC_SYS_CTRL_RESET_BBP ); }#define RANDOM_WRITE (dev, tab) \
@@ -152,13 +155,6 @@ static void mt76x0_init_mac_registers(struct mt76x0_dev *dev) reg &= ~0x3 ;mt76_wr (dev,MT_MAC_SYS_CTRL , reg); -if (is_mt7610e (dev)) { -/* Disable COEX_EN */ - reg =mt76_rr (dev,MT_COEXCFG0 ); - reg &=0xFFFFFFFE ; -mt76_wr (dev,MT_COEXCFG0 , reg); - } -/* Set 0x141C[15:12]=0xF */ reg =mt76_rr (dev,MT_EXT_CCA_CFG ); reg |=0x0000F000 ;
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +2 -0
@@ -138,6 +138,8 @@ void mt76x0_mac_stop(struct mt76x0_dev *dev);void mt76x0u_cleanup (struct mt76x0_dev *dev);int mt76x0u_register_device (struct mt76x0_dev *dev); +int mt76x0e_register_device (struct mt76x0_dev *dev); +/* PHY */ void mt76x0_phy_init (struct mt76x0_dev *dev);int mt76x0_wait_bbp_ready (struct mt76x0_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +1 -1
@@ -50,7 +50,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev->mt76.rev =mt76_rr (dev,MT_ASIC_VERSION );dev_info (dev->mt76.dev,"ASIC revision: %08x\n" , dev->mt76.rev); - ret =mt76x0e_mcu_init (dev); + ret =mt76x0e_register_device (dev);if (ret <0 ) goto error;
drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c new file +65 -0
65 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h +1 -0
@@ -107,6 +107,7 @@ enum mt76x02_eeprom_field {#define MT_EE_NIC_CONF_0_PA_TYPE GENMASK(9, 8)#define MT_EE_NIC_CONF_0_PA_INT_2G BIT(8)#define MT_EE_NIC_CONF_0_PA_INT_5G BIT(9) +#define MT_EE_NIC_CONF_0_PA_IO_CURRENT BIT(10)#define MT_EE_NIC_CONF_0_BOARD_TYPE GENMASK(13, 12)#define MT_EE_NIC_CONF_1_HW_RF_CTRL BIT(0)
Signature · 1 line
2.17.1
Re: [PATCH 19/26] mt76x0: pci: add hw initialization at bootstrap
Quoted 19 lines · Lorenzo Bianconi
Add
mt76x0e_register_deviceroutine inpci_init.c
to initialize the device during hw probe.Signed-off-by Lorenzo Bianconi <[email protected]>--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/init.c | 10 +-- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 2 + .../net/wireless/mediatek/mt76/mt76x0/pci.c | 2 +- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 65 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.h | 1 + 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.cdrivers/net/wireless/mediatek/mt76/mt76x0/Makefile +0
-0
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile mt76x0-common-y := \ · line 9
Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1
-1@@ -6,7 +6,7 @@ mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o mt76x0u-y := usb.o usb_mcu.o usb_init.o -mt76x0e-y := pci.o pci_mcu.o +mt76x0e-y := pci.o pci_mcu.o pci_init.o
How much {pci,usb}_{init,mcu}.c files are expected to grow? For now they are about between 100 and 200 lines of code and I do not see reason to move code into separate files so far. It could be easy placed in usb.c and pci.c files. But if the files will grow, I'm ok with code moving.
Thanks
Stanislaw
Re: [PATCH 19/26] mt76x0: pci: add hw initialization at bootstrap
Quoted 15 lines · Lorenzo Bianconi
Quoted 14 lines
Add
mt76x0e_register_deviceroutine inpci_init.c
to initialize the device during hw probe.Signed-off-by Lorenzo Bianconi <[email protected]>--- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/init.c | 10 +-- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 2 + .../net/wireless/mediatek/mt76/mt76x0/pci.c | 2 +- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 65 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.h | 1 + 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c
Quoted 16 lines
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile mt76x0-common-y := \ · line 9
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +1
-1@@ -6,7 +6,7 @@ mt76x0-common-y := \ init.o main.o trace.o eeprom.o phy.o \ mac.o debugfs.o tx.o mt76x0u-y := usb.o usb_mcu.o usb_init.o -mt76x0e-y := pci.o pci_mcu.o +mt76x0e-y := pci.o pci_mcu.o pci_init.oHow much {pci,usb}_{init,mcu}.c files are expected to grow? For now they are about between 100 and 200 lines of code and I do not see reason to move code into separate files so far. It could be easy placed in
usb.candpci.cfiles. But if the files will grow, I'm ok with code moving.
At the moment I do not know how much {pci,usb}_{init,mcu}.c will grow, I guess a little bit more. Anyway I would prefer to have in {pci/usb}.c just bus specific code (but it is a matter of taste actually)
Regards,
Lorenzo
Quoted 3 lines
Thanks
Stanislaw
PATCH 20/26 mt76x0: phy: set antenna parameter according to wireless band
In reply to Lorenzo BianconiMove mt76x0_ant_select routine in __mt76x0_phy_set_channel in order to configure antenna parameters according to the current wireless channel
--- .../net/wireless/mediatek/mt76/mt76x0/phy.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +20 -11
@@ -548,6 +548,25 @@ mt76x0_phy_set_chan_bbp_params(struct mt76x0_dev *dev, u8 channel, u16 rf_bw_ban } } +static void mt76x0_ant_select (struct mt76x0_dev *dev) +{ +struct ieee80211_channel *chan = dev->mt76.chandef.chan; + +/* single antenna mode */ +if (chan->band ==NL80211_BAND_2GHZ ) { +mt76_rmw (dev,MT_COEXCFG3 , +BIT (5 ) |BIT (4 ) |BIT (3 ) |BIT (2 ),BIT (1 )); +mt76_rmw (dev,MT_WLAN_FUN_CTRL ,BIT (5 ),BIT (6 )); + }else { +mt76_rmw (dev,MT_COEXCFG3 ,BIT (5 ) |BIT (2 ), +BIT (4 ) |BIT (3 )); +mt76_clear (dev,MT_WLAN_FUN_CTRL , +BIT (6 ) |BIT (5 )); + } +mt76_clear (dev,MT_CMB_CTRL ,BIT (14 ) |BIT (12 )); +mt76_clear (dev,MT_COEXCFG0 ,BIT (2 )); +} +static void mt76x0_bbp_set_bw (struct mt76x0_dev *dev,enum nl80211_chan_width width) {
@@ -658,6 +677,7 @@ __mt76x0_phy_set_channel(struct mt76x0_dev *dev,mt76x0_bbp_set_bw (dev, chandef->width);mt76x0_bbp_set_ctrlch (dev, chandef->width, ch_group_index);mt76x0_mac_set_ctrlch (dev, ch_group_index &1 ); +mt76x0_ant_select (dev); mt76_rmw(dev, MT_EXT_CCA_CFG, (MT_EXT_CCA_CFG_CCA0 |
@@ -915,21 +935,10 @@ mt76x0_rf_init(struct mt76x0_dev *dev)rf_set (dev,MT_RF (0 ,4 ),0x80 ); } -static void mt76x0_ant_select (struct mt76x0_dev *dev) -{ -/* Single antenna mode. */ -mt76_rmw (dev,MT_WLAN_FUN_CTRL ,BIT (5 ),BIT (6 )); -mt76_clear (dev,MT_CMB_CTRL ,BIT (14 ) |BIT (12 )); -mt76_clear (dev,MT_COEXCFG0 ,BIT (2 )); -mt76_rmw (dev,MT_COEXCFG3 ,BIT (5 ) |BIT (4 ) |BIT (3 ) |BIT (2 ),BIT (1 )); -} -void mt76x0_phy_init (struct mt76x0_dev *dev) {INIT_DELAYED_WORK (&dev->cal_work, mt76x0_phy_calibrate); -mt76x0_ant_select (dev); -mt76x0_rf_init (dev);mt76x0_set_rx_chains (dev);
Signature · 1 line
2.17.1
PATCH 21/26 mt76: move set_{tx,rx}_path routines in mt76x02-lib module
In reply to Lorenzo BianconiMove mt76x02_phy_set_rxpath and mt76x02_phy_tx_dac routines in mt76x02_phy.c since they are shared between mt76x2 and mt76x0 drivers. Moreover move chainmask variable from mt76x2/mt76x0 to mt76_dev data structure
--- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + .../wireless/mediatek/mt76/mt76x0/eeprom.c | 2 +- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 1 - .../net/wireless/mediatek/mt76/mt76x0/phy.c | 31 +-------------- .../net/wireless/mediatek/mt76/mt76x02_phy.c | 38 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x02_phy.h | 2 + drivers/net/wireless/mediatek/mt76/mt76x2.h | 2 - .../mediatek/mt76/mt76x2_init_common.c | 2 +- .../net/wireless/mediatek/mt76/mt76x2_main.c | 2 +- .../mediatek/mt76/mt76x2_mcu_common.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2u.h | 2 - .../net/wireless/mediatek/mt76/mt76x2u_init.c | 5 ++- .../net/wireless/mediatek/mt76/mt76x2u_phy.c | 33 ---------------- 13 files changed, 50 insertions(+), 73 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -404,6 +404,7 @@ struct mt76_dev {unsigned long state;u8 antenna_mask; +u16 chainmask;struct mt76_sband sband_2g;struct mt76_sband sband_5g;
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c +1 -1
@@ -313,7 +313,7 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev)mt76x0_set_freq_offset (dev);mt76x0_set_temp_offset (dev); - dev->chainmask =0x0101 ; + dev->mt76.chainmask =0x0101 ;return 0 ; }
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +0 -1
@@ -104,7 +104,6 @@ struct mt76x0_dev {int avg_rssi;/* starts at 0 and converges */ u8 agc_save; -u16 chainmask;bool no_2ghz;
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +2 -29
@@ -855,32 +855,6 @@ void mt76x0_phy_con_cal_onoff(struct mt76x0_dev *dev,spin_unlock_bh (&dev->con_mon_lock); } -static void -mt76x0_set_rx_chains (struct mt76x0_dev *dev) -{ -u32 val; - - val =mt76_rr (dev,MT_BBP (AGC ,0 )); - val &= ~(BIT (3 ) |BIT (4 )); - -if (dev->chainmask &BIT (1 )) - val |=BIT (3 ); - -mt76_wr (dev,MT_BBP (AGC ,0 ), val); - -mb (); - val =mt76_rr (dev,MT_BBP (AGC ,0 )); -} - -static void -mt76x0_set_tx_dac (struct mt76x0_dev *dev) -{ -if (dev->chainmask &BIT (1 )) -mt76_set (dev,MT_BBP (TXBE ,5 ),3 ); -else -mt76_clear (dev,MT_BBP (TXBE ,5 ),3 ); -} -static void mt76x0_rf_init (struct mt76x0_dev *dev) {
@@ -940,7 +914,6 @@ void mt76x0_phy_init(struct mt76x0_dev *dev)INIT_DELAYED_WORK (&dev->cal_work, mt76x0_phy_calibrate);mt76x0_rf_init (dev); - -mt76x0_set_rx_chains (dev); -mt76x0_set_tx_dac (dev); +mt76x02_phy_set_rxpath (&dev->mt76); +mt76x02_phy_set_txdac (&dev->mt76); }
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c +38 -0
@@ -20,6 +20,44 @@#include "mt76.h" #include "mt76x02_phy.h" +void mt76x02_phy_set_rxpath (struct mt76_dev *dev) +{ +u32 val; + + val =__mt76_rr (dev,MT_BBP (AGC ,0 )); + val &= ~BIT (4 ); + +switch (dev->chainmask &0xf ) { +case 2 : + val |=BIT (3 ); +break ; +default : + val &= ~BIT (3 ); +break ; + } + +__mt76_wr (dev,MT_BBP (AGC ,0 ), val); +mb (); + val =__mt76_rr (dev,MT_BBP (AGC ,0 )); +} +EXPORT_SYMBOL_GPL (mt76x02_phy_set_rxpath); + +void mt76x02_phy_set_txdac (struct mt76_dev *dev) +{ +int txpath; + + txpath = (dev->chainmask >>8 ) &0xf ; +switch (txpath) { +case 2 : +__mt76_set (dev,MT_BBP (TXBE ,5 ),0x3 ); +break ; +default : +__mt76_clear (dev,MT_BBP (TXBE ,5 ),0x3 ); +break ; + } +} +EXPORT_SYMBOL_GPL (mt76x02_phy_set_txdac); +static u32 mt76x02_tx_power_mask (u8 v1,u8 v2,u8 v3,u8 v4) {
drivers/net/wireless/mediatek/mt76/mt76x02_phy.h +2 -0
@@ -23,5 +23,7 @@ void mt76x02_add_rate_power_offset(struct mt76_rate_power *r, int offset);void mt76x02_phy_set_txpower (struct mt76_dev *dev,int txp_0,int txp_2);void mt76x02_limit_rate_power (struct mt76_rate_power *r,int limit);int mt76x02_get_max_rate_power (struct mt76_rate_power *r); +void mt76x02_phy_set_rxpath (struct mt76_dev *dev); +void mt76x02_phy_set_txdac (struct mt76_dev *dev);#endif /* __MT76x02_PHY_H */
drivers/net/wireless/mediatek/mt76/mt76x2.h +0 -2
@@ -97,8 +97,6 @@ struct mt76x2_dev {u8 tbtt_count;u16 beacon_int; -u16 chainmask; -struct mt76x2_calibration cal;s8 target_power;
drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c +1 -1
@@ -177,7 +177,7 @@ void mt76x2_init_device(struct mt76x2_dev *dev) dev->mt76.sband_2g.sband.ht_cap.cap |=IEEE80211_HT_CAP_LDPC_CODING ; dev->mt76.sband_5g.sband.ht_cap.cap |=IEEE80211_HT_CAP_LDPC_CODING ; - dev->chainmask =0x202 ; + dev->mt76.chainmask =0x202 ; dev->mt76.global_wcid.idx =255 ; dev->mt76.global_wcid.hw_key_idx =-1 ; dev->slottime =9 ;
drivers/net/wireless/mediatek/mt76/mt76x2_main.c +1 -1
@@ -241,7 +241,7 @@ static int mt76x2_set_antenna(struct ieee80211_hw *hw, u32 tx_ant,mutex_lock (&dev->mt76.mutex); - dev->chainmask = (tx_ant ==3 ) ?0x202 :0x101 ; + dev->mt76.chainmask = (tx_ant ==3 ) ?0x202 :0x101 ; dev->mt76.antenna_mask = tx_ant;mt76_set_stream_caps (&dev->mt76, true);
drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c +1 -1
@@ -42,7 +42,7 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw, .idx = channel, .scan = scan, .bw = bw, - .chainmask = cpu_to_le16(dev->chainmask), + .chainmask = cpu_to_le16(dev->mt76.chainmask), };/* first set the channel without the extension channel info */
drivers/net/wireless/mediatek/mt76/mt76x2u.h +0 -2
@@ -45,8 +45,6 @@ int mt76x2u_phy_set_channel(struct mt76x2_dev *dev, struct cfg80211_chan_def *chandef);void mt76x2u_phy_calibrate (struct work_struct *work);void mt76x2u_phy_channel_calibrate (struct mt76x2_dev *dev); -void mt76x2u_phy_set_txdac (struct mt76x2_dev *dev); -void mt76x2u_phy_set_rxpath (struct mt76x2_dev *dev);void mt76x2u_mcu_complete_urb (struct urb *urb); int mt76x2u_mcu_set_dynamic_vga(struct mt76x2_dev *dev, u8 channel, bool ap,
drivers/net/wireless/mediatek/mt76/mt76x2u_init.c +3 -2
@@ -18,6 +18,7 @@#include "mt76x2u.h" #include "mt76x02_util.h" +#include "mt76x02_phy.h" #include "mt76x2_eeprom.h" static void mt76x2u_init_dma (struct mt76x2_dev *dev)
@@ -236,8 +237,8 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev)if (err <0 )return err; -mt76x2u_phy_set_rxpath (dev); -mt76x2u_phy_set_txdac (dev); +mt76x02_phy_set_rxpath (&dev->mt76); +mt76x02_phy_set_txdac (&dev->mt76);return mt76x2u_mac_stop (dev); }
drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c +0 -33
@@ -17,39 +17,6 @@#include "mt76x2u.h" #include "mt76x2_eeprom.h" -void mt76x2u_phy_set_rxpath (struct mt76x2_dev *dev) -{ -u32 val; - - val =mt76_rr (dev,MT_BBP (AGC ,0 )); - val &= ~BIT (4 ); - -switch (dev->chainmask &0xf ) { -case 2 : - val |=BIT (3 ); -break ; -default : - val &= ~BIT (3 ); -break ; - } -mt76_wr (dev,MT_BBP (AGC ,0 ), val); -} - -void mt76x2u_phy_set_txdac (struct mt76x2_dev *dev) -{ -int txpath; - - txpath = (dev->chainmask >>8 ) &0xf ; -switch (txpath) { -case 2 : -mt76_set (dev,MT_BBP (TXBE ,5 ),0x3 ); -break ; -default : -mt76_clear (dev,MT_BBP (TXBE ,5 ),0x3 ); -break ; - } -} -void mt76x2u_phy_channel_calibrate (struct mt76x2_dev *dev) {struct ieee80211_channel *chan = dev->mt76.chandef.chan;
Signature · 1 line
2.17.1
PATCH 22/26 mt76x0: add ieee80211_ops ops pointer to mt76x0_alloc_device signature
In reply to Lorenzo BianconiAdd ieee80211_ops ops pointer to mt76x0_alloc_device routine signature in order to specify mac80211 callbacks and remove usb dependency from mt76x0 generic code.
Move mt76x0_ops callbacks in usb module in order to remove leftover usb dependency in mt76x0 generic code.
Introduce mt76x0e_ops mac80211 callbacks for pci code
--- .../net/wireless/mediatek/mt76/mt76x0/init.c | 38 ++-------- .../net/wireless/mediatek/mt76/mt76x0/main.c | 75 +++++-------------- .../wireless/mediatek/mt76/mt76x0/mt76x0.h | 20 ++++- .../net/wireless/mediatek/mt76/mt76x0/pci.c | 2 +- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 20 +++++ .../net/wireless/mediatek/mt76/mt76x0/tx.c | 1 + .../net/wireless/mediatek/mt76/mt76x0/usb.c | 5 +- .../wireless/mediatek/mt76/mt76x0/usb_init.c | 66 ++++++++++++++++ 8 files changed, 137 insertions(+), 90 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +8 -30
@@ -246,23 +246,13 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)return !mt76x02_wait_for_wpdma (&dev->mt76,50 ) ? -ETIMEDOUT :0 ; } +EXPORT_SYMBOL_GPL (mt76x0_mac_start); -static void mt76x0_mac_stop_hw (struct mt76x0_dev *dev) +void mt76x0_mac_stop (struct mt76x0_dev *dev) { -int i, ok; - -if (test_bit (MT76_REMOVED , &dev->mt76.state)) -return ; - -mt76_clear (dev,MT_BEACON_TIME_CFG ,MT_BEACON_TIME_CFG_TIMER_EN | -MT_BEACON_TIME_CFG_SYNC_MODE |MT_BEACON_TIME_CFG_TBTT_EN | -MT_BEACON_TIME_CFG_BEACON_TX ); - -if (!mt76_poll (dev,MT_USB_DMA_CFG ,MT_USB_DMA_CFG_TX_BUSY ,0 ,1000 )) -dev_warn (dev->mt76.dev,"Warning: TX DMA did not stop!\n" ); +int i =200 , ok =0 ;/* Page count on TxQ */ - i =200 ;while (i-- && ((mt76_rr (dev,0x0438 ) &0xffffffff ) || (mt76_rr (dev,0x0a30 ) &0x000000ff ) || (mt76_rr (dev,0x0a34 ) &0x00ff00ff )))
@@ -275,9 +265,7 @@ static void mt76x0_mac_stop_hw(struct mt76x0_dev *dev) MT_MAC_SYS_CTRL_ENABLE_TX);/* Page count on RxQ */ - ok =0 ; - i =200 ; -while (i--) { +for (i =0 ; i <200 ; i++) {if (!(mt76_rr (dev,MT_RXQ_STA ) &0x00ff0000 ) && !mt76_rr (dev,0x0a30 ) && !mt76_rr (dev,0x0a34 )) {
@@ -290,19 +278,7 @@ static void mt76x0_mac_stop_hw(struct mt76x0_dev *dev)if (!mt76_poll (dev,MT_MAC_STATUS ,MT_MAC_STATUS_RX ,0 ,1000 ))dev_warn (dev->mt76.dev,"Warning: MAC RX did not stop!\n" ); - -if (!mt76_poll (dev,MT_USB_DMA_CFG ,MT_USB_DMA_CFG_RX_BUSY ,0 ,1000 )) -dev_warn (dev->mt76.dev,"Warning: RX DMA did not stop!\n" ); -} - -void mt76x0_mac_stop (struct mt76x0_dev *dev) -{ -cancel_delayed_work_sync (&dev->cal_work); -cancel_delayed_work_sync (&dev->mac_work); -mt76u_stop_stat_wk (&dev->mt76); -mt76x0_mac_stop_hw (dev); } -EXPORT_SYMBOL_GPL (mt76x0_mac_stop);int mt76x0_init_hardware (struct mt76x0_dev *dev) {
@@ -365,12 +341,14 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)EXPORT_SYMBOL_GPL (mt76x0_init_hardware);struct mt76x0_dev * -mt76x0_alloc_device (struct device *pdev,const struct mt76_driver_ops *drv_ops) +mt76x0_alloc_device (struct device *pdev, +const struct mt76_driver_ops *drv_ops, +const struct ieee80211_ops *ops) {struct mt76x0_dev *dev;struct mt76_dev *mdev; - mdev =mt76_alloc_device (sizeof (*dev), &mt76x0_ops); + mdev =mt76_alloc_device (sizeof (*dev), ops);if (!mdev)return NULL ;
drivers/net/wireless/mediatek/mt76/mt76x0/main.c +20 -55
130 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +18 -2
@@ -110,7 +110,8 @@ struct mt76x0_dev {struct mac_stats stats; }; -extern const struct ieee80211_ops mt76x0_ops; +extern const struct ieee80211_ops mt76x0u_ops; +extern const struct ieee80211_ops mt76x0e_ops;static inline bool is_mt7610e (struct mt76x0_dev *dev) {
@@ -126,7 +127,9 @@ void mt76x0_init_debugfs(struct mt76x0_dev *dev);/* Init */ struct mt76x0_dev * -mt76x0_alloc_device (struct device *pdev,const struct mt76_driver_ops *drv_ops); +mt76x0_alloc_device (struct device *pdev, +const struct mt76_driver_ops *drv_ops, +const struct ieee80211_ops *ops);int mt76x0_init_hardware (struct mt76x0_dev *dev);int mt76x0_register_device (struct mt76x0_dev *dev);void mt76x0_chip_onoff (struct mt76x0_dev *dev,bool enable,bool reset);
@@ -134,8 +137,21 @@ void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset);int mt76x0_mac_start (struct mt76x0_dev *dev);void mt76x0_mac_stop (struct mt76x0_dev *dev); +void mt76x0_start (struct mt76x0_dev *dev); +void mt76x0_stop (struct mt76x0_dev *dev); +int mt76x0_config (struct ieee80211_hw *hw,u32 changed); +void mt76x0_bss_info_changed (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_bss_conf *info,u32 changed); +void mt76x0_sw_scan (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +const u8 *mac_addr); +void mt76x0_sw_scan_complete (struct ieee80211_hw *hw, +struct ieee80211_vif *vif); +int mt76x0_set_rts_threshold (struct ieee80211_hw *hw,u32 value); +void mt76x0u_cleanup (struct mt76x0_dev *dev);int mt76x0u_register_device (struct mt76x0_dev *dev); +void mt76x0u_mac_stop (struct mt76x0_dev *dev);int mt76x0e_register_device (struct mt76x0_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +1 -1
@@ -41,7 +41,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (ret)return ret; - dev =mt76x0_alloc_device (&pdev->dev,NULL ); + dev =mt76x0_alloc_device (&pdev->dev,NULL , &mt76x0e_ops);if (!dev)return -ENOMEM ;
drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c +20 -0
@@ -19,6 +19,26 @@#include "mt76x0.h" #include "mcu.h" #include "../mt76x02_dma.h" +#include "../mt76x02_util.h" + +static int mt76x0e_start (struct ieee80211_hw *hw) +{ +return 0 ; +} + +static void mt76x0e_stop (struct ieee80211_hw *hw) +{ +} + +const struct ieee80211_ops mt76x0e_ops = { + .tx = mt76x0_tx, + .start = mt76x0e_start, + .stop = mt76x0e_stop, + .config = mt76x0_config, + .add_interface = mt76x02_add_interface, + .remove_interface = mt76x02_remove_interface, + .configure_filter = mt76x02_configure_filter, +};int mt76x0e_register_device (struct mt76x0_dev *dev) {
drivers/net/wireless/mediatek/mt76/mt76x0/tx.c +1 -0
@@ -81,6 +81,7 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,mt76_tx (&dev->mt76, control->sta, wcid, skb); } +EXPORT_SYMBOL_GPL (mt76x0_tx); int mt76x0_tx_prepare_skb(struct mt76_dev *mdev, void *data, struct sk_buff *skb, struct mt76_queue *q,
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +3 -2
@@ -63,7 +63,8 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,u32 asic_rev, mac_rev;int ret; - dev =mt76x0_alloc_device (&usb_intf->dev, &drv_ops); + dev =mt76x0_alloc_device (&usb_intf->dev, &drv_ops, + &mt76x0u_ops);if (!dev)return -ENOMEM ;
@@ -136,7 +137,7 @@ static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,struct mt76_usb *usb = &dev->mt76.usb;mt76u_stop_queues (&dev->mt76); -mt76x0_mac_stop (dev); +mt76x0u_mac_stop (dev);usb_kill_urb (usb->mcu.res.urb);return 0 ;
drivers/net/wireless/mediatek/mt76/mt76x0/usb_init.c +66 -0
72 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 23/26 mt76x0: pci: add mt76x0e_start callback
In reply to Lorenzo BianconiIntroduce mt76x0e_start mac80211 callback to start device mac opening the netdevice
--- drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c +9 -0
@@ -23,6 +23,15 @@static int mt76x0e_start (struct ieee80211_hw *hw) { +struct mt76x0_dev *dev = hw->priv; + +mutex_lock (&dev->mt76.mutex); + +mt76x02_mac_start (&dev->mt76); +mt76x0_start (dev); + +mutex_unlock (&dev->mt76.mutex); +return 0 ; }
Signature · 1 line
2.17.1
PATCH 24/26 mt76x0: pci: add mt76x0e_stop callback
In reply to Lorenzo BianconiIntroduce mt76x0e_stop mac80211 callback to stop
device mac closing the netdevice
--- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c +17 -0
@@ -37,6 +37,23 @@ static int mt76x0e_start(struct ieee80211_hw *hw)static void mt76x0e_stop (struct ieee80211_hw *hw) { +struct mt76x0_dev *dev = hw->priv; + +mutex_lock (&dev->mt76.mutex); + +if (!mt76_poll (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_DMA_BUSY , +0 ,1000 )) +dev_warn (dev->mt76.dev,"TX DMA did not stop\n" ); +mt76_clear (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_TX_DMA_EN ); + +mt76x0_stop (dev); + +if (!mt76_poll (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_RX_DMA_BUSY , +0 ,1000 )) +dev_warn (dev->mt76.dev,"TX DMA did not stop\n" ); +mt76_clear (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_RX_DMA_EN ); + +mutex_unlock (&dev->mt76.mutex); }const struct ieee80211_ops mt76x0e_ops = {
Signature · 1 line
2.17.1
PATCH 25/26 mt76: move eeprom_load routines in mt76x02_eeprom.c
In reply to Lorenzo BianconiMove mt76x02_eeprom_load, mt76x02_check_eeprom, mt76x02_apply_cal_free_data and mt76x02_has_cal_free_data in mt76x02-lib module since they will be used to load mt76x0e eeprom data
--- .../wireless/mediatek/mt76/mt76x02_eeprom.c | 152 +++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.h | 1 + .../wireless/mediatek/mt76/mt76x2_eeprom.c | 157 +----------------- 3 files changed, 154 insertions(+), 156 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c +152 -0
@@ -154,3 +154,155 @@ u8 mt76x02_get_lna_gain(struct mt76_dev *dev,return lna !=0xff ? lna :0 ; }EXPORT_SYMBOL_GPL (mt76x02_get_lna_gain); + +static bool mt76x02_has_cal_free_data (u8 *efuse) +{ +u16 *efuse_w = (u16 *) efuse; + +if (efuse_w[MT_EE_NIC_CONF_0 ] !=0 ) +return false; + +if (efuse_w[MT_EE_XTAL_TRIM_1 ] ==0xffff ) +return false; + +if (efuse_w[MT_EE_TX_POWER_DELTA_BW40 ] !=0 ) +return false; + +if (efuse_w[MT_EE_TX_POWER_0_START_2G ] ==0xffff ) +return false; + +if (efuse_w[MT_EE_TX_POWER_0_GRP3_TX_POWER_DELTA ] !=0 ) +return false; + +if (efuse_w[MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE ] ==0xffff ) +return false; + +return true; +} + +static void mt76x02_apply_cal_free_data (struct mt76_dev *dev,u8 *efuse) +{ +#define GROUP_5G (_id) \ + MT_EE_TX_POWER_0_START_5G + MT_TX_POWER_GROUP_SIZE_5G * (_id), \ + MT_EE_TX_POWER_0_START_5G + MT_TX_POWER_GROUP_SIZE_5G * (_id) + 1, \ + MT_EE_TX_POWER_1_START_5G + MT_TX_POWER_GROUP_SIZE_5G * (_id), \ + MT_EE_TX_POWER_1_START_5G + MT_TX_POWER_GROUP_SIZE_5G * (_id) + 1 + +static const u8 cal_free_bytes[] = { +MT_EE_XTAL_TRIM_1 , +MT_EE_TX_POWER_EXT_PA_5G +1 , +MT_EE_TX_POWER_0_START_2G , +MT_EE_TX_POWER_0_START_2G +1 , +MT_EE_TX_POWER_1_START_2G , +MT_EE_TX_POWER_1_START_2G +1 , +GROUP_5G (0 ), +GROUP_5G (1 ), +GROUP_5G (2 ), +GROUP_5G (3 ), +GROUP_5G (4 ), +GROUP_5G (5 ), +MT_EE_RF_2G_TSSI_OFF_TXPOWER , +MT_EE_RF_2G_RX_HIGH_GAIN +1 , +MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN , +MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN +1 , +MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN , +MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN +1 , +MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN , +MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN +1 , + }; +u8 *eeprom = dev->eeprom.data; +u8 prev_grp0[4 ] = { + eeprom[MT_EE_TX_POWER_0_START_5G ], + eeprom[MT_EE_TX_POWER_0_START_5G +1 ], + eeprom[MT_EE_TX_POWER_1_START_5G ], + eeprom[MT_EE_TX_POWER_1_START_5G +1 ] + }; +u16 val; +int i; + +if (!mt76x02_has_cal_free_data (efuse)) +return ; + +for (i =0 ; i <ARRAY_SIZE (cal_free_bytes); i++) { +int offset = cal_free_bytes[i]; + + eeprom[offset] = efuse[offset]; + } + +if (!(efuse[MT_EE_TX_POWER_0_START_5G ] | + efuse[MT_EE_TX_POWER_0_START_5G +1 ])) +memcpy (eeprom +MT_EE_TX_POWER_0_START_5G , prev_grp0,2 ); +if (!(efuse[MT_EE_TX_POWER_1_START_5G ] | + efuse[MT_EE_TX_POWER_1_START_5G +1 ])) +memcpy (eeprom +MT_EE_TX_POWER_1_START_5G , prev_grp0 +2 ,2 ); + + val =get_unaligned_le16 (efuse +MT_EE_BT_RCAL_RESULT ); +if (val !=0xffff ) + eeprom[MT_EE_BT_RCAL_RESULT ] = val &0xff ; + + val =get_unaligned_le16 (efuse +MT_EE_BT_VCDL_CALIBRATION ); +if (val !=0xffff ) + eeprom[MT_EE_BT_VCDL_CALIBRATION +1 ] = val >>8 ; + + val =get_unaligned_le16 (efuse +MT_EE_BT_PMUCFG ); +if (val !=0xffff ) + eeprom[MT_EE_BT_PMUCFG ] = val &0xff ; +} + +static int mt76x02_check_eeprom (struct mt76_dev *dev) +{ +u16 val =get_unaligned_le16 (dev->eeprom.data); + +if (!val) + val =get_unaligned_le16 (dev->eeprom.data +MT_EE_PCI_ID ); + +switch (val) { +case 0x7662 : +case 0x7612 : +return 0 ; +default : +dev_err (dev->dev,"EEPROM data check failed: %04x\n" , val); +return -EINVAL ; + } +} + +int mt76x02_eeprom_load (struct mt76_dev *dev,int eeprom_size) +{ +void *efuse; +bool found; +int ret; + + ret =mt76_eeprom_init (dev, eeprom_size); +if (ret <0 ) +return ret; + + found = ret; +if (found) + found = !mt76x02_check_eeprom (dev); + + dev->otp.data =devm_kzalloc (dev->dev, eeprom_size,GFP_KERNEL ); + dev->otp.size = eeprom_size; +if (!dev->otp.data) +return -ENOMEM ; + + efuse = dev->otp.data; + +if (mt76x02_get_efuse_data (dev,0 , efuse, eeprom_size, +MT_EE_READ )) + goto out; + +if (found) { +mt76x02_apply_cal_free_data (dev, efuse); + }else { +/* FIXME: check if efuse data is complete */ + found = true; +memcpy (dev->eeprom.data, efuse, eeprom_size); + } + +out: +if (!found) +return -ENOENT ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt76x02_eeprom_load);
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h +1 -0
@@ -207,5 +207,6 @@ u8 mt76x02_get_lna_gain(struct mt76_dev *dev, s8 *lna_2g, s8 *lna_5g, struct ieee80211_channel *chan);void mt76x02_eeprom_parse_hw_cap (struct mt76_dev *dev); +int mt76x02_eeprom_load (struct mt76_dev *dev,int eeprom_size);#endif /* __MT76x02_EEPROM_H */
drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c +1 -156
169 lines not on this page · raw message
Signature · 1 line
2.17.1
Felix Fietkau
maintainerRe: [PATCH 25/26] mt76: move eeprom_load routines in mt76x02_eeprom.c
Quoted 6 lines · Lorenzo Bianconi
Move
mt76x02_eeprom_load,mt76x02_check_eeprom,mt76x02_apply_cal_free_dataandmt76x02_has_cal_free_datain mt76x02-lib module since they will be used to load mt76x0e eeprom dataSigned-off-by Lorenzo Bianconi <[email protected]>
This patch should be dropped. Almost all of the code is inherently 76x2 specific and does not belong into common 76x02 code.
- Felix
Re: [PATCH 25/26] mt76: move eeprom_load routines in mt76x02_eeprom.c
Quoted 9 lines · Lorenzo Bianconi
Quoted 6 lines
Move
mt76x02_eeprom_load,mt76x02_check_eeprom,mt76x02_apply_cal_free_dataandmt76x02_has_cal_free_datain mt76x02-lib module since they will be used to load mt76x0e eeprom dataSigned-off-by Lorenzo Bianconi <[email protected]>This patch should be dropped. Almost all of the code is inherently 76x2 specific and does not belong into common 76x02 code.
reviewing the code I think we can merge 25/26 and 26/26. Will do in v2
Regards,
Lorenzo
Quoted 2 lines
- Felix
PATCH 26/26 mt76x0: introduce mt76x0{e,u}_eeprom_init routines
In reply to Lorenzo BianconiAdd mt76x0e_eeprom_init/mt76x0u_eeprom_init routines to initialize pci/usb eeprom and move eeprom init shared code between pci and usb drivers in mt76x0_eeprom_init
--- .../wireless/mediatek/mt76/mt76x0/eeprom.c | 19 +++------------ .../wireless/mediatek/mt76/mt76x0/eeprom.h | 1 + .../net/wireless/mediatek/mt76/mt76x0/init.c | 5 ---- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 15 ++++++++++++ .../wireless/mediatek/mt76/mt76x0/usb_init.c | 24 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.c | 2 ++ 6 files changed, 45 insertions(+), 21 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c +3 -16
@@ -24,8 +24,7 @@#include "../mt76x02_phy.h" #define MT_MAP_READS DIV_ROUND_UP(MT_EFUSE_USAGE_MAP_SIZE, 16) -static int -mt76x0_efuse_physical_size_check (struct mt76x0_dev *dev) +int mt76x0_efuse_physical_size_check (struct mt76x0_dev *dev) {u8 data[MT_MAP_READS *16 ];int ret, i;
@@ -52,6 +51,7 @@ mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)return 0 ; } +EXPORT_SYMBOL_GPL (mt76x0_efuse_physical_size_check);static void mt76x0_set_chip_cap (struct mt76x0_dev *dev) {
@@ -281,20 +281,6 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev) {u8 version, fae;u16 data; -int ret; - - ret =mt76x0_efuse_physical_size_check (dev); -if (ret) -return ret; - - ret =mt76_eeprom_init (&dev->mt76,MT76X0_EEPROM_SIZE ); -if (ret <0 ) -return ret; - - ret =mt76x02_get_efuse_data (&dev->mt76,0 , dev->mt76.eeprom.data, -MT76X0_EEPROM_SIZE ,MT_EE_READ ); -if (ret) -return ret; data =mt76x02_eeprom_get (&dev->mt76,MT_EE_VERSION ); version = data >>8 ;
@@ -317,5 +303,6 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev)return 0 ; } +EXPORT_SYMBOL_GPL (mt76x0_eeprom_init);MODULE_LICENSE ("Dual BSD/GPL" );
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h +1 -0
@@ -35,6 +35,7 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev);void mt76x0_read_rx_gain (struct mt76x0_dev *dev);void mt76x0_get_tx_power_per_rate (struct mt76x0_dev *dev);void mt76x0_get_power_info (struct mt76x0_dev *dev,u8 *info); +int mt76x0_efuse_physical_size_check (struct mt76x0_dev *dev);static inline s8 s6_to_s8 (u32 val) {
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +0 -5
@@ -329,11 +329,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev) }mt76x0_reset_counters (dev); - - ret =mt76x0_eeprom_init (dev); -if (ret) -return ret; -mt76x0_phy_init (dev);return 0 ;
drivers/net/wireless/mediatek/mt76/mt76x0/pci_init.c +15 -0
@@ -66,6 +66,17 @@ const struct ieee80211_ops mt76x0e_ops = { .configure_filter = mt76x02_configure_filter, }; +static int mt76x0e_eeprom_init (struct mt76x0_dev *dev) +{ +int err; + + err =mt76x02_eeprom_load (&dev->mt76,MT76X0_EEPROM_SIZE ); +if (err <0 ) +return err; + +return mt76x0_eeprom_init (dev); +} +int mt76x0e_register_device (struct mt76x0_dev *dev) {int err;
@@ -79,6 +90,10 @@ int mt76x0e_register_device(struct mt76x0_dev *dev)if (err <0 )return err; + err =mt76x0e_eeprom_init (dev); +if (err <0 ) +return err; + err =mt76x02_dma_init (&dev->mt76);if (err <0 )return err;
drivers/net/wireless/mediatek/mt76/mt76x0/usb_init.c +24 -0
@@ -120,6 +120,26 @@ void mt76x0u_cleanup(struct mt76x0_dev *dev)mt76u_mcu_deinit (&dev->mt76); } +static int mt76x0u_eeprom_init (struct mt76x0_dev *dev) +{ +int err; + + err =mt76x0_efuse_physical_size_check (dev); +if (err <0 ) +return err; + + err =mt76_eeprom_init (&dev->mt76,MT76X0_EEPROM_SIZE ); +if (err <0 ) +return err; + + err =mt76x02_get_efuse_data (&dev->mt76,0 , dev->mt76.eeprom.data, +MT76X0_EEPROM_SIZE ,MT_EE_READ ); +if (err <0 ) +return err; + +return mt76x0_eeprom_init (dev); +} +int mt76x0u_register_device (struct mt76x0_dev *dev) {struct ieee80211_hw *hw = dev->mt76.hw;
@@ -139,6 +159,10 @@ int mt76x0u_register_device(struct mt76x0_dev *dev) goto err; } + err =mt76x0u_eeprom_init (dev); +if (err <0 ) +return err; + err =mt76x0u_mcu_init (dev);if (err <0 ) goto err;
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c +2 -0
@@ -259,6 +259,8 @@ static int mt76x02_check_eeprom(struct mt76_dev *dev)switch (val) {case 0x7662 :case 0x7612 : +case 0x7650 : +case 0x7610 :return 0 ;default :dev_err (dev->dev,"EEPROM data check failed: %04x\n" , val);
Signature · 1 line
2.17.1