1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/netdevice.h>
33#include <pcmcia/cistpl.h>
34#include <pcmcia/ds.h>
35
36
37
38MODULE_AUTHOR("Wai Chan");
39MODULE_DESCRIPTION("FT1000 PCMCIA driver");
40MODULE_LICENSE("GPL");
41
42
43
44static int ft1000_config(struct pcmcia_device *link);
45static void ft1000_detach(struct pcmcia_device *link);
46static int ft1000_attach(struct pcmcia_device *link);
47
48#include "ft1000.h"
49
50
51
52static void ft1000_reset(struct pcmcia_device *link)
53{
54 pcmcia_reset_card(link->socket);
55}
56
57static int ft1000_attach(struct pcmcia_device *link)
58{
59 link->priv = NULL;
60 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
61
62 return ft1000_config(link);
63}
64
65static void ft1000_detach(struct pcmcia_device *link)
66{
67 struct net_device *dev = link->priv;
68
69 if (dev)
70 stop_ft1000_card(dev);
71
72 pcmcia_disable_device(link);
73 free_netdev(dev);
74}
75
76static int ft1000_confcheck(struct pcmcia_device *link, void *priv_data)
77{
78 return pcmcia_request_io(link);
79}
80
81
82
83
84
85
86
87
88
89static int ft1000_config(struct pcmcia_device *link)
90{
91 int ret;
92
93 dev_dbg(&link->dev, "ft1000_cs: ft1000_config(0x%p)\n", link);
94
95
96 ret = pcmcia_loop_config(link, ft1000_confcheck, NULL);
97 if (ret) {
98 printk(KERN_INFO "ft1000: Could not configure pcmcia\n");
99 return -ENODEV;
100 }
101
102
103 ret = pcmcia_enable_device(link);
104 if (ret) {
105 printk(KERN_INFO "ft1000: could not enable pcmcia\n");
106 goto failed;
107 }
108
109 link->priv = init_ft1000_card(link, &ft1000_reset);
110 if (!link->priv) {
111 printk(KERN_INFO "ft1000: Could not register as network device\n");
112 goto failed;
113 }
114
115
116
117 return 0;
118failed:
119 pcmcia_disable_device(link);
120 return -ENODEV;
121}
122
123static int ft1000_suspend(struct pcmcia_device *link)
124{
125 struct net_device *dev = link->priv;
126
127 if (link->open)
128 netif_device_detach(dev);
129 return 0;
130}
131
132static int ft1000_resume(struct pcmcia_device *link)
133{
134 return 0;
135}
136
137
138
139static const struct pcmcia_device_id ft1000_ids[] = {
140 PCMCIA_DEVICE_MANF_CARD(0x02cc, 0x0100),
141 PCMCIA_DEVICE_MANF_CARD(0x02cc, 0x1000),
142 PCMCIA_DEVICE_MANF_CARD(0x02cc, 0x1300),
143 PCMCIA_DEVICE_NULL,
144};
145
146MODULE_DEVICE_TABLE(pcmcia, ft1000_ids);
147
148static struct pcmcia_driver ft1000_cs_driver = {
149 .owner = THIS_MODULE,
150 .name = "ft1000_cs",
151 .probe = ft1000_attach,
152 .remove = ft1000_detach,
153 .id_table = ft1000_ids,
154 .suspend = ft1000_suspend,
155 .resume = ft1000_resume,
156};
157
158static int __init init_ft1000_cs(void)
159{
160 return pcmcia_register_driver(&ft1000_cs_driver);
161}
162
163static void __exit exit_ft1000_cs(void)
164{
165 pcmcia_unregister_driver(&ft1000_cs_driver);
166}
167
168module_init(init_ft1000_cs);
169module_exit(exit_ft1000_cs);
170