2 * PCMCIA driver for SL811HS (as found in REX-CFU1U)
4 * Author: Yukio Yamamoto
6 * Port to sl811-hcd and 2.6.x by
7 * Botond Botyanszki <boti@rocketmail.com>
10 * Last update: 2005-05-12
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/ptrace.h>
16 #include <linux/slab.h>
17 #include <linux/string.h>
18 #include <linux/timer.h>
19 #include <linux/ioport.h>
20 #include <linux/platform_device.h>
22 #include <pcmcia/cistpl.h>
23 #include <pcmcia/cisreg.h>
24 #include <pcmcia/ds.h>
26 #include <linux/usb/sl811.h>
28 MODULE_AUTHOR("Botond Botyanszki");
29 MODULE_DESCRIPTION("REX-CFU1U PCMCIA driver for 2.6");
30 MODULE_LICENSE("GPL");
33 /*====================================================================*/
35 /*====================================================================*/
37 #define INFO(args...) printk(KERN_INFO "sl811_cs: " args)
39 /*====================================================================*/
41 /*====================================================================*/
43 typedef struct local_info_t
{
44 struct pcmcia_device
*p_dev
;
47 static void sl811_cs_release(struct pcmcia_device
* link
);
49 /*====================================================================*/
51 static void release_platform_dev(struct device
* dev
)
53 dev_dbg(dev
, "sl811_cs platform_dev release\n");
57 static struct sl811_platform_data platform_data
= {
59 .power
= 50, /* == 100mA */
60 // .reset = ... FIXME: invoke CF reset on the card
63 static struct resource resources
[] = {
65 .flags
= IORESOURCE_IRQ
,
69 .flags
= IORESOURCE_IO
,
73 .flags
= IORESOURCE_IO
,
77 extern struct platform_driver sl811h_driver
;
79 static struct platform_device platform_dev
= {
82 .platform_data
= &platform_data
,
83 .release
= release_platform_dev
,
85 .resource
= resources
,
86 .num_resources
= ARRAY_SIZE(resources
),
89 static int sl811_hc_init(struct device
*parent
, resource_size_t base_addr
,
92 if (platform_dev
.dev
.parent
)
94 platform_dev
.dev
.parent
= parent
;
96 /* finish seting up the platform device */
97 resources
[0].start
= irq
;
99 resources
[1].start
= base_addr
;
100 resources
[1].end
= base_addr
;
102 resources
[2].start
= base_addr
+ 1;
103 resources
[2].end
= base_addr
+ 1;
105 /* The driver core will probe for us. We know sl811-hcd has been
106 * initialized already because of the link order dependency created
107 * by referencing "sl811h_driver".
109 platform_dev
.name
= sl811h_driver
.driver
.name
;
110 return platform_device_register(&platform_dev
);
113 /*====================================================================*/
115 static void sl811_cs_detach(struct pcmcia_device
*link
)
117 dev_dbg(&link
->dev
, "sl811_cs_detach\n");
119 sl811_cs_release(link
);
121 /* This points to the parent local_info_t struct */
125 static void sl811_cs_release(struct pcmcia_device
* link
)
127 dev_dbg(&link
->dev
, "sl811_cs_release\n");
129 pcmcia_disable_device(link
);
130 platform_device_unregister(&platform_dev
);
133 static int sl811_cs_config_check(struct pcmcia_device
*p_dev
, void *priv_data
)
135 if (p_dev
->config_index
== 0)
138 return pcmcia_request_io(p_dev
);
142 static int sl811_cs_config(struct pcmcia_device
*link
)
144 struct device
*parent
= &link
->dev
;
147 dev_dbg(&link
->dev
, "sl811_cs_config\n");
149 link
->config_flags
|= CONF_ENABLE_IRQ
| CONF_AUTO_SET_VPP
|
150 CONF_AUTO_CHECK_VCC
| CONF_AUTO_SET_IO
;
152 if (pcmcia_loop_config(link
, sl811_cs_config_check
, NULL
))
155 /* require an IRQ and two registers */
156 if (resource_size(link
->resource
[0]) < 2)
162 ret
= pcmcia_enable_device(link
);
166 if (sl811_hc_init(parent
, link
->resource
[0]->start
, link
->irq
)
169 printk(KERN_WARNING
"sl811_cs_config failed\n");
170 sl811_cs_release(link
);
176 static int sl811_cs_probe(struct pcmcia_device
*link
)
180 local
= kzalloc(sizeof(local_info_t
), GFP_KERNEL
);
186 return sl811_cs_config(link
);
189 static const struct pcmcia_device_id sl811_ids
[] = {
190 PCMCIA_DEVICE_MANF_CARD(0xc015, 0x0001), /* RATOC USB HOST CF+ Card */
193 MODULE_DEVICE_TABLE(pcmcia
, sl811_ids
);
195 static struct pcmcia_driver sl811_cs_driver
= {
196 .owner
= THIS_MODULE
,
198 .probe
= sl811_cs_probe
,
199 .remove
= sl811_cs_detach
,
200 .id_table
= sl811_ids
,
202 module_pcmcia_driver(sl811_cs_driver
);