Lines Matching +full:probe +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Mac80211 SPI driver for ST-Ericsson CW1200 device
9 * Copyright (c) 2010, ST-Ericsson
25 #include <linux/platform_data/net-cw1200.h>
29 MODULE_DESCRIPTION("mac80211 ST-Ericsson CW1200 SPI driver");
41 struct gpio_desc *reset; member
54 Hardware expects 32-bit data to be written as 16-bit BE words:
91 if (self->func->bits_per_word == 8) in cw1200_spi_memcpy_fromio()
98 ret = spi_sync(self->func, &m); in cw1200_spi_memcpy_fromio()
114 if (self->func->bits_per_word == 8) in cw1200_spi_memcpy_fromio()
156 if (self->func->bits_per_word == 8) in cw1200_spi_memcpy_toio()
178 rval = spi_sync(self->func, &m); in cw1200_spi_memcpy_toio()
186 if (self->func->bits_per_word == 8) in cw1200_spi_memcpy_toio()
204 add_wait_queue(&self->wq, &wait); in cw1200_spi_lock()
205 spin_lock_irqsave(&self->lock, flags); in cw1200_spi_lock()
208 if (!self->claimed) in cw1200_spi_lock()
210 spin_unlock_irqrestore(&self->lock, flags); in cw1200_spi_lock()
212 spin_lock_irqsave(&self->lock, flags); in cw1200_spi_lock()
215 self->claimed = 1; in cw1200_spi_lock()
216 spin_unlock_irqrestore(&self->lock, flags); in cw1200_spi_lock()
217 remove_wait_queue(&self->wq, &wait); in cw1200_spi_lock()
226 spin_lock_irqsave(&self->lock, flags); in cw1200_spi_unlock()
227 self->claimed = 0; in cw1200_spi_unlock()
228 spin_unlock_irqrestore(&self->lock, flags); in cw1200_spi_unlock()
229 wake_up(&self->wq); in cw1200_spi_unlock()
238 if (self->core) { in cw1200_spi_irq_handler()
240 cw1200_irq_handler(self->core); in cw1200_spi_irq_handler()
254 ret = request_threaded_irq(self->func->irq, NULL, in cw1200_spi_irq_subscribe()
261 ret = enable_irq_wake(self->func->irq); in cw1200_spi_irq_subscribe()
268 free_irq(self->func->irq, self); in cw1200_spi_irq_subscribe()
276 disable_irq_wake(self->func->irq); in cw1200_spi_irq_unsubscribe()
277 free_irq(self->func->irq, self); in cw1200_spi_irq_unsubscribe()
282 if (self->reset) { in cw1200_spi_off()
283 /* Assert RESET, note active low */ in cw1200_spi_off()
284 gpiod_set_value(self->reset, 1); in cw1200_spi_off()
288 if (pdata->power_ctrl) in cw1200_spi_off()
289 pdata->power_ctrl(pdata, false); in cw1200_spi_off()
290 if (pdata->clk_ctrl) in cw1200_spi_off()
291 pdata->clk_ctrl(pdata, false); in cw1200_spi_off()
299 gpiod_direction_output(self->reset, 1); /* Active low */ in cw1200_spi_on()
300 gpiod_direction_output(self->powerup, 0); in cw1200_spi_on()
301 if (self->reset || self->powerup) in cw1200_spi_on()
305 if (pdata->power_ctrl) { in cw1200_spi_on()
306 if (pdata->power_ctrl(pdata, true)) { in cw1200_spi_on()
308 return -1; in cw1200_spi_on()
313 if (pdata->clk_ctrl) { in cw1200_spi_on()
314 if (pdata->clk_ctrl(pdata, true)) { in cw1200_spi_on()
316 return -1; in cw1200_spi_on()
322 if (self->powerup) { in cw1200_spi_on()
323 gpiod_set_value(self->powerup, 1); in cw1200_spi_on()
327 if (self->reset) { in cw1200_spi_on()
328 gpiod_set_value(self->reset, 0); in cw1200_spi_on()
341 return irq_set_irq_wake(self->func->irq, suspend); in cw1200_spi_pm()
353 /* Probe Function to be called by SPI stack when device is discovered */
357 dev_get_platdata(&func->dev); in cw1200_spi_probe()
362 if (func->max_speed_hz > 52000000) in cw1200_spi_probe()
363 func->max_speed_hz = 52000000; in cw1200_spi_probe()
364 if (func->max_speed_hz < 1000000) in cw1200_spi_probe()
365 func->max_speed_hz = 1000000; in cw1200_spi_probe()
368 if (plat_data->spi_bits_per_word) in cw1200_spi_probe()
369 func->bits_per_word = plat_data->spi_bits_per_word; in cw1200_spi_probe()
370 if (!func->bits_per_word) in cw1200_spi_probe()
371 func->bits_per_word = 16; in cw1200_spi_probe()
374 func->mode = SPI_MODE_0; in cw1200_spi_probe()
376 pr_info("cw1200_wlan_spi: Probe called (CS %d M %d BPW %d CLK %d)\n", in cw1200_spi_probe()
377 spi_get_chipselect(func, 0), func->mode, func->bits_per_word, in cw1200_spi_probe()
378 func->max_speed_hz); in cw1200_spi_probe()
380 self = devm_kzalloc(&func->dev, sizeof(*self), GFP_KERNEL); in cw1200_spi_probe()
383 return -ENOMEM; in cw1200_spi_probe()
386 /* Request reset asserted */ in cw1200_spi_probe()
387 self->reset = devm_gpiod_get_optional(&func->dev, "reset", GPIOD_OUT_HIGH); in cw1200_spi_probe()
388 if (IS_ERR(self->reset)) in cw1200_spi_probe()
389 return dev_err_probe(&func->dev, PTR_ERR(self->reset), in cw1200_spi_probe()
390 "could not get reset GPIO\n"); in cw1200_spi_probe()
391 gpiod_set_consumer_name(self->reset, "cw1200_wlan_reset"); in cw1200_spi_probe()
393 self->powerup = devm_gpiod_get_optional(&func->dev, "powerup", GPIOD_OUT_LOW); in cw1200_spi_probe()
394 if (IS_ERR(self->powerup)) in cw1200_spi_probe()
395 return dev_err_probe(&func->dev, PTR_ERR(self->powerup), in cw1200_spi_probe()
397 gpiod_set_consumer_name(self->reset, "cw1200_wlan_powerup"); in cw1200_spi_probe()
401 return -ENODEV; in cw1200_spi_probe()
406 return -ENODEV; in cw1200_spi_probe()
409 self->pdata = plat_data; in cw1200_spi_probe()
410 self->func = func; in cw1200_spi_probe()
411 spin_lock_init(&self->lock); in cw1200_spi_probe()
415 init_waitqueue_head(&self->wq); in cw1200_spi_probe()
420 self, &func->dev, &self->core, in cw1200_spi_probe()
421 self->pdata->ref_clk, in cw1200_spi_probe()
422 self->pdata->macaddr, in cw1200_spi_probe()
423 self->pdata->sdd_file, in cw1200_spi_probe()
424 self->pdata->have_5ghz); in cw1200_spi_probe()
441 if (self->core) { in cw1200_spi_disconnect()
442 cw1200_core_release(self->core); in cw1200_spi_disconnect()
443 self->core = NULL; in cw1200_spi_disconnect()
446 cw1200_spi_off(self, dev_get_platdata(&func->dev)); in cw1200_spi_disconnect()
453 if (!cw1200_can_suspend(self->core)) in cw1200_spi_suspend()
454 return -EAGAIN; in cw1200_spi_suspend()
463 .probe = cw1200_spi_probe,