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>
17 #include "bus.h"
62 * support big endian host and commonly used SPI 8bits.
66 struct wfx_spi_priv *bus = priv; in wfx_spi_copy_from_io() local
83 if (bus->need_swab) in wfx_spi_copy_from_io()
89 ret = spi_sync(bus->func, &m); in wfx_spi_copy_from_io()
91 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_from_io()
99 struct wfx_spi_priv *bus = priv; in wfx_spi_copy_to_io() local
122 if (bus->need_swab) in wfx_spi_copy_to_io()
124 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_to_io()
131 ret = spi_sync(bus->func, &m); in wfx_spi_copy_to_io()
133 if (bus->need_swab && addr == WFX_REG_CONFIG) in wfx_spi_copy_to_io()
149 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_handler() local
151 wfx_bh_request_rx(bus->core); in wfx_spi_irq_handler()
157 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_subscribe() local
160 flags = irq_get_trigger_type(bus->func->irq); in wfx_spi_irq_subscribe()
164 return devm_request_threaded_irq(&bus->func->dev, bus->func->irq, NULL, in wfx_spi_irq_subscribe()
165 wfx_spi_irq_handler, flags, "wfx", bus); in wfx_spi_irq_subscribe()
170 struct wfx_spi_priv *bus = priv; in wfx_spi_irq_unsubscribe() local
172 devm_free_irq(&bus->func->dev, bus->func->irq, bus); in wfx_spi_irq_unsubscribe()
178 /* Most of SPI controllers avoid DMA if buffer size is not 32bit aligned */ in wfx_spi_align_size()
195 struct wfx_spi_priv *bus; in wfx_spi_probe() local
198 if (!func->bits_per_word) in wfx_spi_probe()
199 func->bits_per_word = 16; in wfx_spi_probe()
203 pdata = (struct wfx_platform_data *)spi_get_device_id(func)->driver_data; in wfx_spi_probe()
205 dev_err(&func->dev, "unable to retrieve driver data (please report)\n"); in wfx_spi_probe()
206 return -ENODEV; in wfx_spi_probe()
210 dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n", in wfx_spi_probe()
211 spi_get_chipselect(func, 0), func->mode, func->bits_per_word, func->max_speed_hz); in wfx_spi_probe()
212 if (func->bits_per_word != 16 && func->bits_per_word != 8) in wfx_spi_probe()
213 dev_warn(&func->dev, "unusual bits/word value: %d\n", func->bits_per_word); in wfx_spi_probe()
214 if (func->max_speed_hz > 50000000) in wfx_spi_probe()
215 dev_warn(&func->dev, "%dHz is a very high speed\n", func->max_speed_hz); in wfx_spi_probe()
217 bus = devm_kzalloc(&func->dev, sizeof(*bus), GFP_KERNEL); in wfx_spi_probe()
218 if (!bus) in wfx_spi_probe()
219 return -ENOMEM; in wfx_spi_probe()
220 bus->func = func; in wfx_spi_probe()
221 if (func->bits_per_word == 8 || IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) in wfx_spi_probe()
222 bus->need_swab = true; in wfx_spi_probe()
223 spi_set_drvdata(func, bus); in wfx_spi_probe()
225 bus->gpio_reset = devm_gpiod_get_optional(&func->dev, "reset", GPIOD_OUT_LOW); in wfx_spi_probe()
226 if (IS_ERR(bus->gpio_reset)) in wfx_spi_probe()
227 return PTR_ERR(bus->gpio_reset); in wfx_spi_probe()
228 if (!bus->gpio_reset) { in wfx_spi_probe()
229 dev_warn(&func->dev, "gpio reset is not defined, trying to load firmware anyway\n"); in wfx_spi_probe()
231 gpiod_set_consumer_name(bus->gpio_reset, "wfx reset"); in wfx_spi_probe()
232 gpiod_set_value_cansleep(bus->gpio_reset, 1); in wfx_spi_probe()
234 gpiod_set_value_cansleep(bus->gpio_reset, 0); in wfx_spi_probe()
238 bus->core = wfx_init_common(&func->dev, pdata, &wfx_spi_hwbus_ops, bus); in wfx_spi_probe()
239 if (!bus->core) in wfx_spi_probe()
240 return -EIO; in wfx_spi_probe()
242 return wfx_probe(bus->core); in wfx_spi_probe()
247 struct wfx_spi_priv *bus = spi_get_drvdata(func); in wfx_spi_remove() local
249 wfx_release(bus->core); in wfx_spi_remove()
263 MODULE_DEVICE_TABLE(spi, wfx_spi_id);
278 .name = "wfx-spi",