Lines Matching +full:spi +full:- +full:addr
4 * SPDX-License-Identifier: Apache-2.0
8 * @brief File containing SPI device interface specific definitions for the
9 * Zephyr OS layer of the Wi-Fi driver.
14 #include <zephyr/drivers/spi.h>
29 static int spim_xfer_tx(unsigned int addr, void *data, unsigned int len) in spim_xfer_tx() argument
34 (((addr >> 16) & 0xFF) | 0x80), in spim_xfer_tx()
35 (addr >> 8) & 0xFF, in spim_xfer_tx()
36 (addr & 0xFF) in spim_xfer_tx()
52 static int spim_xfer_rx(unsigned int addr, void *data, unsigned int len, unsigned int discard_bytes) in spim_xfer_rx() argument
56 (addr >> 16) & 0xFF, in spim_xfer_rx()
57 (addr >> 8) & 0xFF, in spim_xfer_rx()
58 addr & 0xFF, in spim_xfer_rx()
79 return -EINVAL; in spim_xfer_rx()
110 LOG_DBG("err: %d -> %x %x %x %x %x %x", err, sr[0], sr[1], sr[2], sr[3], sr[4], sr[5]); in spim_read_reg()
130 LOG_ERR("SPI error: %d", err); in spim_write_reg()
176 return -1; in _spim_wait_while_rpu_awake()
203 return -1; in spim_wait_while_rpu_wake_write()
225 LOG_ERR("SPI error: %d", err); in spim_cmd_sleep_rpu()
234 LOG_ERR("Device %s is not ready", spi_spec.bus->name); in spim_init()
235 return -ENODEV; in spim_init()
240 k_sem_init(&spim_config->lock, 1, 1); in spim_init()
243 spim_config->qspi_slave_latency = 1; in spim_init()
246 LOG_INF("SPIM %s: freq = %d MHz", spi_spec.bus->name, in spim_init()
248 LOG_INF("SPIM %s: latency = %d", spi_spec.bus->name, spim_config->qspi_slave_latency); in spim_init()
260 static void spim_addr_check(unsigned int addr, const void *data, unsigned int len) in spim_addr_check() argument
262 if ((addr % 4 != 0) || (((unsigned int)data) % 4 != 0) || (len % 4 != 0)) { in spim_addr_check()
263 LOG_ERR("%s : Unaligned address %x %x %d %x %x", __func__, addr, in spim_addr_check()
264 (unsigned int)data, (addr % 4 != 0), (((unsigned int)data) % 4 != 0), in spim_addr_check()
269 int spim_write(unsigned int addr, const void *data, int len) in spim_write() argument
273 spim_addr_check(addr, data, len); in spim_write()
275 addr |= spim_config->addrmask; in spim_write()
277 k_sem_take(&spim_config->lock, K_FOREVER); in spim_write()
279 status = spim_xfer_tx(addr, (void *)data, len); in spim_write()
281 k_sem_give(&spim_config->lock); in spim_write()
286 int spim_read(unsigned int addr, void *data, int len) in spim_read() argument
290 spim_addr_check(addr, data, len); in spim_read()
292 addr |= spim_config->addrmask; in spim_read()
294 k_sem_take(&spim_config->lock, K_FOREVER); in spim_read()
296 status = spim_xfer_rx(addr, data, len, 0); in spim_read()
298 k_sem_give(&spim_config->lock); in spim_read()
303 static int spim_hl_readw(unsigned int addr, void *data) in spim_hl_readw() argument
305 int status = -1; in spim_hl_readw()
307 k_sem_take(&spim_config->lock, K_FOREVER); in spim_hl_readw()
309 status = spim_xfer_rx(addr, data, 4, 4 * spim_config->qspi_slave_latency); in spim_hl_readw()
311 k_sem_give(&spim_config->lock); in spim_hl_readw()
316 int spim_hl_read(unsigned int addr, void *data, int len) in spim_hl_read() argument
320 spim_addr_check(addr, data, len); in spim_hl_read()
323 spim_hl_readw(addr + (4 * count), (char *)data + (4 * count)); in spim_hl_read()
330 /* ------------------------------added for wifi utils -------------------------------- */