@@ -654,6 +654,17 @@ static u32 ux500v2_get_dctrl_cfg(struct mmci_host *host)
654654 return MCI_DPSM_ENABLE | (host -> data -> blksz << 16 );
655655}
656656
657+ static void ux500_busy_clear_mask_done (struct mmci_host * host )
658+ {
659+ void __iomem * base = host -> base ;
660+
661+ writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
662+ writel (readl (base + MMCIMASK0 ) &
663+ ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
664+ host -> busy_state = MMCI_BUSY_DONE ;
665+ host -> busy_status = 0 ;
666+ }
667+
657668/*
658669 * ux500_busy_complete() - this will wait until the busy status
659670 * goes off, saving any status that occur in the meantime into
@@ -678,11 +689,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
678689
679690 if (status & err_msk ) {
680691 /* Stop any ongoing busy detection if an error occurs */
681- writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
682- writel (readl (base + MMCIMASK0 ) &
683- ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
684- host -> busy_state = MMCI_BUSY_DONE ;
685- host -> busy_status = 0 ;
692+ ux500_busy_clear_mask_done (host );
686693 goto out_ret_state ;
687694 }
688695
@@ -724,10 +731,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
724731 retries -- ;
725732 }
726733 dev_dbg (mmc_dev (host -> mmc ), "no busy signalling in time\n" );
727- writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
728- writel (readl (base + MMCIMASK0 ) &
729- ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
730- host -> busy_state = MMCI_BUSY_DONE ;
734+ ux500_busy_clear_mask_done (host );
731735 break ;
732736
733737 /*
@@ -749,18 +753,15 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
749753 } else {
750754 dev_dbg (mmc_dev (host -> mmc ),
751755 "lost busy status when waiting for busy start IRQ\n" );
752- writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
753- writel (readl (base + MMCIMASK0 ) &
754- ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
755- host -> busy_state = MMCI_BUSY_DONE ;
756- host -> busy_status = 0 ;
756+ ux500_busy_clear_mask_done (host );
757757 }
758758 break ;
759759
760760 case MMCI_BUSY_WAITING_FOR_END_IRQ :
761761 if (!(status & host -> variant -> busy_detect_flag )) {
762762 host -> busy_status |= status & (MCI_CMDSENT | MCI_CMDRESPEND );
763- host -> busy_state = MMCI_BUSY_DONE ;
763+ writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
764+ ux500_busy_clear_mask_done (host );
764765 } else {
765766 dev_dbg (mmc_dev (host -> mmc ),
766767 "busy status still asserted when handling busy end IRQ - will keep waiting\n" );
0 commit comments