Lines Matching +full:operation +full:- +full:mode

4  * SPDX-License-Identifier: Apache-2.0
41 const struct spi_cc13xx_cc26xx_config *cfg = dev->config; in spi_cc13xx_cc26xx_configure()
42 struct spi_cc13xx_cc26xx_data *data = dev->data; in spi_cc13xx_cc26xx_configure()
43 struct spi_context *ctx = &data->ctx; in spi_cc13xx_cc26xx_configure()
51 if (config->operation & SPI_HALF_DUPLEX) { in spi_cc13xx_cc26xx_configure()
52 LOG_ERR("Half-duplex not supported"); in spi_cc13xx_cc26xx_configure()
53 return -ENOTSUP; in spi_cc13xx_cc26xx_configure()
56 /* Slave mode has not been implemented */ in spi_cc13xx_cc26xx_configure()
57 if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) { in spi_cc13xx_cc26xx_configure()
58 LOG_ERR("Slave mode is not supported"); in spi_cc13xx_cc26xx_configure()
59 return -ENOTSUP; in spi_cc13xx_cc26xx_configure()
63 if (SPI_WORD_SIZE_GET(config->operation) != 8) { in spi_cc13xx_cc26xx_configure()
65 return -ENOTSUP; in spi_cc13xx_cc26xx_configure()
68 if (config->operation & SPI_TRANSFER_LSB) { in spi_cc13xx_cc26xx_configure()
69 LOG_ERR("Transfer LSB first mode is not supported"); in spi_cc13xx_cc26xx_configure()
70 return -EINVAL; in spi_cc13xx_cc26xx_configure()
74 (config->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) { in spi_cc13xx_cc26xx_configure()
76 return -EINVAL; in spi_cc13xx_cc26xx_configure()
79 if (config->operation & SPI_CS_ACTIVE_HIGH && !spi_cs_is_gpio(config)) { in spi_cc13xx_cc26xx_configure()
81 return -EINVAL; in spi_cc13xx_cc26xx_configure()
84 if (config->frequency < 2000000) { in spi_cc13xx_cc26xx_configure()
86 return -EINVAL; in spi_cc13xx_cc26xx_configure()
89 if (2 * config->frequency > CPU_FREQ) { in spi_cc13xx_cc26xx_configure()
90 LOG_ERR("Frequency greater than supported in master mode"); in spi_cc13xx_cc26xx_configure()
91 return -EINVAL; in spi_cc13xx_cc26xx_configure()
94 if (SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) { in spi_cc13xx_cc26xx_configure()
95 if (SPI_MODE_GET(config->operation) & SPI_MODE_CPHA) { in spi_cc13xx_cc26xx_configure()
101 if (SPI_MODE_GET(config->operation) & SPI_MODE_CPHA) { in spi_cc13xx_cc26xx_configure()
108 ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in spi_cc13xx_cc26xx_configure()
114 ctx->config = config; in spi_cc13xx_cc26xx_configure()
117 SSIDisable(cfg->base); in spi_cc13xx_cc26xx_configure()
120 SSIConfigSetExpClk(cfg->base, CPU_FREQ, prot, in spi_cc13xx_cc26xx_configure()
121 SSI_MODE_MASTER, config->frequency, 8); in spi_cc13xx_cc26xx_configure()
123 if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) { in spi_cc13xx_cc26xx_configure()
124 sys_set_bit(cfg->base + SSI_O_CR1, 0); in spi_cc13xx_cc26xx_configure()
127 /* Re-enable SSI after making configuration changes */ in spi_cc13xx_cc26xx_configure()
128 SSIEnable(cfg->base); in spi_cc13xx_cc26xx_configure()
138 const struct spi_cc13xx_cc26xx_config *cfg = dev->config; in spi_cc13xx_cc26xx_transceive()
139 struct spi_cc13xx_cc26xx_data *data = dev->data; in spi_cc13xx_cc26xx_transceive()
140 struct spi_context *ctx = &data->ctx; in spi_cc13xx_cc26xx_transceive()
158 txd = *ctx->tx_buf; in spi_cc13xx_cc26xx_transceive()
163 SSIDataPut(cfg->base, txd); in spi_cc13xx_cc26xx_transceive()
167 SSIDataGet(cfg->base, &rxd); in spi_cc13xx_cc26xx_transceive()
170 *ctx->rx_buf = rxd; in spi_cc13xx_cc26xx_transceive()
187 const struct spi_cc13xx_cc26xx_config *cfg = dev->config; in spi_cc13xx_cc26xx_release()
188 struct spi_cc13xx_cc26xx_data *data = dev->data; in spi_cc13xx_cc26xx_release()
189 struct spi_context *ctx = &data->ctx; in spi_cc13xx_cc26xx_release()
192 return -EINVAL; in spi_cc13xx_cc26xx_release()
195 if (SSIBusy(cfg->base)) { in spi_cc13xx_cc26xx_release()
196 return -EBUSY; in spi_cc13xx_cc26xx_release()
208 const struct spi_cc13xx_cc26xx_config *config = dev->config; in spi_cc13xx_cc26xx_pm_action()
212 if (config->base == DT_INST_REG_ADDR(0)) { in spi_cc13xx_cc26xx_pm_action()
219 SSIDisable(config->base); in spi_cc13xx_cc26xx_pm_action()
223 if (config->base == DT_INST_REG_ADDR(0)) { in spi_cc13xx_cc26xx_pm_action()
230 return -ENOTSUP; in spi_cc13xx_cc26xx_pm_action()
304 struct spi_cc13xx_cc26xx_data *data = dev->data; \
308 err = spi_context_cs_configure_all(&data->ctx); \
313 spi_context_unlock_unconditionally(&data->ctx); \