Lines Matching +full:spi +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0-only
3 * SPI interface.
5 * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
7 * Copyright (c) 2010, ST-Ericsson
12 #include <linux/spi/spi.h>
18 #include "bus.h"
63 * support big endian host and commonly used SPI 8bits.
67 struct wfx_spi_priv *bus = priv; in wfx_spi_copy_from_io() local
84 if (bus->need_swab) in wfx_spi_copy_from_io()
90 ret = spi_sync(bus->func, &m); in wfx_spi_copy_from_io()
92 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_from_io()
100 struct wfx_spi_priv *bus = priv; in wfx_spi_copy_to_io() local
123 if (bus->need_swab) in wfx_spi_copy_to_io()
125 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_to_io()
132 ret = spi_sync(bus->func, &m); in wfx_spi_copy_to_io()
134 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_to_io()
150 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_handler() local
152 wfx_bh_request_rx(bus->core); in wfx_spi_irq_handler()
158 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_subscribe() local
161 flags = irq_get_trigger_type(bus->func->irq); in wfx_spi_irq_subscribe()
165 return devm_request_threaded_irq(&bus->func->dev, bus->func->irq, NULL, in wfx_spi_irq_subscribe()
166 wfx_spi_irq_handler, flags, "wfx", bus); in wfx_spi_irq_subscribe()
171 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_unsubscribe() local
173 devm_free_irq(&bus->func->dev, bus->func->irq, bus); in wfx_spi_irq_unsubscribe()
179 /* Most of SPI controllers avoid DMA if buffer size is not 32bit aligned */ in wfx_spi_align_size()
185 struct wfx_spi_priv *bus = priv; in wfx_spi_set_wakeup() local
187 device_set_wakeup_enable(&bus->func->dev, enabled); in wfx_spi_set_wakeup()
204 struct wfx_spi_priv *bus = spi_get_drvdata(func); in wfx_spi_suspend() local
208 flush_work(&bus->core->hif.bh); in wfx_spi_suspend()
209 return enable_irq_wake(func->irq); in wfx_spi_suspend()
218 return disable_irq_wake(func->irq); in wfx_spi_resume()
224 struct wfx_spi_priv *bus; in wfx_spi_probe() local
227 if (!func->bits_per_word) in wfx_spi_probe()
228 func->bits_per_word = 16; in wfx_spi_probe()
232 pdata = (struct wfx_platform_data *)spi_get_device_id(func)->driver_data; in wfx_spi_probe()
234 dev_err(&func->dev, "unable to retrieve driver data (please report)\n"); in wfx_spi_probe()
235 return -ENODEV; in wfx_spi_probe()
239 dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n", in wfx_spi_probe()
240 spi_get_chipselect(func, 0), func->mode, func->bits_per_word, func->max_speed_hz); in wfx_spi_probe()
241 if (func->bits_per_word != 16 && func->bits_per_word != 8) in wfx_spi_probe()
242 dev_warn(&func->dev, "unusual bits/word value: %d\n", func->bits_per_word); in wfx_spi_probe()
243 if (func->max_speed_hz > 50000000) in wfx_spi_probe()
244 dev_warn(&func->dev, "%dHz is a very high speed\n", func->max_speed_hz); in wfx_spi_probe()
246 bus = devm_kzalloc(&func->dev, sizeof(*bus), GFP_KERNEL); in wfx_spi_probe()
247 if (!bus) in wfx_spi_probe()
248 return -ENOMEM; in wfx_spi_probe()
249 bus->func = func; in wfx_spi_probe()
250 if (func->bits_per_word == 8 || IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) in wfx_spi_probe()
251 bus->need_swab = true; in wfx_spi_probe()
252 spi_set_drvdata(func, bus); in wfx_spi_probe()
254 bus->gpio_reset = devm_gpiod_get_optional(&func->dev, "reset", GPIOD_OUT_LOW); in wfx_spi_probe()
255 if (IS_ERR(bus->gpio_reset)) in wfx_spi_probe()
256 return PTR_ERR(bus->gpio_reset); in wfx_spi_probe()
257 if (!bus->gpio_reset) { in wfx_spi_probe()
258 dev_warn(&func->dev, "gpio reset is not defined, trying to load firmware anyway\n"); in wfx_spi_probe()
260 gpiod_set_consumer_name(bus->gpio_reset, "wfx reset"); in wfx_spi_probe()
261 gpiod_set_value_cansleep(bus->gpio_reset, 1); in wfx_spi_probe()
263 gpiod_set_value_cansleep(bus->gpio_reset, 0); in wfx_spi_probe()
267 bus->core = wfx_init_common(&func->dev, pdata, &wfx_spi_hwbus_ops, bus); in wfx_spi_probe()
268 if (!bus->core) in wfx_spi_probe()
269 return -EIO; in wfx_spi_probe()
271 ret = wfx_probe(bus->core); in wfx_spi_probe()
275 device_set_wakeup_capable(&func->dev, true); in wfx_spi_probe()
281 struct wfx_spi_priv *bus = spi_get_drvdata(func); in wfx_spi_remove() local
283 wfx_release(bus->core); in wfx_spi_remove()
297 MODULE_DEVICE_TABLE(spi, wfx_spi_id);
317 .name = "wfx-spi",