rtl8xxxu: Identify chip vendors correctly
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 29 Feb 2016 22:04:00 +0000 (17:04 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 10 Mar 2016 13:28:52 +0000 (15:28 +0200)
This identifies the chip vendors correctly and also picks the correct
firmware for rtl8192eu.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h

index bb95d00f0565395ecc70482820839c2f7fe59d95..745942299f41b448104b8dbaa9962544870f9440 100644 (file)
@@ -1662,16 +1662,24 @@ static void rtl8xxxu_print_chipinfo(struct rtl8xxxu_priv *priv)
        case 1:
                cut = "B";
                break;
+       case 2:
+               cut = "C";
+               break;
+       case 3:
+               cut = "D";
+               break;
+       case 4:
+               cut = "E";
+               break;
        default:
                cut = "unknown";
        }
 
        dev_info(dev,
                 "RTL%s rev %s (%s) %iT%iR, TX queues %i, WiFi=%i, BT=%i, GPS=%i, HI PA=%i\n",
-                priv->chip_name, cut, priv->vendor_umc ? "UMC" : "TSMC",
-                priv->tx_paths, priv->rx_paths, priv->ep_tx_count,
-                priv->has_wifi, priv->has_bluetooth, priv->has_gps,
-                priv->hi_pa);
+                priv->chip_name, cut, priv->chip_vendor, priv->tx_paths,
+                priv->rx_paths, priv->ep_tx_count, priv->has_wifi,
+                priv->has_bluetooth, priv->has_gps, priv->hi_pa);
 
        dev_info(dev, "RTL%s MAC: %pM\n", priv->chip_name, priv->mac_addr);
 }
@@ -1708,7 +1716,21 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
        } else if (val32 & SYS_CFG_TYPE_ID) {
                bonding = rtl8xxxu_read32(priv, REG_HPON_FSM);
                bonding &= HPON_FSM_BONDING_MASK;
-               if (bonding == HPON_FSM_BONDING_1T2R) {
+               if (priv->chip_cut >= 3) {
+                       if (bonding == HPON_FSM_BONDING_1T2R) {
+                               sprintf(priv->chip_name, "8191EU");
+                               priv->rf_paths = 2;
+                               priv->rx_paths = 2;
+                               priv->tx_paths = 1;
+                               priv->rtlchip = 0x8191e;
+                       } else {
+                               sprintf(priv->chip_name, "8192EU");
+                               priv->rf_paths = 2;
+                               priv->rx_paths = 2;
+                               priv->tx_paths = 2;
+                               priv->rtlchip = 0x8192e;
+                       }
+               } else if (bonding == HPON_FSM_BONDING_1T2R) {
                        sprintf(priv->chip_name, "8191CU");
                        priv->rf_paths = 2;
                        priv->rx_paths = 2;
@@ -1731,8 +1753,34 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
                priv->has_wifi = 1;
        }
 
-       if (val32 & SYS_CFG_VENDOR_ID)
-               priv->vendor_umc = 1;
+       switch (priv->rtlchip) {
+       case 0x8188e:
+       case 0x8192e:
+       case 0x8723b:
+               switch (val32 & SYS_CFG_VENDOR_EXT_MASK) {
+               case SYS_CFG_VENDOR_ID_TSMC:
+                       sprintf(priv->chip_vendor, "TSMC");
+                       break;
+               case SYS_CFG_VENDOR_ID_SMIC:
+                       sprintf(priv->chip_vendor, "SMIC");
+                       priv->vendor_smic = 1;
+                       break;
+               case SYS_CFG_VENDOR_ID_UMC:
+                       sprintf(priv->chip_vendor, "UMC");
+                       priv->vendor_umc = 1;
+                       break;
+               default:
+                       sprintf(priv->chip_vendor, "unknown");
+               }
+               break;
+       default:
+               if (val32 & SYS_CFG_VENDOR_ID) {
+                       sprintf(priv->chip_vendor, "UMC");
+                       priv->vendor_umc = 1;
+               } else {
+                       sprintf(priv->chip_vendor, "TSMC");
+               }
+       }
 
        val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS);
        priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28;
@@ -1934,7 +1982,7 @@ static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv)
                                 raw[i + 6], raw[i + 7]);
                }
        }
-       return -EINVAL;
+       return 0;
 }
 
 static int
@@ -2269,6 +2317,7 @@ static int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name)
 
        signature = le16_to_cpu(priv->fw_data->signature);
        switch (signature & 0xfff0) {
+       case 0x92e0:
        case 0x92c0:
        case 0x88c0:
        case 0x2300:
@@ -2338,13 +2387,7 @@ static int rtl8192eu_load_firmware(struct rtl8xxxu_priv *priv)
        char *fw_name;
        int ret;
 
-       return -EBUSY;
-       if (!priv->vendor_umc)
-               fw_name = "rtlwifi/rtl8192cufw_TMSC.bin";
-       else if (priv->chip_cut || priv->rtlchip == 0x8192c)
-               fw_name = "rtlwifi/rtl8192cufw_B.bin";
-       else
-               fw_name = "rtlwifi/rtl8192cufw_A.bin";
+       fw_name = "rtlwifi/rtl8192eu_nic.bin";
 
        ret = rtl8xxxu_load_firmware(priv, fw_name);
 
index 8168a35c314cf7556c13352dbd647c39a52764f7..0d4ff80f0ab177f959ac2cf36a97e370b85deeb4 100644 (file)
@@ -625,6 +625,7 @@ struct rtl8xxxu_priv {
 
        u8 mac_addr[ETH_ALEN];
        char chip_name[8];
+       char chip_vendor[8];
        u8 cck_tx_power_index_A[3];     /* 0x10 */
        u8 cck_tx_power_index_B[3];
        u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
@@ -647,6 +648,7 @@ struct rtl8xxxu_priv {
        u32 has_gps:1;
        u32 hi_pa:1;
        u32 vendor_umc:1;
+       u32 vendor_smic:1;
        u32 has_polarity_ctrl:1;
        u32 has_eeprom:1;
        u32 boot_eeprom:1;
index 8f6c9c6c7c094fdade4fb10dc1e655d8ead31058..a934c0de197bc3f8242aa1b0c5f69e12edf1bfa5 100644 (file)
 #define  SYS_CFG_CHIP_VER              (BIT(12) | BIT(13) | BIT(14) | BIT(15))
 #define  SYS_CFG_BT_FUNC               BIT(16)
 #define  SYS_CFG_VENDOR_ID             BIT(19)
+#define  SYS_CFG_VENDOR_EXT_MASK       (BIT(18) | BIT(19))
+#define   SYS_CFG_VENDOR_ID_TSMC       0
+#define   SYS_CFG_VENDOR_ID_SMIC       BIT(18)
+#define   SYS_CFG_VENDOR_ID_UMC                BIT(19)
 #define  SYS_CFG_PAD_HWPD_IDN          BIT(22)
 #define  SYS_CFG_TRP_VAUX_EN           BIT(23)
 #define  SYS_CFG_TRP_BT_EN             BIT(24)