1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3 *
4 * Based on the r8180 driver, which is:
5 * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * The full GNU General Public License is included in this distribution in the
16 * file called LICENSE.
17 *
18 * Contact Information:
19 * wlanfae <wlanfae@realtek.com>
20 *****************************************************************************/
21 #include "rtl_pci.h"
22 #include "rtl_core.h"
23
_rtl92e_parse_pci_configuration(struct pci_dev * pdev,struct net_device * dev)24 static void _rtl92e_parse_pci_configuration(struct pci_dev *pdev,
25 struct net_device *dev)
26 {
27 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
28
29 u8 tmp;
30 u16 LinkCtrlReg;
31
32 pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg);
33
34 RT_TRACE(COMP_INIT, "Link Control Register =%x\n", LinkCtrlReg);
35
36 pci_read_config_byte(pdev, 0x98, &tmp);
37 tmp |= BIT4;
38 pci_write_config_byte(pdev, 0x98, tmp);
39
40 tmp = 0x17;
41 pci_write_config_byte(pdev, 0x70f, tmp);
42 }
43
rtl92e_check_adapter(struct pci_dev * pdev,struct net_device * dev)44 bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev)
45 {
46 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
47 u16 VenderID;
48 u16 DeviceID;
49 u8 RevisionID;
50 u16 IrqLine;
51
52 VenderID = pdev->vendor;
53 DeviceID = pdev->device;
54 RevisionID = pdev->revision;
55 pci_read_config_word(pdev, 0x3C, &IrqLine);
56
57 priv->card_8192 = priv->ops->nic_type;
58
59 if (DeviceID == 0x8192) {
60 switch (RevisionID) {
61 case HAL_HW_PCI_REVISION_ID_8192PCIE:
62 dev_info(&pdev->dev,
63 "Adapter(8192 PCI-E) is found - DeviceID=%x\n",
64 DeviceID);
65 priv->card_8192 = NIC_8192E;
66 break;
67 case HAL_HW_PCI_REVISION_ID_8192SE:
68 dev_info(&pdev->dev,
69 "Adapter(8192SE) is found - DeviceID=%x\n",
70 DeviceID);
71 priv->card_8192 = NIC_8192SE;
72 break;
73 default:
74 dev_info(&pdev->dev,
75 "UNKNOWN nic type(%4x:%4x)\n",
76 pdev->vendor, pdev->device);
77 priv->card_8192 = NIC_UNKNOWN;
78 return false;
79 }
80 }
81
82 if (priv->ops->nic_type != priv->card_8192) {
83 dev_info(&pdev->dev,
84 "Detect info(%x) and hardware info(%x) not match!\n",
85 priv->ops->nic_type, priv->card_8192);
86 dev_info(&pdev->dev,
87 "Please select proper driver before install!!!!\n");
88 return false;
89 }
90
91 _rtl92e_parse_pci_configuration(pdev, dev);
92
93 return true;
94 }
95