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 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called LICENSE.
21 *
22 * Contact Information:
23 * wlanfae <wlanfae@realtek.com>
24 *****************************************************************************/
25 #include "rtl_pci.h"
26 #include "rtl_core.h"
27
rtl8192_parse_pci_configuration(struct pci_dev * pdev,struct net_device * dev)28 static void rtl8192_parse_pci_configuration(struct pci_dev *pdev,
29 struct net_device *dev)
30 {
31 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
32
33 u8 tmp;
34 u16 LinkCtrlReg;
35
36 pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg);
37 priv->NdisAdapter.LinkCtrlReg = (u8)LinkCtrlReg;
38
39 RT_TRACE(COMP_INIT, "Link Control Register =%x\n",
40 priv->NdisAdapter.LinkCtrlReg);
41
42 pci_read_config_byte(pdev, 0x98, &tmp);
43 tmp |= BIT4;
44 pci_write_config_byte(pdev, 0x98, tmp);
45
46 tmp = 0x17;
47 pci_write_config_byte(pdev, 0x70f, tmp);
48 }
49
rtl8192_pci_findadapter(struct pci_dev * pdev,struct net_device * dev)50 bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev)
51 {
52 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
53 u16 VenderID;
54 u16 DeviceID;
55 u8 RevisionID;
56 u16 IrqLine;
57
58 VenderID = pdev->vendor;
59 DeviceID = pdev->device;
60 RevisionID = pdev->revision;
61 pci_read_config_word(pdev, 0x3C, &IrqLine);
62
63 priv->card_8192 = priv->ops->nic_type;
64
65 if (DeviceID == 0x8172) {
66 switch (RevisionID) {
67 case HAL_HW_PCI_REVISION_ID_8192PCIE:
68 dev_info(&pdev->dev,
69 "Adapter(8192 PCI-E) is found - DeviceID=%x\n",
70 DeviceID);
71 priv->card_8192 = NIC_8192E;
72 break;
73 case HAL_HW_PCI_REVISION_ID_8192SE:
74 dev_info(&pdev->dev,
75 "Adapter(8192SE) is found - DeviceID=%x\n",
76 DeviceID);
77 priv->card_8192 = NIC_8192SE;
78 break;
79 default:
80 dev_info(&pdev->dev,
81 "UNKNOWN nic type(%4x:%4x)\n",
82 pdev->vendor, pdev->device);
83 priv->card_8192 = NIC_UNKNOWN;
84 return false;
85 }
86 }
87
88 if (priv->ops->nic_type != priv->card_8192) {
89 dev_info(&pdev->dev,
90 "Detect info(%x) and hardware info(%x) not match!\n",
91 priv->ops->nic_type, priv->card_8192);
92 dev_info(&pdev->dev,
93 "Please select proper driver before install!!!!\n");
94 return false;
95 }
96
97 rtl8192_parse_pci_configuration(pdev, dev);
98
99 return true;
100 }
101