]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mt76x0: pci: add hw initialization at bootstrap
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Fri, 28 Sep 2018 11:39:01 +0000 (13:39 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 1 Oct 2018 10:34:37 +0000 (12:34 +0200)
Add mt76x0e_register_device routine in pci.c
to initialize the device during hw probe.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/init.c
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h

index 1d20ed56d201a9aecc541abfd9e57143e2dc7b63..5ec0ee6ce38db84fbd33b7bd55e736631deece95 100644 (file)
@@ -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;
index 99d142319d1cb93af4fb698b34594bc473c15c9a..79db75811458c6ed53ca1c944bc8fbdf481d6236 100644 (file)
 
 #include "mt76x0.h"
 #include "mcu.h"
+#include "../mt76x02_dma.h"
+
+static int mt76x0e_register_device(struct mt76x0_dev *dev)
+{
+       int err;
+
+       mt76x0_chip_onoff(dev, true, false);
+       if (!mt76x02_wait_for_mac(&dev->mt76))
+               return -ETIMEDOUT;
+
+       mt76x02_dma_disable(&dev->mt76);
+       err = mt76x0e_mcu_init(dev);
+       if (err < 0)
+               return err;
+
+       err = mt76x02_dma_init(&dev->mt76);
+       if (err < 0)
+               return err;
+
+       err = mt76x0_init_hardware(dev);
+       if (err < 0)
+               return err;
+
+       if (mt76_chip(&dev->mt76) == 0x7610) {
+               u16 val;
+
+               mt76_clear(dev, MT_COEXCFG0, BIT(0));
+               val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0);
+               if (val & MT_EE_NIC_CONF_0_PA_IO_CURRENT) {
+                       u32 data;
+
+                       /* set external external PA I/O
+                        * current to 16mA
+                        */
+                       data = mt76_rr(dev, 0x11c);
+                       val |= 0xc03;
+                       mt76_wr(dev, 0x11c, val);
+               }
+       }
+
+       mt76_clear(dev, 0x110, BIT(9));
+       mt76_set(dev, MT_MAX_LEN_CFG, BIT(13));
+
+       return 0;
+}
 
 static int
 mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -50,7 +95,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;
 
index b45e2afeadd0f8770a5b2ea8ac922d70f9fd56bb..bcd05f7c5f45dd62082868e0825ee2640379a6d3 100644 (file)
@@ -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)