diff options
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r-- | arch/arm/plat-omap/mcbsp.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c index e47686e0a633..5e6d3096c725 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/arch/arm/plat-omap/mcbsp.c | |||
@@ -561,6 +561,61 @@ u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) | |||
561 | } | 561 | } |
562 | EXPORT_SYMBOL(omap_mcbsp_get_max_rx_threshold); | 562 | EXPORT_SYMBOL(omap_mcbsp_get_max_rx_threshold); |
563 | 563 | ||
564 | #define MCBSP2_FIFO_SIZE 0x500 /* 1024 + 256 locations */ | ||
565 | #define MCBSP1345_FIFO_SIZE 0x80 /* 128 locations */ | ||
566 | /* | ||
567 | * omap_mcbsp_get_tx_delay returns the number of used slots in the McBSP FIFO | ||
568 | */ | ||
569 | u16 omap_mcbsp_get_tx_delay(unsigned int id) | ||
570 | { | ||
571 | struct omap_mcbsp *mcbsp; | ||
572 | u16 buffstat; | ||
573 | |||
574 | if (!omap_mcbsp_check_valid_id(id)) { | ||
575 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); | ||
576 | return -ENODEV; | ||
577 | } | ||
578 | mcbsp = id_to_mcbsp_ptr(id); | ||
579 | |||
580 | /* Returns the number of free locations in the buffer */ | ||
581 | buffstat = MCBSP_READ(mcbsp, XBUFFSTAT); | ||
582 | |||
583 | /* Number of slots are different in McBSP ports */ | ||
584 | if (mcbsp->id == 2) | ||
585 | return MCBSP2_FIFO_SIZE - buffstat; | ||
586 | else | ||
587 | return MCBSP1345_FIFO_SIZE - buffstat; | ||
588 | } | ||
589 | EXPORT_SYMBOL(omap_mcbsp_get_tx_delay); | ||
590 | |||
591 | /* | ||
592 | * omap_mcbsp_get_rx_delay returns the number of free slots in the McBSP FIFO | ||
593 | * to reach the threshold value (when the DMA will be triggered to read it) | ||
594 | */ | ||
595 | u16 omap_mcbsp_get_rx_delay(unsigned int id) | ||
596 | { | ||
597 | struct omap_mcbsp *mcbsp; | ||
598 | u16 buffstat, threshold; | ||
599 | |||
600 | if (!omap_mcbsp_check_valid_id(id)) { | ||
601 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); | ||
602 | return -ENODEV; | ||
603 | } | ||
604 | mcbsp = id_to_mcbsp_ptr(id); | ||
605 | |||
606 | /* Returns the number of used locations in the buffer */ | ||
607 | buffstat = MCBSP_READ(mcbsp, RBUFFSTAT); | ||
608 | /* RX threshold */ | ||
609 | threshold = MCBSP_READ(mcbsp, THRSH1); | ||
610 | |||
611 | /* Return the number of location till we reach the threshold limit */ | ||
612 | if (threshold <= buffstat) | ||
613 | return 0; | ||
614 | else | ||
615 | return threshold - buffstat; | ||
616 | } | ||
617 | EXPORT_SYMBOL(omap_mcbsp_get_rx_delay); | ||
618 | |||
564 | /* | 619 | /* |
565 | * omap_mcbsp_get_dma_op_mode just return the current configured | 620 | * omap_mcbsp_get_dma_op_mode just return the current configured |
566 | * operating mode for the mcbsp channel | 621 | * operating mode for the mcbsp channel |