diff options
Diffstat (limited to 'drivers/net/wireless/ti/wl1251')
-rw-r--r-- | drivers/net/wireless/ti/wl1251/cmd.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl1251/sdio.c | 31 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl1251/spi.c | 71 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl1251/wl1251.h | 4 |
4 files changed, 78 insertions, 30 deletions
diff --git a/drivers/net/wireless/ti/wl1251/cmd.c b/drivers/net/wireless/ti/wl1251/cmd.c index 223649bcaa5a..bf1fa18b9786 100644 --- a/drivers/net/wireless/ti/wl1251/cmd.c +++ b/drivers/net/wireless/ti/wl1251/cmd.c | |||
@@ -448,7 +448,7 @@ int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len, | |||
448 | * Note: This bug may be caused by the fw's DTIM handling. | 448 | * Note: This bug may be caused by the fw's DTIM handling. |
449 | */ | 449 | */ |
450 | if (is_zero_ether_addr(wl->bssid)) | 450 | if (is_zero_ether_addr(wl->bssid)) |
451 | cmd->params.scan_options |= WL1251_SCAN_OPT_PRIORITY_HIGH; | 451 | cmd->params.scan_options |= cpu_to_le16(WL1251_SCAN_OPT_PRIORITY_HIGH); |
452 | cmd->params.num_channels = n_channels; | 452 | cmd->params.num_channels = n_channels; |
453 | cmd->params.num_probe_requests = n_probes; | 453 | cmd->params.num_probe_requests = n_probes; |
454 | cmd->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */ | 454 | cmd->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */ |
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c index e2b3d9c541e8..b661f896e9fe 100644 --- a/drivers/net/wireless/ti/wl1251/sdio.c +++ b/drivers/net/wireless/ti/wl1251/sdio.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/wl12xx.h> | 28 | #include <linux/wl12xx.h> |
29 | #include <linux/irq.h> | 29 | #include <linux/irq.h> |
30 | #include <linux/pm_runtime.h> | 30 | #include <linux/pm_runtime.h> |
31 | #include <linux/gpio.h> | ||
31 | 32 | ||
32 | #include "wl1251.h" | 33 | #include "wl1251.h" |
33 | 34 | ||
@@ -182,8 +183,9 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable) | |||
182 | * callback in case it wants to do any additional setup, | 183 | * callback in case it wants to do any additional setup, |
183 | * for example enabling clock buffer for the module. | 184 | * for example enabling clock buffer for the module. |
184 | */ | 185 | */ |
185 | if (wl->set_power) | 186 | if (gpio_is_valid(wl->power_gpio)) |
186 | wl->set_power(true); | 187 | gpio_set_value(wl->power_gpio, true); |
188 | |||
187 | 189 | ||
188 | ret = pm_runtime_get_sync(&func->dev); | 190 | ret = pm_runtime_get_sync(&func->dev); |
189 | if (ret < 0) { | 191 | if (ret < 0) { |
@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable) | |||
203 | if (ret < 0) | 205 | if (ret < 0) |
204 | goto out; | 206 | goto out; |
205 | 207 | ||
206 | if (wl->set_power) | 208 | if (gpio_is_valid(wl->power_gpio)) |
207 | wl->set_power(false); | 209 | gpio_set_value(wl->power_gpio, false); |
208 | } | 210 | } |
209 | 211 | ||
210 | out: | 212 | out: |
@@ -227,7 +229,7 @@ static int wl1251_sdio_probe(struct sdio_func *func, | |||
227 | struct wl1251 *wl; | 229 | struct wl1251 *wl; |
228 | struct ieee80211_hw *hw; | 230 | struct ieee80211_hw *hw; |
229 | struct wl1251_sdio *wl_sdio; | 231 | struct wl1251_sdio *wl_sdio; |
230 | const struct wl12xx_platform_data *wl12xx_board_data; | 232 | const struct wl1251_platform_data *wl1251_board_data; |
231 | 233 | ||
232 | hw = wl1251_alloc_hw(); | 234 | hw = wl1251_alloc_hw(); |
233 | if (IS_ERR(hw)) | 235 | if (IS_ERR(hw)) |
@@ -254,11 +256,20 @@ static int wl1251_sdio_probe(struct sdio_func *func, | |||
254 | wl->if_priv = wl_sdio; | 256 | wl->if_priv = wl_sdio; |
255 | wl->if_ops = &wl1251_sdio_ops; | 257 | wl->if_ops = &wl1251_sdio_ops; |
256 | 258 | ||
257 | wl12xx_board_data = wl12xx_get_platform_data(); | 259 | wl1251_board_data = wl1251_get_platform_data(); |
258 | if (!IS_ERR(wl12xx_board_data)) { | 260 | if (!IS_ERR(wl1251_board_data)) { |
259 | wl->set_power = wl12xx_board_data->set_power; | 261 | wl->power_gpio = wl1251_board_data->power_gpio; |
260 | wl->irq = wl12xx_board_data->irq; | 262 | wl->irq = wl1251_board_data->irq; |
261 | wl->use_eeprom = wl12xx_board_data->use_eeprom; | 263 | wl->use_eeprom = wl1251_board_data->use_eeprom; |
264 | } | ||
265 | |||
266 | if (gpio_is_valid(wl->power_gpio)) { | ||
267 | ret = devm_gpio_request(&func->dev, wl->power_gpio, | ||
268 | "wl1251 power"); | ||
269 | if (ret) { | ||
270 | wl1251_error("Failed to request gpio: %d\n", ret); | ||
271 | goto disable; | ||
272 | } | ||
262 | } | 273 | } |
263 | 274 | ||
264 | if (wl->irq) { | 275 | if (wl->irq) { |
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c index 1342f81e683d..b06d36d99362 100644 --- a/drivers/net/wireless/ti/wl1251/spi.c +++ b/drivers/net/wireless/ti/wl1251/spi.c | |||
@@ -26,6 +26,10 @@ | |||
26 | #include <linux/crc7.h> | 26 | #include <linux/crc7.h> |
27 | #include <linux/spi/spi.h> | 27 | #include <linux/spi/spi.h> |
28 | #include <linux/wl12xx.h> | 28 | #include <linux/wl12xx.h> |
29 | #include <linux/gpio.h> | ||
30 | #include <linux/of.h> | ||
31 | #include <linux/of_gpio.h> | ||
32 | #include <linux/regulator/consumer.h> | ||
29 | 33 | ||
30 | #include "wl1251.h" | 34 | #include "wl1251.h" |
31 | #include "reg.h" | 35 | #include "reg.h" |
@@ -221,8 +225,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl) | |||
221 | 225 | ||
222 | static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) | 226 | static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) |
223 | { | 227 | { |
224 | if (wl->set_power) | 228 | if (gpio_is_valid(wl->power_gpio)) |
225 | wl->set_power(enable); | 229 | gpio_set_value(wl->power_gpio, enable); |
226 | 230 | ||
227 | return 0; | 231 | return 0; |
228 | } | 232 | } |
@@ -238,13 +242,13 @@ static const struct wl1251_if_operations wl1251_spi_ops = { | |||
238 | 242 | ||
239 | static int wl1251_spi_probe(struct spi_device *spi) | 243 | static int wl1251_spi_probe(struct spi_device *spi) |
240 | { | 244 | { |
241 | struct wl12xx_platform_data *pdata; | 245 | struct wl1251_platform_data *pdata = dev_get_platdata(&spi->dev); |
246 | struct device_node *np = spi->dev.of_node; | ||
242 | struct ieee80211_hw *hw; | 247 | struct ieee80211_hw *hw; |
243 | struct wl1251 *wl; | 248 | struct wl1251 *wl; |
244 | int ret; | 249 | int ret; |
245 | 250 | ||
246 | pdata = dev_get_platdata(&spi->dev); | 251 | if (!np && !pdata) { |
247 | if (!pdata) { | ||
248 | wl1251_error("no platform data"); | 252 | wl1251_error("no platform data"); |
249 | return -ENODEV; | 253 | return -ENODEV; |
250 | } | 254 | } |
@@ -271,22 +275,42 @@ static int wl1251_spi_probe(struct spi_device *spi) | |||
271 | goto out_free; | 275 | goto out_free; |
272 | } | 276 | } |
273 | 277 | ||
274 | wl->set_power = pdata->set_power; | 278 | if (np) { |
275 | if (!wl->set_power) { | 279 | wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); |
276 | wl1251_error("set power function missing in platform data"); | 280 | wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); |
277 | return -ENODEV; | 281 | } else if (pdata) { |
282 | wl->power_gpio = pdata->power_gpio; | ||
283 | wl->use_eeprom = pdata->use_eeprom; | ||
284 | } | ||
285 | |||
286 | if (wl->power_gpio == -EPROBE_DEFER) { | ||
287 | ret = -EPROBE_DEFER; | ||
288 | goto out_free; | ||
289 | } | ||
290 | |||
291 | if (gpio_is_valid(wl->power_gpio)) { | ||
292 | ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, | ||
293 | GPIOF_OUT_INIT_LOW, "wl1251 power"); | ||
294 | if (ret) { | ||
295 | wl1251_error("Failed to request gpio: %d\n", ret); | ||
296 | goto out_free; | ||
297 | } | ||
298 | } else { | ||
299 | wl1251_error("set power gpio missing in platform data"); | ||
300 | ret = -ENODEV; | ||
301 | goto out_free; | ||
278 | } | 302 | } |
279 | 303 | ||
280 | wl->irq = spi->irq; | 304 | wl->irq = spi->irq; |
281 | if (wl->irq < 0) { | 305 | if (wl->irq < 0) { |
282 | wl1251_error("irq missing in platform data"); | 306 | wl1251_error("irq missing in platform data"); |
283 | return -ENODEV; | 307 | ret = -ENODEV; |
308 | goto out_free; | ||
284 | } | 309 | } |
285 | 310 | ||
286 | wl->use_eeprom = pdata->use_eeprom; | ||
287 | |||
288 | irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); | 311 | irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); |
289 | ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); | 312 | ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0, |
313 | DRIVER_NAME, wl); | ||
290 | if (ret < 0) { | 314 | if (ret < 0) { |
291 | wl1251_error("request_irq() failed: %d", ret); | 315 | wl1251_error("request_irq() failed: %d", ret); |
292 | goto out_free; | 316 | goto out_free; |
@@ -294,16 +318,26 @@ static int wl1251_spi_probe(struct spi_device *spi) | |||
294 | 318 | ||
295 | irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | 319 | irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); |
296 | 320 | ||
321 | wl->vio = devm_regulator_get(&spi->dev, "vio"); | ||
322 | if (IS_ERR(wl->vio)) { | ||
323 | ret = PTR_ERR(wl->vio); | ||
324 | wl1251_error("vio regulator missing: %d", ret); | ||
325 | goto out_free; | ||
326 | } | ||
327 | |||
328 | ret = regulator_enable(wl->vio); | ||
329 | if (ret) | ||
330 | goto out_free; | ||
331 | |||
297 | ret = wl1251_init_ieee80211(wl); | 332 | ret = wl1251_init_ieee80211(wl); |
298 | if (ret) | 333 | if (ret) |
299 | goto out_irq; | 334 | goto disable_regulator; |
300 | 335 | ||
301 | return 0; | 336 | return 0; |
302 | 337 | ||
303 | out_irq: | 338 | disable_regulator: |
304 | free_irq(wl->irq, wl); | 339 | regulator_disable(wl->vio); |
305 | 340 | out_free: | |
306 | out_free: | ||
307 | ieee80211_free_hw(hw); | 341 | ieee80211_free_hw(hw); |
308 | 342 | ||
309 | return ret; | 343 | return ret; |
@@ -315,6 +349,7 @@ static int wl1251_spi_remove(struct spi_device *spi) | |||
315 | 349 | ||
316 | free_irq(wl->irq, wl); | 350 | free_irq(wl->irq, wl); |
317 | wl1251_free_hw(wl); | 351 | wl1251_free_hw(wl); |
352 | regulator_disable(wl->vio); | ||
318 | 353 | ||
319 | return 0; | 354 | return 0; |
320 | } | 355 | } |
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h index 235617a7716d..16dae5269175 100644 --- a/drivers/net/wireless/ti/wl1251/wl1251.h +++ b/drivers/net/wireless/ti/wl1251/wl1251.h | |||
@@ -276,10 +276,12 @@ struct wl1251 { | |||
276 | void *if_priv; | 276 | void *if_priv; |
277 | const struct wl1251_if_operations *if_ops; | 277 | const struct wl1251_if_operations *if_ops; |
278 | 278 | ||
279 | void (*set_power)(bool enable); | 279 | int power_gpio; |
280 | int irq; | 280 | int irq; |
281 | bool use_eeprom; | 281 | bool use_eeprom; |
282 | 282 | ||
283 | struct regulator *vio; | ||
284 | |||
283 | spinlock_t wl_lock; | 285 | spinlock_t wl_lock; |
284 | 286 | ||
285 | enum wl1251_state state; | 287 | enum wl1251_state state; |