rootfs_split fixes
[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 int __devinit bcm43xx_pcmcia_probe(struct pcmcia_device *dev)
59 {
60 struct ssb_bus *ssb;
61 win_req_t win;
62 memreq_t mem;
63 tuple_t tuple;
64 cisparse_t parse;
65 int err = -ENOMEM;
66 int res;
67 unsigned char buf[64];
68
69 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
70 if (!ssb)
71 goto out;
72
73 err = -ENODEV;
74 tuple.DesiredTuple = CISTPL_CONFIG;
75 tuple.Attributes = 0;
76 tuple.TupleData = buf;
77 tuple.TupleDataMax = sizeof(buf);
78 tuple.TupleOffset = 0;
79
80 res = pcmcia_get_first_tuple(dev, &tuple);
81 if (res != CS_SUCCESS)
82 goto err_kfree_ssb;
83 res = pcmcia_get_tuple_data(dev, &tuple);
84 if (res != CS_SUCCESS)
85 goto err_kfree_ssb;
86 res = pcmcia_parse_tuple(dev, &tuple, &parse);
87 if (res != CS_SUCCESS)
88 goto err_kfree_ssb;
89
90 dev->conf.ConfigBase = parse.config.base;
91 dev->conf.Present = parse.config.rmask[0];
92
93 dev->io.BasePort2 = 0;
94 dev->io.NumPorts2 = 0;
95 dev->io.Attributes2 = 0;
96
97 win.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
98 win.Base = 0;
99 win.Size = SSB_CORE_SIZE;
100 win.AccessSpeed = 1000;
101 res = pcmcia_request_window(&dev, &win, &dev->win);
102 if (res != CS_SUCCESS)
103 goto err_kfree_ssb;
104
105 mem.CardOffset = 0;
106 mem.Page = 0;
107 res = pcmcia_map_mem_page(dev->win, &mem);
108 if (res != CS_SUCCESS)
109 goto err_kfree_ssb;
110
111 res = pcmcia_request_configuration(dev, &dev->conf);
112 if (res != CS_SUCCESS)
113 goto err_disable;
114
115 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base);
116 dev->priv = ssb;
117
118 out:
119 return err;
120 err_disable:
121 pcmcia_disable_device(dev);
122 err_kfree_ssb:
123 kfree(ssb);
124 return err;
125 }
126
127 static void __devexit bcm43xx_pcmcia_remove(struct pcmcia_device *dev)
128 {
129 struct ssb_bus *ssb = dev->priv;
130
131 ssb_bus_unregister(ssb);
132 pcmcia_release_window(dev->win);
133 pcmcia_disable_device(dev);
134 kfree(ssb);
135 dev->priv = NULL;
136 }
137
138 static struct pcmcia_driver bcm43xx_pcmcia_driver = {
139 .owner = THIS_MODULE,
140 .drv = {
141 .name = "bcm43xx-pcmcia",
142 },
143 .id_table = bcm43xx_pcmcia_tbl,
144 .probe = bcm43xx_pcmcia_probe,
145 .remove = bcm43xx_pcmcia_remove,
146 .suspend = bcm43xx_pcmcia_suspend,
147 .resume = bcm43xx_pcmcia_resume,
148 };
149
150 int bcm43xx_pcmcia_init(void)
151 {
152 return pcmcia_register_driver(&bcm43xx_pcmcia_driver);
153 }
154
155 void bcm43xx_pcmcia_exit(void)
156 {
157 pcmcia_unregister_driver(&bcm43xx_pcmcia_driver);
158 }
This page took 0.063924 seconds and 5 git commands to generate.