| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 1 | /* | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 2 | * This file is part of wl1251 | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 3 | * | 
|  | 4 | * Copyright (C) 2008 Nokia Corporation | 
|  | 5 | * | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or | 
|  | 7 | * modify it under the terms of the GNU General Public License | 
|  | 8 | * version 2 as published by the Free Software Foundation. | 
|  | 9 | * | 
|  | 10 | * This program is distributed in the hope that it will be useful, but | 
|  | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 13 | * General Public License for more details. | 
|  | 14 | * | 
|  | 15 | * You should have received a copy of the GNU General Public License | 
|  | 16 | * along with this program; if not, write to the Free Software | 
|  | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | 
|  | 18 | * 02110-1301 USA | 
|  | 19 | * | 
|  | 20 | */ | 
|  | 21 |  | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 22 | #include <linux/irq.h> | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 23 | #include <linux/module.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 25 | #include <linux/crc7.h> | 
|  | 26 | #include <linux/spi/spi.h> | 
| Ohad Ben-Cohen | c1f9a09 | 2010-09-16 13:16:02 +0200 | [diff] [blame] | 27 | #include <linux/wl12xx.h> | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 28 |  | 
| Kalle Valo | 1367411 | 2009-06-12 14:17:25 +0300 | [diff] [blame] | 29 | #include "wl1251.h" | 
| Kalle Valo | 9bc6772 | 2010-10-10 11:28:32 +0300 | [diff] [blame] | 30 | #include "reg.h" | 
|  | 31 | #include "spi.h" | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 32 |  | 
| Bob Copeland | b5ed9c1 | 2009-08-07 13:33:49 +0300 | [diff] [blame] | 33 | static irqreturn_t wl1251_irq(int irq, void *cookie) | 
|  | 34 | { | 
|  | 35 | struct wl1251 *wl; | 
|  | 36 |  | 
|  | 37 | wl1251_debug(DEBUG_IRQ, "IRQ"); | 
|  | 38 |  | 
|  | 39 | wl = cookie; | 
|  | 40 |  | 
| Kalle Valo | 16e711f | 2009-08-07 13:35:04 +0300 | [diff] [blame] | 41 | ieee80211_queue_work(wl->hw, &wl->irq_work); | 
| Bob Copeland | b5ed9c1 | 2009-08-07 13:33:49 +0300 | [diff] [blame] | 42 |  | 
|  | 43 | return IRQ_HANDLED; | 
|  | 44 | } | 
|  | 45 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 46 | static struct spi_device *wl_to_spi(struct wl1251 *wl) | 
|  | 47 | { | 
|  | 48 | return wl->if_priv; | 
|  | 49 | } | 
|  | 50 |  | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 51 | static void wl1251_spi_reset(struct wl1251 *wl) | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 52 | { | 
|  | 53 | u8 *cmd; | 
|  | 54 | struct spi_transfer t; | 
|  | 55 | struct spi_message m; | 
|  | 56 |  | 
|  | 57 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | 
|  | 58 | if (!cmd) { | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 59 | wl1251_error("could not allocate cmd for spi reset"); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 60 | return; | 
|  | 61 | } | 
|  | 62 |  | 
|  | 63 | memset(&t, 0, sizeof(t)); | 
|  | 64 | spi_message_init(&m); | 
|  | 65 |  | 
|  | 66 | memset(cmd, 0xff, WSPI_INIT_CMD_LEN); | 
|  | 67 |  | 
|  | 68 | t.tx_buf = cmd; | 
|  | 69 | t.len = WSPI_INIT_CMD_LEN; | 
|  | 70 | spi_message_add_tail(&t, &m); | 
|  | 71 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 72 | spi_sync(wl_to_spi(wl), &m); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 73 |  | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 74 | wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 75 | } | 
|  | 76 |  | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 77 | static void wl1251_spi_wake(struct wl1251 *wl) | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 78 | { | 
|  | 79 | u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; | 
|  | 80 | struct spi_transfer t; | 
|  | 81 | struct spi_message m; | 
|  | 82 |  | 
|  | 83 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | 
|  | 84 | if (!cmd) { | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 85 | wl1251_error("could not allocate cmd for spi init"); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 86 | return; | 
|  | 87 | } | 
|  | 88 |  | 
|  | 89 | memset(crc, 0, sizeof(crc)); | 
|  | 90 | memset(&t, 0, sizeof(t)); | 
|  | 91 | spi_message_init(&m); | 
|  | 92 |  | 
|  | 93 | /* | 
|  | 94 | * Set WSPI_INIT_COMMAND | 
|  | 95 | * the data is being send from the MSB to LSB | 
|  | 96 | */ | 
|  | 97 | cmd[2] = 0xff; | 
|  | 98 | cmd[3] = 0xff; | 
|  | 99 | cmd[1] = WSPI_INIT_CMD_START | WSPI_INIT_CMD_TX; | 
|  | 100 | cmd[0] = 0; | 
|  | 101 | cmd[7] = 0; | 
|  | 102 | cmd[6] |= HW_ACCESS_WSPI_INIT_CMD_MASK << 3; | 
|  | 103 | cmd[6] |= HW_ACCESS_WSPI_FIXED_BUSY_LEN & WSPI_INIT_CMD_FIXEDBUSY_LEN; | 
|  | 104 |  | 
|  | 105 | if (HW_ACCESS_WSPI_FIXED_BUSY_LEN == 0) | 
|  | 106 | cmd[5] |=  WSPI_INIT_CMD_DIS_FIXEDBUSY; | 
|  | 107 | else | 
|  | 108 | cmd[5] |= WSPI_INIT_CMD_EN_FIXEDBUSY; | 
|  | 109 |  | 
|  | 110 | cmd[5] |= WSPI_INIT_CMD_IOD | WSPI_INIT_CMD_IP | WSPI_INIT_CMD_CS | 
|  | 111 | | WSPI_INIT_CMD_WSPI | WSPI_INIT_CMD_WS; | 
|  | 112 |  | 
|  | 113 | crc[0] = cmd[1]; | 
|  | 114 | crc[1] = cmd[0]; | 
|  | 115 | crc[2] = cmd[7]; | 
|  | 116 | crc[3] = cmd[6]; | 
|  | 117 | crc[4] = cmd[5]; | 
|  | 118 |  | 
|  | 119 | cmd[4] |= crc7(0, crc, WSPI_INIT_CMD_CRC_LEN) << 1; | 
|  | 120 | cmd[4] |= WSPI_INIT_CMD_END; | 
|  | 121 |  | 
|  | 122 | t.tx_buf = cmd; | 
|  | 123 | t.len = WSPI_INIT_CMD_LEN; | 
|  | 124 | spi_message_add_tail(&t, &m); | 
|  | 125 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 126 | spi_sync(wl_to_spi(wl), &m); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 127 |  | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 128 | wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 129 | } | 
|  | 130 |  | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 131 | static void wl1251_spi_reset_wake(struct wl1251 *wl) | 
|  | 132 | { | 
|  | 133 | wl1251_spi_reset(wl); | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 134 | wl1251_spi_wake(wl); | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 135 | } | 
|  | 136 |  | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 137 | static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, | 
|  | 138 | size_t len) | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 139 | { | 
|  | 140 | struct spi_transfer t[3]; | 
|  | 141 | struct spi_message m; | 
| Kalle Valo | 5262c12 | 2009-06-12 14:14:55 +0300 | [diff] [blame] | 142 | u8 *busy_buf; | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 143 | u32 *cmd; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 144 |  | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 145 | cmd = &wl->buffer_cmd; | 
| Kalle Valo | 5262c12 | 2009-06-12 14:14:55 +0300 | [diff] [blame] | 146 | busy_buf = wl->buffer_busyword; | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 147 |  | 
|  | 148 | *cmd = 0; | 
|  | 149 | *cmd |= WSPI_CMD_READ; | 
|  | 150 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | 
|  | 151 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 152 |  | 
|  | 153 | spi_message_init(&m); | 
|  | 154 | memset(t, 0, sizeof(t)); | 
|  | 155 |  | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 156 | t[0].tx_buf = cmd; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 157 | t[0].len = 4; | 
|  | 158 | spi_message_add_tail(&t[0], &m); | 
|  | 159 |  | 
|  | 160 | /* Busy and non busy words read */ | 
|  | 161 | t[1].rx_buf = busy_buf; | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 162 | t[1].len = WL1251_BUSY_WORD_LEN; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 163 | spi_message_add_tail(&t[1], &m); | 
|  | 164 |  | 
|  | 165 | t[2].rx_buf = buf; | 
|  | 166 | t[2].len = len; | 
|  | 167 | spi_message_add_tail(&t[2], &m); | 
|  | 168 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 169 | spi_sync(wl_to_spi(wl), &m); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 170 |  | 
|  | 171 | /* FIXME: check busy words */ | 
|  | 172 |  | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 173 | wl1251_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); | 
|  | 174 | wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 175 | } | 
|  | 176 |  | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 177 | static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, | 
|  | 178 | size_t len) | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 179 | { | 
|  | 180 | struct spi_transfer t[2]; | 
|  | 181 | struct spi_message m; | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 182 | u32 *cmd; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 183 |  | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 184 | cmd = &wl->buffer_cmd; | 
|  | 185 |  | 
|  | 186 | *cmd = 0; | 
|  | 187 | *cmd |= WSPI_CMD_WRITE; | 
|  | 188 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | 
|  | 189 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 190 |  | 
|  | 191 | spi_message_init(&m); | 
|  | 192 | memset(t, 0, sizeof(t)); | 
|  | 193 |  | 
| Kalle Valo | 56343a3 | 2009-06-12 14:14:47 +0300 | [diff] [blame] | 194 | t[0].tx_buf = cmd; | 
|  | 195 | t[0].len = sizeof(*cmd); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 196 | spi_message_add_tail(&t[0], &m); | 
|  | 197 |  | 
|  | 198 | t[1].tx_buf = buf; | 
|  | 199 | t[1].len = len; | 
|  | 200 | spi_message_add_tail(&t[1], &m); | 
|  | 201 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 202 | spi_sync(wl_to_spi(wl), &m); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 203 |  | 
| Kalle Valo | 80301cd | 2009-06-12 14:17:39 +0300 | [diff] [blame] | 204 | wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); | 
|  | 205 | wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); | 
| Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 206 | } | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 207 |  | 
| Bob Copeland | b5ed9c1 | 2009-08-07 13:33:49 +0300 | [diff] [blame] | 208 | static void wl1251_spi_enable_irq(struct wl1251 *wl) | 
|  | 209 | { | 
|  | 210 | return enable_irq(wl->irq); | 
|  | 211 | } | 
|  | 212 |  | 
|  | 213 | static void wl1251_spi_disable_irq(struct wl1251 *wl) | 
|  | 214 | { | 
|  | 215 | return disable_irq(wl->irq); | 
|  | 216 | } | 
|  | 217 |  | 
| Grazvydas Ignotas | cb7bbc7 | 2010-11-04 00:13:47 +0200 | [diff] [blame] | 218 | static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) | 
|  | 219 | { | 
|  | 220 | if (wl->set_power) | 
|  | 221 | wl->set_power(enable); | 
|  | 222 |  | 
|  | 223 | return 0; | 
|  | 224 | } | 
|  | 225 |  | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 226 | static const struct wl1251_if_operations wl1251_spi_ops = { | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 227 | .read = wl1251_spi_read, | 
|  | 228 | .write = wl1251_spi_write, | 
|  | 229 | .reset = wl1251_spi_reset_wake, | 
| Bob Copeland | b5ed9c1 | 2009-08-07 13:33:49 +0300 | [diff] [blame] | 230 | .enable_irq = wl1251_spi_enable_irq, | 
|  | 231 | .disable_irq = wl1251_spi_disable_irq, | 
| Grazvydas Ignotas | cb7bbc7 | 2010-11-04 00:13:47 +0200 | [diff] [blame] | 232 | .power = wl1251_spi_set_power, | 
| Bob Copeland | 08d9f572 | 2009-08-07 13:33:11 +0300 | [diff] [blame] | 233 | }; | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 234 |  | 
|  | 235 | static int __devinit wl1251_spi_probe(struct spi_device *spi) | 
|  | 236 | { | 
|  | 237 | struct wl12xx_platform_data *pdata; | 
|  | 238 | struct ieee80211_hw *hw; | 
|  | 239 | struct wl1251 *wl; | 
|  | 240 | int ret; | 
|  | 241 |  | 
|  | 242 | pdata = spi->dev.platform_data; | 
|  | 243 | if (!pdata) { | 
|  | 244 | wl1251_error("no platform data"); | 
|  | 245 | return -ENODEV; | 
|  | 246 | } | 
|  | 247 |  | 
|  | 248 | hw = wl1251_alloc_hw(); | 
|  | 249 | if (IS_ERR(hw)) | 
|  | 250 | return PTR_ERR(hw); | 
|  | 251 |  | 
|  | 252 | wl = hw->priv; | 
|  | 253 |  | 
|  | 254 | SET_IEEE80211_DEV(hw, &spi->dev); | 
|  | 255 | dev_set_drvdata(&spi->dev, wl); | 
| Bob Copeland | af8c78e | 2009-08-07 13:33:34 +0300 | [diff] [blame] | 256 | wl->if_priv = spi; | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 257 | wl->if_ops = &wl1251_spi_ops; | 
|  | 258 |  | 
|  | 259 | /* This is the only SPI value that we need to set here, the rest | 
|  | 260 | * comes from the board-peripherals file */ | 
|  | 261 | spi->bits_per_word = 32; | 
|  | 262 |  | 
|  | 263 | ret = spi_setup(spi); | 
|  | 264 | if (ret < 0) { | 
|  | 265 | wl1251_error("spi_setup failed"); | 
|  | 266 | goto out_free; | 
|  | 267 | } | 
|  | 268 |  | 
|  | 269 | wl->set_power = pdata->set_power; | 
|  | 270 | if (!wl->set_power) { | 
|  | 271 | wl1251_error("set power function missing in platform data"); | 
|  | 272 | return -ENODEV; | 
|  | 273 | } | 
|  | 274 |  | 
|  | 275 | wl->irq = spi->irq; | 
|  | 276 | if (wl->irq < 0) { | 
|  | 277 | wl1251_error("irq missing in platform data"); | 
|  | 278 | return -ENODEV; | 
|  | 279 | } | 
|  | 280 |  | 
| David-John Willis | c95cf3d0 | 2009-11-17 18:50:09 +0200 | [diff] [blame] | 281 | wl->use_eeprom = pdata->use_eeprom; | 
|  | 282 |  | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 283 | ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); | 
|  | 284 | if (ret < 0) { | 
|  | 285 | wl1251_error("request_irq() failed: %d", ret); | 
|  | 286 | goto out_free; | 
|  | 287 | } | 
|  | 288 |  | 
| Thomas Gleixner | dced35a | 2011-03-28 17:49:12 +0200 | [diff] [blame] | 289 | irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 290 |  | 
|  | 291 | disable_irq(wl->irq); | 
|  | 292 |  | 
|  | 293 | ret = wl1251_init_ieee80211(wl); | 
|  | 294 | if (ret) | 
|  | 295 | goto out_irq; | 
|  | 296 |  | 
|  | 297 | return 0; | 
|  | 298 |  | 
|  | 299 | out_irq: | 
|  | 300 | free_irq(wl->irq, wl); | 
|  | 301 |  | 
|  | 302 | out_free: | 
|  | 303 | ieee80211_free_hw(hw); | 
|  | 304 |  | 
|  | 305 | return ret; | 
|  | 306 | } | 
|  | 307 |  | 
|  | 308 | static int __devexit wl1251_spi_remove(struct spi_device *spi) | 
|  | 309 | { | 
|  | 310 | struct wl1251 *wl = dev_get_drvdata(&spi->dev); | 
|  | 311 |  | 
| Bob Copeland | b5ed9c1 | 2009-08-07 13:33:49 +0300 | [diff] [blame] | 312 | free_irq(wl->irq, wl); | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 313 | wl1251_free_hw(wl); | 
|  | 314 |  | 
|  | 315 | return 0; | 
|  | 316 | } | 
|  | 317 |  | 
|  | 318 | static struct spi_driver wl1251_spi_driver = { | 
|  | 319 | .driver = { | 
| Kalle Valo | 7590a55 | 2010-04-02 15:31:46 +0300 | [diff] [blame] | 320 | .name		= DRIVER_NAME, | 
| Bob Copeland | 8e639c0 | 2009-08-07 13:33:26 +0300 | [diff] [blame] | 321 | .bus		= &spi_bus_type, | 
|  | 322 | .owner		= THIS_MODULE, | 
|  | 323 | }, | 
|  | 324 |  | 
|  | 325 | .probe		= wl1251_spi_probe, | 
|  | 326 | .remove		= __devexit_p(wl1251_spi_remove), | 
|  | 327 | }; | 
|  | 328 |  | 
|  | 329 | static int __init wl1251_spi_init(void) | 
|  | 330 | { | 
|  | 331 | int ret; | 
|  | 332 |  | 
|  | 333 | ret = spi_register_driver(&wl1251_spi_driver); | 
|  | 334 | if (ret < 0) { | 
|  | 335 | wl1251_error("failed to register spi driver: %d", ret); | 
|  | 336 | goto out; | 
|  | 337 | } | 
|  | 338 |  | 
|  | 339 | out: | 
|  | 340 | return ret; | 
|  | 341 | } | 
|  | 342 |  | 
|  | 343 | static void __exit wl1251_spi_exit(void) | 
|  | 344 | { | 
|  | 345 | spi_unregister_driver(&wl1251_spi_driver); | 
|  | 346 |  | 
|  | 347 | wl1251_notice("unloaded"); | 
|  | 348 | } | 
|  | 349 |  | 
|  | 350 | module_init(wl1251_spi_init); | 
|  | 351 | module_exit(wl1251_spi_exit); | 
|  | 352 |  | 
|  | 353 | MODULE_LICENSE("GPL"); | 
| Kalle Valo | 31c726f | 2010-08-22 22:46:15 +0300 | [diff] [blame] | 354 | MODULE_AUTHOR("Kalle Valo <kvalo@adurom.com>"); | 
| Ameya Palande | f148cfd | 2010-07-05 17:12:38 +0300 | [diff] [blame] | 355 | MODULE_ALIAS("spi:wl1251"); |