2 * PCMCIA client driver for AVM A1 / Fritz!PCMCIA
5 * Copyright 1998-2001 by Carsten Paeth <calle@calle.in-berlin.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>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/ptrace.h>
18 #include <linux/slab.h>
19 #include <linux/string.h>
21 #include <asm/system.h>
23 #include <pcmcia/cistpl.h>
24 #include <pcmcia/ds.h>
25 #include "hisax_cfg.h"
27 MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for AVM A1/Fritz!PCMCIA cards");
28 MODULE_AUTHOR("Carsten Paeth");
29 MODULE_LICENSE("GPL");
32 /*====================================================================*/
34 /* Parameters that can be set with 'insmod' */
36 static int isdnprot
= 2;
38 module_param(isdnprot
, int, 0);
40 /*====================================================================*/
42 static int avma1cs_config(struct pcmcia_device
*link
) __devinit
;
43 static void avma1cs_release(struct pcmcia_device
*link
);
44 static void avma1cs_detach(struct pcmcia_device
*p_dev
) __devexit
;
46 static int __devinit
avma1cs_probe(struct pcmcia_device
*p_dev
)
48 dev_dbg(&p_dev
->dev
, "avma1cs_attach()\n");
50 /* General socket configuration */
51 p_dev
->config_flags
|= CONF_ENABLE_IRQ
| CONF_AUTO_SET_IO
;
52 p_dev
->config_index
= 1;
53 p_dev
->config_regs
= PRESENT_OPTION
;
55 return avma1cs_config(p_dev
);
56 } /* avma1cs_attach */
58 static void __devexit
avma1cs_detach(struct pcmcia_device
*link
)
60 dev_dbg(&link
->dev
, "avma1cs_detach(0x%p)\n", link
);
61 avma1cs_release(link
);
63 } /* avma1cs_detach */
65 static int avma1cs_configcheck(struct pcmcia_device
*p_dev
, void *priv_data
)
67 p_dev
->resource
[0]->end
= 16;
68 p_dev
->resource
[0]->flags
&= ~IO_DATA_PATH_WIDTH
;
69 p_dev
->resource
[0]->flags
|= IO_DATA_PATH_WIDTH_8
;
72 return pcmcia_request_io(p_dev
);
76 static int __devinit
avma1cs_config(struct pcmcia_device
*link
)
83 dev_dbg(&link
->dev
, "avma1cs_config(0x%p)\n", link
);
87 strlcpy(devname
, link
->prod_id
[1], sizeof(devname
));
89 if (pcmcia_loop_config(link
, avma1cs_configcheck
, NULL
))
94 * allocate an interrupt line
98 pcmcia_disable_device(link
);
103 * configure the PCMCIA socket
105 i
= pcmcia_enable_device(link
);
107 pcmcia_disable_device(link
);
113 /* If any step failed, release any partially configured state */
115 avma1cs_release(link
);
119 icard
.para
[0] = link
->irq
;
120 icard
.para
[1] = link
->resource
[0]->start
;
121 icard
.protocol
= isdnprot
;
122 icard
.typ
= ISDN_CTYPE_A1_PCMCIA
;
124 i
= hisax_init_pcmcia(link
, &busy
, &icard
);
126 printk(KERN_ERR
"avma1_cs: failed to initialize AVM A1 "
127 "PCMCIA %d at i/o %#x\n", i
,
128 (unsigned int) link
->resource
[0]->start
);
129 avma1cs_release(link
);
132 link
->priv
= (void *) (unsigned long) i
;
135 } /* avma1cs_config */
137 static void avma1cs_release(struct pcmcia_device
*link
)
139 unsigned long minor
= (unsigned long) link
->priv
;
141 dev_dbg(&link
->dev
, "avma1cs_release(0x%p)\n", link
);
143 /* now unregister function with hisax */
144 HiSax_closecard(minor
);
146 pcmcia_disable_device(link
);
147 } /* avma1cs_release */
149 static const struct pcmcia_device_id avma1cs_ids
[] = {
150 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
151 PCMCIA_DEVICE_PROD_ID12("ISDN", "CARD", 0x8d9761c8, 0x01c5aa7b),
154 MODULE_DEVICE_TABLE(pcmcia
, avma1cs_ids
);
156 static struct pcmcia_driver avma1cs_driver
= {
157 .owner
= THIS_MODULE
,
159 .probe
= avma1cs_probe
,
160 .remove
= __devexit_p(avma1cs_detach
),
161 .id_table
= avma1cs_ids
,
164 static int __init
init_avma1_cs(void)
166 return pcmcia_register_driver(&avma1cs_driver
);
169 static void __exit
exit_avma1_cs(void)
171 pcmcia_unregister_driver(&avma1cs_driver
);
174 module_init(init_avma1_cs
);
175 module_exit(exit_avma1_cs
);