@@ -41,6 +41,8 @@ LOG_MODULE_REGISTER(spi_dw);
41
41
#include <zephyr/drivers/pinctrl.h>
42
42
#endif
43
43
44
+ #define DW_HSSI_VER_102A (0x3130322a)
45
+
44
46
static inline bool spi_dw_is_slave (struct spi_dw_data * spi )
45
47
{
46
48
return (IS_ENABLED (CONFIG_SPI_SLAVE ) &&
@@ -213,6 +215,7 @@ static int spi_dw_configure(const struct device *dev,
213
215
214
216
if ((config -> operation & SPI_TRANSFER_LSB ) ||
215
217
(IS_ENABLED (CONFIG_SPI_EXTENDED_MODES ) &&
218
+ !IS_ENABLED (CONFIG_SPI_DW_HSSI ) &&
216
219
(config -> operation & (SPI_LINES_DUAL |
217
220
SPI_LINES_QUAD | SPI_LINES_OCTAL )))) {
218
221
LOG_ERR ("Unsupported configuration" );
@@ -248,6 +251,23 @@ static int spi_dw_configure(const struct device *dev,
248
251
ctrlr0 |= DW_SPI_CTRLR0_SRL ;
249
252
}
250
253
254
+ #if defined(CONFIG_SPI_DW_HSSI ) && defined(CONFIG_SPI_EXTENDED_MODES )
255
+ if (spi -> version >= DW_HSSI_VER_102A ) {
256
+ /* SPI frame format for Tx/Rx data */
257
+ switch (SPI_LINES_GET (config -> operation )) {
258
+ case SPI_LINES_DUAL :
259
+ ctrlr0 |= DW_SPI_CTRLR0_SPI_DUAL ;
260
+ break ;
261
+ case SPI_LINES_QUAD :
262
+ ctrlr0 |= DW_SPI_CTRLR0_SPI_QUAD ;
263
+ break ;
264
+ case SPI_LINES_OCTAL :
265
+ ctrlr0 |= DW_SPI_CTRLR0_SPI_OCTAL ;
266
+ break ;
267
+ }
268
+ }
269
+ #endif
270
+
251
271
/* Installing the configuration */
252
272
write_ctrlr0 (dev , ctrlr0 );
253
273
@@ -410,6 +430,23 @@ static int transceive(const struct device *dev,
410
430
411
431
write_ctrlr0 (dev , reg_data );
412
432
433
+ #if defined(CONFIG_SPI_DW_HSSI ) && defined(CONFIG_SPI_EXTENDED_MODES )
434
+ if (spi -> version >= DW_HSSI_VER_102A ) {
435
+ /* Enhanced SPI operation */
436
+ reg_data = read_spi_ctrlr0 (dev );
437
+ reg_data &= ~DW_SPI_ESPI_CTRLR0_TRANS_TYPE_MASK ;
438
+ reg_data |= FIELD_PREP (DW_SPI_ESPI_CTRLR0_TRANS_TYPE_MASK ,
439
+ SPI_TRANS_TYPE_FIELD_GET (config -> operation ));
440
+ reg_data &= ~DW_SPI_ESPI_CTRLR0_ADDR_L_MASK ;
441
+ reg_data |= FIELD_PREP (DW_SPI_ESPI_CTRLR0_ADDR_L_MASK ,
442
+ SPI_ADDR_L_FIELD_GET (config -> operation ));
443
+ reg_data &= ~DW_SPI_ESPI_CTRLR0_INST_L_MASK ;
444
+ reg_data |= FIELD_PREP (DW_SPI_ESPI_CTRLR0_INST_L_MASK ,
445
+ SPI_INST_L_FIELD_GET (config -> operation ));
446
+ write_spi_ctrlr0 (dev , reg_data );
447
+ }
448
+ #endif
449
+
413
450
/* Set buffers info */
414
451
spi_context_buffers_setup (& spi -> ctx , tx_bufs , rx_bufs , spi -> dfs );
415
452
0 commit comments