Lines Matching +full:spi +full:- +full:half +full:- +full:duplex

4  * SPDX-License-Identifier: Apache-2.0
44 const struct spi_litex_dev_config *dev_config = dev->config; in spi_litex_set_frequency()
46 if (!dev_config->phy_clk_divisor_exists) { in spi_litex_set_frequency()
52 uint32_t divisor = DIV_ROUND_UP(sys_clock_hw_cycles_per_sec(), (2 * config->frequency)) - 1; in spi_litex_set_frequency()
54 litex_write32(divisor, dev_config->phy_clk_divisor_addr); in spi_litex_set_frequency()
61 struct spi_litex_data *dev_data = dev->data; in spi_config()
63 if (config->slave != 0) { in spi_config()
64 if (config->slave >= SPI_MAX_CS_SIZE) { in spi_config()
66 return -ENOTSUP; in spi_config()
70 if (config->operation & SPI_HALF_DUPLEX) { in spi_config()
71 LOG_ERR("Half-duplex not supported"); in spi_config()
72 return -ENOTSUP; in spi_config()
75 if (SPI_WORD_SIZE_GET(config->operation) > SPI_MAX_WORD_SIZE) { in spi_config()
77 SPI_WORD_SIZE_GET(config->operation)); in spi_config()
78 return -ENOTSUP; in spi_config()
81 if (config->operation & SPI_CS_ACTIVE_HIGH) { in spi_config()
83 return -ENOTSUP; in spi_config()
86 if (config->operation & SPI_LOCK_ON) { in spi_config()
88 return -ENOTSUP; in spi_config()
92 (config->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) { in spi_config()
94 return -ENOTSUP; in spi_config()
97 if (config->operation & SPI_TRANSFER_LSB) { in spi_config()
99 return -ENOTSUP; in spi_config()
102 if (config->operation & (SPI_MODE_CPOL | SPI_MODE_CPHA)) { in spi_config()
104 return -ENOTSUP; in spi_config()
107 if (config->operation & SPI_OP_MODE_SLAVE) { in spi_config()
109 return -ENOTSUP; in spi_config()
112 if (config->operation & SPI_MODE_LOOP) { in spi_config()
114 return -ENOTSUP; in spi_config()
117 dev_data->dfs = get_dfs_value(config); in spi_config()
139 const struct spi_litex_dev_config *dev_config = dev->config; in spi_litex_xfer()
140 struct spi_litex_data *data = dev->data; in spi_litex_xfer()
141 struct spi_context *ctx = &data->ctx; in spi_litex_xfer()
145 uint8_t len = data->dfs; /* SPI Xfer length*/ in spi_litex_xfer()
146 uint8_t old_len = len; /* old SPI Xfer length*/ in spi_litex_xfer()
147 uint8_t width = BIT(0); /* SPI Xfer width*/ in spi_litex_xfer()
148 uint8_t mask = BIT(0); /* SPI Xfer mask*/ in spi_litex_xfer()
150 spiflash_len_mask_width_write(len * 8, width, mask, dev_config->core_master_phyconfig_addr); in spi_litex_xfer()
152 litex_write32(BIT(config->slave), dev_config->core_master_cs_addr); in spi_litex_xfer()
155 while ((litex_read8(dev_config->core_master_status_addr) & in spi_litex_xfer()
157 rxd = litex_read32(dev_config->core_master_rxtx_addr); in spi_litex_xfer()
162 len = MIN(spi_context_max_continuous_chunk(ctx), dev_config->core_master_rxtx_size); in spi_litex_xfer()
165 dev_config->core_master_phyconfig_addr); in spi_litex_xfer()
170 litex_spi_tx_put(len, &txd, ctx->tx_buf); in spi_litex_xfer()
175 while (!(litex_read8(dev_config->core_master_status_addr) & in spi_litex_xfer()
181 litex_write32(txd, dev_config->core_master_rxtx_addr); in spi_litex_xfer()
183 spi_context_update_tx(ctx, data->dfs, len / data->dfs); in spi_litex_xfer()
185 while (!(litex_read8(dev_config->core_master_status_addr) & in spi_litex_xfer()
190 rxd = litex_read32(dev_config->core_master_rxtx_addr); in spi_litex_xfer()
194 litex_spi_rx_put(len, &rxd, ctx->rx_buf); in spi_litex_xfer()
197 spi_context_update_rx(ctx, data->dfs, len / data->dfs); in spi_litex_xfer()
201 litex_write32(0, dev_config->core_master_cs_addr); in spi_litex_xfer()
212 struct spi_litex_data *data = dev->data; in spi_litex_transceive()
224 spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, data->dfs); in spi_litex_transceive()
237 return -ENOTSUP; in spi_litex_transceive_async()
248 static DEVICE_API(spi, spi_litex_api) = {