This source file includes following definitions.
- orinoco_pci_cor_reset
- orinoco_pci_init_one
- orinoco_pci_remove_one
- orinoco_pci_init
- orinoco_pci_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 #define DRIVER_NAME "orinoco_pci"
45 #define PFX DRIVER_NAME ": "
46
47 #include <linux/module.h>
48 #include <linux/kernel.h>
49 #include <linux/init.h>
50 #include <linux/delay.h>
51 #include <linux/pci.h>
52
53 #include "orinoco.h"
54 #include "orinoco_pci.h"
55
56
57 #define HERMES_PCI_COR (0x26)
58
59
60 #define HERMES_PCI_COR_MASK (0x0080)
61
62
63
64
65 #define HERMES_PCI_COR_ONT (250)
66 #define HERMES_PCI_COR_OFFT (500)
67 #define HERMES_PCI_COR_BUSYT (500)
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 static int orinoco_pci_cor_reset(struct orinoco_private *priv)
83 {
84 struct hermes *hw = &priv->hw;
85 unsigned long timeout;
86 u16 reg;
87
88
89 hermes_write_regn(hw, PCI_COR, HERMES_PCI_COR_MASK);
90 mdelay(HERMES_PCI_COR_ONT);
91
92
93 hermes_write_regn(hw, PCI_COR, 0x0000);
94 mdelay(HERMES_PCI_COR_OFFT);
95
96
97 timeout = jiffies + msecs_to_jiffies(HERMES_PCI_COR_BUSYT);
98 reg = hermes_read_regn(hw, CMD);
99 while (time_before(jiffies, timeout) && (reg & HERMES_CMD_BUSY)) {
100 mdelay(1);
101 reg = hermes_read_regn(hw, CMD);
102 }
103
104
105 if (reg & HERMES_CMD_BUSY) {
106 printk(KERN_ERR PFX "Busy timeout\n");
107 return -ETIMEDOUT;
108 }
109
110 return 0;
111 }
112
113 static int orinoco_pci_init_one(struct pci_dev *pdev,
114 const struct pci_device_id *ent)
115 {
116 int err;
117 struct orinoco_private *priv;
118 struct orinoco_pci_card *card;
119 void __iomem *hermes_io;
120
121 err = pci_enable_device(pdev);
122 if (err) {
123 printk(KERN_ERR PFX "Cannot enable PCI device\n");
124 return err;
125 }
126
127 err = pci_request_regions(pdev, DRIVER_NAME);
128 if (err) {
129 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
130 goto fail_resources;
131 }
132
133 hermes_io = pci_iomap(pdev, 0, 0);
134 if (!hermes_io) {
135 printk(KERN_ERR PFX "Cannot remap chipset registers\n");
136 err = -EIO;
137 goto fail_map_hermes;
138 }
139
140
141 priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
142 orinoco_pci_cor_reset, NULL);
143 if (!priv) {
144 printk(KERN_ERR PFX "Cannot allocate network device\n");
145 err = -ENOMEM;
146 goto fail_alloc;
147 }
148
149 card = priv->card;
150
151 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING);
152
153 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
154 DRIVER_NAME, priv);
155 if (err) {
156 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
157 err = -EBUSY;
158 goto fail_irq;
159 }
160
161 err = orinoco_pci_cor_reset(priv);
162 if (err) {
163 printk(KERN_ERR PFX "Initial reset failed\n");
164 goto fail;
165 }
166
167 err = orinoco_init(priv);
168 if (err) {
169 printk(KERN_ERR PFX "orinoco_init() failed\n");
170 goto fail;
171 }
172
173 err = orinoco_if_add(priv, 0, 0, NULL);
174 if (err) {
175 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
176 goto fail_wiphy;
177 }
178
179 pci_set_drvdata(pdev, priv);
180
181 return 0;
182
183 fail_wiphy:
184 wiphy_unregister(priv_to_wiphy(priv));
185 fail:
186 free_irq(pdev->irq, priv);
187
188 fail_irq:
189 free_orinocodev(priv);
190
191 fail_alloc:
192 pci_iounmap(pdev, hermes_io);
193
194 fail_map_hermes:
195 pci_release_regions(pdev);
196
197 fail_resources:
198 pci_disable_device(pdev);
199
200 return err;
201 }
202
203 static void orinoco_pci_remove_one(struct pci_dev *pdev)
204 {
205 struct orinoco_private *priv = pci_get_drvdata(pdev);
206
207 orinoco_if_del(priv);
208 wiphy_unregister(priv_to_wiphy(priv));
209 free_irq(pdev->irq, priv);
210 free_orinocodev(priv);
211 pci_iounmap(pdev, priv->hw.iobase);
212 pci_release_regions(pdev);
213 pci_disable_device(pdev);
214 }
215
216 static const struct pci_device_id orinoco_pci_id_table[] = {
217
218 {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,},
219
220 {0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID,},
221
222 {0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID,},
223 {0,},
224 };
225
226 MODULE_DEVICE_TABLE(pci, orinoco_pci_id_table);
227
228 static struct pci_driver orinoco_pci_driver = {
229 .name = DRIVER_NAME,
230 .id_table = orinoco_pci_id_table,
231 .probe = orinoco_pci_init_one,
232 .remove = orinoco_pci_remove_one,
233 .suspend = orinoco_pci_suspend,
234 .resume = orinoco_pci_resume,
235 };
236
237 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
238 " (Pavel Roskin <proski@gnu.org>,"
239 " David Gibson <hermes@gibson.dropbear.id.au> &"
240 " Jean Tourrilhes <jt@hpl.hp.com>)";
241 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> &"
242 " David Gibson <hermes@gibson.dropbear.id.au>");
243 MODULE_DESCRIPTION("Driver for wireless LAN cards using direct PCI interface");
244 MODULE_LICENSE("Dual MPL/GPL");
245
246 static int __init orinoco_pci_init(void)
247 {
248 printk(KERN_DEBUG "%s\n", version);
249 return pci_register_driver(&orinoco_pci_driver);
250 }
251
252 static void __exit orinoco_pci_exit(void)
253 {
254 pci_unregister_driver(&orinoco_pci_driver);
255 }
256
257 module_init(orinoco_pci_init);
258 module_exit(orinoco_pci_exit);
259
260
261
262
263
264
265
266