This source file includes following definitions.
- orinoco_tmd_cor_reset
- orinoco_tmd_init_one
- orinoco_tmd_remove_one
- orinoco_tmd_init
- orinoco_tmd_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 #define DRIVER_NAME "orinoco_tmd"
41 #define PFX DRIVER_NAME ": "
42
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/init.h>
46 #include <linux/delay.h>
47 #include <linux/pci.h>
48 #include <pcmcia/cisreg.h>
49
50 #include "orinoco.h"
51 #include "orinoco_pci.h"
52
53 #define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA)
54 #define COR_RESET (0x80)
55 #define TMD_RESET_TIME (500)
56
57
58
59
60 static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
61 {
62 struct hermes *hw = &priv->hw;
63 struct orinoco_pci_card *card = priv->card;
64 unsigned long timeout;
65 u16 reg;
66
67 iowrite8(COR_VALUE | COR_RESET, card->bridge_io);
68 mdelay(1);
69
70 iowrite8(COR_VALUE, card->bridge_io);
71 mdelay(1);
72
73
74 timeout = jiffies + msecs_to_jiffies(TMD_RESET_TIME);
75 reg = hermes_read_regn(hw, CMD);
76 while (time_before(jiffies, timeout) && (reg & HERMES_CMD_BUSY)) {
77 mdelay(1);
78 reg = hermes_read_regn(hw, CMD);
79 }
80
81
82 if (reg & HERMES_CMD_BUSY) {
83 printk(KERN_ERR PFX "Busy timeout\n");
84 return -ETIMEDOUT;
85 }
86
87 return 0;
88 }
89
90
91 static int orinoco_tmd_init_one(struct pci_dev *pdev,
92 const struct pci_device_id *ent)
93 {
94 int err;
95 struct orinoco_private *priv;
96 struct orinoco_pci_card *card;
97 void __iomem *hermes_io, *bridge_io;
98
99 err = pci_enable_device(pdev);
100 if (err) {
101 printk(KERN_ERR PFX "Cannot enable PCI device\n");
102 return err;
103 }
104
105 err = pci_request_regions(pdev, DRIVER_NAME);
106 if (err) {
107 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
108 goto fail_resources;
109 }
110
111 bridge_io = pci_iomap(pdev, 1, 0);
112 if (!bridge_io) {
113 printk(KERN_ERR PFX "Cannot map bridge registers\n");
114 err = -EIO;
115 goto fail_map_bridge;
116 }
117
118 hermes_io = pci_iomap(pdev, 2, 0);
119 if (!hermes_io) {
120 printk(KERN_ERR PFX "Cannot map chipset registers\n");
121 err = -EIO;
122 goto fail_map_hermes;
123 }
124
125
126 priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
127 orinoco_tmd_cor_reset, NULL);
128 if (!priv) {
129 printk(KERN_ERR PFX "Cannot allocate network device\n");
130 err = -ENOMEM;
131 goto fail_alloc;
132 }
133
134 card = priv->card;
135 card->bridge_io = bridge_io;
136
137 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
138
139 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
140 DRIVER_NAME, priv);
141 if (err) {
142 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
143 err = -EBUSY;
144 goto fail_irq;
145 }
146
147 err = orinoco_tmd_cor_reset(priv);
148 if (err) {
149 printk(KERN_ERR PFX "Initial reset failed\n");
150 goto fail;
151 }
152
153 err = orinoco_init(priv);
154 if (err) {
155 printk(KERN_ERR PFX "orinoco_init() failed\n");
156 goto fail;
157 }
158
159 err = orinoco_if_add(priv, 0, 0, NULL);
160 if (err) {
161 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
162 goto fail;
163 }
164
165 pci_set_drvdata(pdev, priv);
166
167 return 0;
168
169 fail:
170 free_irq(pdev->irq, priv);
171
172 fail_irq:
173 free_orinocodev(priv);
174
175 fail_alloc:
176 pci_iounmap(pdev, hermes_io);
177
178 fail_map_hermes:
179 pci_iounmap(pdev, bridge_io);
180
181 fail_map_bridge:
182 pci_release_regions(pdev);
183
184 fail_resources:
185 pci_disable_device(pdev);
186
187 return err;
188 }
189
190 static void orinoco_tmd_remove_one(struct pci_dev *pdev)
191 {
192 struct orinoco_private *priv = pci_get_drvdata(pdev);
193 struct orinoco_pci_card *card = priv->card;
194
195 orinoco_if_del(priv);
196 free_irq(pdev->irq, priv);
197 free_orinocodev(priv);
198 pci_iounmap(pdev, priv->hw.iobase);
199 pci_iounmap(pdev, card->bridge_io);
200 pci_release_regions(pdev);
201 pci_disable_device(pdev);
202 }
203
204 static const struct pci_device_id orinoco_tmd_id_table[] = {
205 {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,},
206 {0,},
207 };
208
209 MODULE_DEVICE_TABLE(pci, orinoco_tmd_id_table);
210
211 static struct pci_driver orinoco_tmd_driver = {
212 .name = DRIVER_NAME,
213 .id_table = orinoco_tmd_id_table,
214 .probe = orinoco_tmd_init_one,
215 .remove = orinoco_tmd_remove_one,
216 .suspend = orinoco_pci_suspend,
217 .resume = orinoco_pci_resume,
218 };
219
220 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
221 " (Joerg Dorchain <joerg@dorchain.net>)";
222 MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
223 MODULE_DESCRIPTION("Driver for wireless LAN cards using the TMD7160 PCI bridge");
224 MODULE_LICENSE("Dual MPL/GPL");
225
226 static int __init orinoco_tmd_init(void)
227 {
228 printk(KERN_DEBUG "%s\n", version);
229 return pci_register_driver(&orinoco_tmd_driver);
230 }
231
232 static void __exit orinoco_tmd_exit(void)
233 {
234 pci_unregister_driver(&orinoco_tmd_driver);
235 }
236
237 module_init(orinoco_tmd_init);
238 module_exit(orinoco_tmd_exit);
239
240
241
242
243
244
245
246