Lines Matching +full:sck +full:- +full:frequency
4 * SPDX-License-Identifier: Apache-2.0
31 static int spi_config(const struct device *dev, uint32_t frequency, in spi_config() argument
38 return -ENOTSUP; in spi_config()
42 return -ENOTSUP; in spi_config()
46 return -ENOTSUP; in spi_config()
49 /* Set the SPI frequency */ in spi_config()
50 div = (SPI_CFG(dev)->f_sys / (frequency * 2U)) - 1; in spi_config()
55 /* If CPOL is set, then SCK idles at logical 1 */ in spi_config()
58 /* SCK idles at logical 0 */ in spi_config()
66 * on the trailing SCK edge in spi_config()
70 /* Data is sampled on the leading SCK edge */ in spi_config()
77 return -ENOTSUP; in spi_config()
87 return -ENOTSUP; in spi_config()
129 struct spi_context *ctx = &SPI_DATA(dev)->ctx; in spi_sifive_xfer()
142 txd = *ctx->tx_buf; in spi_sifive_xfer()
156 *ctx->rx_buf = rxd; in spi_sifive_xfer()
158 queued_frames--; in spi_sifive_xfer()
165 spi_context_cs_control(&SPI_DATA(dev)->ctx, false); in spi_sifive_xfer()
179 struct spi_sifive_cfg *cfg = (struct spi_sifive_cfg *)dev->config; in spi_sifive_init()
184 err = spi_context_cs_configure_all(&SPI_DATA(dev)->ctx); in spi_sifive_init()
190 err = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in spi_sifive_init()
197 spi_context_unlock_unconditionally(&SPI_DATA(dev)->ctx); in spi_sifive_init()
210 spi_context_lock(&SPI_DATA(dev)->ctx, false, NULL, NULL, config); in spi_sifive_transceive()
213 SPI_DATA(dev)->ctx.config = config; in spi_sifive_transceive()
237 sys_write32(config->slave, SPI_REG(dev, REG_CSID)); in spi_sifive_transceive()
241 rc = spi_config(dev, config->frequency, config->operation); in spi_sifive_transceive()
243 spi_context_release(&SPI_DATA(dev)->ctx, rc); in spi_sifive_transceive()
247 spi_context_buffers_setup(&SPI_DATA(dev)->ctx, tx_bufs, rx_bufs, 1); in spi_sifive_transceive()
251 spi_context_cs_control(&SPI_DATA(dev)->ctx, true); in spi_sifive_transceive()
259 rc = spi_context_wait_for_completion(&SPI_DATA(dev)->ctx); in spi_sifive_transceive()
261 spi_context_release(&SPI_DATA(dev)->ctx, rc); in spi_sifive_transceive()
269 spi_context_unlock_unconditionally(&SPI_DATA(dev)->ctx); in spi_sifive_release()