Blame view
drivers/isdn/hisax/elsa_cs.c
6.24 KB
1da177e4c
|
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 |
/*====================================================================== An elsa_cs PCMCIA client driver This driver is for the Elsa PCM ISDN Cards, i.e. the MicroLink The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The initial developer of the original code is David A. Hinds <dahinds@users.sourceforge.net>. Portions created by David A. Hinds are Copyright (C) 1999 David A. Hinds. All Rights Reserved. Modifications from dummy_cs.c are Copyright (C) 1999-2001 Klaus Lichtenwalder <Lichtenwalder@ACM.org>. All Rights Reserved. Alternatively, the contents of this file may be used under the terms of the GNU General Public License version 2 (the "GPL"), in which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under either the MPL or the GPL. ======================================================================*/ #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> |
1da177e4c
|
41 42 43 44 45 46 47 |
#include <linux/ptrace.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/timer.h> #include <linux/ioport.h> #include <asm/io.h> #include <asm/system.h> |
1da177e4c
|
48 49 50 51 52 53 54 55 |
#include <pcmcia/cistpl.h> #include <pcmcia/cisreg.h> #include <pcmcia/ds.h> #include "hisax_cfg.h" MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Elsa PCM cards"); MODULE_AUTHOR("Klaus Lichtenwalder"); MODULE_LICENSE("Dual MPL/GPL"); |
1da177e4c
|
56 57 58 59 60 61 62 |
/*====================================================================*/ /* Parameters that can be set with 'insmod' */ static int protocol = 2; /* EURO-ISDN Default */ module_param(protocol, int, 0); |
f61bb62e3
|
63 |
static int elsa_cs_config(struct pcmcia_device *link) __devinit ; |
fba395eee
|
64 |
static void elsa_cs_release(struct pcmcia_device *link); |
f61bb62e3
|
65 |
static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit; |
1da177e4c
|
66 |
|
1da177e4c
|
67 |
typedef struct local_info_t { |
fd238232c
|
68 |
struct pcmcia_device *p_dev; |
1da177e4c
|
69 70 71 |
int busy; int cardnr; } local_info_t; |
f61bb62e3
|
72 |
static int __devinit elsa_cs_probe(struct pcmcia_device *link) |
1da177e4c
|
73 |
{ |
1da177e4c
|
74 |
local_info_t *local; |
1da177e4c
|
75 |
|
e773cfe16
|
76 77 |
dev_dbg(&link->dev, "elsa_cs_attach() "); |
1da177e4c
|
78 79 |
/* Allocate space for private device-specific data */ |
41f96935b
|
80 |
local = kzalloc(sizeof(local_info_t), GFP_KERNEL); |
f8cfa618d
|
81 |
if (!local) return -ENOMEM; |
fd238232c
|
82 |
|
fba395eee
|
83 |
local->p_dev = link; |
fd238232c
|
84 |
link->priv = local; |
1da177e4c
|
85 |
local->cardnr = -1; |
1da177e4c
|
86 |
|
15b99ac17
|
87 |
return elsa_cs_config(link); |
1da177e4c
|
88 |
} /* elsa_cs_attach */ |
f61bb62e3
|
89 |
static void __devexit elsa_cs_detach(struct pcmcia_device *link) |
1da177e4c
|
90 |
{ |
e2d409636
|
91 |
local_info_t *info = link->priv; |
1da177e4c
|
92 |
|
e773cfe16
|
93 94 |
dev_dbg(&link->dev, "elsa_cs_detach(0x%p) ", link); |
1da177e4c
|
95 |
|
e2d409636
|
96 97 |
info->busy = 1; elsa_cs_release(link); |
1da177e4c
|
98 |
|
e2d409636
|
99 |
kfree(info); |
1da177e4c
|
100 |
} /* elsa_cs_detach */ |
00990e7ce
|
101 |
static int elsa_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) |
1da177e4c
|
102 |
{ |
5fcd4da00
|
103 |
int j; |
90abdc3b9
|
104 |
p_dev->io_lines = 3; |
00990e7ce
|
105 106 107 |
p_dev->resource[0]->end = 8; p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH; p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; |
90abdc3b9
|
108 |
|
00990e7ce
|
109 |
if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) { |
5fcd4da00
|
110 111 |
printk(KERN_INFO "(elsa_cs: looks like the 96 model) "); |
90abdc3b9
|
112 |
if (!pcmcia_request_io(p_dev)) |
5fcd4da00
|
113 114 115 116 |
return 0; } else { printk(KERN_INFO "(elsa_cs: looks like the 97 model) "); |
5fcd4da00
|
117 |
for (j = 0x2f0; j > 0x100; j -= 0x10) { |
90abdc3b9
|
118 119 |
p_dev->resource[0]->start = j; if (!pcmcia_request_io(p_dev)) |
5fcd4da00
|
120 121 122 123 |
return 0; } } return -ENODEV; |
1da177e4c
|
124 |
} |
f61bb62e3
|
125 |
static int __devinit elsa_cs_config(struct pcmcia_device *link) |
1da177e4c
|
126 |
{ |
e773cfe16
|
127 |
int i; |
1da177e4c
|
128 |
IsdnCard_t icard; |
e773cfe16
|
129 130 |
dev_dbg(&link->dev, "elsa_config(0x%p) ", link); |
1da177e4c
|
131 |
|
00990e7ce
|
132 |
link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; |
5fcd4da00
|
133 |
i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); |
e773cfe16
|
134 135 |
if (i != 0) goto failed; |
1da177e4c
|
136 |
|
eb14120f7
|
137 |
if (!link->irq) |
e773cfe16
|
138 |
goto failed; |
1da177e4c
|
139 |
|
1ac71e5a3
|
140 |
i = pcmcia_enable_device(link); |
e773cfe16
|
141 142 |
if (i != 0) goto failed; |
1da177e4c
|
143 |
|
eb14120f7
|
144 |
icard.para[0] = link->irq; |
9a017a910
|
145 |
icard.para[1] = link->resource[0]->start; |
1da177e4c
|
146 147 148 149 150 |
icard.protocol = protocol; icard.typ = ISDN_CTYPE_ELSA_PCMCIA; i = hisax_init_pcmcia(link, &(((local_info_t*)link->priv)->busy), &icard); if (i < 0) { |
9a017a910
|
151 152 153 |
printk(KERN_ERR "elsa_cs: failed to initialize Elsa " "PCMCIA %d with %pR ", i, link->resource[0]); |
1da177e4c
|
154 155 156 |
elsa_cs_release(link); } else ((local_info_t*)link->priv)->cardnr = i; |
15b99ac17
|
157 |
return 0; |
e773cfe16
|
158 |
failed: |
1da177e4c
|
159 |
elsa_cs_release(link); |
15b99ac17
|
160 |
return -ENODEV; |
1da177e4c
|
161 |
} /* elsa_cs_config */ |
fba395eee
|
162 |
static void elsa_cs_release(struct pcmcia_device *link) |
1da177e4c
|
163 164 |
{ local_info_t *local = link->priv; |
e773cfe16
|
165 166 |
dev_dbg(&link->dev, "elsa_cs_release(0x%p) ", link); |
1da177e4c
|
167 168 169 170 171 172 173 |
if (local) { if (local->cardnr >= 0) { /* no unregister function with hisax */ HiSax_closecard(local->cardnr); } } |
5f2a71fcb
|
174 |
|
fba395eee
|
175 |
pcmcia_disable_device(link); |
1da177e4c
|
176 |
} /* elsa_cs_release */ |
fba395eee
|
177 |
static int elsa_suspend(struct pcmcia_device *link) |
98e4c28b7
|
178 |
{ |
98e4c28b7
|
179 |
local_info_t *dev = link->priv; |
98e4c28b7
|
180 |
dev->busy = 1; |
98e4c28b7
|
181 182 183 |
return 0; } |
fba395eee
|
184 |
static int elsa_resume(struct pcmcia_device *link) |
98e4c28b7
|
185 |
{ |
98e4c28b7
|
186 |
local_info_t *dev = link->priv; |
98e4c28b7
|
187 188 189 190 |
dev->busy = 0; return 0; } |
25f8f54f6
|
191 |
static const struct pcmcia_device_id elsa_ids[] = { |
02ae38cfc
|
192 193 194 195 196 |
PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257), PCMCIA_DEVICE_NULL }; MODULE_DEVICE_TABLE(pcmcia, elsa_ids); |
1da177e4c
|
197 198 |
static struct pcmcia_driver elsa_cs_driver = { .owner = THIS_MODULE, |
2e9b981a7
|
199 |
.name = "elsa_cs", |
15b99ac17
|
200 |
.probe = elsa_cs_probe, |
f61bb62e3
|
201 |
.remove = __devexit_p(elsa_cs_detach), |
02ae38cfc
|
202 |
.id_table = elsa_ids, |
98e4c28b7
|
203 204 |
.suspend = elsa_suspend, .resume = elsa_resume, |
1da177e4c
|
205 206 207 208 209 210 211 212 213 214 |
}; static int __init init_elsa_cs(void) { return pcmcia_register_driver(&elsa_cs_driver); } static void __exit exit_elsa_cs(void) { pcmcia_unregister_driver(&elsa_cs_driver); |
1da177e4c
|
215 216 217 218 |
} module_init(init_elsa_cs); module_exit(exit_elsa_cs); |