diff options
-rw-r--r-- | arch/arm/plat-omap/include/plat/mcbsp.h | 6 | ||||
-rw-r--r-- | arch/arm/plat-omap/mcbsp.c | 55 |
2 files changed, 61 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h index 39748354ce45..1bd7021336c2 100644 --- a/arch/arm/plat-omap/include/plat/mcbsp.h +++ b/arch/arm/plat-omap/include/plat/mcbsp.h | |||
@@ -149,6 +149,8 @@ | |||
149 | #define OMAP_MCBSP_REG_WAKEUPEN 0xA8 | 149 | #define OMAP_MCBSP_REG_WAKEUPEN 0xA8 |
150 | #define OMAP_MCBSP_REG_XCCR 0xAC | 150 | #define OMAP_MCBSP_REG_XCCR 0xAC |
151 | #define OMAP_MCBSP_REG_RCCR 0xB0 | 151 | #define OMAP_MCBSP_REG_RCCR 0xB0 |
152 | #define OMAP_MCBSP_REG_XBUFFSTAT 0xB4 | ||
153 | #define OMAP_MCBSP_REG_RBUFFSTAT 0xB8 | ||
152 | #define OMAP_MCBSP_REG_SSELCR 0xBC | 154 | #define OMAP_MCBSP_REG_SSELCR 0xBC |
153 | 155 | ||
154 | #define OMAP_ST_REG_REV 0x00 | 156 | #define OMAP_ST_REG_REV 0x00 |
@@ -471,6 +473,8 @@ void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold); | |||
471 | void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold); | 473 | void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold); |
472 | u16 omap_mcbsp_get_max_tx_threshold(unsigned int id); | 474 | u16 omap_mcbsp_get_max_tx_threshold(unsigned int id); |
473 | u16 omap_mcbsp_get_max_rx_threshold(unsigned int id); | 475 | u16 omap_mcbsp_get_max_rx_threshold(unsigned int id); |
476 | u16 omap_mcbsp_get_tx_delay(unsigned int id); | ||
477 | u16 omap_mcbsp_get_rx_delay(unsigned int id); | ||
474 | int omap_mcbsp_get_dma_op_mode(unsigned int id); | 478 | int omap_mcbsp_get_dma_op_mode(unsigned int id); |
475 | #else | 479 | #else |
476 | static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold) | 480 | static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold) |
@@ -479,6 +483,8 @@ static inline void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold) | |||
479 | { } | 483 | { } |
480 | static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; } | 484 | static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; } |
481 | static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; } | 485 | static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; } |
486 | static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; } | ||
487 | static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; } | ||
482 | static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; } | 488 | static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; } |
483 | #endif | 489 | #endif |
484 | int omap_mcbsp_request(unsigned int id); | 490 | int omap_mcbsp_request(unsigned int id); |
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 |