@@ -75,7 +75,7 @@ static void completed(struct device *dev, uint8_t error)
75
75
SYS_LOG_DBG ("SPI transaction completed %s error" ,
76
76
error ? "with" : "without" );
77
77
78
- spi_context_complete (& spi -> ctx );
78
+ spi_context_complete (& spi -> ctx , error ? - EIO : 0 );
79
79
}
80
80
81
81
static void push_data (struct device * dev )
@@ -250,25 +250,25 @@ static int spi_dw_configure(const struct spi_dw_config *info,
250
250
return 0 ;
251
251
}
252
252
253
- static int spi_dw_transceive (struct spi_config * config ,
254
- const struct spi_buf * * tx_bufs ,
255
- struct spi_buf * * rx_bufs )
253
+ static int transceive (struct spi_config * config ,
254
+ const struct spi_buf * * tx_bufs ,
255
+ struct spi_buf * * rx_bufs ,
256
+ bool asynchronous ,
257
+ struct k_poll_signal * signal )
256
258
{
257
259
const struct spi_dw_config * info = config -> dev -> config -> config_info ;
258
260
struct spi_dw_data * spi = config -> dev -> driver_data ;
259
261
u32_t rx_thsld = DW_SPI_RXFTLR_DFLT ;
260
262
u32_t imask = DW_SPI_IMR_UNMASK ;
261
263
int ret = 0 ;
262
264
263
- SYS_LOG_DBG ("%p, %p, %p" , config -> dev , tx_bufs , rx_bufs );
264
-
265
265
/* Check status */
266
266
if (test_bit_ssienr (info -> regs ) || test_bit_sr_busy (info -> regs )) {
267
267
SYS_LOG_DBG ("Controller is busy" );
268
268
return - EBUSY ;
269
269
}
270
270
271
- spi_context_lock (& spi -> ctx );
271
+ spi_context_lock (& spi -> ctx , asynchronous , signal );
272
272
273
273
/* Configure */
274
274
ret = spi_dw_configure (info , spi , config );
@@ -311,11 +311,32 @@ static int spi_dw_transceive(struct spi_config *config,
311
311
ret = - EIO ;
312
312
}
313
313
out :
314
- spi_context_release (& spi -> ctx );
314
+ spi_context_release (& spi -> ctx , ret );
315
315
316
316
return ret ;
317
317
}
318
318
319
+ static int spi_dw_transceive (struct spi_config * config ,
320
+ const struct spi_buf * * tx_bufs ,
321
+ struct spi_buf * * rx_bufs )
322
+ {
323
+ SYS_LOG_DBG ("%p, %p, %p" , config -> dev , tx_bufs , rx_bufs );
324
+
325
+ return transceive (config , tx_bufs , rx_bufs , false, NULL );
326
+ }
327
+
328
+ #ifdef CONFIG_POLL
329
+ static int spi_dw_transceive_async (struct spi_config * config ,
330
+ const struct spi_buf * * tx_bufs ,
331
+ struct spi_buf * * rx_bufs ,
332
+ struct k_poll_signal * async )
333
+ {
334
+ SYS_LOG_DBG ("%p, %p, %p, %p" , config -> dev , tx_bufs , rx_bufs , async );
335
+
336
+ return transceive (config , tx_bufs , rx_bufs , true, async );
337
+ }
338
+ #endif /* CONFIG_POLL */
339
+
319
340
void spi_dw_isr (struct device * dev )
320
341
{
321
342
const struct spi_dw_config * info = dev -> config -> config_info ;
@@ -349,6 +370,9 @@ void spi_dw_isr(struct device *dev)
349
370
350
371
static const struct spi_driver_api dw_spi_api = {
351
372
.transceive = spi_dw_transceive ,
373
+ #ifdef CONFIG_POLL
374
+ .transceive_async = spi_dw_transceive_async ,
375
+ #endif
352
376
};
353
377
354
378
int spi_dw_init (struct device * dev )
@@ -367,7 +391,7 @@ int spi_dw_init(struct device *dev)
367
391
368
392
SYS_LOG_DBG ("Designware SPI driver initialized on device: %p" , dev );
369
393
370
- spi_context_release (& spi -> ctx );
394
+ spi_context_release (& spi -> ctx , 0 );
371
395
372
396
return 0 ;
373
397
}
0 commit comments