Drivers: isdn: remove __dev* attributes.
[linux-block.git] / drivers / isdn / hisax / teles_cs.c
CommitLineData
1da177e4
LT
1/* $Id: teles_cs.c,v 1.1.2.2 2004/01/25 15:07:06 keil Exp $ */
2/*======================================================================
3
475be4d8 4 A teles S0 PCMCIA client driver
1da177e4 5
475be4d8
JP
6 Based on skeleton by David Hinds, dhinds@allegro.stanford.edu
7 Written by Christof Petig, christof.petig@wtal.de
1da177e4 8
475be4d8
JP
9 Also inspired by ELSA PCMCIA driver
10 by Klaus Lichtenwalder <Lichtenwalder@ACM.org>
1da177e4 11
475be4d8
JP
12 Extensions to new hisax_pcmcia by Karsten Keil
13
14 minor changes to be compatible with kernel 2.4.x
15 by Jan.Schubert@GMX.li
16
17 ======================================================================*/
1da177e4
LT
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
1da177e4
LT
22#include <linux/ptrace.h>
23#include <linux/slab.h>
24#include <linux/string.h>
25#include <linux/timer.h>
26#include <linux/ioport.h>
27#include <asm/io.h>
1da177e4 28
1da177e4
LT
29#include <pcmcia/cistpl.h>
30#include <pcmcia/cisreg.h>
31#include <pcmcia/ds.h>
32#include "hisax_cfg.h"
33
34MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Teles PCMCIA cards");
35MODULE_AUTHOR("Christof Petig, christof.petig@wtal.de, Karsten Keil, kkeil@suse.de");
36MODULE_LICENSE("GPL");
37
1da177e4
LT
38
39/*====================================================================*/
40
41/* Parameters that can be set with 'insmod' */
42
43static int protocol = 2; /* EURO-ISDN Default */
44module_param(protocol, int, 0);
45
ed5a84cd 46static int teles_cs_config(struct pcmcia_device *link);
fba395ee 47static void teles_cs_release(struct pcmcia_device *link);
ed5a84cd 48static void teles_detach(struct pcmcia_device *p_dev);
1da177e4 49
1da177e4 50typedef struct local_info_t {
fd238232 51 struct pcmcia_device *p_dev;
475be4d8
JP
52 int busy;
53 int cardnr;
1da177e4
LT
54} local_info_t;
55
ed5a84cd 56static int teles_probe(struct pcmcia_device *link)
1da177e4 57{
475be4d8 58 local_info_t *local;
1da177e4 59
475be4d8 60 dev_dbg(&link->dev, "teles_attach()\n");
1da177e4 61
475be4d8
JP
62 /* Allocate space for private device-specific data */
63 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
64 if (!local) return -ENOMEM;
65 local->cardnr = -1;
fd238232 66
475be4d8
JP
67 local->p_dev = link;
68 link->priv = local;
1da177e4 69
475be4d8 70 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
1da177e4 71
475be4d8 72 return teles_cs_config(link);
1da177e4
LT
73} /* teles_attach */
74
ed5a84cd 75static void teles_detach(struct pcmcia_device *link)
1da177e4 76{
e2d40963 77 local_info_t *info = link->priv;
1da177e4 78
e773cfe1 79 dev_dbg(&link->dev, "teles_detach(0x%p)\n", link);
1da177e4 80
e2d40963
DB
81 info->busy = 1;
82 teles_cs_release(link);
1da177e4 83
e2d40963 84 kfree(info);
1da177e4
LT
85} /* teles_detach */
86
00990e7c 87static int teles_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
1da177e4 88{
5fcd4da0
DB
89 int j;
90
90abdc3b 91 p_dev->io_lines = 5;
00990e7c
DB
92 p_dev->resource[0]->end = 96;
93 p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH;
94 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
90abdc3b 95
00990e7c 96 if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) {
5fcd4da0 97 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n");
90abdc3b 98 if (!pcmcia_request_io(p_dev))
5fcd4da0
DB
99 return 0;
100 } else {
101 printk(KERN_INFO "(teles_cs: looks like the 97 model)\n");
5fcd4da0 102 for (j = 0x2f0; j > 0x100; j -= 0x10) {
90abdc3b
DB
103 p_dev->resource[0]->start = j;
104 if (!pcmcia_request_io(p_dev))
5fcd4da0
DB
105 return 0;
106 }
107 }
108 return -ENODEV;
1da177e4
LT
109}
110
ed5a84cd 111static int teles_cs_config(struct pcmcia_device *link)
1da177e4 112{
475be4d8
JP
113 int i;
114 IsdnCard_t icard;
115
116 dev_dbg(&link->dev, "teles_config(0x%p)\n", link);
117
118 i = pcmcia_loop_config(link, teles_cs_configcheck, NULL);
119 if (i != 0)
120 goto cs_failed;
121
122 if (!link->irq)
123 goto cs_failed;
124
125 i = pcmcia_enable_device(link);
126 if (i != 0)
127 goto cs_failed;
15b99ac1 128
475be4d8
JP
129 icard.para[0] = link->irq;
130 icard.para[1] = link->resource[0]->start;
131 icard.protocol = protocol;
132 icard.typ = ISDN_CTYPE_TELESPCMCIA;
133
134 i = hisax_init_pcmcia(link, &(((local_info_t *)link->priv)->busy), &icard);
135 if (i < 0) {
136 printk(KERN_ERR "teles_cs: failed to initialize Teles PCMCIA %d at i/o %#x\n",
137 i, (unsigned int) link->resource[0]->start);
138 teles_cs_release(link);
139 return -ENODEV;
140 }
141
142 ((local_info_t *)link->priv)->cardnr = i;
143 return 0;
1da177e4 144
1da177e4 145cs_failed:
475be4d8
JP
146 teles_cs_release(link);
147 return -ENODEV;
1da177e4
LT
148} /* teles_cs_config */
149
fba395ee 150static void teles_cs_release(struct pcmcia_device *link)
1da177e4 151{
475be4d8 152 local_info_t *local = link->priv;
1da177e4 153
475be4d8 154 dev_dbg(&link->dev, "teles_cs_release(0x%p)\n", link);
1da177e4 155
475be4d8
JP
156 if (local) {
157 if (local->cardnr >= 0) {
158 /* no unregister function with hisax */
159 HiSax_closecard(local->cardnr);
160 }
1da177e4 161 }
5f2a71fc 162
475be4d8 163 pcmcia_disable_device(link);
1da177e4
LT
164} /* teles_cs_release */
165
fba395ee 166static int teles_suspend(struct pcmcia_device *link)
98e4c28b 167{
98e4c28b
DB
168 local_info_t *dev = link->priv;
169
475be4d8 170 dev->busy = 1;
98e4c28b
DB
171
172 return 0;
173}
174
fba395ee 175static int teles_resume(struct pcmcia_device *link)
98e4c28b 176{
98e4c28b
DB
177 local_info_t *dev = link->priv;
178
475be4d8 179 dev->busy = 0;
98e4c28b
DB
180
181 return 0;
182}
183
1da177e4 184
25f8f54f 185static const struct pcmcia_device_id teles_ids[] = {
0a10d73d
DB
186 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119),
187 PCMCIA_DEVICE_NULL,
188};
189MODULE_DEVICE_TABLE(pcmcia, teles_ids);
190
1da177e4
LT
191static struct pcmcia_driver teles_cs_driver = {
192 .owner = THIS_MODULE,
2e9b981a 193 .name = "teles_cs",
15b99ac1 194 .probe = teles_probe,
ed5a84cd 195 .remove = teles_detach,
0a10d73d 196 .id_table = teles_ids,
98e4c28b
DB
197 .suspend = teles_suspend,
198 .resume = teles_resume,
1da177e4
LT
199};
200
201static int __init init_teles_cs(void)
202{
203 return pcmcia_register_driver(&teles_cs_driver);
204}
205
206static void __exit exit_teles_cs(void)
207{
208 pcmcia_unregister_driver(&teles_cs_driver);
1da177e4
LT
209}
210
211module_init(init_teles_cs);
212module_exit(exit_teles_cs);