1 /* $Id: teles_cs.c,v 1.1.2.2 2004/01/25 15:07:06 keil Exp $ */
2 /*======================================================================
4 A teles S0 PCMCIA client driver
6 Based on skeleton by David Hinds, dhinds@allegro.stanford.edu
7 Written by Christof Petig, christof.petig@wtal.de
9 Also inspired by ELSA PCMCIA driver
10 by Klaus Lichtenwalder <Lichtenwalder@ACM.org>
12 Extensions to new hisax_pcmcia by Karsten Keil
14 minor changes to be compatible with kernel 2.4.x
15 by Jan.Schubert@GMX.li
17 ======================================================================*/
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/init.h>
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>
29 #include <pcmcia/cistpl.h>
30 #include <pcmcia/cisreg.h>
31 #include <pcmcia/ds.h>
32 #include "hisax_cfg.h"
34 MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Teles PCMCIA cards");
35 MODULE_AUTHOR("Christof Petig, christof.petig@wtal.de, Karsten Keil, kkeil@suse.de");
36 MODULE_LICENSE("GPL");
39 /*====================================================================*/
41 /* Parameters that can be set with 'insmod' */
43 static int protocol
= 2; /* EURO-ISDN Default */
44 module_param(protocol
, int, 0);
46 static int teles_cs_config(struct pcmcia_device
*link
);
47 static void teles_cs_release(struct pcmcia_device
*link
);
48 static void teles_detach(struct pcmcia_device
*p_dev
);
50 typedef struct local_info_t
{
51 struct pcmcia_device
*p_dev
;
56 static int teles_probe(struct pcmcia_device
*link
)
60 dev_dbg(&link
->dev
, "teles_attach()\n");
62 /* Allocate space for private device-specific data */
63 local
= kzalloc(sizeof(local_info_t
), GFP_KERNEL
);
64 if (!local
) return -ENOMEM
;
70 link
->config_flags
|= CONF_ENABLE_IRQ
| CONF_AUTO_SET_IO
;
72 return teles_cs_config(link
);
75 static void teles_detach(struct pcmcia_device
*link
)
77 local_info_t
*info
= link
->priv
;
79 dev_dbg(&link
->dev
, "teles_detach(0x%p)\n", link
);
82 teles_cs_release(link
);
87 static int teles_cs_configcheck(struct pcmcia_device
*p_dev
, void *priv_data
)
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
;
96 if ((p_dev
->resource
[0]->end
) && p_dev
->resource
[0]->start
) {
97 printk(KERN_INFO
"(teles_cs: looks like the 96 model)\n");
98 if (!pcmcia_request_io(p_dev
))
101 printk(KERN_INFO
"(teles_cs: looks like the 97 model)\n");
102 for (j
= 0x2f0; j
> 0x100; j
-= 0x10) {
103 p_dev
->resource
[0]->start
= j
;
104 if (!pcmcia_request_io(p_dev
))
111 static int teles_cs_config(struct pcmcia_device
*link
)
116 dev_dbg(&link
->dev
, "teles_config(0x%p)\n", link
);
118 i
= pcmcia_loop_config(link
, teles_cs_configcheck
, NULL
);
125 i
= pcmcia_enable_device(link
);
129 icard
.para
[0] = link
->irq
;
130 icard
.para
[1] = link
->resource
[0]->start
;
131 icard
.protocol
= protocol
;
132 icard
.typ
= ISDN_CTYPE_TELESPCMCIA
;
134 i
= hisax_init_pcmcia(link
, &(((local_info_t
*)link
->priv
)->busy
), &icard
);
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
);
142 ((local_info_t
*)link
->priv
)->cardnr
= i
;
146 teles_cs_release(link
);
148 } /* teles_cs_config */
150 static void teles_cs_release(struct pcmcia_device
*link
)
152 local_info_t
*local
= link
->priv
;
154 dev_dbg(&link
->dev
, "teles_cs_release(0x%p)\n", link
);
157 if (local
->cardnr
>= 0) {
158 /* no unregister function with hisax */
159 HiSax_closecard(local
->cardnr
);
163 pcmcia_disable_device(link
);
164 } /* teles_cs_release */
166 static int teles_suspend(struct pcmcia_device
*link
)
168 local_info_t
*dev
= link
->priv
;
175 static int teles_resume(struct pcmcia_device
*link
)
177 local_info_t
*dev
= link
->priv
;
185 static const struct pcmcia_device_id teles_ids
[] = {
186 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119),
189 MODULE_DEVICE_TABLE(pcmcia
, teles_ids
);
191 static struct pcmcia_driver teles_cs_driver
= {
192 .owner
= THIS_MODULE
,
194 .probe
= teles_probe
,
195 .remove
= teles_detach
,
196 .id_table
= teles_ids
,
197 .suspend
= teles_suspend
,
198 .resume
= teles_resume
,
200 module_pcmcia_driver(teles_cs_driver
);