3 #include <linux/module.h>
5 #include <linux/init.h>
6 #include <linux/kernel.h> /* printk() */
7 #include <linux/fs.h> /* everything... */
8 #include <linux/errno.h> /* error codes */
9 #include <linux/slab.h>
11 #include <pcmcia/cs_types.h>
12 #include <pcmcia/cs.h>
13 #include <pcmcia/cistpl.h>
14 #include <pcmcia/ds.h>
19 * PCMCIA service support for Quicknet cards
23 typedef struct ixj_info_t
{
29 static void ixj_detach(struct pcmcia_device
*p_dev
);
30 static int ixj_config(struct pcmcia_device
* link
);
31 static void ixj_cs_release(struct pcmcia_device
* link
);
33 static int ixj_probe(struct pcmcia_device
*p_dev
)
35 dev_dbg(&p_dev
->dev
, "ixj_attach()\n");
36 /* Create new ixj device */
37 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
38 p_dev
->io
.Attributes2
= IO_DATA_PATH_WIDTH_8
;
39 p_dev
->io
.IOAddrLines
= 3;
40 p_dev
->conf
.IntType
= INT_MEMORY_AND_IO
;
41 p_dev
->priv
= kzalloc(sizeof(struct ixj_info_t
), GFP_KERNEL
);
46 return ixj_config(p_dev
);
49 static void ixj_detach(struct pcmcia_device
*link
)
51 dev_dbg(&link
->dev
, "ixj_detach\n");
58 static void ixj_get_serial(struct pcmcia_device
* link
, IXJ
* j
)
62 dev_dbg(&link
->dev
, "ixj_get_serial\n");
64 str
= link
->prod_id
[0];
68 str
= link
->prod_id
[1];
72 str
= link
->prod_id
[2];
76 for (i
= strlen(str
) - 1; i
>= 0; i
--) {
88 j
->serial
+= (str
[i
] - 48) * place
;
96 j
->serial
+= (str
[i
] - 55) * place
;
104 j
->serial
+= (str
[i
] - 87) * place
;
107 place
= place
* 0x10;
109 str
= link
->prod_id
[3];
112 printk(" version %s\n", str
);
117 static int ixj_config_check(struct pcmcia_device
*p_dev
,
118 cistpl_cftable_entry_t
*cfg
,
119 cistpl_cftable_entry_t
*dflt
,
123 if ((cfg
->io
.nwin
> 0) || (dflt
->io
.nwin
> 0)) {
124 cistpl_io_t
*io
= (cfg
->io
.nwin
) ? &cfg
->io
: &dflt
->io
;
125 p_dev
->io
.BasePort1
= io
->win
[0].base
;
126 p_dev
->io
.NumPorts1
= io
->win
[0].len
;
128 p_dev
->io
.BasePort2
= io
->win
[1].base
;
129 p_dev
->io
.NumPorts2
= io
->win
[1].len
;
131 if (!pcmcia_request_io(p_dev
, &p_dev
->io
))
137 static int ixj_config(struct pcmcia_device
* link
)
141 cistpl_cftable_entry_t dflt
= { 0 };
144 dev_dbg(&link
->dev
, "ixj_config\n");
146 if (pcmcia_loop_config(link
, ixj_config_check
, &dflt
))
149 if (pcmcia_request_configuration(link
, &link
->conf
))
153 * Register the card with the core.
155 j
= ixj_pcmcia_probe(link
->io
.BasePort1
, link
->io
.BasePort1
+ 0x10);
158 info
->node
.major
= PHONE_MAJOR
;
159 link
->dev_node
= &info
->node
;
160 ixj_get_serial(link
, j
);
164 ixj_cs_release(link
);
168 static void ixj_cs_release(struct pcmcia_device
*link
)
170 ixj_info_t
*info
= link
->priv
;
171 dev_dbg(&link
->dev
, "ixj_cs_release\n");
173 pcmcia_disable_device(link
);
176 static struct pcmcia_device_id ixj_ids
[] = {
177 PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600),
180 MODULE_DEVICE_TABLE(pcmcia
, ixj_ids
);
182 static struct pcmcia_driver ixj_driver
= {
183 .owner
= THIS_MODULE
,
188 .remove
= ixj_detach
,
192 static int __init
ixj_pcmcia_init(void)
194 return pcmcia_register_driver(&ixj_driver
);
197 static void ixj_pcmcia_exit(void)
199 pcmcia_unregister_driver(&ixj_driver
);
202 module_init(ixj_pcmcia_init
);
203 module_exit(ixj_pcmcia_exit
);
205 MODULE_LICENSE("GPL");