New: mac80211-based bcm43xx driver from the wireless-dev tree
[openwrt.git] / package / bcm43xx-mac80211 / src / bcm43xx / bcm43xx_pcmcia.c
1 /*
2
3 Broadcom BCM43xx wireless driver
4
5 Copyright (c) 2007 Michael Buesch <mb@bu3sch.de>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21
22 */
23
24 #include <linux/ssb/ssb.h>
25
26 #include <pcmcia/cs_types.h>
27 #include <pcmcia/cs.h>
28 #include <pcmcia/cistpl.h>
29 #include <pcmcia/ciscode.h>
30 #include <pcmcia/ds.h>
31 #include <pcmcia/cisreg.h>
32
33
34 static /*const*/ struct pcmcia_device_id bcm43xx_pcmcia_tbl[] = {
35 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
36 PCMCIA_DEVICE_NULL,
37 };
38 MODULE_DEVICE_TABLE(pcmcia, bcm43xx_pcmcia_tbl);
39
40
41 #ifdef CONFIG_PM
42 static int bcm43xx_pcmcia_suspend(struct pcmcia_device *dev)
43 {
44 //TODO
45 return 0;
46 }
47
48 static int bcm43xx_pcmcia_resume(struct pcmcia_device *dev)
49 {
50 //TODO
51 return 0;
52 }
53 #else /* CONFIG_PM */
54 # define bcm43xx_pcmcia_suspend NULL
55 # define bcm43xx_pcmcia_resume NULL
56 #endif /* CONFIG_PM */
57
58 static void bcm43xx_pcmcia_fill_sprom(struct ssb_sprom *sprom)
59 {//TODO
60 }
61
62 static int __devinit bcm43xx_pcmcia_probe(struct pcmcia_device *dev)
63 {
64 struct ssb_bus *ssb;
65 win_req_t win;
66 memreq_t mem;
67 tuple_t tuple;
68 cisparse_t parse;
69 int err = -ENOMEM;
70 int res;
71 unsigned char buf[64];
72
73 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
74 if (!ssb)
75 goto out;
76
77 err = -ENODEV;
78 tuple.DesiredTuple = CISTPL_CONFIG;
79 tuple.Attributes = 0;
80 tuple.TupleData = buf;
81 tuple.TupleDataMax = sizeof(buf);
82 tuple.TupleOffset = 0;
83
84 res = pcmcia_get_first_tuple(dev, &tuple);
85 if (res != CS_SUCCESS)
86 goto err_kfree_ssb;
87 res = pcmcia_get_tuple_data(dev, &tuple);
88 if (res != CS_SUCCESS)
89 goto err_kfree_ssb;
90 res = pcmcia_parse_tuple(dev, &tuple, &parse);
91 if (res != CS_SUCCESS)
92 goto err_kfree_ssb;
93
94 dev->conf.ConfigBase = parse.config.base;
95 dev->conf.Present = parse.config.rmask[0];
96
97 dev->io.BasePort2 = 0;
98 dev->io.NumPorts2 = 0;
99 dev->io.Attributes2 = 0;
100
101 win.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
102 win.Base = 0;
103 win.Size = SSB_CORE_SIZE;
104 win.AccessSpeed = 1000;
105 res = pcmcia_request_window(&dev, &win, &dev->win);
106 if (res != CS_SUCCESS)
107 goto err_kfree_ssb;
108
109 mem.CardOffset = 0;
110 mem.Page = 0;
111 res = pcmcia_map_mem_page(dev->win, &mem);
112 if (res != CS_SUCCESS)
113 goto err_kfree_ssb;
114
115 res = pcmcia_request_configuration(dev, &dev->conf);
116 if (res != CS_SUCCESS)
117 goto err_disable;
118
119 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base,
120 bcm43xx_pcmcia_fill_sprom);
121 dev->priv = ssb;
122
123 out:
124 return err;
125 err_disable:
126 pcmcia_disable_device(dev);
127 err_kfree_ssb:
128 kfree(ssb);
129 return err;
130 }
131
132 static void __devexit bcm43xx_pcmcia_remove(struct pcmcia_device *dev)
133 {
134 struct ssb_bus *ssb = dev->priv;
135
136 ssb_bus_unregister(ssb);
137 pcmcia_release_window(dev->win);
138 pcmcia_disable_device(dev);
139 kfree(ssb);
140 dev->priv = NULL;
141 }
142
143 static struct pcmcia_driver bcm43xx_pcmcia_driver = {
144 .owner = THIS_MODULE,
145 .drv = {
146 .name = "bcm43xx-pcmcia",
147 },
148 .id_table = bcm43xx_pcmcia_tbl,
149 .probe = bcm43xx_pcmcia_probe,
150 .remove = bcm43xx_pcmcia_remove,
151 .suspend = bcm43xx_pcmcia_suspend,
152 .resume = bcm43xx_pcmcia_resume,
153 };
154
155 int bcm43xx_pcmcia_init(void)
156 {
157 return pcmcia_register_driver(&bcm43xx_pcmcia_driver);
158 }
159
160 void bcm43xx_pcmcia_exit(void)
161 {
162 pcmcia_unregister_driver(&bcm43xx_pcmcia_driver);
163 }
This page took 0.053286 seconds and 5 git commands to generate.