]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
OMAP3: McBSP: Add interface for FIFO caused delay query
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>
Wed, 3 Mar 2010 13:08:08 +0000 (15:08 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 12 Mar 2010 11:12:25 +0000 (11:12 +0000)
New functions for querying the FIFO caused delay on both
TX and RX path.
On TX path the return value shows the number of used
locations in the FIFO.
On RX papth it returns the number of locations to be filled
to reach the threshold value (DMA will be triggered to read
the data out from the FIFO).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
arch/arm/plat-omap/include/plat/mcbsp.h
arch/arm/plat-omap/mcbsp.c

index 39748354ce455f9d0f1fcbce915d36cd0758dc13..1bd7021336c2b37b3cc9921820503c42960baec5 100644 (file)
 #define OMAP_MCBSP_REG_WAKEUPEN        0xA8
 #define OMAP_MCBSP_REG_XCCR    0xAC
 #define OMAP_MCBSP_REG_RCCR    0xB0
+#define OMAP_MCBSP_REG_XBUFFSTAT       0xB4
+#define OMAP_MCBSP_REG_RBUFFSTAT       0xB8
 #define OMAP_MCBSP_REG_SSELCR  0xBC
 
 #define OMAP_ST_REG_REV                0x00
@@ -471,6 +473,8 @@ void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
 void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
 u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
 u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
+u16 omap_mcbsp_get_tx_delay(unsigned int id);
+u16 omap_mcbsp_get_rx_delay(unsigned int id);
 int omap_mcbsp_get_dma_op_mode(unsigned int id);
 #else
 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)
 { }
 static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; }
 static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; }
+static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; }
+static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; }
 static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; }
 #endif
 int omap_mcbsp_request(unsigned int id);
index e47686e0a63369e816ed965edf153e9667c660de..5e6d3096c7253265c87a6ead2704111db210f1cf 100644 (file)
@@ -561,6 +561,61 @@ u16 omap_mcbsp_get_max_rx_threshold(unsigned int id)
 }
 EXPORT_SYMBOL(omap_mcbsp_get_max_rx_threshold);
 
+#define MCBSP2_FIFO_SIZE       0x500 /* 1024 + 256 locations */
+#define MCBSP1345_FIFO_SIZE    0x80  /* 128 locations */
+/*
+ * omap_mcbsp_get_tx_delay returns the number of used slots in the McBSP FIFO
+ */
+u16 omap_mcbsp_get_tx_delay(unsigned int id)
+{
+       struct omap_mcbsp *mcbsp;
+       u16 buffstat;
+
+       if (!omap_mcbsp_check_valid_id(id)) {
+               printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
+               return -ENODEV;
+       }
+       mcbsp = id_to_mcbsp_ptr(id);
+
+       /* Returns the number of free locations in the buffer */
+       buffstat = MCBSP_READ(mcbsp, XBUFFSTAT);
+
+       /* Number of slots are different in McBSP ports */
+       if (mcbsp->id == 2)
+               return MCBSP2_FIFO_SIZE - buffstat;
+       else
+               return MCBSP1345_FIFO_SIZE - buffstat;
+}
+EXPORT_SYMBOL(omap_mcbsp_get_tx_delay);
+
+/*
+ * omap_mcbsp_get_rx_delay returns the number of free slots in the McBSP FIFO
+ * to reach the threshold value (when the DMA will be triggered to read it)
+ */
+u16 omap_mcbsp_get_rx_delay(unsigned int id)
+{
+       struct omap_mcbsp *mcbsp;
+       u16 buffstat, threshold;
+
+       if (!omap_mcbsp_check_valid_id(id)) {
+               printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
+               return -ENODEV;
+       }
+       mcbsp = id_to_mcbsp_ptr(id);
+
+       /* Returns the number of used locations in the buffer */
+       buffstat = MCBSP_READ(mcbsp, RBUFFSTAT);
+       /* RX threshold */
+       threshold = MCBSP_READ(mcbsp, THRSH1);
+
+       /* Return the number of location till we reach the threshold limit */
+       if (threshold <= buffstat)
+               return 0;
+       else
+               return threshold - buffstat;
+}
+EXPORT_SYMBOL(omap_mcbsp_get_rx_delay);
+
 /*
  * omap_mcbsp_get_dma_op_mode just return the current configured
  * operating mode for the mcbsp channel