Lines Matching refs:spi

44 static inline bool spi_dw_is_slave(struct spi_dw_data *spi)  in spi_dw_is_slave()  argument
47 spi_context_is_slave(&spi->ctx)); in spi_dw_is_slave()
52 struct spi_dw_data *spi = dev->data; in completed() local
53 struct spi_context *ctx = &spi->ctx; in completed()
59 if (spi_context_tx_on(&spi->ctx) || in completed()
60 spi_context_rx_on(&spi->ctx)) { in completed()
74 if (!spi_dw_is_slave(spi)) { in completed()
85 spi_context_complete(&spi->ctx, dev, error); in completed()
91 struct spi_dw_data *spi = dev->data; in push_data() local
95 if (spi_context_rx_on(&spi->ctx)) { in push_data()
106 if (spi_context_tx_buf_on(&spi->ctx)) { in push_data()
107 switch (spi->dfs) { in push_data()
110 (spi->ctx.tx_buf)); in push_data()
114 (spi->ctx.tx_buf)); in push_data()
118 (spi->ctx.tx_buf)); in push_data()
121 } else if (spi_context_rx_on(&spi->ctx)) { in push_data()
123 if ((int)(spi->ctx.rx_len - spi->fifo_diff) <= 0) { in push_data()
128 } else if (spi_context_tx_on(&spi->ctx)) { in push_data()
137 spi_context_update_tx(&spi->ctx, spi->dfs, 1); in push_data()
138 spi->fifo_diff++; in push_data()
143 if (!spi_context_tx_on(&spi->ctx)) { in push_data()
152 struct spi_dw_data *spi = dev->data; in pull_data() local
157 if (spi_context_rx_buf_on(&spi->ctx)) { in pull_data()
158 switch (spi->dfs) { in pull_data()
160 UNALIGNED_PUT(data, (uint8_t *)spi->ctx.rx_buf); in pull_data()
163 UNALIGNED_PUT(data, (uint16_t *)spi->ctx.rx_buf); in pull_data()
166 UNALIGNED_PUT(data, (uint32_t *)spi->ctx.rx_buf); in pull_data()
171 spi_context_update_rx(&spi->ctx, spi->dfs, 1); in pull_data()
172 spi->fifo_diff--; in pull_data()
175 if (!spi->ctx.rx_len && spi->ctx.tx_len < info->fifo_depth) { in pull_data()
176 write_rxftlr(dev, spi->ctx.tx_len - 1); in pull_data()
177 } else if (read_rxftlr(dev) >= spi->ctx.rx_len) { in pull_data()
178 write_rxftlr(dev, spi->ctx.rx_len - 1); in pull_data()
183 struct spi_dw_data *spi, in spi_dw_configure() argument
189 LOG_DBG("%p (prev %p)", config, spi->ctx.config); in spi_dw_configure()
191 if (spi_context_configured(&spi->ctx, config)) { in spi_dw_configure()
236 spi->dfs = SPI_WS_TO_DFS(SPI_WORD_SIZE_GET(config->operation)); in spi_dw_configure()
255 spi->ctx.config = config; in spi_dw_configure()
257 if (!spi_dw_is_slave(spi)) { in spi_dw_configure()
263 if (spi_dw_is_slave(spi)) { in spi_dw_configure()
267 SPI_WORD_SIZE_GET(config->operation), spi->dfs, in spi_dw_configure()
280 SPI_WORD_SIZE_GET(config->operation), spi->dfs, in spi_dw_configure()
314 struct spi_dw_data *spi) in spi_dw_update_txftlr() argument
320 if (spi_dw_is_slave(spi)) { in spi_dw_update_txftlr()
321 if (!spi->ctx.tx_len) { in spi_dw_update_txftlr()
323 } else if (spi->ctx.tx_len < dw_spi_txftlr_dflt) { in spi_dw_update_txftlr()
324 reg_data = spi->ctx.tx_len - 1; in spi_dw_update_txftlr()
342 struct spi_dw_data *spi = dev->data; in transceive() local
348 spi_context_lock(&spi->ctx, asynchronous, cb, userdata, config); in transceive()
357 ret = spi_dw_configure(dev, spi, config); in transceive()
371 !spi_dw_is_slave(spi)) { in transceive()
374 spi->dfs); in transceive()
385 if (spi_dw_is_slave(spi)) { in transceive()
402 spi_context_buffers_setup(&spi->ctx, tx_bufs, rx_bufs, spi->dfs); in transceive()
404 spi->fifo_diff = 0U; in transceive()
407 spi_dw_update_txftlr(dev, spi); in transceive()
412 if (spi_dw_is_slave(spi)) { in transceive()
413 if (spi->ctx.rx_len && in transceive()
414 spi->ctx.rx_len < dw_spi_rxftlr_dflt) { in transceive()
415 reg_data = spi->ctx.rx_len - 1; in transceive()
418 if (spi->ctx.rx_len && spi->ctx.rx_len < info->fifo_depth) { in transceive()
419 reg_data = spi->ctx.rx_len - 1; in transceive()
432 if (!spi_dw_is_slave(spi)) { in transceive()
435 spi_context_cs_control(&spi->ctx, true); in transceive()
444 ret = spi_context_wait_for_completion(&spi->ctx); in transceive()
447 if (spi_context_is_slave(&spi->ctx) && !ret) { in transceive()
448 ret = spi->ctx.recv_frames; in transceive()
453 spi_context_release(&spi->ctx, ret); in transceive()
487 struct spi_dw_data *spi = dev->data; in spi_dw_release() local
489 if (!spi_context_configured(&spi->ctx, config)) { in spi_dw_release()
493 spi_context_unlock_unconditionally(&spi->ctx); in spi_dw_release()
528 static DEVICE_API(spi, dw_spi_api) = {
543 struct spi_dw_data *spi = dev->data; in spi_dw_init() local
559 err = spi_context_cs_configure_all(&spi->ctx); in spi_dw_init()
564 spi_context_unlock_unconditionally(&spi->ctx); in spi_dw_init()