Commit | Line | Data |
---|---|---|
94a79942 LF |
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 <andreamrl@tiscali.it>, 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 | ||
62f27cc4 LF |
28 | static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, |
29 | struct net_device *dev) | |
94a79942 LF |
30 | { |
31 | struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); | |
32 | ||
33 | u8 tmp; | |
479e0d48 | 34 | u16 LinkCtrlReg; |
94a79942 | 35 | |
479e0d48 JL |
36 | pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg); |
37 | priv->NdisAdapter.LinkCtrlReg = (u8)LinkCtrlReg; | |
94a79942 | 38 | |
62f27cc4 LF |
39 | RT_TRACE(COMP_INIT, "Link Control Register =%x\n", |
40 | priv->NdisAdapter.LinkCtrlReg); | |
94a79942 LF |
41 | |
42 | pci_read_config_byte(pdev, 0x98, &tmp); | |
62f27cc4 | 43 | tmp |= BIT4; |
94a79942 LF |
44 | pci_write_config_byte(pdev, 0x98, tmp); |
45 | ||
46 | tmp = 0x17; | |
47 | pci_write_config_byte(pdev, 0x70f, tmp); | |
48 | } | |
49 | ||
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: | |
62f27cc4 LF |
68 | printk(KERN_INFO "Adapter(8192 PCI-E) is found - " |
69 | "DeviceID=%x\n", DeviceID); | |
94a79942 LF |
70 | priv->card_8192 = NIC_8192E; |
71 | break; | |
72 | case HAL_HW_PCI_REVISION_ID_8192SE: | |
62f27cc4 LF |
73 | printk(KERN_INFO "Adapter(8192SE) is found - " |
74 | "DeviceID=%x\n", DeviceID); | |
94a79942 LF |
75 | priv->card_8192 = NIC_8192SE; |
76 | break; | |
77 | default: | |
62f27cc4 LF |
78 | printk(KERN_INFO "UNKNOWN nic type(%4x:%4x)\n", |
79 | pdev->vendor, pdev->device); | |
94a79942 LF |
80 | priv->card_8192 = NIC_UNKNOWN; |
81 | return false; | |
82 | } | |
83 | } | |
84 | ||
85 | if (priv->ops->nic_type != priv->card_8192) { | |
62f27cc4 | 86 | printk(KERN_INFO "Detect info(%x) and hardware info(%x) not match!\n", |
94a79942 | 87 | priv->ops->nic_type, priv->card_8192); |
62f27cc4 | 88 | printk(KERN_INFO "Please select proper driver before install!!!!\n"); |
94a79942 LF |
89 | return false; |
90 | } | |
91 | ||
94a79942 LF |
92 | rtl8192_parse_pci_configuration(pdev, dev); |
93 | ||
94 | return true; | |
95 | } |