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.h>
12 #include <pcmcia/cistpl.h>
13 #include <pcmcia/ds.h>
18 * PCMCIA service support for Quicknet cards
22 typedef struct ixj_info_t
{
27 static void ixj_detach(struct pcmcia_device
*p_dev
);
28 static int ixj_config(struct pcmcia_device
* link
);
29 static void ixj_cs_release(struct pcmcia_device
* link
);
31 static int ixj_probe(struct pcmcia_device
*p_dev
)
33 dev_dbg(&p_dev
->dev
, "ixj_attach()\n");
34 /* Create new ixj device */
35 p_dev
->resource
[0]->flags
|= IO_DATA_PATH_WIDTH_8
;
36 p_dev
->resource
[1]->flags
|= IO_DATA_PATH_WIDTH_8
;
37 p_dev
->conf
.IntType
= INT_MEMORY_AND_IO
;
38 p_dev
->priv
= kzalloc(sizeof(struct ixj_info_t
), GFP_KERNEL
);
43 return ixj_config(p_dev
);
46 static void ixj_detach(struct pcmcia_device
*link
)
48 dev_dbg(&link
->dev
, "ixj_detach\n");
55 static void ixj_get_serial(struct pcmcia_device
* link
, IXJ
* j
)
59 dev_dbg(&link
->dev
, "ixj_get_serial\n");
61 str
= link
->prod_id
[0];
65 str
= link
->prod_id
[1];
69 str
= link
->prod_id
[2];
73 for (i
= strlen(str
) - 1; i
>= 0; i
--) {
85 j
->serial
+= (str
[i
] - 48) * place
;
93 j
->serial
+= (str
[i
] - 55) * place
;
101 j
->serial
+= (str
[i
] - 87) * place
;
104 place
= place
* 0x10;
106 str
= link
->prod_id
[3];
109 printk(" version %s\n", str
);
114 static int ixj_config_check(struct pcmcia_device
*p_dev
,
115 cistpl_cftable_entry_t
*cfg
,
116 cistpl_cftable_entry_t
*dflt
,
120 if ((cfg
->io
.nwin
> 0) || (dflt
->io
.nwin
> 0)) {
121 cistpl_io_t
*io
= (cfg
->io
.nwin
) ? &cfg
->io
: &dflt
->io
;
122 p_dev
->resource
[0]->start
= io
->win
[0].base
;
123 p_dev
->resource
[0]->end
= io
->win
[0].len
;
126 p_dev
->resource
[1]->start
= io
->win
[1].base
;
127 p_dev
->resource
[1]->end
= io
->win
[1].len
;
129 if (!pcmcia_request_io(p_dev
))
135 static int ixj_config(struct pcmcia_device
* link
)
139 cistpl_cftable_entry_t dflt
= { 0 };
142 dev_dbg(&link
->dev
, "ixj_config\n");
144 if (pcmcia_loop_config(link
, ixj_config_check
, &dflt
))
147 if (pcmcia_request_configuration(link
, &link
->conf
))
151 * Register the card with the core.
153 j
= ixj_pcmcia_probe(link
->resource
[0]->start
,
154 link
->resource
[0]->start
+ 0x10);
157 ixj_get_serial(link
, j
);
161 ixj_cs_release(link
);
165 static void ixj_cs_release(struct pcmcia_device
*link
)
167 ixj_info_t
*info
= link
->priv
;
168 dev_dbg(&link
->dev
, "ixj_cs_release\n");
170 pcmcia_disable_device(link
);
173 static struct pcmcia_device_id ixj_ids
[] = {
174 PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600),
177 MODULE_DEVICE_TABLE(pcmcia
, ixj_ids
);
179 static struct pcmcia_driver ixj_driver
= {
180 .owner
= THIS_MODULE
,
185 .remove
= ixj_detach
,
189 static int __init
ixj_pcmcia_init(void)
191 return pcmcia_register_driver(&ixj_driver
);
194 static void ixj_pcmcia_exit(void)
196 pcmcia_unregister_driver(&ixj_driver
);
199 module_init(ixj_pcmcia_init
);
200 module_exit(ixj_pcmcia_exit
);
202 MODULE_LICENSE("GPL");