1 /* $Id: avm_cs.c,v 1.4.6.3 2001/09/23 22:24:33 kai Exp $
3 * A PCMCIA client driver for AVM B1/M1/M2
5 * Copyright 1999 by Carsten Paeth <calle@calle.de>
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/ptrace.h>
16 #include <linux/string.h>
17 #include <linux/tty.h>
18 #include <linux/serial.h>
19 #include <linux/major.h>
21 #include <asm/system.h>
23 #include <pcmcia/cistpl.h>
24 #include <pcmcia/ciscode.h>
25 #include <pcmcia/ds.h>
26 #include <pcmcia/cisreg.h>
28 #include <linux/skbuff.h>
29 #include <linux/capi.h>
30 #include <linux/b1lli.h>
31 #include <linux/b1pcmcia.h>
33 /*====================================================================*/
35 MODULE_DESCRIPTION("CAPI4Linux: PCMCIA client driver for AVM B1/M1/M2");
36 MODULE_AUTHOR("Carsten Paeth");
37 MODULE_LICENSE("GPL");
39 /*====================================================================*/
41 static int avmcs_config(struct pcmcia_device
*link
);
42 static void avmcs_release(struct pcmcia_device
*link
);
43 static void avmcs_detach(struct pcmcia_device
*p_dev
);
45 static int avmcs_probe(struct pcmcia_device
*p_dev
)
47 /* General socket configuration */
48 p_dev
->config_flags
|= CONF_ENABLE_IRQ
| CONF_AUTO_SET_IO
;
49 p_dev
->config_index
= 1;
50 p_dev
->config_regs
= PRESENT_OPTION
;
52 return avmcs_config(p_dev
);
56 static void avmcs_detach(struct pcmcia_device
*link
)
61 static int avmcs_configcheck(struct pcmcia_device
*p_dev
, void *priv_data
)
63 p_dev
->resource
[0]->end
= 16;
64 p_dev
->resource
[0]->flags
&= ~IO_DATA_PATH_WIDTH
;
65 p_dev
->resource
[0]->flags
|= IO_DATA_PATH_WIDTH_8
;
67 return pcmcia_request_io(p_dev
);
70 static int avmcs_config(struct pcmcia_device
*link
)
75 int (*addcard
)(unsigned int port
, unsigned irq
);
79 strlcpy(devname
, link
->prod_id
[1], sizeof(devname
));
84 if (pcmcia_loop_config(link
, avmcs_configcheck
, NULL
))
90 pcmcia_disable_device(link
);
95 * configure the PCMCIA socket
97 i
= pcmcia_enable_device(link
);
99 pcmcia_disable_device(link
);
106 char *s
= strrchr(devname
, ' ');
110 if (strcmp("M1", s
) == 0) {
111 cardtype
= AVM_CARDTYPE_M1
;
112 } else if (strcmp("M2", s
) == 0) {
113 cardtype
= AVM_CARDTYPE_M2
;
115 cardtype
= AVM_CARDTYPE_B1
;
118 cardtype
= AVM_CARDTYPE_B1
;
120 /* If any step failed, release any partially configured state */
128 case AVM_CARDTYPE_M1
: addcard
= b1pcmcia_addcard_m1
; break;
129 case AVM_CARDTYPE_M2
: addcard
= b1pcmcia_addcard_m2
; break;
131 case AVM_CARDTYPE_B1
: addcard
= b1pcmcia_addcard_b1
; break;
133 if ((i
= (*addcard
)(link
->resource
[0]->start
, link
->irq
)) < 0) {
135 "avm_cs: failed to add AVM-Controller at i/o %#x, irq %d\n",
136 (unsigned int) link
->resource
[0]->start
, link
->irq
);
145 static void avmcs_release(struct pcmcia_device
*link
)
147 b1pcmcia_delcard(link
->resource
[0]->start
, link
->irq
);
148 pcmcia_disable_device(link
);
149 } /* avmcs_release */
152 static const struct pcmcia_device_id avmcs_ids
[] = {
153 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
154 PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M1", 0x95d42008, 0x81e10430),
155 PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M2", 0x95d42008, 0x18e8558a),
158 MODULE_DEVICE_TABLE(pcmcia
, avmcs_ids
);
160 static struct pcmcia_driver avmcs_driver
= {
161 .owner
= THIS_MODULE
,
163 .probe
= avmcs_probe
,
164 .remove
= avmcs_detach
,
165 .id_table
= avmcs_ids
,
168 static int __init
avmcs_init(void)
170 return pcmcia_register_driver(&avmcs_driver
);
173 static void __exit
avmcs_exit(void)
175 pcmcia_unregister_driver(&avmcs_driver
);
178 module_init(avmcs_init
);
179 module_exit(avmcs_exit
);