]>
Commit | Line | Data |
---|---|---|
e4d6b795 MB |
1 | /* |
2 | ||
3 | Broadcom B43 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 | ||
1a09404a MB |
24 | #include "pcmcia.h" |
25 | ||
e4d6b795 | 26 | #include <linux/ssb/ssb.h> |
5a0e3ad6 | 27 | #include <linux/slab.h> |
e4d6b795 MB |
28 | |
29 | #include <pcmcia/cs_types.h> | |
30 | #include <pcmcia/cs.h> | |
31 | #include <pcmcia/cistpl.h> | |
32 | #include <pcmcia/ciscode.h> | |
33 | #include <pcmcia/ds.h> | |
34 | #include <pcmcia/cisreg.h> | |
35 | ||
1a09404a | 36 | |
e4d6b795 MB |
37 | static /*const */ struct pcmcia_device_id b43_pcmcia_tbl[] = { |
38 | PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448), | |
cff782cd | 39 | PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476), |
e4d6b795 MB |
40 | PCMCIA_DEVICE_NULL, |
41 | }; | |
42 | ||
43 | MODULE_DEVICE_TABLE(pcmcia, b43_pcmcia_tbl); | |
44 | ||
45 | #ifdef CONFIG_PM | |
46 | static int b43_pcmcia_suspend(struct pcmcia_device *dev) | |
47 | { | |
8fe2b65a MB |
48 | struct ssb_bus *ssb = dev->priv; |
49 | ||
50 | return ssb_bus_suspend(ssb); | |
e4d6b795 MB |
51 | } |
52 | ||
53 | static int b43_pcmcia_resume(struct pcmcia_device *dev) | |
54 | { | |
8fe2b65a MB |
55 | struct ssb_bus *ssb = dev->priv; |
56 | ||
57 | return ssb_bus_resume(ssb); | |
e4d6b795 MB |
58 | } |
59 | #else /* CONFIG_PM */ | |
60 | # define b43_pcmcia_suspend NULL | |
61 | # define b43_pcmcia_resume NULL | |
62 | #endif /* CONFIG_PM */ | |
63 | ||
64 | static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |
65 | { | |
66 | struct ssb_bus *ssb; | |
67 | win_req_t win; | |
68 | memreq_t mem; | |
e4d6b795 | 69 | int err = -ENOMEM; |
ce2d9059 | 70 | int res = 0; |
e4d6b795 MB |
71 | |
72 | ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); | |
73 | if (!ssb) | |
ce2d9059 | 74 | goto out_error; |
e4d6b795 MB |
75 | |
76 | err = -ENODEV; | |
e4d6b795 | 77 | |
e6458901 MB |
78 | dev->conf.Attributes = CONF_ENABLE_IRQ; |
79 | dev->conf.IntType = INT_MEMORY_AND_IO; | |
e4d6b795 MB |
80 | |
81 | dev->io.BasePort2 = 0; | |
82 | dev->io.NumPorts2 = 0; | |
83 | dev->io.Attributes2 = 0; | |
84 | ||
ce2d9059 MB |
85 | win.Attributes = WIN_ADDR_SPACE_MEM | WIN_MEMORY_TYPE_CM | |
86 | WIN_ENABLE | WIN_DATA_WIDTH_16 | | |
87 | WIN_USE_WAIT; | |
e4d6b795 MB |
88 | win.Base = 0; |
89 | win.Size = SSB_CORE_SIZE; | |
ce2d9059 | 90 | win.AccessSpeed = 250; |
6838b03f | 91 | res = pcmcia_request_window(dev, &win, &dev->win); |
4c89e88b | 92 | if (res != 0) |
e4d6b795 MB |
93 | goto err_kfree_ssb; |
94 | ||
95 | mem.CardOffset = 0; | |
96 | mem.Page = 0; | |
868575d1 | 97 | res = pcmcia_map_mem_page(dev, dev->win, &mem); |
4c89e88b | 98 | if (res != 0) |
ce2d9059 | 99 | goto err_disable; |
e4d6b795 | 100 | |
eb14120f | 101 | if (!dev->irq) |
9dcb5f47 MB |
102 | goto err_disable; |
103 | ||
e4d6b795 | 104 | res = pcmcia_request_configuration(dev, &dev->conf); |
4c89e88b | 105 | if (res != 0) |
e4d6b795 MB |
106 | goto err_disable; |
107 | ||
108 | err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); | |
ce2d9059 MB |
109 | if (err) |
110 | goto err_disable; | |
e4d6b795 MB |
111 | dev->priv = ssb; |
112 | ||
ce2d9059 MB |
113 | return 0; |
114 | ||
115 | err_disable: | |
e4d6b795 | 116 | pcmcia_disable_device(dev); |
ce2d9059 | 117 | err_kfree_ssb: |
e4d6b795 | 118 | kfree(ssb); |
ce2d9059 MB |
119 | out_error: |
120 | printk(KERN_ERR "b43-pcmcia: Initialization failed (%d, %d)\n", | |
121 | res, err); | |
e4d6b795 MB |
122 | return err; |
123 | } | |
124 | ||
125 | static void __devexit b43_pcmcia_remove(struct pcmcia_device *dev) | |
126 | { | |
127 | struct ssb_bus *ssb = dev->priv; | |
128 | ||
129 | ssb_bus_unregister(ssb); | |
e4d6b795 MB |
130 | pcmcia_disable_device(dev); |
131 | kfree(ssb); | |
132 | dev->priv = NULL; | |
133 | } | |
134 | ||
135 | static struct pcmcia_driver b43_pcmcia_driver = { | |
ce2d9059 MB |
136 | .owner = THIS_MODULE, |
137 | .drv = { | |
138 | .name = "b43-pcmcia", | |
139 | }, | |
140 | .id_table = b43_pcmcia_tbl, | |
141 | .probe = b43_pcmcia_probe, | |
142 | .remove = __devexit_p(b43_pcmcia_remove), | |
143 | .suspend = b43_pcmcia_suspend, | |
144 | .resume = b43_pcmcia_resume, | |
e4d6b795 MB |
145 | }; |
146 | ||
147 | int b43_pcmcia_init(void) | |
148 | { | |
149 | return pcmcia_register_driver(&b43_pcmcia_driver); | |
150 | } | |
151 | ||
152 | void b43_pcmcia_exit(void) | |
153 | { | |
154 | pcmcia_unregister_driver(&b43_pcmcia_driver); | |
155 | } |