diff options
Diffstat (limited to 'drivers/net/pcmcia/ibmtr_cs.c')
-rw-r--r-- | drivers/net/pcmcia/ibmtr_cs.c | 117 |
1 files changed, 33 insertions, 84 deletions
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index b0d06a3d962f..6006d5488fbe 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c | |||
@@ -45,6 +45,8 @@ | |||
45 | 45 | ||
46 | ======================================================================*/ | 46 | ======================================================================*/ |
47 | 47 | ||
48 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
49 | |||
48 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
49 | #include <linux/init.h> | 51 | #include <linux/init.h> |
50 | #include <linux/ptrace.h> | 52 | #include <linux/ptrace.h> |
@@ -52,12 +54,10 @@ | |||
52 | #include <linux/string.h> | 54 | #include <linux/string.h> |
53 | #include <linux/timer.h> | 55 | #include <linux/timer.h> |
54 | #include <linux/module.h> | 56 | #include <linux/module.h> |
55 | #include <linux/ethtool.h> | ||
56 | #include <linux/netdevice.h> | 57 | #include <linux/netdevice.h> |
57 | #include <linux/trdevice.h> | 58 | #include <linux/trdevice.h> |
58 | #include <linux/ibmtr.h> | 59 | #include <linux/ibmtr.h> |
59 | 60 | ||
60 | #include <pcmcia/cs.h> | ||
61 | #include <pcmcia/cistpl.h> | 61 | #include <pcmcia/cistpl.h> |
62 | #include <pcmcia/ds.h> | 62 | #include <pcmcia/ds.h> |
63 | 63 | ||
@@ -102,35 +102,16 @@ static void ibmtr_detach(struct pcmcia_device *p_dev); | |||
102 | 102 | ||
103 | typedef struct ibmtr_dev_t { | 103 | typedef struct ibmtr_dev_t { |
104 | struct pcmcia_device *p_dev; | 104 | struct pcmcia_device *p_dev; |
105 | struct net_device *dev; | 105 | struct net_device *dev; |
106 | window_handle_t sram_win_handle; | 106 | struct tok_info *ti; |
107 | struct tok_info *ti; | ||
108 | } ibmtr_dev_t; | 107 | } ibmtr_dev_t; |
109 | 108 | ||
110 | static void netdev_get_drvinfo(struct net_device *dev, | ||
111 | struct ethtool_drvinfo *info) | ||
112 | { | ||
113 | strcpy(info->driver, "ibmtr_cs"); | ||
114 | } | ||
115 | |||
116 | static const struct ethtool_ops netdev_ethtool_ops = { | ||
117 | .get_drvinfo = netdev_get_drvinfo, | ||
118 | }; | ||
119 | |||
120 | static irqreturn_t ibmtr_interrupt(int irq, void *dev_id) { | 109 | static irqreturn_t ibmtr_interrupt(int irq, void *dev_id) { |
121 | ibmtr_dev_t *info = dev_id; | 110 | ibmtr_dev_t *info = dev_id; |
122 | struct net_device *dev = info->dev; | 111 | struct net_device *dev = info->dev; |
123 | return tok_interrupt(irq, dev); | 112 | return tok_interrupt(irq, dev); |
124 | }; | 113 | }; |
125 | 114 | ||
126 | /*====================================================================== | ||
127 | |||
128 | ibmtr_attach() creates an "instance" of the driver, allocating | ||
129 | local data structures for one device. The device is registered | ||
130 | with Card Services. | ||
131 | |||
132 | ======================================================================*/ | ||
133 | |||
134 | static int __devinit ibmtr_attach(struct pcmcia_device *link) | 115 | static int __devinit ibmtr_attach(struct pcmcia_device *link) |
135 | { | 116 | { |
136 | ibmtr_dev_t *info; | 117 | ibmtr_dev_t *info; |
@@ -153,26 +134,14 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link) | |||
153 | 134 | ||
154 | link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; | 135 | link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; |
155 | link->resource[0]->end = 4; | 136 | link->resource[0]->end = 4; |
156 | link->conf.Attributes = CONF_ENABLE_IRQ; | 137 | link->config_flags |= CONF_ENABLE_IRQ; |
157 | link->conf.IntType = INT_MEMORY_AND_IO; | 138 | link->config_regs = PRESENT_OPTION; |
158 | link->conf.Present = PRESENT_OPTION; | ||
159 | 139 | ||
160 | info->dev = dev; | 140 | info->dev = dev; |
161 | 141 | ||
162 | SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); | ||
163 | |||
164 | return ibmtr_config(link); | 142 | return ibmtr_config(link); |
165 | } /* ibmtr_attach */ | 143 | } /* ibmtr_attach */ |
166 | 144 | ||
167 | /*====================================================================== | ||
168 | |||
169 | This deletes a driver "instance". The device is de-registered | ||
170 | with Card Services. If it has been released, all local data | ||
171 | structures are freed. Otherwise, the structures will be freed | ||
172 | when the device is released. | ||
173 | |||
174 | ======================================================================*/ | ||
175 | |||
176 | static void ibmtr_detach(struct pcmcia_device *link) | 145 | static void ibmtr_detach(struct pcmcia_device *link) |
177 | { | 146 | { |
178 | struct ibmtr_dev_t *info = link->priv; | 147 | struct ibmtr_dev_t *info = link->priv; |
@@ -197,26 +166,17 @@ static void ibmtr_detach(struct pcmcia_device *link) | |||
197 | kfree(info); | 166 | kfree(info); |
198 | } /* ibmtr_detach */ | 167 | } /* ibmtr_detach */ |
199 | 168 | ||
200 | /*====================================================================== | ||
201 | |||
202 | ibmtr_config() is scheduled to run after a CARD_INSERTION event | ||
203 | is received, to configure the PCMCIA socket, and to make the | ||
204 | token-ring device available to the system. | ||
205 | |||
206 | ======================================================================*/ | ||
207 | |||
208 | static int __devinit ibmtr_config(struct pcmcia_device *link) | 169 | static int __devinit ibmtr_config(struct pcmcia_device *link) |
209 | { | 170 | { |
210 | ibmtr_dev_t *info = link->priv; | 171 | ibmtr_dev_t *info = link->priv; |
211 | struct net_device *dev = info->dev; | 172 | struct net_device *dev = info->dev; |
212 | struct tok_info *ti = netdev_priv(dev); | 173 | struct tok_info *ti = netdev_priv(dev); |
213 | win_req_t req; | ||
214 | int i, ret; | 174 | int i, ret; |
215 | 175 | ||
216 | dev_dbg(&link->dev, "ibmtr_config\n"); | 176 | dev_dbg(&link->dev, "ibmtr_config\n"); |
217 | 177 | ||
218 | link->conf.ConfigIndex = 0x61; | ||
219 | link->io_lines = 16; | 178 | link->io_lines = 16; |
179 | link->config_index = 0x61; | ||
220 | 180 | ||
221 | /* Determine if this is PRIMARY or ALTERNATE. */ | 181 | /* Determine if this is PRIMARY or ALTERNATE. */ |
222 | 182 | ||
@@ -240,39 +200,39 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
240 | ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); | 200 | ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); |
241 | 201 | ||
242 | /* Allocate the MMIO memory window */ | 202 | /* Allocate the MMIO memory window */ |
243 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; | 203 | link->resource[2]->flags |= WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; |
244 | req.Attributes |= WIN_USE_WAIT; | 204 | link->resource[2]->flags |= WIN_USE_WAIT; |
245 | req.Base = 0; | 205 | link->resource[2]->start = 0; |
246 | req.Size = 0x2000; | 206 | link->resource[2]->end = 0x2000; |
247 | req.AccessSpeed = 250; | 207 | ret = pcmcia_request_window(link, link->resource[2], 250); |
248 | ret = pcmcia_request_window(link, &req, &link->win); | ||
249 | if (ret) | 208 | if (ret) |
250 | goto failed; | 209 | goto failed; |
251 | 210 | ||
252 | ret = pcmcia_map_mem_page(link, link->win, mmiobase); | 211 | ret = pcmcia_map_mem_page(link, link->resource[2], mmiobase); |
253 | if (ret) | 212 | if (ret) |
254 | goto failed; | 213 | goto failed; |
255 | ti->mmio = ioremap(req.Base, req.Size); | 214 | ti->mmio = ioremap(link->resource[2]->start, |
215 | resource_size(link->resource[2])); | ||
256 | 216 | ||
257 | /* Allocate the SRAM memory window */ | 217 | /* Allocate the SRAM memory window */ |
258 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; | 218 | link->resource[3]->flags = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; |
259 | req.Attributes |= WIN_USE_WAIT; | 219 | link->resource[3]->flags |= WIN_USE_WAIT; |
260 | req.Base = 0; | 220 | link->resource[3]->start = 0; |
261 | req.Size = sramsize * 1024; | 221 | link->resource[3]->end = sramsize * 1024; |
262 | req.AccessSpeed = 250; | 222 | ret = pcmcia_request_window(link, link->resource[3], 250); |
263 | ret = pcmcia_request_window(link, &req, &info->sram_win_handle); | ||
264 | if (ret) | 223 | if (ret) |
265 | goto failed; | 224 | goto failed; |
266 | 225 | ||
267 | ret = pcmcia_map_mem_page(link, info->sram_win_handle, srambase); | 226 | ret = pcmcia_map_mem_page(link, link->resource[3], srambase); |
268 | if (ret) | 227 | if (ret) |
269 | goto failed; | 228 | goto failed; |
270 | 229 | ||
271 | ti->sram_base = srambase >> 12; | 230 | ti->sram_base = srambase >> 12; |
272 | ti->sram_virt = ioremap(req.Base, req.Size); | 231 | ti->sram_virt = ioremap(link->resource[3]->start, |
273 | ti->sram_phys = req.Base; | 232 | resource_size(link->resource[3])); |
233 | ti->sram_phys = link->resource[3]->start; | ||
274 | 234 | ||
275 | ret = pcmcia_request_configuration(link, &link->conf); | 235 | ret = pcmcia_enable_device(link); |
276 | if (ret) | 236 | if (ret) |
277 | goto failed; | 237 | goto failed; |
278 | 238 | ||
@@ -285,15 +245,14 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
285 | 245 | ||
286 | i = ibmtr_probe_card(dev); | 246 | i = ibmtr_probe_card(dev); |
287 | if (i != 0) { | 247 | if (i != 0) { |
288 | printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n"); | 248 | pr_notice("register_netdev() failed\n"); |
289 | goto failed; | 249 | goto failed; |
290 | } | 250 | } |
291 | 251 | ||
292 | printk(KERN_INFO | 252 | netdev_info(dev, "port %#3lx, irq %d, mmio %#5lx, sram %#5lx, hwaddr=%pM\n", |
293 | "%s: port %#3lx, irq %d, mmio %#5lx, sram %#5lx, hwaddr=%pM\n", | 253 | dev->base_addr, dev->irq, |
294 | dev->name, dev->base_addr, dev->irq, | 254 | (u_long)ti->mmio, (u_long)(ti->sram_base << 12), |
295 | (u_long)ti->mmio, (u_long)(ti->sram_base << 12), | 255 | dev->dev_addr); |
296 | dev->dev_addr); | ||
297 | return 0; | 256 | return 0; |
298 | 257 | ||
299 | failed: | 258 | failed: |
@@ -301,14 +260,6 @@ failed: | |||
301 | return -ENODEV; | 260 | return -ENODEV; |
302 | } /* ibmtr_config */ | 261 | } /* ibmtr_config */ |
303 | 262 | ||
304 | /*====================================================================== | ||
305 | |||
306 | After a card is removed, ibmtr_release() will unregister the net | ||
307 | device, and release the PCMCIA configuration. If the device is | ||
308 | still open, this will be postponed until it is closed. | ||
309 | |||
310 | ======================================================================*/ | ||
311 | |||
312 | static void ibmtr_release(struct pcmcia_device *link) | 263 | static void ibmtr_release(struct pcmcia_device *link) |
313 | { | 264 | { |
314 | ibmtr_dev_t *info = link->priv; | 265 | ibmtr_dev_t *info = link->priv; |
@@ -316,7 +267,7 @@ static void ibmtr_release(struct pcmcia_device *link) | |||
316 | 267 | ||
317 | dev_dbg(&link->dev, "ibmtr_release\n"); | 268 | dev_dbg(&link->dev, "ibmtr_release\n"); |
318 | 269 | ||
319 | if (link->win) { | 270 | if (link->resource[2]->end) { |
320 | struct tok_info *ti = netdev_priv(dev); | 271 | struct tok_info *ti = netdev_priv(dev); |
321 | iounmap(ti->mmio); | 272 | iounmap(ti->mmio); |
322 | } | 273 | } |
@@ -389,7 +340,7 @@ static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase) | |||
389 | outb(0x40, dev->base_addr); | 340 | outb(0x40, dev->base_addr); |
390 | } | 341 | } |
391 | 342 | ||
392 | static struct pcmcia_device_id ibmtr_ids[] = { | 343 | static const struct pcmcia_device_id ibmtr_ids[] = { |
393 | PCMCIA_DEVICE_PROD_ID12("3Com", "TokenLink Velocity PC Card", 0x41240e5b, 0x82c3734e), | 344 | PCMCIA_DEVICE_PROD_ID12("3Com", "TokenLink Velocity PC Card", 0x41240e5b, 0x82c3734e), |
394 | PCMCIA_DEVICE_PROD_ID12("IBM", "TOKEN RING", 0xb569a6e5, 0xbf8eed47), | 345 | PCMCIA_DEVICE_PROD_ID12("IBM", "TOKEN RING", 0xb569a6e5, 0xbf8eed47), |
395 | PCMCIA_DEVICE_NULL, | 346 | PCMCIA_DEVICE_NULL, |
@@ -398,9 +349,7 @@ MODULE_DEVICE_TABLE(pcmcia, ibmtr_ids); | |||
398 | 349 | ||
399 | static struct pcmcia_driver ibmtr_cs_driver = { | 350 | static struct pcmcia_driver ibmtr_cs_driver = { |
400 | .owner = THIS_MODULE, | 351 | .owner = THIS_MODULE, |
401 | .drv = { | 352 | .name = "ibmtr_cs", |
402 | .name = "ibmtr_cs", | ||
403 | }, | ||
404 | .probe = ibmtr_attach, | 353 | .probe = ibmtr_attach, |
405 | .remove = ibmtr_detach, | 354 | .remove = ibmtr_detach, |
406 | .id_table = ibmtr_ids, | 355 | .id_table = ibmtr_ids, |