98
98
99
99
#define MMCSD_CAPACITY (b , s ) ((s) >= 10 ? (b) << ((s) - 10) : (b) >> (10 - (s)))
100
100
101
+ #define MMCSD_USLEEP (usec ) \
102
+ do \
103
+ { \
104
+ if (up_interrupt_context()) \
105
+ { \
106
+ up_udelay(usec); \
107
+ } \
108
+ else \
109
+ { \
110
+ nxsig_usleep(usec); \
111
+ } \
112
+ } while (0)
113
+
101
114
/****************************************************************************
102
115
* Private Types
103
116
****************************************************************************/
@@ -336,12 +349,12 @@ static inline int mmcsd_sendcmd4(FAR struct mmcsd_state_s *priv)
336
349
*/
337
350
338
351
mmcsd_sendcmdpoll (priv , MMCSD_CMD4 , CONFIG_MMCSD_DSR << 16 );
339
- nxsig_usleep (MMCSD_DSR_DELAY );
352
+ MMCSD_USLEEP (MMCSD_DSR_DELAY );
340
353
341
354
/* Send it again to have more confidence */
342
355
343
356
mmcsd_sendcmdpoll (priv , MMCSD_CMD4 , CONFIG_MMCSD_DSR << 16 );
344
- nxsig_usleep (MMCSD_DSR_DELAY );
357
+ MMCSD_USLEEP (MMCSD_DSR_DELAY );
345
358
}
346
359
else
347
360
{
@@ -1305,7 +1318,7 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv)
1305
1318
1306
1319
sched_yield ();
1307
1320
#else
1308
- nxsig_usleep (1000 );
1321
+ MMCSD_USLEEP (1000 );
1309
1322
#endif
1310
1323
1311
1324
/* We are still in the programming state. Calculate the elapsed
@@ -2595,7 +2608,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
2595
2608
SDIO_WIDEBUS (priv -> dev , false);
2596
2609
priv -> widebus = false;
2597
2610
SDIO_CLOCK (priv -> dev , CLOCK_SDIO_DISABLED );
2598
- nxsig_usleep (MMCSD_CLK_DELAY );
2611
+ MMCSD_USLEEP (MMCSD_CLK_DELAY );
2599
2612
2600
2613
return OK ;
2601
2614
}
@@ -2656,7 +2669,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
2656
2669
}
2657
2670
#endif /* #ifdef CONFIG_MMCSD_MMCSUPPORT */
2658
2671
2659
- nxsig_usleep (MMCSD_CLK_DELAY );
2672
+ MMCSD_USLEEP (MMCSD_CLK_DELAY );
2660
2673
return OK ;
2661
2674
}
2662
2675
@@ -3450,7 +3463,7 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv)
3450
3463
/* Select high speed SD clocking (which may depend on the DSR setting) */
3451
3464
3452
3465
SDIO_CLOCK (priv -> dev , CLOCK_SD_TRANSFER_1BIT );
3453
- nxsig_usleep (MMCSD_CLK_DELAY );
3466
+ MMCSD_USLEEP (MMCSD_CLK_DELAY );
3454
3467
3455
3468
/* If the hardware only supports 4-bit transfer mode then we forced to
3456
3469
* attempt to setup the card in this mode before checking the SCR register.
@@ -3547,7 +3560,7 @@ static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv)
3547
3560
*/
3548
3561
3549
3562
mmcsd_sendcmdpoll (priv , MMCSD_CMD0 , 0xf0f0f0f0 );
3550
- nxsig_usleep (MMCSD_IDLE_DELAY );
3563
+ MMCSD_USLEEP (MMCSD_IDLE_DELAY );
3551
3564
3552
3565
/* After power up at least 74 clock cycles are required prior to starting
3553
3566
* bus communication
@@ -3558,7 +3571,7 @@ static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv)
3558
3571
/* Then send CMD0 just once is standard procedure */
3559
3572
3560
3573
mmcsd_sendcmdpoll (priv , MMCSD_CMD0 , 0 );
3561
- nxsig_usleep (MMCSD_IDLE_DELAY );
3574
+ MMCSD_USLEEP (MMCSD_IDLE_DELAY );
3562
3575
3563
3576
#ifdef CONFIG_MMCSD_MMCSUPPORT
3564
3577
/* Send CMD1 which is supported only by MMC. if there is valid response
@@ -3580,7 +3593,7 @@ static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv)
3580
3593
*/
3581
3594
3582
3595
mmcsd_sendcmdpoll (priv , MMCSD_CMD0 , 0 );
3583
- nxsig_usleep (MMCSD_IDLE_DELAY );
3596
+ MMCSD_USLEEP (MMCSD_IDLE_DELAY );
3584
3597
}
3585
3598
else
3586
3599
{
0 commit comments